コード例 #1
0
/**
 * @sa G_ClientConnect
 */
void G_ClientDisconnect (player_t * player)
{
#if 0
	edict_t *ent = NULL;
#endif

	/* only if the player already sent his began */
	if (player->began) {
		level.numplayers--;
		gi.ConfigString(CS_PLAYERCOUNT, "%i", level.numplayers);

		if (level.activeTeam == player->pers.team)
			G_ClientEndRound(player);

		/* if no more players are connected - stop the server */
		G_MatchEndCheck();
	}

#if 0
	/* now let's remove all the edicts that belongs to this player */
	while ((ent = G_EdictsGetNextLivingActor(ent))) {
		if (ent->pnum == player->num)
			G_ActorDie(ent, STATE_DEAD, NULL);
	}
	G_MatchEndCheck();
#endif

	player->began = false;
	player->roundDone = false;
	player->isReady = false;

	gi.BroadcastPrintf(PRINT_CONSOLE, "%s disconnected.\n", player->pers.netname);
}
コード例 #2
0
/**
 * @brief Stun all members of a giben team.
 */
static void G_StunTeam_f (void)
{
    /* default is to kill all teams */
    int teamToKill = -1;
    edict_t *ent = NULL;

    /* with a parameter we will be able to kill a specific team */
    if (gi.Cmd_Argc() == 2)
        teamToKill = atoi(gi.Cmd_Argv(1));

    if (teamToKill >= 0) {
        while ((ent = G_EdictsGetNextLivingActorOfTeam(ent, teamToKill))) {
            /* stun */
            G_ActorDieOrStun(ent, NULL);

            if (teamToKill == TEAM_ALIEN)
                level.num_stuns[TEAM_PHALANX][TEAM_ALIEN]++;
            else
                level.num_stuns[TEAM_ALIEN][teamToKill]++;
        }
    }

    /* check for win conditions */
    G_MatchEndCheck();
}
コード例 #3
0
/**
 * @brief This function does not add statistical values. Because there is no attacker.
 * The same counts for morale states - they are not affected.
 * @note: This is a debug function to let a whole team die
 */
static void G_KillTeam_f (void)
{
    /* default is to kill all teams */
    int teamToKill = -1;
    edict_t *ent = NULL;
    int amount = -1;

    /* with a parameter we will be able to kill a specific team */
    if (gi.Cmd_Argc() >= 2) {
        teamToKill = atoi(gi.Cmd_Argv(1));
        if (gi.Cmd_Argc() == 3)
            amount = atoi(gi.Cmd_Argv(2));
    }

    Com_DPrintf(DEBUG_GAME, "G_KillTeam: kill team %i\n", teamToKill);

    if (teamToKill >= 0) {
        while ((ent = G_EdictsGetNextLivingActorOfTeam(ent, teamToKill))) {
            if (amount == 0)
                break;
            /* die */
            ent->HP = 0;
            G_ActorDieOrStun(ent, NULL);

            if (teamToKill == TEAM_ALIEN)
                level.num_kills[TEAM_PHALANX][TEAM_ALIEN]++;
            else
                level.num_kills[TEAM_ALIEN][teamToKill]++;
            amount--;
        }
    }

    /* check for win conditions */
    G_MatchEndCheck();
}
コード例 #4
0
ファイル: g_health.cpp プロジェクト: yason/ufoai
/**
 * @brief Deal damage to each wounded team member.
 * @param[in] team The index of the team to deal damage to.
 */
void G_BleedWounds (const int team)
{
	Actor* actor = nullptr;

	while ((actor = G_EdictsGetNextLivingActorOfTeam(actor, team))) {
		if (CHRSH_IsTeamDefRobot(actor->chr.teamDef))
			continue;
		const teamDef_t* const teamDef = actor->chr.teamDef;
		const woundInfo_t& wounds = actor->chr.wounds;
		int damage = 0;
		for (int bodyPart = 0; bodyPart < teamDef->bodyTemplate->numBodyParts(); ++bodyPart)
			if (wounds.woundLevel[bodyPart] > actor->chr.maxHP * teamDef->bodyTemplate->woundThreshold(bodyPart))
				damage += wounds.woundLevel[bodyPart] * teamDef->bodyTemplate->bleedingFactor(bodyPart);
		if (damage > 0) {
			G_PrintStats("%s is bleeding (damage: %i)", actor->chr.name, damage);
			G_TakeDamage(actor, damage);
			G_CheckDeathOrKnockout(actor, nullptr, nullptr, damage);
		}
	}
	/* Maybe the last team member bled to death */
	G_MatchEndCheck();
}