emootootoo
Top Banana
- Reaction score
- 51
I'm making a spell Fire Blast (ripoff from pokemon lol).
The issue is that the angle I've set the units to be created from a center point is a bit off.
Here's a picture to show what i mean:
Notice how the stick figure is facing the wrong direction? It should be facing the direction it was cast. I really don't know what I've done wrong. I figured a simple angle-90 would get the correct angle for the arms/legs.
Code: (yeah I could of used loops but I didn't)
The issue is that the angle I've set the units to be created from a center point is a bit off.
Here's a picture to show what i mean:
Notice how the stick figure is facing the wrong direction? It should be facing the direction it was cast. I really don't know what I've done wrong. I figured a simple angle-90 would get the correct angle for the arms/legs.
Code: (yeah I could of used loops but I didn't)
JASS:
scope FireBlast initializer Init
globals
private constant integer SPELLID = 039;A040039;
private constant integer DUMMYID = 039;h01M039;
private constant integer DISTANCE = 800
private constant integer SPEED = 30
endglobals
private struct Data
unit caster
real angle
real x
real y
real cos
real sin
integer ticks
unit array dummys[35]
integer dummyCount = -1
endstruct
private function CreateDummy takes real length, real height, integer dat returns nothing
local Data d = dat
local real angle = d.angle-90
local real x = d.x + length*Cos(angle)
local real y = d.y + length*Sin(angle)
local unit u= CreateUnit(GetOwningPlayer(d.caster),DUMMYID,x,y,d.angle)
call AllowFlying(u)
call SetUnitFlyHeight(u,height,0)
call SetUnitPathing(u,false)
set d.dummyCount = d.dummyCount+1
set d.dummys[d.dummyCount] = u
set u = null
endfunction
private function Core takes nothing returns boolean
local Data d = TT_GetData()
local integer i = d.dummyCount
local real x
local real y
if d.ticks > 0 then
loop
exitwhen i < 0
set x = GetUnitX(d.dummys<i>)+d.cos
set y = GetUnitY(d.dummys<i>)+d.sin
call MoveUnit(d.dummys<i>,x,y,false)
set i = i - 1
endloop
set d.x = d.x + d.cos
set d.y = d.y + d.sin
set d.ticks = d.ticks - 1
else
loop
exitwhen i < 0
call KillUnit(d.dummys<i>)
set i = i - 1
endloop
call d.destroy()
return true
endif
return false
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELLID
endfunction
private function Actions takes nothing returns nothing
local Data d = Data.create()
local location loc = GetSpellTargetLoc()
local unit caster = GetTriggerUnit()
local real angle = Atan2(GetLocationY(loc)-GetUnitY(caster),GetLocationX(loc)-GetUnitX(caster))
set d.caster = caster
set d.angle = angle
set d.cos = SPEED*Cos(angle)
set d.sin = SPEED*Sin(angle)
set d.x = GetUnitX(caster)
set d.y = GetUnitY(caster)
set d.ticks = DISTANCE/SPEED
call CreateDummy(0,280,d)
call CreateDummy(0,260,d)
call CreateDummy(0,240,d)
call CreateDummy(0,220,d)
call CreateDummy(0,200,d)
call CreateDummy(0,180,d)
call CreateDummy(20,180,d)
call CreateDummy(40,180,d)
call CreateDummy(60,180,d)
call CreateDummy(80,180,d)
call CreateDummy(-20,180,d)
call CreateDummy(-40,180,d)
call CreateDummy(-60,180,d)
call CreateDummy(-80,180,d)
call CreateDummy(5,160,d)
call CreateDummy(-5,160,d)
call CreateDummy(10,140,d)
call CreateDummy(-10,140,d)
call CreateDummy(16,120,d)
call CreateDummy(-16,120,d)
call CreateDummy(24,100,d)
call CreateDummy(-24,100,d)
call CreateDummy(34,80,d)
call CreateDummy(-34,80,d)
call CreateDummy(44,60,d)
call CreateDummy(-44,60,d)
call CreateDummy(54,40,d)
call CreateDummy(-54,40,d)
call CreateDummy(64,20,d)
call CreateDummy(-64,20,d)
call CreateDummy(74,0,d)
call CreateDummy(-74,0,d)
call TT_Start(function Core,d)
set caster = null
call RemoveLocation(loc)
set loc = null
endfunction
private function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(Trig,Condition(function Conditions))
call TriggerAddAction(Trig,function Actions)
set Trig = null
endfunction
endscope</i></i></i></i>