Zwiebelchen
You can change this now in User CP.
- Reaction score
- 60
Hmm, this is a spell that creates a cross-shaped special effect below the feet of the caster pointing towards the selected target destination.
The spell lags heavily everytime the dummys are created and destroyed.
I know that I could make it more efficient using a struct instead of all those hashtable slots, but I think that is not the problem here. Anyone has an idea what could be the problem?
PS: The spell lags even if there is no unit in range, so it's not the damage function that causes the lag.
Also, the spell doesn't lag in singleplayer or Bnet-games without other players.
The spell lags heavily everytime the dummys are created and destroyed.
I know that I could make it more efficient using a struct instead of all those hashtable slots, but I think that is not the problem here. Anyone has an idea what could be the problem?
PS: The spell lags even if there is no unit in range, so it's not the damage function that causes the lag.
Also, the spell doesn't lag in singleplayer or Bnet-games without other players.
JASS:
library Crucify uses Damage, ZTS
globals
private integer system_dummyId1 = 039;h00V039;
private integer system_spellId = 039;A042039;
private string system_orderId = "unloadall"
private constant group targetGroup = CreateGroup()
private player tplayer = null
endglobals
private function DamageTarget takes unit caster, unit target returns nothing
local real dmg = (I2R(StatSpellpower[caster])) * 1.5 * (GetRandomReal(0.8, 1.2))
if IsUnitType(target, UNIT_TYPE_UNDEAD) then
set dmg = dmg*2
endif
call UnitDamageTargetEx(caster, target, dmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS)
call ZTS_ModifyThreat(caster, target, dmg*0.5, true)
endfunction
private function GroupFilter takes nothing returns boolean
return (GetUnitTypeId(GetFilterUnit())!=system_dummyId1) and IsUnitEnemy(GetFilterUnit(), tplayer)
endfunction
//-----------------------------------------------------------------------------
private function RotMatrixX takes real x, real y, real angle returns real
return x*Cos(angle)-y*Sin(angle)
endfunction
private function RotMatrixY takes real x, real y, real angle returns real
return x*Sin(angle)+y*Cos(angle)
endfunction
private function Tick takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer parentKey = GetHandleId(t)
local integer state = LoadInteger(TimerHash, parentKey, 2)
local integer drawMax
local integer i = 6
local real angle = LoadReal(TimerHash, parentKey, 5)
local unit caster = LoadUnitHandle(TimerHash, parentKey, 0)
local unit tempUnit
local real tempUnitX
local real tempUnitY
local real length
local real width
local real casterX = LoadReal(TimerHash, parentKey, 3)
local real casterY = LoadReal(TimerHash, parentKey, 4)
local boolean channeling = false
call RecalcStats(caster)
if (OrderId2String(GetUnitCurrentOrder(caster))==system_orderId) then
set channeling = true
endif
if(channeling) then
call SaveInteger(TimerHash, parentKey, 2, state+1)
if(state==0) then
set drawMax = 135
set length = 300
set width = 50
elseif(state==1) then
set drawMax = 111
set length = 250
set width = 50
elseif(state==2) then
set drawMax = 87
set length = 200
set width = 50
elseif(state==3) then
set drawMax = 63
set length = 150
set width = 50
endif
loop
exitwhen i>=drawMax
call KillUnit(CreateUnit(GetOwningPlayer(caster), system_dummyId1, LoadReal(TimerHash, parentKey, i),LoadReal(TimerHash, parentKey, i+1), 0.0))
set i=i+2
endloop
set tplayer = GetOwningPlayer(caster)
call GroupEnumUnitsInRange(targetGroup, casterX, casterY, 300, Condition(function GroupFilter))
set tempUnit=FirstOfGroup(targetGroup)
set tplayer = null
loop
exitwhen tempUnit==null
set tempUnitX = RotMatrixX(GetUnitX(tempUnit)-casterX, GetUnitY(tempUnit)-casterY, angle*(-1))
set tempUnitY = RotMatrixY(GetUnitX(tempUnit)-casterX, GetUnitY(tempUnit)-casterY, angle*(-1))
if((((-1)*width<=tempUnitX)and(tempUnitX<=width)and((-1)*length<=tempUnitY)and(tempUnitY<=length)) or (((-1)*width<=tempUnitY)and(tempUnitY<=width)and((-1)*length<=tempUnitX)and(tempUnitX<=length))) then
call DamageTarget(caster, tempUnit)
endif
call GroupRemoveUnit(targetGroup, tempUnit)
set tempUnit=FirstOfGroup(targetGroup)
endloop
if(state==0) then
call TimerStart(t, 0.7, false, function Tick)
elseif(state==1) then
call TimerStart(t, 0.7, false, function Tick)
elseif(state==2) then
call TimerStart(t, 0.7, false, function Tick)
else
call FlushChildHashtable(TimerHash, parentKey)
call DestroyTimer(t)
endif
else
call FlushChildHashtable(TimerHash, parentKey)
call DestroyTimer(t)
endif
set t=null
set caster = null
set tempUnit = null
endfunction
function Crucify takes unit caster, unit target returns nothing
local timer t = CreateTimer()
local integer parentKey = GetHandleId(t)
local real targetX = GetUnitX(target)
local real targetY = GetUnitY(target)
local real casterX = GetUnitX(caster)
local real casterY = GetUnitY(caster)
local real angle = Atan2(targetY-casterY,targetX-casterX)
local integer i
local integer childKey = 0
call SaveUnitHandle(TimerHash, parentKey, 0, caster)
call SaveUnitHandle(TimerHash, parentKey, 1, target)
call SaveInteger(TimerHash, parentKey, 2, 0)
call SaveReal(TimerHash, parentKey, 3, casterX)
call SaveReal(TimerHash, parentKey, 4, casterY)
call SaveReal(TimerHash, parentKey, 5, angle)
//middle:
call SaveReal(TimerHash, parentKey, 6, casterX)
call SaveReal(TimerHash, parentKey, 7, casterY)
call SaveReal(TimerHash, parentKey, 8, casterX+RotMatrixX(25,25,angle))
call SaveReal(TimerHash, parentKey, 9, casterY+RotMatrixY(25,25,angle))
call SaveReal(TimerHash, parentKey, 10, casterX+RotMatrixX(25,-25,angle))
call SaveReal(TimerHash, parentKey, 11, casterY+RotMatrixY(25,-25,angle))
call SaveReal(TimerHash, parentKey, 12, casterX+RotMatrixX(-25,25,angle))
call SaveReal(TimerHash, parentKey, 13, casterY+RotMatrixY(-25,25,angle))
call SaveReal(TimerHash, parentKey, 14, casterX+RotMatrixX(-25,-25,angle))
call SaveReal(TimerHash, parentKey, 15, casterY+RotMatrixY(-25,-25,angle))
set childKey=16
//row1:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(50,0,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(50,0,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 23
//row2:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(75,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(75,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(75,-25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(75,-25,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 39
//row3:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(100,0,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(100,0,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 47
//row4:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(125,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(125,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(125,-25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(125,-25,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 63
//row5:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(150,0,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(150,0,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 71
//row6:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(175,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(175,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(175,-25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(175,-25,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 87
//row7:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(200,0,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(200,0,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 95
//row8:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(225,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(225,25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(225,-25,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(225,-25,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 111
//row9:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(250,0,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(250,0,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 119
//row10:
set i=0
loop
exitwhen i==4
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(250,40,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(250,40,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterX+RotMatrixX(250,-40,angle+i*bj_PI/2))
set childKey=childKey+1
call SaveReal(TimerHash, parentKey, childKey, casterY+RotMatrixY(250,-40,angle+i*bj_PI/2))
set childKey=childKey+1
set i=i+1
endloop //childkey == 135
call TimerStart(t, 0.0, false, function Tick)
set t = null
endfunction
endlibrary