Angle, not what it seems.

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:
spellproblem.jpg


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    = 'A040'
        private constant integer DUMMYID    = 'h01M'
        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 &lt; 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>
 

Ryuu

I am back with Chocolate (:
Reaction score
64
[del]I haven't looked through your code, but did you use a SetUnitFacing function?
'Cause the GUI comment on (Make Unit face Unit) roughly says 'This cannot be done when the unit is moving'.[/del]

Oh sorry I didn't understood your post before, now I do.

Perhaps the model's 90 degrees is a bit way off?
 

emootootoo

Top Banana
Reaction score
51
Nah it's a special effect made out of several small units, it just looks like it has arms and legs.

The problem is the units are supposed to be lined up perpendicular to the angle of the caster to the casting point.

But the units are never lined up perpendicular even though the debug messeges say the angles are X and X-90 as I've set them.
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Perhaps the caster's 90 degrees is a bit way off?
 
Reaction score
456
The angle is in radians. Reduce it by bj_PI / 2 instead of 90.00?

> local unit u= CreateUnit(GetOwningPlayer(d.caster),DUMMYID,x,y,d.angle)
And FYI, all those unit facings use degrees. This would make the dummy face something that is near 0.00 (faces right).
 

emootootoo

Top Banana
Reaction score
51
brb while I write retard on my face in permanent marker.
thanks lol

(forgot I hadn't converted the angle to degrees)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top