- Joined
- Feb 11, 2008
- Messages
- 809
JASS:
function SpawnEnemyUnits takes nothing returns nothing
// Creating local variables
local unit u
local group g
local location p
local real a
local real x
local real y
local real xe
local real ye
local PatrolPath Route1
// First debug message
call BJDebugMsg("Trigger is firing correctly")
// First Lane of Units
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], -2200.00, 2830.00, 270 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], -1750.00, 2400.00, 90 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], -1300.00, 2830.00, 270 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], -850.00, 2400.00, 90 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], -400.00, 2830.00, 270 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 50.00, 2400.00, 90 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 500.00, 2830.00, 270 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 950.00, 2400.00, 90 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 1400.00, 2830.00, 270 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 1850.00, 2400.00, 90 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2300.00, 2830.00, 270 )
// Second Lane of Units
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2680.00, 1920.00, 0 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 3100.00, 1470.00, 180 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2680.00, 1020.00, 0 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 3100.00, 570.00, 180 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2680.00, 120.00, 0 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 3100.00, -330.00, 180 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2680.00, -780.00, 0 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 3100.00, -1230.00, 180 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2680.00, -1680.00, 0 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 3100.00, -2130.00, 180 )
call CreateUnit( udg_EnemyController, udg_EnemyUnitType[udg_GameModeChosen], 2680.00, -2580.00, 0 )
// Second debug message
call BJDebugMsg("Units are created correctly")
// Add patrol system to all filtered enemy units
call GroupEnumUnitsInRange( g, 0, 0, 256, null)
// Third debug message
call BJDebugMsg("Units are filtered correctly")
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitTypeId(u) == udg_EnemyUnitType[udg_GameModeChosen] then
// Fourth debug message
call BJDebugMsg("Loop is working correctly")
// Set local variables for unit positions
set p = GetUnitLoc(u)
set a = GetUnitFacing(u)
set x = GetLocationX(p)
set y = GetLocationY(p)
set xe = x + 450 * Cos(a * bj_DEGTORAD)
set ye = y + 450 * Sin(a * bj_DEGTORAD)
set Route1 = PatrolPath.create()
// Create the patrol points for the units
call Route1.push(PatrolPoint.create(xe, ye))
call Route1.push(PatrolPoint.create(x, y))
// This adds the patrol settings to the units
call PatrolUnit.create(u, Route1, PatrolType.NORMAL, PatrolOrder.MOVE, 0, false)
endif
call GroupRemoveUnit( g, u)
endloop
// Fifth debug message
call BJDebugMsg("Trigger has finished correctly")
endfunction
// Initializes the trigger and begins running actions
function InitTrig_Spawn_Enemys takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "-test", true)
call TriggerAddAction( t, function SpawnEnemyUnits )
set t = null
endfunction
As you can see by the BJDebugMsgs this trigger stops working at GroupEnumUnitsInRange and i cant figure out exactly why>? can someone help me with this?