- Joined
- Dec 12, 2008
- Messages
- 7,385
Why does this code crash the game?
I made small annotations in the code to tell you where it's crashing.
edit
It's not just this, if I place a hero on the map, the game crashes while it's loading >_>
What's going on?
edit
Here's an image (In-case the error seems familiar)
edit
Strangely, the error only occurs when I create a hero that has a certain ability.
In this case, I'm placing units with a custom ability I created.
edit
Meh, I solved it.
It's Object Editor error >_>
If a tooltip uses data like <A000,Area1> incorrectly (say <A000; Area1>), the game crashes.
Stupid Blizzard >_>
You can mark this thread as Solved.
Thanks to anyone who tried
JASS:
struct Demo extends array
static unit hero = null
static timer t = CreateTimer()
static real dist = 0
private static method cast takes real x, real y returns nothing
call IssuePointOrderById(hero, OrderId("channel"), x, y)
endmethod
private static method makeUnit takes real x, real y returns unit
return CreateUnit(Player(1), 'hpea', x, y, 270)
endmethod
private static method destroyThem takes nothing returns nothing
call RemoveDestructable(GetEnumDestructable())
endmethod
private static method setDist takes nothing returns nothing
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, dist, 0)
endmethod
private static method lockCam takes real distance returns nothing
call TimerStart(t, 0.05, true, function thistype.setDist)
set dist = distance
endmethod
private static method print takes string s returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, s)
endmethod
private static method test takes nothing returns nothing
local integer i = 0
local unit u
local real x = 800
local real y = 800
local fogmodifier fm = CreateFogModifierRadius(Player(0), FOG_OF_WAR_VISIBLE, 0, 0, 9001, false, false)
call FogModifierStart(fm)
call print("Phase 1: Multi-unit Instanceability")
call TriggerSleepAction(1)
// The crash occurs somewhere from this point
set hero = CreateUnit(Player(0), 'Hamg', 0, 0, 270)
call TriggerSleepAction(0)
call cast(400, 400)
// to this point.
call TriggerSleepAction(1)
call cast(400, -400)
call TriggerSleepAction(1)
call cast(-400, 400)
call TriggerSleepAction(1)
call cast(-400, -400)
call TriggerSleepAction(7)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "Phase 2: Efficiency")
call SetUnitX(hero, -500)
call SetUnitY(hero, 0)
call SetUnitFacing(hero, 0)
call TriggerSleepAction(0.5)
loop
call cast(0,0)
call TriggerSleepAction(0)
set i = i + 1
exitwhen i == 50
endloop
call TriggerSleepAction(7)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "Phase 3: Damage")
call makeUnit(0,0)
set i = 0
loop
call makeUnit(200*Cos(i*(bj_PI/4)),200*Sin(i*(bj_PI/4)))
set i = i + 1
exitwhen i == 8
endloop
loop
call makeUnit(400*Cos(i*(bj_PI/4)),400*Sin(i*(bj_PI/4)))
set i = i + 1
exitwhen i == 16
endloop
call TriggerSleepAction(2)
call cast(0,0)
call TriggerSleepAction(7)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "Phase 4: Trees")
call GroupEnumUnitsInRange(bj_lastCreatedGroup, 0, 0, 1000, null)
loop
set u = FirstOfGroup(bj_lastCreatedGroup)
exitwhen u == null
call GroupRemoveUnit(bj_lastCreatedGroup, u)
if hero != u then
call RemoveUnit(u)
endif
endloop
set i = 0
loop
loop
call CreateDestructable('LTlt', x, y, 0, 1, 1)
set x = x - 100
exitwhen x == -900
endloop
set y = y - 100
set x = 800
exitwhen y == -900
endloop
call SetUnitX(hero, 0)
call SetUnitY(hero, 1000)
call lockCam(3000)
call TriggerSleepAction(1)
call cast(0,0)
call TriggerSleepAction(7)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "Phase 5: Have fun!")
call EnumDestructablesInRect(bj_mapInitialPlayableArea, null, function thistype.destroyThem)
call SetUnitX(hero, 0)
call SetUnitY(hero, 0)
call lockCam(2500)
endmethod
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "start", true)
call TriggerAddAction(t, function thistype.test)
call print("Type 'start' to begin the test.")
set t = null
endmethod
endstruct
I made small annotations in the code to tell you where it's crashing.
edit
It's not just this, if I place a hero on the map, the game crashes while it's loading >_>
What's going on?
edit
Here's an image (In-case the error seems familiar)
edit
Strangely, the error only occurs when I create a hero that has a certain ability.
In this case, I'm placing units with a custom ability I created.
edit
Meh, I solved it.
It's Object Editor error >_>
If a tooltip uses data like <A000,Area1> incorrectly (say <A000; Area1>), the game crashes.
Stupid Blizzard >_>
You can mark this thread as Solved.
Thanks to anyone who tried