• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] what's wrong with this code?

Status
Not open for further replies.
Level 3
Joined
Sep 14, 2007
Messages
43
This code suppose to teleport a target unit infront of the caster, but it doesnt, so please tell me what's wrong with it.

JASS:
function Trig_Void_Tunnel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A03T'
endfunction

function Trig_Void_Tunnel_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    call TriggerSleepAction(0.1)
    call SetUnitX(t, x + Cos(bj_RADTODEG * GetUnitFacing(u)) * 130)
    call SetUnitY(t, y + Sin(bj_RADTODEG * GetUnitFacing(u)) * 130)
    set u = null
    set t = null
endfunction
//===========================================================================
function InitTrig_Void_Tunnel takes nothing returns nothing
    set gg_trg_Void_Tunnel = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Void_Tunnel, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Void_Tunnel, Condition(function Trig_Void_Tunnel_Conditions))
    call TriggerAddAction(gg_trg_Void_Tunnel, function Trig_Void_Tunnel_Actions)
endfunction
 
Last edited by a moderator:
GetUnitFacing() returns a real in degrees, not radians, so you don't use bj_RADTODEG, you use bj_DEGTORAD or CosBJ() or GetUnitFacing(u)*3.14159/180.

Also, even if you do TriggerSleepAction(0.1), the smallest amount of time TriggerSleepAction can work is 0.27 seconds (don't ask why, I don't know). You're better to use timers + globals or handle vars.

Also, watch out with SetUnitX and SetUnitY. If the targeted coordinate is outside map bounds, the map will fatal error.

EDIT: OMG POOT STOP STEALING MY POSTS!
 
w8 there's something i dont understand.
if GetUnitFacing(u) returns degrees so why cant i just leave it that way?
why do i have to turn it to radians?
 
so if i write shiftsin(0.5) in jass it will print pie/6 and not 30? :(
getunitface work with degs while trigo funcs work with rads... how can i tell which function work with deg and which with rads?
 
Wtf is 'shiftsin'? You mean Asin?

Everything that returns angles except custom functions (including BJs like AngleBetweenPoints) and GetUnitFacing return radians.

AngleBetweenPoints would return radians, but they multiply by bj_RADTODEG before returning it.



And shouldn't this be old news to you, if you already have done trigonometry? Or are they still making you use that accursed "Degree Mode" on the calculators?
 
Status
Not open for further replies.
Back
Top