Welcome to Open Carnage

A resource for Halo 1 modding and tech, with unique means of rewarding individual content creation and support. Have a wander to see why we're worth the time! EST. 2012

Sign in to follow this  
Followers 0
NeX

Global Item Spawn Replacement Script

37 posts in this topic

Background

 

If you care about this:

 

Hey, I know I don't do much scripting, but a while back 002 released an item spawner script, and it's a well known fact that spawn drift and tick-counts result in inaccurate item spawning times. Weapons and equipment don't spawn at the correct intervals on PC, removing one of the biggest factors influencing metagame play at high levels.

 

stunt_man and I had chatted a bit before about "halo roots" and metagame, and I had an idea that expanding on 002's original itmc script would be a good way to fix this glaring issue.

 

Very high level players (even on PC, oddly enough) would use YouTube or other sites that provided a stopwatch-style timer system with audio cues representing the spawns of important items, such as power weapons and powerups.

 

As useful as replacing the spawn timing for items was in and of itself, if one didn't know it was running, it wouldn't be very beneficial to anyone - players needed to be notified, especially because 

  1. Most players wouldn't know about the timing system and would therefore be at a serious disadvantage to players who did know and were timing the items waiting for spawn control
  2. Timing for individual items can vary map to map because of scenario-specific spawn times in the netgame_equipment block, meaning that one map's timing won't necessarily be accurate for another, and even the same items within a map may vary (one powerup may spawn on different intervals than another).

 

 

The original item spawner from 002 used a static table population for spawning items, meaning each map would need to be input as its own table. 

 

However, gametypes can influence which items spawn as well, so each table would need to have 5 instances to accurately take over the game's item spawning system.

 

The first iteration of this script used a static-table system as well (using a quick program I wrote to parse the scenarios to make it easier), but it resulted in >5,000 lines of meaningless data loading, and would require the same steps for any additional maps a user wanted this implemented for.

 

So it needed to be dynamic, and load the data directly from the scenario each game. It also needed to take into account the gametypes and sort the data accordingly. On top of that, the existing item_collection tags needed to be disabled so items didn't double-spawn, one from the script and one naturally via Halo.

 

002 had the nice idea of writing a 0 to the index of the netgame_equipment block, which if done quickly enough fools the game into thinking there are no item_collections to spawn in the first place.

 

Unfortunately with moving to a new apartment and the holiday season, I didn't have a lot of time to work on this for large intervals, so its development was stretched out over a few weeks, with stunt_man's competitive GMYF server(s) providing a good source of testing and feedback from the exact base of players this would be marketed to in the first place, which really helped keep it on track.

 

 

How it works:

Again, if you care :P

 

This implementation is fairly lazy, and so it uses two distinct scripts. One is a constantly running game start and loading script, and the other is the actual spawn and timer logic script. 

 

The reason I split it up was from the variability in the time it took to parse the data from the scenario, write the 0 to stop spawns, and make sure the timer and the spawning system started and stayed in sync.  The two-script implementation could probably be easily integrated into a single one, but it works as-is so why bother.

 

1) Global Spawn Replacement

  • The global_spawn_replacement script is the "loader" script. It provides a countdown for the game to start as well as handling the "no spawn" logic. It also prevents shenanigans like players skipping the map before the countdown is complete.
  • When the countdown is complete, it loads the dynamic_itmc script. When the game is over, it unloads the dynamic_itmc script.

 

2) Dynamic ITMC

  • The dynamic_itmc script loads when called from the GSR master script. It scans the scenario and grabs all the netgame_equipment_block dependencies. This gives us the item_collection tag (and by extension it's spawn timer), the gametypes it will spawn in, and the scenario-specific spawn timer. We then follow the dependencies deeper to see what tags are referenced inside the item_collection. This allows us to account for multiple-item spawns (shield-invisibility) and gives us an easy way to get the tag class and name.
  • It uses a 3D table (i know right?) to keep everything for spawns in a nice consistent order. This final table is the result of the parsing, and will contain everything that will be spawning for that map and gametype variant.  The gametype variant is simply one of the 5 standards (koth, ctf, slayer, oddball, race).
  • It handles levitation in a strange way, but it works. It takes spawn coordinates from an item supposed to levitate, and uses SAPP's intersect function to return the first collision directly below it following the Z axis, giving us the Z coordinate to spawn it at. Unfortunately, an item must "settle" by letting its stationary bit (0x10 bit 5 IIRC) be set by the game.
  • Setting it early results in warping, so we put it directly on the ground, which takes 1 game tick to set, after which we can change the Z coordinate to the original value. Unfortunately, X and Y cannot be changed without breaking equipment spawns (dunno why), and the yaw/pitch/roll will be the same in the air as on the ground. most of the time this is fine, but occasionally you'll see a crooked item.
  • When an item's yaw/pitch/roll change from what they are at levitation time (it's been shot or had AOE damage and has moved), a new object of the same type is spawned at the location to let everything drop naturally. It also transfers the original levitated object's vector velocity so that explosions still move the item correctly. The "newly spawned item" object ID replaces the old, so it will despawn correctly with the timers and all that jazz.

That's about all I'll get into here. The script itself is meticulously documented, since I had to end up forging ahead in a lot of "dark" areas of missing knowledge or on the basis of what were previously just hunches, so I wrote a crap load of comments and doc to make it easy to understand and modify if needed.

 

 

Constraints:

 

There are a few things to keep in mind to make this work correctly.

 

1) Normal weapon sets only

  • This was made for high level competitive (or just fun) play, so I did not take the time to account for "special" weapon gametype modes. If you play a variant with all rockets, obviously this timer will provide very little use other than for timing powerups. If you use any of the non-generic weapon sets, this will not work right. It will likely just end up spawning everything as normal, and you won't get your rocket or sniper fest gametype. I'm not going to fix this, although as stated in the how it works section, the script is documented well enough you could probably get that working pretty easily.

 

2) Custom tags not guaranteed

  • The easiest way to figure out what tags were what types was by parsing their names. Most maps played in the style this script was designed for use the classic tagset anyway, so no problems there. 
  • I tested it on Revolution maps, and because the rev tagset follows a pretty standard naming convention, they work as well. However, your [h3]yonlex2[reach][h4]Spiker.weapon certainly won't have its own timer.
  • All tags should spawn correctly, given how the spawn system works by reading the scnario, so if you're going to use this for that, you can just alter the timer printouts to do away with unnecessary ones, or disable the item spawn timers altogether in the script config section. Easy peasy. You'll still get the timer at the bottom, but I didn't have the time or patience to make a notification system that caters to all tags, nor would I even have a good system to do so. Even the weapon-type enum in the weapon tag isn't necessarily consistent.

 

3) Multi-item spawns

  • This was a pain in the ass with how the "percentage chance of spawn" works, so I made sure it worked with the shield-invisibility correctly, gave it a logic system that would handle n-number of items inside the item_collection, and left it at that.    
  • If you want to have a "random heavy" item_collection that spawns a flamethrower/fuel rod/rocket with each 33% chance, that should work.  
  • If you want to levitate them, it won't. I didn't support levitation for these types because I'd not seen it happen in any map, and it was more work than what the incredibly small percentage of maps that would benefit from it warranted. Sorry?

 

Setup:

 

There are two versions of this script here for download: 

<links at bottom>

 

Classic PC

Xbox

 

The classic PC is probably the one you want, unless you're specifically using ported Xbox maps that don't feature the Fuel rod or Flamethrower. Either way, the setup is the same.

  1. Place the two (or all) lua files within the sapp/lua folder just like any
    Global Spawn Replacement (Xbox or standard)
    Dynamic ITMC (Xbox or standard)
     
  2. Within your SAPP init.txt you will need to load the global_spawn_replacement script.

 

Classic PC:

lua_load global_spawn_replacement

Xbox:

lua_load global_spawn_replacement_xbox

Relevant FYIs:

 

Map Skipping:

 

If you are enabling map_skip within your server, adjust the "skip_percent" variable inside the dynamic_itmc script you are using to match that. The reason for this is that you can't simply disable and reenable the map_skip without giving it a percentage as an argument - so when the script disables map skipping during the countdown, it needs a value to reenable it with.

It uses a default of 51 right now, but make sure that value matches what you are already using, or it will be overridden.

 

If you aren't using map_skip at all, set skip_percent to 0.

 

This is all documented in the script, but I know people like to just plug and play, so this is early warning.

 

STFU:

 

The server operator can disable item spawn notifications completely (not the clock-timer itself) with a boolean in the config.

 

If you as a player don't want to see the timers, just type "/stfu_spawn" into the chat field.

"/unstfu_spawn" will reenable them.

 

In all of these cases the timer will remain in the bottom right corner. 

 

Yes, this uses console printing. Hac2's bookmarking does as well. Sucks, yo.

 

Hac2 Beta:

 

The official release of hac2 that is out right now (or if you aren't using it at all, lol) does NOT have the necessary console printing fix, and will likely result in print stuttering unless you use VSYNC.

 

This is because OG Halo (and current Hac2) ties the console printing to your framerate, meaning nothing good. Generally this results in some weird stuttering and odd formatting, maybe even complete "blank outs" of the notifications.

 

BETA FIX

 

This is a file "hac.dll" that just goes on top of the existing release. If you have hac2 already installed, stick this hac.dll file in your root Halo directory: "C:\........\Halo\hac.dll" or "C:\........\Halo Custom Edition\hac.dll". It's a plug and play fix.

 

hac.zip

 

 

If you don't have hac2, you probably shouldn't be trying to host a SAPP script. You could be using this time to color.

 

SCRIPTS:

 

Release v1.3

PC:

 

Xbox:

 

 

I would appreciate it if anyone could post a video showing this in action, as I don't have any and am not at home right now to record one.

stunt_man, Kavawuvi and Tucker933 like this

KsqHutE.png

Share this post


Link to post
Share on other sites

Members of Open Carnage never see off-site ads.

...

Oh snap I didn't even realize you released it!

Endorsement: I run this on my servers and it works great, even on custom maps. I have a real hard time playing on other servers after having experienced this script.

There's really no reason not to use this script. Even if you disable the notifications for all players, it still makes the weapons spawn at their correct times according to what's specified in the map's tags.

The problem with timing on PC was originally one of the main reasons that many high-level players never came over. We may not need players now, but there was a time when Custom Edition was truly hurting for more players.

It's a shame that this script came up so late in the game, but I'm extremely grateful to NeX for putting this together and releasing it nonetheless.

Good work.

Share this post


Link to post
Share on other sites

I'm sure it could be optimized a bit, but hey.

 

I've yet to see if it is compatible with OS v4, since I know the Hac2 beta fix makes the console printing work in the first place.

 

I had some ideas regarding that, I'll post back when I know more


KsqHutE.png

Share this post


Link to post
Share on other sites

Here's a full match with the timer enabled, to give folks an idea of what the map reset looks like as well as the notifications. You'll probably see that player timing weapons/powerups on the money, too, to give you an idea of what's possible with access to a precise timer.

Share this post


Link to post
Share on other sites

Very good script, and as you can get only the clock? that appears in the game on the right side, for to know how long has each game

Edited by planetX2

Share this post


Link to post
Share on other sites

Very good script, and as you can get only the clock? that appears in the game on the right side, for to know how long has each game

You need to edit the dynamic_itmc script I believe. It's fully documented. Players can disable the notifications and keep the clock by typing in /stfu_spawn, but if you want to force it off for all players you need to edit the value in the lua file.

Share this post


Link to post
Share on other sites

Very good script, and as you can get only the clock? that appears in the game on the right side, for to know how long has each game

 

You need to edit the dynamic_itmc script I believe. It's fully documented. Players can disable the notifications and keep the clock by typing in /stfu_spawn, but if you want to force it off for all players you need to edit the value in the lua file.

 

OOh. I think he's wanting just a "time remaining" clock for the current game, rather than actually using any elements of the existing script.

 

Um, yeah you could just use the same function I'm using for printing that timer, remove all the stuff about grabbing the spawn items, and then just have it count down from the set game time after the reset.

 

The problem with this is that halo's system relies on ticks while this script uses the server's OS.clock, so they won't match up. In fact that disparity of Halo not using true seconds is the reason this was needed in the first place, so I doubt it would sync up very well unless you made it a delay of like 990ms instead of 1 second or something to compensate. Even then the ticks are not set in stone really, so it's just a closer approximation.


KsqHutE.png

Share this post


Link to post
Share on other sites

Please fix for this, in halo ce appears and disappears

 

//vid.me/ieqi

 

This is fixed by an un-released add-on for HAC2. Btcc22 has said that he will push it to everyone (eventually). For now, I've attached it to this reply.

 

Simply place hac.dll in your Halo Custom Edition root directory (the folder that contains haloce.exe). All players will need to use this fix or they will experience the same bug with the timer.

 

hac.zip

Tucker933 and NeX like this

Share this post


Link to post
Share on other sites

This is fixed by an un-released add-on for HAC2. Btcc22 has said that he will push it to everyone (eventually). For now, I've attached it to this reply.

 

Simply place hac.dll in your Halo Custom Edition root directory (the folder that contains haloce.exe). All players will need to use this fix or they will experience the same bug with the timer.

 

attachicon.gifhac.zip

very well, thanks for the explanation, now works well

stunt_man likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.