Remove Effect (Model) Attached to Unit?

Tyrulan

Ultra Cool Member
Reaction score
37
Here's the code:

JASS:
        call SetUnitAnimation( caster, "attack" )
        call AddSpecialEffectTargetUnitBJ( "hand, left", caster, "war3mapImported\\Final Rod.mdx" )
        set fD.casterRod = GetLastCreatedEffectBJ()


It is contained within the create of my struct.

In the onDestroy() I am destroying it.

JASS:
    method onDestroy takes nothing returns nothing
        set this.caster = null        
        call DestroyEffectBJ(this.casterRod)        
    endmethod


However it is still there? Attached the left hand of my unit. :( Please go away!!! Lol
 

wraithseeker

Tired.
Reaction score
122
local [structname] this is always generated in methods so this or . will work well.

Mind showing the whole code? You can try removing those BJ too.

In your create method simply just put set
JASS:
fD.casterRod = AddSpecialEffectTarget(//parametres)
 

Tyrulan

Ultra Cool Member
Reaction score
37
I've fixed this problem. However it takes about.. 5-6 seconds for the model to be removed from the unit. Any way to make this faster?

For anyone who cares here's my solution.

JASS:
call AddSpecialEffectTargetUnitBJ( "hand, left", caster, "war3mapImported\\Final Rod.mdx" )
set fD.casterRod = bj_lastCreatedEffect


JASS:
method onDestroy takes nothing returns nothing
     set this.caster = null        
     call DestroyEffectBJ(this.casterRod)     
endmethod
 

Nexor

...
Reaction score
74
at gameplay constants you can set the time for effects to be removed, but it'll change every effect's time.
 

wraithseeker

Tired.
Reaction score
122
Maybe this library would help

JASS:
library TargetTimedEffects requires TimerUtils

private struct data
    effect EFFECT
    timer t

static method create takes nothing returns data
    local data d = data.allocate()
    set d.t = NewTimer()
    return d
endmethod

endstruct

function StopEffect takes data instance returns nothing
    call DestroyEffect(instance.EFFECT)
    call ReleaseTimer(instance.t)
    call instance.destroy()
endfunction

private function DestroyEffects takes nothing returns nothing
    local data d = GetTimerData(GetExpiredTimer())
    call DestroyEffect(d.EFFECT)
    call ReleaseTimer(d.t)
    call d.destroy()
endfunction
    
function AddTimedSpecialEffect takes string EFFECT, real x, real y, real TIME returns nothing
    local data d = data.create()
    call SetTimerData(d.t,d)
    call TimerStart(d.t,TIME,false,function DestroyEffects)
    set d.EFFECT = AddSpecialEffect(EFFECT,x,y)
endfunction
    
function AddTimedEffectTarget takes string EFFECT, unit target, string attachpoint, real TIME returns nothing
    local data d = data.create()
    call SetTimerData(d.t,d)
    call TimerStart(d.t,TIME,false,function DestroyEffects)
    set d.EFFECT = AddSpecialEffectTarget(EFFECT,target,attachpoint)
endfunction

endlibrary
 

Tyrulan

Ultra Cool Member
Reaction score
37
Looks great Wraith, though I'm a little unfamiliar with libraries and not sure how to actually use this. Thanks guys!!
 

_whelp

New Member
Reaction score
54
I've fixed this problem. However it takes about.. 5-6 seconds for the model to be removed from the unit. Any way to make this faster?

For anyone who cares here's my solution.

JASS:

call AddSpecialEffectTargetUnitBJ( "hand, left", caster, "war3mapImported\\Final Rod.mdx" )
set fD.casterRod = bj_lastCreatedEffect


JASS:

method onDestroy takes nothing returns nothing
     set this.caster = null        
     call DestroyEffectBJ(this.casterRod)     
endmethod

Your fishing rod may not have any animations if it stays for 5-6 seconds.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>it takes about.. 5-6 seconds for the model to be removed from the unit.
It is the model's death period?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top