- Joined
- Nov 28, 2008
- Messages
- 704
Alright, Ive got a fairly minor problem blocking me from completeing a spell.
using GetUnitState() in a function, or setting a variable to it, causes it to be null. This unit HAS mana, it is NOT null (checked this, debugging with those ever so useful BJDebugMsg()'s..
heres a lil bit of codes.
In using the SetUnitState(), it causes the unit to lose the mana correctly. WTH, much?
Setting it to the real causes the real to be null, causing the crash in the if. This is part of a knockback timer, by the way. After it checks the manaCheck, and finds it null.. crash. Timer does not run, no knockback.
Suggestions, anyone?
using GetUnitState() in a function, or setting a variable to it, causes it to be null. This unit HAS mana, it is NOT null (checked this, debugging with those ever so useful BJDebugMsg()'s..
heres a lil bit of codes.
JASS:
static method Move takes nothing returns nothing
local LBD lbd
local integer i = LightningBallCounter
local real x
local real y
local integer ii
local real distance
local real manaCheck = 0
loop
set lbd = Lbd[i]
set x = GetUnitX(lbd.Dummy) + lbd.Speed * lbd.Cosine
set y = GetUnitY(lbd.Dummy) + lbd.Speed * lbd.Sine
call SetUnitX(lbd.Dummy, x)
call SetUnitY(lbd.Dummy, y)
call SetUnitX(lbd.Unit, x)
call SetUnitY(lbd.Unit, y)
call SetUnitX(lbd.FXDummy, x)
call SetUnitY(lbd.FXDummy, y)
set manaCheck = GetUnitState(lbd.Unit, UNIT_STATE_MANA) //I reutrn null. However, SetUnitState does work.
set lbd.Speed = lbd.Speed + lbd.SpeedIncrease
call MoveLightning(lbd.Bolt, true, lbd.OriginalX, lbd.OriginalY, x, y)
call SetUnitState(lbd.Unit, UNIT_STATE_MANA , GetUnitState(lbd.Unit, UNIT_STATE_MANA) - lbd.ManaCost) //I work, breaking the laws of physics.
set distance = SquareRoot((lbd.DestinationX - x) * (lbd.DestinationX - x) + (lbd.DestinationY - y) * (lbd.DestinationY - y))
if manaCheck == null then
call BJDebugMsg("Roar!") //I trigger lots!
endif
if manaCheck < 1 then//distance < lbd.Speed * 5 then //I only work when the mana is in fact below 0. Otherwise, I crash this thread, causing no knockbacks to happen anymoar.
call lbd.destroy()
if LightningBallCounter == -1 then
call PauseTimer(LBDTimer)
endif
set ii = i
loop
exitwhen i > LightningBallCounter
set Lbd[ii + 1] = Lbd[i]
set ii = ii + 1
endloop
endif
set i = i - 1
endloop
endmethod
In using the SetUnitState(), it causes the unit to lose the mana correctly. WTH, much?
Setting it to the real causes the real to be null, causing the crash in the if. This is part of a knockback timer, by the way. After it checks the manaCheck, and finds it null.. crash. Timer does not run, no knockback.
Suggestions, anyone?