• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] GUI Left Click Mouse Down Event Error with Unit Pause

Status
Not open for further replies.
Level 3
Joined
Aug 18, 2009
Messages
21
Hi,
I would like to request assistance regarding the mouse down button. I have an error where the unit i paused does not unpause at the end of the code line when using skills triggered by mouse down button.

After clicking the left mouse button I would order a unit to cast an ability. The ability pauses the unit and plays the attack animation, after 0.35 seconds the damage will be dealt in an area and unpause the triggering unit. I am using Guhun's Timer System for the timing of the damage and unpause.

I tested it multiple times with just the unit casting the ability and it unpauses the unit just fine. But when I use it with conjunction to the mouse down button, the unpause part of the code does not seem to work. I added messages to view when the part of the code is being run and it seems the end was reached.

Thanks

Below is the code I used

  • mouse test Copy
    • Events
      • Player - Player 1 (Red) issues Mouse Down event
    • Conditions
      • (Trigger Mouse Button) Equal to Left Mouse Button
    • Actions
      • Set MouseLoc[(Player number of (Triggering player))] = (Mouse Position for Triggered Mouse Event)
      • Quest - Display to (All players) the Quest Update message: (String((X of MouseLoc[(Player number of (Triggering player))])))
  • Basic Attack
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Berserk
    • Actions
      • Animation - Play (Triggering unit)'s attack animation
      • Set GTS_TimeOut = 0.40
      • Set GTS_Trigger = Basic Attack Timer <gen>
      • Unit - Pause (Triggering unit)
      • Trigger - Run GTS Main <gen> (checking conditions)
      • Set Location[1] = (Position of (Triggering unit))
      • Set SlashUnitArray = (Custom value of (Triggering unit))
      • Set SlashUnit[SlashUnitArray] = (Triggering unit)
      • Animation - Change SlashUnit[SlashUnitArray]'s animation speed to 160.00% of its original speed
      • Unit - Make (Triggering unit) face MouseLoc[(Player number of (Owner of (Triggering unit)))] over 0.00 seconds
      • Unit Group - Add (Triggering unit) to SlashStrikeUnits
  • Basic Attack Timer
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GTS_ExecutionCounter Equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in SlashStrikeUnits and do (Actions)
            • Loop - Actions
              • Set SlashUnitArray = (Custom value of (Picked unit))
              • Set Location[1] = (Position of SlashUnit[SlashUnitArray])
              • Set Location[3] = (Location[1] offset by 200.00 towards (Facing of SlashUnit[SlashUnitArray]) degrees)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 200.00 of Location[1] matching (((Matching unit) belongs to an enemy of (Owner of SlashUnit[SlashUnitArray])) Equal to True)) and do (Actions)
                • Loop - Actions
                  • Set Location[2] = (Position of (Picked unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in SlashStrikeUnits) Equal to False
                      • ((Picked unit) belongs to an enemy of (Owner of SlashUnit[SlashUnitArray])) Equal to True
                      • ((Picked unit) is alive) Equal to True
                      • ((Picked unit) is Mechanical) Equal to False
                      • (Angle from Location[1] to Location[2]) Greater than or equal to ((Angle from Location[1] to Location[3]) - 90.00)
                      • (Angle from Location[1] to Location[2]) Less than or equal to ((Angle from Location[1] to Location[3]) + 90.00)
                    • Then - Actions
                      • Special Effect - Create a special effect at Location[2] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Set DamageEventType = DamageTypePhysical
                      • Unit - Cause SlashUnit[SlashUnitArray] to damage (Picked unit), dealing (0.00 + (1.00 x (Real((Agility of SlashUnit[SlashUnitArray] (Include bonuses)))))) damage of attack type Hero and damage type Normal
                      • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\SkeletalMageMissile\SkeletalMageMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit Group - Add (Picked unit) to SlashStrikeUnits
                      • Custom script: call RemoveLocation(udg_Location[2])
                    • Else - Actions
                      • Special Effect - Create a special effect at Location[2] using Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
                      • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_Location[1])
              • Custom script: call RemoveLocation(udg_Location[3])
              • Quest - Display to (All players) the Quest Update message: attacked
              • Animation - Change SlashUnit[SlashUnitArray]'s animation speed to 100.00% of its original speed
              • Unit - Unpause SlashUnit[SlashUnitArray]
              • Unit - Order SlashUnit[SlashUnitArray] to Stop
              • Quest - Display to (All players) the Quest Update message: unpause
              • Unit Group - Remove (Picked unit) from SlashStrikeUnits
              • Quest - Display to (All players) the Quest Update message: remove group
        • Else - Actions
 
Last edited:
Level 9
Joined
Apr 23, 2011
Messages
527
I don't see why the unit is not unpaused if you say that everything in the trigger works just as planned. Try issuing the name of SlashUnit[SlashUnitArray] if it is the same as the one you are using before the unpause.

You remove all units of SlashStrikeUnits inside the unit group loop, try removing just the current picked unit (SlashUnit[SlashUnitArray]) instead. It might help, who knows.


Holy moly them point leaks and redundant unit group picks, though.
I'd do some other things to your trigger:
1. Use a different array for each point you use and remove them at the end of the unit group action
2. I'd use several unit group variables, add them to a singular unit group and just pick once, that way it's cleaner.
 
Last edited:
Level 3
Joined
Aug 18, 2009
Messages
21
Thanks I noticed the 'Unit Group - Remove all units from SlashStrikeUnits' part yesterday by removing only the picked unit but the issue is still there something inside click event might have caused the unit to stay paused or something else in the trigger. I also made the code much shorter because i just planned to pick units in front of the caster haha. Thanks for your advice. I also updated the code to the latest revision
 
Status
Not open for further replies.
Top