- Joined
- Jul 26, 2008
- Messages
- 1,009
Alright, I tried rearranging the code here several ways and no matter what (Deleting scope, remove init from struct and putting it in scope with initializer, etc.) I couldn't get the debug message to fire. Obviously I"m doing something wrong (And I'm sure my code isn't very optimal so any pointers is appreciated)
Here it is. How do I get it to do the onInit like it's suppose to?
Here it is. How do I get it to do the onInit like it's suppose to?
JASS:
scope Locamotive
globals
private constant real tick = 0.1
endglobals
struct Drive
unit loco
real x
real y
real dur = 0
integer spot = 1
boolean forward = true
boolean moving = false
static real array pointX
static real array pointY
private static method Path takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
local real locoX = GetUnitX(.loco)
local real locoY = GetUnitY(.loco)
local real distance = SquareRoot((locoX - .x)*(locoX - .x) + (locoY - .y)*(locoY - .y))
call IssuePointOrder(.loco, "move", .x, .y)
if distance < 10 then
if .pointX[.spot+1] == 0 and .forward then
set .forward = false
elseif .pointX[.spot-1] == 0 and not .forward then
set .forward = true
endif
if .forward then
set .spot = .spot + 1
else
set .spot = .spot - 1
endif
set .x = .pointX[.spot]
set .y = .pointY[.spot]
call IssuePointOrder(.loco, "move", .x, .y)
endif
endmethod
private static method create takes nothing returns thistype
local thistype this = thistype.allocate()
local timer tim = NewTimerEx(this)
set .loco = gg_unit_subt_0578
set .x = .pointX[.spot]
set .y = .pointY[.spot]
call SetUnitPathing(.loco, false)
call TimerStart(tim, tick, true, function thistype.Path)
return this
endmethod
private static method onInit takes nothing returns nothing
set gg_trg_LocamotivePath = CreateTrigger()
call TriggerAddAction( gg_trg_LocamotivePath, function thistype.create )
debug call BJDebugMsg("GO!")
set pointX[1] = -9565
set pointY[1] = -15042
set pointX[2] = -9567
set pointY[2] = -14757
set pointX[3] = -9709
set pointY[3] = -14576
set pointX[4] = -10045
set pointY[4] = -14424
set pointX[5] = -10103
set pointY[5] = -13890
set pointX[6] = -9878
set pointY[6] = -13622
set pointX[7] = -9070
set pointY[7] = -13637
set pointX[8] = -8867
set pointY[8] = -13487
set pointX[9] = -8840
set pointY[9] = -13021
set pointX[10] = -8614
set pointY[10] = -12740
set pointX[11] = -7815
set pointY[11] = -12760
set pointX[12] = -7576
set pointY[12] = -13017
set pointX[13] = -7612
set pointY[13] = -13550
set pointX[14] = -7612
set pointY[14] = -15250
set pointX[15] = -7379
set pointY[15] = -15500
set pointX[16] = -7150
set pointY[16] = -15500
set pointX[17] = -6000
set pointY[17] = -15500
set pointX[18] = -4950
set pointY[18] = -15500
set pointX[19] = -4400
set pointY[19] = -15500
set pointX[20] = -4150
set pointY[20] = -15250
set pointX[21] = -4135
set pointY[21] = -14300
set pointX[22] = -3900
set pointY[22] = -14020
set pointX[23] = -3190
set pointY[23] = -14025
set pointX[24] = -2770
set pointY[24] = -13585
set pointX[25] = -2650
set pointY[25] = -13530
set pointX[26] = -2150//Station East
set pointY[26] = -13530
/* set pointX[27] =
set pointY[27] =
set pointX[28] =
set pointY[28] =
set pointX[29] =
set pointY[29] =
set pointX[30] =
set pointY[30] =
set pointX[31] =
set pointY[31] =
set pointX[32] =
set pointY[32] =
set pointX[33] =
set pointY[33] =
set pointX[34] =
set pointY[34] =
set pointX[35] =
set pointY[35] =
set pointX[36] =
set pointY[36] =
set pointX[37] =
set pointY[37] =
set pointX[38] =
set pointY[38] =
set pointX[39] =
set pointY[39] =
set pointX[40] =
set pointY[40] =
set pointX[41] =
set pointY[41] =
set pointX[42] =
set pointY[42] =
set pointX[43] =
set pointY[43] =
set pointX[44] =
set pointY[44] =
set pointX[45] =
set pointY[45] =
set pointX[46] =
set pointY[46] =
set pointX[47] =
set pointY[47] =
set pointX[48] =
set pointY[48] =
set pointX[49] =
set pointY[49] =
*/ endmethod
endstruct
endscope