From 00697caa6e40ea07fcb2f6fb78c18a770bd1d890 Mon Sep 17 00:00:00 2001 From: lachwright Date: Thu, 3 Oct 2019 12:49:46 +0800 Subject: [PATCH 01/22] Initial commit --- src/b_bot.c | 314 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 277 insertions(+), 37 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 17211b353..02ac6d1bc 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -24,12 +24,36 @@ static boolean lastForward = false; static boolean lastBlocked = false; static boolean blocked = false; +static boolean jump_last = false; +static boolean spin_last = false; +static UINT8 anxiety = 0; +static boolean panic = false; +static UINT8 flymode = 0; +static boolean spinmode = false; +static boolean thinkfly = false; +static mobj_t *overlay; + 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; - angle_t angle; - INT16 rangle; - fixed_t dist; + + player_t *player = sonic->player, *bot = tails->player; + ticcmd_t *pcmd = &player->cmd; + boolean water = tails->eflags & MFE_UNDERWATER; + boolean flip = P_MobjFlip(tails); + boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel; + fixed_t scale = tails->scale; + + fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y); + fixed_t zdist = flip * (sonic->z - tails->z); + angle_t ang = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y); + fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy); + fixed_t bmom = P_AproxDistance(tails->momx, tails->momy); + fixed_t followmax = 128 * 8 *scale; + fixed_t followthres = 92 * scale; + fixed_t followmin = 32 * scale; + fixed_t comfortheight = 96 * scale; + fixed_t touchdist = 24 * scale; // We can't follow Sonic if he's not around! if (!sonic || sonic->health <= 0) @@ -58,46 +82,255 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm return; } - // Gather data about the environment - dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y); - if (tails->player->pflags & PF_STARTDASH) - angle = sonic->angle; + // Adapted from CobaltBW's tails_AI.wad + + // Check water + if (water) + { + followmin = 0; + followthres = 16*scale; + followmax >>= 1; + thinkfly = false; + } + + // Check anxiety + if (spinmode) + { + anxiety = 0; + panic = false; + } + else if (dist > followmax || zdist > comfortheight) + { + anxiety = min(anxiety + 2, 70); + if (anxiety >= 70) + panic = true; + } else - angle = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y); - - // Decide which direction to turn - angle = (tails->angle - angle); - if (angle < ANGLE_180) { - right = true; // We need to turn right - rangle = AngleFixed(angle)>>FRACBITS; - } else { - left = true; // We need to turn left - rangle = 360-(AngleFixed(angle)>>FRACBITS); + { + anxiety = max(anxiety - 1, 0); + panic = false; } - - // Decide to move forward if you're finished turning - if (abs(rangle) < 10) { // We're facing the right way? - left = right = false; // Stop turning - forward = true; // and walk forward instead. + + // Orientation + if ((bot->pflags & (PF_SPINNING|PF_STARTDASH)) || flymode == 2) + { + tails->angle = sonic->angle; } - if (dist < (sonic->radius+tails->radius)*3) // We're close enough? - forward = false; // Stop walking. - - // Decide when to jump - if (!(tails->player->pflags & (PF_JUMPED|PF_JUMPDOWN))) { // We're not jumping yet... - if (forward && lastForward && blocked && lastBlocked) // We've been stopped by a wall or something - jump = true; // Try to jump up - } else if ((tails->player->pflags & (PF_JUMPDOWN|PF_JUMPED)) == (PF_JUMPDOWN|PF_JUMPED)) { // When we're already jumping... - if (lastForward && blocked) // We're still stuck on something? + else + { + tails->angle = ang; + } + + // ******** + // FLY MODE + // spinmode check + if (spinmode) + thinkfly = false; + else + { + // Activate co-op flight + if (thinkfly && player->pflags & PF_JUMPED) + { + if (!jump_last) + { + jump = true; + if (bot->pflags & PF_JUMPED) + { + flymode = 1; + thinkfly = false; + } + } + } + + // Check positioning + // Thinker for co-op flight + if (!(water || pmom || bmom) + && (dist < touchdist) + && !(pcmd->forwardmove || pcmd->sidemove || player->dashspeed) + && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) + && !(player->pflags & PF_STASIS)) + thinkfly = true; + else + thinkfly = false; + + // Ready for takeoff + if (flymode == 1) + { + thinkfly = false; + if (zdist < -64*scale || (flip * tails->momz) > scale) // Make sure we're not too high up + spin = true; + else if (!jump_last) + jump = true; + + // Abort if the player moves away or spins + if (dist > followthres || player->dashspeed) + flymode = 0; + + // Set carried state + if (bot->pflags & PF_THOKKED && flymode == 1 + && !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; + player->pflags &= ~PF_JUMPED; + } + } + // Read player inputs + else if (flymode == 2) + { + cmd->forwardmove = pcmd->forwardmove; + cmd->sidemove = pcmd->sidemove; + if (pcmd->buttons & BT_USE) + { + spin = true; + jump = false; + } + else if (!jump_last) + jump = true; + // End flymode + if (player->pflags & PF_JUMPED + || player->powers[pw_carry] != CR_PLAYER + || P_IsObjectOnGround(sonic)) + { + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&sonic->tracer, NULL); + flymode = 0; + } + } + } + + if (flymode && P_IsObjectOnGround(tails) && !(pcmd->buttons & BT_JUMP)) + flymode = 0; + + // ******** + // SPINNING + if (panic || flymode || !(player->pflags & PF_SPINNING) || (player->pflags & PF_JUMPED)) + spinmode = false; + else + { + if (!_2d) + { + // Spindash + if (player->dashspeed) + { + if (dist < followthres && dist > touchdist) // Do positioning + { + tails->angle = ang; + cmd->forwardmove = 50; + spinmode = true; + } + else if (dist < touchdist && !bmom + && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING))) + { + tails->angle = sonic->angle; + spin = true; + spinmode = true; + } + else + spinmode = 0; + } + // Spin + else if (player->dashspeed == bot->dashspeed && player->pflags & PF_SPINNING) + { + if (bot->pflags & PF_SPINNING || !spin_last) + { + spin = true; + tails->angle = sonic->angle; + cmd->forwardmove = MAXPLMOVE; + spinmode = true; + } + else + spinmode = false; + } + } + // 2D mode + else + { + if ((player->dashspeed && !bmom) || (player->dashspeed == bot->dashspeed && player->pflags & PF_SPINNING)) + { + spin = true; + spinmode = true; + } + } + } + + // ******** + // FOLLOW + if (!(flymode || spinmode)) + { + // Too far + if (panic || dist > followthres) + { + if (!_2d) + cmd->forwardmove = MAXPLMOVE; + else if (sonic->x > tails->x) + cmd->sidemove = MAXPLMOVE; + else + cmd->sidemove = -MAXPLMOVE; + } + // Within threshold + else if (!panic && dist > followmin && abs(zdist) < 192*scale) + { + if (!_2d) + cmd->forwardmove = FixedHypot(pcmd->forwardmove, pcmd->sidemove); + else + cmd->sidemove = pcmd->sidemove; + } + // Below min + else if (dist < followmin) + { + // Copy inputs + tails->angle = sonic->angle; + bot->drawangle = player->drawangle; + cmd->forwardmove = 8 * pcmd->forwardmove / 10; + cmd->sidemove = 8 * pcmd->sidemove / 10; + } + } + + // ******** + // JUMP + if (!(flymode || spinmode)) + { + // Flying catch-up + if (bot->pflags & PF_THOKKED) + { + cmd->forwardmove = min(50, dist/scale/8); + if (zdist < -64*scale) + spin = true; + else if (zdist > 0 && !jump_last) + jump = true; + } + + // Just landed + if (tails->eflags & MFE_JUSTHITFLOOR) + jump = false; + // Start jump + else if (!jump_last && !(bot->pflags & PF_JUMPED) && !(player->pflags & PF_SPINNING) + && ((zdist > 32*scale && player->pflags & PF_JUMPED) // Following + || (zdist > 64*scale && panic) // Vertical catch-up + || (bmom < scale>>3 && dist > followthres && !(bot->powers[pw_carry])) // Stopped & not in carry state + || (bot->pflags & PF_SPINNING && !(bot->pflags & PF_JUMPED)))) // Spinning + jump = true; + // Hold jump + else if (bot->pflags & PF_JUMPED && jump_last && tails->momz*flip > 0 && (zdist > 0 || panic)) jump = true; - if (sonic->floorz > tails->floorz) // He's still above us? Jump HIGHER, then! + // Start flying + else if (bot->pflags & PF_JUMPED && panic && !jump_last) jump = true; } - - // Decide when to spin - if (sonic->player->pflags & PF_STARTDASH - && (tails->player->pflags & PF_STARTDASH || (P_AproxDistance(tails->momx, tails->momy) < 2*FRACUNIT && !forward))) - spin = true; + + // ******** + // HISTORY + jump_last = jump; + spin_last = spin; + + // ******** + // Thinkfly overlay + // doing this later :P // Turn the virtual keypresses into ticcmd_t. B_KeysToTiccmd(tails, cmd, forward, backward, left, right, false, false, jump, spin); @@ -188,6 +421,13 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward cmd->sidemove -= MAXPLMOVE<>16; if (straferight) cmd->sidemove += MAXPLMOVE<>16; + + // cap inputs so the bot can't accelerate faster diagonally + angle_t angle = R_PointToAngle2(0, 0, cmd->sidemove << FRACBITS, cmd->forwardmove << FRACBITS); + INT32 maxforward = abs(P_ReturnThrustY(NULL, angle, MAXPLMOVE)); + INT32 maxside = abs(P_ReturnThrustX(NULL, angle, MAXPLMOVE)); + cmd->forwardmove = max(min(cmd->forwardmove, maxforward), -maxforward); + cmd->sidemove = max(min(cmd->sidemove, maxside), -maxside); } if (jump) cmd->buttons |= BT_JUMP; From b120193eb72ea66112e5a70c3b6a6c87d5a53056 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sat, 5 Oct 2019 02:48:20 +0800 Subject: [PATCH 02/22] Fix AI angling --- src/b_bot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 02ac6d1bc..be1d9dd60 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -114,11 +114,11 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm // Orientation if ((bot->pflags & (PF_SPINNING|PF_STARTDASH)) || flymode == 2) { - tails->angle = sonic->angle; + cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; } else { - tails->angle = ang; + cmd->angleturn = (ang - tails->angle) >> FRACBITS; } // ******** @@ -219,14 +219,14 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm { if (dist < followthres && dist > touchdist) // Do positioning { - tails->angle = ang; + cmd->angleturn = (ang - tails->angle) >> FRACBITS; cmd->forwardmove = 50; spinmode = true; } else if (dist < touchdist && !bmom && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING))) { - tails->angle = sonic->angle; + cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; spin = true; spinmode = true; } @@ -239,7 +239,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm if (bot->pflags & PF_SPINNING || !spin_last) { spin = true; - tails->angle = sonic->angle; + cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; cmd->forwardmove = MAXPLMOVE; spinmode = true; } @@ -284,7 +284,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm else if (dist < followmin) { // Copy inputs - tails->angle = sonic->angle; + cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; bot->drawangle = player->drawangle; cmd->forwardmove = 8 * pcmd->forwardmove / 10; cmd->sidemove = 8 * pcmd->sidemove / 10; From b180fd7c91110295eaef89ad33962f5aa60fb7bc Mon Sep 17 00:00:00 2001 From: lachwright Date: Sat, 5 Oct 2019 03:02:27 +0800 Subject: [PATCH 03/22] Update to 9/25 Lua script --- src/b_bot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index be1d9dd60..7d6732365 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -223,11 +223,13 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm cmd->forwardmove = 50; spinmode = true; } - else if (dist < touchdist && !bmom - && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING))) + else if (dist < touchdist) { - cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; - spin = true; + if (!bmom && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING))) + { + cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; + spin = true; + } spinmode = true; } else From 800052a746a953f3f05ee13c6429b5a0589073ab Mon Sep 17 00:00:00 2001 From: lachwright Date: Wed, 6 Nov 2019 13:59:53 +0800 Subject: [PATCH 04/22] WIP update to latest version of Lua script, halted because script inconsistencies still exist --- src/b_bot.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index fdccd08a4..e4c3a2110 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -36,24 +36,25 @@ static mobj_t *overlay; 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; - + player_t *player = sonic->player, *bot = tails->player; ticcmd_t *pcmd = &player->cmd; boolean water = tails->eflags & MFE_UNDERWATER; boolean flip = P_MobjFlip(tails); boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel; fixed_t scale = tails->scale; - + fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y); fixed_t zdist = flip * (sonic->z - tails->z); angle_t ang = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y); fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy); fixed_t bmom = P_AproxDistance(tails->momx, tails->momy); - fixed_t followmax = 128 * 8 *scale; - fixed_t followthres = 92 * scale; + fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state + fixed_t followthres = 92 * scale; // Distance that AI will try to reach fixed_t followmin = 32 * scale; fixed_t comfortheight = 96 * scale; fixed_t touchdist = 24 * scale; + boolean stalled = (bmom < scale >> 1) && dist > followthres; // Helps to see if the AI is having trouble catching up // We can't follow Sonic if he's not around! if (!sonic || sonic->health <= 0) @@ -83,7 +84,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm } // Adapted from CobaltBW's tails_AI.wad - + // Check water if (water) { @@ -92,14 +93,14 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm followmax >>= 1; thinkfly = false; } - + // Check anxiety if (spinmode) { anxiety = 0; panic = false; } - else if (dist > followmax || zdist > comfortheight) + else if (dist > followmax || zdist > comfortheight || stalled) { anxiety = min(anxiety + 2, 70); if (anxiety >= 70) @@ -110,7 +111,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm anxiety = max(anxiety - 1, 0); panic = false; } - + // Orientation if ((bot->pflags & (PF_SPINNING|PF_STARTDASH)) || flymode == 2) { @@ -120,7 +121,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm { cmd->angleturn = (ang - tails->angle) >> FRACBITS; } - + // ******** // FLY MODE // spinmode check @@ -141,7 +142,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm } } } - + // Check positioning // Thinker for co-op flight if (!(water || pmom || bmom) From b721c035f8e30891c73a844319547a44fc93adbc Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 05:23:59 +0800 Subject: [PATCH 05/22] Add Dragonbomber enemy --- src/dehacked.c | 26 ++++++++ src/hardware/hw_light.c | 1 + src/info.c | 128 ++++++++++++++++++++++++++++++++++++++++ src/info.h | 27 +++++++++ src/p_enemy.c | 102 ++++++++++++++++++++++++++++++++ src/p_inter.c | 11 ++++ src/p_mobj.c | 77 ++++++++++++++++++++++++ 7 files changed, 372 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index fff9dbee8..5e29c8def 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2781,6 +2781,9 @@ static actionpointer_t actionpointers[] = {{A_PterabyteHover}, "A_PTERABYTEHOVER"}, {{A_RolloutSpawn}, "A_ROLLOUTSPAWN"}, {{A_RolloutRock}, "A_ROLLOUTROCK"}, + {{A_DragonbomberSpawn}, "A_DRAGONBOMERSPAWN"}, + {{A_DragonWing}, "A_DRAGONWING"}, + {{A_DragonSegment}, "A_DRAGONSEGMENT"}, {{NULL}, "NONE"}, // This NULL entry must be the last in the list @@ -5041,6 +5044,25 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_PTERABYTE_SWOOPDOWN", "S_PTERABYTE_SWOOPUP", + // Dragonbomber + "S_DRAGONBOMBER", + "S_DRAGONWING1", + "S_DRAGONWING2", + "S_DRAGONWING3", + "S_DRAGONWING4", + "S_DRAGONTAIL_LOADED", + "S_DRAGONTAIL_EMPTY", + "S_DRAGONTAIL_EMPTYLOOP", + "S_DRAGONTAIL_RELOAD", + "S_DRAGONMINE", + "S_DRAGONMINE_LAND", + "S_DRAGONMINE_GROUND1", + "S_DRAGONMINE_FLASH1", + "S_DRAGONMINE_LOOP1", + "S_DRAGONMINE_GROUND2", + "S_DRAGONMINE_FLASH2", + "S_DRAGONMINE_LOOP2", + // Boss Explosion "S_BOSSEXPLODE", @@ -7712,6 +7734,10 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_PTERABYTESPAWNER", // Pterabyte spawner "MT_PTERABYTEWAYPOINT", // Pterabyte waypoint "MT_PTERABYTE", // Pterabyte + "MT_DRAGONBOMBER", // Dragonbomber + "MT_DRAGONWING", // Dragonbomber wing + "MT_DRAGONTAIL", // Dragonbomber tail segment + "MT_DRAGONMINE", // Dragonbomber mine // Generic Boss Items "MT_BOSSEXPLODE", diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 491cb739f..8cd8143eb 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -184,6 +184,7 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_CANG &lspr[NOLIGHT], // SPR_PYRE &lspr[NOLIGHT], // SPR_PTER + &lspr[NOLIGHT], // SPR_DRAB // Generic Boos Items &lspr[JETLIGHT_L], // SPR_JETF // Boss jet fumes diff --git a/src/info.c b/src/info.c index ed29fe2bf..52b04f4a0 100644 --- a/src/info.c +++ b/src/info.c @@ -72,6 +72,7 @@ char sprnames[NUMSPRITES + 1][5] = "CANG", // Canarivore gas "PYRE", // Pyre Fly "PTER", // Pterabyte + "DRAB", // Dragonbomber // Generic Boss Items "JETF", // Boss jet fumes @@ -1163,6 +1164,25 @@ state_t states[NUMSTATES] = {SPR_PTER, 4, 1, {NULL}, 0, 0, S_PTERABYTE_SWOOPDOWN}, // S_PTERABYTE_SWOOPDOWN {SPR_PTER, 0, 1, {NULL}, 0, 0, S_PTERABYTE_SWOOPUP}, // S_PTERABYTE_SWOOPUP + // Dragonbomber + {SPR_DRAB, 0, -1, {A_DragonbomberSpawn}, 6, 0, S_NULL}, // S_DRAGONBOMBER + {SPR_DRAB, FF_PAPERSPRITE|7, 1, {A_DragonWing}, 0, 0, S_DRAGONWING2}, // S_DRAGONWING1 + {SPR_DRAB, FF_PAPERSPRITE|8, 1, {A_DragonWing}, 0, 0, S_DRAGONWING3}, // S_DRAGONWING2 + {SPR_DRAB, FF_PAPERSPRITE|9, 1, {A_DragonWing}, 0, 0, S_DRAGONWING4}, // S_DRAGONWING3 + {SPR_DRAB, FF_PAPERSPRITE|10, 1, {A_DragonWing}, 0, 0, S_DRAGONWING1}, // S_DRAGONWING4 + {SPR_DRAB, 1, 1, {A_DragonSegment}, 0, 0, S_DRAGONTAIL_LOADED}, // S_DRAGONTAIL_LOADED + {SPR_DRAB, 2, 1, {A_DragonSegment}, 0, 0, S_DRAGONTAIL_EMPTYLOOP}, // S_DRAGONTAIL_EMPTY + {SPR_DRAB, 2, 0, {A_Repeat}, 3*TICRATE, S_DRAGONTAIL_EMPTY, S_DRAGONTAIL_RELOAD}, // S_DRAGONTAIL_EMPTYLOOP + {SPR_DRAB, 1, 0, {A_PlayActiveSound}, 0, 0, S_DRAGONTAIL_LOADED}, // S_DRAGONTAIL_RELOAD + {SPR_DRAB, 3, 1, {A_MinusCheck}, S_DRAGONMINE_LAND, 0, S_DRAGONMINE}, // S_DRAGONMINE + {SPR_DRAB, 4, 2, {A_PlayActiveSound}, 0, 0, S_DRAGONMINE_GROUND1}, // S_DRAGONMINE_LAND + {SPR_DRAB, 5, 11, {NULL}, 0, 0, S_DRAGONMINE_FLASH1}, // S_DRAGONMINE_GROUND1 + {SPR_DRAB, FF_FULLBRIGHT|6, 1, {A_PlayAttackSound}, 0, 0, S_DRAGONMINE_LOOP1}, // S_DRAGONMINE_FLASH1 + {SPR_DRAB, 5, 0, {A_Repeat}, 4, S_DRAGONMINE_GROUND1, S_DRAGONMINE_GROUND2}, // S_DRAGONMINE_LOOP1 + {SPR_DRAB, 5, 3, {NULL}, 0, 0, S_DRAGONMINE_FLASH2}, // S_DRAGONMINE_GROUND2 + {SPR_DRAB, FF_FULLBRIGHT|6, 1, {A_PlayAttackSound}, 0, 0, S_DRAGONMINE_LOOP2}, // S_DRAGONMINE_FLASH2 + {SPR_DRAB, 5, 0, {A_Repeat}, 5, S_DRAGONMINE_GROUND2, S_DEATHSTATE}, // S_DRAGONMINE_LOOP2 + // Boss Explosion {SPR_BOM2, FF_FULLBRIGHT|FF_ANIMATE, (5*7), {NULL}, 6, 5, S_NULL}, // S_BOSSEXPLODE @@ -5238,6 +5258,114 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_DRAGONBOMBER + 137, // doomednum + S_DRAGONBOMBER, // spawnstate + 1, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 6, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_XPLD_FLICKY, // deathstate + S_NULL, // xdeathstate + sfx_pop, // deathsound + 10*FRACUNIT, // speed + 28*FRACUNIT, // radius + 48*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_SPECIAL|MF_SHOOTABLE|MF_ENEMY|MF_NOGRAVITY|MF_BOUNCE|MF_RUNSPAWNFUNC, // flags + S_NULL // raisestate + }, + + { // MT_DRAGONWING + -1, // doomednum + S_DRAGONWING1, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_XPLD_FLICKY, // deathstate + S_NULL, // xdeathstate + sfx_pop, // deathsound + 0, // speed + 12*FRACUNIT, // radius + 12*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_NOGRAVITY|MF_SCENERY|MF_NOBLOCKMAP|MF_NOCLIP, // flags + S_NULL // raisestate + }, + + { // MT_DRAGONTAIL + -1, // doomednum + S_DRAGONTAIL_LOADED, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + MT_DRAGONMINE, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_XPLD1, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 20*FRACUNIT, // radius + 40*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_tink, // activesound + MF_NOGRAVITY|MF_SLIDEME|MF_PAIN, // flags + S_DRAGONTAIL_EMPTY // raisestate + }, + + { // MT_DRAGONMINE + -1, // doomednum + S_DRAGONMINE, // spawnstate + 1, // spawnhealth + S_NULL, // seestate + sfx_s3k76, // seesound + 0, // reactiontime + sfx_s3k89, // attacksound + S_NULL, // painstate + 6, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_TNTBARREL_EXPL1, // deathstate + S_NULL, // xdeathstate + sfx_s3k6e, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_s3k5d, // activesound + MF_SPECIAL|MF_SHOOTABLE, // flags + S_NULL // raisestate + }, + { // MT_BOSSEXPLODE -1, // doomednum S_BOSSEXPLODE, // spawnstate diff --git a/src/info.h b/src/info.h index bbb6a21fc..7838b4f71 100644 --- a/src/info.h +++ b/src/info.h @@ -282,6 +282,9 @@ void A_SpawnPterabytes(); void A_PterabyteHover(); void A_RolloutSpawn(); void A_RolloutRock(); +void A_DragonbomberSpawn(); +void A_DragonWing(); +void A_DragonSegment(); // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 #define NUMMOBJFREESLOTS 512 @@ -334,6 +337,7 @@ typedef enum sprite SPR_CANG, // Canarivore gas SPR_PYRE, // Pyre Fly SPR_PTER, // Pterabyte + SPR_DRAB, // Dragonbomber // Generic Boss Items SPR_JETF, // Boss jet fumes @@ -1355,6 +1359,25 @@ typedef enum state S_PTERABYTE_SWOOPDOWN, S_PTERABYTE_SWOOPUP, + // Dragonbomber + S_DRAGONBOMBER, + S_DRAGONWING1, + S_DRAGONWING2, + S_DRAGONWING3, + S_DRAGONWING4, + S_DRAGONTAIL_LOADED, + S_DRAGONTAIL_EMPTY, + S_DRAGONTAIL_EMPTYLOOP, + S_DRAGONTAIL_RELOAD, + S_DRAGONMINE, + S_DRAGONMINE_LAND, + S_DRAGONMINE_GROUND1, + S_DRAGONMINE_FLASH1, + S_DRAGONMINE_LOOP1, + S_DRAGONMINE_GROUND2, + S_DRAGONMINE_FLASH2, + S_DRAGONMINE_LOOP2, + // Boss Explosion S_BOSSEXPLODE, @@ -4049,6 +4072,10 @@ typedef enum mobj_type MT_PTERABYTESPAWNER, // Pterabyte spawner MT_PTERABYTEWAYPOINT, // Pterabyte waypoint MT_PTERABYTE, // Pterabyte + MT_DRAGONBOMBER, // Dragonbomber + MT_DRAGONWING, // Dragonbomber wing + MT_DRAGONTAIL, // Dragonbomber tail segment + MT_DRAGONMINE, // Dragonbomber mine // Generic Boss Items MT_BOSSEXPLODE, diff --git a/src/p_enemy.c b/src/p_enemy.c index eedbecaa7..18da9c7e6 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -312,6 +312,9 @@ void A_SpawnPterabytes(mobj_t *actor); void A_PterabyteHover(mobj_t *actor); void A_RolloutSpawn(mobj_t *actor); void A_RolloutRock(mobj_t *actor); +void A_DragonbomberSpawn(mobj_t *actor); +void A_DragonWing(mobj_t *actor); +void A_DragonSegment(mobj_t *actor); //for p_enemy.c @@ -14597,3 +14600,102 @@ void A_RolloutRock(mobj_t *actor) actor->flags2 ^= MF2_DONTDRAW; } + +// Function: A_DragonbomberSpawn +// +// Description: Spawns the body parts for Dragonbomber +// +// var1 = Tail segments to spawn +// var2 = unused +// +void A_DragonbomberSpawn(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + UINT8 i; + mobj_t *mo = actor; + + #ifdef HAVE_BLUA + if (LUA_CallAction("A_DragonbomberSpawn", actor)) + return; + #endif + + for (i = 0; i < var1; i++) // spawn tail segments + { + mobj_t *segment; + fixed_t x, y; + x = P_ReturnThrustX(mo, mo->angle, -mo->radius << 1); + y = P_ReturnThrustY(mo, mo->angle, -mo->radius << 1); + segment = P_SpawnMobjFromMobj(mo, x, y, 0, MT_DRAGONTAIL); + P_SetTarget(&segment->target, mo); + P_SetTarget(&mo->tracer, segment); + segment->angle = mo->angle; + mo = segment; + } + for (i = 0; i < 2; i++) // spawn wings + { + mo = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_DRAGONWING); + P_SetTarget(&mo->target, actor); + mo->movedir = ANGLE_90 + i * ANGLE_180; + } +} + +// Function: A_DragonWing +// +// Description: Moves actor such that it is placed away from its target at a distance equal to the target's radius in the direction of its target's angle. +// The actor's movedir can be used to offset the angle. +// +// var1 = unused +// var2 = unused +// +void A_DragonWing(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + mobj_t *target = actor->target; + fixed_t x, y; + + #ifdef HAVE_BLUA + if (LUA_CallAction("A_DragonSegment", actor)) + return; + #endif + + if (target == NULL || !target->health) + { + P_RemoveMobj(actor); + return; + } + actor->angle = target->angle + actor->movedir; + x = target->x + P_ReturnThrustX(actor, actor->angle, -target->radius); + y = target->y + P_ReturnThrustY(actor, actor->angle, -target->radius); + P_TeleportMove(actor, x, y, target->z); +} + +// Function: A_DragonSegment +// +// Description: Moves actor such that it is placed away from its target at an absolute distance equal to the sum of the two mobjs' radii. +// +// var1 = unused +// var2 = unused +// +void A_DragonSegment(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + mobj_t *target = actor->target; + fixed_t dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z); + fixed_t radius = actor->radius + target->radius; + angle_t hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y); + angle_t zangle = R_PointToAngle2(0, target->z, dist, actor->z); + fixed_t hdist = P_ReturnThrustX(target, zangle, radius); + fixed_t xdist = P_ReturnThrustX(target, hangle, hdist); + fixed_t ydist = P_ReturnThrustY(target, hangle, hdist); + fixed_t zdist = P_ReturnThrustY(target, zangle, radius); + + #ifdef HAVE_BLUA + if (LUA_CallAction("A_DragonSegment", actor)) + return; + #endif + + P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist); +} \ No newline at end of file diff --git a/src/p_inter.c b/src/p_inter.c index b0a401b10..7da987815 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2678,6 +2678,17 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget target->flags = (target->flags|MF_NOCLIPHEIGHT) & ~MF_NOGRAVITY; break; + case MT_DRAGONBOMBER: + { + mobj_t *segment = target; + while (segment->tracer != NULL) + { + P_KillMobj(segment->tracer, NULL, NULL, 0); + segment = segment->tracer; + } + break; + } + case MT_EGGMOBILE3: { mobj_t *mo2; diff --git a/src/p_mobj.c b/src/p_mobj.c index 5d6a8a10f..dd960f5ad 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9622,6 +9622,83 @@ void P_MobjThinker(mobj_t *mobj) } break; } + case MT_DRAGONBOMBER: + { +#define DRAGONTURNSPEED ANG2 + mobj->movecount = (mobj->movecount + 9) % 360; + P_SetObjectMomZ(mobj, 4*FINESINE(((mobj->movecount*ANG1) >> ANGLETOFINESHIFT) & FINEMASK), false); + if (mobj->threshold > 0) // are we dropping mines? + { + mobj->threshold--; + if (mobj->threshold == 0) // if the timer hits 0, look for a mine to drop! + { + mobj_t *segment = mobj; + while (segment->tracer != NULL && segment->tracer->state == &states[segment->tracer->info->spawnstate]) + { + segment = segment->tracer; + } + if (segment != mobj) // found an unactivated segment? + { + mobj_t *mine = P_SpawnMobjFromMobj(segment, 0, 0, 0, segment->info->painchance); + mine->angle = segment->angle; + P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy)); + P_SetObjectMomZ(mine, -2*FRACUNIT, true); + S_StartSound(mine, mine->info->seesound); + P_SetMobjState(segment, segment->info->raisestate); + mobj->threshold = mobj->info->painchance; + } + } + } + if (mobj->target != NULL) // Are we chasing a player? + { + CONS_Printf("%s\n", "Chase state"); + fixed_t dist = P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y); + if (dist > 2000 * mobj->scale) // Not anymore! + P_SetTarget(&mobj->target, NULL); + else + { + fixed_t vspeed = FixedMul(mobj->info->speed >> 3, mobj->scale); + fixed_t z = mobj->target->z + (mobj->height >> 1) + (mobj->flags & MFE_VERTICALFLIP ? -128*mobj->scale : 128*mobj->scale + mobj->target->height); + angle_t diff = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y) - mobj->angle; + if (diff > ANGLE_180) + mobj->angle -= DRAGONTURNSPEED; + else + mobj->angle += DRAGONTURNSPEED; + if (!mobj->threshold && dist < 512 * mobj->scale) // Close enough to drop bombs + { + mobj->threshold = mobj->info->painchance; + } + mobj->momz += max(min(z - mobj->z, vspeed), -vspeed); + } + } + else // Can we find a player to chase? + { + CONS_Printf("%s\n", "Search state"); + if (mobj->tracer == NULL || mobj->tracer->state != &states[mobj->tracer->info->spawnstate] + || !P_LookForPlayers(mobj, true, false, 2000*mobj->scale)) // if not, circle around the spawnpoint + { + if (!mobj->spawnpoint) // unless we don't have one, in which case uhhh just circle around wherever we currently are I guess?? + mobj->angle += DRAGONTURNSPEED; + else + { + fixed_t vspeed = FixedMul(mobj->info->speed >> 3, mobj->scale); + fixed_t x = mobj->spawnpoint->x << FRACBITS; + fixed_t y = mobj->spawnpoint->y << FRACBITS; + fixed_t z = mobj->spawnpoint->z << FRACBITS; + fixed_t dist = P_AproxDistance(mobj->x - x, mobj->y - y); + angle_t diff = R_PointToAngle2(mobj->x, mobj->y, x, y) - mobj->angle; + if (diff > ANGLE_180) + mobj->angle -= DRAGONTURNSPEED; + else + mobj->angle += DRAGONTURNSPEED; + mobj->momz += max(min(z - mobj->z, vspeed), -vspeed); + } + } + } + P_InstaThrust(mobj, mobj->angle, FixedMul(mobj->info->speed, mobj->scale)); +#undef DRAGONTURNSPEED + } + break; case MT_SPINFIRE: if (mobj->flags & MF_NOGRAVITY) { From 5cafed5c7202bb6562cf2902ce7c7e663d50d91f Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 05:30:14 +0800 Subject: [PATCH 06/22] Make rollout rocks more friendly --- src/p_map.c | 1 - src/p_user.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index bb56a50b1..53ca81335 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1020,7 +1020,6 @@ static boolean PIT_CheckThing(mobj_t *thing) if ((thing->flags & MF_PUSHABLE) // not carrying a player && (tmthing->player->powers[pw_carry] == CR_NONE) // player is not already riding something && ((tmthing->eflags & MFE_VERTICALFLIP) == (thing->eflags & MFE_VERTICALFLIP)) - && (P_AproxDistance(thing->x - tmthing->x, thing->y - tmthing->y) < (thing->radius)) && (P_MobjFlip(tmthing)*tmthing->momz <= 0) && ((!(tmthing->eflags & MFE_VERTICALFLIP) && abs(thing->z + thing->height - tmthing->z) < (thing->height>>2)) || (tmthing->eflags & MFE_VERTICALFLIP && abs(tmthing->z + tmthing->height - thing->z) < (thing->height>>2)))) diff --git a/src/p_user.c b/src/p_user.c index 3c481e7e2..d8afd2bd5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4391,7 +4391,7 @@ void P_DoJump(player_t *player, boolean soundandstate) } else if (player->powers[pw_carry] == CR_ROLLOUT) { - player->mo->momz = 9*FRACUNIT + player->mo->tracer->momz; + player->mo->momz = 9*FRACUNIT; player->powers[pw_carry] = CR_NONE; player->mo->tracer->flags |= MF_PUSHABLE; P_SetTarget(&player->mo->tracer->tracer, NULL); From cf53e255eb009c03d19bda215a876ace2c1bc811 Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 05:31:26 +0800 Subject: [PATCH 07/22] Remove tester console prints --- src/p_mobj.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index dd960f5ad..a76dd7e4c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9651,7 +9651,6 @@ void P_MobjThinker(mobj_t *mobj) } if (mobj->target != NULL) // Are we chasing a player? { - CONS_Printf("%s\n", "Chase state"); fixed_t dist = P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y); if (dist > 2000 * mobj->scale) // Not anymore! P_SetTarget(&mobj->target, NULL); @@ -9673,7 +9672,6 @@ void P_MobjThinker(mobj_t *mobj) } else // Can we find a player to chase? { - CONS_Printf("%s\n", "Search state"); if (mobj->tracer == NULL || mobj->tracer->state != &states[mobj->tracer->info->spawnstate] || !P_LookForPlayers(mobj, true, false, 2000*mobj->scale)) // if not, circle around the spawnpoint { From ac7d07c9da1c6d556f5cfc63f70b32d2484eab9c Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 10:35:56 +0800 Subject: [PATCH 08/22] Prevent mines from sliding upon touching the ground --- src/dehacked.c | 15 ++++++++------- src/info.c | 33 +++++++++++++++++---------------- src/info.h | 15 ++++++++------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 5e29c8def..9a96945c5 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5055,13 +5055,14 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_DRAGONTAIL_EMPTYLOOP", "S_DRAGONTAIL_RELOAD", "S_DRAGONMINE", - "S_DRAGONMINE_LAND", - "S_DRAGONMINE_GROUND1", - "S_DRAGONMINE_FLASH1", - "S_DRAGONMINE_LOOP1", - "S_DRAGONMINE_GROUND2", - "S_DRAGONMINE_FLASH2", - "S_DRAGONMINE_LOOP2", + "S_DRAGONMINE_LAND1", + "S_DRAGONMINE_LAND2", + "S_DRAGONMINE_SLOWFLASH1", + "S_DRAGONMINE_SLOWFLASH2", + "S_DRAGONMINE_SLOWLOOP", + "S_DRAGONMINE_FASTFLASH1", + "S_DRAGONMINE_FASTFLASH2", + "S_DRAGONMINE_FASTLOOP", // Boss Explosion "S_BOSSEXPLODE", diff --git a/src/info.c b/src/info.c index 52b04f4a0..6124dc14e 100644 --- a/src/info.c +++ b/src/info.c @@ -1165,23 +1165,24 @@ state_t states[NUMSTATES] = {SPR_PTER, 0, 1, {NULL}, 0, 0, S_PTERABYTE_SWOOPUP}, // S_PTERABYTE_SWOOPUP // Dragonbomber - {SPR_DRAB, 0, -1, {A_DragonbomberSpawn}, 6, 0, S_NULL}, // S_DRAGONBOMBER - {SPR_DRAB, FF_PAPERSPRITE|7, 1, {A_DragonWing}, 0, 0, S_DRAGONWING2}, // S_DRAGONWING1 - {SPR_DRAB, FF_PAPERSPRITE|8, 1, {A_DragonWing}, 0, 0, S_DRAGONWING3}, // S_DRAGONWING2 - {SPR_DRAB, FF_PAPERSPRITE|9, 1, {A_DragonWing}, 0, 0, S_DRAGONWING4}, // S_DRAGONWING3 - {SPR_DRAB, FF_PAPERSPRITE|10, 1, {A_DragonWing}, 0, 0, S_DRAGONWING1}, // S_DRAGONWING4 - {SPR_DRAB, 1, 1, {A_DragonSegment}, 0, 0, S_DRAGONTAIL_LOADED}, // S_DRAGONTAIL_LOADED - {SPR_DRAB, 2, 1, {A_DragonSegment}, 0, 0, S_DRAGONTAIL_EMPTYLOOP}, // S_DRAGONTAIL_EMPTY + {SPR_DRAB, 0, -1, {A_DragonbomberSpawn}, 6, 0, S_NULL}, // S_DRAGONBOMBER + {SPR_DRAB, FF_PAPERSPRITE|7, 1, {A_DragonWing}, 0, 0, S_DRAGONWING2}, // S_DRAGONWING1 + {SPR_DRAB, FF_PAPERSPRITE|8, 1, {A_DragonWing}, 0, 0, S_DRAGONWING3}, // S_DRAGONWING2 + {SPR_DRAB, FF_PAPERSPRITE|9, 1, {A_DragonWing}, 0, 0, S_DRAGONWING4}, // S_DRAGONWING3 + {SPR_DRAB, FF_PAPERSPRITE|10, 1, {A_DragonWing}, 0, 0, S_DRAGONWING1}, // S_DRAGONWING4 + {SPR_DRAB, 1, 1, {A_DragonSegment}, 0, 0, S_DRAGONTAIL_LOADED}, // S_DRAGONTAIL_LOADED + {SPR_DRAB, 2, 1, {A_DragonSegment}, 0, 0, S_DRAGONTAIL_EMPTYLOOP}, // S_DRAGONTAIL_EMPTY {SPR_DRAB, 2, 0, {A_Repeat}, 3*TICRATE, S_DRAGONTAIL_EMPTY, S_DRAGONTAIL_RELOAD}, // S_DRAGONTAIL_EMPTYLOOP - {SPR_DRAB, 1, 0, {A_PlayActiveSound}, 0, 0, S_DRAGONTAIL_LOADED}, // S_DRAGONTAIL_RELOAD - {SPR_DRAB, 3, 1, {A_MinusCheck}, S_DRAGONMINE_LAND, 0, S_DRAGONMINE}, // S_DRAGONMINE - {SPR_DRAB, 4, 2, {A_PlayActiveSound}, 0, 0, S_DRAGONMINE_GROUND1}, // S_DRAGONMINE_LAND - {SPR_DRAB, 5, 11, {NULL}, 0, 0, S_DRAGONMINE_FLASH1}, // S_DRAGONMINE_GROUND1 - {SPR_DRAB, FF_FULLBRIGHT|6, 1, {A_PlayAttackSound}, 0, 0, S_DRAGONMINE_LOOP1}, // S_DRAGONMINE_FLASH1 - {SPR_DRAB, 5, 0, {A_Repeat}, 4, S_DRAGONMINE_GROUND1, S_DRAGONMINE_GROUND2}, // S_DRAGONMINE_LOOP1 - {SPR_DRAB, 5, 3, {NULL}, 0, 0, S_DRAGONMINE_FLASH2}, // S_DRAGONMINE_GROUND2 - {SPR_DRAB, FF_FULLBRIGHT|6, 1, {A_PlayAttackSound}, 0, 0, S_DRAGONMINE_LOOP2}, // S_DRAGONMINE_FLASH2 - {SPR_DRAB, 5, 0, {A_Repeat}, 5, S_DRAGONMINE_GROUND2, S_DEATHSTATE}, // S_DRAGONMINE_LOOP2 + {SPR_DRAB, 1, 0, {A_PlayActiveSound}, 0, 0, S_DRAGONTAIL_LOADED}, // S_DRAGONTAIL_RELOAD + {SPR_DRAB, 3, 1, {A_MinusCheck}, S_DRAGONMINE_LAND1, 0, S_DRAGONMINE}, // S_DRAGONMINE + {SPR_DRAB, 4, 0, {A_PlayActiveSound}, 0, 0, S_DRAGONMINE_LAND2}, // S_DRAGONMINE_LAND1 + {SPR_DRAB, 4, 2, {A_Thrust}, 0, 1, S_DRAGONMINE_SLOWFLASH1}, // S_DRAGONMINE_LAND2 + {SPR_DRAB, 5, 11, {NULL}, 0, 0, S_DRAGONMINE_SLOWFLASH2}, // S_DRAGONMINE_SLOWFLASH1 + {SPR_DRAB, FF_FULLBRIGHT|6, 1, {A_PlayAttackSound}, 0, 0, S_DRAGONMINE_SLOWLOOP}, // S_DRAGONMINE_SLOWFLASH2 + {SPR_DRAB, 5, 0, {A_Repeat}, 4, S_DRAGONMINE_SLOWFLASH1, S_DRAGONMINE_FASTFLASH1}, // S_DRAGONMINE_SLOWLOOP + {SPR_DRAB, 5, 3, {NULL}, 0, 0, S_DRAGONMINE_FASTFLASH2}, // S_DRAGONMINE_FASTFLASH1 + {SPR_DRAB, FF_FULLBRIGHT|6, 1, {A_PlayAttackSound}, 0, 0, S_DRAGONMINE_FASTLOOP}, // S_DRAGONMINE_FASTFLASH2 + {SPR_DRAB, 5, 0, {A_Repeat}, 5, S_DRAGONMINE_FASTFLASH1, S_DEATHSTATE}, // S_DRAGONMINE_FASTLOOP // Boss Explosion {SPR_BOM2, FF_FULLBRIGHT|FF_ANIMATE, (5*7), {NULL}, 6, 5, S_NULL}, // S_BOSSEXPLODE diff --git a/src/info.h b/src/info.h index 7838b4f71..03494dd62 100644 --- a/src/info.h +++ b/src/info.h @@ -1370,13 +1370,14 @@ typedef enum state S_DRAGONTAIL_EMPTYLOOP, S_DRAGONTAIL_RELOAD, S_DRAGONMINE, - S_DRAGONMINE_LAND, - S_DRAGONMINE_GROUND1, - S_DRAGONMINE_FLASH1, - S_DRAGONMINE_LOOP1, - S_DRAGONMINE_GROUND2, - S_DRAGONMINE_FLASH2, - S_DRAGONMINE_LOOP2, + S_DRAGONMINE_LAND1, + S_DRAGONMINE_LAND2, + S_DRAGONMINE_SLOWFLASH1, + S_DRAGONMINE_SLOWFLASH2, + S_DRAGONMINE_SLOWLOOP, + S_DRAGONMINE_FASTFLASH1, + S_DRAGONMINE_FASTFLASH2, + S_DRAGONMINE_FASTLOOP, // Boss Explosion S_BOSSEXPLODE, From bf4dbead748acbc66b4abefa5891f31419314f31 Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 11:22:27 +0800 Subject: [PATCH 09/22] Update to latest script version --- src/b_bot.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index e4c3a2110..fd70f88c2 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -153,7 +153,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm thinkfly = true; else thinkfly = false; - + // Ready for takeoff if (flymode == 1) { @@ -180,7 +180,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm player->pflags &= ~PF_JUMPED; } } - // Read player inputs + // Read player inputs while carrying else if (flymode == 2) { cmd->forwardmove = pcmd->forwardmove; @@ -203,10 +203,10 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm } } } - + if (flymode && P_IsObjectOnGround(tails) && !(pcmd->buttons & BT_JUMP)) flymode = 0; - + // ******** // SPINNING if (panic || flymode || !(player->pflags & PF_SPINNING) || (player->pflags & PF_JUMPED)) @@ -234,7 +234,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm spinmode = true; } else - spinmode = 0; + spinmode = false; } // Spin else if (player->dashspeed == bot->dashspeed && player->pflags & PF_SPINNING) @@ -253,14 +253,15 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm // 2D mode else { - if ((player->dashspeed && !bmom) || (player->dashspeed == bot->dashspeed && player->pflags & PF_SPINNING)) + if (((player->dashspeed && !bmom) || (player->dashspeed == bot->dashspeed && (player->pflags & PF_SPINNING))) + && ((bot->pflags & PF_SPINNING) || !spin_last)) { spin = true; spinmode = true; } } } - + // ******** // FOLLOW if (!(flymode || spinmode)) @@ -288,7 +289,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm { // Copy inputs cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; - bot->drawangle = player->drawangle; + bot->drawangle = ang; cmd->forwardmove = 8 * pcmd->forwardmove / 10; cmd->sidemove = 8 * pcmd->sidemove / 10; } @@ -301,21 +302,22 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm // Flying catch-up if (bot->pflags & PF_THOKKED) { - cmd->forwardmove = min(50, dist/scale/8); + cmd->forwardmove = min(MAXPLMOVE, (dist/scale)>>3); if (zdist < -64*scale) spin = true; else if (zdist > 0 && !jump_last) jump = true; } - + // Just landed if (tails->eflags & MFE_JUSTHITFLOOR) jump = false; // Start jump - else if (!jump_last && !(bot->pflags & PF_JUMPED) && !(player->pflags & PF_SPINNING) + else if (!jump_last && !(bot->pflags & PF_JUMPED) //&& !(player->pflags & PF_SPINNING) && ((zdist > 32*scale && player->pflags & PF_JUMPED) // Following || (zdist > 64*scale && panic) // Vertical catch-up - || (bmom < scale>>3 && dist > followthres && !(bot->powers[pw_carry])) // Stopped & not in carry state + || (stalled && anxiety > 20 && bot->powers[pw_carry] == CR_NONE) + //|| (bmom < scale>>3 && dist > followthres && !(bot->powers[pw_carry])) // Stopped & not in carry state || (bot->pflags & PF_SPINNING && !(bot->pflags & PF_JUMPED)))) // Spinning jump = true; // Hold jump @@ -325,12 +327,12 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm else if (bot->pflags & PF_JUMPED && panic && !jump_last) jump = true; } - + // ******** // HISTORY jump_last = jump; spin_last = spin; - + // ******** // Thinkfly overlay // doing this later :P From 52a24e0bc42a157e049dbb0e6dc453f6576cdc9c Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 13:30:07 +0800 Subject: [PATCH 10/22] Allow AI Tails to carry the player --- src/b_bot.c | 38 ++++++++++++++++++++------------------ src/p_map.c | 3 --- src/p_user.c | 7 +++++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index fd70f88c2..e1c3cf387 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -33,6 +33,17 @@ static boolean spinmode = false; static boolean thinkfly = false; 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) { 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) { jump = true; - if (bot->pflags & PF_JUMPED) - { - flymode = 1; - thinkfly = false; - } + flymode = 1; + 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; // Set carried state - if (bot->pflags & PF_THOKKED && flymode == 1 - && !P_IsObjectOnGround(sonic) - && dist < touchdist - && zdist < 32*scale - && flip * sonic->momz < 0) + if (player->powers[pw_carry] == CR_PLAYER && sonic->tracer == tails) { - P_SetTarget(&sonic->tracer, tails); - player->powers[pw_carry] = CR_PLAYER; flymode = 2; 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) jump = true; // End flymode - if (player->pflags & PF_JUMPED - || player->powers[pw_carry] != CR_PLAYER + if (player->powers[pw_carry] != CR_PLAYER || P_IsObjectOnGround(sonic)) { - player->powers[pw_carry] = CR_NONE; - P_SetTarget(&sonic->tracer, NULL); 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) { // 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; // Turn the virtual keypresses into ticcmd_t. 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 (sonic->player->pflags & (PF_GLIDING|PF_SLIDING|PF_BOUNCING) || (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; // Low ceiling, do not want! @@ -497,6 +497,8 @@ void B_RespawnBot(INT32 playernum) if (!sonic || sonic->health <= 0) return; + B_ResetAI(); + player->bot = 1; P_SpawnPlayer(playernum); tails = player->mo; diff --git a/src/p_map.c b/src/p_map.c index bb56a50b1..29ad6bcbc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -592,9 +592,6 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) if (!(tails->pflags & PF_CANCARRY)) return; - if (tails->bot == 1) - return; - if ((sonic->mo->eflags & MFE_VERTICALFLIP) != (tails->mo->eflags & MFE_VERTICALFLIP)) return; // Both should be in same gravity diff --git a/src/p_user.c b/src/p_user.c index 3c481e7e2..6b4de4598 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5295,7 +5295,10 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH); - player->pflags |= (PF_THOKKED|PF_CANCARRY); + if (player->bot == 1) + player->pflags |= PF_THOKKED; + else + player->pflags |= (PF_THOKKED|PF_CANCARRY); } break; case CA_GLIDEANDCLIMB: @@ -12276,7 +12279,7 @@ void P_PlayerAfterThink(player_t *player) player->mo->momz = tails->momz; } - if (gametype == GT_COOP) + if (gametype == GT_COOP && (!tails->player || tails->player->bot != 1)) { player->mo->angle = tails->angle; From 70051bd794e96b882ef5a23a2656321da9bce0eb Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 13:37:09 +0800 Subject: [PATCH 11/22] Don't let the bot decide to fly if it doesn't have the ability to fly --- src/b_bot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index e1c3cf387..ce7807321 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -158,7 +158,8 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm && (dist < touchdist) && !(pcmd->forwardmove || pcmd->sidemove || player->dashspeed) && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) - && !(player->pflags & PF_STASIS)) + && !(player->pflags & PF_STASIS) + && bot->charability == CA_FLY) thinkfly = true; else thinkfly = false; @@ -324,7 +325,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm else if (bot->pflags & PF_JUMPED && jump_last && tails->momz*flip > 0 && (zdist > 0 || panic)) jump = true; // Start flying - else if (bot->pflags & PF_JUMPED && panic && !jump_last) + else if (bot->pflags & PF_JUMPED && panic && !jump_last && bot->charability == CA_FLY) jump = true; } From bb67b24143da5b9d4fd050ecb8f3cfba2abf39a6 Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 15:17:27 +0800 Subject: [PATCH 12/22] Add flight indicator --- src/b_bot.c | 15 ++++++++++++++- src/dehacked.c | 2 ++ src/hardware/hw_light.c | 1 + src/info.c | 4 ++++ src/info.h | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/b_bot.c b/src/b_bot.c index ce7807321..d3fc25aa6 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -336,7 +336,20 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm // ******** // Thinkfly overlay - // doing this later :P + if (thinkfly) + { + if (overlay == NULL) + { + overlay = P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY); + P_SetTarget(&overlay->target, tails); + P_SetMobjState(overlay, S_FLIGHTINDICATOR); + } + } + else if (overlay != NULL) + { + P_RemoveMobj(overlay); + overlay = NULL; + } // Turn the virtual keypresses into ticcmd_t. B_KeysToTiccmd(tails, cmd, forward, backward, left, right, false, false, jump, spin); diff --git a/src/dehacked.c b/src/dehacked.c index fff9dbee8..cce596289 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7139,6 +7139,8 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_FOUR2", "S_FIVE2", + "S_FLIGHTINDICATOR", + "S_LOCKON1", "S_LOCKON2", "S_LOCKON3", diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 491cb739f..09545f28f 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -505,6 +505,7 @@ light_t *t_lspr[NUMSPRITES] = // Game Indicators &lspr[NOLIGHT], // SPR_SCOR &lspr[NOLIGHT], // SPR_DRWN + &lspr[NOLIGHT], // SPR_FLII &lspr[NOLIGHT], // SPR_LCKN &lspr[NOLIGHT], // SPR_TTAG &lspr[NOLIGHT], // SPR_GFLG diff --git a/src/info.c b/src/info.c index ed29fe2bf..125babd7d 100644 --- a/src/info.c +++ b/src/info.c @@ -402,6 +402,7 @@ char sprnames[NUMSPRITES + 1][5] = // Game Indicators "SCOR", // Score logo "DRWN", // Drowning Timer + "FLII", // Flight indicator "LCKN", // Target "TTAG", // Tag Sign "GFLG", // Got Flag sign @@ -3319,6 +3320,9 @@ state_t states[NUMSTATES] = {SPR_DRWN, 10, 40, {NULL}, 0, 0, S_NULL}, // S_FOUR2 {SPR_DRWN, 11, 40, {NULL}, 0, 0, S_NULL}, // S_FIVE2 + // Flight indicator + {SPR_FLII, FF_FULLBRIGHT|FF_ANIMATE|0, -1, {NULL}, 4, 4, S_NULL}, // S_FLIGHTINDICATOR + {SPR_LCKN, FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_NULL}, // S_LOCKON1 {SPR_LCKN, 1|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_NULL}, // S_LOCKON2 {SPR_LCKN, 2|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_NULL}, // S_LOCKON3 diff --git a/src/info.h b/src/info.h index bbb6a21fc..16e535384 100644 --- a/src/info.h +++ b/src/info.h @@ -664,6 +664,7 @@ typedef enum sprite // Game Indicators SPR_SCOR, // Score logo SPR_DRWN, // Drowning Timer + SPR_FLII, // AI flight indicator SPR_LCKN, // Target SPR_TTAG, // Tag Sign SPR_GFLG, // Got Flag sign @@ -3454,6 +3455,8 @@ typedef enum state S_FOUR2, S_FIVE2, + S_FLIGHTINDICATOR, + S_LOCKON1, S_LOCKON2, S_LOCKON3, From f682de3f1b429c38cf8db428bb6ee2528075a4bb Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 15:55:55 +0800 Subject: [PATCH 13/22] Fix controllable flight ending when player hits the ground while being carried by Tailsbot --- src/b_bot.c | 4 +--- src/p_user.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index d3fc25aa6..0740dba4e 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -181,7 +181,6 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm if (player->powers[pw_carry] == CR_PLAYER && sonic->tracer == tails) { flymode = 2; - player->pflags &= ~PF_JUMPED; } } // Read player inputs while carrying @@ -197,8 +196,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm else if (!jump_last) jump = true; // End flymode - if (player->powers[pw_carry] != CR_PLAYER - || P_IsObjectOnGround(sonic)) + if (player->powers[pw_carry] != CR_PLAYER) { flymode = 0; } diff --git a/src/p_user.c b/src/p_user.c index 6b4de4598..837d7d75c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8367,7 +8367,7 @@ static void P_MovePlayer(player_t *player) // Tails Put-Put noise if (player->charability == CA_FLY - && player->bot != 1 + && (player->pflags & PF_CANCARRY) && !(player->mo->eflags & MFE_UNDERWATER) && leveltime % 10 == 0 && !player->spectator) From 280d151d76af04cc8118c3ce20a851885d787e76 Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 22:36:25 +0800 Subject: [PATCH 14/22] Allow positive momentum retention when jumping off rollout rocks --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index d8afd2bd5..305e167b1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4392,6 +4392,8 @@ void P_DoJump(player_t *player, boolean soundandstate) else if (player->powers[pw_carry] == CR_ROLLOUT) { player->mo->momz = 9*FRACUNIT; + if (P_MobjFlip(player->mo->tracer)*player->mo->tracer->momz > 0) + player->mo->momz += player->mo->tracer->momz; player->powers[pw_carry] = CR_NONE; player->mo->tracer->flags |= MF_PUSHABLE; P_SetTarget(&player->mo->tracer->tracer, NULL); From f786a8dbf63b1dec51550070466e7742de68f9fb Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 18 Nov 2019 22:57:26 +0800 Subject: [PATCH 15/22] Important fixes & mine lob speed reduction --- src/p_enemy.c | 3 ++- src/p_mobj.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 18da9c7e6..32695fcae 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -14656,7 +14656,7 @@ void A_DragonWing(mobj_t *actor) fixed_t x, y; #ifdef HAVE_BLUA - if (LUA_CallAction("A_DragonSegment", actor)) + if (LUA_CallAction("A_DragonWing", actor)) return; #endif @@ -14697,5 +14697,6 @@ void A_DragonSegment(mobj_t *actor) return; #endif + actor->angle = hangle; P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist); } \ No newline at end of file diff --git a/src/p_mobj.c b/src/p_mobj.c index a76dd7e4c..dbba83c8a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9633,7 +9633,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->threshold == 0) // if the timer hits 0, look for a mine to drop! { mobj_t *segment = mobj; - while (segment->tracer != NULL && segment->tracer->state == &states[segment->tracer->info->spawnstate]) + while (segment->tracer != NULL && !P_MobjWasRemoved(segment->tracer) && segment->tracer->state == &states[segment->tracer->info->spawnstate]) { segment = segment->tracer; } @@ -9641,7 +9641,7 @@ void P_MobjThinker(mobj_t *mobj) { mobj_t *mine = P_SpawnMobjFromMobj(segment, 0, 0, 0, segment->info->painchance); mine->angle = segment->angle; - P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy)); + P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy) >> 1); P_SetObjectMomZ(mine, -2*FRACUNIT, true); S_StartSound(mine, mine->info->seesound); P_SetMobjState(segment, segment->info->raisestate); From 508fdb493b08d9938f15044f3c88f8c93ee2f4a8 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 18 Nov 2019 19:22:51 +0000 Subject: [PATCH 16/22] compilation fixes (no review yet, currently just about to have dinner) --- src/b_bot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 0740dba4e..badc36b27 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -33,7 +33,7 @@ static boolean spinmode = false; static boolean thinkfly = false; static mobj_t *overlay; -static inline void B_ResetAI() +static inline void B_ResetAI(void) { jump_last = false; spin_last = false; @@ -429,6 +429,7 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward cmd->sidemove += MAXPLMOVE<>16; } } else { + angle_t angle; if (forward) cmd->forwardmove += MAXPLMOVE<>16; if (backward) @@ -443,7 +444,7 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward cmd->sidemove += MAXPLMOVE<>16; // cap inputs so the bot can't accelerate faster diagonally - angle_t angle = R_PointToAngle2(0, 0, cmd->sidemove << FRACBITS, cmd->forwardmove << FRACBITS); + angle = R_PointToAngle2(0, 0, cmd->sidemove << FRACBITS, cmd->forwardmove << FRACBITS); INT32 maxforward = abs(P_ReturnThrustY(NULL, angle, MAXPLMOVE)); INT32 maxside = abs(P_ReturnThrustX(NULL, angle, MAXPLMOVE)); cmd->forwardmove = max(min(cmd->forwardmove, maxforward), -maxforward); From eefc285b5c3ffa9aaa2947018afe360d43f9d440 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 18 Nov 2019 15:48:29 -0800 Subject: [PATCH 17/22] locvars not needed --- src/p_enemy.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index a77c2a5ec..ea09533df 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -14606,8 +14606,6 @@ void A_RolloutRock(mobj_t *actor) // void A_DragonbomberSpawn(mobj_t *actor) { - INT32 locvar1 = var1; - INT32 locvar2 = var2; UINT8 i; mobj_t *mo = actor; @@ -14646,8 +14644,6 @@ void A_DragonbomberSpawn(mobj_t *actor) // void A_DragonWing(mobj_t *actor) { - INT32 locvar1 = var1; - INT32 locvar2 = var2; mobj_t *target = actor->target; fixed_t x, y; @@ -14676,8 +14672,6 @@ void A_DragonWing(mobj_t *actor) // void A_DragonSegment(mobj_t *actor) { - INT32 locvar1 = var1; - INT32 locvar2 = var2; mobj_t *target = actor->target; fixed_t dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z); fixed_t radius = actor->radius + target->radius; @@ -14695,4 +14689,4 @@ void A_DragonSegment(mobj_t *actor) actor->angle = hangle; P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist); -} \ No newline at end of file +} From 1febf8cb4b67108b85b8fad4e20ffe24e5d8d541 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 18 Nov 2019 15:52:14 -0800 Subject: [PATCH 18/22] Mixed code... --- src/b_bot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index badc36b27..0b3d08168 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -445,10 +445,12 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward // cap inputs so the bot can't accelerate faster diagonally angle = R_PointToAngle2(0, 0, cmd->sidemove << FRACBITS, cmd->forwardmove << FRACBITS); - INT32 maxforward = abs(P_ReturnThrustY(NULL, angle, MAXPLMOVE)); - INT32 maxside = abs(P_ReturnThrustX(NULL, angle, MAXPLMOVE)); - cmd->forwardmove = max(min(cmd->forwardmove, maxforward), -maxforward); - cmd->sidemove = max(min(cmd->sidemove, maxside), -maxside); + { + INT32 maxforward = abs(P_ReturnThrustY(NULL, angle, MAXPLMOVE)); + INT32 maxside = abs(P_ReturnThrustX(NULL, angle, MAXPLMOVE)); + cmd->forwardmove = max(min(cmd->forwardmove, maxforward), -maxforward); + cmd->sidemove = max(min(cmd->sidemove, maxside), -maxside); + } } if (jump) cmd->buttons |= BT_JUMP; From f3e66f7b5899dcd1b9d13bb3bdd16e1fa1ca278d Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 18 Nov 2019 15:53:30 -0800 Subject: [PATCH 19/22] dist is unused --- src/p_mobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index b9770809e..cbd6c3c7f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9693,7 +9693,6 @@ void P_MobjThinker(mobj_t *mobj) fixed_t x = mobj->spawnpoint->x << FRACBITS; fixed_t y = mobj->spawnpoint->y << FRACBITS; fixed_t z = mobj->spawnpoint->z << FRACBITS; - fixed_t dist = P_AproxDistance(mobj->x - x, mobj->y - y); angle_t diff = R_PointToAngle2(mobj->x, mobj->y, x, y) - mobj->angle; if (diff > ANGLE_180) mobj->angle -= DRAGONTURNSPEED; From 1db9e312a6ce59546d15064ed49a3a63da07fb43 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 18 Nov 2019 15:55:21 -0800 Subject: [PATCH 20/22] P_MobjFlip does not return boolean --- src/b_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/b_bot.c b/src/b_bot.c index 0b3d08168..12cdc36a0 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -51,7 +51,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm player_t *player = sonic->player, *bot = tails->player; ticcmd_t *pcmd = &player->cmd; boolean water = tails->eflags & MFE_UNDERWATER; - boolean flip = P_MobjFlip(tails); + SINT8 flip = P_MobjFlip(tails); boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel; fixed_t scale = tails->scale; From 2ac44240db77c0d6aa52855083f272be592aab22 Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 19 Nov 2019 12:59:01 +0000 Subject: [PATCH 21/22] Fix the coords of the subtitle. --- src/st_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 4e8afa16a..42a89aab6 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1335,7 +1335,7 @@ void ST_drawTitleCard(void) V_DrawLevelTitle(lvlttlxpos - ttlscroll, 80, V_PERPLAYER, lvlttl); if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) V_DrawLevelTitle(zonexpos + ttlscroll, 104, V_PERPLAYER, M_GetText("Zone")); - V_DrawCenteredString(subttlxpos - ttlnumxpos, 128, V_PERPLAYER|V_ALLOWLOWERCASE, subttl); + V_DrawCenteredString(subttlxpos - ttlscroll, 135, V_PERPLAYER|V_ALLOWLOWERCASE, subttl); lt_lasttic = lt_ticker; From 3add9a9bd257d1d32b6739e393ca7faa5dbb6a0a Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 19 Nov 2019 13:00:10 +0000 Subject: [PATCH 22/22] Make the SPEEDING OFF TO ZONE text that appears while loading: * Use a mixed case "Zone" to match the mixed case level titles. * Have V_TRANSLUCENT to not stick out too much against pure black/white backgrounds. (Can revert this aspect if necessary, but I think you'll agree it's a good balance between readable and aesthetic.) --- src/p_setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index bc0829670..e87a088d8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2805,12 +2805,12 @@ boolean P_SetupLevel(boolean skipprecip) { // Don't include these in the fade! char tx[64]; - V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); + V_DrawSmallString(1, 191, V_ALLOWLOWERCASE|V_TRANSLUCENT, M_GetText("Speeding off to...")); snprintf(tx, 63, "%s%s%s", mapheaderinfo[gamemap-1]->lvlttl, - (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE", - (mapheaderinfo[gamemap-1]->actnum > 0) ? va(", Act %d",mapheaderinfo[gamemap-1]->actnum) : ""); - V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); + (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone", + (mapheaderinfo[gamemap-1]->actnum > 0) ? va("%d",mapheaderinfo[gamemap-1]->actnum) : ""); + V_DrawSmallString(1, 195, V_ALLOWLOWERCASE|V_TRANSLUCENT, tx); I_UpdateNoVsync(); }