1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  4. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  5. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  6. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  7. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  8. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Hiding Units during channeling abilities

Discussion in 'Triggers & Scripts' started by TexasRage, Aug 17, 2014.

  1. TexasRage

    TexasRage

    Joined:
    Aug 9, 2012
    Messages:
    19
    Resources:
    0
    Resources:
    0
    I'm trying to make a unit invisible and untargetable while channeling an ability, I've been using the hide unit trigger and got it to work, but I can't get the unit to reappear.
     
  2. NightSkyAurora

    NightSkyAurora

    Joined:
    Mar 1, 2013
    Messages:
    528
    Resources:
    8
    Models:
    4
    Spells:
    4
    Resources:
    8
    Use 'show unit' maby? post the trigger so we can see if you do something wrong.
     
  3. aple

    aple

    Joined:
    May 20, 2009
    Messages:
    807
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Unhide is the function to make them reappear.
     
  4. TexasRage

    TexasRage

    Joined:
    Aug 9, 2012
    Messages:
    19
    Resources:
    0
    Resources:
    0
    • Here's my trigger
      • Events
        • Unit - A unit Begins channeling an ability
      • Conditions
        • (Ability being cast) Equal to Heaven's Wrath
      • Actions
        • Unit - Hide (Triggering unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
          • Then - Actions
            • Countdown Timer - Start Heavens_Wrath_Timer as a One-shot timer that will expire in 5.00 seconds
          • Else - Actions
            • Unit - Unhide (Triggering unit)
     
  5. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    You have no idea what you're doing, do you? :D

    The If/Then/Else structure can be divided into three obvious blocks. The "If" block is a place for various conditions. The "Then" block is for actions that take place if all conditions of the "If" block are true/correct. The "Else" block is for actions that take place when any condition of the "If" block fails.

    Basically this statement: "If the sky is cloudy it rains, else it's sunny day." would be written in GUI as this:
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • The sky is cloudy equals to True
      • Then - Actions
        • It rains
      • Else - Actions
        • It's sunny day


    So you have no condition and in that case it will always be true. So your ITE will always use the "Then" block - so it starts a 5 second timer.

    Also, I'm not sure what you are trying to achieve here, but if you think the count down timer will serve as a 5-second wait, then you are mistaken.
     
  6. TexasRage

    TexasRage

    Joined:
    Aug 9, 2012
    Messages:
    19
    Resources:
    0
    Resources:
    0
    You're right about I don't know what I'm doing, I'm still kinda learning this. :p
    So what you're saying is the ITE isn't necessary and instead of the timer i should use wait?

    Edit: Figured it out now, I didn't think it was that simple I feel so dumb now. XD
    But thanks anyways.
     
  7. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    well, waits aren't always good due to them not being accurate (a wait of 5.00 is not that long or it is actually longer) and the wait time gets prolonged by player's ping, etc.
     
  8. jonhysone

    jonhysone

    Joined:
    Oct 29, 2012
    Messages:
    1,240
    Resources:
    1
    Maps:
    1
    Resources:
    1
    There are 3 delaying types :
    Countdown timers , they aren't MPI
    Waits aren't MPI
    Trigger with periodic event and increasing integer ( Absolutely MPI )

    You may use TWPAII ( Trigger with periodic event and an increasing integer - Don't clap plz - ) to make custom MPI-MUI spells and MPI systems and triggers like the one you're trying to make now
     
  9. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    Waits are actually MUI if used right with or even without simple indexing.
    Countdown timers, if used right, can be used and re-used and will absolutely be MUI, however to use them correctly requires to save their handles into hashtable afaik and the process after that is quite similar to the 3rd option - to periodic event.
     
  10. McQvaBlood

    McQvaBlood

    Joined:
    Jul 3, 2010
    Messages:
    536
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    Add a global named Heavens_Wrath_Unit and replace your trigger with these two:
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Heaven's Wrath
    • Actions
      • Set Heavens_Wrath_Unit = (Triggering unit)
      • Unit - Hide (Triggering unit)
      • Countdown Timer - Start Heavens_Wrath_Timer as a One-shot timer that will expire in 5.00 seconds

    • Events
      • Time - Heavens_Wrath_Timer expires
    • Conditions
    • Actions
      • Unit - Unhide Heavens_Wrath_Unit
      • Set Heavens_Wrath_Unit = No unit


    However, this will result in this spell not being MUI: if unit (1) uses it and then unit (2) uses it while unit (1) is still hidden, only unit (2) will reappear.
    You will need some sort of GUI indexing for it to work for multiple units. If you're interested in those, I will post an example of that too.
     
  11. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    If you do it with waits, it will look like this:
    • Events
      • Unit - A Unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Heaven's Wrath
    • Actions
      • Unit - Hide (Triggering unit)
      • Wait 5.00 second game time
      • Unit - Unhide (Triggering unit)

    The trigger above is fully MUI.
    While simple, you still need to consider if cons are greater than pros with waits
     
  12. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,470
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    I heard it is bad to use the polled wait/game time.

    countdown timers are MPI and MUI depending on how you use them.
     
  13. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    yes, polled wait is bad because of its inaccuracy and the wait time further prolonged by player's ping... and I also think there was a thing about waits still counting down even when you pause game, but I can be wrong on that one.
     
  14. Gismo359

    Gismo359

    Joined:
    Jul 14, 2011
    Messages:
    771
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    As far as I remember the timers and sounds are the ones that dont wait during pauses and people lagging out, not sure about waits.
    Then again, the last time I read anything about that was a couple of months ago.
     
  15. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,978
    Resources:
    17
    Spells:
    17
    Resources:
    17
    Using arrayed variable can make your trigger to become MPI.
    Using indexing technique can make your trigger to become MUI.

    What's the deal with MPI and MUI ?

    MPI (Multi-player Instanceability)
    You can have at max 16 (if you want to include Neutral Players too) units (each own by a player) casting/using the trigger at once.
    More than that, it will bug.
    Also, ONE player can only interact with the trigger using ONE unit only.
    Player 1, 1 unit.
    Player 2, 1 unit.
    ...
    Player 16, 1 unit.

    If a player have 2 units using the trigger, the first unit will get overwritten by the second one.

    Example:
    MPI

    • Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
      • Actions
        • Set PlayerNumber = (Player number of (Triggering player))
        • Set PlayerUnit[PlayerNumber] = (Triggering unit)
        • Set PlayerDuration[PlayerNumber] = 5.00
        • Unit Group - Add PlayerUnit[PlayerNumber] to UnitGroup
        • Trigger - Turn on Loop <gen>


    • Loop
      • Events
        • Time - Every 0.03 seconds of game time
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (UnitGroup is empty) Equal to True
          • Then - Actions
            • Trigger - Turn off (This trigger)
          • Else - Actions
            • Unit Group - Pick every unit in UnitGroup and do (Actions)
              • Loop - Actions
                • Set TempUnit = (Picked unit)
                • Set PlayerNumber = (Player number of (Owner of TempUnit))
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • PlayerDuration[PlayerNumber] Greater than 0.00
                    • (TempUnit is alive) Equal to True
                  • Then - Actions
                    • Set PlayerDuration[PlayerNumber] = (PlayerDuration[PlayerNumber] - 0.03)
                    • Set TempLoc = (Position of TempUnit)
                    • Set TempLoc2 = (TempLoc offset by 10.00 towards (Facing of TempUnit) degrees)
                    • Unit - Move TempUnit instantly to TempLoc2
                    • Custom script: call RemoveLocation(udg_TempLoc)
                    • Custom script: call RemoveLocation(udg_TempLoc2)
                  • Else - Actions
                    • Unit Group - Remove TempUnit from UnitGroup


    MUI (Multi-unit Instanceability)
    You can have at most 8192 units using this trigger at a time (it will be almost impossible to create 1,000 units at a time in a map, right?) so this limit will be more than enough.
    This is why MUI > MPI.

    Example:
    MUI
    • Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
      • Actions
        • Set MaxIndex = (MaxIndex + 1)
        • Set Unit[MaxIndex] = (Triggering unit)
        • Set Duration[MaxIndex] = 5.00
        • Trigger - Turn on Loop <gen>


    • Loop
      • Events
        • Time - Every 0.03 seconds of game time
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • MaxIndex Equal to 0
          • Then - Actions
            • Trigger - Turn off (This trigger)
          • Else - Actions
            • For each (Integer CurrentIndex) from 1 to MaxIndex, do (Actions)
              • Loop - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Duration[CurrentIndex] Greater than 0.00
                    • (Unit[CurrentIndex] is alive) Equal to True
                  • Then - Actions
                    • Set Duration[CurrentIndex] = (Duration[CurrentIndex] - 0.03)
                    • Set TempLoc = (Position of Unit[CurrentIndex])
                    • Set TempLoc2 = (TempLoc offset by 10.00 towards (Facing of Unit[CurrentIndex]) degrees)
                    • Unit - Move Unit[CurrentIndex] instantly to TempLoc2
                    • Custom script: call RemoveLocation(udg_TempLoc)
                    • Custom script: call RemoveLocation(udg_TempLoc2)
                  • Else - Actions
                    • Set Duration[CurrentIndex] = Duration[MaxIndex]
                    • Set Unit[CurrentIndex] = Unit[MaxIndex]
                    • Set MaxIndex = (MaxIndex - 1)