Kevin Caccamo
Rear Admiral
I've started working on the fourth episode of WC1 Remake (Dakota/Port Hedland) and I've ran into a big problem...
After I kill all the Krants at NAV 1 where the Drayman is supposed to jump out (I call the enemydie function after I kill each Krant) the Drayman does not jump out when it is supposed to!
Here is the mission code, done fully in the mission editor:
And here is the LUA script.
After I kill all the Krants at NAV 1 where the Drayman is supposed to jump out (I call the enemydie function after I kill each Krant) the Drayman does not jump out when it is supposed to!
Here is the mission code, done fully in the mission editor:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mission name = "" sector="peach" can_eject="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mission.xsd">
<navpoints number="5">
<navpoint numships="4" numwaves="1">
<ship name="claw" pilot="" comm="" video="" autopilot="false" must_survive="true" alignment="friend" wave="0">
<location>
<point x="-90.81803" y ="0.0" z ="-1586.6444" />
</location>
<rotation>
<point x="0.0" y ="0.0" z ="0.0" />
</rotation>
</ship>
<ship name="raptor" pilot="player" comm="" video="" autopilot="true" alignment="friend" wave="0">
<location>
<point x="-64.10684" y ="0.0" z ="-448.7479" />
</location>
<rotation>
<point x="0.0" y ="0.0" z ="0.0" />
</rotation>
</ship>
<ship name="raptor" pilot="" comm="" video="" autopilot="true" alignment="friend" last_autopilot_nav="4" wave="0">
<location>
<point x="138.89816" y ="0.0" z ="-454.09015" />
</location>
<rotation>
<point x="0.0" y ="0.0" z ="0.0" />
</rotation>
</ship>
<ship name="drayman" pilot="" comm="" video="" autopilot="true" must_survive="true" alignment="friend" last_autopilot_nav="2" wave="0" scriptid="drayone">
<location>
<point x="-261.76962" y ="0.0" z ="-443.40567" />
</location>
<rotation>
<point x="0.0" y ="0.0" z ="0.0" />
</rotation>
<script ondestroy="ifdraydies" />
</ship>
</navpoint>
<navpoint numships="5" numwaves="1">
<ship name="salthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-619.69946" y ="0.0" z ="1137.8965" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
</ship>
<ship name="salthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-341.90317" y ="0.0" z ="1143.2388" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
</ship>
<ship name="salthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-69.44908" y ="0.0" z ="1148.5809" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
</ship>
<ship name="salthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="245.7429" y ="0.0" z ="1143.2388" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
</ship>
<ship name="salthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="523.53925" y ="0.0" z ="1143.2388" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
</ship>
</navpoint>
<navpoint numships="4" numwaves="1">
<ship name="jumpbuoy" pilot="" comm="" video="" autopilot="false" alignment="neutral" wave="0">
<location>
<point x="-37.39566" y ="0.0" z ="886.81134" />
</location>
<rotation>
<point x="0.0" y ="0.0" z ="0.0" />
</rotation>
</ship>
<ship name="krant" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-657.09515" y ="0.0" z ="908.1803" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
<script ondestroy="enemydie" />
</ship>
<ship name="krant" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-1180.6344" y ="0.0" z ="507.5125" />
</location>
<rotation>
<point x="0.0" y ="138.0" z ="0.0" />
</rotation>
<script ondestroy="enemydie" />
</ship>
<ship name="krant" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="753.25543" y ="0.0" z ="58.764606" />
</location>
<rotation>
<point x="0.0" y ="260.0" z ="0.0" />
</rotation>
<script ondestroy="enemydie" />
</ship>
</navpoint>
<navpoint numships="5" numwaves="1">
<ship name="jumpbuoy" pilot="" comm="" video="" autopilot="false" alignment="neutral" wave="0">
<location>
<point x="-186.9783" y ="0.0" z ="1073.7897" />
</location>
<rotation>
<point x="0.0" y ="0.0" z ="0.0" />
</rotation>
</ship>
<ship name="drayman" pilot="" comm="" video="" autopilot="true" must_survive="true" alignment="friend" last_autopilot_nav="4" wave="0" jumpin="true">
<location>
<point x="-165.60934" y ="0.0" z ="876.1269" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
<script ondestroy="draytwodies" />
</ship>
<ship name="jalthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-667.7796" y ="0.0" z ="443.40567" />
</location>
<rotation>
<point x="0.0" y ="121.0" z ="0.0" />
</rotation>
</ship>
<ship name="jalthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-731.8865" y ="0.0" z ="240.40067" />
</location>
<rotation>
<point x="0.0" y ="105.0" z ="0.0" />
</rotation>
</ship>
<ship name="jalthi" pilot="" comm="kilrathi1" video="" autopilot="false" alignment="enemy" wave="0">
<location>
<point x="-758.59766" y ="0.0" z ="80.13355" />
</location>
<rotation>
<point x="0.0" y ="100.0" z ="0.0" />
</rotation>
</ship>
</navpoint>
<navpoint numships="1" numwaves="1">
<ship name="claw" pilot="" comm="tc" video="" autopilot="false" land="true" must_survive="true" alignment="friend" wave="0">
<location>
<point x="-160.2671" y ="0.0" z ="1442.4039" />
</location>
<rotation>
<point x="0.0" y ="180.0" z ="0.0" />
</rotation>
</ship>
<script oncreate="haveiwon" />
</navpoint>
</navpoints>
<objectives>
<objective name="Escort Hospital ship out of the system" category="primary" default="incomplete" />
<objective name="Escort Drayman back to the Claw" category="primary" default="incomplete" />
</objectives>
</mission>
And here is the LUA script.
Code:
dofile "flightcommander.lua"
draydead = 0
cleared = 0
draytwodead = 0
enemykilled = 0
function ifdraydies()
draydead = draydead + 1;
end
-- Since lua cannot support if statements within if statements
-- I have declared a new variable called "cleared"
-- If you have killed all the enemies, cleared will increase by 1
-- If the drayman is alive, cleared will also be increased by 1
-- If the drayman is dead, cleared will be increased by 2
-- Therefore, if cleared is 2, the drayman will jump out
-- And if cleared is 3, you will fail your first objective
function enemydie()
enemykilled = enemykilled + 1;
if enemykilled == 3 then
cleared = cleared + 1;
end
if draydead == 0 then
cleared = cleared + 1;
end
if draydead == 1 then
cleared = cleared + 2;
end
if cleared == 2 then
Ship_jumpOut("drayone")
Objective_setState(0, OBJECTIVE_COMPLETE)
elseif cleared == 3 then
Objective_setState(0, OBJECTIVE_FAILED)
end
end
function draytwodies()
draytwodead = draytwodead + 1;
end
function haveiwon()
if draytwodead == 1 then
Objective_setState(1, OBJECTIVE_FAILED)
elseif draytwodead == 0 then
Objective_setState(1, OBJECTIVE_COMPLETE)
end
end