mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 21:20:54 +00:00
Allow AI Tails to carry the player
This commit is contained in:
parent
bf4dbead74
commit
52a24e0bc4
3 changed files with 25 additions and 23 deletions
34
src/b_bot.c
34
src/b_bot.c
|
@ -33,6 +33,17 @@ static boolean spinmode = false;
|
||||||
static boolean thinkfly = false;
|
static boolean thinkfly = false;
|
||||||
static mobj_t *overlay;
|
static mobj_t *overlay;
|
||||||
|
|
||||||
|
static inline void B_ResetAI()
|
||||||
|
{
|
||||||
|
jump_last = false;
|
||||||
|
spin_last = false;
|
||||||
|
anxiety = 0;
|
||||||
|
panic = false;
|
||||||
|
flymode = 0;
|
||||||
|
spinmode = false;
|
||||||
|
thinkfly = false;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
||||||
{
|
{
|
||||||
boolean forward=false, backward=false, left=false, right=false, jump=false, spin=false;
|
boolean forward=false, backward=false, left=false, right=false, jump=false, spin=false;
|
||||||
|
@ -135,11 +146,9 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
|
||||||
if (!jump_last)
|
if (!jump_last)
|
||||||
{
|
{
|
||||||
jump = true;
|
jump = true;
|
||||||
if (bot->pflags & PF_JUMPED)
|
|
||||||
{
|
|
||||||
flymode = 1;
|
flymode = 1;
|
||||||
thinkfly = false;
|
thinkfly = false;
|
||||||
}
|
bot->pflags |= PF_CANCARRY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,14 +177,8 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
|
||||||
flymode = 0;
|
flymode = 0;
|
||||||
|
|
||||||
// Set carried state
|
// Set carried state
|
||||||
if (bot->pflags & PF_THOKKED && flymode == 1
|
if (player->powers[pw_carry] == CR_PLAYER && sonic->tracer == tails)
|
||||||
&& !P_IsObjectOnGround(sonic)
|
|
||||||
&& dist < touchdist
|
|
||||||
&& zdist < 32*scale
|
|
||||||
&& flip * sonic->momz < 0)
|
|
||||||
{
|
{
|
||||||
P_SetTarget(&sonic->tracer, tails);
|
|
||||||
player->powers[pw_carry] = CR_PLAYER;
|
|
||||||
flymode = 2;
|
flymode = 2;
|
||||||
player->pflags &= ~PF_JUMPED;
|
player->pflags &= ~PF_JUMPED;
|
||||||
}
|
}
|
||||||
|
@ -193,12 +196,9 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
|
||||||
else if (!jump_last)
|
else if (!jump_last)
|
||||||
jump = true;
|
jump = true;
|
||||||
// End flymode
|
// End flymode
|
||||||
if (player->pflags & PF_JUMPED
|
if (player->powers[pw_carry] != CR_PLAYER
|
||||||
|| player->powers[pw_carry] != CR_PLAYER
|
|
||||||
|| P_IsObjectOnGround(sonic))
|
|| P_IsObjectOnGround(sonic))
|
||||||
{
|
{
|
||||||
player->powers[pw_carry] = CR_NONE;
|
|
||||||
P_SetTarget(&sonic->tracer, NULL);
|
|
||||||
flymode = 0;
|
flymode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
|
||||||
void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin)
|
void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin)
|
||||||
{
|
{
|
||||||
// don't try to do stuff if your sonic is in a minecart or something
|
// don't try to do stuff if your sonic is in a minecart or something
|
||||||
if (players[consoleplayer].powers[pw_carry])
|
if (players[consoleplayer].powers[pw_carry] && players[consoleplayer].powers[pw_carry] != CR_PLAYER)
|
||||||
return;
|
return;
|
||||||
// Turn the virtual keypresses into ticcmd_t.
|
// Turn the virtual keypresses into ticcmd_t.
|
||||||
if (twodlevel || mo->flags2 & MF2_TWOD) {
|
if (twodlevel || mo->flags2 & MF2_TWOD) {
|
||||||
|
@ -462,7 +462,7 @@ boolean B_CheckRespawn(player_t *player)
|
||||||
// If he's doing any of these things, he probably doesn't want to see us.
|
// If he's doing any of these things, he probably doesn't want to see us.
|
||||||
if (sonic->player->pflags & (PF_GLIDING|PF_SLIDING|PF_BOUNCING)
|
if (sonic->player->pflags & (PF_GLIDING|PF_SLIDING|PF_BOUNCING)
|
||||||
|| (sonic->player->panim != PA_IDLE && sonic->player->panim != PA_WALK)
|
|| (sonic->player->panim != PA_IDLE && sonic->player->panim != PA_WALK)
|
||||||
|| (sonic->player->powers[pw_carry]))
|
|| (sonic->player->powers[pw_carry] && sonic->player->powers[pw_carry] != CR_PLAYER))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Low ceiling, do not want!
|
// Low ceiling, do not want!
|
||||||
|
@ -497,6 +497,8 @@ void B_RespawnBot(INT32 playernum)
|
||||||
if (!sonic || sonic->health <= 0)
|
if (!sonic || sonic->health <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
B_ResetAI();
|
||||||
|
|
||||||
player->bot = 1;
|
player->bot = 1;
|
||||||
P_SpawnPlayer(playernum);
|
P_SpawnPlayer(playernum);
|
||||||
tails = player->mo;
|
tails = player->mo;
|
||||||
|
|
|
@ -592,9 +592,6 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails)
|
||||||
if (!(tails->pflags & PF_CANCARRY))
|
if (!(tails->pflags & PF_CANCARRY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tails->bot == 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((sonic->mo->eflags & MFE_VERTICALFLIP) != (tails->mo->eflags & MFE_VERTICALFLIP))
|
if ((sonic->mo->eflags & MFE_VERTICALFLIP) != (tails->mo->eflags & MFE_VERTICALFLIP))
|
||||||
return; // Both should be in same gravity
|
return; // Both should be in same gravity
|
||||||
|
|
||||||
|
|
|
@ -5295,6 +5295,9 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
|
||||||
player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer
|
player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer
|
||||||
|
|
||||||
player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH);
|
player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH);
|
||||||
|
if (player->bot == 1)
|
||||||
|
player->pflags |= PF_THOKKED;
|
||||||
|
else
|
||||||
player->pflags |= (PF_THOKKED|PF_CANCARRY);
|
player->pflags |= (PF_THOKKED|PF_CANCARRY);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -12276,7 +12279,7 @@ void P_PlayerAfterThink(player_t *player)
|
||||||
player->mo->momz = tails->momz;
|
player->mo->momz = tails->momz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gametype == GT_COOP)
|
if (gametype == GT_COOP && (!tails->player || tails->player->bot != 1))
|
||||||
{
|
{
|
||||||
player->mo->angle = tails->angle;
|
player->mo->angle = tails->angle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue