PDA

View Full Version : Homeworld снова мертв?


Valeran
05-30-2017, 10:50 PM
Что-то о хоумворлд ни слуху ни духу опять. Ремастер забросили, пески кхарака забросили, о третьей части новостей нет, блеки пилят другую игру. Неуж-то франчайз снова мёртв?:(

Fencer
06-01-2017, 12:32 PM
Время от времени с HW такое случается

mpv2909
06-02-2017, 10:12 PM
Не всё так сразу, бывает проходит и 5 лет до анонса новых частей, обычно хорошие проекты разрабатывают долго. Homeworld не умрёт, он будет жить вечно в наших сердцах

Lavos
06-04-2017, 08:58 PM
Думаю проблема не столь в отсутствии продолжения серии, сколь в простое жанра в целом. Во всяком случае я таковой вижу ситуацию на игровом рынке.

Bravo
06-10-2017, 01:35 AM
Думаю что-то делают , пока показывать рано. А вообще как то странно почему не сделают сюжетное дополнение к пескам кхарака, по идеи должно же быть просто т.к. вся база уже есть.

Nickolay
06-29-2017, 03:09 PM
Я тут на фоне ностальгии и печали по поводу отсутствия ремастера Катаклизма решил его ещё раз перепройти.
До сих пор не могу поверить, что можно продолбать исходники (как говорят).

Pandorazero
06-30-2017, 10:34 AM
Такое случается когда компания накрывается и ресурсы теряются !
Я как понял материалы по HW1 и HW2 хранились у RELIC, а Homeworld:Cataclysm у Sierra или Barking Dog Studios, поэтому после развала студий материалы тю-тю.

Haarkin
07-04-2017, 11:29 PM
Ну совсем забыть или пропасть не могли, просто доход не слишком высокий на данный момент. Проект скорее всего уложен в долгий ящик анабиоз сундук, находящийся внутри n-ого количества больших сундуков и только Драконорожденный сможет все сундуки за раз открыть. Шутка. Серьезно.

stalker[fox]
06-16-2019, 06:44 PM
До сих пор не могу поверить, что можно продолбать исходники (как говорят).

Такое случается когда компания накрывается и ресурсы теряются !

Ну, не знаю... Могли бы и в интернете у кого-нибудь спросить. У меня вот, например, уже лет 15 какие-то исходники хомяка без дела лежат. Всё никак руки не дойдут собрать посмотреть.

:gigi:


/*=============================================================================
Name : Mothership.c
Purpose : Specifics for the Mothership

Created 6/30/1997 by gshaw
Copyright Relic Entertainment, Inc. All rights reserved.
=============================================================================*/

#include "types.h"
#include "debug.h"
#include "spaceobj.h"
#include "Mothership.h"
#include "statscript.h"
#include "gun.h"
#include "attack.h"
#include "DefaultShip.h"
#include "madLinkin.h"
#include "savegame.h"
#include "universe.h"
#include "aitrack.h"
#include "salcapcorvette.h"
#include "madlinkindefs.h"
#include "commandlayer.h"

extern sdword R1MOTHERSHIP_Big;
extern sdword R2MOTHERSHIP_Big;

MothershipStatics MothershipStatic;

MothershipStatics MothershipStaticRace1;
MothershipStatics MothershipStaticRace2;

//I don't envision any more ships attaching themselves to the mothership door...should they then hooray!
scriptStructEntry MothershipStaticTable[] =
{
{ "specialDoorOffset[R1][AdvanceSupportFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][AdvanceSupportFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][Carrier]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][Carrier]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][CloakGenerator]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][CloakGenerator]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][DDDFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][DDDFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][DFGFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][DFGFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][GravWellGenerator]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][GravWellGenerator]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][HeavyCruiser]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][HeavyCruiser]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][IonCannonFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][IonCannonFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][MissileDestroyer]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][MissileDestroyer]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][ResourceController]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][ResourceController]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][StandardDestroyer]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][StandardDestroyer]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][StandardFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][StandardFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][P1IonArrayFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][P1IonArrayFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][P2MultiBeamFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][P2MultiBeamFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][P2FuelPod]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][P2FuelPod]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R1][CryoTray]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R1][CryoTray]), (udword) &(MothershipStatic) },

{ "specialDoorOffset[R2][AdvanceSupportFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][AdvanceSupportFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][Carrier]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][Carrier]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][CloakGenerator]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][CloakGenerator]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][DDDFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][DDDFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][DFGFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][DFGFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][GravWellGenerator]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][GravWellGenerator]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][HeavyCruiser]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][HeavyCruiser]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][IonCannonFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][IonCannonFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][MissileDestroyer]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][MissileDestroyer]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][ResourceController]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][ResourceController]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][StandardDestroyer]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][StandardDestroyer]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][StandardFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][StandardFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][P1IonArrayFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][P1IonArrayFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][P2MultiBeamFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][P2MultiBeamFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][P2FuelPod]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][P2FuelPod]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[R2][CryoTray]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[R2][CryoTray]), (udword) &(MothershipStatic) },

{ "specialDoorOffset[P1][P1IonArrayFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[P1][P1IonArrayFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[P2][P2MultiBeamFrigate]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[P2][P2MultiBeamFrigate]), (udword) &(MothershipStatic) },
{ "specialDoorOffset[P2][P2FuelPod]", scriptSetLWToHWMonkeyVectorCB, (udword) &(MothershipStatic.specialDoorOffset[P2][P2FuelPod]), (udword) &(MothershipStatic) },

{ "specialDoorOffset", scriptSetSpecialDoorOffsetCB,(udword) &(MothershipStatic), (udword) &(MothershipStatic)},




{ "specialDoorInterpolationPerSecond", scriptSetReal32CB, (udword) &(MothershipStatic.specialDoorInterpolationPerSecond), (udword) &(MothershipStatic) },

{ NULL,NULL,0,0 }
};

real32 DOCKPOINT_BUSY_TOO_LONG = UNIVERSE_UPDATE_RATE * 60;

void MothershipStaticInit(char *directory,char *filename,struct ShipStaticInfo *statinfo)
{
MothershipStatics *mothershipstat = (statinfo->shiprace == R1) ? &MothershipStaticRace1 : &MothershipStaticRace2;
sdword i,j;
//init static info
for(i=0;i<NUM_RACES;i++)
{
for(j=0;j<TOTAL_NUM_SHIPS;j++)
{
mothershipstat->specialDoorOffset[i][j].x = 0.0f;
mothershipstat->specialDoorOffset[i][j].y = 0.0f;
mothershipstat->specialDoorOffset[i][j].z = 0.0f;
mothershipstat->specialDoorOrientationHeading[i][j]=-1;
mothershipstat->specialDoorOrientationUp[i][j]=-1;
}
}

scriptSetStruct(directory,filename,MothershipStaticTable,(ubyte *)mothershipstat);

statinfo->custstatinfo = mothershipstat;
}
void MothershipInit(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
sdword i;

for(i=0;i<MAX_NUM_DROP;i++)
{
spec->dropstate[i] = 0;
spec->droptarget[i] = NULL;
spec->dockindex[i] = 0;
}
spec->doorCargo = NULL;

spec->CAP_NumInBuildCue=0;
}
void MothershipAttack(Ship *ship,SpaceObjRotImpTarg *target,real32 maxdist)
{
attackPassive(ship,(Ship *)target); // Typecast to prevent warning, attackPassive will handle SpaceObjRotImpTarg
}

void MothershipAttackPassive(Ship *ship,Ship *target,bool rotate)
{
attackPassive(ship,target);
}

//single player game...called when hs button is pushed for quick
//docking + progression to HS..this will ensure it partly works when
//launching big ships...
void mothershipCleanDoorForHSInstant(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;

if(spec->doorCargo != NULL)
{
MothershipDettachObjectFromDoor(ship);
spec->doorCargo = NULL;
}

if( ship->madDoorStatus != MAD_STATUS_DOOR_CLOSED)
{
//if door isn't closed
if(ship->madBindings->bPaused)
{
//animation is paused...well,unpause it
//so as to fix a bug in lukes code!
madAnimationPause(ship,!ship->madBindings->bPaused);
}
madAnimationStop(ship);

ship->cuedAnimationIndex = ship->staticinfo->madStatic->DoorOpenIndexes[0];
ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
ship->madDoorStatus = MAD_STATUS_DOOR_CLOSED;
ship->madAnimationFlags=0;
ship->nextAnim = 0;
}
}

void MothershipDoorUpKeep(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
MothershipStatics *mothershipstatics = (MothershipStatics *)((ship->staticinfo))->custstatinfo;
vector positionWS,doorHeading,doorRight,doorUp;
vector heading,up,right;
matrix coordsysWS;

if(spec->doorCargo != NULL)
{
//get info
mothershipGetCargoPosition(ship,spec->doorCargo,&positionWS,&coordsysWS,&heading,&up,&right);

matGetVectFromMatrixCol1(doorUp,coordsysWS);
matGetVectFromMatrixCol2(doorRight,coordsysWS);
matGetVectFromMatrixCol3(doorHeading,coordsysWS);

//vecScalarMultiply(doorLeft,doorRight,-1.0f);
matPutVectIntoMatrixCol1(up,spec->doorCargo->rotinfo.coordsys);
//vecScalarMultiply(doorHeading,doorHeading,-1.0f);
matPutVectIntoMatrixCol2(right,spec->doorCargo->rotinfo.coordsys);
matPutVectIntoMatrixCol3(heading,spec->doorCargo->rotinfo.coordsys);

if(spec->doorCargo->putOnDoor==TRUE || MoveReachedDestinationVariable((Ship *)spec->doorCargo,&positionWS,1.0f))
{
spec->doorCargo->putOnDoor=TRUE;
spec->doorCargo->posinfo.position = positionWS;
}
else
{
vector adder;
vecSub(adder,positionWS,spec->doorCargo->posinfo.position);
vecScalarMultiply(adder,adder,0.3f);
vecAddTo(spec->doorCargo->posinfo.position,adder);
}
}
}

/*-----------------------------------------------------------------------------
Name : GetDirectionVectorFromMat
Description : gets a direction vector from a matrix (0=up,1=right,2=forward,4=down,5=left,6=back)
Inputs : direction, ship
Outputs : result
Return :
----------------------------------------------------------------------------*/
void GetDirectionVectorFromMat(vector *result,udword direction,matrix *coordsys)
{
switch (direction & 3)
{
case 0:
matGetVectFromMatrixCol1(*result,*coordsys);
break;

case 1:
matGetVectFromMatrixCol2(*result,*coordsys);
break;

case 2:
case 3:
matGetVectFromMatrixCol3(*result,*coordsys);
break;
}

if (direction & 4)
{
vecNegate(*result);
}
}
void mothershipGetCargoPosition(Ship *ship,SpaceObjRotImpTargGuidanceShipDerelict *cargo, vector *position, matrix *coordsys, vector *heading, vector *up, vector *right)
{
MothershipStatics *mothershipstatics = (MothershipStatics *)((ship->staticinfo))->custstatinfo;
vector worldRelative;//doorUp,doorRight,doorHeading;
sdword headingdir,updir;


if(madLinkInGetDoorInfo(ship,coordsys,position))
{
position->x += TW_R1_MOTHERSHIP_DOOR_OFFSET_MODIFIER;
headingdir = mothershipstatics->specialDoorOrientationHeading[((Ship *)cargo)->shiprace][((Ship *)cargo)->shiptype];
if(headingdir == -1)
headingdir = 0;
updir = mothershipstatics->specialDoorOrientationUp[((Ship *)cargo)->shiprace][((Ship *)cargo)->shiptype];
if(updir == -1)
updir = 1;
if(cargo->objtype == OBJ_ShipType)
{
matMultiplyMatByVec(&worldRelative,coordsys,&mothershipstatics->specialDoorOffset[((Ship *)cargo)->shiprace][((Ship *)cargo)->shiptype]);
GetDirectionVectorFromMat(heading,headingdir,coordsys);
GetDirectionVectorFromMat(up,updir,coordsys);
vecCrossProduct(*right,*heading,*up);
}
else
{
//probably never going to get here normally...derelicts will not be salvaged or docked.
//use default values
matMultiplyMatByVec(&worldRelative,coordsys,&mothershipstatics->specialDoorOffset[R1][HeavyCruiser]);
GetDirectionVectorFromMat(heading,0,&ship->rotinfo.coordsys);
GetDirectionVectorFromMat(up,1,&ship->rotinfo.coordsys);
vecCrossProduct(*right,*heading,*up);

}
vecAddTo(*position,worldRelative);
}
else
{
//no postion attainable use default values
*position = ship->posinfo.position;
GetDirectionVectorFromMat(heading,0,&ship->rotinfo.coordsys);
GetDirectionVectorFromMat(up,1,&ship->rotinfo.coordsys);
vecCrossProduct(*right,*heading,*up);
}

}
void MothershipRemoveShipReferences(Ship *ship,Ship *shiptoremove)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
sdword i;
if(shiptoremove == (Ship *) spec->doorCargo)
{
spec->doorCargo = NULL;
}

for(i=0;i<MAX_NUM_DROP;i++)
{
if(shiptoremove == (Ship *) spec->droptarget[i])
{
if(ship->dockInfo != NULL)
{
if(ship->dockInfo->dockpoints[spec->dockindex[i]].thisDockBusy)
ship->dockInfo->dockpoints[spec->dockindex[i]].thisDockBusy--;
}
if(ship->shiprace == R1)
{
if(ship->shiptype == Mothership)
{
if(salCapNeedBig(ship,spec->droptarget[i]))
{
//we will have told the door too open...so lets check
if(ship->madDoorStatus == MAD_STATUS_DOOR_OPEN ||
ship->madDoorStatus == MAD_STATUS_DOOR_OPENING)
{
madLinkInCloseDoor(ship); //close door if open!
}
}
}
}
spec->droptarget[i] = NULL;
}
}
}

void MothershipAttachObjectToDoor(Ship *ship,SpaceObjRotImpTargGuidanceShipDerelict *object)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;

#ifndef HW_Release
dbgAssert(ship->shiptype == Mothership);
dbgAssert(ship->shiprace == R1);
#endif
spec->doorCargo = object;
//in future, need to calculate offset from offset from offset!
}
void MothershipDettachObjectFromDoor(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;

#ifndef HW_Release
dbgAssert(ship->shiptype == Mothership);
dbgAssert(ship->shiprace == R1);
#endif
spec->doorCargo = NULL;
}

#pragma warning( 4 : 4047) // turns off "different levels of indirection warning"
void Mothership_PreFix(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
sdword i;
for(i=0;i<MAX_NUM_DROP;i++)
{
spec->droptarget[i] = SpaceObjRegistryGetID((SpaceObj *)spec->droptarget[i]);
}
spec->doorCargo = SpaceObjRegistryGetID((SpaceObj *)spec->doorCargo);

}

void Mothership_Fix(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
sdword i;
for(i=0;i<MAX_NUM_DROP;i++)
{
spec->droptarget[i] = (SpaceObjRotImpTargGuidanceShipDerelict *)SpaceObjRegistryGetObj((sdword)spec->droptarget[i]);
}
spec->doorCargo = (SpaceObjRotImpTargGuidanceShipDerelict *)SpaceObjRegistryGetObj((sdword)spec->doorCargo);
}
#pragma warning( 2 : 4047) // turn back on "different levels of indirection warning"

udword ReadDockTimer(ubyte *docktimer)
{
return (docktimer[0] | (docktimer[1]<<8) | (docktimer[2]<<16));
}

void WriteDockTimer(ubyte *docktimer,udword newvalue)
{
docktimer[0] = newvalue & 255;
docktimer[1] = (newvalue>>8) & 255;
docktimer[2] = (newvalue>>16) & 255;
}

bool NoShipUsingThisDockPoint(Ship *ship,DockStaticPoint *dockpoint)
{
// walk the command layer to make sure no one is using this dockpoint

Node *curnode = universe.mainCommandLayer.todolist.head;
CommandToDo *command;
SelectCommand *selection;
Ship *dship;
sdword i;

while (curnode != NULL)
{
command = (CommandToDo *)listGetStructOfNode(curnode);
switch (command->ordertype.order)
{
case COMMAND_DOCK:
case COMMAND_LAUNCHSHIP:
selection = command->selection;
for (i=0;i<selection->numShips;i++)
{
dship = selection->ShipPtr[i];
if (dship->dockvars.dockship == ship)
{
if (dship->dockvars.dockstaticpoint == dockpoint)
{
// we're docking/launching with this ship,
return FALSE;
}
}
}
break;
}

curnode = curnode->next;
}

return TRUE;
}

void MothershipHouseKeep(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
sdword i;
bool droppingTargets = FALSE;

for(i=0;i<MAX_NUM_DROP;i++)
{
if(spec->droptarget[i] != NULL)
{
droppingTargets = TRUE;
if(DropTargetInShip(ship,&spec->dropstate[i],spec->droptarget[i],&spec->dockindex[i]))
{
spec->dropstate[i] = 0;
spec->droptarget[i] = NULL;
}
}
}

for(i=0;i<spec->CAP_NumInBuildCue;)
{
spec->CAPTimeToBuildShip[i]-= universe.phystimeelapsed;
if(spec->CAPTimeToBuildShip[i] < 0.0f)
{
//time for a captured ship to pop out
Ship *newship;

if (GetShipStaticInfoSafe(spec->CAPshiptype[i],spec->CAPshiprace[i]))
{
if ((multiPlayerGame) && (ship->playerowner->playerIndex==sigsPlayerIndex))
{
shiplagtotals[spec->CAPshiptype[i]]++;
}

newship = clCreateShip(&universe.mainCommandLayer,
spec->CAPshiptype[i],
spec->CAPshiprace[i],
ship->playerowner->playerIndex,
ship);
newship->colorScheme = spec->CAPcolorScheme[i];
}

spec->CAP_NumInBuildCue--;
spec->CAPTimeToBuildShip[i] = spec->CAPTimeToBuildShip[spec->CAP_NumInBuildCue];
spec->CAPshiptype[i] = spec->CAPshiptype[spec->CAP_NumInBuildCue];
spec->CAPshiprace[i] = spec->CAPshiprace[spec->CAP_NumInBuildCue];
spec->CAPcolorScheme[i] = spec->CAPcolorScheme[spec->CAP_NumInBuildCue];
continue;
}
i++;
}

// check dock point and unbusy if it's busy for really long
if (!droppingTargets)
{
DockPoint *dockpoint = NULL;

if (ship->shiprace == R1)
{
dbgAssert((R1MOTHERSHIP_Big >= 0) && (R1MOTHERSHIP_Big < ship->dockInfo->numDockPoints));
dockpoint = &ship->dockInfo->dockpoints[R1MOTHERSHIP_Big];
}
else if (ship->shiprace == R2)
{
dbgAssert((R2MOTHERSHIP_Big >= 0) && (R2MOTHERSHIP_Big < ship->dockInfo->numDockPoints));
dockpoint = &ship->dockInfo->dockpoints[R2MOTHERSHIP_Big];
}

if (dockpoint)
{
udword docktimer = ReadDockTimer(spec->freedocktimer);

if (dockpoint->thisDockBusy)
{
if (docktimer >= DOCKPOINT_BUSY_TOO_LONG)
{
if (NoShipUsingThisDockPoint(ship,dockpoint->dockstaticpoint))
{
dockpoint->thisDockBusy = 0;
}
docktimer = 0;
}
else
{
docktimer++;
}
}
else
{
docktimer = 0;
}

WriteDockTimer(spec->freedocktimer,docktimer);
}
}
}

void MothershipDied(Ship *ship)
{
MothershipSpec *spec = (MothershipSpec *)ship->ShipSpecifics;
sdword i;
for(i=0;i<MAX_NUM_DROP;i++)
{
if(spec->droptarget[i] != NULL)
{
if(spec->droptarget[i]->objtype == OBJ_ShipType)
{
//undisabled and make selectable
if(!bitTest(((Ship *)spec->droptarget[i])->specialFlags2,SPECIAL_2_DisabledForever))
{
bitClear(spec->droptarget[i]->flags,SOF_Disabled);
bitClear(spec->droptarget[i]->specialFlags,SPECIAL_SalvagedTargetGoingIntoDockWithShip);
bitSet(spec->droptarget[i]->flags,SOF_Selectable);
}
}

}
}
}
CustShipHeader MothershipHeader =
{
Mothership,
sizeof(MothershipSpec),
MothershipStaticInit,
NULL,
MothershipInit,
NULL,
MothershipAttack,
DefaultShipFire,
MothershipAttackPassive,
NULL,
NULL,
MothershipHouseKeep,
MothershipRemoveShipReferences,
MothershipDied,
Mothership_PreFix,
NULL,
NULL,
Mothership_Fix
};



//
// MISSION07 - Swarmer Battle
//
//

//#include "Utilities.kash"


LOCALIZATION //컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴

LSTRING_LCLocationCard
"THE GARDENS OF KADESH"
"JARDINS DE KADESH"
"DIE G?TEN VON KADESH"
"LOS JARDINES DE KADESH"
"I GIARDINI DI KADESH"

LSTRING_FINebulaRich
"The Nebula is incredibly rich in energy and resources. Energy levels are so high that our sensors are having trouble compensating.\n\nBegin harvesting the nebula while we address this problem."
"La N?uleuse est incroyablement riche en ?ergie et en ressources. Il y a de tels niveaux d'?ergie que nos d?ecteurs peinent ?compenser.\n\nCommencez la collecte dans la n?uleuse pendant que nous nous penchons sur ce probl?e."
"Der Nebel ist unglaublich reich an Energie und Rohstoffen. Die Energie-Level sind so hoch, dass unsere Sensoren Probleme haben, dies zu kompensieren.\n\nBeginnen Sie mit der Rohstoffernte im Nebel, w?rend wir uns um dieses Problem k?mern."
"La nebulosa es muy rica en energ? y recursos. Los niveles de energ? son tan altos que nuestros sensores no pueden compensarlos.\n\nEmpieza a recolectar en la nebulosa mientras buscamos soluci? a este problema."
"Questa nebulosa ?ricchissima di energia e risorse; i livelli energetici sono cos?alti che i nostri sensori non riescono a calcolarli.\n\nComincia la raccolta delle risorse, mentre tentiamo di risolvere questo problema."

LSTRING_FIUnknownContacts
"There is a contact closing with the Mothership. Sensors instability in this region makes it difficult to identify."
"Contact ?abli avec v?icule pr? du Vaisseau M?e, mais l'instabilit?des d?ecteurs dans cette r?ion rend son identification difficile."
"Ein Kontakt n?ert sich dem Mutterschiff. Die Sensor-Instabilit? in dieser Region macht eine Identifikation sehr schwierig."
"Se est?cerrando un contacto con la Nave nodriza. La inestabilidad de los sensores en esta zona dificulta la identificaci? de ese contacto."
"C'?un contatto in avvicinamento all'Astronave Madre. Purtroppo, i sensori sono fuori scala e non riescono a identificarlo."

LSTRING_FIPreparingAmbassador
"Prepare the Ambassador."
"Pr?aration de l'Ambassadeur."
"Botschafter bereitmachen."
"Preparad al embajador."
"Prepara l'Ambassador."

LSTRING_FIDefendMothership
"Delay the attacking ships while Fleet Command charges the hyperdrive module. We should have the range to jump clear of the nebula."
"Retardez les vaisseaux agresseurs pendant que l'Amiraut?charge le module d'hyperpropulsion. La port? devrait ?re suffisante pour nous faire bondir hors de la n?uleuse."
"Halten Sie die angreifenden Schiffe zur?k, w?rend das Flottenkommando das Hypersprung-Modul aufl?t. Unsere Reichweite sollte so gro?sein, dass wir aus dem Nebel herausspringen."
"Distrae a las naves atacantes mientras el mando de la flota carga el m?ulo de hiperpropulsi?. Deberemos tener el alcance necesario para salir de la nebulosa."
"Trattieni le navi nemiche mentre il Comando della Flotta carica il modulo dell'iperguida. Dovremmo essere in grado di allontanarci dalla nebulosa."

LSTRING_FCHyperModuleCharging1
"Hyperspace module at 35%, ready in 8 minutes."
"Module hyperspatial ?35%, pr? dans 8 minutes."
"Hypersprung-Modul bei 35%. Bereit in 8 Minuten."
"M?ulo hiperespacial al 35%, preparado en 8 minutos."
"Modulo dell'Iperspazio al 35%, pronto in 8 minuti."

LSTRING_FCHyperModuleCharging2
"Hyperspace module at 90%, ready in 1 minute."
"Module hyperspatial ?90%, pr? dans 1 minute."
"Hypersprung-Modul bei 90%. Bereit in 1 Minute."
"M?ulo hiperespacial al 90%, preparado en 1 minuto."
"Modulo dell'Iperspazio al 90%, pronto in 1 minuto."

LSTRING_FCLetsGetOutOfHere
"Hyperspace module fully charged. Get us out of this place."
"Activation maximale du module hyperspatial. Sortez-nous vite d'ici."
"Hypersprung-Modul voll aufgeladen. Nichts wie raus hier!"
"M?ulo hiperespacial completamente cargado. V?onos de este sitio."
"Modulo dell'Iperspazio pronto. Andiamocene da qui."

LSTRING_FIEngage
"Yes, co-ordinates set. Engage hyperdrive!"
"Oui, le cap est d?ermin? Enclenchez l'hyperpropulsion!"
"Ja, Koordinaten sind eingestellt. Hypersprung-Aggregat einschalten!"
"S? coordenadas establecidas. Activar hiperpropulsi?."
"Coordinate impostate: attiva l'iperguida!"

LSTRING_FCHyperdriveFail
"Hyperdrive jump failed! The Quantum waveform collapsed before the ship could enter hyperspace."
"Le bond par hyperpropulsion a ?hou?! Il y a eu effondrement de l'amplitude quantique avant m?e que le vaisseau puisse atteindre l'hyperespace. "
"Hyperraum-Sprung fehlgeschlagen! Die Quanten-Wellenform brach zusammen, bevor das Schiff in den Hyperraum eintreten konnte."
"Ha fallado la hiperpropulsi?. La forma de onda cu?tica ha colapsado antes de que la nave pudiera entrar en el hiperespacio."
"Salto nell'Iperspazio fallito! La forma d'onda Quantum ?collassata prima che la nave potesse entrare nell'Iperspazio."

LSTRING_FIContinueProtecting
"Analyzing malfunction. Continue to protect the Mothership until the problem is solved."
"Analyse de la d?aillance. Protection du Vaisseau M?e jusqu'?r?olution du probl?e."
"Fehlfunktion wird analysiert. Sch?zen Sie weiterhin das Mutterschiff, bis das Problem gel?t ist."
"Analizando fallo de funcionamiento. Sigue protegiendo la Nave nodriza hasta que se resuelva el problema."
"Stiamo analizzando il malfunzionamento: continua a proteggere l'Astronave Madre fino a quando non avremo trovato una soluzione."

LSTRING_FINewResearch
"We have never had to combat so many fighter craft before. Our Research division has determined that it can design a new type of Corvette specially suited to combat multiple fighters. Begin Research as soon as possible."
"Jamais n'avons nous d?affronter autant de chasseurs. Notre Service de recherche a ?abli la faisabilit?d'un nouveau type de Corvette adapt?au combat contre de multiples chasseurs. Lancez cette recherche d? que possible."
"Wir mussten uns noch nie so vielen J?ern gleichzeitig stellen. Unsere Forschungsabteilung hat festgestellt, dass sie einen neuen Korvettentyp entwickeln kann, der speziell f? den Kampf gegen mehrere J?er ausgelegt ist. Beginnen Sie so schnell wie m?lich mit den Forschungsarbeiten."
"Nunca hab?mos tenido que enfrentarnos a tantos cazas juntos. Nuestra divisi? de investigaci? ha determinado que puede dise?r un nuevo tipo de corbeta concebida especialmente para combatir a varios cazas. La investigaci? debe comenzar cuanto antes."
"Non abbiamo mai dovuto combattere con cos?tanti caccia prima d'ora. I nostri ricercatori pensano di poter creare un nuovo tipo di Corvetta, dedicata al combattimento contro nemici multipli. Comincia le ricerche il prima possibile."

LSTRING_FIProtectResources
"Enemy forces are concentrating on our Resource Collectors. Allocate combat vessels to protect them."
"Les forces ennemies se concentrent sur nos Collecteurs de Ressources. Affectez des unit? de combat ?leur protection."
"Feindliche Kr?te konzentrieren sich auf unsere Rohstoffernteschiffe. Setzen Sie Kampfschiffe zu ihrem Schutz ein."
"Las fuerzas enemigas se concentran en nuestros recolectores de recursos. Asigna naves de combate a su protecci?."
"Le forze nemiche si stanno concentrando intorno ai nostri Collettori di Ricerca: disponi le forze in modo da proteggerli."

LSTRING_FCHyperspaceBack
"The Hyperdrive is back on-line."
"L'hyperpropulsion est de nouveau op?ationnelle."
"Das Hypersprung-Aggregat ist wieder online."
"Ya funciona la hiperpropulsi?."
"L'Iperguida ?di nuovo operativa."

LSTRING_FIJumpAway
"Let's put these fanatics behind us."
"Semons ces fanatiques."
"Nichts wie weg von diesen Irren."
"Alej?onos de esos fan?icos."
"Lasciamoci alle spalle questi pazzi."

LSTRING_TBHyperspace
" HYPERSPACE"
" HYPERESPACE"
" HYPERRAUMSPRUNG"
" HIPERESPACIO"
" IPERSPAZIO"

LSTRING_OBDefendFleet
"Defend Fleet"
"D?endre la Flotte"
"Flotte sch?zen."
"Defiende la flota"
"Difendi la flotta"

LSTRING_OBHarvestNebula
"Harvest Nebula"
"Collecter des ressources au sein de la N?uleuse"
"Rohstoffe in Nebelwolke ernten."
"Recolecta nebulosas"
"Raccogli le risorse nella nebulosa"

LSTRING_OBProtect
"Protect Resourcers"
"Prot?er les collecteurs de ressources"
"Rohstoffschiffe sch?zen."
"Protege los recursos"
"Proteggi le risorse"

LSTRING_LevelSave
"07 - The Gardens of Kadesh"
"07 - Jardins de Kadesh"
"07 – Die G?ten von Kadesh"
"07 - Los jardines de Kadesh"
"07 - I giardini di Kadesh"

ENDL //컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴


#define MISSION7
#define MOTHERTEAM TEAM_P2Mothership
#define MASTERTEAM TEAM_P2Mothership
#define EVENTSTEAM TEAM_Dummy1
#include "Swarmer.kash"
#include "speechevent.h"
#include "soundmusic.h"
#include "CommandDefs.h"
//-----------------------------------------------------------------------------
// Name : Events
// Description : Contains Fleet Intel/Command events and Objectives
// Objectives: Harvest Nebula
// Defend Mothership
// Secondary Objectives: Defend Resource Collectors
//-----------------------------------------------------------------------------
FSM Events

States LocationCard, Wait1, NebulaRich, UnknownContacts, PreparingAmbassador, UnknownContactsWait, LBXIn1,
P2IntroNIS, DefendMothership, HyperModuleCharging1, HyperModuleCharging2,
LetsGetOutOfHere, Engage, HyperdriveFail, ContinueProtecting, AddedResearch, ProtectResourcers,
P2MothershipEscapes, HyperspaceBack, JumpAway, NullState, FinalState;

INIT
VarCreateSet("InNullState", FALSE);
IntelEventNotEnded();
JUMP LocationCard;
// VarCreateSet("G_MothershipComeOnIn", TRUE);
// JUMP UnknownContactsWait; //temporary
ENDINIT
WATCH
// IFONCE (FindEnemyShipsOfType(SHIPS_Whatever, "Carrier"))
// JUMP LetsGetOutOfHere;
// ENDIFONCE

//once a few resources have been collected,
//trigger the P2
IFONCE (VarGet("G_HarvestedRUs") > 600)
MsgSend(TEAM_P2Mothership, "MothershipComeOnIn");
VarSet("InNullState", FALSE);
JUMP UnknownContactsWait;
ENDIFONCE

IFONCE (FindEnemyShipsOfType(SHIPS_Stuff, "HeavyCruiser"))
MsgSend(TEAM_P2Mothership, "MothershipComeOnIn");
VarSet("InNullState", FALSE);
JUMP UnknownContactsWait;
ENDIFONCE

//IFONCE (FindEnemyShipsOfType(SHIPS_Stuff, "Carrier"))
// TimerCreateSetStart("HyperTest", 20);
//ENDIFONCE

//IF (TimerExpiredDestroy("HyperTest"))
// JUMP Engage;
//ENDIF

IFONCE ((RUsEnemyCollected() > 1400))
ObjectiveSet("Harvest", TRUE);
ENDIFONCE

IFONCE (MsgReceived("ImTakingTheResourcers"))
TimerCreateSetStart("Resourcers", Random(20, 30));
ENDIFONCE

//for new research
IFONCE (MsgReceived("MoSwarmersInTrouble"))
TimerCreateSetStart("ResearchTimer", 45);
ENDIFONCE

IF (VarGet("G_CLICK_Harvest"))
VarDestroy("G_CLICK_Harvest");
JUMP NebulaRich;
ELSEIF (VarGet("G_CLICK_DefendFleet"))
VarDestroy("G_CLICK_DefendFleet");
JUMP DefendMothership;
ELSEIF (VarGet("G_CLICK_ProtectResourcers"))
VarDestroy("G_CLICK_ProtectResourcers");
JUMP ProtectResourcers;
ENDIF

//only call these states if we're in the NULL state
IF (VarGet("InNullState") && !VarGet("InFinalState"))
//this state was called from DefendMothership state
IFONCE (TimerExpiredDestroy("ChargeUpTimer1"))
VarSet("InNullState", FALSE);
JUMP HyperModuleCharging1;
ENDIFONCE

//this state was called from HyperModuleCharging1 state
IFONCE (TimerExpiredDestroy("ChargeUpTimer2"))
VarSet("InNullState", FALSE);
JUMP HyperModuleCharging2;
ENDIFONCE

//finished charging up soon
IFONCE (TimerExpiredDestroy("ChargeUpTimer3"))
VarSet("InNullState", FALSE);
JUMP LetsGetOutOfHere;
ENDIFONCE

//new research topic
IFONCE (TimerExpiredDestroy("ResearchTimer"))
VarSet("InNullState", FALSE);
JUMP AddedResearch;
ENDIFONCE

//Resourcers being attacked
IFONCE (TimerExpiredDestroy("Resourcers"))
VarSet("InNullState", FALSE);
JUMP ProtectResourcers;
ENDIFONCE

//P2Mothership takes off
IFONCE (MsgReceived("P2MothershipBlowin"))
VarSet("InNullState", FALSE);
JUMP P2MothershipEscapes;
ENDIFONCE

//if the mothership died, instead of hyperspacing out
IFONCE (VarGet("P2MothershipIn") && !FindFriendlyShipsOfType(SHIPS_Temp, "P2Mothership"))
VarSet("InNullState", FALSE);
JUMP HyperspaceBack;
ENDIFONCE
ENDIF

ENDWATCH

//---------------------------
// Events: LocationCard
// Wait a little for location card
STATE LocationCard
INIT
TimerCreateSetStart("LocationCardTimer", 2);
ENDINIT
WATCH
IF (TimerExpiredDestroy("LocationCardTimer"))
LocationCard(5000, LSTRING_LCLocationCard);
JUMP Wait1;
ENDIF
ENDWATCH
ENDSTATE LocationCard

//---------------------------
// Events: Wait1
// Wait a little while everything launches
STATE Wait1
INIT
TimerCreateSetStart("Launching", 8);
ENDINIT
WATCH
IF (TimerExpiredDestroy("Launching"))
JUMP NebulaRich;
ENDIF
ENDWATCH
ENDSTATE Wait1

//---------------------------
// Events: NebulaRich
// Event 1.0 Fleet Intel Observes Rich Nebula
STATE NebulaRich
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_HarvestNebula, 0);
// SubtitleSimulate(4, 18000, LSTRING_FINebulaRich);
ObjectiveCreate("Harvest", LSTRING_OBHarvestNebula, "fleet intel 3.2");
JUMP NullState;
ENDINIT
WATCH
ENDWATCH
ENDSTATE NebulaRich

//---------------------------
// Events: UnknownContactsWait
// Delay time for Unknown contacts event to start
STATE UnknownContactsWait
INIT
TimerCreateSetStart("ScaryUFOGuys", Random(20, 28));
ENDINIT
WATCH
IF (TimerExpiredDestroy("ScaryUFOGuys"))
VarCreateSet("MothershipIn", TRUE);
JUMP LBXIn1;
ENDIF
ENDWATCH
ENDSTATE UnknownContactsWait

//---------------------------
// Events: LBXIn1
// Letterbox come in...
STATE LBXIn1
INIT
wideScreenIn(30);
TimerCreateSetStart("LBXTimer", 4);
ENDINIT
WATCH
IF ((TimerRemaining("LBXTimer") == 0))
OpenSensors(80000);
JUMP UnknownContacts;
ENDIF
ENDWATCH
ENDSTATE LBXIn1

//---------------------------
// Events: UnknownContacts
// Event 1.1 Intel believes an unknown contact
// is closing on the mothership
STATE UnknownContacts
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_AlertStatus, 0);
// SubtitleSimulate(4, 15000, LSTRING_FIUnknownContacts);
TutSetPointerTargetShipSelection("Contacts", TEAMSHIPS_P2Mothership);
PingAddShips(TEAMSHIPS_P2Mothership, "UnknownContacts");
ENDINIT
WATCH
IF (IntelEventEnded())
TutRemoveAllPointers();
CloseSensors(TRUE);
WideScreenOut(90);
JUMP PreparingAmbassador;
ENDIF
ENDWATCH
ENDSTATE UnknownContacts

//---------------------------
// Events: PreparingAmbassador
// Letterbox come in...
STATE PreparingAmbassador
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_PrepareAmbassador, 0);
// SubtitleSimulate(4, 5000, LSTRING_FIPreparingAmbassador);
ENDINIT
WATCH
IF (IntelEventEnded())
TimerCreateSetStart("Ambassador", 5);
TimerCreateSetStart("LBX", 2);
ENDIF
IF (TimerExpiredDestroy("LBX"))
WideScreenIn(90);
ENDIF
IF (TimerExpiredDestroy("Ambassador"))
JUMP P2IntroNIS;
ENDIF
ENDWATCH
ENDSTATE PreparingAmbassador

//---------------------------
// Events: P2IntroNIS
// Event 1.2 Play N05
STATE P2IntroNIS
INIT
FindEnemyShipsOfType(SHIPS_NISTargetShips, "Mothership");
PingRemove("UnknownContacts");
VarCreateSet("G_PlayNis", 5);
VarCreateSet("G_PlayingNIS", TRUE);
ENDINIT
WATCH
IF (VarGet("G_Nis5Complete"))
VarSet("G_PlayingNIS", FALSE);
WideScreenOut(90);
JUMP DefendMothership;
ENDIF
ENDWATCH
ENDSTATE P2IntroNIS

//---------------------------
// Events: DefendMothership
// Event 1.3 Intel asks to hold off swarmers
STATE DefendMothership
INIT
MusicPlay(B03_Swarmers);
SoundEvent(262);
SpeechEvent(M07_Intel_DefendMothership, 0);
// SubtitleSimulate(4, 10000, LSTRING_FIDefendMothership);
ObjectiveCreate("DefendFleet", LSTRING_OBDefendFleet, "fleet intel 3.2");
TimerCreateSetStart("ChargeUpTimer1", 30); //30 seconds
ENDINIT
WATCH
JUMP NullState;
ENDWATCH
ENDSTATE DefendMothership

//---------------------------
// Events: HyperModuleCharging1
// Event 1.4 Hyperspace Module at 35
STATE HyperModuleCharging1
INIT
SoundEvent(262);
SpeechEvent(M07_Fleet_Charging8Minutes, 0);
// SubtitleSimulate(0, 10000, LSTRING_FCHyperModuleCharging1);
TimerCreateSetStart("ChargeUpTimer2", 420);
ENDINIT
WATCH
JUMP NullState;
ENDWATCH
ENDSTATE HyperModuleCharging1

//---------------------------
// Events: HyperModuleCharging2
// Event 1.5 Hyperspace module at 90
STATE HyperModuleCharging2
INIT
SoundEvent(262);
SpeechEvent(M07_Fleet_Charging1Minute, 0);
// SubtitleSimulate(0, 10000, LSTRING_FCHyperModuleCharging2);
TimerCreateSetStart("ChargeUpTimer3", 60);
ENDINIT
WATCH
JUMP NullState;
ENDWATCH
ENDSTATE HyperModuleCharging2

//---------------------------
// Events: LetsGetOutOfHere
// Event 1.6 Fleet command says "let's get out of here!"
STATE LetsGetOutOfHere
INIT
SoundEvent(262);
SpeechEvent(M07_Fleet_HyperspaceReady, 0);
MsgSend(TEAM_P2Mothership, "PlayerPoweredUp");
// SubtitleSimulate(0, 10000, LSTRING_FCLetsGetOutOfHere);
ENDINIT
WATCH
IF (IntelEventEnded())
JUMP Engage;
ENDIF
ENDWATCH
ENDSTATE LetsGetOutOfHere

//---------------------------
// Events: Engage
// Event 1.6 Fleet Intel does the picard thing
// but hyperspacing has been disabled! Watchout!
STATE Engage
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_EngageHyperdrive, 0);
// SubtitleSimulate(4, 10000, LSTRING_FIEngage);
DisablePlayerHyperspace();
ObjectiveSet("DefendFleet", TRUE);
ObjectiveCreate("Hyperspace", LSTRING_TBHyperspace, LSTRING_FIEngage);
ENDINIT
WATCH
IF (TutGameSentMessage("Game_HyperspaceFailed") == 1)
JUMP HyperdriveFail;
ENDIF
ENDWATCH
ENDSTATE Engage

//---------------------------
// Events: HyperdriveFail
// Event 1.7 Fleet Command whines about hyperdrive failing
STATE HyperdriveFail
INIT
SoundEvent(262);
SpeechEvent(M07_Fleet_HyperdriveFailedNEW, 0);
// SubtitleSimulate(0, 10000, LSTRING_FCHyperdriveFail);
ENDINIT
WATCH
IF (IntelEventEnded())
MsgSend(TEAM_P2Mothership, "TheyreGettingAway");
JUMP ContinueProtecting;
ENDIF
ENDWATCH
ENDSTATE HyperdriveFail

//---------------------------
// Events: ContinueProtecting
// Event 1.7 Fleet Intel tries to do something about hyperdrive
STATE ContinueProtecting
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_AnalyzingField, 0);
// SubtitleSimulate(4, 10000, LSTRING_FIContinueProtecting);
ObjectiveDestroy("DefendFleet");
ObjectiveDestroy("Hyperspace");
ObjectiveCreate("DefendFleet", LSTRING_OBDefendFleet, "fleet intel 3.2");
TimerCreateSetStart("ResearchTimer", 45);
ENDINIT
WATCH
JUMP NullState;
ENDWATCH
ENDSTATE ContinueProtecting

//---------------------------
// Events: AddedResearch
// Fleet intel indicates a new research topic is available
STATE AddedResearch
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_ResearchMultigunVette, 0);
// SubtitleSimulate(4, 10000, LSTRING_FINewResearch);
TechSetResearch("TargetingSystems");
ENDINIT
WATCH
JUMP NullState;
ENDWATCH
ENDSTATE AddedResearch


//---------------------------
// Events: ProtectResourcers
// Event 1.8 Secondary objective - protect resourcers
STATE ProtectResourcers
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_DefendCollectors, 0);
// SubtitleSimulate(0, 10000, LSTRING_FIProtectResources);
ObjectiveCreateSecondary("ProtectResourcers", LSTRING_OBProtect, LSTRING_FIProtectResources);
ENDINIT
WATCH
JUMP NullState;
ENDWATCH
ENDSTATE ProtectResourcers

//---------------------------
// Events: P2MothershipEscapes
// Event 1.9 NISLet of P2 Mothership leaving
STATE P2MothershipEscapes
INIT
SoundEvent(262);
TutCameraFocus(TEAMSHIPS_P2Mothership);
TutCameraFocus(TEAMSHIPS_P2Mothership);
MusicStop (4);
TimerCreateSetStart("P2EscapeTimer", 20);
TimerCreateSetStart("CancelFocus", 14);
// ShipsAdd(SHIPS_NisCenterShip, TEAMSHIPS_P2Mothership);
// VarCreateSet("G_PlayNislet", 70);
ENDINIT
WATCH
IF (TutGameSentMessage("Game_BandBoxFocus,Game_ClickFocus,KB_CancelFocus,KB_Focus"))
TimerDestroy("CancelFocus");
ENDIF

IF (TimerExpiredDestroy("CancelFocus"))
SoundEvent(262);
TutCameraFocusCancel();
TutCameraFocusCancel();
ENDIF

IF (TimerExpiredDestroy("P2EscapeTimer"))
VarSet("P2MothershipIn", FALSE);
JUMP HyperspaceBack;
ENDIF
ENDWATCH
ENDSTATE P2MothershipEscapes

//---------------------------
// Events: HyperspaceBack
// Event 1.10 Fleet Command all giddy about hyperspace being back
STATE HyperspaceBack
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_FieldDisappeared, 0);
// SubtitleSimulate(0, 10000, LSTRING_FCHyperspaceBack);
ObjectiveCreate("Hyperspace", LSTRING_TBHyperspace, LSTRING_FIEngage);
ObjectiveSet("DefendFleet", TRUE);
ENDINIT
WATCH
IF (IntelEventEnded())
JUMP JumpAway;
ENDIF
ENDWATCH
ENDSTATE HyperspaceBack

//---------------------------
// Events: JumpAway
// Event 1.10 Fleet Intel oozes with pleasure about hyperdrives
STATE JumpAway
INIT
SoundEvent(262);
SpeechEvent(M07_Intel_HyperdriveFunctional, 0);
//SubtitleSimulate(4, 10000, LSTRING_FIJumpAway);
ENDINIT
WATCH
JUMP FinalState;
ENDWATCH
ENDSTATE JumpAway

//*** Need mission failure states.

//---------------------------
// Events: NullState
// Nothing happens here
STATE NullState
INIT
VarCreateSet("InNullState", TRUE);
ENDINIT
WATCH
ENDWATCH
ENDSTATE NullState

//---------------------------
// Events: FinalState
// Nothing happens here
STATE FinalState
INIT
VarCreateSet("InFinalState", TRUE);
ENDINIT
WATCH
ENDWATCH
ENDSTATE FinalState


ENDFSM Events


//-----------------------------------------------------------------------------
// Name : P2Mothership
// Description : P2 Mothership - moves around and drops off swarmers, then makes a b-line outa there
//-----------------------------------------------------------------------------
FSM P2Mothership

States NullState, Wait, Reappear, InitialAttack, ReissueMove, HyperDodge, HypeDodgeIn, MidBattle,
SecondAttack, EndBattleDelay, EndBattle, DefendSelf, GetOuttaHere;

INIT
VarCreateSet("WaveNum", 0);
JUMP Wait;
ENDINIT
WATCH
IF (!VarGet("G_MothershipDead"))
// IFONCE (Nearby(POINT_StartPointPlayer, 6000))
// MoveTo(POINT_Vol2);
// ENDIFONCE

IFONCE (Nearby(POINT_Vol2, 2000))
VarSet("MovingToVol2", FALSE);
VarCreateSet("MovingToVol1", TRUE);
MoveTo(POINT_Vol1);
ENDIFONCE

IFONCE (Nearby(POINT_Vol1, 2000))
VarSet("MovingToVol1", FALSE);
VarCreateSet("MovingToVol3", TRUE);
MoveTo(POINT_Vol3);
ENDIFONCE

IFONCE (Nearby(POINT_Vol3, 2000))
VarSet("MovingToVol2", FALSE);
VarCreateSet("AttackingMothership", TRUE);
AttackMothership();
ENDIFONCE

IFONCE ((VarGet("WaveNum") == 6) && VarGet("FinalAssaultGone"))
TimerCreateSetStart("ImDryImOuttaHere", Random(60, 90));
ENDIFONCE

IFONCE (TimerExpiredDestroy("ImDryImOuttaHere"))
JUMP GetOuttaHere;
ENDIFONCE

IF (!VarGet("DodgingOrOuttaHere") &&
TeamHealthLowest() <= MO_ESCAPE_HYPER_HEALTH)
IF (VarGet("AttackingMothership"))
JUMP GetOuttaHere;
ELSE
JUMP HyperDodge;
ENDIF
ENDIF


ENDIF
IFONCE (TeamCount() == 0)
//I am Invincible!!!!
FindEnemyShipsOfType(SHIPS_YourDeadNow, "Mothership");
KamikazeEveryone(SHIPS_YourDeadNow);
VarCreateSet("G_MothershipDead", TRUE);
JUMP NullState;
ENDIFONCE
ENDWATCH

//---------------------------
// P2Mothership: Wait
// Waits for other ships to dock with it, then disappears
STATE Wait
INIT
TimerCreateSetStart("WaitForDocking", 2);
ENDINIT
WATCH
IF (TimerExpiredDestroy("WaitForDocking"))
TeamHyperspaceOut();
ENDIF
IF (MsgReceived("MothershipComeOnIn"))
JUMP Reappear;
ENDIF
ENDWATCH
ENDSTATE Wait

//---------------------------
// P2Mothership: Reappear
// Mothership reappears for a time
STATE Reappear
INIT
TeamHyperspaceIn(POINT_MothershipIn);
// AttackMothership(); //just to get the P2 Mothership closer to the Mothership
ENDINIT
WATCH
IFONCE (Nearby(POINT_MothershipIn, 2000))
AttackMothership();
ENDIFONCE
IFONCE (VarGet("G_PlayingNIS"))
Stop();
HideShips(TEAMSHIPS_P2Mothership);
ENDIFONCE
IF (VarGet("G_Nis5Complete"))
UnHideShips(TEAMSHIPS_P2Mothership);
MoveTo(POINT_Vol2);
VarCreateSet("MovingToVol2", TRUE);
JUMP InitialAttack;
ENDIF
ENDWATCH
ENDSTATE Reappear

//---------------------------
// P2Mothership: InitialAttack
// Main Attack Code for the P2 Mothership
STATE InitialAttack
INIT
// initial attack (wave 0) sent off
VarInc("WaveNum");

FSMCreate(GenericMothershipSwarm, TEAM_NISTeam1);
FindEnemyShipsOfType(SHIPS_Test, "ResourceCollector");
FindEnemiesNearby(SHIPS_Test, 6000);

// if there are armed ships near the resourcers
IF (ShipsSelectSpecial(SHIPS_Armed, SHIPS_Test, 3) > 5)
FSMCreate(ResourceDefenderSwarm, TEAM_NISTeam2);
TimerCreateSetStart("ResourcerSwarm", Random(50, 70));
ELSE
FSMCreate(GenericResourcerSwarm, TEAM_NISTeam2);
TimerCreateSetStart("ResourceDefenderSwarm", Random(50, 70));
ENDIF
ENDINIT
WATCH
IF (TimerExpiredDestroy("ResourcerSwarm"))
FSMCreate(GenericResourcerSwarm, TEAM_NISTeam3);
JUMP MidBattle;
ENDIF

IF (TimerExpiredDestroy("ResourceDefenderSwarm"))
FSMCreate(ResourceDefenderSwarm, TEAM_NISTeam3);
JUMP MidBattle;
ENDIF
ENDWATCH
ENDSTATE InitialAttack


//---------------------------
// P2Mothership: ReissueMove
// Gets the mothership moving again after it attacks
STATE ReissueMove
INIT
IF (VarGet("MovingToVol2"))
MoveTo(POINT_Vol2);
ELSEIF (VarGet("MovingToVol1"))
MoveTo(POINT_Vol1);
ELSEIF (VarGet("MovingToVol3"))
MoveTo(POINT_Vol3);
ELSEIF (VarGet("AttackingMothership"))
AttackMothership();
ENDIF
JUMP MidBattle;
ENDINIT
WATCH
ENDWATCH
ENDSTATE ReissueMove

//---------------------------
// P2Mothership: HyperDodge
// Mothership hyperspaces out, then hyperspaces in at another point.
STATE HyperDodge
INIT
//keeps this state from being called over and over again
VarCreateSet("DodgingOrOuttaHere", TRUE);
TeamHyperspaceOut();
TimerCreateSetStart("HyperspaceTimer", 15);
ENDINIT
WATCH
IF (TimerExpiredDestroy("HyperspaceTimer"))
JUMP HypeDodgeIn;
ENDIF
ENDWATCH
ENDSTATE HyperDodge


//---------------------------
// P2Mothership: HypeDodgeIn
// Waits for the P2Mothership to hyperspace in
STATE HypeDodgeIn
INIT
TeamHealthSet(100);
IF (VarGet("MovingToVol2"))
TeamHyperspaceIn(POINT_Vol2);
ELSEIF (VarGet("MovingToVol1"))
TeamHyperspaceIn(POINT_Vol1);
ELSEIF (VarGet("MovingToVol3"))
TeamHyperspaceIn(POINT_Vol3);
ELSE
TeamHyperspaceIn(POINT_Vol2);
ENDIF
ENDINIT
WATCH
IF (Nearby(THISTEAMSPOINT, 10000))
VarDestroy("DodgingOrOuttaHere");
JUMP MidBattle;
ENDIF
ENDWATCH
ENDSTATE HypeDodgeIn

...

//---------------------------
// P2Mothership: DefendSelf
// P2 Mothership sends out bunch of defense stuff.
STATE DefendSelf
INIT
UnderAttack(SHIPS_Attacking);
IF (ShipsSelectCapital(SHIPS_Capital, SHIPS_Attacking))
VarCreateSet("CounterAttack", TRUE);
Attack(SHIPS_Capital);
ENDIF

//maybe launch depending on number of attackers
//or have timer change depending on number of attackers
IF (VarGet("WaveNum") == 1)
MsgSend(TEAM_FuelPod1WAVE1, "DefendMothership");
MsgSend(TEAM_Swarmer1WAVE1, "DefendMothership");
ELSEIF (VarGet("WaveNum") == 2)
MsgSend(TEAM_FuelPod1WAVE2, "DefendMothership");
MsgSend(TEAM_Swarmer1WAVE2A, "DefendMothership");
MsgSend(TEAM_Swarmer1WAVE2B, "DefendMothership");
VarInc("WaveNum");
ELSEIF (VarGet("WaveNum") == 3)
MsgSend(TEAM_FuelPod2WAVE1, "DefendMothership");
MsgSend(TEAM_Swarmer2WAVE1, "DefendMothership");
VarInc("WaveNum");
ELSEIF (VarGet("WaveNum") == 4)
MsgSend(TEAM_FuelPod2WAVE2, "DefendMothership");
MsgSend(TEAM_Swarmer2WAVE2A, "DefendMothership");
MsgSend(TEAM_Swarmer2WAVE2B, "DefendMothership");
VarInc("WaveNum");
ELSEIF (VarGet("WaveNum") == 5)
MsgSend(TEAM_FuelPod3WAVE1, "DefendMothership");
MsgSend(TEAM_Swarmer3WAVE1, "DefendMothership");
VarInc("WaveNum");
ENDIF
TimerCreateSetStart("DefenseTimer", Random(40, 100));
ENDINIT
WATCH
// wait a bit
IF (TimerExpiredDestroy("DefenseTimer"))
IF (UnderAttack(SHIPS_Attacking))
SetSwarmTargets(SHIPS_Attacking);
ENDIF
JUMP MidBattle;
ENDIF
IF (VarGet("CounterAttack") &&
(ShipsOrder(THISTEAMSHIPS) != COMMAND_ATTACK))
IF (UnderAttack(SHIPS_Attacking) &&
ShipsSelectCapital(SHIPS_Capital, SHIPS_Attacking))
Attack(SHIPS_Capital);
ELSE
VarDestroy("CounterAttack");
ENDIF
ENDIF
ENDWATCH
ENDSTATE DefendSelf


//---------------------------
// P2Mothership: EndBattle
// Delay before the end of battle
STATE EndBattleDelay
INIT
TimerCreateSetStart("AttackTimer", Random(5, 20));
ENDINIT
WATCH
IF (TimerExpiredDestroy("AttackTimer"))
JUMP EndBattle;
ENDIF
ENDWATCH
ENDSTATE EndBattleDelay


//---------------------------
// P2Mothership: EndBattle
// Mothership launches last wave and attacks the mothership
STATE EndBattle
INIT
// AttackMothership();
MsgSend(TEAM_FuelPod3WAVE2, "MothershipSwarm");
MsgSend(TEAM_Swarmer3WAVE2A, "MothershipSwarm");
MsgSend(TEAM_Swarmer3WAVE2B, "MothershipSwarm");
TimerCreateSetStart("AttackTimer", Random(30, 60));
VarCreateSet("FinalAssaultGone", TRUE);
ENDINIT
WATCH
IF (TimerExpiredDestroy("AttackTimer") AND
VarGet("WaveNum") < 6)
JUMP MidBattle;
ENDIF
ENDWATCH
ENDSTATE EndBattle


//---------------------------
// P2Mothership: GetOuttaHere
// Mothership calls in ships to dock, then hyperspaces out
STATE GetOuttaHere
INIT
VarCreateSet("DodgingOrOuttaHere", TRUE);
MsgSendAll("DockNow");
TimerCreateSetStart("BootIt", 50);
ENDINIT
WATCH
IF (TeamHealthLowest() < MO_ESCAPE_LOW_HEALTH)
TeamHealthSet(MO_ESCAPE_PROPUP_HEALTH);
ENDIF

VarSet("NumSwarmers", FindFriendlyShipsOfType(SHIPS_Swarmers, "P2Swarmer"));
VarSet("NumAdv", FindFriendlyShipsOfType(SHIPS_AdvSwarmers, "P2AdvanceSwarmer"));

IF (((VarGet("NumSwarmers") == 0) && (VarGet("NumAdv") == 0)) ||
(TeamHealthLowest() <= 8) ||
(TimerExpiredDestroy("BootIt")))
MsgSendAll("P2MothershipBlowin");
TeamHyperspaceOut();
JUMP NullState;
ENDIF
ENDWATCH
ENDSTATE GetOuttaHere

//---------------------------
// P2Mothership: NullState
// Nothing happens here
STATE NullState
INIT
ENDINIT
WATCH
ENDWATCH
ENDSTATE NullState

ENDFSM P2Mothership

...

//栢栢栢栢栢栢栢栢栢栢栢 Global Stuff 栢栢栢栢栢栢栢栢栢栢栢