/** * @brief Prepare things for baseattack battle * @param[in] mission Mission to prepare battle for */ static void CP_BaseAttackPrepareBattle (mission_t* mission) { if (!mission) return; base_t* base = mission->data.base; GEO_SelectMission(mission); mission->active = true; cgi->Com_DPrintf(DEBUG_CLIENT, "Base attack: %s at %.0f:%.0f\n", mission->id, mission->pos[0], mission->pos[1]); /* Fill the fake aircraft */ OBJZERO(baseAttackFakeAircraft); baseAttackFakeAircraft.homebase = base; /* needed for transfer of alien corpses */ VectorCopy(base->pos, baseAttackFakeAircraft.pos); /* needed to spawn soldiers on map */ baseAttackFakeAircraft.maxTeamSize = std::min(MAX_ACTIVETEAM, E_CountByType(EMPL_SOLDIER) + E_CountByType(EMPL_ROBOT)); baseAttackFakeAircraft.mission = mission; base->aircraftCurrent = &baseAttackFakeAircraft; GEO_SetMissionAircraft(&baseAttackFakeAircraft); /** @todo remove me - this is not needed because we are using the base->aircraftCurrent * pointer for resolving the aircraft - only Autocombat needs this */ GEO_SetInterceptorAircraft(&baseAttackFakeAircraft); /* needed for updating soldier stats sa CHAR_UpdateStats */ B_SetCurrentSelectedBase(base); /* needed for equipment menu */ static char popupText[1024]; Com_sprintf(popupText, sizeof(popupText), _("Base '%s' is under attack! What to do?"), base->name); cgi->UI_RegisterText(TEXT_POPUP, popupText); CP_GameTimeStop(); cgi->UI_PushWindow("popup_baseattack"); }
/** * @brief Base attack mission ends: UFO leave earth. * @note Base attack mission -- Stage 3 * @note UFO attacking this base will be redirected when notify function will be called, don't set new destination here. */ void CP_BaseAttackMissionDestroyBase (mission_t* mission) { base_t* base = mission->data.base; assert(base); /* Base attack is over, alien won */ Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("Your base: %s has been destroyed! All employees killed and all equipment destroyed."), base->name); MS_AddNewMessage(_("Notice"), cp_messageBuffer); cgi->LIST_Delete(&baseAttackFakeAircraft.acTeam); B_Destroy(base); CP_GameTimeStop(); /* we really don't want to use the fake aircraft anywhere */ GEO_SetMissionAircraft(nullptr); /* HACK This hack is only needed until base will be really destroyed * we must recalculate items in storage because of the items we collected on battlefield */ CAP_UpdateStorageCap(base); base->aircraftCurrent = nullptr; base->baseStatus = BASE_WORKING; }
/** * @brief Base attack mission is over and is a failure (from an alien point of view): change interest values. */ void CP_BaseAttackMissionIsFailure (mission_t* mission) { base_t* base = mission->data.base; if (base) { base->baseStatus = BASE_WORKING; /* clean up the fakeAircraft */ cgi->LIST_Delete(&baseAttackFakeAircraft.acTeam); base->aircraftCurrent = AIR_GetFirstFromBase(base); baseAttackFakeAircraft.mission = nullptr; } GEO_SetMissionAircraft(nullptr); INT_ChangeIndividualInterest(0.05f, INTERESTCATEGORY_BUILDING); INT_ChangeIndividualInterest(0.1f, INTERESTCATEGORY_BASE_ATTACK); /* reset current selected mission */ GEO_NotifyMissionRemoved(mission); CP_MissionRemove(mission); }