Nherwyziant
Be better than you were yesterday :D
- Reaction score
- 96
Hello, I was making a spell, but when the 30th cast of the spell, a bug is spawning. I dunno why. I was not thinking to ask, cuz I was making a spell pack for waaaks RoS, but since I can't fix this, the bug has forced me to ask.
//Note that this spell is not yet finished so don't say anything, like "hey, lol why no damage?".
//Requires: TimerUtils(RedFlavor, by Vexorian), GTrigger(J4L)
MADE in china, woops I mean in 1.24b version. Help plz.
Here's the spelll
//Note that this spell is not yet finished so don't say anything, like "hey, lol why no damage?".
//Requires: TimerUtils(RedFlavor, by Vexorian), GTrigger(J4L)
JASS:
scope LightningTentacle
private struct s
private static constant real DISTANCE = 100. //Distance moved per period.
private static constant real PERIODIC = .05 //Period.
private static constant real WORMS = 25 //Number of worms.
private static constant integer MAX = 10 //Max number of worm segments.
private static constant integer MOVES = 50 //Number of moves.
private static constant integer RAWCODE = 039;A002039; //The rawcode of the spell.
private static constant real REDCOLOR = 1. //Lightning color red
private static constant real GREENCOLOR = 1. //Lightning color green
private static constant real BLUECOLOR = 1. //Lightning color blue
private static constant real ALPHA = .5 //Lightning Alpha
private static constant string LIGHTNING = "DRAL" //The Lightning Effect.
private static constant string EFFECT1 = ""
private static constant string EFFECT2 = ""
real array x[11]
real array y[11]
lightning array l[10]
//DO NOT TOUCH THIS PART===================================================================================
unit u
unit c
real a
timer t
effect e
integer v
integer d
method Destroy takes nothing returns nothing
call ReleaseTimer(.t)
set .u = null
set .c = null
set .t = null
set .v = 0
loop
set .v = .v+1
set .l[.v] = null
exitwhen .v == MAX
endloop
endmethod
static method create takes unit u returns s
local s this = s.allocate()
set .t = NewTimer()
set .u = u
return this
endmethod
static method Remove takes nothing returns nothing
local s this = GetTimerData(GetExpiredTimer())
set .v = .v-1
call DestroyLightning(.l[.v])
if .v == 1 then
call .Destroy()
endif
endmethod
method Fader takes nothing returns nothing
call ReleaseTimer(.t)
set .v = MAX+1
set .t = NewTimer()
call DestroyEffect(.e)
call SetTimerData(.t,this)
call TimerStart(.t,PERIODIC,true,function s.Remove)
endmethod
static method Mover takes nothing returns nothing
local s this = GetTimerData(GetExpiredTimer())
set .d = .d+1
set .v = MAX+1
loop
set .v = .v-1
if .x[.v] == .x[1] and .y[.v] == .y[1] then
set .x[1] = .x[1]+DISTANCE*Cos(a+GetRandomInt(-90,90)*bj_DEGTORAD)
set .y[1] = .y[1]+DISTANCE*Sin(a+GetRandomInt(-90,90)*bj_DEGTORAD)
else
set .x[.v] = .x[.v-1]
set .y[.v] = .y[.v-1]
endif
exitwhen .v == 1
endloop
set .v = 0
loop
set .v = .v+1
call MoveLightning(.l[.v],true,.x[.v+1],.y[.v+1],.x[.v],.y[.v])
if .l[.v] == .l[1] then
if .e != null then
call DestroyEffect(.e)
endif
set .e = AddSpecialEffect(EFFECT1,.x[.v],.y[.v])
endif
exitwhen .v == MAX-1
endloop
if .d >= MOVES then
call .Fader()
endif
endmethod
static method Act takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local s this = s.create(u)
set .x[1] = GetUnitX(.u)
set .y[1] = GetUnitY(.u)
set .a = Atan2(.y[1]+DISTANCE*Sin(GetRandomInt(0,360)*bj_DEGTORAD)-.y[1],(.x[1]+DISTANCE*Cos(GetRandomInt(0,360)*bj_DEGTORAD))-.x[1])
set .v = MAX+1
loop
set .v = .v-1
if .x[.v] == .x[1] and .y[.v] == .y[1] then
set .x[1] = .x[1]+DISTANCE*Cos(a)
set .y[1] = .y[1]+DISTANCE*Sin(a)
else
set .x[.v] = GetUnitX(.u)
set .y[.v] = GetUnitY(.u)
endif
exitwhen .v == 1
endloop
set .v = 0
loop
set .v = .v+1
set .l[.v] = AddLightning(LIGHTNING,true,.x[.v+1],.y[.v+1],.x[.v],.y[.v])
call SetLightningColor(.l[.v],REDCOLOR,GREENCOLOR,BLUECOLOR,ALPHA)
exitwhen .v == MAX-1
endloop
call SetTimerData(.t,this)
call TimerStart(.t,PERIODIC,true,function s.Mover)
endmethod
static method Action takes nothing returns nothing
local integer i = 0
loop
set i = i+1
call s.Act()
exitwhen i==WORMS
endloop
endmethod
private static method onInit takes nothing returns nothing
local trigger g = CreateTrigger()
call GT_RegisterStartsEffectEvent(g,RAWCODE)
call TriggerAddAction(g,function s.Action)
endmethod
endstruct
endscope
MADE in china, woops I mean in 1.24b version. Help plz.
Here's the spelll