• 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.

Help with "Unequip" Trigger

Status
Not open for further replies.
Level 5
Joined
Feb 1, 2009
Messages
107
I wanna do a trigger that makes my character unequip its current weapon. By "weapon" I mean the special effect attached to his hand. The first choice would be:

  • Unequip
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Unequip Current Weapon
    • Actions
      • Special Effect - Destroy (Last created special effect)
Of course, that would most likely destroy unwanted special effects, since they are being created all the time in my map.
So, i had to find a way so specify which Special Effect the "Unequip Current Weapon" button will destroy. I found one way, but I think it's way too complicated, and may not even work... I would have to change all the "Equip" triggers to something like...

  • Equip Sword
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Equip Sword
    • Actions
      • Special Effect - Create a special effect attached to the right hand of (Triggering unit) using Basic Sword.mdx
      • Set Equip = Player[(Player number of (Owner of (Triggering unit)))]
      • For each (Integer Equip) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (Equip Equal to 1) then do (Set redhassword = (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 2) then do (Set bluehassword = (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 3) then do (Set "color"hasword= (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 4) then do (Set "color"hasword= (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 5) then do (Set "color"hasword= (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 6) then do (Set "color"hasword= (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 7) then do (Set "color"hasword= (Last created special effect)) else do (Do nothing)
          • If (Equip Equal to 8) then do (Set "color"hasword= (Last created special effect)) else do (Do nothing)
      • Unit - Remove Spell Book from (Triggering unit)
      • Unit - Add Unequip Current Weapon to (Triggering unit)
The "Spell Book" in the second last action is the "Equip Weapons" ability, which opens the current weapon choices the character has. "Equip Sword" is an ability inside this Spell Book.

So, basically, what I wanted to do with this thing is set a "special effect" variable for each possible case of a Player (my map has 8 players max) ordering his unit to equip a sword (and my map will have other weapons besides swords). So when I wanted to destroy the effect, so that the character unequips the weapon, I'd be able to specify which effect I want destroyed.

I wonder if there is any easier option to do this? :eekani:
 
Level 6
Joined
Apr 24, 2008
Messages
174
You need to create an Variable for your special effect...

1: Create the special effect
2: Create a Variable named for example: Unequip_Effect
Variable type: Special Effect
3: Now set the Variable:
Set Unequip_Effect = Last created special effect
4: In the "Unequip" trigger, change the "Destroy (Last created special effect)
and make it to: Special Effect - Destroy (Unequip_Effect)

That should do the job ;)
Hope it helpes
 
Level 5
Joined
Feb 1, 2009
Messages
107
ok, but this way i will have to create variables for each type of weapon and for each player, isnt it? Because if I just create one variable, I'll end up with the same problem. Example:

Player 1 uses the equip trigger:

  • Equip Sword
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Equip Sword
    • Actions
      • Special Effect - Create a special effect attached to the right hand of (Triggering unit) using Basic Sword.mdx
      • Set equippedsword = (Last created special effect)
Then Player 2 uses the same trigger to equip his sword, also.

After that, Player 1 wants to unequip his sword, so he uses the unequip trigger:

  • Equip Sword
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Unequip Current Weapon
    • Actions
      • Special Effect - Destroy equippedsword
So what will happen is that Player 1 is gonna destroy Player 2's sword, because he equiped it last, and "equippedsword" reffers to the last created special effect :p

I think I got it with two very simple triggers :D

See if you guys think it'll work:

  • Equip Sword
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Equip Sword
    • Actions
      • Special Effect - Create a special effect attached to the right hand of (Triggering unit) using Basic Sword.mdx
      • Set equippedsword[(Player number of (Owner of (Triggering unit)))] = (Last created special effect)
  • Unequip Sword
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Unequip Current Weapon
    • Actions
      • Set usingsword[(Player number of (Owner of (Triggering unit)))] = (Integer A)
      • For each (Integer A) from 1 to 8, do (Special Effect - Destroy equippedsword[(Integer A)])
With this I only have to create a trigger for every existing weapon on my RPG, but at least i don't have to specify which players is commanding his character to equip/unequip. The variables should do it with their arrays.
 
Last edited by a moderator:
Level 5
Joined
Feb 1, 2009
Messages
107
Nope. In the unequip one, just do

"Destroy (Equipped sword[Player number of triggering player])"

Yes, that's better =P
I got it to work, I believe. Still have to test equiping/unequiping weapons simultaneously with more than 1 player in the map, but it'll probraly work.

NEW PROBLEM:
My "Unequip Current Weapon" ability takes a bit too long to work... In the trigger i put "Unit begins casting and ability" as an event, but still it takes like 3 seconds for the sword to disappear from the character's hand. I'm using War Stomp as a base ability. Wonder if the game is waiting the correspondent time a War Stomp would take to play its animation (even though the animation is obviously turned off by me) to trigger the action (destroy the sword effect).

Any ideas?
 
Level 5
Joined
Feb 1, 2009
Messages
107
Ok, my tip here is that you use another ability, for example: Divine Shield
Just make sure you change the durration of the spell to 0.01 or such.

Result: Still takes about 5 seconds for the weapon to disappear from the character, plus he gets a divine shield animation + bluff, both lasting undefinitely =p

War stomp is just weird. I suggest using Channel.

Result: Custom ability using "Channel" as base doesnt appear at character's menu.

More options? =x
Or am I doing something wrong at the ability editor?
 
Level 5
Joined
Feb 1, 2009
Messages
107
In the Data - Options field, enable Visible.

Yay, it appeared now!

Oh, still takes 5 seconds to do what I want it to do =(

Same case with every ability I use, I must be editing something wrong at the editor... any idea what is it?

Come to think of it, this unexpected delay could be used to prevent abuses, such as a player constantly switching weapons to gain their respective bonuses at the same time, or something like that. I might just leave it be, and add a message like "Unequipping weapon. Please wait 5 seconds...".

Or even making a condition for him to unequip the weapon, like "being next to a weapon rack". What do you guys think about this one? :D

Still, for the purpose of learning, I'm still interested in knowing why does it happen =P.
 
Last edited by a moderator:
Level 7
Joined
Jul 20, 2008
Messages
377
Try checking the unit's casting "backswing" and "point" animation times, the spell's animation names, the spell's casting time, etc.

And if you want to prevent abuse, I would suggest having a cooldown as opposed to casting time. Having a casting time to prevent abuse is a bit counter-intuitive, I would say.
 
Level 5
Joined
Feb 1, 2009
Messages
107
Checked those things you said and still have the problem o_O

It's funny how I only get the 5 sec delay for unequiping the weapon, and get no delay for equiping it, since I'm using the same spell as a base for both Equip and Unequip actions.
 
Level 5
Joined
Feb 1, 2009
Messages
107
Triggers:

  • Equip Sword
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Equip Sword
    • Actions
      • Unit - Remove warriorweapons from (Triggering unit)
      • Unit - Add Unequip Current Weapon to (Triggering unit)
      • Unit - Move (Triggering unit) instantly to (Position of (Triggering unit))
      • Special Effect - Create a special effect attached to the right hand of (Triggering unit) using Basic Sword.mdx
      • Set equippedsword[(Player number of (Owner of (Triggering unit)))] = (Last created special effect)
  • Unequip
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Unequip Current Weapon
    • Actions
      • Unit - Remove Unequip Current Weapon from (Triggering unit)
      • Unit - Add warriorweapons to (Triggering unit)
      • Unit - Move (Triggering unit) instantly to (Position of (Triggering unit))
      • Special Effect - Destroy equippedsword[(Player number of (Owner of (Triggering unit)))]
"warriorweapons" is a spellbook containing the "equip sword spell". when a character uses the equip sword spell, I want him to lose the spellbook ability ang gain the unequip ability. Then he switches again when he unequips. That explains the first two actions in each trigger.

The third action may look a bit weird...
I was having a problem before with this trigger. without that third action, after I removed/added the abilities, the character would bug and not respond to any order, being stuck. Doing that with him, somehow, fixed that bug.

the special effects are the main thing for the triggers, adding/removing the weapon from the character's hand. the variable specifies to the game which special effect i want to remove afterwards.
 
Level 5
Joined
Feb 1, 2009
Messages
107
I FINALLY FIXED IT!!! :D :D

A guy on another forum mentioned that the time it takes for the special effect to disappear could be the same time it takes to aura effects to vanish from units after they are no longer next to the aura.
So I searched the Gameplay Constants and found "Decay Time - Effects". Setting it to 0 has made my unequip effect work instantly ^^

My trigger now works 100% :D
 
Status
Not open for further replies.
Top