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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. 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.

[Spell] Spells that trap units inside an area?

Discussion in 'World Editor Help Zone' started by sniper_zero, Sep 10, 2012.

  1. sniper_zero

    sniper_zero

    Joined:
    Sep 9, 2009
    Messages:
    646
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Can anyone tell me how to trigger GUI spells which cause units to be trapped in the targeted area? As in once you've cast your spell in a target area, the units in that target area won't be able to get out until the spell wears off or something like that.
     
  2. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    You'll have to make a looping trigger that checks each unit's distance from the center, and if it is greater than the radius you want, it moves the unit back to the maximum radius.

    The spell trigger itself will set where this point is, and which units are affected.
     
  3. Bad Meets Evil

    Bad Meets Evil

    Joined:
    Sep 10, 2012
    Messages:
    4
    Resources:
    0
    Resources:
    0
  4. sniper_zero

    sniper_zero

    Joined:
    Sep 9, 2009
    Messages:
    646
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Thanks but can you post a simple sample trigger on how to do it? It gets a bit confusing when I look at that spell's triggers since I don't really know hashtables very well.
     
  5. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    Alright, I can whip up a quick trigger that will work for only one player.
     
  6. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    Right, so I went and made it MUI. Used Bribe's GUI Unit Indexer.

    Ability is based on Healing Ward.

    triggers
    When the ward is summoned, record its position and the units near it.
    • Ward Cast
      • Events
        • Game - UnitIndexEvent becomes Equal to 1.00
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit-type of UDexUnits[UDex]) Equal to Healing Ward
          • Then - Actions
            • Set TrapPoint[UDex] = (Position of UDexUnits[UDex])
            • Set TrapGroup[UDex] = (Units within 300.00 of TrapPoint[UDex] matching (((Matching unit) is dead) Equal to False))
            • Unit Group - Add UDexUnits[UDex] to Traps
          • Else - Actions

    10 times a second, check the distance between each ward and each unit associated with each ward.
    • Ward Loop
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in Traps and do (Actions)
          • Loop - Actions
            • Set key = (Custom value of (Picked unit))
            • Unit Group - Add all units of TrapGroup[key] to loopGroup
            • For each (Integer loopUnitid) from 1 to (Number of units in loopGroup), do (Actions)
              • Loop - Actions
                • Set loopUnit = (Random unit from loopGroup)
                • Unit Group - Remove loopUnit from loopGroup
                • Set tempLoc = (Position of loopUnit)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Distance between TrapPoint[key] and tempLoc) Greater than 300.00
                  • Then - Actions
                    • Set tempLoc2 = (TrapPoint[key] offset by 285.00 towards (Angle from TrapPoint[key] to tempLoc) degrees)
                    • Unit - Move loopUnit instantly to tempLoc2
                    • Custom script: call RemoveLocation(udg_tempLoc2)
                  • Else - Actions
                • Custom script: call RemoveLocation(udg_tempLoc)



    Note that:
    You still need a trigger that removes the wards from the unit group "Traps", and then nulls the variables registered to it.
    Doesn't account for units that enter the range; you'll have to make another trigger that adds them to the "TrapGroup".
     

    Attached Files:

  7. sniper_zero

    sniper_zero

    Joined:
    Sep 9, 2009
    Messages:
    646
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Oh, thanks! I'll try to figure out the rest now.
     
  8. Elfansoer

    Elfansoer

    Joined:
    Aug 26, 2012
    Messages:
    122
    Resources:
    0
    Resources:
    0
    Well, I have an idea, a crazy idea... But maybe it works or just inspire...
    (Hey, just give out the idea!
    This is his idea...:
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • Number of units in (unit-type group (ward)) not equal to 0
    • Actions
      • Unit Group - Pick every unit in (unit-type group (ward)) and do actions
        • Actions
          • Set The_Ward = Picked unit //You can use locals...
          • Unit Group - Pick every unit in ((units within (the_distance) of (The_Ward) matching (Picked unit equal to enemy of The_Ward)) and do actions
            • Actions
              • Unit - Move (picked unit) instantly to (position of (The_Ward))


    Well, that's HIS idea, so don't blame me if it won't work, and don't 100% trust the trigger!)
     
  9. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    You're picking units... in a picking units. please don't
     
  10. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Ruleroffiron99's trigger is great except that he uses GUI move positon which stuns a unit when moved. SetUnitX/Y will solve this problem yet will keep them out of bounds.
     
  11. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    baassee's method is definitely the better way to go, but requires a bit more custom scripting.
     
  12. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Think there was such a spell in the spell section before. Rather cool it was.
     
  13. Elfansoer

    Elfansoer

    Joined:
    Aug 26, 2012
    Messages:
    122
    Resources:
    0
    Resources:
    0
    Yeah, I know, sorry about that...
    That's why I call it crazy idea... never tried! lol
    (So, he's declaring that he's crazy, huh? that's true...
    he's the man with nothing to do, so he's just crazy-ing triggers...)