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

Item passive give +2 damage/kill

Status
Not open for further replies.
Level 13
Joined
Sep 11, 2013
Messages
467
Hello there!
How can i make an item that give permanently +2 damage for each kill you made(units or buildings) with the carrier of the item?
How about even if you kill your own units/buildings (optional).

The help will be appreacited!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
Is the damage added to the Item or to the Unit? In other words, if the Hero drops the Item do they lose the damage?

Also, the solution changes depending on which version of Warcraft 3 you're using. Remember that on older versions you don't have as many Events/Condtions/Actions and you also can't open newer version maps.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
The easiest method is to add a +2 damage ability to the killing unit:
  • Events
    • Unit - A unit acquires an item
  • Conditions
    • Item-type of (Item being manipulated) Equal to YourItem
  • Actions
    • Set Variable CV = (Custom value of (Triggering unit))
    • Set Variable ItemCount[CV] = ItemCount[CV] + 1
  • Events
    • Unit - A unit loses an item
  • Conditions
    • Item-type of (Item being manipulated) Equal to YourItem
  • Actions
    • Set Variable CV = (Custom value of (Triggering unit))
    • Set Variable ItemCount[CV] = ItemCount[CV] - 1
  • Events
    • Unit - A unit dies
  • Conditions
    • ItemCount[(Custom value of (Killing unit))] Greater than 0
  • Actions
    • Set Variable CV = (Custom value of (Killing unit))
    • For each integer ItemLoop from 1 to ItemCount[CV] do
      • Loop - Actions
        • Unit - Add Item Damage Bonus (+1) to (Killing unit)
I'm using Unit Indexing to track the number of these Items that you have equipped. You can replace the Unit Indexing method with a Hashtable if you'd like.

You could also simplify this to one trigger and Loop over the unit's inventory and count the number of items each time "A unit dies" but that'd be pretty inefficient.

To further improve the efficiency of my example method you can instead have one damage ability and use the new natives to update it's damage -> Set Ability Integer Field. You'd do this by tracking the number of kills using an Integer array similar to how ItemCount is tracked and then reference that variable when setting the damage (2 * Number of kills). Just make sure to look up how it's done as there's some tricks for updating Ability fields.
 
Last edited:
Level 13
Joined
Sep 11, 2013
Messages
467
The easiest method is to add a +2 damage ability to the killing unit:
  • Events
    • Unit - A unit acquires an item
  • Conditions
    • Item-type of (Item being manipulated) Equal to YourItem
  • Actions
    • Set Variable CV = (Custom value of (Triggering unit))
    • Set Variable ItemCount[CV] = ItemCount[CV] + 1
  • Events
    • Unit - A unit loses an item
  • Conditions
    • Item-type of (Item being manipulated) Equal to YourItem
  • Actions
    • Set Variable CV = (Custom value of (Triggering unit))
    • Set Variable ItemCount[CV] = ItemCount[CV] - 1
  • Events
    • Unit - A unit dies
  • Conditions
    • ItemCount[(Custom value of (Killing unit))] Greater than 0
  • Actions
    • Set Variable CV = (Custom value of (Killing unit))
    • For each integer ItemLoop from 1 to ItemCount[CV] do
      • Loop - Actions
        • Unit - Add Item Damage Bonus (+1) to (Killing unit)
I'm using Unit Indexing to track the number of these Items that you have equipped. You can replace the Unit Indexing method with a Hashtable if you'd like.

You could also simplify this to one trigger and Loop over the unit's inventory and count the number of items each time "A unit dies" but that'd be pretty inefficient.

To further improve the efficiency of my example method you can instead have one damage ability and use the new natives to update it's damage -> Set Ability Integer Field. You'd do this by tracking the number of kills using an Integer array similar to how ItemCount is tracked and then reference that variable when setting the damage (2 * Number of kills). Just make sure to look up how it's done as there's some tricks for updating Ability fields.

Hi, well, thanks for the answer, but i don't understand how to implement this in my map.. i am still kind a noob.

1.What variable type is: CV(i suppose is integer)?
2.What variable type is: ItemCount(integger array)?
3.In your example "Set Variable ItemCount[CV] = ItemCount[CV] + 1" --- I don't know to obtain that ItemCount[CV] + 1, i only obatain ItemCount[(CV + 1)] in brackets
4.For each integer "ItemLoop" - where is/or what is this "ItemLoop"
5.Where is this "Unit - Add Item Damage Bonus (+1)"

Sorry for all this noob questions, but i really tried to find them, but i don't know how or where..:peasant-work-work:
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
1. Integer
2. Integer array
3. You click the value of ItemCount[CV] and in there you choose the Arithmetic function. You then set the first value to ItemCount[CV] and the second value to 1 and choose addition (+). Do NOT do anything to CV, it needs to stay the same. So you're Setting the variable to be equal to it itself + the new amount.
4. It's the For Each action using a variable instead of IntegerA/B. You'd create ItemLoop yourself (it's an Integer).
5. Some of the Item abilities can stack. All of the Damage bonus abilities that you'd find on items like Claws of Attack have this capability. So you simply copy and paste one of these Item damage abilities and change it to only add +1 damage. Now whenever you Add this ability to a Unit it will gain +1 permanent damage.
Edit: I was wrong, the damage abilities do not stack. Check below for a proper solution.
 
Last edited:
Level 13
Joined
Sep 11, 2013
Messages
467
1. Integer
2. Integer array
3. You click the value of ItemCount[CV] and in there you choose the Arithmetic function. You then set the first value to ItemCount[CV] and the second value to 1 and choose addition (+). Do NOT do anything to CV, it needs to stay the same. So you're Setting the variable to be equal to it itself + the new amount.
4. It's the For Each action using a variable instead of IntegerA/B. You'd create ItemLoop yourself (it's an Integer).
5. Some of the Item abilities can stack. All of the Damage bonus abilities that you'd find on items like Claws of Attack have this capability. So you simply copy and paste one of these Item damage abilities and change it to only add +1 damage. Now whenever you Add this ability to a Unit it will gain +1 permanent damage.
I did it as you said, but seems not to work. I tested it and it give me just +1 once and then nothing.
Here is what i did:peasant-confused:
 

Attachments

  • Item +1 damage.w3m
    128.1 KB · Views: 4

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
I guess I was wrong about the Damage bonus ability, it doesn't stack. Some of the Item abilities do though, that's for certain.

Here's a fixed version which applies my suggestion about updating the ability field. This is more efficient anyway so it's better this way.
 

Attachments

  • Item +1 damage Fix.w3m
    129.6 KB · Views: 4
Level 13
Joined
Sep 11, 2013
Messages
467
I guess I was wrong about the Damage bonus ability, it doesn't stack. Some of the Item abilities do though, that's for certain.

Here's a fixed version which applies my suggestion about updating the ability field. This is more efficient anyway so it's better this way.
Work very good! Thanks!:peasant-thumbs-up:
I wonder if this trigger will interfere with other spells that use the same unit indexer:peasant-thinking:
  • Reset Variables
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
      • ItemCount[UDex] Greater than 0
    • Actions
      • -------- The Unit Indexer will recycle unused custom values. It's important that we reset variables when this happens so a new unit doesn't get an old unit's data! --------
      • Set VariableSet KillCount[UDex] = 0
      • Set VariableSet ItemCount[UDex] = 0
PS.I am very impressed with how well you explain every time you help someone and how outstandingly you work!:peasant-thumbs-up-cheers:
 
Status
Not open for further replies.
Top