Esempio n. 1
0
/**
 * @brief Kill all aliens in given base.
 * @param[in] base The base in which you want to kill all aliens
 * @sa AC_KillAll_f
 */
void AC_KillAll (base_t *base)
{
	int i;
	qboolean aliens = qfalse;

	assert(base);

	/* Are there aliens here at all? */
	for (i = 0; i < ccs.numAliensTD; i++) {
		if (base->alienscont[i].amountAlive > 0) {
			aliens = qtrue;
			break;
		}
	}

	/* No aliens, return. */
	if (!aliens)
		return;

	AL_RemoveAliens(base, NULL, 0, AL_KILL);
}
/**
 * @brief Kill single alien of a given type.
 */
static void AC_KillOne_f (void)
{
	int num;
	base_t *base = B_GetCurrentSelectedBase();

	/* Can be called from everywhere. */
	if (!base)
		return;

	if (Cmd_Argc() < 2) {
		Com_Printf("Usage: %s <alien list index>\n", Cmd_Argv(0));
		return;
	}

	/* which item from the list? */
	num = atoi(Cmd_Argv(1));
	if (num >= numAliensOnList || num < 0) {
		Com_DPrintf(DEBUG_CLIENT, "AC_KillOne_f: max exceeded %i/%i\n", num, numAliensOnList);
		return;
	}

	if (B_GetBuildingStatus(base, B_ALIEN_CONTAINMENT)) {
		aliensCont_t *containment = base->alienscont;
		int i, step;
		for (i = 0, step = 0; i < ccs.numAliensTD; i++) {
			if (!containment[i].amountAlive && !containment[i].amountDead)
				continue;
			if (step == num) {
				num = i;
				break;
			}
			step++;
		}
		AL_RemoveAliens(base, containment[num].teamDef, 1, AL_KILLONE);
		/* Reinit menu to display proper values. */
		AC_UpdateMenu(base);
	}
}