• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Trigger fires when it shouldn't

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
Concept: turret gun in a capital ship. When in the ship, right-clicking in any direction will cause a laser to fire in that direction.

Trigger:
  • Command Ship Turret
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Command Ship Gunner
      • cooldownTurret[(Player number of (Owner of (Triggering unit)))] Equal to False
      • ((Issued order) Equal to (Order(move))) or ((Issued order) Equal to (Order(smart)))
    • Actions
      • Game - Display to (All players) the text: (String((Issued order)))
      • Set tempUnit = (Triggering unit)
      • Set tempInteger = (Player number of (Owner of tempUnit))
      • -------- - --------
      • -------- ----fire --------
      • -------- - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of tempUnit) Greater than or equal to 3.00
        • Then - Actions
          • Set tempPoint = (Target point of issued order)
          • Set x = (X of tempPoint)
          • Set y = (Y of tempPoint)
          • Custom script: call RemoveLocation (udg_tempPoint)
          • Custom script: set udg_CreateX = GetUnitX(udg_RepublicCommandShip)
          • Custom script: set udg_CreateY = GetUnitY(udg_RepublicCommandShip)
          • Custom script: call MoveLocation(udg_LocationMove1, udg_CreateX, udg_CreateY)
          • Custom script: call MoveLocation(udg_LocationMove2, udg_x, udg_y)
          • Unit - Set mana of tempUnit to ((Mana of tempUnit) - 3.00)
          • Set CreationShipType = Laser Red
          • Set CreationPlayerOwner = (Owner of tempUnit)
          • Set CreationUnitOwner = tempUnit
          • Set CreationAngle = (Angle from LocationMove1 to LocationMove2)
          • Trigger - Run Create Laser Cannon <gen> (ignoring conditions)
          • Set cooldownTurret[tempInteger] = True
          • Wait 0.20 game-time seconds
          • Set cooldownTurret[(Player number of (Owner of (Triggering unit)))] = False
        • Else - Actions
          • Game - Display to PlayerGroup[tempInteger] the text: |c00ffff66No energy...
You can ignore the actions for now; the first action indicates that the trigger is firing correctly when the player right-clicks. The problem is it also fires when the same unit casts the Summon Bear ability!

There are 3 conditions, the third of which should stop the trigger from firing when the bear is summoned, but it's not.

1. Unit-type comparison. The summon bear ability and the right-click will both meet this condition.

2. cooldownTurret = false. This is a timer so you can only cast 5 times a second. It should work for both the summon bear ability and the right-click.

3. Issued order = move or smart. This is the condition that should rule out the summon bear ability! The order to summon a bear is: summongrizzly, but for some reason this trigger is still firing! The bear summoned ability is changed so that there is no summoned bear (number of summoned units = zero), so it's not the case that a bear is being summoned and ordered to move... The issued order, according to the first action, is "smart".

Is there another condition I could put in to distinguish the summon bear ability from the right-click?


Does anyone have any idea why this is happening.

p.s. This trigger also fires when I cast an ability based on Item Mana Regain, but not when I cast mirror image or divine shield.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
The problem is that the unit remembers the move order it was given before the transformation.

If a unit is moving while ordered to transform, it will be ordered to move to the targeted location after the transformation is over.

You can try to avoid it with this trigger:
  • Untitled Trigger 076
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(bearform))
          • (Issued order) Equal to (Order(unbearform))
    • Actions
      • Wait 0.00 seconds
      • Set point = (Position of (Triggering unit))
      • Unit - Move (Triggering unit) instantly to point
      • Custom script: call RemoveLocation(udg_point)
Also note that in your trigger, you should not use wait. It's highly inaccurate. Use a countdown timer instead.

In single player using a 0.20 wait, you might get values between 0.275 and 0.375. Different each time, In multilayer it could be even worse. That's not really fair for players if their wait times are random.
 
Status
Not open for further replies.
Top