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

[JASS] Problem with effects being shown in this script

Status
Not open for further replies.
Level 18
Joined
Nov 1, 2006
Messages
1,612
I'm working on my first full JASS script and I have loosely followed some tutorials to figure out how to get what I want. However, when my effects are supposed to be created, UDeathSmall shows VERY quickly and then disappears (not playing it's full animation before being removed) and HowlTarget does not even show up.

Can anyone spot the problem? I'm sure there's a few considering this is my first attempt at a full JASS script.

JASS:
function Trig_EnableVampirism_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A002' ) ) then
        return false
    endif
    return true
endfunction

function Trig_EnableVampirism_Actions takes nothing returns nothing
    local effect b
    local unit u = GetSpellTargetUnit()
    local unit t = GetTriggerUnit()
    call TriggerSleepAction( 0.15 )
    // Uses udg_RVunit to check if the spell was blocked or not
    if ( not ( GetUnitUserData(u) == 99) ) then
        // Spell was blocked
        set b = null
        set u = null
        set t = null
    else
        // Spell wasn't blocked, effects created and Spell<gen> is turned on
        call SetUnitUserData( u, 13 )
        call DestroyEffect (AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\UDeathSmall\\UDeathSmall.mdl", u,"origin"))
        set b = AddSpecialEffectTarget("Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl", u,"origin")
        call EnableTrigger( gg_trg_Spell )
        call TriggerSleepAction( ( 5.00 + ( 5.00 * I2R(GetUnitAbilityLevelSwapped('A002', t)) ) ) )
        call DisableTrigger( gg_trg_Spell )
        call SetUnitUserData( u, 0 )
        call DestroyEffect(b)
        set u = null
        set t = null
        set b = null
    endif

endfunction

//===========================================================================
function InitTrig_EnableVampirism takes nothing returns nothing
    set gg_trg_EnableVampirism = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_EnableVampirism, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_EnableVampirism, Condition( function Trig_EnableVampirism_Conditions ) )
    call TriggerAddAction( gg_trg_EnableVampirism, function Trig_EnableVampirism_Actions )
endfunction
 
Level 6
Joined
Jul 22, 2008
Messages
243
UDeathSmall
Try define a effect variable and the wait x seconds before destroying it.
At the moment you are destroying it before the full animation.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
UDeathSmall
Try define a effect variable and the wait x seconds before destroying it.
At the moment you are destroying it before the full animation.

He does wait (note the TriggerSleepAction).

It's quite strange that the effect is almost instantly destroyed, it should have been destroyed at least 10 seconds after it was created....I honestly can't see the problem atm, it has to be some kind of a bug. TriggerSleepAction is a lousy function, try to avoid it in the future. Also, when using effects that has to be played once and then destroyed, it's quite clumsy to try to figure out how much you have to wait before you destroy it, so I suggest you maybe try to put the spell effect directly in the spell in the Object editor? Or if you don't know how, you can give use the info of the spell (spell type, how the spell works, other triggers connected to the spell etc.) so maybe we can try to help.

Btw, nice code for a first attempt.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
Thanks for the responses so far. I actually do not wait to destroy this one

JASS:
call DestroyEffect (AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\UDeathSmall\\UDeathSmall.mdl", u,"origin"))
. It should play its effect and then be destroyed.

The other one waits because the effect acts as a buff and I don't see any other way of destroying it. The wait is there for a reason because it sets the duration of the spell, which is in another script.
 
Level 6
Joined
Jul 22, 2008
Messages
243
He does wait (note the TriggerSleepAction).

I beg to differ.

Haha nevermind I found the problem. I had the if and the else mixed up, they should have been reversed. Thanks!

But how about this, is it possible to create two functions in one script that have different events but use the same locals?

Locals is for each function, either you make them global or use structs.
Note: Structs is kind of hard if you are new to JASS / Programming overall.

Are you sure this works? Set is quite bugged, so try defining the local there:
local b = AddSpecialEffectTarget("Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl", u,"origin")
Can't defince locals in the middle of the function, has to be done at the beginning.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
Fixed and working version just involved switching the if and else. Thanks guys.

JASS:
    if ( not ( GetUnitUserData(u) == 99) ) then
        // Spell wasn't blocked, effects created and Spell<gen> is turned on
        call SetUnitUserData( u, 13 )
        call DestroyEffect (AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\UDeathSmall\\UDeathSmall.mdl", u,"origin"))
        set b = AddSpecialEffectTarget("Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl", u,"origin")
        call EnableTrigger( gg_trg_Spell )
       call TriggerSleepAction( ( 5.00 + ( 5.00 * I2R(GetUnitAbilityLevelSwapped('A002', t)) ) ) )
        call DisableTrigger( gg_trg_Spell )
        call SetUnitUserData( u, 0 )
        call DestroyEffect(b)
        set u = null
        set t = null
        set b = null

    else
        // Spell was blocked
        set b = null
        set u = null
        set t = null
        
    endif
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Are you sure this works? Set is quite bugged

Not at all. Even if it is, "quite" is not the appropriate word, because the bugs that may occur are too rare for us to mind.

Since I am that stupid to misread your first post, I will be glad to solve the effect problem. When you create and then instantly destroy the effect (so you create the efffect of the destroy function parameter), it will not play it's normal animation and then be destroyed. It will play only it's death animation, since it's destroyed. Keep an eye on that in the future, it's pretty important in spellmaking.

We went through all this just to find out that the problem of the effect was solved in the second post by QueloR right:

Try define a effect variable and the wait x seconds before destroying it.
At the moment you are destroying it before the full animation.

I thought it was the howl effect that's not working. But I still don't understand what you fixed? It was obviously not the effect problem.

All hail QueloR, btw.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
No actually nobody came up with the right answer. There was no problem at all with the special effects, it was just that I had the IF and ELSE parts of the script wrong.

And actually when you call DestroyEffect(AddSpecialEffectTarget()) it does not just play it's death animation. If it is an ability effect it will play it's birth and death animations.
 
Status
Not open for further replies.
Top