/** * @brief Run actions on finishing disassembling of a ufo * @param base The base to produce in * @param prod The production that is running */ static void PR_FinishDisassembly (base_t* base, production_t* prod) { storedUFO_t* ufo = prod->data.data.ufo; assert(ufo); for (int i = 0; i < ufo->comp->numItemtypes; i++) { const objDef_t* compOd = ufo->comp->items[i]; const int amount = (ufo->condition < 1 && ufo->comp->itemAmount2[i] != COMP_ITEMCOUNT_SCALED) ? ufo->comp->itemAmount2[i] : round(ufo->comp->itemAmount[i] * ufo->condition); assert(compOd); if (amount <= 0) continue; if (Q_streq(compOd->id, ANTIMATTER_ITEM_ID)) { B_AddAntimatter(base, amount); } else { technology_t* tech = RS_GetTechForItem(compOd); B_AddToStorage(base, compOd, amount); RS_MarkCollected(tech); } } Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("The disassembling of %s at %s has finished."), UFO_TypeToName(ufo->ufoTemplate->getUfoType()), base->name); MSO_CheckAddNewMessage(NT_PRODUCTION_FINISHED, _("Production finished"), cp_messageBuffer, MSG_PRODUCTION, ufo->ufoTemplate->tech); /* Removing UFO will remove the production too */ US_RemoveStoredUFO(ufo); }
/** * @brief For things like craft_ufo_scout that are no real items this function will * increase the collected counter by one * @note Mission trigger function * @sa CP_MissionTriggerFunctions * @sa CP_ExecuteMissionTrigger */ static void CP_AddItemAsCollected_f (void) { int baseID; const char* id; base_t *base; const objDef_t *item; if (Cmd_Argc() < 2) { Com_Printf("Usage: %s <item>\n", Cmd_Argv(0)); return; } id = Cmd_Argv(1); baseID = atoi(Cmd_Argv(2)); base = B_GetBaseByIDX(baseID); if (base == NULL) return; /* i = item index */ item = INVSH_GetItemByIDSilent(id); if (item) { technology_t *tech = RS_GetTechForItem(item); base->storage.numItems[item->idx]++; Com_DPrintf(DEBUG_CLIENT, "add item: '%s'\n", item->id); RS_MarkCollected(tech); } }
/** * @brief Add aliens to the containment by teamDef * @param[in] team Pointer to the alien Team Definition * @param[in] alive Number of alive aliens * @param[in] dead Number of dead aliens */ bool AlienContainment::add(const teamDef_t* team, int alive, int dead) { if (!team) return false; if (!isLifeSupported(team)) { dead += alive; alive = 0; } if (AlienCargo::add(team, alive, dead)) { if (this->aliveCapacity) this->aliveCapacity->cur += alive * getCapacityNeedForAlien(team, false); if (this->deadCapacity) this->deadCapacity->cur += dead * getCapacityNeedForAlien(team, true); if (this->getAlive(team) > 0 || this->getDead(team) > 0) { technology_t* tech = RS_GetTechForTeam(team); RS_MarkCollected(tech); } return true; } return false; }
/** * @brief Puts alien cargo into Alien Containment. * @param[in] aircraft Aircraft transporting cargo to homebase. * @sa B_AircraftReturnedToHomeBase * @sa AL_FillInContainment * @note an event mail about missing breathing tech will be triggered if necessary. */ void AL_AddAliens (aircraft_t *aircraft) { base_t *toBase; const aliensTmp_t *cargo; int alienCargoTypes; int i; int j; qboolean limit = qfalse; qboolean messageAlreadySet = qfalse; technology_t *breathingTech; qboolean alienBreathing = qfalse; const objDef_t *alienBreathingObjDef; assert(aircraft); toBase = aircraft->homebase; assert(toBase); cargo = AL_GetAircraftAlienCargo(aircraft); alienCargoTypes = AL_GetAircraftAlienCargoTypes(aircraft); if (alienCargoTypes == 0) return; if (!B_GetBuildingStatus(toBase, B_ALIEN_CONTAINMENT)) { MS_AddNewMessage(_("Notice"), _("You cannot process aliens yet. Alien Containment not ready in this base."), qfalse, MSG_STANDARD, NULL); return; } breathingTech = RS_GetTechByID(BREATHINGAPPARATUS_TECH); if (!breathingTech) Com_Error(ERR_DROP, "AL_AddAliens: Could not get breathing apparatus tech definition"); alienBreathing = RS_IsResearched_ptr(breathingTech); alienBreathingObjDef = INVSH_GetItemByID(breathingTech->provides); if (!alienBreathingObjDef) Com_Error(ERR_DROP, "AL_AddAliens: Could not get breathing apparatus item definition"); for (i = 0; i < alienCargoTypes; i++) { for (j = 0; j < ccs.numAliensTD; j++) { assert(toBase->alienscont[j].teamDef); assert(cargo[i].teamDef); if (toBase->alienscont[j].teamDef == cargo[i].teamDef) { toBase->alienscont[j].amountDead += cargo[i].amountDead; /* Add breathing apparatuses to aircraft cargo so that they are processed with other collected items */ AII_CollectItem(aircraft, alienBreathingObjDef, cargo[i].amountDead); if (cargo[i].amountAlive <= 0) continue; if (!alienBreathing && !CHRSH_IsTeamDefRobot(cargo[i].teamDef)) { /* We can not store living (i.e. no robots or dead bodies) aliens without rs_alien_breathing tech */ toBase->alienscont[j].amountDead += cargo[i].amountAlive; /* Add breathing apparatuses as well */ AII_CollectItem(aircraft, alienBreathingObjDef, cargo[i].amountAlive); /* only once */ if (!messageAlreadySet) { MS_AddNewMessage(_("Notice"), _("You can't hold live aliens yet. Aliens died."), qfalse, MSG_DEATH, NULL); messageAlreadySet = qtrue; } if (!ccs.breathingMailSent) { Cmd_ExecuteString("addeventmail alienbreathing"); ccs.breathingMailSent = qtrue; } } else { int k; for (k = 0; k < cargo[i].amountAlive; k++) { /* Check base capacity. */ if (AL_CheckAliveFreeSpace(toBase, NULL, 1)) { AL_ChangeAliveAlienNumber(toBase, &(toBase->alienscont[j]), 1); } else { /* Every exceeding alien is killed * Display a message only when first one is killed */ if (!limit) { toBase->capacities[CAP_ALIENS].cur = toBase->capacities[CAP_ALIENS].max; MS_AddNewMessage(_("Notice"), _("You don't have enough space in Alien Containment. Some aliens got killed."), qfalse, MSG_STANDARD, NULL); limit = qtrue; } /* Just kill aliens which don't fit the limit. */ toBase->alienscont[j].amountDead++; AII_CollectItem(aircraft, alienBreathingObjDef, 1); } } /* only once */ if (!messageAlreadySet) { MS_AddNewMessage(_("Notice"), _("You've captured new aliens."), qfalse, MSG_STANDARD, NULL); messageAlreadySet = qtrue; } } break; } } } for (i = 0; i < ccs.numAliensTD; i++) { aliensCont_t *ac = &toBase->alienscont[i]; technology_t *tech = ac->tech; #ifdef DEBUG if (!tech) Sys_Error("AL_AddAliens: Failed to initialize the tech for '%s'\n", ac->teamDef->name); #endif /* we need this to let RS_Collected_ return true */ if (ac->amountAlive + ac->amountDead > 0) RS_MarkCollected(tech); #ifdef DEBUG /* print all of them */ if (ac->amountAlive > 0) Com_DPrintf(DEBUG_CLIENT, "AL_AddAliens alive: %s amount: %i\n", ac->teamDef->name, ac->amountAlive); if (ac->amountDead > 0) Com_DPrintf(DEBUG_CLIENT, "AL_AddAliens bodies: %s amount: %i\n", ac->teamDef->name, ac->amountDead); #endif } /* we shouldn't have any more aliens on the aircraft after this */ AL_SetAircraftAlienCargoTypes(aircraft, 0); }