How to Make Static Weapon Timers in H2A

Discussion in 'Articles' started by WAR, Nov 12, 2014.

  1. buddhacrane

    buddhacrane Ancient
    Senior Member

    Messages:
    1,204
    Likes Received:
    116
    Possibly, I never tested this because I kinda assumed someone would've already looked into this. I just assumed that the answer required scripting.

    I suppose it depends on when the weapon begins its respawn timer. Is it when the weapon spawns into the map, or when the player picks it up, or when the player drops the weapon? The only one that would work for static weapon timers is if the respawn timer starts the moment the weapon spawns into the map, if it doesn't, then scripting is the only way to go.

    Additionally, does the weapon respawn start the moment the map is loaded (i.e. the moment the "Deploying" countdown starts), or once the game actually starts (i.e. the moment the "Deploying" countdown ends). Again, the only one that would work for static weapon timers is if the respawn timer starts the moment the game starts; otherwise, again, scripting is the only way to go.

    Maybe I'll look into it later ... maybe.

    Anyway, I'll explain how to extend Scripting Timer delays shortly. I also might have a way to explain them with odd numbered respawn times too, but I need to do a quick bit of testing when I get back home before I can say for certain, so just bear with me :)
     
  2. SecretSchnitzel

    SecretSchnitzel Donald Trump
    Forge Critic Senior Member

    Messages:
    2,433
    Likes Received:
    1,885
    The game bases respawn timer off of when a player drops the weapon rather than when it was picked up, so in effect, no.
     
  3. ThisIsNotTheNSA

    ThisIsNotTheNSA Legendary

    Messages:
    279
    Likes Received:
    333
    I always thought the spawn timer worked like this: The game will keep trying to start the timer until the max limit is reached, but held weapons count towards the limit.

    So, if the max count is 2, then it will spawn 1 additional weapon even if the other is held.

    I still need to go and test this though.
     
  4. A Haunted Army

    A Haunted Army Your Local Pessimist
    Forge Critic Senior Member

    Messages:
    416
    Likes Received:
    311
    this was true in h4 and reach but not true now. the time is now based on when the weapon is dropped regardless of the max allowed settings.
     
  5. buddhacrane

    buddhacrane Ancient
    Senior Member

    Messages:
    1,204
    Likes Received:
    116
    OK, I finally have a moment to explain how to extend the delay on the Timers beyond 100 seconds. Here's how it's done:

    The first thing to understand is that your first Timer is always going to be looping, regardless of what any of the other Timers are doing; this first Timer is the only one that's actually keeping time throughout the game. The other Timers that we're going to add, to extend the duration, are just acting off of the back of that first Timer. Hopefully that will make sense after the examples.

    Also, I'm only going to give examples that work up to 180, since this is the limit that normal weapon respawns go up to. You can go higher of course, but you would need to extend on more Timers.

    Even number example
    A respawn time that is an even number is easier to extend than one that is an odd number, so I'll start with that.

    Previously, you just needed the following setup:
    • Timer: On Once: Broadcast Channel 0, Timer/User Data 10
    • Timer: On: Power Channel 0, Broadcast Channel 1, Timer/User Data x (substitute x for whatever weapon repawn time you want in seconds)
    • Timer: Off Once: Power Channel 1, Broadcast Channel 1, Timer/User Data 1
    • Your weapon of choice: Spawn Time Never, Place at Start True, Max Count 16, Spawn Channel 1, Can Despawn False
    Now, you will need the following setup to set a longer respawn time:
    • Timer: On Once: Broadcast Channel 0, Timer/User Data 10
    • Timer: On: Power Channel 0, Broadcast Channel 1, Timer/User Data x (where x is HALF the weapon respawn time you want)
    • Timer: On Once: Power Channel 1, Broadcast Channel 2, Timer/User Data x (where x is HALF the weapon respawn time you want)
    • Timer: Off Once: Power Channel 2, Broadcast Channel 1, Timer/User Data 0
    • Timer: Off Once: Power Channel 2, Broadcast Channel 2, Timer/User Data 1
    • Your weapon of choice: Spawn Time Never, Place at Start True, Max Count 16, Spawn Channel 2, Can Despawn False
    This will allow you to have any even numbered weapon respawn time, up to 200 seconds.

    Note that we're using an extra broadcast channel here, so the weapon is now listening on Spawn Channel 2, not 1 - 1 is being used to kick off the second Timer, to extend the delay.

    Also note that you have to give each Timer half of the total respawn time that you want. Basically (without going into the technical details), if you don't do this then your Timer: On will not be in sync with the respawn time you want after the first iteration. Well, technically there are other distributions of the respawn time that would work, but just damn well halve it OK! :p
    Odd number example
    Ok, this is the "fun" one. We need to do some Maths (or Math as you yanks say - I guess you can only handle one piece of mathematics at a time? ;)) which goes beyond simply halving the total time.

    The basic setup is the same, but we can't just halve the total respawn time to distribute between the timers (we can't halve and have half a second :D). What we instead need to do is take whatever respawn time we want, and then find a number (ideally the largest) that can divide into that time without any remainder; and that number needs to be larger than 1, so that does mean that any Prime Number respawn times you wanted beyond 100, I'm afraid you're just going to have to let them go (cue Vader-style "nooooooooooooooooooooooooo").

    Putting it in purely Mathematical terms, we're basically trying to find the highest Factor of our chosen respawn time - and that respawn time must be a Composite Number. If you hate your brain, then feel free to use this calculator :p: http://www.mathwarehouse.com/arithmetic/factorization-calculator.php

    Why do we need to do this? Because the Timer will go out of sync otherwise, that's all you need to know. Stop asking questions!

    As an example, let's say we wanted a respawn time of 165 seconds (that's 2 mins 45 seconds). The highest factor of that number is 55 - 55 can divide into 165 without any remainder. Therefore, 55 is what our first Timer wants a delay of, and then the other 110 seconds can be distributed among the other Timers however we see fit. In this case we would need to chain an extra 2 Timers, not just 1, because we can't fit the remaining 110 seconds into 1 Timer. Going up to a max respawn time of 177 though (you can't have 179, that's a Prime Number, stop being difficult!), we should never need to have more than an extra 2 Timers, so I'll show how you set that up:
    • Timer: On Once: Broadcast Channel 0, Timer/User Data 10
    • Timer: On: Power Channel 0, Broadcast Channel 1, Timer/User Data x (where x is the largest number you can have that's a factor of the weapon respawn time you want)
    • Timer: On Once: Power Channel 1, Broadcast Channel 2, Timer/User Data 100
    • Timer: On Once: Power Channel 2, Broadcast Channel 3, Timer/User Data y (where y is whatever time is leftover to get the respawn time you want)
    • Timer: Off Once: Power Channel 3, Broadcast Channel 1, Timer/User Data 0
    • Timer: Off Once: Power Channel 3, Broadcast Channel 2, Timer/User Data 0
    • Timer: Off Once: Power Channel 3, Broadcast Channel 3, Timer/User Data 1
    • Your weapon of choice: Spawn Time Never, Place at Start True, Max Count 16, Spawn Channel 3, Can Despawn False
    Simple, right?! Yeah, I'd just stick with the even numbers if I were you...
     
    #25 buddhacrane, Dec 23, 2014
    Last edited: Mar 4, 2015
    WaiHo, a Chunk and SecretSchnitzel like this.
  6. Korlash

    Korlash Remember Isao
    Forge Critic Senior Member

    Messages:
    780
    Likes Received:
    99
    So I am considering on trying static weapon spawns for my first time, but I have a couple questions still:

    1) Can the basic way that is explained in the current OP not work for weapons that spawn above 100 seconds (in my case, Rockets at 120s)? Judging from buddha's post, doesn't sound like it.

    2) What is this like for having multiple weapons on static timers? Would additional weapons require new timer objects with different power/spawn channels?

    Thanks!
     
  7. a Chunk

    a Chunk Blockout Artist
    Forge Critic Wiki Contributor Senior Member

    Messages:
    2,670
    Likes Received:
    7,152
    1) Read the spoilers in the post directly above yours for an explanation of how to do timers longer than 100 seconds (you can do them, but they require a few additional timers).

    2) This post earlier in the thread gives a pretty good description - http://www.forgehub.com/threads/how-to-make-static-weapon-timers-in-h2a.147983/#post-1606690
     
  8. Korlash

    Korlash Remember Isao
    Forge Critic Senior Member

    Messages:
    780
    Likes Received:
    99
    Ah I see. I think I understand this overall, but I'll need to test it out and make sure. Thanks for accommodating for my laziness.
     
  9. WaiHo

    WaiHo Talented
    Forge Critic Senior Member

    Messages:
    231
    Likes Received:
    305
    This should be stickied. :forgehub:
     
  10. darkprince909

    darkprince909 Talented
    Creative Force

    Messages:
    304
    Likes Received:
    328
    Agreed on this sticky. Also, for this to not be a useless bump, a quick question. I get sick and tired of my weapons despawning in Forge if I accidentally bump them out of place. If I were to set the weapon's respawn time to 180 seconds as opposed to Never, would that affect it negatively when it's set up this way? I would think it would never have the chance to spawn in on the 180 second timer because the scripted timer would always get it first. Has anyone done any tests with this? If not, I'll see what I can gather. Might make the whole system less frustrating for us all.
     
  11. buddhacrane

    buddhacrane Ancient
    Senior Member

    Messages:
    1,204
    Likes Received:
    116
    You know, in this case you might just be right. I'm not 100% sure if the spawning of an object via Scripting "resets" its standard respawn timer, but it just might. I shall do some tests after work tonight.

    Incidentally, if you don't want to worry about your "Never" weapons despawning on you while you Forge. Just set them to "Fixed" until you're finished Forging. Do remember to set them back to "Normal" though!
     
  12. Zombievillan

    Zombievillan Ancient
    Forge Critic Senior Member

    Messages:
    2,717
    Likes Received:
    3,623
    Why do the have to be on normal? Isn't fixed ok with this method?
     
  13. A Haunted Army

    A Haunted Army Your Local Pessimist
    Forge Critic Senior Member

    Messages:
    416
    Likes Received:
    311
    you can't walk through weapons on fixed which interferes with gameplay.
     
  14. Zombievillan

    Zombievillan Ancient
    Forge Critic Senior Member

    Messages:
    2,717
    Likes Received:
    3,623
    Ohhhhhhhhh...
    I never realized that. But phased is ok? Cuz I've seen people spawning weapons on walls & there's no way they are set to normal.
     
  15. A Haunted Army

    A Haunted Army Your Local Pessimist
    Forge Critic Senior Member

    Messages:
    416
    Likes Received:
    311
    well walls are different to being in the middle of a path. i think phased has the same effect but when its on a wall it's not really going to obstruct your movement so it doesn't matter.
     
  16. WaiHo

    WaiHo Talented
    Forge Critic Senior Member

    Messages:
    231
    Likes Received:
    305
    Is there a way to have a static timer when you have a weapon not placed at start?
     
  17. buddhacrane

    buddhacrane Ancient
    Senior Member

    Messages:
    1,204
    Likes Received:
    116
    Sure, just follow exactly what the guide says, but instead of setting the Weapon to "Place at Start True" set it to "Place at Start False"; then the weapon won't spawn in until that "Timer: On" turns on the Broadcast Channel after the first delay. So if you've set it to 60 seconds, then the weapon won't spawn onto the map until 60 seconds into the game, and then it will continue spawning in every 60 seconds as normal.

    If you're actually asking "Can I start the static Timer later into the match, instead of at the beginning?" then the answer is also "Sure". You just, again follow the guide, also set the Weapon's "Place at Start False", and then have that "Timer: On" activated from a Switch or whatever, instead of from that first "Timer: On Once"; and finally, if you want the weapon to initially spawn in when you hit that Switch or whatever, then also add a "Timer: On Once", setup the same as the "Timer: On" but with no delay. Doing this will kick off the whole static weapon respawn thing based on a Switch or whatever, instead of at the beginning of the match.

    Simples!
     
  18. WaiHo

    WaiHo Talented
    Forge Critic Senior Member

    Messages:
    231
    Likes Received:
    305
    Alright thanks! I'll try it out again next time I'm on. The first time I tried, the weapon wouldn't spawn at all if I had it set to 'Place at start False'. May just have been me not setting everything in the right way though.
     

Share This Page