mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
- Changed TThinkerIterator loops back to MAXPLAYERS loops.
- Added STAT_BOT.
This commit is contained in:
parent
ee977f94d7
commit
e38aee070c
7 changed files with 56 additions and 62 deletions
|
@ -24,6 +24,7 @@ IMPLEMENT_POINTY_CLASS(DBot)
|
||||||
END_POINTERS
|
END_POINTERS
|
||||||
|
|
||||||
DBot::DBot ()
|
DBot::DBot ()
|
||||||
|
: DThinker(STAT_BOT)
|
||||||
{
|
{
|
||||||
Clear ();
|
Clear ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,12 +272,10 @@ shootmissile:
|
||||||
|
|
||||||
bool FCajunMaster::IsLeader (player_t *player)
|
bool FCajunMaster::IsLeader (player_t *player)
|
||||||
{
|
{
|
||||||
DBot *Bot;
|
for (int count = 0; count < MAXPLAYERS; count++)
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
|
|
||||||
while ((Bot = it.Next ()) != NULL)
|
|
||||||
{
|
{
|
||||||
if (Bot->mate == player->mo)
|
if (players[count].Bot != NULL
|
||||||
|
&& players[count].Bot->mate == player->mo)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -557,22 +555,22 @@ bool FCajunMaster::SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FChec
|
||||||
|
|
||||||
void FCajunMaster::StartTravel ()
|
void FCajunMaster::StartTravel ()
|
||||||
{
|
{
|
||||||
DBot *Bot;
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
|
|
||||||
while ((Bot = it.Next ()) != NULL)
|
|
||||||
{
|
{
|
||||||
Bot->ChangeStatNum (STAT_TRAVELLING);
|
if (players[i].Bot != NULL)
|
||||||
|
{
|
||||||
|
players[i].Bot->ChangeStatNum (STAT_TRAVELLING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FCajunMaster::FinishTravel ()
|
void FCajunMaster::FinishTravel ()
|
||||||
{
|
{
|
||||||
DBot *Bot;
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
||||||
TThinkerIterator<DBot> it(STAT_TRAVELLING);
|
|
||||||
|
|
||||||
while ((Bot = it.Next ()) != NULL)
|
|
||||||
{
|
{
|
||||||
Bot->ChangeStatNum (STAT_DEFAULT);
|
if (players[i].Bot != NULL)
|
||||||
|
{
|
||||||
|
players[i].Bot->ChangeStatNum (STAT_BOT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,16 +170,15 @@ void FCajunMaster::Init ()
|
||||||
//Called on each level exit (from g_game.c).
|
//Called on each level exit (from g_game.c).
|
||||||
void FCajunMaster::End ()
|
void FCajunMaster::End ()
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
//Arrange wanted botnum and their names, so they can be spawned next level.
|
//Arrange wanted botnum and their names, so they can be spawned next level.
|
||||||
getspawned.Clear();
|
getspawned.Clear();
|
||||||
if (deathmatch)
|
if (deathmatch)
|
||||||
{
|
{
|
||||||
DBot *Bot;
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
|
|
||||||
while ((Bot = it.Next ()) != NULL)
|
|
||||||
{
|
{
|
||||||
getspawned.Push(Bot->player->userinfo.GetName());
|
getspawned.Push(players[i].userinfo.GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
wanted_botnum = botnum;
|
wanted_botnum = botnum;
|
||||||
|
@ -393,30 +392,31 @@ bool FCajunMaster::DoAddBot (BYTE *info, botskill_t skill)
|
||||||
|
|
||||||
void FCajunMaster::RemoveAllBots (bool fromlist)
|
void FCajunMaster::RemoveAllBots (bool fromlist)
|
||||||
{
|
{
|
||||||
DBot *Bot;
|
int i, j;
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
while ((Bot = it.Next ()) != NULL)
|
for (i = 0; i < MAXPLAYERS; ++i)
|
||||||
|
{
|
||||||
|
if (players[i].Bot != NULL)
|
||||||
{
|
{
|
||||||
// If a player is looking through this bot's eyes, make him
|
// If a player is looking through this bot's eyes, make him
|
||||||
// look through his own eyes instead.
|
// look through his own eyes instead.
|
||||||
for (i = 0; i < MAXPLAYERS; ++i)
|
for (j = 0; j < MAXPLAYERS; ++j)
|
||||||
{
|
{
|
||||||
if (Bot->player != &players[i] && playeringame[i] && players[i].Bot == NULL)
|
if (i != j && playeringame[j] && players[j].Bot == NULL)
|
||||||
{
|
{
|
||||||
if (players[i].camera == Bot->player->mo)
|
if (players[j].camera == players[i].mo)
|
||||||
{
|
{
|
||||||
players[i].camera = players[i].mo;
|
players[j].camera = players[j].mo;
|
||||||
if (i == consoleplayer)
|
if (j == consoleplayer)
|
||||||
{
|
{
|
||||||
StatusBar->AttachToPlayer (players + i);
|
StatusBar->AttachToPlayer (players + j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClearPlayer (Bot->player - players, !fromlist);
|
ClearPlayer (i, !fromlist);
|
||||||
FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, NULL, true, Bot->player - players);
|
FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, NULL, true, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromlist)
|
if (fromlist)
|
||||||
|
|
|
@ -1021,14 +1021,11 @@ void AInventory::Touch (AActor *toucher)
|
||||||
P_GiveSecret(toucher, true, true, -1);
|
P_GiveSecret(toucher, true, true, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBot *Bot;
|
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
|
|
||||||
//Added by MC: Check if item taken was the roam destination of any bot
|
//Added by MC: Check if item taken was the roam destination of any bot
|
||||||
while ((Bot = it.Next ()) != NULL)
|
for (int i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (Bot->dest == this)
|
if (players[i].Bot != NULL && this == players[i].Bot->dest)
|
||||||
Bot->dest = NULL;
|
players[i].Bot->dest = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -611,17 +611,14 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
|
||||||
if (player->Bot != NULL)
|
if (player->Bot != NULL)
|
||||||
player->Bot->t_respawn = (pr_botrespawn()%15)+((bglobal.botnum-1)*2)+TICRATE+1;
|
player->Bot->t_respawn = (pr_botrespawn()%15)+((bglobal.botnum-1)*2)+TICRATE+1;
|
||||||
|
|
||||||
DBot *Bot;
|
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
|
|
||||||
//Added by MC: Discard enemies.
|
//Added by MC: Discard enemies.
|
||||||
while ((Bot = it.Next ()) != NULL)
|
for (int i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (this == Bot->enemy)
|
if (players[i].Bot != NULL && this == players[i].Bot->enemy)
|
||||||
{
|
{
|
||||||
if (Bot->dest == Bot->enemy)
|
if (players[i].Bot->dest == players[i].Bot->enemy)
|
||||||
Bot->dest = NULL;
|
players[i].Bot->dest = NULL;
|
||||||
Bot->enemy = NULL;
|
players[i].Bot->enemy = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3042,6 +3042,7 @@ void AActor::Tick ()
|
||||||
|
|
||||||
|
|
||||||
AActor *onmo;
|
AActor *onmo;
|
||||||
|
int i;
|
||||||
|
|
||||||
//assert (state != NULL);
|
//assert (state != NULL);
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
|
@ -3231,36 +3232,35 @@ void AActor::Tick ()
|
||||||
{
|
{
|
||||||
BotSupportCycles.Clock();
|
BotSupportCycles.Clock();
|
||||||
bglobal.m_Thinking = true;
|
bglobal.m_Thinking = true;
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
DBot *Bot;
|
|
||||||
TThinkerIterator<DBot> it;
|
|
||||||
|
|
||||||
while ((Bot = it.Next ()) != NULL)
|
|
||||||
{
|
{
|
||||||
|
if (!playeringame[i] || players[i].Bot == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (flags3 & MF3_ISMONSTER)
|
if (flags3 & MF3_ISMONSTER)
|
||||||
{
|
{
|
||||||
if (health > 0
|
if (health > 0
|
||||||
&& !Bot->enemy
|
&& !players[i].Bot->enemy
|
||||||
&& player ? !IsTeammate (Bot->player->mo) : true
|
&& player ? !IsTeammate (players[i].mo) : true
|
||||||
&& P_AproxDistance (Bot->player->mo->x-x, Bot->player->mo->y-y) < MAX_MONSTER_TARGET_DIST
|
&& P_AproxDistance (players[i].mo->x-x, players[i].mo->y-y) < MAX_MONSTER_TARGET_DIST
|
||||||
&& P_CheckSight (Bot->player->mo, this, SF_SEEPASTBLOCKEVERYTHING))
|
&& P_CheckSight (players[i].mo, this, SF_SEEPASTBLOCKEVERYTHING))
|
||||||
{ //Probably a monster, so go kill it.
|
{ //Probably a monster, so go kill it.
|
||||||
Bot->enemy = this;
|
players[i].Bot->enemy = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (flags & MF_SPECIAL)
|
else if (flags & MF_SPECIAL)
|
||||||
{ //Item pickup time
|
{ //Item pickup time
|
||||||
//clock (BotWTG);
|
//clock (BotWTG);
|
||||||
bglobal.WhatToGet (Bot->player->mo, this);
|
bglobal.WhatToGet (players[i].mo, this);
|
||||||
//unclock (BotWTG);
|
//unclock (BotWTG);
|
||||||
BotWTG++;
|
BotWTG++;
|
||||||
}
|
}
|
||||||
else if (flags & MF_MISSILE)
|
else if (flags & MF_MISSILE)
|
||||||
{
|
{
|
||||||
if (!Bot->missile && (flags3 & MF3_WARNBOT))
|
if (!players[i].Bot->missile && (flags3 & MF3_WARNBOT))
|
||||||
{ //warn for incoming missiles.
|
{ //warn for incoming missiles.
|
||||||
if (target != Bot->player->mo && bglobal.Check_LOS (Bot->player->mo, this, ANGLE_90))
|
if (target != players[i].mo && bglobal.Check_LOS (players[i].mo, this, ANGLE_90))
|
||||||
Bot->missile = this;
|
players[i].Bot->missile = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ enum
|
||||||
STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement
|
STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement
|
||||||
STAT_ACTORMOVER, // actor movers
|
STAT_ACTORMOVER, // actor movers
|
||||||
STAT_SCRIPTS, // The ACS thinker. This is to ensure that it can't tick before all actors called PostBeginPlay
|
STAT_SCRIPTS, // The ACS thinker. This is to ensure that it can't tick before all actors called PostBeginPlay
|
||||||
|
STAT_BOT, // Bot thinker
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue