예제 #1
0
/**
 * @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)
{
	if (!aircraft)
		return;
	if (!aircraft->alienCargo)
		return;
	if (!aircraft->homebase) {
		Com_Printf("AL_AddAliens: Aircraft %s (idx: %d) has no base, alienCargo destroyed\n", aircraft->name, aircraft->idx);
		delete aircraft->alienCargo;
		aircraft->alienCargo = nullptr;
		return;
	}

	if (aircraft->homebase->alienContainment == nullptr)
		aircraft->homebase->alienContainment = new AlienContainment(CAP_Get(aircraft->homebase, CAP_ALIENS), nullptr);

	AlienContainment* cont = aircraft->homebase->alienContainment;
	if (!cont)
		return;

	bool messageSent = false;
	linkedList_t* cargo = aircraft->alienCargo->list();
	LIST_Foreach(cargo, alienCargo_t, item) {
		const bool lifeSupported = AlienContainment::isLifeSupported(item->teamDef);

		if (!lifeSupported) {
			cont->add(item->teamDef, 0, item->alive + item->dead);
			aircraft->alienCargo->add(item->teamDef, -item->alive, -item->dead);

			ccs.campaignStats.killedAliens += item->dead + item->alive;
			if (item->alive > 0) {
				CP_TriggerEvent(CAPTURED_ALIENS_DIED, nullptr);
				/* only once */
				if (!messageSent) {
					MS_AddNewMessage(_("Notice"), _("You can't hold live aliens yet. Aliens died."), MSG_DEATH);
					messageSent = true;
				}
			}
		} else {
			cont->add(item->teamDef, item->alive, item->dead);
			aircraft->alienCargo->add(item->teamDef, -item->alive, -item->dead);

			ccs.campaignStats.killedAliens += item->dead;
			ccs.campaignStats.capturedAliens += item->alive;
			if (item->alive > 0) {
				CP_TriggerEvent(CAPTURED_ALIENS, nullptr);
				if (!messageSent) {
					MS_AddNewMessage(_("Notice"), _("You've captured new aliens."));
					messageSent = true;
				}
			}
		}
	}
	cgi->LIST_Delete(&cargo);
}
예제 #2
0
/**
 * @brief Perform actions when a new UFO is detected.
 * @param[in] ufocraft Pointer to the UFO that has just been detected.
 */
void UFO_DetectNewUFO (aircraft_t* ufocraft)
{
	if (ufocraft->detected)
		return;

	/* Make this UFO detected */
	if (!ufocraft->detectionIdx) {
		ufocraft->detectionIdx = ++ccs.campaignStats.ufosDetected;
	}
	ufocraft->detected = true;
	ufocraft->lastSpotted = ccs.date;

	/* If this is the first UFO on geoscape, activate radar */
	if (!GEO_IsRadarOverlayActivated())
		GEO_SetOverlay("radar", 1);

	CP_TriggerEvent(UFO_DETECTION, cgi->Com_UFOTypeToShortName(ufocraft->ufotype));

	GEO_UpdateGeoscapeDock();
}