• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Part of trigger not executing

Status
Not open for further replies.
Level 7
Joined
Aug 19, 2009
Messages
278
Hi...
A part of this trigger is not working... i must have done some noob mistake but... i guess it must be due to some noob mistake by me... any way i am new to jass so...

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local real x1
local real y1
local real x2
local real y2
set udg_angle = GetUnitFacing(udg_pusher)
set x1 = GetUnitX(udg_unit)
set y2 = GetUnitY(udg_unit)
set udg_x = Cos(udg_angle * bj_DEGTORAD)
set udg_y = Sin(udg_angle * bj_DEGTORAD)
set x2 = (Cos(udg_angle * bj_DEGTORAD)*500)
set y2= (Sin(udg_angle * bj_DEGTORAD)*500)
call DisplayTextToForce( GetPlayersAll(), "1" )
set udg_xd = x1 + x2
set udg_yd = y1 + y2
call DisplayTextToForce( GetPlayersAll(), "2" )
set udg_pb = 1
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

1 prints but not 2

The map is also attached
 

Attachments

  • pb.w3x
    18.5 KB · Views: 45
Level 7
Joined
Aug 19, 2009
Messages
278
When the code gets halted, it's most likely due to an uninitialized variable you try to read from.

In this case, y1 has no value.

JASS:
set x1 = GetUnitX(udg_unit)
set y2 = GetUnitY(udg_unit)

You meant y1 instead of y2 here probably.

Oh... Thanks...
 
Level 13
Joined
May 11, 2008
Messages
1,198
with practice in jass code and saving your map and evaluating the last bits of code you edited...you should be able to spot these kinds of errors yourself. i make mistakes like this all the time, even now, so no, that wasn't really a newbie mistake.

did your problem get fixed or is there something else the matter?
 
Status
Not open for further replies.
Top