コード例 #1
0
ファイル: widow.c プロジェクト: acebox/yquake2_acemod
void
widow_ready_spawn(edict_t *self)
{
	vec3_t f, r, u, offset, startpoint, spawnpoint;
	int i;

	if (!self)
	{
		return;
	}

	WidowBlaster(self);
	AngleVectors(self->s.angles, f, r, u);

	for (i = 0; i < 2; i++)
	{
		VectorCopy(spawnpoints[i], offset);
		G_ProjectSource2(self->s.origin, offset, f, r, u, startpoint);

		if (FindSpawnPoint(startpoint, stalker_mins, stalker_maxs, spawnpoint,
					64))
		{
			SpawnGrow_Spawn(spawnpoint, 1);
		}
	}
}
コード例 #2
0
ファイル: carrier.c プロジェクト: yquake2/rogue
void
carrier_ready_spawn(edict_t *self)
{
	float current_yaw;
	vec3_t offset, f, r, startpoint, spawnpoint;

	if (!self)
	{
		return;
	}

	CarrierCoopCheck(self);
	CarrierMachineGun(self);

	current_yaw = anglemod(self->s.angles[YAW]);

	if (fabs(current_yaw - self->ideal_yaw) > 0.1)
	{
		self->monsterinfo.aiflags |= AI_HOLD_FRAME;
		self->timestamp += FRAMETIME;
		return;
	}

	self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;

	VectorSet(offset, 105, 0, -58);
	AngleVectors(self->s.angles, f, r, NULL);
	G_ProjectSource(self->s.origin, offset, f, r, startpoint);

	if (FindSpawnPoint(startpoint, flyer_mins, flyer_maxs, spawnpoint, 32))
	{
		SpawnGrow_Spawn(spawnpoint, 0);
	}
}
コード例 #3
0
ファイル: respawn.cpp プロジェクト: master4523/crimsonglory
void CRespawn::Think()
{
    int i;
    for ( i = 0; i < queue.size(); i++ )
    {
      if ( !queue[i]->waveRespawn )
      {
        if ( queue[i]->respawnTime > 0 )
        {
          queue[i]->respawnTime--;
        }
      }
      else
      {
      }
    }

    for ( i = 0; i < queue.size(); i++ )
    {
      if ( !queue[i]->waveRespawn )
      {
        if ( queue[i]->respawnTime < 1 )
        {
          queue[i]->Respawn( FindSpawnPoint( queue[i] ) );
          delete queue[i];
          queue.erase( i );
          i = 0;
        }
      }
      else
      {
      }
    }
}
コード例 #4
0
void CCarrier::ReadySpawn ()
{
	CoopCheck();
	MachineGun();

	float current_yaw = AngleModf (Entity->State.GetAngles().Y);

	if (Abs(current_yaw - IdealYaw) > 0.1f)
	{
		AIFlags |= AI_HOLD_FRAME;
		FrameCalc += ServerFramesPerSecond;
		return;
	}

	AIFlags &= ~AI_HOLD_FRAME;

	static const vec3f offset (105, 0, -58);
	vec3f startpoint, spawnpoint;

	anglef angles = Entity->State.GetAngles().ToVectors ();
	G_ProjectSource (Entity->State.GetOrigin(), offset, angles, startpoint);

	if (FindSpawnPoint (startpoint, flyer_mins, flyer_maxs, spawnpoint, 32))
		CSpawnGrow::Spawn (spawnpoint, 0);
}
コード例 #5
0
ファイル: widow.c プロジェクト: acebox/yquake2_acemod
void
WidowSpawn(edict_t *self)
{
	vec3_t f, r, u, offset, startpoint, spawnpoint;
	edict_t *ent, *designated_enemy;
	int i;

	if (!self)
	{
		return;
	}

	AngleVectors(self->s.angles, f, r, u);

	for (i = 0; i < 2; i++)
	{
		VectorCopy(spawnpoints[i], offset);

		G_ProjectSource2(self->s.origin, offset, f, r, u, startpoint);

		if (FindSpawnPoint(startpoint, stalker_mins, stalker_maxs, spawnpoint,
					64))
		{
			ent = CreateGroundMonster(spawnpoint, self->s.angles, stalker_mins, stalker_maxs,
					"monster_stalker", 256);

			if (!ent)
			{
				continue;
			}

			self->monsterinfo.monster_used++;
			ent->monsterinfo.commander = self;
			ent->nextthink = level.time;
			ent->think(ent);

			ent->monsterinfo.aiflags |= /* AI_SPAWNED_WIDOW | */ AI_DO_NOT_COUNT | AI_IGNORE_SHOTS;

			designated_enemy = self->enemy;

			if ((designated_enemy->inuse) && (designated_enemy->health > 0))
			{
				ent->enemy = designated_enemy;
				FoundTarget(ent);
				ent->monsterinfo.attack(ent);
			}
		}
	}
}
コード例 #6
0
ファイル: carrier.c プロジェクト: yquake2/rogue
void
CarrierSpawn(edict_t *self)
{
	vec3_t f, r, offset, startpoint, spawnpoint;
	edict_t *ent;
	int mytime;

	if (!self)
	{
		return;
	}

	VectorSet(offset, 105, 0, -58);
	AngleVectors(self->s.angles, f, r, NULL);

	G_ProjectSource(self->s.origin, offset, f, r, startpoint);

	/* the +0.1 is because level.time is sometimes a little low */
	mytime = (int)((level.time + 0.1 - self->timestamp) / 0.5);

	if (FindSpawnPoint(startpoint, flyer_mins, flyer_maxs, spawnpoint, 32))
	{
		/* the second flier should be a kamikaze flyer */
		if (mytime != 2)
		{
			ent = CreateMonster(spawnpoint, self->s.angles, "monster_flyer");
		}
		else
		{
			ent = CreateMonster(spawnpoint, self->s.angles, "monster_kamikaze");
		}

		if (!ent)
		{
			return;
		}

		gi.sound(self, CHAN_BODY, sound_spawn, 1, ATTN_NONE, 0);

		self->monsterinfo.monster_slots--;

		ent->nextthink = level.time;
		ent->think(ent);

		ent->monsterinfo.aiflags |= AI_SPAWNED_CARRIER | AI_DO_NOT_COUNT |
									AI_IGNORE_SHOTS;
		ent->monsterinfo.commander = self;

		if ((self->enemy->inuse) && (self->enemy->health > 0))
		{
			ent->enemy = self->enemy;
			FoundTarget(ent);

			if (mytime == 1)
			{
				ent->monsterinfo.lefty = 0;
				ent->monsterinfo.attack_state = AS_SLIDING;
				ent->monsterinfo.currentmove = &flyer_move_attack3;
			}
			else if (mytime == 2)
			{
				ent->monsterinfo.lefty = 0;
				ent->monsterinfo.attack_state = AS_STRAIGHT;
				ent->monsterinfo.currentmove = &flyer_move_kamikaze;
				ent->mass = 100;
				ent->monsterinfo.aiflags |= AI_CHARGING;
			}
			else if (mytime == 3)
			{
				ent->monsterinfo.lefty = 1;
				ent->monsterinfo.attack_state = AS_SLIDING;
				ent->monsterinfo.currentmove = &flyer_move_attack3;
			}
		}
	}
}
コード例 #7
0
void medic_finish_spawn (edict_t *self)
{
	edict_t *ent;
	vec3_t	f, r, offset, startpoint, spawnpoint;
	int		summonStr;
	int		count;
	int		inc;
	int		num_summoned; // should be 1, 3, or 5
	qboolean	behind = false;
	edict_t	*designated_enemy;

//	trace_t		tr;
//	vec3_t mins, maxs;

	// this is one bigger than the soldier's real mins .. just for paranoia's sake
//	VectorSet (mins, -17, -17, -25);
//	VectorSet (maxs, 17, 17, 33);

	//FIXME - better place to store this info?
	if (self->plat2flags < 0)
	{
		behind = true;
		self->plat2flags *= -1;
	}
	summonStr = self->plat2flags;

	AngleVectors (self->s.angles, f, r, NULL);

//	num_summoned = ((((summonStr-1)/2)+1)*2)-1;  // this yields either 1, 3, or 5
	if (summonStr)
		num_summoned = (summonStr - 1) + (summonStr % 2);
	else
		num_summoned = 1;

//	if ((g_showlogic) && (g_showlogic->value))
//		gi.dprintf ("medic_commander: summonStr = %d num = %d\n", summonStr, num_summoned);

	for (count = 0; count < num_summoned; count++)
	{
		inc = count + (count%2); // 0, 2, 2, 4, 4
		VectorCopy (reinforcement_position[count], offset);

		G_ProjectSource (self->s.origin, offset, f, r, startpoint);

		// a little off the ground
		startpoint[2] += 10;

		ent = NULL;
		if (FindSpawnPoint (startpoint, reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], spawnpoint, 32))
		{
			if (CheckSpawnPoint (spawnpoint, reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc]))
				ent = CreateGroundMonster (spawnpoint, self->s.angles,
					reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc],
					reinforcements[summonStr-inc], 256);
//			else if ((g_showlogic) && (g_showlogic->value))
//				gi.dprintf ("CheckSpawnPoint failed volume check!\n");
		}
		else
		{
//			if ((g_showlogic) && (g_showlogic->value))
//				gi.dprintf ("FindSpawnPoint failed to find a point!\n");
		}

		if (!ent)
		{
//			if ((g_showlogic) && (g_showlogic->value))
//				gi.dprintf ("Spawn point obstructed for %s, aborting!\n", reinforcements[summonStr-inc]);
			continue;
		}

//		gi.sound (self, CHAN_WEAPON, commander_sound_spawn, 1, ATTN_NORM, 0);

		if (ent->think)
		{
			ent->nextthink = level.time;
			ent->think (ent);
		}

		ent->monsterinfo.aiflags |= AI_IGNORE_SHOTS|AI_DO_NOT_COUNT|AI_SPAWNED_MEDIC_C;
		ent->monsterinfo.commander = self;
		self->monsterinfo.monster_slots--;
//		if ((g_showlogic) && (g_showlogic->value))
//			gi.dprintf ("medic_commander: %d slots remaining\n", self->monsterinfo.monster_slots);

		if (self->monsterinfo.aiflags & AI_MEDIC)
			designated_enemy = self->oldenemy;
		else
			designated_enemy = self->enemy;

		if (coop && coop->value)
		{
			designated_enemy = PickCoopTarget(ent);
			if (designated_enemy)
			{
				// try to avoid using my enemy
				if (designated_enemy == self->enemy)
				{
					designated_enemy = PickCoopTarget(ent);
					if (designated_enemy)
					{
//						if ((g_showlogic) && (g_showlogic->value))
//						{
//							gi.dprintf ("PickCoopTarget returned a %s - ", designated_enemy->classname);
//							if (designated_enemy->client)
//								gi.dprintf ("with name %s\n", designated_enemy->client->pers.netname);
//							else
//								gi.dprintf ("NOT A CLIENT\n");
//						}
					}
					else
					{
//						if ((g_showlogic) && (g_showlogic->value))
//							gi.dprintf ("pick coop failed, using my current enemy\n");
						designated_enemy = self->enemy;
					}
				}
			}
			else
			{
//				if ((g_showlogic) && (g_showlogic->value))
//					gi.dprintf ("pick coop failed, using my current enemy\n");
				designated_enemy = self->enemy;
			}
		}

		if ((designated_enemy) && (designated_enemy->inuse) && (designated_enemy->health > 0))
		{
			// fixme
//			if ((g_showlogic) && (g_showlogic -> value))
//				gi.dprintf  ("setting enemy to %s\n", designated_enemy->classname);
			ent->enemy = designated_enemy;
			FoundTarget (ent);
		}
		else
		{
			ent->enemy = NULL;
			ent->monsterinfo.stand (ent);
		}
//		ent->s.event = EV_PLAYER_TELEPORT;
	}
}
コード例 #8
0
void medic_spawngrows (edict_t *self)
{
	vec3_t	f, r, offset, startpoint, spawnpoint;
	int		summonStr;
	int		count;
	int		inc;
	int		num_summoned; // should be 1, 3, or 5
	int		num_success = 0;
	float	current_yaw;
	qboolean	behind = false;

	// if we've been directed to turn around
	if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
	{
		current_yaw = anglemod(self->s.angles[YAW]);
		if (fabs(current_yaw - self->ideal_yaw) > 0.1)
		{
			self->monsterinfo.aiflags |= AI_HOLD_FRAME;
			return;
		}

		// done turning around
		self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
		self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
	}

//	if (self->plat2flags < 0)
//	{
//		summonStr = -1.0 * self->plat2flags;
//		behind = true;
//	}
//	else
		summonStr = self->plat2flags;

	AngleVectors (self->s.angles, f, r, NULL);

//	num_summoned = ((((summonStr-1)/2)+1)*2)-1;  // this yields either 1, 3, or 5
	if (summonStr)
		num_summoned = (summonStr - 1) + (summonStr % 2);
	else
		num_summoned = 1;

	for (count = 0; count < num_summoned; count++)
	{
		inc = count + (count%2); // 0, 2, 2, 4, 4
		VectorCopy (reinforcement_position[count], offset);

		G_ProjectSource (self->s.origin, offset, f, r, startpoint);
		// a little off the ground
		startpoint[2] += 10;

		if (FindSpawnPoint (startpoint, reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], spawnpoint, 32))
		{
			if (CheckGroundSpawnPoint(spawnpoint, 
				reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], 
				256, -1))
			{
				num_success++;
				if ((summonStr-inc) > 3)
					SpawnGrow_Spawn (spawnpoint, 1);		// big monster
				else
					SpawnGrow_Spawn (spawnpoint, 0);		// normal size
			}
		}
	}

	if (num_success == 0)
	{
//		if ((g_showlogic) && (g_showlogic->value))
//			gi.dprintf ("medic_commander: spawngrows bad, aborting!\n");
		self->monsterinfo.nextframe = FRAME_attack53;
	}
}
コード例 #9
0
void medic_determine_spawn (edict_t *self)
{
	vec3_t	f, r, offset, startpoint, spawnpoint;
	float	lucky;
	int		summonStr;
	int		count;
	int		inc;
	int		num_summoned; // should be 1, 3, or 5
	int		num_success = 0;

	lucky = random();
	summonStr = skill->value;

	// bell curve - 0 = 67%, 1 = 93%, 2 = 99% -- too steep
	// this ends up with
	// -3 = 5%
	// -2 = 10%
	// -1 = 15%
	// 0  = 40%
	// +1 = 15%
	// +2 = 10%
	// +3 = 5%
	if (lucky < 0.05)
		summonStr -= 3;
	else if (lucky < 0.15)
		summonStr -= 2;
	else if (lucky < 0.3)
		summonStr -= 1;
	else if (lucky > 0.95)
		summonStr += 3;
	else if (lucky > 0.85)
		summonStr += 2;
	else if (lucky > 0.7)
		summonStr += 1;

	if (summonStr < 0)
		summonStr = 0;

	//FIXME - need to remember this, might as well use this int that isn't used for monsters
	self->plat2flags = summonStr;
	AngleVectors (self->s.angles, f, r, NULL);

// this yields either 1, 3, or 5
	if (summonStr)
		num_summoned = (summonStr - 1) + (summonStr % 2);
	else
		num_summoned = 1;

//	if ((g_showlogic) && (g_showlogic->value))
//		gi.dprintf ("medic_commander: summonStr = %d num = %d\n", summonStr, num_summoned);

	for (count = 0; count < num_summoned; count++)
	{
		inc = count + (count%2); // 0, 2, 2, 4, 4
		VectorCopy (reinforcement_position[count], offset);

		G_ProjectSource (self->s.origin, offset, f, r, startpoint);
		// a little off the ground
		startpoint[2] += 10;

		if (FindSpawnPoint (startpoint, reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], spawnpoint, 32))
		{
			if (CheckGroundSpawnPoint(spawnpoint, 
				reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], 
				256, -1))
			{
				num_success++;
				// we found a spot, we're done here
				count = num_summoned;
			}
//			else if ((g_showlogic) && (g_showlogic->value))
//				gi.dprintf ("medic_commander: CheckGroundSpawnPoint says bad stuff down there!\n");
		}
	}

	if (num_success == 0)
	{
		for (count = 0; count < num_summoned; count++)
		{
			inc = count + (count%2); // 0, 2, 2, 4, 4
			VectorCopy (reinforcement_position[count], offset);
			
			// check behind
			offset[0] *= -1.0;
			offset[1] *= -1.0;
			G_ProjectSource (self->s.origin, offset, f, r, startpoint);
			// a little off the ground
			startpoint[2] += 10;

			if (FindSpawnPoint (startpoint, reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], spawnpoint, 32))
			{
				if (CheckGroundSpawnPoint(spawnpoint, 
					reinforcement_mins[summonStr-inc], reinforcement_maxs[summonStr-inc], 
					256, -1))
				{
					num_success++;
					// we found a spot, we're done here
					count = num_summoned;
				}
			}
		}

		if (num_success)
		{
			self->monsterinfo.aiflags |= AI_MANUAL_STEERING;
			self->ideal_yaw = anglemod(self->s.angles[YAW]) + 180;
			if (self->ideal_yaw > 360.0)
				self->ideal_yaw -= 360.0;
//			self->plat2flags *= -1;
		}
	}

	if (num_success == 0)
	{
//		if ((g_showlogic) && (g_showlogic->value))
//			gi.dprintf ("medic_commander: failed to find any spawn points, aborting!\n");
		self->monsterinfo.nextframe = FRAME_attack53;
	}
}
コード例 #10
0
ファイル: m_widow2.c プロジェクト: janisl/quake2-game
void Widow2Spawn (edict_t *self)
{
	vec3_t	f, r, u, offset, startpoint, spawnpoint;
	edict_t	*ent, *designated_enemy;
	int		i;

	AngleVectors (self->s.angles, f, r, u);

	for (i=0; i < 2; i++)
	{
		VectorCopy (spawnpoints[i], offset);

		G_ProjectSource2 (self->s.origin, offset, f, r, u, startpoint);

		if (FindSpawnPoint (startpoint, stalker_mins, stalker_maxs, spawnpoint, 64))
		{
			ent = CreateGroundMonster (spawnpoint, self->s.angles, stalker_mins, stalker_maxs, "monster_stalker", 256);

			if (!ent)
				continue;

			self->monsterinfo.monster_used++;
			ent->monsterinfo.commander = self;
//			if ((g_showlogic) && (g_showlogic->value))
//				gi.dprintf ("widow: post-spawn : %d slots left\n", SELF_SLOTS_LEFT);

			ent->nextthink = level.time;
			ent->think (ent);
			
			ent->monsterinfo.aiflags |= AI_SPAWNED_WIDOW|AI_DO_NOT_COUNT|AI_IGNORE_SHOTS;

			if (!(coop && coop->value))
			{
				designated_enemy = self->enemy;
			}
			else
			{
				designated_enemy = PickCoopTarget(ent);
				if (designated_enemy)
				{
					// try to avoid using my enemy
					if (designated_enemy == self->enemy)
					{
						designated_enemy = PickCoopTarget(ent);
						if (designated_enemy)
						{
//							if ((g_showlogic) && (g_showlogic->value))
//							{
//								gi.dprintf ("PickCoopTarget returned a %s - ", designated_enemy->classname);
//								if (designated_enemy->client)
//									gi.dprintf ("with name %s\n", designated_enemy->client->pers.netname);
//								else
//									gi.dprintf ("NOT A CLIENT\n");
//							}
						}
						else
						{
//							if ((g_showlogic) && (g_showlogic->value))
//								gi.dprintf ("pick coop failed, using my current enemy\n");
							designated_enemy = self->enemy;
						}
					}
				}
				else
				{
//					if ((g_showlogic) && (g_showlogic->value))
//						gi.dprintf ("pick coop failed, using my current enemy\n");
					designated_enemy = self->enemy;
				}
			}

			if ((designated_enemy->inuse) && (designated_enemy->health > 0))
			{
				ent->enemy = designated_enemy;
				FoundTarget (ent);
				ent->monsterinfo.attack(ent);
			}
		}
	}
}
コード例 #11
0
void CCarrier::SpawnMonsters ()
{
	vec3f offset (105, 0, -58); // real distance needed is (sqrt (56*56*2) + sqrt(16*16*2)) or 101.8
	anglef angles = Entity->State.GetAngles().ToVectors ();

	vec3f startpoint;
	G_ProjectSource (Entity->State.GetOrigin(), offset, angles, startpoint);

	// the +0.1 is because level.time is sometimes a little low
	FrameNumber mytime = ((Level.Frame + 1 - FrameCalc) / 5);

	vec3f spawnpoint;
	if (FindSpawnPoint (startpoint, flyer_mins, flyer_maxs, spawnpoint, 32))
	{
		CMonsterEntity *ent = NULL;

		// the second flier should be a kamikaze flyer
		if (mytime != 2)
			ent = CreateMonster (spawnpoint, Entity->State.GetAngles(), "monster_flyer");
		else
			ent = CreateMonster (spawnpoint, Entity->State.GetAngles(), "monster_kamikaze");

		if (!ent)
			return;

		Entity->PlaySound (CHAN_BODY, Sounds[SOUND_SPAWN]);

		MonsterSlots--;

		ent->NextThink = Level.Frame;
		void	(IMonster::*TheThink) () = ent->Monster->Think;
		(ent->Monster->*TheThink) ();
		
		ent->Monster->AIFlags |= AI_SPAWNED_CARRIER|AI_DO_NOT_COUNT|AI_IGNORE_SHOTS;
		ent->Monster->Commander = Entity;

		if ((Entity->Enemy->GetInUse()) && (entity_cast<IHurtableEntity>(*Entity->Enemy)->Health > 0))
		{
			ent->Enemy = Entity->Enemy;
			ent->Monster->FoundTarget ();
			if (mytime == 1)
			{
				ent->Monster->Lefty = false;
				ent->Monster->AttackState = AS_SLIDING;
				ent->Monster->CurrentMove = &FlyerMoveAttack2;
			}
			else if (mytime == 2)
			{
				ent->Monster->Lefty = false;
				ent->Monster->AttackState = AS_STRAIGHT;
				ent->Monster->CurrentMove = &FlyerMoveKamikaze;
				ent->Monster->AIFlags |= AI_CHARGING;
			}
			else if (mytime == 3)
			{
				ent->Monster->Lefty = true;
				ent->Monster->AttackState = AS_SLIDING;
				ent->Monster->CurrentMove = &FlyerMoveAttack2;
			}
		}
	}
}