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

add spell to unit

Status
Not open for further replies.
Level 9
Joined
May 30, 2008
Messages
430
I need trigger that to add spell to unit that buy dummy item/unit but i can't even detect the item buying event and when the unit buy the item item is dropped on the ground (the trigger must be for units not for heroes) if some one can help with this will be nice
 
Level 19
Joined
May 1, 2008
Messages
1,130
  • add ability
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Hero manipulating item) has an item of type "dumy item" Equal to True
    • Actions
      • Hero - Drop (Item being manipulated) from (Hero manipulating item)
      • Unit - Add "your spell" to (Hero manipulating item)
this shall work for units and heroes
 
Level 4
Joined
Mar 15, 2008
Messages
71
...
  • -.-'
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to <your dummy unit type>
    • Actions
      • Unit - Remove (Sold unit) from the game
      • Unit - Add <Your Spell> to (Buying unit)
      • Unit - Set level of <Your Spell> for (Buying unit) to 1//If you are adding a spell to a non-hero unit you must set the level of his spell to 1(for start) and for upgrading you could use a variable that would store upgrades/buying of your dummy unit ,so you could set the appropriate level of the spell :)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
He want a dota like system?
Where you can Buy stuff with full inventory.
Guessing:
Maybe something with orders.

@raid1000 he said not for heroes ;)
 
Level 9
Joined
May 30, 2008
Messages
430
thanks AKI_SER everything work but i have 1 more request my unit sells the units so when i buy the unit and the unit have the ability i wonna to remove the unit from selling unit i try this but don't work don't know why i add "sell units" ability but still don't work for my unit
  • Test1
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Footman
    • Actions
      • Unit - Remove (Sold unit) from the game
      • Unit - Add Critical Strike (Neutral Hostile) to (Selling unit)
      • Unit - Set level of Critical Strike (Neutral Hostile) for (Selling unit) to 1
      • Neutral Building - Remove Footman from (Selling unit)/The problem is in this line if some one can tell me how to fix it i will be very happy
or if some one can tell me how to add ability to unit after the unit have x kills and how to do this becouse i do those things for first time and no can't do them working
 
Level 3
Joined
Jan 30, 2005
Messages
38
Not sure what the problem is with the Neutral Building command..

But you can add the ability after a certain amount of kills a number of ways.
To control it, I would tend to check kills after every kill.

For example:
Event - Unit kills unit

Conditions - Killing unit equal to Footman

Actions -
If UnitKills = 10
Then Add ability..
Else Set UnitKills = UnitKills + 1

Hope that helps
 
Level 3
Joined
Jan 30, 2005
Messages
38
lol ok, so you want it for multiple units?
Explain in depth what you need.. because you'll need to do things a certain way if its specific.

But to count kills for multiple units:
Create an "integer" variable with an array of '1'
Then you can store the units kills as :
Unit 1 makes a kill then : UnitKills[1] = UnitKills[1] + 1

or Unit 2 makes a kill then itd be : UnitKills[2] = UnitKills[2] + 1
etc etc..

Make sense?

Please post with more detail about this though, because it won't work unless its specifically assigned to a unit.. unless its very simple..

Thx
 
Level 3
Joined
Jan 30, 2005
Messages
38
Yep, okay... so I've tried to comment the following to make sense of it..
Its 3 variables in 2 triggers. You can spread out the addition of abilities over multiple triggers if you wish.
I've used Integer Looping for the kill trigger, which basically chooses a number, runs everything beneath it inserting the number into where it specfies, then loops choosing a different number every time.

The variables:
UnitKills - Integer with array of 1.
UnitCount - Integer, no array
UnitAssigned - Unit variable with array of 1

The triggers:

TRIGGER 1:
"Creation"
Events
Map initialization
Conditions
Actions
-------- IMPORTANT NOTE : ALL VARIABLE NUMBERS MUST MATCH. --------
-------- UnitKills[1] must be the kills of UnitAssigned[1] <--- very important the number [1], or whatever it is, is the same for all variables concerned. --------
-------- Simple creation of a footman. --------
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
-------- Firstly, a count for all your units. Secondly, allows other triggers to work. --------
Set UnitCount = (UnitCount + 1)
Set UnitKills[UnitCount] = 0
-------- Sets the number to a unit variable, so when that unit kills, it can be found --------
Set UnitAssigned[UnitCount] = (Last created unit)


[ --- The trigger creates and assigns the unit. You can change this to make it mass produce units and assign every single unit with a number, or on a different event.. no limitations. --- ]

TRIGGER 2:
"OnDeath"
Events
Unit - A unit Dies
Conditions
Actions
-------- Integer loops, will go through every unit from 1 -> your UnitCount --------
For each (Integer A) from 1 to UnitCount, do (Actions)
Loop - Actions
-------- Firstly find which unit is your killing unit... --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Killing unit) Equal to UnitAssigned[(Integer A)]
Then - Actions
-------- Once its found the killing unit, then it sets the unitkills + 1 --------
Set UnitKills[(Integer A)] = (UnitKills[(Integer A)] + 1)
-------- Secondly, once the counts and additions are done, check if kills are 10 or 15.. and set ability --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UnitKills[(Integer A)] Equal to 10
Then - Actions
-------- Set the ability --------
Unit - Add Bash to UnitAssigned[(Integer A)]
Else - Actions
Do nothing
Else - Actions
Do nothing


[ --- So, when the unit dies, it'll find which unit did the killing, add a kill to its score, then check how many kills it has to see if it needs to add an ability --- ]

Hope this helps..
and I hope I've done it the way you needed



SORRY- Not very clear, I don't now how to insert the trigger on the white bg.. if you tell me I can do this for you..
 
Level 9
Joined
May 30, 2008
Messages
430
i will begin creating and testing will tell the results when i am rdy
hmm when i am reading the trigger is hard to see the trigger and my units are created from baracs not spawn in region but anyway i will try to make the trigger working but i don't think will succeed.

Somthing is wrong here this shit can't detect the killing unit and add kills to it

  • Set units
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Unit-type of (Entering unit)) Equal to Footman
    • Actions
      • Set UnitAssignet[UnitCount] = (Last created unit)
      • Set UnitCount = (UnitCount + 1)
      • Set UnitKills[UnitCount] = 0
      • Game - Display to (All players) for 30.00 seconds the text: unit set
  • Add skill
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer A) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Killing unit) Equal to UnitAssignet[(Integer A)]
            • Then - Actions
              • Set UnitKills[(Integer A)] = UnitKills[((Integer A) + 1)]
              • Game - Display to (All players) for 30.00 seconds the text: add kill
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitKills[(Integer A)] Equal to 10
                • Then - Actions
                  • Unit - Add Bash (Neutral Hostile 1) to UnitAssignet[(Integer A)]
                  • Unit - Set level of Bash (Neutral Hostile 1) for UnitAssignet[(Integer A)] to 1
                  • Game - Display to (All players) for 30.00 seconds the text: ability add
                • Else - Actions
            • Else - Actions
in upper part of the menu have red icon named Tube next to it is for jass and next to jass is for WE if you don't find the icon for WE use those tags ["TRIGGER]Your Trigger[/TRIGGER"] without "
 
Last edited:
Level 3
Joined
Jan 30, 2005
Messages
38
then change the event to:

a unit finishes training a unit..

  • Creation
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • -------- IMPORTANT NOTE : ALL VARIABLE NUMBERS MUST MATCH. --------
      • -------- UnitKills[1] must be the kills of UnitAssigned[1] <--- very important the number [1], or whatever it is, is the same for all units. --------
      • -------- Firstly, a count for all your units. Secondly, allows other triggers to work. --------
      • Set UnitCount = (UnitCount + 1)
      • -------- Sets the number to a unit variable, so when that unit kills, it can be found --------
      • Set UnitAssigned[UnitCount] = (Trained unit)


I dont know how to post the trigger with the white bg.. so im sorry if its hard to read.
 
Last edited:
Level 3
Joined
Jan 30, 2005
Messages
38
yeh you've got it in the wrong order.. you've got to remember, when the trigger executes it goes line by line..

Do exactly this, in this order:

[-EDIT-]
You may also want to set the variables to 0 on Map init.
  • Starter
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set UnitCount = 0
-- This eliminates the chance of a screw up.

[-EDIT #2-]
I looked back over your triggers..
MAKE SURE you fix this, because it is the 2nd major problem which I just noticed.
  • Set UnitKills[(Integer A)] = UnitKills[((Integer A) + 1)]
-- This will not work because you are essentially saying (Using Unit 1 as an example): Set UnitKills[1] = UnitKills[2] ---- > UnitKills[((Integer A) + 1)]
This needs to be:
  • Set UnitKills[(Integer A)] = UnitKills[(Integer A)] +1)
Very important. This says: Set UnitKills[1] = UnitKills[1] + 1

  • Creation
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Footman
    • Actions
      • Set UnitCount = (UnitCount + 1)
      • Set UnitAssigned[UnitCount] = (Trained unit)
      • Set UnitKills[UnitCount] = 0
  • OnDeath
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer A) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Killing unit) Equal to UnitAssigned[(Integer A)]
            • Then - Actions
              • Set UnitKills[(Integer A)] = (UnitKills[(Integer A)] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitKills[(Integer A)] Equal to 10
                • Then - Actions
                  • Unit - Add Bash to UnitAssigned[(Integer A)]
                  • Unit - Set level of Bash (Neutral Hostile 1) for UnitAssigned[(Integer A)] to 1
                • Else - Actions
                  • Do nothing
            • Else - Actions
              • Do nothing

this will work
 
Level 9
Joined
May 30, 2008
Messages
430
  • Start
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set UnitCount = 0
Work
  • Set units
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Footman
    • Actions
      • Set UnitCount = (UnitCount + 1)
      • Set UnitAssignet[UnitCount] = (Trained unit)
      • Set UnitKills[UnitCount] = 0
      • Game - Display to (All players) for 30.00 seconds the text: unit set
Work
  • Add skill
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer A) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Killing unit) Equal to UnitAssignet[(Integer A)]
            • Then - Actions
              • Set UnitKills[(Integer A)] = UnitKills[((Integer A) + 1)]
              • Game - Display to (All players) for 30.00 seconds the text: add kill
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitKills[(Integer A)] Equal to 10
                • Then - Actions
                  • Game - Display to (All players) for 30.00 seconds the text: ability add
                  • Unit - Add Bash (Neutral Hostile 1) to UnitAssignet[(Integer A)]
                  • Unit - Set level of Bash (Neutral Hostile 1) for UnitAssignet[(Integer A)] to 1
                • Else - Actions
            • Else - Actions
the part where add ability trigger don't run there don't know why
 
Level 3
Joined
Jan 30, 2005
Messages
38
You mean where it finishes training a unit?
Ummm.. no that shouldnt matter.. in fact you could remove that condition entirely.

  • (Unit-type of (Trained unit)) Equal to Footman <--- that one
Its not important if your assigning it to a variable, so try it without.. and let me know.
 
Level 9
Joined
May 30, 2008
Messages
430
if i remove the condition how the trigger will know who unit to add i think if i remove the condition the trigger will add the ability to all units that make kills

EVERYTHING IS READY NOW tnx for the help NoMAd +rep
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
The trigger named Start is useless. There is initial value in the variable window ...
To make it work for more than one type of unit, you must use the "OR any conditions".
Trigger "add skill" is inefficient.
Use custom values. For instance, in set units, set the custom value of the unit to unit count. And in "add skill" you can find the killing unit in the array much faster.
So, unit # 10 is produced, set unit's custom value to 10. Unit kills a unit, Get unit custom value - 10. Now find UnitKills[Unit CUstom value] - UnitKills[10].

Or just go to wc3campaigns.net and get PUI.
 
Status
Not open for further replies.
Top