Hunger Games Scripting
Moderator: Moderators
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Hunger Games Scripting
Hey everyone, I'm currently working on making a map that will be used for playing online battlefront Hunger Games. I've played several rounds with friends and it works fine but I'd like things to be a bit more automated. I want to make a mission script that will do all the timing/lua commands for me so that I'll be able to play this map on a PC dedi server without having to use fake console.Here's what I want it to do:
1. Wait until all humans that are spawned in/alive are in a region in the center of the map (there will be no bots.)
2. Once they all stay in the region for 10 seconds, they will be frozen in place for a few moments while a few messages pop up.
3. There will be a countdown, after which there will be a 30 second period where everyone runs out from the center and goes wherever, but they're not allowed to shoot or follow other people.
4. After the 30 seconds, the Games begin. At this point I usually use the Fake console command Enemies Teams 1<>1 2<>2 3<>3 so that teams wont matter and nobody can spawn back in after they've already been eliminated.
5. Once there is only 1 person remaining alive, the round is over, everything is reset, and the mission starts over from step 1.
I'm still a beginner at lua scripting, but I'm familiar with programming in general, and I've skimmed through the mission scripts for Repsharpshooter's Battle Arena 2.0. If you have any ideas or recommendations as to what functions to use where, please do contribute!
EDIT 3/12/14: Here's where I'm at right now: With the lua, I've got most of my objectives working, but it crashes in MP. A wierd quirk is that with my first objective (GoTo), if I complete it as CIS, it will complete the objective and go to the next one, but if I complete it as Republic, it will complete the objective then I get mission victory and the game ends. I also need to get my shield powerups working. My lua is posted below.
Sounds: The sides are missing a lot of sounds, including blaster pistol shot, walking, weapon change sounds for some weapons. Environmental sounds won't work either. I DID get the main global amb to work one time, but the next time I munged, it went away.
Thanks,
Kfm
1. Wait until all humans that are spawned in/alive are in a region in the center of the map (there will be no bots.)
2. Once they all stay in the region for 10 seconds, they will be frozen in place for a few moments while a few messages pop up.
3. There will be a countdown, after which there will be a 30 second period where everyone runs out from the center and goes wherever, but they're not allowed to shoot or follow other people.
4. After the 30 seconds, the Games begin. At this point I usually use the Fake console command Enemies Teams 1<>1 2<>2 3<>3 so that teams wont matter and nobody can spawn back in after they've already been eliminated.
5. Once there is only 1 person remaining alive, the round is over, everything is reset, and the mission starts over from step 1.
I'm still a beginner at lua scripting, but I'm familiar with programming in general, and I've skimmed through the mission scripts for Repsharpshooter's Battle Arena 2.0. If you have any ideas or recommendations as to what functions to use where, please do contribute!
EDIT 3/12/14: Here's where I'm at right now: With the lua, I've got most of my objectives working, but it crashes in MP. A wierd quirk is that with my first objective (GoTo), if I complete it as CIS, it will complete the objective and go to the next one, but if I complete it as Republic, it will complete the objective then I get mission victory and the game ends. I also need to get my shield powerups working. My lua is posted below.
Sounds: The sides are missing a lot of sounds, including blaster pistol shot, walking, weapon change sounds for some weapons. Environmental sounds won't work either. I DID get the main global amb to work one time, but the next time I munged, it went away.
Thanks,
Kfm
Last edited by LRKfm946 on Wed Mar 12, 2014 12:08 pm, edited 2 times in total.
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Re: Hunger Games Scripting
For your scripting, I'd recommend looking through the stock scripts. This way, you can get an idea of all the functions and how they work. If you need to find any specific ones, they're all listed here.
And of course, if something goes wrong with the script, you can post the problem here.
And of course, if something goes wrong with the script, you can post the problem here.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
Does anyone have a solution to the health/ammo droid issue?
-
MileHighGuy
- Jedi

- Posts: 1194
- Joined: Fri Dec 19, 2008 7:58 pm
Re: Hunger Games Scripting
You should make the droids into automated turrets that fire health and and ammo.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
I like that idea, and I could totally do it. I just need to figure out how to get the changes to work ingame. I modified the droids' odfs but the changes didn't show up. I'm assuming it's some Lua code that I have to add in to the mission scripts but I don't know what the code is.
I'm also thinking of using the method Repsharpshooter used in Battle Arena 2.0 wave mode where the health/ammo packs would periodically spawn at path nodes. It'll be harder, but probably more effective and more realistic because you'd have to search for the packs as opposed to just going to the droids.
I'm also thinking of using the method Repsharpshooter used in Battle Arena 2.0 wave mode where the health/ammo packs would periodically spawn at path nodes. It'll be harder, but probably more effective and more realistic because you'd have to search for the packs as opposed to just going to the droids.
- [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: Hunger Games Scripting
1+2+3) It might be easier to have an impassable wall all around the center of the map. Then when you want the game to begin, the wall moves down under the ground and/or disappears.
3) Setting all teams to be friends of each other will prevent units from hurting each other if team damage is off.
4) The code from that command is:
What you want to do is all possible.
3) Setting all teams to be friends of each other will prevent units from hurting each other if team damage is off.
4) The code from that command is:
Code: Select all
SetTeamAsEnemy(1, 1)
SetTeamAsEnemy(2, 2)
SetTeamAsEnemy(3, 3)-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
That's a great idea, unfortunately ZE doesn't work on my computer so I can't edit worlds. This means I'm stuck with using maps that have already been made and making a new mission script for them. Therefore adding any objects, regions, etc. wont be possible.
I do like the idea of turning friendly fire off and making all teams friends though, it's much more effective at controlling players before the match starts. The other alternative would be locking weapons until the games start. Is there a function for that? Another huge thing I wanted to do was deplete the ammo from every weapon at the beginning of each round. Is it possible to make units spawn without ammo?
I'm also thinking efore a round starts, teleport all players to some position or region in the middle of the map (if that's possible) and hold them there. What are the functions that affect player position?
I do like the idea of turning friendly fire off and making all teams friends though, it's much more effective at controlling players before the match starts. The other alternative would be locking weapons until the games start. Is there a function for that? Another huge thing I wanted to do was deplete the ammo from every weapon at the beginning of each round. Is it possible to make units spawn without ammo?
I'm also thinking efore a round starts, teleport all players to some position or region in the middle of the map (if that's possible) and hold them there. What are the functions that affect player position?
- Locutus
- 1st Lieutenant

- Posts: 420
- Joined: Fri Jun 04, 2010 10:08 am
- Projects :: Stargate Battlefront Pegasus
- Location: Germany
- Contact:
Re: Hunger Games Scripting
I never tried spawning ammo packs but I believe you could do it like this:LRKfm946 wrote:I'm also thinking of using the method Repsharpshooter used in Battle Arena 2.0 wave mode where the health/ammo packs would periodically spawn at path nodes. It'll be harder, but probably more effective and more realistic because you'd have to search for the packs as opposed to just going to the droids.
Code: Select all
--get the path point
Ammo1Spawn = GetPathPoint("YourPath", 0) --GetPathPoint(Pathname, node)
--spawn powerup
CreateEntity("com_item_powerup_dual", Ammo1Spawn, "ammo1") --CreateEntity(class, node, name)
Technically, you could change a players weapon by using SetProperty to give him weapons that do no damage (like a fusion cutter) but this will crash the game for all clients in MP... Maybe SetClassProperty works in MP, I never tested that.LRKfm946 wrote:The other alternative would be locking weapons until the games start. Is there a function for that?
http://www.gametoast.com/viewtopic.php?p=199663#p199663LRKfm946 wrote:I'm also thinking efore a round starts, teleport all players to some position or region in the middle of the map (if that's possible) and hold them there. What are the functions that affect player position?
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
Thanks for that sample code! I've successfully coded the ammo packs spawning. A few issues:
1. I want to make it so that the packs that spawn at cps WILL refill ammo for the engi's dispenser, but packs dispensed by the engi will NOT. Is this possible?
2. I was able to get changes to droids/packs in game but now all of the fake console commands are gone except ToggleQosDisplay. In the Lua before ScriptPostLoad() I have:
Is there a fix?
Another feature I'd like to add is that if a person camps for too long, they will start to lose health at a very slow rate, and they'll stop losing health if they go on the move. Is this possible?
1. I want to make it so that the packs that spawn at cps WILL refill ammo for the engi's dispenser, but packs dispensed by the engi will NOT. Is this possible?
2. I was able to get changes to droids/packs in game but now all of the fake console commands are gone except ToggleQosDisplay. In the Lua before ScriptPostLoad() I have:
Code: Select all
ReadDataFile("common.lvl")
ReadDataFile("dc:common.lvl")
ReadDataFile("core.lvl")
ReadDataFile("dc:core.lvl")Another feature I'd like to add is that if a person camps for too long, they will start to lose health at a very slow rate, and they'll stop losing health if they go on the move. Is this possible?
Is there a way to teleport players to a position on the map instead of a region or node?Locutus wrote:http://www.gametoast.com/viewtopic.php?p=199663#p199663LRKfm946 wrote:I'm also thinking efore a round starts, teleport all players to some position or region in the middle of the map (if that's possible) and hold them there. What are the functions that affect player position?
- Locutus
- 1st Lieutenant

- Posts: 420
- Joined: Fri Jun 04, 2010 10:08 am
- Projects :: Stargate Battlefront Pegasus
- Location: Germany
- Contact:
Re: Hunger Games Scripting
1. Sry, I don't know, never looked into that.
2. That's because your custom core level overwrites the regular one I think. What do you need the core.lvl for?
3. Yes, you can also teleport players to a matrix location:See here for information on how to get the correct offset values.
Edit: Stumbled upon this, you might try it to spawn units with less/no ammo: viewtopic.php?f=27&t=23708&p=406957#p407030
2. That's because your custom core level overwrites the regular one I think. What do you need the core.lvl for?
3. Yes, you can also teleport players to a matrix location:
Code: Select all
--find an object that's close to the position you want the player to teleport to
local object1Location = GetEntityMatrix("name_of_your_prop_in_ZE")
--create a new matrix to which the player is supposed to be teleported
local destination1Matrix = CreateMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, object1Location)Edit: Stumbled upon this, you might try it to spawn units with less/no ammo: viewtopic.php?f=27&t=23708&p=406957#p407030
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
I've made pretty good progress on the map. I go home from campus on some weekends, so I can use my old computer that runs ZE. I started making the world, but it'll take a while.
As for everything else:
1. Since I'm only slightly modifying the stock sides, I made a custom side containing all units from each faction that I'm actually using, modifying some parameters, and inheriting the rest from the stock units as ClassParents.
I got it all working, including localization, but since I'm using 1.3 sides, all of the custom weapon models have floating HUD icons :S I looked through some threads about fixing it but all the threads were about icons made by the modder themself, not loaded from stock sides. Any ideas?
EDIT: FIXED!!!
2. Sound issues: I added a global soundstream and some thunder, but niether have sound. Again, all of the sound threads seemed to be about adding custom sounds or fixing shipped sounds from sides, not world sounds. EDIT: Foliage collision sounds are also missing.
There are some other random sounds missing though, including footsteps on land in CW, footsteps on land and water in GCW, some weapon change sounds, objective update/complete sounds, among others. How can I round up all the missing sounds and get them back in? Do I have to pick them out one by one?
3. LUA issues: I'm having trouble with teleporting powerups to a players position when they spawn. Here's my code:
When I spawn, the powerups are spawned at their spawn node, but they don't get teleported to me.
Is there a way to get the node that a player spawned at, on player spawn?
4. Here's a biggie: I've added "armor" to all units (technically they're shields, but without any visual effects). The armor will start at zero (once I get the player/powerup spawning issue fixed) and there will be armor "powerups" throughout the map. I can't get the powerups to work. I know it's possible (http://www.gametoast.com/viewtopic.php? ... 2&p=501080). Mav or Marth, could ya help me out?
I'm also concerned about MP compatibility issues. Given that this entire project is meant specifically to be played online, I can't have any issues whatsoever. Are there certain things I should stay away from in my mission script? And how exactly do mission scripts work online?
As for everything else:
1. Since I'm only slightly modifying the stock sides, I made a custom side containing all units from each faction that I'm actually using, modifying some parameters, and inheriting the rest from the stock units as ClassParents.
I got it all working, including localization, but since I'm using 1.3 sides, all of the custom weapon models have floating HUD icons :S I looked through some threads about fixing it but all the threads were about icons made by the modder themself, not loaded from stock sides. Any ideas?
EDIT: FIXED!!!
2. Sound issues: I added a global soundstream and some thunder, but niether have sound. Again, all of the sound threads seemed to be about adding custom sounds or fixing shipped sounds from sides, not world sounds. EDIT: Foliage collision sounds are also missing.
There are some other random sounds missing though, including footsteps on land in CW, footsteps on land and water in GCW, some weapon change sounds, objective update/complete sounds, among others. How can I round up all the missing sounds and get them back in? Do I have to pick them out one by one?
3. LUA issues: I'm having trouble with teleporting powerups to a players position when they spawn. Here's my code:
Code: Select all
antipower = function( player )
print("Getting player position:")
local unit = GetCharacterUnit( player )
local unitLocation = GetEntityMatrix( unit )
--get the player's spawn position
--local player_pos = GetEntityMatrix(player)
print("Player position: ")
print(unitLocation)
CreateEntity("com_item_powerup_antiarmor", sammo_spawn4, "antiarmor")
CreateEntity("com_item_powerup_antiammo", sammo_spawn4, "antiammo")
SetEntityMatrix("antiarmor", unitLocation)
SetEntityMatrix("antiammo", unitLocation)
end
Is there a way to get the node that a player spawned at, on player spawn?
4. Here's a biggie: I've added "armor" to all units (technically they're shields, but without any visual effects). The armor will start at zero (once I get the player/powerup spawning issue fixed) and there will be armor "powerups" throughout the map. I can't get the powerups to work. I know it's possible (http://www.gametoast.com/viewtopic.php? ... 2&p=501080). Mav or Marth, could ya help me out?
I'm also concerned about MP compatibility issues. Given that this entire project is meant specifically to be played online, I can't have any issues whatsoever. Are there certain things I should stay away from in my mission script? And how exactly do mission scripts work online?
Last edited by LRKfm946 on Fri Mar 07, 2014 2:08 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: Hunger Games Scripting
3. Ever tried to spawn the powerups directly at the player location?
CreateEntity("com_item_powerup_antiammo", unitLocation, "antiammo")
4. Zerted does that in his holocron mode, go check it out.
(5.) Math.random can cause issues if you're not Zerted.
In general, MP is less stable then SP so avoid hitting engine limits. SetProperty() on player units is likely to crash as well as tempering with weapons via lua. pilotetype="vehicleself" will always crash MP. There are a few things that work while others crash, simplest thing is to try it out.
CreateEntity("com_item_powerup_antiammo", unitLocation, "antiammo")
4. Zerted does that in his holocron mode, go check it out.
(5.) Math.random can cause issues if you're not Zerted.
In general, MP is less stable then SP so avoid hitting engine limits. SetProperty() on player units is likely to crash as well as tempering with weapons via lua. pilotetype="vehicleself" will always crash MP. There are a few things that work while others crash, simplest thing is to try it out.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
Okay so I fixed the floating HUD icons by deleting everything in ingame.req except what I modified. I fixed the server crashing issue; for some reason it doesn't like loading sound from the addon folder. I had to take out all of the dc:sound lines in my lua, then it worked. That fixed some of the missing sounds but these ones are still missing:
I was thinking of making the other two superpowerups be invisibility and adrenaline (speed boost, etc.). I messed around in the lua with SetProperty trying several different properties, but nothing worked. Has anyone tried anything like this?
Currently my biggest issue is that when I run the map on a dedicated server, for some reason I'm unable to jump. (Click here for a video) It's pretty bizzarre and I have no idea why it's happening. It doesn't happen in single player. The client's game think's it's possible to jump, but the server doesn't, even though they have the exact same files. I copy the HGS folder to the server addon after each munge. This doesn't happen with any other map on the server. I'm using server manager 1.1, with v1.3 common, shell, and ingame.lvls and bryant's v1.4 patched exe.
The other biggest problem is that with my first objective (GoTo), if I complete it as CIS, it will complete the objective and go to the next one, but if I complete it as Republic, it will complete the objective then I get mission victory and the game ends. I want it to treat both teams the same, since it's a free for all game mode. How can I set this up?
Here's my lua:
Hidden/Spoiler:
Currently my biggest issue is that when I run the map on a dedicated server, for some reason I'm unable to jump. (Click here for a video) It's pretty bizzarre and I have no idea why it's happening. It doesn't happen in single player. The client's game think's it's possible to jump, but the server doesn't, even though they have the exact same files. I copy the HGS folder to the server addon after each munge. This doesn't happen with any other map on the server. I'm using server manager 1.1, with v1.3 common, shell, and ingame.lvls and bryant's v1.4 patched exe.
The other biggest problem is that with my first objective (GoTo), if I complete it as CIS, it will complete the objective and go to the next one, but if I complete it as Republic, it will complete the objective then I get mission victory and the game ends. I want it to treat both teams the same, since it's a free for all game mode. How can I set this up?
Here's my lua:
Hidden/Spoiler:
- [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: Hunger Games Scripting
Never use math.random() unless you're in the shell or have limited your map to SP only. Use ScriptCB_random() instead.
-
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: Hunger Games Scripting
Wait, what does ScriptCB_random() do? 
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
I should probably make this thread up to date:
I no longer have the jump issue and I'm no longer using objectives, so all those issues are gone. Here's my current LUA:
NOTE: I took some unimportant stuff out to get under the character limit for the post
Current issues are:
- Missing sounds still (I posted in the request thread for someone to make one for me because I don't have enough time to get it done on my own
I've followed every tutorial I can find and it still won't work.)
- I need to set up my traps/custom sound regions/regional sound streams. Is it possible to have 2 sound stream regions overlapping?
- fix super-powerups/think of a fourth one
I no longer have the jump issue and I'm no longer using objectives, so all those issues are gone. Here's my current LUA:
Hidden/Spoiler:
NOTE: I took some unimportant stuff out to get under the character limit for the post
Current issues are:
- Missing sounds still (I posted in the request thread for someone to make one for me because I don't have enough time to get it done on my own
- I need to set up my traps/custom sound regions/regional sound streams. Is it possible to have 2 sound stream regions overlapping?
- fix super-powerups/think of a fourth one
Last edited by LRKfm946 on Fri Apr 04, 2014 3:37 pm, edited 1 time in total.
-
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: Hunger Games Scripting
Hidden/Spoiler:
- [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: Hunger Games Scripting
Actually I just noticed I used math.random() in Holocron, so maybe it works fine. It looks like ScriptCB_random() returns a number between 0 and 1 but I can't test that. I'd assume ScriptCB_random() works online and math.random() doesn't.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Hunger Games Scripting
I got ScriptCB_random() working. I do believe it's a number b/t 0 and 1. So for a number b/t 60 and 180 seconds, I did (math.ceil(ScriptCB_random()*120)+60)
Hidden/Spoiler:
Last edited by LRKfm946 on Fri Apr 04, 2014 3:39 pm, edited 1 time in total.
-
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: Hunger Games Scripting
Hmm. I use math.random all over the place in this mod and it doesn't seem to cause any problems.
Granted I can't use it in online matches (except for things like music), but still. 
