From 59fccab8e50aa4cc2227952e6af35357dd625d3d Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 20 Oct 2016 20:55:15 +0100 Subject: [PATCH] Restructured things so nojumpdamage characters can use the elemental, bubblewrap and attract shields. --- src/d_player.h | 5 ++++- src/lua_hook.h | 2 ++ src/lua_hooklib.c | 1 + src/p_inter.c | 6 +++--- src/p_map.c | 8 ++++---- src/p_mobj.c | 4 +++- src/p_user.c | 14 ++++++++++++-- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index e5e296f17..4f9833fa0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -154,7 +154,10 @@ typedef enum PF_CANCARRY = 1<<27, // Used shield ability - PF_SHIELDABILITY = 1<<28 + PF_SHIELDABILITY = 1<<28, + + // Do jump damage? + PF_JUMPDAMAGE = 1<<29 // free up to and including 1<<31 } pflags_t; diff --git a/src/lua_hook.h b/src/lua_hook.h index bed32edac..e0f08d175 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -43,6 +43,7 @@ enum hook { hook_PlayerMsg, hook_HurtMsg, hook_PlayerSpawn, + hook_ShieldSpawn, hook_MAX // last hook }; @@ -77,5 +78,6 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer +#define LUAh_ShieldSpawn(player) LUAh_PlayerHook(player, hook_ShieldSpawn) // Hook for P_SpawnShieldOrb #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1b9652571..1065f193a 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -54,6 +54,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerMsg", "HurtMsg", "PlayerSpawn", + "ShieldSpawn", NULL }; diff --git a/src/p_inter.c b/src/p_inter.c index e3523d29d..ddbac5ed3 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -306,7 +306,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || ((player->pflags & PF_JUMPED) && !(player->charflags & SF_NOJUMPDAMAGE && !(player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) + || ((player->pflags & PF_JUMPED) && (player->pflags & PF_JUMPDAMAGE || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) || (player->pflags & (PF_SPINNING|PF_GLIDING)) || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) || ((player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)) @@ -353,7 +353,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_DamageMobj(toucher, special, special, 1, 0); } else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || ((player->pflags & PF_JUMPED) && !(player->charflags & SF_NOJUMPDAMAGE && !(player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) + || ((player->pflags & PF_JUMPED) && (player->pflags & PF_JUMPDAMAGE || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) || (player->pflags & (PF_SPINNING|PF_GLIDING)) || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) || ((player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)) @@ -1346,7 +1346,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; } else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || ((player->pflags & PF_JUMPED) && !(player->charflags & SF_NOJUMPDAMAGE)) + || ((player->pflags & PF_JUMPED) && (player->pflags & PF_JUMPDAMAGE || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) || ((player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)) || (player->pflags & (PF_SPINNING|PF_GLIDING)) || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? diff --git a/src/p_map.c b/src/p_map.c index 6c4ea979a..d924ad564 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1058,8 +1058,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->flags & MF_MONITOR && (tmthing->player->pflags & (PF_SPINNING|PF_GLIDING) || ((tmthing->player->pflags & PF_JUMPED) - && !(tmthing->player->charflags & SF_NOJUMPDAMAGE - && !(tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY))) + && (tmthing->player->pflags & PF_JUMPDAMAGE + || (tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY))) || (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2) || ((tmthing->player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(tmthing)*(tmthing->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(tmthing)*tmthing->momz < 0)) @@ -1093,8 +1093,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (thing->flags & MF_MONITOR && tmthing->player && (tmthing->player->pflags & (PF_SPINNING|PF_GLIDING) || ((tmthing->player->pflags & PF_JUMPED) - && !(tmthing->player->charflags & SF_NOJUMPDAMAGE - && !(tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY))) + && (tmthing->player->pflags & PF_JUMPDAMAGE + || (tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY))) || (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2) || ((tmthing->player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(tmthing)*(tmthing->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(tmthing)*tmthing->momz < 0))) diff --git a/src/p_mobj.c b/src/p_mobj.c index 77952c269..40683a991 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3233,7 +3233,7 @@ static void P_PlayerZMovement(mobj_t *mo) mo->player->pflags &= ~PF_SPINNING; if (!(mo->player->pflags & PF_GLIDING)) - mo->player->pflags &= ~PF_JUMPED; + mo->player->pflags &= ~(PF_JUMPED|PF_JUMPDAMAGE); mo->player->pflags &= ~(PF_THOKKED|PF_CANCARRY/*|PF_GLIDING*/); mo->player->secondjump = 0; @@ -3267,6 +3267,8 @@ static void P_PlayerZMovement(mobj_t *mo) { S_StartSound(mo, sfx_s3k44); P_DoJump(mo->player, false); + if (mo->player->charflags & SF_NOJUMPSPIN) + P_SetPlayerMobjState(mo, S_PLAY_FALL); mo->player->pflags |= PF_THOKKED; mo->player->secondjump = UINT8_MAX; mo->momz = FixedMul(mo->momz, 5*FRACUNIT/4); diff --git a/src/p_user.c b/src/p_user.c index 8b871f72b..1ddb7a25c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -877,7 +877,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) // Useful when you want to kill everything the player is doing. void P_ResetPlayer(player_t *player) { - player->pflags &= ~(PF_SPINNING|PF_STARTDASH|PF_JUMPED|PF_GLIDING|PF_THOKKED|PF_CANCARRY|PF_SHIELDABILITY); + player->pflags &= ~(PF_SPINNING|PF_STARTDASH|PF_JUMPED|PF_JUMPDAMAGE|PF_GLIDING|PF_THOKKED|PF_CANCARRY|PF_SHIELDABILITY); player->powers[pw_carry] = CR_NONE; player->jumping = 0; player->secondjump = 0; @@ -1338,6 +1338,11 @@ void P_SpawnShieldOrb(player_t *player) I_Error("P_SpawnShieldOrb: player->mo is NULL!\n"); #endif +#ifdef HAVE_BLUA + if (LUAh_ShieldSpawn(player)) + return; +#endif + if (player->powers[pw_shield] & SH_FORCE) orbtype = MT_FORCE_ORB; else switch (player->powers[pw_shield] & SH_NOSTACK) @@ -3761,6 +3766,8 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->eflags &= ~MFE_APPLYPMOMZ; player->pflags |= PF_JUMPED; + if (!(player->charflags & SF_NOJUMPDAMAGE)) + player->pflags |= PF_JUMPDAMAGE; if (soundandstate) { @@ -7039,6 +7046,8 @@ static void P_MovePlayer(player_t *player) player->homing = 2; if (P_LookForEnemies(player, false) && player->mo->tracer) { + player->pflags |= PF_JUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_SPIN); S_StartSound(player->mo, sfx_s3k40); player->homing = 3*TICRATE; } @@ -7048,7 +7057,8 @@ static void P_MovePlayer(player_t *player) // Elemental/Bubblewrap shield activation case SH_ELEMENTAL: case SH_BUBBLEWRAP: - player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + player->pflags |= PF_JUMPDAMAGE|PF_THOKKED|PF_SHIELDABILITY; + P_SetPlayerMobjState(player->mo, S_PLAY_SPIN); player->secondjump = 0; player->mo->momx = player->mo->momy = 0; P_SetObjectMomZ(player->mo, -24*FRACUNIT, false);