• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Item Charge

Status
Not open for further replies.
Level 1
Joined
May 16, 2013
Messages
7
Is it possible to make an item that gives an additional damage based on its number of charge. If yes, how?

THANKS
 
Level 6
Joined
Feb 5, 2012
Messages
1,685
Event

A Unit is Attack

Condition

Attacking unit has an item of (YOUR ITEM)
(YOUR ITEM) carried by Attacking Unit has a charge with not equal to 0

Then

Unit - Cause Attacking Unit to deal (base damage) x (number of item charge) to the attack unit



Using this way.. it is not complicated.. you can add also different conditions and
YOU CAN SET THE DAMAGE TYPE YOU WANT (Sorry for the caps)

You can add also Floating Texts in it!
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Try this...
http://www.hiveworkshop.com/forums/jass-resources-412/system-physical-damage-detection-228456/

JASS:
scope ChargesDam initializer init

private function onDamage takes nothing returns nothing
   local integer slot = 0
   local integer charges = 0
   local real fullDamage
   local item it
   if damageType == PHYSICAL then
      loop
           set it = UnitItemInSlot(source, slot)
           if GetItemTypeId(it)=='I000' and GetItemCharges(it) > 0 then
              set charges = GetItemCharges(it)
              exitwhen true
           endif
           set slot = slot + 1
           exitwhen slot==6
      endloop
      set fullDamage = charges*amount //this is the damage
      call UnitDamageTarget(source, target, fullDamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
   endif
   set it = null
endfunction

private function init takes nothing returns nothing
    call AddDamageHandler(function onDamage)
endfunction

endscope

where 'I000' is the raw ID of the item in the object editor...
 
Last edited:
Status
Not open for further replies.
Top