• 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] Ability Trigger

Status
Not open for further replies.
Level 1
Joined
Jun 21, 2009
Messages
282
I want this ability to be a copy-ability

This one spell is a copy ability effect, so basically I want this ability to give your hero a buff/effect that lasts 30 seconds and then if other heros use abilitys around 1200 range of you, then you learn that ability and adds into your ability slots, when the buff/effect ends, you lose the abilitys you gained from the other heros, and make it so some abilitys can't be copyed. Only make it so you can copy 2 abilitys.

Please and thank you Rep+
 
Level 3
Joined
Dec 6, 2005
Messages
67
don't have access to the WE right now, but i'll give you the jist, shouldn't be that hard
basically use an ability that already gives a buff like 'Bloodlust' for example
now do (trigger was written by hand so text might be a little different from the editor)
  • Events
    • Generic Unit Event - Unit Starts the Effect of an Ability
  • Conditions
  • Actions
    • Pick Every Unit within 1200 of (triggering unit) matching condition ((matching unit) has buff 'bloodlust') and do actions
      • loop actions
        • Unit - add ability (ability being cast) to picked unit
see if you can get that to work... that won't limit the number of abilities to 2, but we can handle that later.
 
Level 1
Joined
Jun 21, 2009
Messages
282
don't have access to the WE right now, but i'll give you the jist, shouldn't be that hard
basically use an ability that already gives a buff like 'Bloodlust' for example
now do (trigger was written by hand so text might be a little different from the editor)
  • Events
    • Generic Unit Event - Unit Starts the Effect of an Ability
  • Conditions
  • Actions
    • Pick Every Unit within 1200 of (triggering unit) matching condition ((matching unit) has buff 'bloodlust') and do actions
      • loop actions
        • Unit - add ability (ability being cast) to picked unit
see if you can get that to work... that won't limit the number of abilities to 2, but we can handle that later.

Alright, but then how would you remove the ability once the buff is over?
 
Level 3
Joined
Feb 13, 2008
Messages
65
Ok first of all you need 3 triggers to make this work successfully. You also need to make 4 variables:
1 . SpellCopied(Array) = Ability variable array with a max of 2
2. SpellsCopied = Integer variable (No array)
3. SpellCopierUnit = Unit variable (No array)
4. SpellCopiedTimer(Array) = Timer variable array with a max of 2

Ok, so your first trigger should be this:

Trigger 1
  • Events
  • Unit - A unit starts the effect of an ability
  • Conditions
  • Actions
    • Unit Group - Pick every unit in (Units within 1200.00 of (Position of (Triggering Unit)) matching (((Matching Unit) has buff YourCopySpell) Equal to True and do (Actions)
    • Loop - Actions
      • Unit - Add (Ability being cast) to (Picked Unit)
      • Set SpellCopierUnit = (Picked Unit)
      • Set SpellsCopied = (SpellsCopied +1)
      • Set SpellCopied[SpellsCopied] = (Ability being cast)
      • Countdown Timer - Start SpellCopiedTimer[SpellsCopied] as a One-shot timer that will expire in 30.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • SpellsCopied Equal to 2
      • Then - Actions
        • Trigger - Turn off (This trigger)
        • Wait 30.00 seconds
        • Trigger - Turn on (This trigger)
      • Else - Actions
Second Trigger:

  • Events
  • Time - SpellCopiedTimer[1] expires
  • Conditions
  • Actions
  • Unit - Remove SpellCopied[1] from SpellCopierUnit
  • Set SpellsCopied = (SpellsCopied - 1)

Third trigger is similar to the second

  • Events
  • Time - SpellCopiedTimer[2] expires
  • Conditions
  • Actions
  • Unit - Remove SpellCopied[2] from SpellCopierUnit
  • Set SpellsCopied = (SpellsCopied - 1)

The last thing you need to do is put
  • Set SpellsCopied = 0
in one of your map initialization triggers.



I did not test this, but it should work. This is how it will basically function:

When the map initializes, it will set the integer variable SpellsCopied to 0. Once someone playing the map gains the buff that copies spells and someone cast a spell within 1200 units of him, that spell will be stored as SpellCopied[1], the unit who stole the spell will be set as SpellCopierUnit, and a timer SpellCopiedTimer[1] will be created and start counting down from 30 seconds, and after the 30 seconds expire the second trigger will function and remove SpellCopied[1] from the unit, and it will also subtract 1 from SpellsCopied so the game recognizes that you have one less copied spell currently learned.

Then, when a second spell is cast while the unit still has your spell copying buff, it will do the same thing it did with SpellCopied[1] except it will be SpellCopied[2]. The only difference with this is that the first trigger will recognize that you have copied 2 spells, and it will disable itself for 30 seconds using that wait action. (You can change how long it disables itself based on how long you want before the unit can copy spells again)

This should work, and i did not check for leaks.
 
Last edited:
Level 3
Joined
Dec 6, 2005
Messages
67
i don't think the above code is MUI however... might still want to try hashtables, but if its just one hero with the ability then by all means use the above
 
Level 3
Joined
Feb 13, 2008
Messages
65
i don't think the above code is MUI however... might still want to try hashtables, but if its just one hero with the ability then by all means use the above


If you want to edit the above code to fit multiple units using it at the same time, just change the SpellCopierUnit variable into an array and it works perfectly
 
Level 3
Joined
Feb 13, 2008
Messages
65
The map is attached. You get a test hero with the copy spells ability. Then i added 3 test enemies, each with a certain spell (chain lightning, faerie fire, curse) just to test to make sure that A) it will not let you have more than 2 copied at a time and B) it works.

Be sure to type -test to make the enemies use their spell on you.

Edit: Im sorry the previous one that i linked had a small bug with it. Please use this one
 

Attachments

  • CopySpell.w3x
    19 KB · Views: 54
Level 1
Joined
Jun 21, 2009
Messages
282
The map is attached. You get a test hero with the copy spells ability. Then i added 3 test enemies, each with a certain spell (chain lightning, faerie fire, curse) just to test to make sure that A) it will not let you have more than 2 copied at a time and B) it works.

Be sure to type -test to make the enemies use their spell on you.

Edit: Im sorry the previous one that i linked had a small bug with it. Please use this one

Alright so, does this copyspell copy itself if used by an enemy hero?

And how do I make it so certain abilitys cannot be copyed?

After these 2 are solved, this thread will be done. Rep+
 
Level 3
Joined
Feb 13, 2008
Messages
65
Alright so, does this copyspell copy itself if used by an enemy hero?

And how do I make it so certain abilitys cannot be copyed?

After these 2 are solved, this thread will be done. Rep+

Yes, it will copy any spell that is used against the hero with the spell. This includes any spell, such as heals that are used on him from allies.

If you want to make certain abilities not be able to be cast on the hero, simply add under the conditions of the first trigger "Ability being cast Not Equal to (ability you dont want). And if you want to make it only enemy spells, then add (Triggering Unit) is an ally of (Target Unit of Ability being Cast) equal to false.
 
Level 3
Joined
Feb 13, 2008
Messages
65
Sometimes its best if you figure certain things out for yourself. At first I gave you the logic needed for this spell to function. Then I actually made a test map with the spell functioning for you, and set it up with dummies and everything else you needed.

Play around with the spell. Dont rely on people to tell you how to do things that you could figure out in seconds such as how to check if a unit casting a spell is an ally of another. You will learn much faster and better if you figure things out for yourself.

I dont mean to be harsh, but if I lead a horse to water, and the horse doesnt know how to drink, then its an issue that the horse must deal with on his own.
 
Level 1
Joined
Jun 21, 2009
Messages
282
Sometimes its best if you figure certain things out for yourself. At first I gave you the logic needed for this spell to function. Then I actually made a test map with the spell functioning for you, and set it up with dummies and everything else you needed.

Play around with the spell. Dont rely on people to tell you how to do things that you could figure out in seconds such as how to check if a unit casting a spell is an ally of another. You will learn much faster and better if you figure things out for yourself.

I dont mean to be harsh, but if I lead a horse to water, and the horse doesnt know how to drink, then its an issue that the horse must deal with on his own.

Ah.. okay, I know what you mean.

Thank you for the spell Tiaan.
 
Status
Not open for further replies.
Top