• 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] Help with a couple of irritating triggers

Status
Not open for further replies.
Level 8
Joined
Sep 15, 2006
Messages
426
Ok. #1: I am making a trigger for headshots, based off of a random number. Here is the trigger I have to randomize the number:
  • HS Random
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Triggering unit)) Not equal to Neutral Hostile
    • Actions
      • Wait 0.10 seconds
      • Set headshot[(Player number of (Owner of (Attacking unit)))] = (Random integer number between 1 and 30)
And here is the trigger I have for the actuall effect:
  • Headshot
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacking unit)) Not equal to Neutral Hostile
      • headshot[(Player number of (Owner of (Attacking unit)))] Equal to 1
      • (Charges remaining in myGun[(Player number of (Owner of (Attacking unit)))]) Greater than 0
    • Actions
      • Sound - Play headshot <gen>
      • Game - Display to (All players) the text: ((|cff00ff00 + (Name of (Owner of (Attacking unit)))) + |r got a headshot!)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Helmet[(Player number of (Owner of (Attacked unit)))] Equal to False
        • Then - Actions
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Random real number between 100.00 and 300.00) damage of attack type Hero and damage type Normal
        • Else - Actions
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Random real number between 50.00 and 100.00) damage of attack type Hero and damage type Normal
The random number trigger definately works; I've proved that it has. Hovever, the actual trigger doesn't seem to be firing at all. Any ideas?

Problem #2:

I'm using a weapons system that replaces the unit with a different unit to change weapons, so I need a trigger to reset the unit when it drops its weapon. Here's what I have:
  • Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Marine [|cffff0000Unarmed|r] (No Weapon)
      • (Item being manipulated) Equal to myGun[(Player number of (Owner of (Hero manipulating item)))]
    • Actions
      • Set myGun[(Player number of (Owner of (Hero manipulating item)))] = No item
      • Wait 0.01 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • myGun[(Player number of (Owner of (Hero manipulating item)))] Equal to No item
        • Then - Actions
          • Unit - Replace (Hero manipulating item) with a Marine [|cffff0000Unarmed|r] (No Weapon) using The old unit's relative life and mana
          • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
        • Else - Actions
          • Do nothing
This was working before, and it just stopped. I don't know why. Does anyone see anything wrong with the trigger?
 
Level 4
Joined
Jun 21, 2007
Messages
116
first of all, first you check if headshot as occured, then you check if it should occur.

also make sure you have myGun[] charges
 
Level 18
Joined
May 27, 2007
Messages
1,689
what your problem is is ur setting the random number .10 seconds after the unit is attacked, then at the same time the unit is attacked, the second and first trigger fire at the same time, but the second trigger will check the conditions, but wont happen, becuz you are setting the number .10 seconds after it has already fired and checked for conditions in the second trigger, i believe that is ur problem
 
Level 2
Joined
Jun 22, 2007
Messages
10
Your headshot trigger will never work on the first attack, but once the variable has been set it will start working.
 
Level 8
Joined
Sep 15, 2006
Messages
426
Oh jeez, I can't believe I didn't notice this before: Instead of using headshot[x] equal to 1, I could just do (random integer between 1 and 50) equal to 1. That would eliminate the entire 2nd trigger, no? But a new problem's cropped up. The myGun[] variable seems to have stopped working. I think it's not even being set to anything when it's supposed to be. Here's my trigger. Is there any reason it wouldn't be setting myGun to the correct item? (I have a ton of other triggers for different weapons here, which are all c&p's):
  • Tactical 1
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cffcccccc.45 Tactical|r
      • (Charges remaining in (Item being manipulated)) Greater than 0
    • Actions
      • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
      • Unit - Replace (Hero manipulating item) with a Marine [|cff00ff00.45 Tactical|r] (.45 Tactical) using The old unit's relative life and mana
      • Set myGun[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)
      • Sound - Play RELOAD <gen> at 100.00% volume, attached to (Hero manipulating item)
      • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
 
Level 21
Joined
Jan 5, 2005
Messages
3,515
try putting

"Set myGun[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)"

above

Unit - Replace (Hero manipulating item) with a Marine [|cff00ff00.45 Tactical|r] (.45 Tactical) using The old unit's relative life and mana

because it may be that when you replace the hero, the replaced hero is not accountable as the hero manipulating the item, so the manipulating hero is gone. so its looking for an item on a hero that does not exist.
 
Level 21
Joined
Jan 5, 2005
Messages
3,515
is the item found in the new units inventory? because it may be due to a new item actually being made with the new hero. thats considering if mygun is a item variable and not an item type...is it an item or item type variable?

if its an item variable try setting it to item of type "|cffcccccc.45 Tactical|r
" in last replaced units inventory.

if it wants to know what slot in the inventory (i cant remember if it does of not) add in a loop from 1-6 through the units inventory slots.

you should also test what your mygun vairable is set to by having a game announcement saying somethings like "convert item type of mygun to string"
 
Last edited:
Status
Not open for further replies.
Top