Very Complex Mapping Question! Dare To Answer!

blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
<div class="IPBDescription">I couldnt figure this out, outa my leagu</div> right now i have a func_button1 targeting a multimanager1 which triggers two things, ambientgeneric1 and envshooter1
i also have a func_button2 targeting a multimanager2 which triggers two things, ambientgeneric2 and envshooter2

I want to make it so that no two button targets can be activated at once. For example no songs can be playing at teh same time, ditto for the env_shooter(s)

So if one button is activated then the song plays and the env shooter shoots, if the other button is activated the first song and shooter stop playing and the second song and shooter start...

If the first button is pushed AGAIN then the song and shooter stop and there is nothing...

BOTH BUTTONS MUST START OFF (ie no music, no env_shooting)

--------------------------------------------------------------------

I found a tutorial that uses the same method:

<a href='http://www.karljones.com/halflife/almanac.asp' target='_blank'>http://www.karljones.com/halflife/almanac.asp</a>

click lifts to the left

then click elevator doors that move

i read it, over 10 times, its too hard to understand for me



Please help me out, i cant figure this out...
«13

Comments

  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    heres an IRC chat that i thought would be helpfull in explaining what i need to do:

    <DD> so you want them to start off
    <blackjackel> exactly
    <DD> be able to toggle each song on or off
    <DD> and only have one song playing at a time
    <blackjackel> yes but triggering one song triggers the other song off..
    <blackjackel> exactly
    <DD> so you can't turn them off
    <DD> one is always playing
    <DD> once on...
    <blackjackel> no
    <blackjackel> i also want to make it so that you can turn one song on
    <blackjackel> then back off
    <blackjackel> and have silence
  • ConfusedConfused Wait. What? Join Date: 2003-01-28 Member: 12904Members, Constellation, NS2 Playtester, Squad Five Blue, Subnautica Playtester
    argh, I have forgotten the enity, i think its a trigger once(?).
    anyway it holds a state which is given it(on or off).
    pressing a button1 will set triger1 to off.
    we will be using multisources ms1 and ms2
    a multi source only triggers if both inputs are on( in this case the button is pressed and teh other button has not set its trigger to off)

    teh multisource triggers teh multimanger if and only if both are on. this may meab you need to store 2 triggers but its 5am and so i cant remember right now

    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    button1->trigger1
             +->ms1 ---> multimanager1
                    ^
                    trigger2
    button2->trigger2
             +->ms2 ---> multimanager2
                    ^
                  TRigger1
    <!--c2--></td></tr></table><span class='postcolor'><!--ec2-->
  • NerdIIINerdIII Join Date: 2003-04-05 Member: 15230Members
    Hmm, I was thinking about a new QuArK script that would automate boolean equations and create the necessary env_globals and such, but I never finished the project. If I had I could now give you the output <!--emo&:(--><img src='http://www.unknownworlds.com/forums/html/emoticons/sad.gif' border='0' style='vertical-align:middle' alt='sad.gif'><!--endemo-->
    something like: play1 = button1 and not play2, play2 = button2 and not play1
    Oh well, Half-Life 2 will do it all a lot better anyway <!--emo&;)--><img src='http://www.unknownworlds.com/forums/html/emoticons/wink.gif' border='0' style='vertical-align:middle' alt='wink.gif'><!--endemo--> .
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    edited October 2003
    <!--QuoteBegin--blackjackel+Oct 26 2003, 09:50 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 26 2003, 09:50 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->Please help me out, i cant figure this out...<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    You have 3 states (both off, A on, B on) and two actions (press A, press B) to consider.

    First question: when A is on and the user presses the button for A again, should it turn off or ignore the second press?
    Second question: do trigger relays set to on/off work as expected with ambient_generic and env_shooter?

    If you <i>do</i> want your buttons to toggle (pressing A twice in a row turns A on then off; I think that's what you want) and the second question is true, use
    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    2 func_buttons (buttonA, buttonB),
    2 trigger relays (Aoff, Boff),
    3 multi_managers (buttonMultiA, buttonMultiB, gamestartedstatus) with flag 1 checked,
    2 ambient_generic (setA, setB),
    2 env_shooter (setA, setB) <-- same names, not a typo

    On user presses buttonA:
    buttonMultiA fires Boff
    ....Boff fires setB (anything named setB is turned off)
    buttonMultiA fires setA (anything named setA is toggled)

    On user presses buttonB:
    buttonMultiB fires Aoff
    ....Aoff fires setA (anything named setA is turned off)
    buttonMultiB fires setB (anything named setB is toggled)

    gamestartedstatus should point to Aoff and Boff to set everything off whenever a round starts or ends.
    <!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    If you <i>don't</i> want your buttons to toggle (pressing A twice leaves A on without interrupting the music) and the second question is true, you can use
    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    2 func_buttons (buttonA, buttonB),
    4 trigger relays (Aoff, Boff, Aon, Bon),
    5 multi_managers (buttonMultiA, buttonMultiB, onMultiA, onMultiB,gamestartedstatus) with flag 1 checked,
    4 env_globals (gAon, gAoff, gBon, gBoff),
    2 ambient_generic (setA, setB),
    2 env_shooter (setA, setB) <-- same names, not a typo

    On user presses buttonA:
    buttonMultiA fires Boff
    ....Boff fires setB (anything named setB is turned off)
    buttonMultiA fires gBoff (global B -> "off")
    buttonMultiA fires onMultiA
    ....onMultiA checks global A, only continues if global A is "off"
    ....onMultiA fires Aon
    ........Aon fires setA (anything named setA is turned on)
    ....onMultiA fires gAon (global A -> "on")

    On user presses buttonB:
    buttonMultiB fires Aoff
    ....Aoff fires setA (anything named setA is turned off)
    buttonMultiB fires gAoff (global A -> "off")
    buttonMultiB fires onMultiB
    ....onMultiB checks global B, only continues if global B is "off"
    ....onMultiB fires Bon
    ........Bon fires setB (anything named setB is turned on)
    ....onMultiB fires gBon (global B -> "on")

    gamestartedstatus should point to Aoff, gAoff, Boff, and gBoff to set everything off whenever a round starts or ends.<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    I don't have the Half-Life SDK installed at the moment (upgraded to WinXP and wiped my drives), so I can't confirm that trigger relays work as expected by looking at the source, but if they don't I'll post a workaround using env_globals to track both states.

    The script I've posted assumes that you're using a looping sound and a continuously firing env_shooter -- otherwise you need to remember the length of the sound and reset both buttons when it's done playing. The setup for that will require a third multi_manager and you'll want to turn off multithreading (flag 1) for the multi_managers that are already present.

    I can walk you through the settings for each item in either of the configurations if needed. The setup is simple enough that you could add additional button/sound/shooter combinations without a hassle (if you wanted 3 or 4 instead of 2, that's not tough to do and scales linearly).

    EDIT: typo <!--emo&:(--><img src='http://www.unknownworlds.com/forums/html/emoticons/sad.gif' border='0' style='vertical-align:middle' alt='sad.gif'><!--endemo-->
  • RedfordRedford Monorailcatfjord Join Date: 2002-04-28 Member: 528Members, NS1 Playtester
    I've said it before and I'll say it again.

    XP-Cagey is my official mapping diety.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    If you do want your buttons to toggle (pressing A twice in a row turns A on then off; I think that's what you want) and the second question is true, use
    CODE

    2 func_buttons (buttonA, buttonB),
    2 trigger relays (Aoff, Boff),
    3 multi_managers (buttonMultiA, buttonMultiB, gamestartedstatus) with flag 1 checked,
    2 ambient_generic (setA, setB),
    2 env_shooter (setA, setB) <-- same names, not a typo

    On user presses buttonA:
    buttonMultiA fires Boff
    ....Boff fires setB (anything named setB is turned off)
    buttonMultiA fires setA (anything named setA is toggled)

    On user presses buttonB:
    buttonMultiB fires Aoff
    ....Aoff fires setA (anything named setA is turned off)
    buttonMultiB fires setB (anything named setB is toggled)

    gamestartedstatus should point to Aoff and Boff to set everything off whenever a round starts or ends.



    I used the above code and now ONLY ONE SONG PLAYS AT A TIME! BRAVO!!!!

    I forgot to mention something, i am using a trigger random to keep firing the inv_shooter several times (as you cant do that with the env_shooter alone.)


    But i am having problems with this setup, apparently the env_shooters are affected differently than the ambient_generic... I think its because the ambient_generic starts ON by default (with start silent flag set)

    So the ambient generic starts on while the env_shooters start off therefore they are effected differently (which is my prediction)





    This is the current effect:

    When buttonA is pushed, song A starts, and both env_shooterA and env_shooterB are triggered (they keep shooting because of trigger_random)

    When buttonA is pushed again songA stops and env_shooterA and env_shooterB stop shooting.



    So far so good (except for both env_shooters shooting at once), so wheres the problem?

    Say you push ButtonA and SongA and env_shooterA and shooterB start...

    If you go over and push buttonB, songA stops, SongB starts playing (so far so good), Then env_shooterA and env_shooterB stop shooting (which is bad)





    The desired effect was: if buttonA is pushed songA starts playing and env_shooterA ONLY shoots repeatedly

    if ButtonB is pushed after pushing buttonA songA stops and SongB plays, env_shooterA stops and env_shooterB ONLY starts shooting


    And all this while both buttons toggle (if buttons are pushed twice you have silence)
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    With the above i used a few things to edit your original suggestion (such as the trigger_randoms to trigger the env_shooters over and over to keep them shooting)

    I will now state here what happned (result) with your original suggestion followed word by word.

    When buttonA is pushed a single shot from both env_shooterA and env_shooterB gets fired.

    When buttonB is pushed after pushing buttonA then songA stops playing and songB starts playing, and again the same effect as button A (a single shot of env_shooterA and env_shooterB get fired)


    The desired effect is When pushing buttonA songA plays and env_shooterA ONLY plays

    When B is pushed after A, song B plays ONLY and env_shooterB plays ONLY.



    i THINK both env_shooters are being triggered is because in the multimanagers, when Aoff or Boff is being activated, for some reason it activates the env_shooter even though its supposed to be turned off.... i know strange =/
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    edited October 2003
    <!--QuoteBegin--blackjackel+Oct 27 2003, 04:24 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 27 2003, 04:24 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> i THINK both env_shooters are being triggered is because in the multimanagers, when Aoff or Boff is being activated, for some reason it activates the env_shooter even  though its supposed to be turned off.... i know strange =/

    <!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    Yeah, I was worried about that sort of thing happening -- IIRC the target_relay code was added after env_shooter, and the older code probably wasn't modified to use the new settings. It's actually why I asked the second question in my post above. Here's the workaround using a multisource + multi_manager loop with a global state value for control:

    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->2 func_button, (buttonA,buttonB)
    5 multi_managers (buttonMultiA, shooterCycleA,buttonMultiB,shooterCycleB,gameStartedStatus) (flag 1 on)
    2 target_relay (Aoff,Boff)
    2 multisource (shotTriggerA, shotTriggerB)
    4 env_globals (gAtoggle,gAoff,gBtoggle,gBoff)
    2 env_shooters (shooterA,shooterB)
    2 ambient_generics (musicA,musicB)

    This code requires the use of two global states: globalA and globalB:
    set shotTriggerA's master to globalA
    set shotTriggerB's master to globalB

    On user presses buttonA:
    buttonMultiA fires gBoff (globalB -> off)
    buttonMultiA fires Boff
    ....Boff fires musicB (turning it off)
    buttonMultiA fires gAtoggle (globalA toggled)
    buttonMultiA fires musicA (toggled)
    buttonMultiA fires shotTriggerA
    ....shotTriggerA fires shooterCycleA if globalA is on
    ........shooterCycleA fires shooterA (single shot)
    ........shooterCycleA fires shotTriggerA after N seconds (for next shot in loop)

    On user presses buttonB:
    buttonMultiB fires gAoff (globalA -> off)
    buttonMultiB fires Aoff
    ....Aoff fires musicA (turning it off)
    buttonMultiB fires gBtoggle (globalB toggled)
    buttonMultiB fires musicB (toggled)
    buttonMultiB fires shotTriggerB
    ....shotTriggerB fires shooterCycleB if globalB is on
    ........shooterCycleB fires shooterB (single shot)
    ........shooterCycleB fires shotTriggerB after N seconds (for next shot in loop)

    gamestartedstatus should trigger gAoff and gBoff, then Aoff and Boff a fraction of a second later to turn everything off<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    The loop made by shotTriggerA and shooterCycleA will fire immediately after the button is pressed and every N seconds after while musicA is playing. When musicA is silent, the fact that globalA is off will kill the loop so the env_shooter will stop. If you don't get consistant results, put the buttonMultiA trigger of shotTriggerA half a second after it triggers gAtoggle.

    EDIT: typo again <!--emo&:0--><img src='http://www.unknownworlds.com/forums/html/emoticons/wow.gif' border='0' style='vertical-align:middle' alt='wow.gif'><!--endemo-->
  • GoPeDeRiCkGoPeDeRiCk Join Date: 2003-03-21 Member: 14742Members
    use trigger_relay

    u can kill both ambiant sound at the same time and then the next sec in the multi manager tell it to start that song u want
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--GoPeDeRiCk+Oct 27 2003, 07:51 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (GoPeDeRiCk @ Oct 27 2003, 07:51 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> use trigger_relay

    u can kill both ambiant sound at the same time and then the next sec in the multi manager tell it to start that song u want <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    echo?
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    Ok the output using this new setup is:

    One song does not play at the same time as the other song (which is great) but NO env_shots at all!!!


    I think that i am doing something wrong with the setup of the multisource and env_global settings, what should i put for the settings of those?
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    edited October 2003
    <!--QuoteBegin--blackjackel+Oct 27 2003, 11:55 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 27 2003, 11:55 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->could you please elaborate on this:
    ....shotTriggerA fires shooterCycleA if globalA is on
    ........shooterCycleA fires shooterA (single shot)
    ........shooterCycleA fires shotTriggerA after N seconds (for next shot in loop)


    and/or

    ...shotTriggerB fires shooterCycleB if globalB is on
    ........shooterCycleB fires shooterB (single shot)
    ........shooterCycleB fires shotTriggerB after N seconds (for next shot in loop)


    please elaborate on the N seconds as well as what that is supposed to do,

    The current setup that i did does the music only but no env_shooters shoot at all....<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    I think I might have found a bug in what I gave you to try -- here's what it's meant to do:

    The multisource (shotTriggerA) only fires when its master value is true (globalA is on). This way if somebody hits buttonB, the loop for the shooter attached to A will stop.

    The multi_manager (shooterCycleA) fires the shooter and then waits before calling the multisource again--the pause should be as long as the amount of time you want between env_shooter effects. By "N" seconds I meant a variable value -- try 2 seconds as a start value and play with it from there to get the effect you want.

    Every time shooterCycleA calls shotTriggerA, shotTriggerA calls shooterCycleA again unless the global matching its master field has been turned off, breaking the loop. That's what allows you to control when the looping shooter stops and starts.

    The bug I introduced came from having buttonMultiA and shooterCycleA both trigger shotTriggerA; when more than one item points at a multisource, all of them must be on at the same time for the multisource to fire its target, which is probably why you're not seeing anything happen. In order to get the correct toggle behavior, you need to use one multisource to start the cycle and another to complete the loop. So the layout now adds one cycler per button (shotCycleCheckA, shotCycleCheckB) and looks like

    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->buttonMultiA fires gBoff (globalB -> off)
    buttonMultiA fires Boff
    ....Boff fires musicB (turning it off)
    buttonMultiA fires gAtoggle (globalA toggled)
    buttonMultiA fires musicA (toggled)
    buttonMultiA fires shotTriggerA
    ....shotTriggerA fires shooterCycleA if globalA is on (for first shot)
    ........shooterCycleA fires shooterA (single shot)
    ........shooterCycleA fires shotCycleCheckA after 2 seconds
    ............shotCycleCheckA fires shooterCycleA if globalA is on (for next shot in loop)<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    With the same setup on the other button. gAToggle should have a globalstate of "globalA" and a triggermode of "3 (toggle)". gAOff should have a globalstate of "globalA", an initialstate of "0 (off)", and a triggermode of "0 (off)" with flag 1 checked. gBToggle and gBOff should have the same setup but with globalstate set to "globalB" -- all of that sets up the masters for the multisources.

    Let me know if you have any more problems.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    you are certainly getting close to the real answer, you see now the output im getting is (music works fine) and now two env_shooter shots are shot (about 2 seconds apart) and then thats it!

    Meaning it dosent loop, it just fires twice and stops

    maybe multisource can only be triggered once? or is not multithreaded?


    Is there some way i can use trigger random to shoot the env_globals out and still have it turn off when you hit the other button?
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--blackjackel+Oct 28 2003, 01:29 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 01:29 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> you are certainly getting close to the real answer, you see now the output im getting is (music works fine) and now two env_shooter shots are shot (about 2 seconds apart) and then thats it!

    Meaning it dosent loop, it just fires twice and stops <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    It's getting through the loop once (at the 2 second mark), but not the second time (at the 4 second mark).

    The multi_manager shooterCycleA is probably acting as a toggle instead of an "on" switch, so the second time it passes through the loop at 4 seconds the signal sent is "off" and the shooting stops; try the following, which removes the second multisource and uses a trigger_relay named Acycle or Bcycle to always send an on signal (triggerstate 1):

    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    2 func_button, (buttonA,buttonB)
    5 multi_managers (buttonMultiA, shooterCycleA,buttonMultiB,shooterCycleB,gameStartedStatus) (flag 1 on)
    4 target_relay (Aoff,Boff,Acycle,Bcycle)
    2 multisource (shotTriggerA, shotTriggerB)
    4 env_globals (gAtoggle,gAoff,gBtoggle,gBoff)
    2 env_shooters (shooterA,shooterB)
    2 ambient_generics (musicA,musicB)

    This code requires the use of two global states: globalA and globalB:
    set shotTriggerA's master to globalA
    set shotTriggerB's master to globalB

    On user presses buttonA:
    buttonMultiA fires gBoff (globalB -> off)
    buttonMultiA fires Boff
    ....Boff fires musicB (turning it off)
    buttonMultiA fires gAtoggle (globalA toggled)
    buttonMultiA fires musicA (toggled)
    buttonMultiA fires Acycle
    (begin loop)
    ....Acycle fires shotTriggerA (triggerstate is 1)
    ........shotTriggerA fires shooterCycleA if globalA is on
    ............shooterCycleA fires shooterA (single shot)
    ............shooterCycleA fires Acycle after 2 seconds (begin next shot loop)
    (end loop)

    mirror for buttonB

    gamestartedstatus should trigger gAoff and gBoff, then Aoff and Boff a fraction of a second later to turn everything off
    <!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    If this still doesn't fire at the 4 second mark, it means that the multisource is ignoring the second on signal because it's not a state change. I'll have to do some reconfiguring of the loop at that point; having Acycle set to toggle is possible but really complicates the round reset problem. You might need to resort to a hack like using a func_button that the user never sees to signal the multisource; whatever does the signaling always needs to cause a true value for the multisource.

    I need to install the SDK again because there's a lot of information about the signaling interface (such as what causes a toggle and what always fires) that isn't obvious. I would have thought that the signal from a multi_manager would act like an "on" value pulse for a multisource but that's apparently not the case--probably so that signals aren't required to be fired at the same time to have an effect.
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--blackjackel+Oct 28 2003, 01:29 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 01:29 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Is there some way i can use trigger random to shoot the env_globals out and still have it turn off when you hit the other button? <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    After reading the trigger_random spec again, it looks like the toggle (flag 2) feature would work if you mirror the current state of each trigger_random with a global and use a multisource to turn it off when needed.
  • YamazakiYamazaki Join Date: 2002-01-24 Member: 21Members, NS1 Playtester, Contributor
    edited October 2003
    1 env_global
    1 multisource

    The buttons use the multisource as a master, and the env_global starts ON (Make sure it has a state set up, and that the multisource uses that state). When a multimanager is fired, it fires the env_global (set to toggle) to flip its state, from on to off. Then when the song is over, it flips the same env_global from off to on, so that the sounds can be triggered again (Probably need a seperate trigger_relay for this, as you can't have the same entity name in a multimanager sequence twice).

    env_global/multisource combo for storing states is a lifesaver, and works 10 times out of 10.

    The only thing you cannot do with this is interrupt the current song by pressing the button again. This only prevents you from starting a new song while the old one is playing.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    <!--QuoteBegin--XP-Cagey+Oct 28 2003, 06:05 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (XP-Cagey @ Oct 28 2003, 06:05 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> <!--QuoteBegin--blackjackel+Oct 28 2003, 01:29 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 01:29 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Is there some way i can use trigger random to shoot the env_globals out and still have it turn off when you hit the other button? <!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    After reading the trigger_random spec again, it looks like the toggle (flag 2) feature would work if you mirror the current state of each trigger_random with a global and use a multisource to turn it off when needed. <!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    when you have time, paste in the procedure for doing this as you always do, i havent tried your suggestion prior to this post because i am currently in school/college =/


    Is there any chance that the mapping code could be updated for ns 2.1 so that we wouldnt have to go through all this trouble to get the same effect?
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    <!--QuoteBegin--XP-Cagey+Oct 28 2003, 05:56 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (XP-Cagey @ Oct 28 2003, 05:56 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> <!--QuoteBegin--blackjackel+Oct 28 2003, 01:29 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 01:29 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> you are certainly getting close to the real answer, you see now the output im getting is (music works fine) and now two env_shooter shots are shot (about 2 seconds apart) and then thats it!

    Meaning it dosent loop, it just fires twice and stops <!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    It's getting through the loop once (at the 2 second mark), but not the second time (at the 4 second mark).

    The multi_manager shooterCycleA is probably acting as a toggle instead of an "on" switch, so the second time it passes through the loop at 4 seconds the signal sent is "off" and the shooting stops; try the following, which removes the second multisource and uses a trigger_relay named Acycle or Bcycle to always send an on signal (triggerstate 1):

    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    2 func_button, (buttonA,buttonB)
    5 multi_managers (buttonMultiA, shooterCycleA,buttonMultiB,shooterCycleB,gameStartedStatus) (flag 1 on)
    4 target_relay (Aoff,Boff,Acycle,Bcycle)
    2 multisource (shotTriggerA, shotTriggerB)
    4 env_globals (gAtoggle,gAoff,gBtoggle,gBoff)
    2 env_shooters (shooterA,shooterB)
    2 ambient_generics (musicA,musicB)

    This code requires the use of two global states: globalA and globalB:
    set shotTriggerA's master to globalA
    set shotTriggerB's master to globalB

    On user presses buttonA:
    buttonMultiA fires gBoff (globalB -> off)
    buttonMultiA fires Boff
    ....Boff fires musicB (turning it off)
    buttonMultiA fires gAtoggle (globalA toggled)
    buttonMultiA fires musicA (toggled)
    buttonMultiA fires Acycle
    (begin loop)
    ....Acycle fires shotTriggerA (triggerstate is 1)
    ........shotTriggerA fires shooterCycleA if globalA is on
    ............shooterCycleA fires shooterA (single shot)
    ............shooterCycleA fires Acycle after 2 seconds (begin next shot loop)
    (end loop)

    mirror for buttonB

    gamestartedstatus should trigger gAoff and gBoff, then Aoff and Boff a fraction of a second later to turn everything off
    <!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    If this still doesn't fire at the 4 second mark, it means that the multisource is ignoring the second on signal because it's not a state change. I'll have to do some reconfiguring of the loop at that point; having Acycle set to toggle is possible but really complicates the round reset problem. You might need to resort to a hack like using a func_button that the user never sees to signal the multisource; whatever does the signaling always needs to cause a true value for the multisource.

    I need to install the SDK again because there's a lot of information about the signaling interface (such as what causes a toggle and what always fires) that isn't obvious. I would have thought that the signal from a multi_manager would act like an "on" value pulse for a multisource but that's apparently not the case--probably so that signals aren't required to be fired at the same time to have an effect. <!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
    I finally implemented this suggestion and IF i did it correctly here are the results:

    env_shooter shoots once, that is all.

    Now i really want to know how would one do the trigger_random suggestion as i think thats the only way to do this without using a hack...

    PS: i am attempting to implement the trigger_random to fire the env_globals on my own untill you give me an answer, but this is still out of my leage and anything i do will be just that, an attempt.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    good news, i believe i have almost solved the problem, i will post when i have completely solved it.
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--blackjackel+Oct 28 2003, 02:57 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 02:57 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> I finally implemented this suggestion and IF i did it correctly here are the results:

    env_shooter shoots once, that is all. <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    <!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->If this still doesn't fire at the 4 second mark, it means that the multisource is ignoring the second on signal because it's not a state change. <!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->

    This is the current problem -- it's actually causing the multisource to not fire at the 2 second mark, since that's the second time the signal is being sent without changing states.

    trigger_random can loop (flag 2) to control the shooter, but you'll still need to use a multisource to toggling it off according to its current state; the same signaling problem exists using either method.

    To get around the signaling problem, you'll have to either use an item twice each loop to ignore the extra off signal, or use an entity class that always registers a positive pulse signal (if one exists). You might want to try turning the trigger_relay into a trigger_multiple to see how that entity's signal is handled by the multisource. If it's not a toggle, your problem is solved. If it is a toggle, you can still work around the problem by inserting an extra call to Acycle via a trigger_multiple inside the loop with a 1 second delay.

    If it weren't for the signaling behavior of a multisource, this would be pretty simple stuff. I'm going to look over at the collective to see if there are any other trigger types that can use a master.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    no need my freind, i have implemented a trigger_random to shoot the env_shooters, im using multisources and env globals to make it behave the way i want, i feel this is the best way, and except for minor glitches, it seems to be working.

    This is the effect i have so far:

    button1 music1 starts playing & envshooter1 start shooting, if pushed again envshooter1 and music1 stop playing...

    If you push button2 after button 1 music1 env1 stop shooting and music2 plays env2 start shoots (so far so GREAT!)

    But my problem is...

    If you push button 2 then 1 then 2 again it messes up (shoots both env1 and env2)

    Same goes if you push button 1 then 2 then 1 again (shoots both env1 and env2 again)



    I am trying to see how i can solve this, if i do, it would be all over
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    I am posting how i achieved the above effect...

    I made two env_globals (gGAon, gGBon) Which remember when the trigger_Ranom's that make the the env_globals shooot.

    I made two multisources (shooterAoff, shooterBoff) Which turn off the trigger_randoms for env1 and env2 respectively only when the env_globals are on....


    here is my setup:

    On user presses buttonA:
    buttonMultiA fires gBoff (globalB -> off)
    buttonMultiA fires Boff
    ....Boff fires musicB (turning it off)
    buttonMultiA fires gAtoggle (globalA toggled)
    buttonMultiA fires musicA (toggled)
    buttonMultiA fires shooterBoff
    .........turns off the trigger_random that shoots the env_shooterB
    buttonMultiA fires gGAon
    .........sets the env_global to on
    buttonMultiA fires trigger_randomA that fires the env_shooterA





    Now i cant figure out why it messes up like how i described in the post before this.
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    edited October 2003
    <!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->
    buttonMultiA fires shooterBoff
    .........turns off the trigger_random that shoots the env_shooterB<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->

    I don't have access to the NS entity code, but it could be that the trigger_random doesn't understand the different types of trigger_relay signals. I've changed it a bit so that you never need to do anything but toggle the items:

    EDIT: no, I can see that you're having the same multisource as AND gate issues I was having; use a trigger_multiple that has the multisource as its master instead to get what I have.

    EDIT 2: using the same substitution would make my second attempt work as well.

    <!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
    5 multi_managers (pressedA, pressedB, toggleA, toggleB, gamestartedstatus) with flag 1 checked

    2 env_globals (gAtoggle,gBtoggle)
    2 multisources (stateA,stateB) with masters globalA & globalB

    2 trigger_multiples (stopA,stopB) with masters stateA & stateB

    2 trigger_randoms (cycleA,cycleB) with flag 2 checked
    2 env_shooters (shooterA, shooterB)
    2 ambient_generics (musicA, musicB)

    on A pressed:
    pressedA fires stopB
    ....stopB fires toggleB (if stateB = on)
    pressedA fires toggleA

    on B pressed:
    pressedB fires stopA
    ....stopA fires toggleA (if stateA = on)
    pressedB fires toggleB

    on toggleA fired:
    toggleA fires musicA
    toggleA fires cyclerA
    ....cyclerA fires shooterA every 2 seconds
    toggleA fires stateA

    on toggleB fired:
    toggleB fires musicB
    toggleB fires cyclerB
    ....cyclerB fires shooterB every 2 seconds
    toggleB fires stateB

    gamestartedstatus should fire stopA and stopB.<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->

    Much cleaner than what I had before. I think 17 is probably the minimum entity count for getting everything tied together.

    The issue I had with multisource wasn't its use as a global state placeholder (which has been part of my design since the first try), but my attempt to use it as an AND gate with an impulse signal, which apparently isn't possible because the default state behavior of entities is toggle instead of impulse.

    I should have been using the multisource as a trigger_multiple's master field, which I'm doing here--I was worried about needing a func_button hack because I didn't know of any triggers with a multisource master field available. I really don't like the need for the extra entity, but oh well--live and learn.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    edited October 2003
    just making sure you want me to use trigger_multiple(s) i dunno just something seems wrong or missing there, but ill try it....
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--blackjackel+Oct 28 2003, 11:04 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 11:04 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> just making sure you want me to use trigger_multiple(s) i dunno just something seems wrong or missing there, but ill try it.... <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    Use trigger_multiples, set the master of the trigger_multiple to the multisource, set the master of the multisource to the global variable. The trigger multiple will only fire when the global is on, which is what you want.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    Alright i followed those instructions word for word here are the results:

    ButtonA pushed, musicA and env_shooter(s)A shoot, buttonA pushed again, silence and no shooters... good!
    Same above effect for buttonB.... good!

    What happens when push buttonB after buttonA? musicA plays, musicB plays, env_shooter(s)A shoot, and env_shooter(s)B shoot all shoot all at once...

    Same thing happens when you push buttonA after pushing buttonB



    So the good thing is that the env shooters are now tied into the music and button, but one button does not turn off the effects of button2....

    I feel that we are getting very close to getting the end result, i will again attempt to do this myself again.



    I believe this is a huge wake up call to mapping and anyone trying to do anything this complex, maybe this thread should be turned into a readme or something....

    I can not wait for you to see the end result of all this, believe me you will think it was worth it! (its that good)
  • NerdIIINerdIII Join Date: 2003-04-05 Member: 15230Members
    <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif'><!--endemo--> Hey, it is not *that* complex. I have heard of people with over 30 entities for a single system to work.
    It only seems to be that complex because simple things either need a few entities in HL or triggers don't work as expected. That's why I wanted to write that script; to make the use of global state variables easier. It would have created the system of multimanagers, mastered trigger_relays, multisources and eng_globals from a few simple equations you enter. But with pen and paper you could do this as well, it just takes some time till you realise this is the only way it works in Half-Life. I tried a lot of other combinations before that seemed to be easier and use less entities, but they just wont work.
    Does someone know if there is already a tutorial on complex trigger systems with states? (No more stickies please, maybe an addition to the guidelines in the section 'advanced tutorials', but no more stickies.)
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--blackjackel+Oct 28 2003, 11:40 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 28 2003, 11:40 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> I can not wait for you to see the end result of all this, believe me you will think it was worth it! (its that good) <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    Some things to check -

    What is the master of stopA? (should be stateA)
    What is the master of stateA? (should be globalA)
    What is the initial state of toggleA? (should be off)
    What is the trigger state of toggleA? (should be toggle)
    What variable does toggleA affect? (should be globalA)

    Ditto for the other button.
  • blackjackelblackjackel Join Date: 2002-11-01 Member: 2151Members, Constellation
    you said toggleA and toggleB should be multimanagers, how can i set the initial state, trigger state, and affecting variables for those if they are multimanagers?
  • CageyCagey Ex-Unknown Worlds Programmer Join Date: 2002-11-15 Member: 8829Members, Retired Developer, NS1 Playtester, Constellation
    <!--QuoteBegin--blackjackel+Oct 29 2003, 12:26 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (blackjackel @ Oct 29 2003, 12:26 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> you said toggleA and toggleB should be multimanagers, how can i set the initial state, trigger state, and affecting variables for those if they are multimanagers? <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
    my bad, I meant stateA's initial state and trigger state <!--emo&:(--><img src='http://www.unknownworlds.com/forums/html/emoticons/sad.gif' border='0' style='vertical-align:middle' alt='sad.gif'><!--endemo-->
Sign In or Register to comment.