Halo 5 Scripting Airlock help.

Discussion in 'Halo and Forge Discussion' started by Rannik, Aug 1, 2016.

  1. Rannik

    Rannik Ancient
    Senior Member

    Messages:
    22
    Likes Received:
    11
    The Basic Premise Is Im building a map with a Airlock (w/ a power weapon in it). So when A player goes for it, another player may hit A switch and eject them from the map. It works doors close and others open gravity pulls them out. Even put Mist and the Green light goes red also sirens go off. But as my friend pointed out its kinda unfair because the switch is on toggle and you could just spam it.

    So is there a way to make the switch only to activate it and have a cooldown so you cant keep doing it.

    thanks for reading Im hoping someone could help me out.
     
    Dunco likes this.
  2. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    Well, I don't have a ton of experience with it but you could probably do something like this:
    switch sends out a signal
    an item despawns when it receives this signal, and is on a respawn timer
    when the item despawns, it turns off power
    switch has to have power to be able to send signal (to both this item and the airlock)
    when item spawns, it turns on power

    You could use this item's spawning to determine exactly how long the airlock is closed for, too. Like pressing the button turns off power to the switch until the thing is closed, then turns it back on; then until it's open, then turns it back on.

    The only thing is, there are several items which can't despawn (basically anything invisible, except teleporters and maybe barriers I think) so be careful which you use.
     
    #2 Rethal, Aug 1, 2016
    Last edited: Aug 1, 2016
    Rannik and Sn1p3r C like this.
  3. Sn1p3r C

    Sn1p3r C Halo 3 Era
    Creative Force

    Messages:
    379
    Likes Received:
    578
    Yep! We just need to make a Circuit Breaker using a multi condition activation script, and a cool down object.

    Edit: @Rethal nailed it up above with the general concept.

    Current situation
    Right now, you push the button and it triggers the thing. Likely something...
    Switch
    Condition: On interaction
    Action: Send Message Alpha

    And the Airlock sounds a bit more complicated... but assuming everything triggered off the message...

    Airlock
    Condition: On Message Received Alpha
    Action: (Lots of things/kill player)

    Making a Circuit Breaker object
    Spawn something outside of your map; I suggest a space whale.
    Give it these two scripts:

    Whale 1
    Condition: On Spawn
    Action: Power: Set X-Ray On (Any unused channel will do)

    Whale 2
    Condition: On Despawn
    Action: Power: Set X-Ray Off (Same channel as X1)

    Now, when the object is in the map, X-Ray is ON. When the object is out of the map, X-Ray is OFF.

    We've got two more things to do... Add a script and modify the respawn/despawn settings to set your cool down timer.

    Whale 3
    Condition: On Message Received Beta (Different from airlock trigger)
    Action: Despawn
    //When the switch is pressed, despawn the whale

    Whale Respawn/Despawn Settings
    Respawn Enabled: On
    Condition: On Death/Deletion
    Timer: <This is your cool down on the switch!>
    Despawn On Timer: Off
    Despawn On Abandoned/Disturbed: Off
    //Whale respawns in X seconds after it despawns. Does not despawn on its own

    So, what did we just do? We said that when the whale gets a message on Beta, it should turn off XRay, despawn itself, and come back in a certain number of seconds (Respawn timer). When it comes back, it will turn on XRay.

    Hooking up current scripts to the circuit breaker
    The last piece of the puzzle is to hook up our switch to the circuit breaker so that it can only activate the airlock when X-Ray is on. Clear your scripts from the switch and add these instead...

    Switch 1
    Condition: On Interaction
    Action: Send Message Beta (This is to the circuit breaker, not the target!)
    //Flips off the whale if it's in the map, turning circuit breaker off

    Switch 2
    Condition: On Message/Power: Multi
    Minimum to Trigger: 2
    Condition 1: On Message Received Beta
    Condition 2: Channel Power X-Ray ON
    Action: Send Message Alpha (to airlock)
    //If the switch is pushed and the whale is in the map, trigger the airlock
     
    Yumudas Beegbut likes this.
  4. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    ^So switches/items can send signals to themselves? That's good news. I wasn't sure of that so I built my slipspace drive entirely circumventing it
     
  5. Sn1p3r C

    Sn1p3r C Halo 3 Era
    Creative Force

    Messages:
    379
    Likes Received:
    578
    Yessir. Well, under the hood, I think they're actually sending it to a central message object and that object in turn signals the original item. But for us Forgers, there's no problem.

    I would recommend testing them of course- All the scripts should execute at once so the state of power channels behaves as expected, but it never hurts to check...

    Also, OP - check out Colonial by @Soldat Du Christ - he's got an aesthetic airlock that might be of interest to you. (Also, the map's pretty cool.)
     
    Soldat Du Christ likes this.
  6. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    Neat. Yesterday I spent hours forging just one piece of script (a slipspace piece - turn the switch on, turns on power, which activates the open animation, which sends a signal to a brain after 1.5 s which sends a signal to both despawn the open and spawn the loop. Power off and the loop sends a signal to the brain to despawn the loop and spawn the close, which despawns on a timer of 3s). Sounds like I could have done it without the brain, but I was being careful (I'm a programmer, I am aware that things go wrong). Plus with the intermediate I might be able to make some easier changes to it in the future (ie, I don't have to nab the open or close animations to add a function).

    That said, it seems that the timers are consistent? Like the timer starts on spawn and can't restart? Maybe I could've used a circuit breaker or something instead but I was trying to nail down the animations so the open and close animations could complete before despawning and just couldn't get it to work - I think because of the timer. Any insight into the internal workings of this?
     
  7. Sn1p3r C

    Sn1p3r C Halo 3 Era
    Creative Force

    Messages:
    379
    Likes Received:
    578
    The way the timer scripts work is that they start when an object is spawned (I believe) - delay for the set duration, then repeat forever until they are despawned. I've had trouble with knowing exactly when a timer is running in the past (seemed like it only began when the match started), so I've stuck with respawn timers.
     
    Yumudas Beegbut likes this.
  8. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    Yeah considering I just came up with that when answering this post, I didn't attempt to use it last night. Still, I may take (yet) another stab at it later. Although maybe I should actually start building this map...

    @Rannik I was just thinking about your airlock. An alternative way of doing this would be if you wanted to have the airlock be self-controlled (ie, it goes through its entire animation, both open and close, then the button works again) you could do something similar without a separate circuit breaker. Just have the switch only be able to turn the power on, and only turn the power off after the completion of the animation (which, actually, would probably work best with a timer anyway).

    In essence I guess it depends on what you want with the airlock capability. Open and close manually, open manually and then close on its own, allowing you to open it again or preventing you from opening it again at all, or just open and remain open for the duration. Sounds like the first option is the one you want so I would recommend making a circuit breaker that prevents from opening and closing too quickly, as well as one that prevents from reopening too quickly.

    I'd love to see it, though!
     
    #8 Rethal, Aug 1, 2016
    Last edited: Aug 1, 2016
  9. Rannik

    Rannik Ancient
    Senior Member

    Messages:
    22
    Likes Received:
    11
    Would that be 3 different whales?
     
  10. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    should be all on one whale. Those are just separate scripts
     
    Sn1p3r C likes this.
  11. Sn1p3r C

    Sn1p3r C Halo 3 Era
    Creative Force

    Messages:
    379
    Likes Received:
    578
    Yep, sorry if that wasn't clear. One Whale, scripts number 1, 2, and 3.
     
  12. Rannik

    Rannik Ancient
    Senior Member

    Messages:
    22
    Likes Received:
    11
    Thank you for your help. It works but I also I forgot the detail that I want the airlock action to last 15 seconds which works perfectly due to your instructions but I also want to the cooldown for the switch to be 60 second or so with red and green lights spawning in and out.
     
    Yumudas Beegbut and Sn1p3r C like this.
  13. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    I don't know what you want for the lights, but that is exactly what I was talking about before - needing to know what you want.

    It may help you to plan your switch out on paper before implementing it.

    So here's my suggested thought process (assuming you want to be able to open and close it, but not reopen it until 60 seconds have passed after it last closed)

    I can't guarantee this will work because I don't know how the polling/timing operates.

    Switch:
    on interaction
    -Send message alpha
    if alpha received and alpha power on and bravo power on
    -toggle power charlie
    if power:charlie on
    -send message bravo
    if power:charlie off
    -send message charlie

    Whale 1:
    if bravo received
    -despawn
    if despawn
    -alpha power off
    if spawn
    -alpha power on
    respawn in 15s

    Whale 2:
    if charlie received
    -despawn
    if despawn
    -bravo power off
    if spawn
    -bravo power on
    respawn in 60s

    Airlock operates via charlie
    if charlie is on, opens; if charlie is off, closes.


    If you wanted to spawn red lights while it was opening or closing, for example, you would tie them to bravo power being off.

    Actually I know this code is slightly off, I'll take another look at it, but this is at least sort of preliminary.

    Edit: ah, I know the issue I was seeing. So, the code above, when you power off charlie, does not toggle whale 1 to despawn. A simple fix would be to add a script for

    if power:charlie : off - send message bravo

    to the switch. Now it should work.

    If you wanted to make the 60s timer start with the first activation of the switch, you would just change the
    if power:charlie off - send message charlie
    to
    if power:charlie on - send message charlie
    (note - I didn't think this through, this would actually make the switch only possible to activate either direction every 60 s. I'll think on it)

    Alternatively, you could tie it to the respawn of the first whale and the switch, so that it's 60s after the thing finishes closing:

    Whale 1:
    (add-ons)
    if spawn
    -send message charlie

    Whale 2:
    (change)
    if charlie received and power: charlie off
    -despawn

    Switch:
    (remove
    if power:charlie off
    -send message charlie)

    So I thought on the one I mentioned a little bit more, and what I've come up with is to do it that way, you'd have to change the switch from toggling to specifically turning on and off. For it to turn on, it would have to be reliant on charlie being off, alpha being on, AND bravo being on. For it to turn off, it would have to be reliant on charlie being on and alpha being on, without paying attention to bravo.

    There could be easier ways of doing these things but tbh this sort of scripting can get tough because we're so limited on what we can do.

    edit whatever-number-it-is-now: just realized in the initial version you don't even need to despawn the first whale to block out the switch. That change would only be necessary if you wanted to tie the despawn of the second whale to the spawn of the first - ie, start that timer after the airlock closes.

    The reason you might want to do this is, say, if someone hit the switch, waited 45 s and then hit it again. They'd be able to reopen the switch right after it finished closing. If that matters to you then I would recommend tying it to the respawn of the first whale.

    yet another edit:
    that reason ^ would only apply if you set the second whale to despawn upon the switch turning on. In the event that you left it in turn-off, the presser would have to wait 45 seconds after it finished closing before turning it back on. And honestly at that point, the easiest solution would be to just change the spawn to be a minute and 15 seconds.
    So obviously there are a ton of ways to do what you want to do, it's all dependent on the exact specifications you want to have enacted. What I've detailed above essentially cover three scenarios:

    1) you want to not be able to use the switch while it's turning on or off (opening and closing) and you want a cooldown of x2 - x1 seconds after the off is pressed
    2) you want to not be able to use the switch while it's opening/closing and you want a cooldown of x2 seconds after the on is pressed before it can be turned on again (comes with the problem I mentioned before of 15s open and close time so only 45s inactive time unless you increase the timer)
    3) you want to not be able to use the switch while it's opening/closing and you want a cooldown of x2 seconds after the close is complete before it can be reopened

    All three can accomplish the same goal - even the same cooldown times - it all depends on your approach. Whichever of those routes seems easiest for you in your current standing is the one I'd recommend going down.
     
    #13 Rethal, Aug 1, 2016
    Last edited: Aug 1, 2016
  14. Sn1p3r C

    Sn1p3r C Halo 3 Era
    Creative Force

    Messages:
    379
    Likes Received:
    578
    Haven't read through Rethal's post, but you should just set the Circuit Breaker's respawn timer to 60 seconds.

    Whatever scripts are going off Alpha (your airlock) should handle their own duration. I'd suggest creating a new object, say Olive the Pig, and giving it the following scripts.

    Olive 1
    Condition: On Message Receive Alpha (your airlock script)
    Action: Despawn
    //This makes it so Olive despawns when your airlock effect begins

    Olive 2
    Condition: Spawn
    Action: Send Message Delta
    //Set up your airlock effect to end when it receives a message on Delta

    Olive Respawn
    Set up Olive's respawn timer just like we did the Whale - Respawn on deletion, your 15 second duration, and all despawn options set to "off."

    If you do it like that, When you press the switch...
    -Your airlock effect begins
    -Olive will despawn when it gets the message from switch
    -Circuit breaker turns "off" for 60 seconds - your switch's cool down.

    After 15 seconds:
    -Olive respawns, sending a message on delta
    -Your airlock responds to the message on delta, and stops.

    After 60 seconds:
    -Circuit breaker flips back to "On" - letting players push the button again


    If you want lights to blink, you can use the "power state" condition to make them turn red when the channel is "off", and turn green when the channel is "on".
     
  15. Soldat Du Christ

    Soldat Du Christ Legendary
    Senior Member

    Messages:
    1,530
    Likes Received:
    2,353
    I had waggly beef help me with the airlock scripting, add and messege him if you're still looking for help
     
  16. Rannik

    Rannik Ancient
    Senior Member

    Messages:
    22
    Likes Received:
    11
    Success! It works! thanks guys! Its beautiful!
     
  17. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    I'd love to see it if you've got a link!

    Edit: I'd like to point out that the difference between Snipe's approach and mine is that his prevents you from opening or closing it for 60 second periods, whereas mine prevents you only from opening it either 60 seconds after open, close, or close completion. I don't know which approach you went with but if you decide that you want to correct its balancing in an alternate system, you might want to consider the other approach.
     
    #17 Rethal, Aug 2, 2016
    Last edited: Aug 2, 2016
    Rannik and Sn1p3r C like this.
  18. Rannik

    Rannik Ancient
    Senior Member

    Messages:
    22
    Likes Received:
    11
    I read both of what you guys wrote then from what I learned I put together something. But it does have a delay till the switch can be hit again.

    I put a green light to let you know when you can hit the switch again.

    [​IMG]

    [​IMG]

    Here is an outside view.

    [​IMG]

    And A first person account.

    [​IMG]



    Some pics of the map in general. (Still working on it).

    [​IMG]

    [​IMG]

    [​IMG]

    [​IMG]

    LAstly a thank you to anyon that responded and help me out. You guys are the best!
     
    Yumudas Beegbut and Wally12 like this.
  19. Rethal

    Rethal Ancient
    Senior Member

    Messages:
    190
    Likes Received:
    44
    Right on! Just a couple notes:
    First, I see what you mean about spamming. I mean obviously it's an easy kill or "kill" (wish there was a way to give that point to the button-presser) but on top of that if you kept pressing the button you could break the airlock. So good implementation.
    Second, I was just thinking - normal airlocks tend to close first and then open. If you wanted to give the ejectee a chance at survival, giving him a brief warning may be a good way to do that.
    Third, please, PLEASE tell me those aren't the final colors XD
    And finally, map looks great, hope you get it to a point you're happy with it!
     
  20. Rannik

    Rannik Ancient
    Senior Member

    Messages:
    22
    Likes Received:
    11
    Yeah I was thinking of making it more fluid. Its gunna take even more script to do so. I could probably figure it out thanks to the information you guys gave me. Also Definitively with the paint job. Dunno what to change it to tho
     

Share This Page