/** * @brief Prepares Alien Containment - names, states, and zeroed amount. * @param[in] base Pointer to the base with AC. * @sa B_BuildBase * @sa AL_AddAliens */ void AL_FillInContainment (base_t *base) { int i, counter = 0; aliensCont_t *containment; assert(base); containment = base->alienscont; for (i = 0; i < csi.numTeamDefs; i++) { const teamDef_t *td = &csi.teamDef[i]; if (!CHRSH_IsTeamDefAlien(td)) continue; if (counter >= MAX_ALIENCONT_CAP) Com_Error(ERR_DROP, "Overflow in AL_FillInContainment"); containment->teamDef = td; /* Link to global race index. */ containment->amountAlive = 0; containment->amountDead = 0; /* for sanity checking */ containment->tech = ccs.teamDefTechs[td->idx]; if (!containment->tech) Com_Error(ERR_DROP, "Could not find a valid tech for '%s'\n", td->name); Com_DPrintf(DEBUG_CLIENT, "AL_FillInContainment: type: %s tech-index: %i\n", td->name, containment->tech->idx); containment++; counter++; } base->capacities[CAP_ALIENS].cur = 0; }
/** * @brief Read the data for campaigns * @sa SAV_GameLoad * @sa CP_ResetCampaignData */ void CP_ParseCampaignData (void) { const char *type, *name, *text; int i; campaign_t *campaign; /* pre-stage parsing */ FS_BuildFileList("ufos/*.ufo"); FS_NextScriptHeader(NULL, NULL, NULL); text = NULL; while ((type = FS_NextScriptHeader("ufos/*.ufo", &name, &text)) != NULL) CP_ParseScriptFirst(type, name, &text); /* fill in IDXs for required research techs */ RS_RequiredLinksAssign(); /* stage two parsing */ FS_NextScriptHeader(NULL, NULL, NULL); text = NULL; Com_DPrintf(DEBUG_CLIENT, "Second stage parsing started...\n"); while ((type = FS_NextScriptHeader("ufos/*.ufo", &name, &text)) != NULL) CP_ParseScriptSecond(type, name, &text); INS_LinkTechnologies(); for (i = 0; i < cgi->csi->numTeamDefs; i++) { const teamDef_t *teamDef = &cgi->csi->teamDef[i]; if (!CHRSH_IsTeamDefAlien(teamDef)) continue; ccs.teamDefTechs[teamDef->idx] = RS_GetTechByID(teamDef->tech); if (ccs.teamDefTechs[teamDef->idx] == NULL) cgi->Com_Error(ERR_DROP, "Could not find a tech for teamdef %s", teamDef->id); } for (i = 0, campaign = ccs.campaigns; i < ccs.numCampaigns; i++, campaign++) { /* find the relevant markets */ campaign->marketDef = INV_GetEquipmentDefinitionByID(campaign->market); campaign->asymptoticMarketDef = INV_GetEquipmentDefinitionByID(campaign->asymptoticMarket); } Com_Printf("Campaign data loaded - size " UFO_SIZE_T " bytes\n", sizeof(ccs)); Com_Printf("...techs: %i\n", ccs.numTechnologies); Com_Printf("...buildings: %i\n", ccs.numBuildingTemplates); Com_Printf("...ranks: %i\n", ccs.numRanks); Com_Printf("...nations: %i\n", ccs.numNations); Com_Printf("...cities: %i\n", ccs.numCities); Com_Printf("\n"); }
/** * @brief Returns teamdef for global alien idx. * @param[in] alienTeamDefIdx Alien index * @sa AL_GetAlienIDX */ const teamDef_t* AL_GetAlienTeamDef (int alienTeamDefIdx) { int i, counter = 0; for (i = 0; i < csi.numTeamDefs; i++) { const teamDef_t *td = &csi.teamDef[i]; if (CHRSH_IsTeamDefAlien(td)) { if (counter == alienTeamDefIdx) return td; counter++; } } Com_Printf("AL_GetAlienGlobalIDX: Alien with AC index %i not found!\n", alienTeamDefIdx); return NULL; }
static qboolean GAME_IsArmourUseableForTeam (const objDef_t *od, const teamDef_t *teamDef) { if (teamDef != NULL && teamDef->armour && INV_IsArmour(od)) { if (CHRSH_IsTeamDefAlien(teamDef)) return od->useable == TEAM_ALIEN; else if (teamDef->race == RACE_PHALANX_HUMAN) return od->useable == TEAM_PHALANX; else if (teamDef->race == RACE_CIVILIAN) return od->useable == TEAM_CIVILIAN; else return qfalse; } return qtrue; }
/** * @brief Get index of alien. * @param[in] alienType Pointer to alien type. * @return Index of alien in alien containment (so less than @c ccs.numAliensTD) * @note It does NOT return the global team index from @c csi.teamDef array. * That would be @c alienType->idx * @sa RS_AssignTechLinks * @sa AL_GetAlienGlobalIDX */ static int AL_GetAlienIDX (const teamDef_t *alienType) { int i, index; index = 0; for (i = 0; i < csi.numTeamDefs; i++) { const teamDef_t *td = &csi.teamDef[i]; if (alienType == td) return index; if (CHRSH_IsTeamDefAlien(td)) index++; } Com_Printf("AL_GetAlienIDX: Alien \"%s\" not found!\n", alienType->id); return -1; }
bool CHRSH_IsArmourUseableForTeam (const objDef_t *od, const teamDef_t *teamDef) { assert(teamDef); assert(INV_IsArmour(od)); if (!teamDef->armour) return false; if (CHRSH_IsTeamDefAlien(teamDef)) return od->useable == TEAM_ALIEN; else if (teamDef->race == RACE_PHALANX_HUMAN) return od->useable == TEAM_PHALANX; else if (teamDef->race == RACE_CIVILIAN) return od->useable == TEAM_CIVILIAN; return false; }
/** * @brief Heals a target and treats wounds. * @param[in,out] target Pointer to the actor who we want to treat. * @param[in] fd Pointer to the firedef used to heal the target. * @param[in] heal The value of the damage to heal. * @param[in] healerTeam The index of the team of the healer. */ void G_TreatActor (Actor* target, const fireDef_t* const fd, const int heal, const int healerTeam) { assert(target->chr.teamDef); /* Treat wounds */ if (fd->dmgweight == gi.csi->damNormal) { int mostWounded = 0; woundInfo_t* wounds = &target->chr.wounds; /* Find the worst not treated wound */ for (int bodyPart = 0; bodyPart < target->chr.teamDef->bodyTemplate->numBodyParts(); ++bodyPart) if (wounds->woundLevel[bodyPart] > wounds->woundLevel[mostWounded]) mostWounded = bodyPart; if (wounds->woundLevel[mostWounded] > 0) { const int woundsHealed = std::min(static_cast<int>(abs(heal) / target->chr.teamDef->bodyTemplate->bleedingFactor(mostWounded)), wounds->woundLevel[mostWounded]); G_TakeDamage(target, heal); wounds->woundLevel[mostWounded] -= woundsHealed; wounds->treatmentLevel[mostWounded] += woundsHealed; /* Update stats here to get info on how many HP the target received. */ if (target->chr.scoreMission) target->chr.scoreMission->heal += abs(heal); } } /* Treat stunned actors */ if (fd->dmgweight == gi.csi->damStunElectro && target->isStunned()) { if (CHRSH_IsTeamDefAlien(target->chr.teamDef) && target->getTeam() != healerTeam) /** @todo According to specs it should only be possible to use the medikit to keep an alien sedated when * 'live alien' is researched, is it possible to find if a tech is researched here? */ target->setStun(std::min(255, target->getStun() - heal)); else target->setStun(std::max(0, target->getStun() + heal)); G_ActorCheckRevitalise(target); } /* Increase morale */ if (fd->dmgweight == gi.csi->damShock) target->setMorale(std::min(GET_MORALE(target->chr.score.skills[ABILITY_MIND]), target->morale - heal)); G_SendWoundStats(target); }
/** * @brief Register some data in the shared client/server structs to ensure that e.g. every known * alien race is used in a skirmish game */ static void GAME_SK_SetMissionParameters (const mapDef_t* md) { cgi->Cvar_SetValue("ai_numcivilians", 8); if (md->civTeam != nullptr) cgi->Cvar_Set("ai_civilianteam", "%s", md->civTeam); else cgi->Cvar_Set("ai_civilianteam", "europe"); cgi->Cvar_Set("sv_hurtaliens", "0"); /* now store the alien teams in the shared csi struct to let the game dll * have access to this data, too */ cgi->csi->numAlienTeams = 0; for (int i = 0; i < cgi->csi->numTeamDefs; i++) { const teamDef_t* td = &cgi->csi->teamDef[i]; if (CHRSH_IsTeamDefAlien(td)) cgi->csi->alienTeams[cgi->csi->numAlienTeams++] = td; if (cgi->csi->numAlienTeams >= MAX_TEAMS_PER_MISSION) break; } }
/** * @brief Register some data in the shared client/server structs to ensure that e.g. every known * alien race is used in a skirmish game */ static void GAME_SK_SetMissionParameters (const mapDef_t *md) { int i; Cvar_SetValue("ai_numcivilians", 8); Cvar_Set("ai_civilian", "europe"); if (md->hurtAliens) Cvar_Set("sv_hurtaliens", "1"); else Cvar_Set("sv_hurtaliens", "0"); /* now store the alien teams in the shared csi struct to let the game dll * have access to this data, too */ csi.numAlienTeams = 0; for (i = 0; i < csi.numTeamDefs; i++) { const teamDef_t* td = &csi.teamDef[i]; if (CHRSH_IsTeamDefAlien(td)) csi.alienTeams[csi.numAlienTeams++] = td; } }
/** * @brief Returns if storing a specific life form is supported by the containment * @param[in] team Pointer to the alien Team Definition */ bool AlienContainment::isLifeSupported(const teamDef_t* team) { /* No team - not supported */ if (!team) return false; /* humans supported */ if (!CHRSH_IsTeamDefAlien(team)) return true; /* Robots are supported */ if (CHRSH_IsTeamDefRobot(team)) return true; /* Organic aliens need breathing apparatus known */ /** @todo find a way that doesn't need a tech ID hardcoded */ const technology_t* tech = RS_GetTechByID(BREATHINGAPPARATUS_TECH); if (!tech) return false; return RS_IsResearched_ptr(tech); }