| 10-14-2009, 03:45 PM | #1 |
Okay so my CreateUnit function has gone against me. JASS:scope Beastmaster initializer onInit function actionOfDoom takes nothing returns nothing //KillUnit( GetTriggerUnit( ) ) BJDebugMsg("Creating unit, attempt 1") BJDebugMsg(GetUnitName(CreateUnit(GetTriggerPlayer(), 'hpea', 0, 0, 0))) BJDebugMsg("Attempt 2") BJDebugMsg(GetUnitName(CreateUnitAtLoc( GetTriggerPlayer(), 'hpea', GetRectCenter(gg_rct_Spawn), 0 ))) BJDebugMsg("Attempt 3") CreateNUnitsAtLoc( 1, 'hpea', GetTriggerPlayer(), GetRectCenter(gg_rct_Spawn), 0 ) endfunction function onInit takes nothing returns nothing trigger daTriggerOfDoom = CreateTrigger( ) TriggerRegisterEnterRectSimple( daTriggerOfDoom, gg_rct_Beastmaster ) TriggerAddAction( daTriggerOfDoom, function actionOfDoom ) endfunction endscope Just prints out (null) Any idea why the hell wc3 is against me? :( |
| 10-14-2009, 04:01 PM | #2 |
Try CreateUnit(player, unitId, x, y, facing) instead of CreateNUnitsAtLoc(). |
| 10-14-2009, 04:17 PM | #3 | |
Quote:
JASS:BJDebugMsg(GetUnitName(CreateUnit(GetTriggerPlayer(), 'hpea', 0, 0, 0))) Just didn't bother checking what's in the unit group, cause it's probaly pretty empty anyway... |
| 10-14-2009, 04:24 PM | #4 |
Oh sorry I didn't understand. EDIT: So the problem is you can't create units right? |
| 10-14-2009, 04:52 PM | #5 | |
Quote:
|
| 10-14-2009, 04:59 PM | #6 |
That's because you are using GetTriggerPlayer in a trigger with a non-player event, so it returns null instead of a player. Trying to create a unit for a null player fails and so the CreateUnit function returns null as well. |
| 10-14-2009, 04:59 PM | #7 |
GetTriggerPlayer() is null in that event response. You should use GetOwningPlayer(GetTriggerUnit()) instead. |
| 10-14-2009, 05:15 PM | #8 | ||
Quote:
Quote:
Worked like a charm. |
