- Joined
- Feb 15, 2009
- Messages
- 463
Whenever the spell comes out of the loop before the destroy loop there´s a big delay and then Debugmessages from xedamage appear that i tried to remove null structs, also it seems that my timer cant work faster then 0.01 is there a way to decrease this time ?
Here is the code
Here is the code
JASS:
//******************************************************************************************
//* Hawk Strike
//* by Saia_Djinn (The Holy Order )
//*
//* A Spell which is cast on melee Range , afterwards a spiral runs
//* from a defined distance towards the Position of the Caster , having various effects
//* to units on the Spiral
//*
//*
//******************************************************************************************
scope HawkStrike initializer Init
//Here are the different Configuration Options
globals
private constant integer SPELL_ID = 'A000' //The ID of your Base Spell
private constant real BASE_DAMAGE = 100. // Damage done to units on the spiral x level
private constant real EFFECT_AOE = 50. //How far from the current effect units will get damage or be spellargets
private constant real START_ANGLE = 90. // Currently Facing North when creating 1st effect
private constant real EFFECT_SCALE = 1. //Scale of the Effect(care 2. is in fact 8x as great as normal )
private constant integer MAX_TOTAL = 60 // How many Effects can be created overall
private constant real INITIAL_SPIRAL_RANGE = 1.0 // If u change this ,the movespeed of the unit
//will not be used anymore instead this value(should atleast be 300.)
private constant string DAMAGE_EFFECT = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" //Path of the Effect which shows up when units are damaged
private constant string EFFECT_PATH = "Abilities\\Spells\\NightElf\\BattleRoar\\RoarTarget.mdl" //The Path of the Specialeffect Model used by the Spell
endglobals
globals
private xedamage damage
private unit TempUnit
endglobals
private function GroupMatch takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit() , GetOwningPlayer(TempUnit) ) == true and GetWidgetLife(GetFilterUnit()) > 0.405 and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false
endfunction
private function DamageConfig takes nothing returns nothing
call damage.useSpecialEffect(DAMAGE_EFFECT,"origin")
set damage.dtype = DAMAGE_TYPE_MAGIC
endfunction
//BASE_DAMAGE * GetUnitAbilityLevel( caster , SPELL_ID)
private function Callback takes unit caster,unit target returns nothing
call damage.damageTarget(caster , target , 2. )
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local real uX = GetUnitX(u)
local real uY = GetUnitY(u)
local real angle
local real distance
local real multi
local real add
local real SpiralX
local real SpiralY
local xefx array Spiral
local integer N = -1
local timer t = CreateTimer()
local group g = CreateGroup()
local unit d
local boolexpr b = Condition( function GroupMatch )
//Declaring the distance variable
//***
if ( INITIAL_SPIRAL_RANGE == 1.0 ) then
set distance = GetUnitMoveSpeed(u)
else
set distance = INITIAL_SPIRAL_RANGE
endif
//***
set SpiralX = uX + distance * Cos( START_ANGLE * bj_DEGTORAD )
set SpiralY = uY + distance * Sin( START_ANGLE * bj_DEGTORAD )
set angle = START_ANGLE
set multi = distance / MAX_TOTAL
set add = 20
//***
loop
set N = N + 1
set SpiralX = uX + distance * Cos(angle)
set SpiralY = uY + distance * Sin(angle)
set angle = ( START_ANGLE + add* N ) *bj_DEGTORAD
set distance = distance - multi
exitwhen N == MAX_TOTAL
set Spiral [N]= xefx.create( SpiralX, SpiralY, angle )
set Spiral[N].fxpath = EFFECT_PATH
set Spiral[N].scale = EFFECT_SCALE
set TempUnit = u
call GroupEnumUnitsInRange( g , SpiralX , SpiralY, EFFECT_AOE , b )
loop
set d = FirstOfGroup(g)
exitwhen d == null
call Callback( u ,d )
call GroupRemoveUnit(g, d)
endloop
call TimerStart(t,0.01,false,null)
loop
exitwhen TimerGetRemaining(t) == 0.
call TriggerSleepAction(0.0)
endloop
endloop
set N = -1
loop
exitwhen N == MAX_TOTAL
call Spiral[N].destroy()
endloop
call DestroyGroup(g)
call DestroyBoolExpr(b)
call DestroyTimer(t)
set t = null
set g = null
set b = null
set u = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
set t = null
set damage = xedamage.create()
endfunction
endscope