From 4a1f0ce91c658608cd0682a60d9d2385d0cb1c1a Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Wed, 27 May 2015 05:24:31 -0400 Subject: [PATCH] New attract shield active Homing attack when activating the attract shield while jumping. --- src/dehacked.c | 1 + src/info.c | 3 ++- src/info.h | 1 + src/lua_baselib.c | 3 ++- src/p_local.h | 2 +- src/p_mobj.c | 7 ++++++- src/p_user.c | 41 +++++++++++++++++++++++++++++++++++------ 7 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 227c48b69..31fb571c1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5375,6 +5375,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_MAGN10", "S_MAGN11", "S_MAGN12", + "S_MAGN13", "S_FORC1", "S_FORC2", diff --git a/src/info.c b/src/info.c index 775996092..58a652f82 100644 --- a/src/info.c +++ b/src/info.c @@ -1757,6 +1757,7 @@ state_t states[NUMSTATES] = {SPR_MAGN, FF_FULLBRIGHT|FF_TRANS40| 9, 2, {NULL}, 0, 0, S_MAGN11}, // S_MAGN10 {SPR_MAGN, FF_FULLBRIGHT|FF_TRANS40|10, 2, {NULL}, 0, 0, S_MAGN12}, // S_MAGN11 {SPR_MAGN, FF_FULLBRIGHT|FF_TRANS40|11, 2, {NULL}, 0, 0, S_MAGN1 }, // S_MAGN12 + {SPR_MAGN, FF_FULLBRIGHT|FF_TRANS10|12, 2, {NULL}, 0, 0, S_MAGN1 }, // S_MAGN13 {SPR_FORC, FF_TRANS50 , 3, {NULL}, 0, 0, S_FORC2 }, // S_FORC1 {SPR_FORC, FF_TRANS50|1, 3, {NULL}, 0, 0, S_FORC3 }, // S_FORC2 @@ -10365,7 +10366,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = sfx_None, // seesound 8, // reactiontime sfx_None, // attacksound - S_NULL, // painstate + S_MAGN13, // painstate SKINCOLOR_NONE, // painchance sfx_None, // painsound S_NULL, // meleestate diff --git a/src/info.h b/src/info.h index 44a3dd012..a6d5dbd3f 100644 --- a/src/info.h +++ b/src/info.h @@ -2262,6 +2262,7 @@ typedef enum state S_MAGN10, S_MAGN11, S_MAGN12, + S_MAGN13, S_FORC1, S_FORC2, diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9b0a34f17..9c09e726e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -791,10 +791,11 @@ static int lib_pReturnThrustY(lua_State *L) static int lib_pLookForEnemies(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean nonenemies = lua_opttrueboolean(L, 2); NOHUD if (!player) return LUA_ErrInvalid(L, "player_t"); - lua_pushboolean(L, P_LookForEnemies(player)); + lua_pushboolean(L, P_LookForEnemies(player, nonenemies)); return 1; } diff --git a/src/p_local.h b/src/p_local.h index 1e0a9e2eb..db10cdb1c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -164,7 +164,7 @@ fixed_t P_ReturnThrustX(mobj_t *mo, angle_t angle, fixed_t move); fixed_t P_ReturnThrustY(mobj_t *mo, angle_t angle, fixed_t move); void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); -boolean P_LookForEnemies(player_t *player); +boolean P_LookForEnemies(player_t *player, boolean nonenemies); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); void P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user boolean P_SuperReady(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 9565648c2..b79350092 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5608,12 +5608,17 @@ void P_MobjThinker(mobj_t *mobj) case MT_BLACKORB: case MT_WHITEORB: case MT_GREENORB: - case MT_YELLOWORB: case MT_BLUEORB: case MT_PITYORB: if (!P_AddShield(mobj)) return; break; + case MT_YELLOWORB: + if (!P_AddShield(mobj)) + return; + if (mobj->target->player->homing) + P_SetMobjState(mobj, mobj->info->painstate); + break; case MT_WATERDROP: P_SceneryCheckWater(mobj); if ((mobj->z <= mobj->floorz || mobj->z <= mobj->watertop) diff --git a/src/p_user.c b/src/p_user.c index 32dc8733f..ad0b7b76a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3971,7 +3971,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) if (player->charability == CA_HOMINGTHOK && !player->homing) { - if (P_LookForEnemies(player)) + if (P_LookForEnemies(player, true)) { if (player->mo->tracer) player->homing = 3*TICRATE; @@ -6792,6 +6792,17 @@ static void P_MovePlayer(player_t *player) if (!(player->powers[pw_super] || player->powers[pw_invulnerability])) P_BlackOw(player); } + // Attract shield activation + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + { + if (!(player->pflags & PF_THOKKED)) + { + player->pflags |= PF_THOKKED; + player->homing = 2; + if (P_LookForEnemies(player, false) && player->mo->tracer) + player->homing = 3*TICRATE; + } + } } // Super Sonic move if (player->charflags & SF_SUPER && player->powers[pw_super] && player->speed > FixedMul(5<mo->scale) @@ -6807,8 +6818,20 @@ static void P_MovePlayer(player_t *player) } } + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + { + if (player->homing && player->mo->tracer) + { + if (!(player->pflags & PF_JUMPED) + || player->mo->tracer->health <= 0 + || player->mo->tracer->flags2 & MF2_FRET) + player->homing = 0; + else + P_HomingAttack(player->mo, player->mo->tracer); + } + } // HOMING option. - if (player->charability == CA_HOMINGTHOK) + else if (player->charability == CA_HOMINGTHOK) { // If you've got a target, chase after it! if (player->homing && player->mo->tracer) @@ -7410,9 +7433,9 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) // // P_LookForEnemies // Looks for something you can hit - Used for homing attack -// Includes monitors and springs! +// If nonenemies is true, includes monitors and springs! // -boolean P_LookForEnemies(player_t *player) +boolean P_LookForEnemies(player_t *player, boolean nonenemies) { mobj_t *mo; thinker_t *think; @@ -7425,7 +7448,8 @@ boolean P_LookForEnemies(player_t *player) continue; // not a mobj thinker mo = (mobj_t *)think; - if (!(mo->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR|MF_SPRING))) + if ((nonenemies && !(mo->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR|MF_SPRING))) + || (!nonenemies && !(mo->flags & (MF_ENEMY|MF_BOSS)))) continue; // not a valid enemy if (mo->health <= 0) // dead @@ -7524,7 +7548,12 @@ void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target ns = FixedMul(source->info->speed, source->scale); } else if (source->player) - ns = FixedDiv(FixedMul(source->player->actionspd, source->scale), 3*FRACUNIT/2); + { + if (source->player->charability == CA_HOMINGTHOK) + ns = FixedDiv(FixedMul(source->player->actionspd, source->scale), 3*FRACUNIT/2); + else //if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + ns = FixedMul(80*FRACUNIT, source->scale); + } source->momx = FixedMul(FixedDiv(enemy->x - source->x, dist), ns); source->momy = FixedMul(FixedDiv(enemy->y - source->y, dist), ns);