Scripting Help (Solved)
Moderator: Moderators
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Scripting Help (Solved)
I need some scripting help. I've managed to make a few basic timers, but I'm having trouble making the three main things I need.
1. Making players unable to switch teams
2. Making players unable to respawn when they die (and ending the game if everyone on that team dies)
3. Making players take damage every time they fire and do not hit an enemy
The last one is definitely going to be the hardest and I have no clue on how to start that one. These all need to be multiplayer compatible because the game mode will be built for multiplayer.
I've tried to do #2 with timers that check every second for units or people alive on a team and then setting the reinforcement count to that number but that didn't work.
1. Making players unable to switch teams
2. Making players unable to respawn when they die (and ending the game if everyone on that team dies)
3. Making players take damage every time they fire and do not hit an enemy
The last one is definitely going to be the hardest and I have no clue on how to start that one. These all need to be multiplayer compatible because the game mode will be built for multiplayer.
I've tried to do #2 with timers that check every second for units or people alive on a team and then setting the reinforcement count to that number but that didn't work.
Last edited by Noobasaurus on Mon Apr 07, 2014 8:25 pm, edited 1 time in total.
- Locutus
- 1st Lieutenant

- Posts: 420
- Joined: Fri Jun 04, 2010 10:08 am
- Projects :: Stargate Battlefront Pegasus
- Location: Germany
- Contact:
Re: Scripting Help
You could use a timer killing the spawn cp or alternatively manually spawn the players via script without using a CP at all. (See i.e. Zerteds King of the Hill script)Noobasaurus wrote:2. Making players unable to respawn when they die
Are you displaying points in your mode?Noobasaurus wrote:(and ending the game if everyone on that team dies)
If yes, simply use:
Code: Select all
if GetTeamPoints(1) <= 0 then
MissionVictory(2)
elseif GetTeamPoints(2) <= 0 then
MissionVictory(1)
endCode: Select all
if GetNumTeamMembersAlive(1) <= 0 then
MissionVictory(2)
else --...-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Scripting Help
Off-topic-ish: Do you have the script on-hand?Locutus wrote:(See i.e. Zerteds King of the Hill script)
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Re: Scripting Help
Thanks Loctus. I was using GetNumTeamMembersAlive() before but I was having problems. Now it seems that it's working pretty well and I'm getting pretty close to cracking this part. I'm just having trouble right now with syncing the two alive checks for both teams. I'll probably try to set one to a variable and then use that.
Now the making players unable to spawn after death needs to be on a per player basis...oh wait. After everyone spawns, I could just destroy the spawn paths. Another timer will probably do the trick.
Now the making players unable to spawn after death needs to be on a per player basis...oh wait. After everyone spawns, I could just destroy the spawn paths. Another timer will probably do the trick.
- Locutus
- 1st Lieutenant

- Posts: 420
- Joined: Fri Jun 04, 2010 10:08 am
- Projects :: Stargate Battlefront Pegasus
- Location: Germany
- Contact:
Re: Scripting Help
Marth8880 wrote:Off-topic-ish: Do you have the script on-hand?Locutus wrote:(See i.e. Zerteds King of the Hill script)His site is down (again [as usual]). Thanks.
Hidden/Spoiler:
I have also made a complete backup of the page. It's not the most recent but if you need sth. else from him you should find it there. Just unzip and open the index.html in your browser
https://www.dropbox.com/s/t7v8f8e5s7pvq6x/Zerted.7z
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Scripting Help
Do you want it to be teams or free for all? If FFA, you could do this:Noobasaurus wrote:1. Making players unable to switch teams
2. Making players unable to respawn when they die (and ending the game if everyone on that team dies)
Code: Select all
SetTeamAsEnemy(1, 1)
SetTeamAsEnemy(2, 2)
SetTeamAsEnemy(3, 3)Code: Select all
SetProperty("cpName", "Team", 0)You might be able to get around this by setting "PercievedTeam" to 0 in addition to "Team". I haven't tried this yet though, so I don't know. Let me know if it works!
As for changing teams, just set teams to Auto Assign.
I'm not sure about this one. If your map is indoors, you could make all the objects destructable, then in your Lua use "OnObjectDamage" and if the object isn't a person, then damage the shooter.Noobasaurus wrote:3. Making players take damage every time they fire and do not hit an enemy
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Scripting Help
That's a backup of this site which is almost always online since it's hosted by my school and not from a laptop sitting on my dresser. It's also very outdated, but better than nothing.Locutus wrote:I have also made a complete backup of the page. It's not the most recent but if you need sth. else from him you should find it there. Just unzip and open the index.html in your browser
https://www.dropbox.com/s/t7v8f8e5s7pvq6x/Zerted.7z
Edit:
For 3 you can cover the map with specific objects. Whenever a player damages one of these objects, they didn't hit a player (or they used something that exploded).
A different way would be to always damage units, but give them health anytime they hit another player.
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Re: Scripting Help
Thanks for the responses everyone. 1 will be basically the same as 2, since I can just disable the spawn points once everyone spawns. That brings up my next problem. My timers are having trouble computing the concept of "every 2 seconds, check if people are alive on both teams, and if true, disable spawn points and if false, reset the timer and try again." Here's what I have.
Unfortunately, when I get in game this code messes up some other code and I instantly get a victory. In the debug log it simply states:
So it basically says there is a problem with one of my timers. I'm nearly certain it's this one because everything else was working fine before I implemented this. Now do I even need a timer to perform a continuous check? Or can I just have it out in the open?
Onto 3...Well, if there was a function that checked if a bullet hit a unit then I could use that (~=), but I don't think that function exists. Number 3 isn't essential to my mod, but it'd be great to have it. Unfortunately I cannot cover the map in objects as I am using stock maps and I want them to be the same way when people played vanilla SWBF2.
Code: Select all
OnTimerElapse(
function(timer)
ShowTimer(nil)
if GetNumTeamMembersAlive(2) >= 1 and GetNumTeamMembersAlive(1) >= 1 then
DestroyTimer(timer)
SetProperty("CP1", "SpawnPath", "")
SetProperty("CP2", "SpawnPath", "")
SetProperty("CP3", "SpawnPath", "")
SetProperty("CP4", "SpawnPath", "")
SetProperty("CP5", "SpawnPath", "")
SetProperty("CP6", "SpawnPath", "")
dead = CreateTimer("dead")
SetTimerValue(dead, 2)
StartTimer(dead)
end
SetTimerValue(alive, 3)
StartTimer(alive)
end,
alive
)Code: Select all
Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #2 to `OnTimerElapse' (string expected, got nil)
stack traceback:
[C]: in function `OnTimerElapse'
(none): in function `ScriptPostLoad'Onto 3...Well, if there was a function that checked if a bullet hit a unit then I could use that (~=), but I don't think that function exists. Number 3 isn't essential to my mod, but it'd be great to have it. Unfortunately I cannot cover the map in objects as I am using stock maps and I want them to be the same way when people played vanilla SWBF2.
How would I do this? Is it on a per-bullet basis, where every time a bullet hits they get/lose health?[RDH]Zerted wrote:but give them health anytime they hit another player.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Scripting Help
This is happening because you're creating the timer inside the elapse function of the other timer. When the elapse function is complete, any new variables created inside it will disappear.Noobasaurus wrote:Code: Select all
Message Severity: 3 C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312) CallProc failed: bad argument #2 to `OnTimerElapse' (string expected, got nil) stack traceback: [C]: in function `OnTimerElapse' (none): in function `ScriptPostLoad'
So put this line:
Code: Select all
dead = CreateTimer("dead")Hidden/Spoiler:
The function is OnObjectDamage(object, damager). The "object" parameter can be an object or a player's unit.Noobasaurus wrote:Onto 3...Well, if there was a function that checked if a bullet hit a unit then I could use that (~=), but I don't think that function exists.
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Re: Scripting Help
Well, I tried using OnObjectDamage but since I'm bad, nothing worked.
I tried what you posted and it worked fine, but then I did a bunch of other stuff.
----------------------------------------
EDIT: I think I found the problem.
EDIT2: I solved the problem. It was in the setting up timers part.
EDIT3: Is there any way to automatically disable nametags in multiplayer? I know you can do it when setting up a server but I want it to be automatically disabled.
I tried what you posted and it worked fine, but then I did a bunch of other stuff.
----------------------------------------
EDIT: I think I found the problem.
EDIT2: I solved the problem. It was in the setting up timers part.
EDIT3: Is there any way to automatically disable nametags in multiplayer? I know you can do it when setting up a server but I want it to be automatically disabled.
