//----------------------------------------------------------------------------------- DROID *getTrackingDroid( void ) { if(!getWarCamStatus()) return(NULL); if(trackingCamera.status != CAM_TRACKING) return(NULL); if(trackingCamera.target->type != OBJ_DROID) return(NULL); return((DROID*)trackingCamera.target); }
// select the n'th command droid void selCommander(int n) { for (DROID *psCurr = apsDroidLists[selectedPlayer]; psCurr; psCurr = psCurr->psNext) { if (droidIsCommanderNum(psCurr, n)) { if (!psCurr->selected) { clearSelection(); psCurr->selected = true; } else { clearSelection(); psCurr->selected = true; // this horrible bit of code is taken from activateGroupAndMove // and sets the camera position to that of the commander if (getWarCamStatus()) { camToggleStatus(); // messy - fix this processWarCam(); // odd, but necessary camToggleStatus(); // messy - FIXME } else { /* Centre display on him if warcam isn't active */ setViewPos(map_coord(psCurr->pos.x), map_coord(psCurr->pos.y), true); } } return; } } }
// --------------------------------------------------------------------- void selNextSpecifiedBuilding(STRUCTURE_TYPE structType) { STRUCTURE *psResult = nullptr, *psOldStruct = nullptr, *psFirst = nullptr; bool bLaterInList = false; /* Firstly, start coughing if the type is invalid */ ASSERT(structType <= NUM_DIFF_BUILDINGS, "Invalid structure type %u", structType); for (STRUCTURE *psCurr = apsStructLists[selectedPlayer]; psCurr && !psResult; psCurr = psCurr->psNext) { if ((psCurr->pStructureType->type == structType) && (psCurr->status == SS_BUILT)) { if (!psFirst) { psFirst = psCurr; } if (psCurr->selected) { bLaterInList = true; psOldStruct = psCurr; } else if (bLaterInList) { psResult = psCurr; } } } if (!psResult && psFirst) { psResult = psFirst; } if (psResult && !psResult->died) { if (getWarCamStatus()) { camToggleStatus(); } setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), false); if (psOldStruct) { psOldStruct->selected = false; } psResult->selected = true; triggerEventSelected(); jsDebugSelected(psResult); } else { // Can't find required building addConsoleMessage("Cannot find required building!", LEFT_JUSTIFY, SYSTEM_MESSAGE); } }
/* Updates the camera position/angle along with the object movement */ bool processWarCam( void ) { BASE_OBJECT *foundTarget; bool Status = true; /* Get out if the camera isn't active */ if(trackingCamera.status == CAM_INACTIVE) { return(true); } /* Ensure that the camera only ever flips state within this routine! */ switch(trackingCamera.status) { case CAM_REQUEST: /* See if we can find the target to follow */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { /* We've got one, so store away info */ camAllignWithTarget(foundTarget); /* We're now into tracking status */ trackingCamera.status = CAM_TRACKING; /* Inform via console */ if(foundTarget->type == OBJ_DROID) { if(getWarCamStatus()) { CONPRINTF(ConsoleString,(ConsoleString,"WZ/CAM - %s",droidGetName((DROID*)foundTarget))); } } } else { /* We've requested a track with no droid selected */ trackingCamera.status = CAM_INACTIVE; } break; case CAM_TRACKING: /* Track the droid unless routine comes back false */ if(!camTrackCamera()) { /* Camera track came back false, either because droid died or is no longer selected, so reset to old values */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { trackingCamera.status = CAM_REQUEST; } else { trackingCamera.status = CAM_RESET; } } processLeaderSelection(); break; case CAM_RESET: /* Reset camera to pre-droid tracking status */ if( (trackingCamera.target==NULL) ||(trackingCamera.target->type!=OBJ_TARGET)) { camSwitchOff(); } /* Switch to inactive mode */ trackingCamera.status = CAM_INACTIVE; Status = false; break; case CAM_INACTIVE: case CAM_TRACK_OBJECT: case CAM_TRACK_LOCATION: ASSERT(false, "Unexpected status for tracking camera"); break; } return Status; }
static void processLeaderSelection( void ) { DROID *psDroid; DROID *psPresent; DROID *psNew = NULL; UDWORD leaderClass; bool bSuccess; UDWORD dif; UDWORD bestSoFar; if (getWarCamStatus()) { /* Only do if we're tracking a droid */ if (trackingCamera.target->type != OBJ_DROID) { return; } } else { return; } /* Don't do if we're driving?! */ if (getDrivingStatus()) { return; } psPresent = (DROID*)trackingCamera.target; if (keyPressed(KEY_LEFTARROW)) { leaderClass = LEADER_LEFT; } else if (keyPressed(KEY_RIGHTARROW)) { leaderClass = LEADER_RIGHT; } else if (keyPressed(KEY_UPARROW)) { leaderClass = LEADER_UP; } else if (keyPressed(KEY_DOWNARROW)) { leaderClass = LEADER_DOWN; } else { leaderClass = LEADER_STATIC; } bSuccess = false; bestSoFar = UDWORD_MAX; switch (leaderClass) { case LEADER_LEFT: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenX < psPresent->sDisplay.screenX) { dif = psPresent->sDisplay.screenX - psDroid->sDisplay.screenX; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_RIGHT: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenX > psPresent->sDisplay.screenX) { dif = psDroid->sDisplay.screenX - psPresent->sDisplay.screenX; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_UP: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenY < psPresent->sDisplay.screenY) { dif = psPresent->sDisplay.screenY - psDroid->sDisplay.screenY; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_DOWN: for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { /* Is it even on the sscreen? */ if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) && psDroid->selected && psDroid != psPresent) { if (psDroid->sDisplay.screenY > psPresent->sDisplay.screenY) { dif = psDroid->sDisplay.screenY - psPresent->sDisplay.screenY; if (dif < bestSoFar) { bestSoFar = dif; bSuccess = true; psNew = psDroid; } } } } break; case LEADER_STATIC: break; } if (bSuccess) { camAllignWithTarget((BASE_OBJECT*)psNew); } }
static GAMECODE renderLoop() { if (bMultiPlayer && !NetPlay.isHostAlive && NetPlay.bComms && !NetPlay.isHost) { intAddInGamePopup(); } int clearMode = 0; if(getDrawShadows()) { clearMode |= CLEAR_SHADOW; } if (loopMissionState == LMS_SAVECONTINUE) { pie_SetFogStatus(false); clearMode = CLEAR_BLACK; } pie_ScreenFlip(clearMode);//gameloopflip HandleClosingWindows(); // Needs to be done outside the pause case. audio_Update(); wzShowMouse(true); INT_RETVAL intRetVal = INT_NONE; if (!paused) { /* Run the in game interface and see if it grabbed any mouse clicks */ if (!rotActive && getWidgetsStatus() && dragBox3D.status != DRAG_DRAGGING && wallDrag.status != DRAG_DRAGGING) { intRetVal = intRunWidgets(); } //don't process the object lists if paused or about to quit to the front end if (!gameUpdatePaused() && intRetVal != INT_QUIT) { if( dragBox3D.status != DRAG_DRAGGING && wallDrag.status != DRAG_DRAGGING && ( intRetVal == INT_INTERCEPT || ( radarOnScreen && CoordInRadar(mouseX(), mouseY()) && getHQExists(selectedPlayer) ) ) ) { // Using software cursors (when on) for these menus due to a bug in SDL's SDL_ShowCursor() wzSetCursor(CURSOR_DEFAULT); intRetVal = INT_INTERCEPT; } #ifdef DEBUG // check all flag positions for duplicate delivery points checkFactoryFlags(); #endif //handles callbacks for positioning of DP's process3DBuilding(); //ajl. get the incoming netgame messages and process them. // FIXME Previous comment is deprecated. multiPlayerLoop does some other weird stuff, but not that anymore. if (bMultiPlayer) { multiPlayerLoop(); } for (unsigned i = 0; i < MAX_PLAYERS; i++) { for (DROID *psCurr = apsDroidLists[i]; psCurr; psCurr = psCurr->psNext) { // Don't copy the next pointer - if droids somehow get destroyed in the graphics rendering loop, who cares if we crash. calcDroidIllumination(psCurr); } } /* update animations */ animObj_Update(); } if (!consolePaused()) { /* Process all the console messages */ updateConsoleMessages(); } if (!scrollPaused() && !getWarCamStatus() && dragBox3D.status != DRAG_DRAGGING && intMode != INT_INGAMEOP ) { scroll(); } } else // paused { // Using software cursors (when on) for these menus due to a bug in SDL's SDL_ShowCursor() wzSetCursor(CURSOR_DEFAULT); if(dragBox3D.status != DRAG_DRAGGING) { scroll(); } if(InGameOpUp || isInGamePopupUp) // ingame options menu up, run it! { unsigned widgval = widgRunScreen(psWScreen); intProcessInGameOptions(widgval); if(widgval == INTINGAMEOP_QUIT_CONFIRM || widgval == INTINGAMEOP_POPUP_QUIT) { if(gamePaused()) { kf_TogglePauseMode(); } intRetVal = INT_QUIT; } } if(bLoadSaveUp && runLoadSave(true) && strlen(sRequestResult)) { debug( LOG_NEVER, "Returned %s", sRequestResult ); if(bRequestLoad) { loopMissionState = LMS_LOADGAME; NET_InitPlayers(); // otherwise alliances were not cleared sstrcpy(saveGameName, sRequestResult); } else { char msgbuffer[256]= {'\0'}; if (saveInMissionRes()) { if (saveGame(sRequestResult, GTYPE_SAVE_START)) { sstrcpy(msgbuffer, _("GAME SAVED: ")); sstrcat(msgbuffer, sRequestResult); addConsoleMessage( msgbuffer, LEFT_JUSTIFY, NOTIFY_MESSAGE); } else { ASSERT( false,"Mission Results: saveGame Failed" ); sstrcpy(msgbuffer, _("Could not save game!")); addConsoleMessage( msgbuffer, LEFT_JUSTIFY, NOTIFY_MESSAGE); deleteSaveGame(sRequestResult); } } else if (bMultiPlayer || saveMidMission()) { if (saveGame(sRequestResult, GTYPE_SAVE_MIDMISSION))//mid mission from [esc] menu { sstrcpy(msgbuffer, _("GAME SAVED: ")); sstrcat(msgbuffer, sRequestResult); addConsoleMessage( msgbuffer, LEFT_JUSTIFY, NOTIFY_MESSAGE); } else { ASSERT(!"saveGame(sRequestResult, GTYPE_SAVE_MIDMISSION) failed", "Mid Mission: saveGame Failed" ); sstrcpy(msgbuffer, _("Could not save game!")); addConsoleMessage( msgbuffer, LEFT_JUSTIFY, NOTIFY_MESSAGE); deleteSaveGame(sRequestResult); } } else { ASSERT( false, "Attempt to save game with incorrect load/save mode" ); } } } } /* Check for quit */ bool quitting = false; if (intRetVal == INT_QUIT) { if (!loop_GetVideoStatus()) { //quitting from the game to the front end //so get a new backdrop quitting = true; pie_LoadBackDrop(SCREEN_RANDOMBDROP); } } if (!loop_GetVideoStatus() && !quitting) { if (!gameUpdatePaused()) { if (dragBox3D.status != DRAG_DRAGGING && wallDrag.status != DRAG_DRAGGING) { ProcessRadarInput(); } processInput(); //no key clicks or in Intelligence Screen if (intRetVal == INT_NONE && !InGameOpUp && !isInGamePopupUp) { processMouseClickInput(); } displayWorld(); } /* Display the in game interface */ pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON); pie_SetFogStatus(false); if(bMultiPlayer && bDisplayMultiJoiningStatus) { intDisplayMultiJoiningStatus(bDisplayMultiJoiningStatus); setWidgetsStatus(false); } if(getWidgetsStatus()) { intDisplayWidgets(); } pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); pie_SetFogStatus(true); } pie_GetResetCounts(&loopPieCount, &loopPolyCount, &loopStateChanges); if ((fogStatus & FOG_BACKGROUND) && (loopMissionState == LMS_SAVECONTINUE)) { pie_SetFogStatus(false); } if (!quitting) { /* Check for toggling display mode */ if ((keyDown(KEY_LALT) || keyDown(KEY_RALT)) && keyPressed(KEY_RETURN)) { screenToggleMode(); } } // deal with the mission state switch (loopMissionState) { case LMS_CLEAROBJECTS: missionDestroyObjects(); setScriptPause(true); loopMissionState = LMS_SETUPMISSION; break; case LMS_NORMAL: // default break; case LMS_SETUPMISSION: setScriptPause(false); if (!setUpMission(nextMissionType)) { return GAMECODE_QUITGAME; } break; case LMS_SAVECONTINUE: // just wait for this to be changed when the new mission starts break; case LMS_NEWLEVEL: //nextMissionType = MISSION_NONE; nextMissionType = LDS_NONE; return GAMECODE_NEWLEVEL; break; case LMS_LOADGAME: return GAMECODE_LOADGAME; break; default: ASSERT( false, "unknown loopMissionState" ); break; } if (quitting) { pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK);//gameloopflip /* Check for toggling display mode */ if ((keyDown(KEY_LALT) || keyDown(KEY_RALT)) && keyPressed(KEY_RETURN)) { screenToggleMode(); } return GAMECODE_QUITGAME; } else if (loop_GetVideoStatus()) { audio_StopAll(); return GAMECODE_PLAYVIDEO; } return GAMECODE_CONTINUE; }
// //////////////////////////////////////////////////////////////////////////// // throw a party when you win! bool multiplayerWinSequence(bool firstCall) { static Position pos; Position pos2; static UDWORD last=0; float rotAmount; STRUCTURE *psStruct; if(firstCall) { pos = cameraToHome(selectedPlayer,true); // pan the camera to home if not already doing so last =0; // stop all research CancelAllResearch(selectedPlayer); // stop all manufacture. for(psStruct=apsStructLists[selectedPlayer];psStruct;psStruct = psStruct->psNext) { if (StructIsFactory(psStruct)) { if (((FACTORY *)psStruct->pFunctionality)->psSubject)//check if active { cancelProduction(psStruct, ModeQueue); } } } } // rotate world if (MissionResUp && !getWarCamStatus()) { rotAmount = graphicsTimeAdjustedIncrement(MAP_SPIN_RATE / 12); player.r.y += rotAmount; } if(last > gameTime)last= 0; if((gameTime-last) < 500 ) // only if not done recently. { return true; } last = gameTime; if(rand()%3 == 0) { pos2=pos; pos2.x += (rand() % world_coord(8)) - world_coord(4); pos2.z += (rand() % world_coord(8)) - world_coord(4); if (pos2.x < 0) pos2.x = 128; if ((unsigned)pos2.x > world_coord(mapWidth)) pos2.x = world_coord(mapWidth); if (pos2.z < 0) pos2.z = 128; if ((unsigned)pos2.z > world_coord(mapHeight)) pos2.z = world_coord(mapHeight); addEffect(&pos2,EFFECT_FIREWORK,FIREWORK_TYPE_LAUNCHER,false,NULL,0); // throw up some fire works. } // show the score.. return true; }
// --------------------------------------------------------------------- void selNextSpecifiedBuilding(UDWORD structType) { STRUCTURE *psCurr; STRUCTURE *psResult; STRUCTURE *psOldStruct; STRUCTURE *psFirst; BOOL bLaterInList; /* Firstly, start coughing if the type is invalid */ ASSERT( structType>=REF_HQ && structType<=NUM_DIFF_BUILDINGS, "Invalid structure type in selNextSpecifiedBuilding" ); for(psCurr = apsStructLists[selectedPlayer], psFirst = NULL,psResult = NULL,psOldStruct=NULL,bLaterInList = false; psCurr && !psResult; psCurr = psCurr->psNext) { if( (psCurr->pStructureType->type == structType) && (psCurr->status == SS_BUILT) ) { if(!psFirst) { psFirst = psCurr; } if(psCurr->selected) { bLaterInList = true; psOldStruct=psCurr; } else if(bLaterInList) { psResult = psCurr; } } } if(!psResult) { if(psFirst) { psResult = psFirst; } } if(psResult && !psResult->died) { if(getWarCamStatus()) { camToggleStatus(); } setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), false); if(psOldStruct) { psOldStruct->selected = false; } psResult->selected = true; } else { // Can't find required building addConsoleMessage("Cannot find required building!",LEFT_JUSTIFY,SYSTEM_MESSAGE); } }
// --------------------------------------------------------------------- void selNextUnassignedUnit( void ) { DROID *psCurr; DROID *psResult; DROID *psFirst; BOOL bLaterInList; for(psCurr = apsDroidLists[selectedPlayer],psFirst = NULL,psResult = NULL,bLaterInList = false; psCurr && !psResult; psCurr = psCurr->psNext) { /* Only look at unselected ones */ if(psCurr->group==UBYTE_MAX) { /* Keep a record of first one */ if(!psFirst) { psFirst = psCurr; } if(psCurr == psOldNS) { bLaterInList = true; } /* First one...? */ if(!psOldNS) { psResult = psCurr; } /* Dont choose same one again */ else if(psCurr!=psOldNS && bLaterInList) { psResult = psCurr; } } } /* If we didn't get one - then select first one */ if(!psResult) { if(psFirst) { psResult = psFirst; } } if(psResult && !psResult->died) { selDroidDeselect(selectedPlayer); // psResult->selected = true; SelectDroid(psResult); if(getWarCamStatus()) { camToggleStatus(); // messy - fix this // setViewPos(map_coord(psCentreDroid->pos.x), map_coord(psCentreDroid->pos.y)); processWarCam(); //odd, but necessary camToggleStatus(); // messy - FIXME } else if(!getWarCamStatus()) { // camToggleStatus(); /* Centre display on him if warcam isn't active */ setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), true); } psOldNS = psResult; } else { addConsoleMessage(_("Unable to locate any repair units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); } }
// ffs am // --------------------------------------------------------------------- void selNextSpecifiedUnit(UDWORD unitType) { DROID *psCurr; DROID *psResult; DROID *psFirst; BOOL bLaterInList, bMatch; for(psCurr = apsDroidLists[selectedPlayer],psFirst = NULL,psResult = NULL,bLaterInList = false; psCurr && !psResult; psCurr = psCurr->psNext) { //if( psCurr->droidType == (SDWORD)unitType ) //exceptions - as always... bMatch = false; if (unitType == DROID_CONSTRUCT) { if (psCurr->droidType == DROID_CONSTRUCT || psCurr->droidType == DROID_CYBORG_CONSTRUCT) { bMatch = true; } } else if (unitType == DROID_REPAIR) { if (psCurr->droidType == DROID_REPAIR || psCurr->droidType == DROID_CYBORG_REPAIR) { bMatch = true; } } else if(psCurr->droidType == (SDWORD)unitType) { bMatch = true; } if (bMatch) { /* Always store away the first one we find */ if(!psFirst) { psFirst = psCurr; } if(psCurr == psOldRD) { bLaterInList = true; } /* Nothing previously found... */ if(!psOldRD) { psResult = psCurr; } /* Only select is this isn't the old one and it's further on in list */ else if(psCurr!=psOldRD && bLaterInList) { psResult = psCurr; } } } /* Did we get one? */ if(!psResult) { /* was there at least one - the first one? Resetting */ if(psFirst) { psResult = psFirst; } } if(psResult && !psResult->died) { selDroidDeselect(selectedPlayer); // psResult->selected = true; SelectDroid(psResult); if(getWarCamStatus()) { camToggleStatus(); // messy - fix this // setViewPos(map_coord(psCentreDroid->pos.x), map_coord(psCentreDroid->pos.y)); processWarCam(); //odd, but necessary camToggleStatus(); // messy - FIXME } else if(!getWarCamStatus()) { // camToggleStatus(); /* Centre display on him if warcam isn't active */ setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), true); } psOldRD = psResult; } else { switch(unitType) { case DROID_REPAIR: addConsoleMessage(_("Unable to locate any repair units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; case DROID_CONSTRUCT: addConsoleMessage(_("Unable to locate any Trucks!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; case DROID_SENSOR: addConsoleMessage(_("Unable to locate any Sensor Units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; case DROID_COMMAND: addConsoleMessage(_("Unable to locate any Commanders!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; } } }
/* Updates the camera position/angle along with the object movement */ BOOL processWarCam( void ) { BASE_OBJECT *foundTarget; BOOL Status = true; /* Get out if the camera isn't active */ if(trackingCamera.status == CAM_INACTIVE) { return(true); } /* Ensure that the camera only ever flips state within this routine! */ switch(trackingCamera.status) { case CAM_REQUEST: /* See if we can find the target to follow */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { /* We've got one, so store away info */ camAllignWithTarget(foundTarget); /* We're now into tracking status */ trackingCamera.status = CAM_TRACKING; /* Inform via console */ if(foundTarget->type == OBJ_DROID) { if(getWarCamStatus()) { CONPRINTF(ConsoleString,(ConsoleString,"WZ/CAM - %s",droidGetName((DROID*)foundTarget))); } } else { // CONPRINTF(ConsoleString,(ConsoleString,"DROID-CAM V0.1 Enabled - Now tracking new location")); } } else { /* We've requested a track with no droid selected */ // addConsoleMessage("Droid-CAM V0.1 ERROR - No targets(s) selected",DEFAULT_JUSTIFY,SYSTEM_MESSAGE); trackingCamera.status = CAM_INACTIVE; } break; case CAM_TRACKING: /* Track the droid unless routine comes back false */ if(!camTrackCamera()) { /* Camera track came back false, either because droid died or is no longer selected, so reset to old values */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { trackingCamera.status = CAM_REQUEST; } else { trackingCamera.status = CAM_RESET; } } processLeaderSelection(); break; case CAM_RESET: /* Reset camera to pre-droid tracking status */ if( (trackingCamera.target==NULL) ||(trackingCamera.target->type!=OBJ_TARGET)) { camSwitchOff(); } /* Switch to inactive mode */ trackingCamera.status = CAM_INACTIVE; // addConsoleMessage("Droid-CAM V0.1 Disabled",DEFAULT_JUSTIFY,SYSTEM_MESSAGE); Status = false; break; default: debug( LOG_FATAL, "Weirdy status for tracking Camera" ); abort(); break; } return Status; }
/* Attempts to find a new location for the tracking camera to go to, or a new object (target) for it to track. */ static void findSomethingInteresting(void) { enum { SEEK_DROID, SEEK_TARGET, SEEK_LAST, SEEK_OVERRIDE, } type; UDWORD player,otherPlayer; DROID *psDroid; UDWORD numWith; BOOL bSeekOnlyLocations; UDWORD i; BOOL bHaveHuman = false; PROPULSION_STATS *psPropStats; //--- //---- /* There may be droids, so don't rule it out */ bSeekOnlyLocations = false; /* Check all the droid lists, looking for empty ones */ for(i = 0,numWith = 0; i<MAX_PLAYERS; i++) { /* Keep a count of how many are empty */ if(apsDroidLists[i]) { /* We got one */ numWith++; if(i<MAX_PLAYERS-2) { bHaveHuman = true; } } } /* If they were all empty, then record this fact and only seek locations */ /* We need two sides for this to work! */ if(numWith<2 || !bHaveHuman) { bSeekOnlyLocations = true; } /* Keep going until we get one */ // while(!gotNewTarget) // { /* Are we only to seek locations? */ if(bSeekOnlyLocations) { /* Then force the switch outcome - hacky I know, but same as if else in code */ type = SEEK_OVERRIDE; } else { /* We're off hunting droids */ type = rand()%2 == 0? SEEK_DROID : SEEK_TARGET; } /* Check which */ switch (type) { /* Go after a droid, or a droid location */ case SEEK_DROID: case SEEK_TARGET: /* Choose a player at random */ player = rand()%MAX_PLAYERS; /* Have they got any droids? */ while(apsDroidLists[player]==NULL) { /* Nope, so choose another one until we get one with droids */ player = rand()%MAX_PLAYERS; } /* Choose a player at random */ otherPlayer = rand()%MAX_PLAYERS; /* Have they got any structures? Make sure it's not their own we're checking! */ while(apsStructLists[otherPlayer]==NULL || otherPlayer==player) { /* Nope, so choose another one until we get one with droids */ otherPlayer = rand()%MAX_PLAYERS; } /* If there was a droid last time, deselect it */ if(psLastDroid && !psLastDroid->died) { psLastDroid->selected = false; } /* Jump to droid and track */ psDroid = getDroidForDemo(player); /* Only do if we've got a droid and an enemy building to attack */ if(psDroid && apsStructLists[otherPlayer]) { psDroid->selected = true; selectedPlayer = player; realSelectedPlayer = selectedPlayer; psLastDroid = psDroid; // if(orderState(psDroid,DORDER_ATTACK) == false) // { orderDroidLoc(psDroid,DORDER_MOVE, apsStructLists[otherPlayer]->pos.x, apsStructLists[otherPlayer]->pos.y, ModeQueue); // } if(!getWarCamStatus()) { /* Start the tracking */ camToggleStatus(); } else { camToggleStatus(); processWarCam(); camToggleStatus(); } psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat; if ( psPropStats->propulsionType == PROPULSION_TYPE_LIFT ) { /* Track vtols for longer */ demoCamInterval = 3*DEFAULT_DEMO_INTERVAL; } else { demoCamInterval = DEFAULT_DEMO_INTERVAL; } } break; /* Go to a new location cos there's no droids left in the world....ahhhhhhh*/ case SEEK_OVERRIDE: requestRadarTrack((16 + rand()%(mapWidth-31))*TILE_UNITS, (16 + rand()%(mapHeight-31)) * TILE_UNITS ); break; default: break; } // } }