HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Animations? (JASS Problem)

04-12-2007, 06:48 AM#1
PurgeandFire111
*JASS Problem*

Ok. So I have this dude that casts an ability on another dude. The thing is, I can't get each dude in the group to do their "attack slam" because the animation is being overwritten with the spell. Here is the trigger:
Collapse JASS:
function Trig_Illusion_Strike_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction
function Trig_Illusion_Strike_GroupFilter takes nothing returns boolean
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == true then
        return false
    endif
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) == true then
        return false
    endif
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == true then
        return false
    endif
    if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == false ) then
        return false
    endif 
    return true
endfunction
function Trig_Illusion_Strike_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy
    local unit striker
    local integer i = 0
    local group is_unit_group = CreateGroup()
    local location casterloc = GetUnitLoc(caster)
    local location dummyloc
    local effect array dummyfx
    local boolexpr ugfilter = Condition(function Trig_Illusion_Strike_GroupFilter) 
    call GroupEnumUnitsInRangeOfLoc(is_unit_group,casterloc,500,ugfilter)
    loop    
        set dummy = FirstOfGroup(is_unit_group)
        exitwhen dummy == null
        set dummyloc = GetUnitLoc(dummy)
        set striker = CreateUnitAtLoc(GetOwningPlayer(caster),'n001',dummyloc,0)
        call SetUnitVertexColorBJ( striker, 100.00, 100.00, 100, 60.00 )
[b]        call SetUnitAnimation( striker, "attack slam" )[/b]
        call UnitAddAbility(striker,'A000')
        call SetUnitAbilityLevel(striker,'A000',GetUnitAbilityLevel(caster,'A001'))
        call IssueTargetOrder(striker,"forkedlightning",dummy)
        call UnitApplyTimedLife(striker,'BTLF',1.5)
        set dummyfx[i] = AddSpecialEffectLoc("Abilities\\Spells\\Human\\Polymorph\\PolyMorphTarget.mdl",dummyloc)
        call RemoveLocation(dummyloc)
        set i = i+1
        call GroupRemoveUnit(is_unit_group,dummy)
    endloop
    call TriggerSleepAction(1)
    set i = 0
    loop
        exitwhen dummyfx[i] == null
        call DestroyEffect(dummyfx[i])
        set dummyfx[i] = null
        set i = i+1
        call RemoveUnit( striker )
    endloop
    call GroupClear(is_unit_group)
    call DestroyGroup(is_unit_group)
    call RemoveLocation(casterloc)
    call DestroyBoolExpr(ugfilter)
    set ugfilter = null
    set caster = null
    set dummy = null
    set striker = null
    set is_unit_group = null
    set casterloc = null
    set dummyloc = null
endfunction

//===========================================================================
function InitTrig_Illusion_Strike takes nothing returns nothing
    local integer i = 0
    local integer a = GetPlayers()
    
    set gg_trg_Illusion_Strike = CreateTrigger()
    loop
        exitwhen i > a
        call TriggerRegisterPlayerUnitEvent(gg_trg_Illusion_Strike,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        set i = i+1
    endloop
    call TriggerAddCondition(gg_trg_Illusion_Strike,Condition(function Trig_Illusion_Strike_Conditions))
    call TriggerAddAction(gg_trg_Illusion_Strike,function Trig_Illusion_Strike_Actions)
endfunction  
This won't make each unit do the animation. Please help me find another way.

2. If I were to use
Collapse JASS:
SetUnitAnimationByIndex(X, Y)
What would I put in those areas? (X, Y)[Note: Those are just variables to represent the values to put in them]

I hope you understand what I'm trying to do...
04-12-2007, 06:56 AM#2
Chocobo
call SetUnitAnimationByIndex(u,index)

u = Unit
index = Index of the animation

Index of Animations can be found using Warcarft 3 Viewer, it starts from 0 and ends at the last animation of the unit.
04-12-2007, 09:29 PM#3
PurgeandFire111
Thanx.. I'll see what I can do. +REP
04-12-2007, 09:36 PM#4
Vexorian
I use a trigger with a loop to show all animations from 0 to infinity, that's my easy way to get an animation index
04-12-2007, 11:06 PM#5
PurgeandFire111
Lol... That would work.. Though I solved the problem by instead making another dummy cast instead of the striker dude, so that the striker can perform his animation, but damage will still be dealt.
04-12-2007, 11:14 PM#6
Vexorian
That's kind of overcomplicated considering that PlayUnitAnimationByIndex is so easy to use...
04-12-2007, 11:30 PM#7
PurgeandFire111
Actually, it isn't overcomplicated too much, unless you say it.

Yes, it is easy to use, but when I did:
Collapse JASS:
call SetUnitAnimationByIndex( striker, 2 )
It didn't work, or did I do something wrong? I guess I might of put the wrong animation, but there is a small chance (About 4/14 or something like that (Blademaster model)) that he would perform no action instead.

Anywayz, I don't want to debate or anything at the moment, mainly because I agree that what was suggested is easier.

Off-Topic:
I got everything to work, but what I want to do, is remove each "striker" unit. Here is the code:
Collapse JASS:
function Trig_Illusion_Strike_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

//==================================================//
function Trig_Illusion_Strike_GroupFilter takes nothing returns boolean
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == true then
        return false
    endif
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) == true then
        return false
    endif
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == true then
        return false
    endif
    if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == false ) then
        return false
    endif 
    return true
endfunction

//===========================================================================
function Trig_Illusion_Strike_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy
    local unit dummy2
    local location dummyloc2
    local unit striker
    local integer i = 0
    local group is_unit_group = CreateGroup()
    local location casterloc = GetUnitLoc(caster)
    local location dummyloc
    local effect array dummyfx
    local boolexpr ugfilter = Condition(function Trig_Illusion_Strike_GroupFilter) 
    call GroupEnumUnitsInRangeOfLoc(is_unit_group,casterloc,500,ugfilter)
    loop    
        set dummy = FirstOfGroup(is_unit_group)
        exitwhen dummy == null
        set dummyloc = GetUnitLoc(dummy)
        set dummy2 = CreateUnitAtLoc(GetOwningPlayer(caster), 'n000',dummyloc,0)
        set striker = CreateUnitAtLoc(GetOwningPlayer(caster),'n001',dummyloc,0)
        call SetUnitVertexColorBJ( striker, 100.00, 100.00, 100, 60.00 )
        call SetUnitAnimation( striker, "attack slam" )
        call UnitAddAbility(dummy2,'A000')
        call SetUnitAbilityLevel(dummy2,'A000',GetUnitAbilityLevel(caster,'A001'))
        call IssueTargetOrder(dummy2,"forkedlightning",dummy)
        call UnitApplyTimedLife(striker,'BTLF',1.5)
        call UnitApplyTimedLife(dummy2, 'BTLF',1.5)
        set dummyfx[i] = AddSpecialEffectLoc("Abilities\\Spells\\Human\\Polymorph\\PolyMorphTarget.mdl",dummyloc)
        call RemoveLocation(dummyloc)
        set i = i+1
        call GroupRemoveUnit(is_unit_group, dummy)
        call RemoveUnit(dummy2)
    endloop
    call TriggerSleepAction(1)
    set i = 0
    loop
        exitwhen dummyfx[i] == null
        call DestroyEffect(dummyfx[i])
=============>>>>call RemoveUnit(striker)<<<<<<<===============
        set dummyfx[i] = null
        set i = i+1
    endloop
    call GroupClear(is_unit_group)
    call DestroyGroup(is_unit_group)
    call RemoveLocation(casterloc)
    call DestroyBoolExpr(ugfilter)
    set ugfilter = null
    set caster = null
    set dummy = null
    set dummy2 = null
    set striker = null
    set is_unit_group = null
    set casterloc = null
    set dummyloc = null

endfunction

//===========================================================================
function InitTrig_Illusion_Strike takes nothing returns nothing
    local integer i = 0
    local integer a = GetPlayers()
    
    set gg_trg_Illusion_Strike = CreateTrigger()
    loop
        exitwhen i > a
        call TriggerRegisterPlayerUnitEvent(gg_trg_Illusion_Strike,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        set i = i+1
    endloop
    call TriggerAddCondition(gg_trg_Illusion_Strike,Condition(function Trig_Illusion_Strike_Conditions))
    call TriggerAddAction(gg_trg_Illusion_Strike,function Trig_Illusion_Strike_Actions)
endfunction 

It only removes it for one unit, how can I make it remove all of the striker units made.

Ability Info:
Creates blademasters at each enemy unit within X range that strike the enemy units for X damage.
04-13-2007, 06:28 AM#8
Zwan
not to overlook the obvious, but have you tried setting the animation field for the base spell to slam?
04-13-2007, 06:42 AM#9
MaD[Lion]
i always have problem tat i cant play other animation while a unit cast a spell
04-13-2007, 06:57 AM#10
Chocobo
Btw "attack slam" of Blademaster is Index 3. (you are doing animation "attack)
04-13-2007, 09:03 AM#11
blu_da_noob
How to play an animation for a spell:
Have a trigger with SPELL_CAST event.
In this trigger start a 0.01 duration timer (0. might work, but I haven't tested).
In the timer callback, set the unit's animation with SetUnitAnimationByIndex.
04-13-2007, 07:24 PM#12
PurgeandFire111
Thanx Peoplez...