| 11-25-2007, 11:32 AM | #1 |
The Spell Engine, a pack of systems that would make spell making a whole lot easier. The engine is almost finished, I just need to fix a terrible bug with the Missile System. The missile is supposed to follow the target, but it's sort of attached to the caster(when I move away from it, it follows me), it's supposed to move towards the target not towards the caster. JASS:
method onExpire takes nothing returns nothing
local group g = null
local boolexpr b = null
if .Distance <= 0 or (.Homing and (GetWidgetLife(.Target) < .405 or .Target == null)) then
call .cleanup()
call .destroy()
else
set .Distance = .Distance - .Speed
set .PrevX = .X
set .PrevY = .Y
set .PrevZ = .Z
if .Homing then
set .Angle = Atan2(GetUnitY(.Target)-.Y,GetUnitX(.Target)-.X)
endif
set .X = .X + .Speed * Cos(.Angle)
set .Y = .Y + .Speed * Sin(.Angle)
call SetUnitX(.M,.X)
call SetUnitY(.M,.Y)
call MoveLocation(TempLoc,.X,.Y)
set .Z = Parabola(.MaxHeight,.Speed,.Speed)+(.StartZ-GetLocationZ(TempLoc))
call SetUnitFlyHeight(.M,.Z,9999)
call SetUnitAnimationByIndex(.M,R2I(PitchBetweenPoints(.PrevX,.PrevY,.PrevZ,.X,.Y,.Z)+90))
set g = CreateGroup()
call GroupAddGroup(.UnitsHit,TempGroup)
set b = Condition(function HeightCheck)
call GroupEnumUnitsInRange(g,.X,.Y,.Radius,b)
call GroupClear(TempGroup)
if FirstOfGroup(g) != null then
set .Target = FirstOfGroup(g)
call GroupAddUnit(.UnitsHit,.Target)
call .Func.evaluate(this)
endif
call DestroyGroup(g)
call DestroyBoolExpr(b)
set g = null
set b = null
endif
endmethod
Thanks in advance! |
| 11-25-2007, 05:02 PM | #2 |
I dunno about the problems you listed, but I did notice several things: 1.) You can't just decrement .Distance by .Speed because that won't take into account the fact that the target may be moving. 2.) You don't need to destroy a boolexpr, so just do: call GroupEnumUnitsInRange(g,.X,.Y,.Radius,Condition(function HeightCheck)) 3.) The cause of the massive lag is most likely the fact that you're creating and destroying a handle periodically (group), so just use a single global group for this as you do with the location. 4.) You should be adding 89.5 instead of 90 to the pitch if you want it to round correctly, and before you convert it to integer. You can also inline it and use a trick to make it faster: JASS:call SetUnitAnimationByIndex(.M, R2I(Atan((.Z - .PrevZ)/.Speed)*57.2957795 + 89.5)) |
| 11-26-2007, 07:46 AM | #3 |
1.) Yes, I can just decrement distance. They are just normal line spells like shockwave, except that you can make it follow a target. 2.) I didn't know about that :P 3.) Mmmkay 4.) Oh, well in that case, shurr. Anyone else find some problems yet? |
| 11-26-2007, 08:37 AM | #4 |
The distance to the target needs to be recalculated because the target can move. |
| 11-26-2007, 08:45 AM | #5 |
They're not meant to act like that. |
