- Joined
- Nov 23, 2008
- Messages
- 512
hey i'm making a diablo 3 spell (seismic slam) but on run of the spell the code skips a part of it (the part with indexing and set variables)
here the if skips the rest:
the rest is skipped and so the whole spell bugs and never stops running
plz help and you get +rep
JASS:
library SeismicSlam
globals
private constant integer SPELL_ID = 'A001'
private constant real REFRESH_TIME = .05
private constant real DISTANCE_BETWEEN_SLAMS = 80.
private constant real AOE_RANGE = 80.
private string EffectModel = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
private real Variation = 10.
endglobals
private struct SeismicWave
unit Caster
integer Level
integer Slams
real StartX
real StartY
real Angle
private integer i
private static timer Tim = CreateTimer()
private static integer Total = 0
private static thistype array SeismicWaves
static integer StoredLevel
static unit StoredCaster
//============================ settings ==============================
private static method NumberOfSlams takes integer lvl returns integer
return 5+(3*lvl)
endmethod
private static method GetDamage takes integer lvl returns real
return 100.+(25.*R2I(lvl))
endmethod
//========================== end of settings =========================
private static method Damage takes nothing returns nothing
//filter here
//if blabla == lol then
call UnitDamageTarget(StoredCaster,GetEnumUnit(),thistype.GetDamage(StoredLevel),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
//endif
endmethod
private method onDestroy takes nothing returns nothing
set Total = Total - 1
call BJDebugMsg("total = total - 1")
call BJDebugMsg("total= "+ I2S(Total))
set SeismicWaves[i] = SeismicWaves[Total]
set SeismicWaves[i].i=i
if Total == 0 then
call PauseTimer(Tim)
endif
endmethod
private static method onLoop takes nothing returns nothing
local thistype dat
local integer i2 = Total-1
local group g = CreateGroup()
local real curx
local real cury
local real anglevariation
call BJDebugMsg(I2S(Total))
call BJDebugMsg("run loop")
call BJDebugMsg(I2S(i2))
loop
exitwhen i2 < 0
set dat = SeismicWaves[i2]
call BJDebugMsg(I2S(NumberOfSlams(dat.Level)))
if dat.Slams < NumberOfSlams(dat.Level) then
call BJDebugMsg("slams smaller then max nr. of slams")
set anglevariation = GetRandomReal(Variation*(-1),Variation)
set curx = Sin((dat.Angle + anglevariation) * bj_DEGTORAD) * (DISTANCE_BETWEEN_SLAMS * dat.Slams)
set cury = Cos((dat.Angle + anglevariation) * bj_DEGTORAD) * (DISTANCE_BETWEEN_SLAMS * dat.Slams)
set dat.Slams = dat.Slams+1
set StoredLevel = dat.Level
set StoredCaster = dat.Caster
call GroupEnumUnitsInRange(g,curx,cury,AOE_RANGE,null)
call ForGroup(g,function thistype.Damage)
call DestroyEffect(AddSpecialEffect(EffectModel,curx,cury))
call GroupClear(g)
else
call dat.destroy()
call BJDebugMsg("dat.destroy")
//call deallocate(dat)
endif
set i2 = i2-1
endloop
call DestroyGroup(g)
set g = null
endmethod
private static method Check takes nothing returns boolean
local thistype dat
local real angle
call BJDebugMsg("check")
if GetSpellAbilityId() == SPELL_ID then
call BJDebugMsg("Correct spell")
if Total==0 then
call TimerStart(Tim,REFRESH_TIME,true,function thistype.onLoop)
endif
set dat.i=Total
set Total = Total+1
set dat = thistype.allocate()
set dat.Caster = GetTriggerUnit()
set dat.Level = GetUnitAbilityLevel(dat.Caster,SPELL_ID)
call BJDebugMsg(I2S(dat.Level))
set dat.Slams = 0
set dat.StartX = GetUnitX(dat.Caster)
call BJDebugMsg(R2S(dat.StartX))
set dat.StartY = GetUnitY(dat.Caster)
call BJDebugMsg(R2S(dat.StartY))
set dat.Angle = Atan2(GetLocationY(GetSpellTargetLoc()) - dat.StartY, GetLocationX(GetSpellTargetLoc()) - dat.StartX)*bj_RADTODEG
call BJDebugMsg(R2S(dat.Angle))
endif
return false
endmethod
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call BJDebugMsg("init")
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.Check))
endmethod
endstruct
endlibrary
here the if skips the rest:
JASS:
private static method Check takes nothing returns boolean
local thistype dat
local real angle
call BJDebugMsg("check")
if GetSpellAbilityId() == SPELL_ID then
call BJDebugMsg("Correct spell")
if Total==0 then
call TimerStart(Tim,REFRESH_TIME,true,function thistype.onLoop)
endif
plz help and you get +rep