Exemplo n.º 1
0
void boss_spawn_tank (edict_t *ent)
{
	char	userinfo[MAX_INFO_STRING];
	//edict_t	*tank;

	//gi.dprintf("boss_spawn_tank()\n");

	if (G_EntExists(ent->owner) && (ent->owner->mtype == BOSS_TANK))
	{
		G_PrintGreenText(va("%s got bored and left the game.", ent->client->pers.netname));

		BecomeTE(ent->owner);
		ent->svflags &= ~SVF_NOCLIENT;
		ent->viewheight = 22;
		ent->movetype = MOVETYPE_WALK;
		ent->solid = SOLID_BBOX;
		ent->takedamage = DAMAGE_AIM;

		// recover player info
		memcpy(userinfo, ent->client->pers.userinfo, sizeof(userinfo));
		InitClientPersistant(ent->client);
		ClientUserinfoChanged(ent, userinfo);
		modify_max(ent);
		Pick_respawnweapon(ent);
		ent->owner = NULL;
		return;
	}

	CreateBoss(ent);
}
Exemplo n.º 2
0
// TODO: Items should get their positions from the level file
void World::InitLevelObjects()
{
	RemoveAIEntities();

	LevelMap map = levels[currentLevelIdx].GetMap();

	// Inits monsters
	auto monsterTiles = map.GetTilesForLogicalSprite(TILE_MONSTER);
	for (auto monster = monsterTiles.begin(); monster != monsterTiles.end(); ++monster)
	{
		CreateMonster(monster->position);
	}

	// Inits items
	// TODO: Needs refactoring!
	auto itemPair = itemsForLevel.find(currentLevelIdx + 1); // We use indices corresponding to the 
														     // level files' names
	if (itemPair != itemsForLevel.end())
	{
		auto itemFileNames = itemPair->second;
		for (auto itemFileName = itemFileNames.begin(); itemFileName != itemFileNames.end(); ++itemFileName)
		{
			// Magnificent loading takes place!!!
			InitItemFromFile((*itemFileName));		
		}
	}

	auto shrinePair = shrinesForLevel.find(currentLevelIdx + 1);
	if (shrinePair != shrinesForLevel.end())
	{
		auto shrineFileNames = shrinePair->second;
		for (auto shrineFileName = shrineFileNames.begin(); shrineFileName != shrineFileNames.end(); ++shrineFileName)
		{
			// Magnificent loading takes place!!!
			InitItemFromFile((*shrineFileName));
		}
	}

	// Inits boss
	if (map.HasTileWithLogicalSprite(TILE_BOSS))
	{
		CreateBoss(map.GetTilesForLogicalSprite(TILE_BOSS)[0].position); // TODO: Unsafe. Make better.
	}

	levels[currentLevelIdx].RemoveWorldSpecificTiles();
}
Exemplo n.º 3
0
Arquivo: pvb.c Projeto: zardoru/vrxcl
void CreateRandomPlayerBoss (qboolean find_new_candidate)
{
	int		i, j=0;
	edict_t *player;//, *boss;
	edict_t	*e[MAX_CLIENTS];

	if (BossExists())
		return;

	// find valid boss candidates
	if (!SelectedBossPlayer)
	{
		if (!find_new_candidate)
			return;

		// initialize pointers
		for (i=0; i<MAX_CLIENTS; i++)
		{
			e[i] = NULL;
		}

		// create a list of valid players
		for (i=0; i<game.maxclients; i++) 
		{
			player = g_edicts+1+i;
			if (G_EntExists(player))
			{
				//gi.dprintf("DEBUG: valid player: %s\n", player->client->pers.netname);
				e[j++] = player;
			}
		}

		if (!j)
			return;

		// choose a player randomly
		SelectedBossPlayer = e[GetRandom(0, j-1)];
		//gi.dprintf("DEBUG: %s was selected to be the boss\n", SelectedBossPlayer->client->pers.netname);

		boss_timeout = level.time + PVB_BOSS_TIMEOUT;
	}
	else
	{
		CreateBoss(SelectedBossPlayer);
	}
}
Exemplo n.º 4
0
void boss_spawn_tank (edict_t *ent)
{
	char	userinfo[MAX_INFO_STRING], *message;
	//edict_t	*tank;

	//gi.dprintf("boss_spawn_tank()\n");

	if (G_EntExists(ent->owner) && (ent->owner->mtype == BOSS_TANK))
	{
		message = HiPrint(va("%s got bored and left the game.", ent->client->pers.netname));
		gi.bprintf(PRINT_HIGH, "%s\n", message);
		V_Free(message);

		BecomeTE(ent->owner);
		ent->svflags &= ~SVF_NOCLIENT;
		ent->viewheight = 22;
		ent->movetype = MOVETYPE_WALK;
		ent->solid = SOLID_BBOX;
		ent->takedamage = DAMAGE_AIM;

		// recover player info
		memcpy(userinfo, ent->client->pers.userinfo, sizeof(userinfo));
		InitClientPersistant(ent->client);
		ClientUserinfoChanged(ent, userinfo);
		modify_max(ent);
		Pick_respawnweapon(ent);
		ent->owner = NULL;
		return;
	}

	CreateBoss(ent);
/*
	message = HiPrint(va("A level %d boss known as %s has spawned!", average_player_level, ent->client->pers.netname));
	gi.bprintf(PRINT_HIGH, "%s\n", message);

	// create the tank entity that the player will pilot
	tank = G_Spawn();
	tank->classname = "boss";
	tank->solid = SOLID_BBOX;
	tank->takedamage = DAMAGE_YES;
	tank->movetype = MOVETYPE_STEP;
	tank->clipmask = MASK_MONSTERSOLID;
	tank->svflags |= SVF_MONSTER;
	tank->activator = ent;
	tank->die = boss_tank_die;
	tank->think = boss_tank_think;
	tank->mass = 500;
	tank->monsterinfo.level = average_player_level;
	tank->health = TANK_INITIAL_HEALTH+TANK_ADDON_HEALTH*tank->monsterinfo.level;
	tank->max_health = tank->health;
	tank->mtype = BOSS_TANK;
	tank->pain = boss_pain;
	tank->flags |= FL_CHASEABLE; // 3.65 indicates entity can be chase cammed
	// set up pointers
	tank->owner = ent;
	ent->owner = tank;
	
	tank->s.modelindex = gi.modelindex ("models/monsters/tank/tris.md2");
	VectorSet (tank->mins, -24, -24, -16);
	VectorSet (tank->maxs, 24, 24, 64);
	tank->s.skinnum = 2; // commander skin
	VectorCopy(ent->s.angles, tank->s.angles);
	tank->s.angles[PITCH] = 0; // monsters don't use pitch
	tank->nextthink = level.time + FRAMETIME;
	VectorCopy(ent->s.origin, tank->s.origin);
	VectorCopy(ent->s.old_origin, tank->s.old_origin);

	// link up entities
	gi.linkentity(tank);
	gi.linkentity(ent);

	// make the player into a ghost
	ent->svflags |= SVF_NOCLIENT;
	ent->viewheight = 0;
	ent->movetype = MOVETYPE_NOCLIP;
	ent->solid = SOLID_NOT;
	ent->takedamage = DAMAGE_NO;
	ent->client->ps.gunindex = 0;
	memset (ent->client->pers.inventory, 0, sizeof(ent->client->pers.inventory));
	ent->client->pers.weapon = NULL;
	*/
}