• 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] Item Variables and Replacing Units

Status
Not open for further replies.
Level 8
Joined
Sep 15, 2006
Messages
426
My map uses a weapons system that replaces the unit with a new one to get the effects of different weapons. I need to track whatever weapon is currently being used with a variable. The problem is, the variable never seems to set itself. Here are my triggers:

  • 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))
The rest are just c&p's.
 
Level 6
Joined
Feb 25, 2005
Messages
230
Maybe youre using an item with only 1 charge. if so, it will dissapear before you can ad a charge. and therefore the variable cannot add it, since theres no item left.

also, you set the variable after replacing the unit. does items follow to the new unit when you use "replace" actions?
 
Level 8
Joined
Sep 15, 2006
Messages
426
None of the items I am using here have only one charge. and they do not disappear when their charges are used up. And yes, the items appear to follow the unit, although I don't know if they are just items that have been re added to the unit.
 
Level 6
Joined
Feb 25, 2005
Messages
230
Strange. Anyway. This one sets the itemvariable to my item if the charges are 2 or higher.

  • itemset
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Healing Wards
      • (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 Paladin using The old unit's relative life and mana
      • Set TheItem = (Item being manipulated)
      • Game - Display to (All players) the text: (Item name: + (Name of TheItem))
therefore, it does not work if you only have 1 charge.
 
Level 8
Joined
Sep 15, 2006
Messages
426
Well, we seem to have a new development. The variable apparently sets itself now, but whenever I run this trigger:
  • Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item being manipulated) Equal to myGun[(Player number of (Owner of (Hero manipulating item)))]
    • Actions
      • Unit - Replace (Hero manipulating item) with a Marine [|cffff0000Unarmed|r] (No Weapon) using The old unit's relative life and mana
      • Set myGun[(Player number of (Owner of (Hero manipulating item)))] = No item
      • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
WC3 crashes. No error message or anything, just freezes for a second and closes. WTF?
 
Level 6
Joined
Feb 25, 2005
Messages
230
why this event? "loses an item" is only triggered when dropping an item or the charges run out, right?

anyway. again, if there is 1 charge left and you use it then you it dissapears and you cant refer to it. maybe thats why it crashes...
 
Status
Not open for further replies.
Top