Need Help , The spell never stop :(

tuantai120

Cool Member
Reaction score
1
Please help me , problem is when cast spell into target , it makes target move but never stop
JASS:
scope lk initializer Init
globals
    private constant integer SID = 'A003'
    private constant integer DID = 'h000'
    private constant string SFX = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
    private constant string Order = "firebolt"
    private constant real Interval = 0.04
    private constant real DamageBase = 150.
endglobals

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SID
endfunction

private function Damage takes integer lvl returns real
    return lvl * DamageBase
endfunction

//==========================
private function TJGetPPX takes real x, real dist, real angle returns real
    return x + dist * Cos(angle * bj_DEGTORAD)
endfunction

private function TJGetPPY takes real y, real dist, real angle returns real
    return y + dist * Sin(angle * bj_DEGTORAD)
endfunction

private struct knockback
    unit u
    unit target
    real dist
    real angle
    real tick
    timer t
    integer lvl
endstruct

private function LightKnock takes nothing returns nothing
    local knockback d = GetTimerData(GetExpiredTimer())
    local real x
    local real y
    local real kx
    local real ky
    if d.tick > 0 or GetWidgetLife(d.target) > 0 then
        set x = GetUnitX(d.target)
        set y = GetUnitY(d.target)
        set kx = TJGetPPX(x,d.dist,d.angle)
        set ky = TJGetPPY(y,d.dist,d.angle)
        call SetUnitPosition(d.target,kx,ky)
        call DestroyEffect(AddSpecialEffect(SFX,x,y))
        set d.tick = d.tick -1
    elseif d.tick <= 0 or GetWidgetLife(d.target) <= 0 then
        call ReleaseTimer(d.t)
        call knockback.destroy(d)
    endif
endfunction

private function LightKnockU takes nothing returns nothing
    local knockback d
    local unit u = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local unit dummy = CreateUnit(GetOwningPlayer(u),DID,x,y,0)
    local real dur = 1.
    local real angle = GetUnitFacing(u)
    local real dist = 400
    local real tick = 25
        if dur == 0. or dist == 0. then
            set u = null
            set target = null
            set dummy = null
            return
        endif
    call IssueTargetOrder(dummy,Order,target)
    call UnitApplyTimedLife(dummy,'BLTF',1.)
    call UnitDamageTarget(dummy,target,DamageBase,false,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
    set d = knockback.create()
    set d.u = u
    set d.target = target
    set d.tick = R2I(dur/Interval)
    set d.dist = dist/d.tick
    set d.angle = angle
    set d.lvl = GetUnitAbilityLevel(u,SID)
    set d.t = NewTimer()
    call SetTimerData(d.t,d)
    call TimerStart( d.t,Interval,true, function LightKnock)
    set u = null
    set target = null
    set dummy = null
endfunction

private function Init takes nothing returns nothing
    local trigger light = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( light , EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( light , Condition ( function Conditions ) )
    call TriggerAddAction ( light , function LightKnockU )
endfunction

endscope
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
[ljass] elseif d.tick <= 0 or GetWidgetLife(d.target) <= 0 then [/ljass]
change to :
[ljass] else [/ljass]
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Changes :
[ljass]if d.tick > 0 and IsUnitType(d.target,UNIT_TYPE_DEAD) == false then[/ljass]
 

tuantai120

Cool Member
Reaction score
1
it stops thanks :)
but why cause damage wrong ?
the spell has 3 lvl so damage in lvl 3 = 450
why it just causes 100 ?
JASS:
scope lk initializer Init
globals
    private constant integer SID = &#039;A003&#039;
    private constant integer DID = &#039;h000&#039;
    private constant string SFX = &quot;Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl&quot;
    private constant string Order = &quot;firebolt&quot;
    private constant real Interval = 0.04
    private constant real DamageBase = 150.
endglobals

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SID
endfunction

private function Damage takes integer lvl returns real
    return lvl * DamageBase
endfunction

//==========================
private function TJGetPPX takes real x, real dist, real angle returns real
    return x + dist * Cos(angle * bj_DEGTORAD)
endfunction

private function TJGetPPY takes real y, real dist, real angle returns real
    return y + dist * Sin(angle * bj_DEGTORAD)
endfunction

private struct knockback
    unit u
    unit target
    real dist
    real angle
    real tick
    timer t
    integer lvl
endstruct

private function LightKnock takes nothing returns nothing
    local knockback d = GetTimerData(GetExpiredTimer())
    local real x
    local real y
    local real kx
    local real ky
    if d.tick &gt; 0 and IsUnitType(d.target,UNIT_TYPE_DEAD) == false then
        set x = GetUnitX(d.target)
        set y = GetUnitY(d.target)
        set kx = TJGetPPX(x,d.dist,d.angle)
        set ky = TJGetPPY(y,d.dist,d.angle)
        call SetUnitPosition(d.target,kx,ky)
        call DestroyEffect(AddSpecialEffect(SFX,x,y))
        set d.tick = d.tick -1
    else
        call ReleaseTimer(d.t)
        call knockback.destroy(d)
    endif
endfunction

private function LightKnockU takes nothing returns nothing
    local knockback d
    local unit u = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local unit dummy = CreateUnit(GetOwningPlayer(u),DID,x,y,0)
    local real dur = 1.
    local real angle = GetUnitFacing(u)
    local real dist = 400
    local real tick = 25
        if dur == 0. or dist == 0. then
            set u = null
            set target = null
            set dummy = null
            return
        endif
    call IssueTargetOrder(dummy,Order,target)
    call UnitApplyTimedLife(dummy,&#039;BLTF&#039;,1.)
    call UnitDamageTarget(dummy,target,DamageBase,false,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
    set d = knockback.create()
    set d.u = u
    set d.target = target
    set d.tick = R2I(dur/Interval)
    set d.dist = dist/d.tick
    set d.angle = angle
    set d.lvl = GetUnitAbilityLevel(u,SID)
    set d.t = NewTimer()
    call SetTimerData(d.t,d)
    call TimerStart( d.t,Interval,true, function LightKnock)
    set u = null
    set target = null
    set dummy = null
endfunction

private function Init takes nothing returns nothing
    local trigger light = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( light , EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( light , Condition ( function Conditions ) )
    call TriggerAddAction ( light , function LightKnockU )
endfunction

endscope
 

_whelp

New Member
Reaction score
54
Well you aren't calling your [ljass]function Damage takes integer lvl returns real[/ljass] function, and I think [ljass]ATTACK_TYPE_HERO[/ljass] will have reduced damage by armor, but I'm not sure...
 

Executor

I see you
Reaction score
57
As _whelp said, you only use your BaseDamage which is 150. and this will be reduced to ~100, because of hero damagetype. Just insert your function and change damage type to chaos (if you want the 450 to be dealt 100%).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top