• 🏆 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!

Damage on buff?

Status
Not open for further replies.
Level 5
Joined
Apr 6, 2006
Messages
98
I'm making a spell that deals a value of a hero's attribute per level, the damage issue is alright for me, nothing needs fixing.

However the problem im facing is that, for example i want the damage only to occur after the ability successfully hits, not after being "casted". Meaning if lets say i use a default storm bolt spell, i want the damage to hit only after the hammer has hit the target (i.e the buff activated)

i have a SS of my trigger so far

whatswrong-2.jpg


the skill damage works perfectly without the "unit has a buff" segment, but when i try this the spell damage dont work at all.
 
It needs the action
  • Wait until (((Target unit of ability being cast) has buff Stunned (Pause)) Equal to True), checking every 0.10 seconds
but since this isn't efficient, I made a Jass version for you (doesn't need JNGP).

  • Hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
JASS:
function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000' //Replace the Raw Code of the ability with the rawcode of your ability.
   //Hit Ctrl+D in the abilities tab, Object Editor to check what's the rawcode of your ability.
endfunction

function TimerDamage takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit u = LoadUnitHandle (udg_Hash, id, StringHash("target"))
    local unit u1 = LoadUnitHandle (udg_Hash, id, StringHash("caster"))
    local real r = LoadReal (udg_Hash, id, StringHash("dmg"))
    if UnitHasBuffBJ (u, 'BPSE') then
        call UnitDamageTarget (u1, u, r, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
        call FlushChildHashtable (udg_Hash, id)
        call DestroyTimer (t)
    endif
    set u = null
    set u1 = null
    set t = null
endfunction

function Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local unit u1 = GetTriggerUnit()
    local real r = GetUnitAbilityLevel (u1, 'A000')*2 + GetHeroStr (u1, true) //'A000' is here too. Don't forget to replace it with the rawcode of your ability.
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    call SaveUnitHandle (udg_Hash, id, StringHash("target"), u)
    call SaveUnitHandle (udg_Hash, id, StringHash("caster"), u1)
    call SaveReal (udg_Hash, id, StringHash("dmg"), r)
    call TimerStart (t, 0.1, true, function TimerDamage)
    set t = null
    set u = null
    set u1 = null
endfunction

//===========================================================================
function InitTrig_StormBolt takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction

Test Map: View attachment Storm Bolt + Custom Damage.w3x
 
Status
Not open for further replies.
Top