Hi again, I'm coding a nova spell for a map o' mine, but there is a problem.
The dummy units are not moving :S
Here's the spell code:
+ rep for anything helpful :thup:
By the way, I'm just using the world editor, no NewGen pack for me, no nothing ^^
The dummy units are not moving :S
Here's the spell code:
JASS:
function Trig_Water_Nova_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;Awrs039;
endfunction
function Trig_Water_Nova_Filter takes nothing returns boolean
return IsPlayerEnemy( GetOwningPlayer( GetTriggerUnit() ), GetOwningPlayer( GetFilterUnit() ) ) and GetWidgetLife( GetFilterUnit() ) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING ) and not IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE )
endfunction
function Trig_Water_Nova_Main takes nothing returns nothing
local timer tiSpellTimer = GetExpiredTimer()
local integer nTimerID = H2I( tiSpellTimer )
local group gDamageGroup = CreateGroup()
local unit array uDummyUnits
local integer nDummyAmount = LoadInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ) )
local real rDamageAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ) )
local real rMaxDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ) )
local real rCurrentDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Current" ) )
local integer nIndex = 0
local real array rDummyX
local real array rDummyY
local boolexpr beGroupFilter = Condition( function Trig_Water_Nova_Filter )
local unit uFirstOfGroup
local real array rDummyFacing
local real rDistanceAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ) )
loop
exitwhen nIndex == nDummyAmount
set uDummyUnits[nIndex] = LoadUnitHandle( udg_AbilityTable, nTimerID, nIndex )
set rDummyX[nIndex] = GetUnitX( uDummyUnits[nIndex] )
set rDummyY[nIndex] = GetUnitY( uDummyUnits[nIndex] )
set rDummyFacing[nIndex] = GetUnitFacing( uDummyUnits[nIndex] )
set nIndex = nIndex + 1
endloop
if not ( rCurrentDuration == rMaxDuration ) then
set nIndex = 0
call BJDebugMsg( "MOVING" )
loop
exitwhen nIndex == nDummyAmount
call GroupEnumUnitsInRange( gDamageGroup, rDummyX[nIndex], rDummyY[nIndex], 40, beGroupFilter )
loop
exitwhen gDamageGroup == null
set uFirstOfGroup = FirstOfGroup( gDamageGroup )
call UnitDamageTarget( uDummyUnits[nIndex], uFirstOfGroup, rDamageAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )
call GroupRemoveUnit( gDamageGroup, uFirstOfGroup )
endloop
// These are the 2 lines that are supposed to move the targeted dummy
call SetUnitX( uDummyUnits[nIndex], rDummyX[nIndex] + rDistanceAmount * Cos( rDummyFacing[nIndex] ) )
call SetUnitY( uDummyUnits[nIndex], rDummyY[nIndex] + rDistanceAmount * Sin( rDummyFacing[nIndex] ) )
set nIndex = nIndex + 1
endloop
set rCurrentDuration = rCurrentDuration + 0.05
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ), rDamageAmount )
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rMaxDuration )
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )
set nIndex = 0
loop
exitwhen nIndex == nDummyAmount
call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uDummyUnits[nIndex] )
set nIndex = nIndex + 1
endloop
else
call DestroyTimer( tiSpellTimer )
call DestroyGroup( gDamageGroup )
set gDamageGroup = null
set uFirstOfGroup = null
set nIndex = 0
loop
exitwhen nIndex == nDummyAmount
call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl", GetUnitX( uDummyUnits[nIndex] ), GetUnitY( uDummyUnits[nIndex] ) ) )
call RemoveUnit( uDummyUnits[nIndex] )
set uDummyUnits[nIndex] = null
set nIndex = nIndex + 1
endloop
call FlushChildHashtable( udg_AbilityTable, nTimerID )
endif
endfunction
function Trig_Water_Nova_Actions takes nothing returns nothing
local integer nAbilityId = 039;Awrs039;
local unit uCastUnit = GetTriggerUnit()
local player plCastOwner = GetOwningPlayer( uCastUnit )
local integer nDummyId = 039;h00E039;
local timer tiSpellTimer = CreateTimer()
local unit array uADummyUnits
local real rDamageAmount = 25. * udg_PLAYER_MAXNUM
local integer nIndex = 0
local integer nDummyAmount = 8
local real rCastX = GetUnitX( uCastUnit )
local real rCastY = GetUnitY( uCastUnit )
local real rFrequency = 0.05
local real rDistancePerTick = 20
local real rTotalDuration = 1.5
local real rCurrentDuration = 0.
local integer nTimerID = H2I( tiSpellTimer )
local real array rDummyFacing
loop
exitwhen nIndex == nDummyAmount
set uADummyUnits[nIndex] = CreateUnit( plCastOwner, nDummyId, rCastX, rCastY, 45. * ( nIndex + 1 ) )
set nIndex = nIndex + 1
endloop
set nIndex = 0
loop
exitwhen nIndex == nDummyAmount
call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uADummyUnits[nIndex] )
set nIndex = nIndex + 1
endloop
call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ), rDamageAmount )
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rTotalDuration )
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ), rDistancePerTick )
call TimerStart( tiSpellTimer, rFrequency, true, function Trig_Water_Nova_Main )
set tiSpellTimer = null
set plCastOwner = null
set uCastUnit = null
set nIndex = 0
loop
exitwhen nIndex == nDummyAmount
set uADummyUnits[nIndex] = null
set nIndex = nIndex + 1
endloop
endfunction
function InitTrig_Water_Nova takes nothing returns nothing
set gg_trg_Water_Nova = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Nova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Water_Nova, Condition( function Trig_Water_Nova_Conditions ) )
call TriggerAddAction( gg_trg_Water_Nova, function Trig_Water_Nova_Actions )
endfunction
+ rep for anything helpful :thup:
By the way, I'm just using the world editor, no NewGen pack for me, no nothing ^^