diff --git a/src/info.c b/src/info.c index 2374c8515..3b99615d3 100644 --- a/src/info.c +++ b/src/info.c @@ -2487,7 +2487,7 @@ state_t states[NUMSTATES] = // Rollout Rock {SPR_NULL, 0, 1, {A_RolloutSpawn}, 256*FRACUNIT, MT_ROLLOUTROCK, S_ROLLOUTSPAWN}, // S_ROLLOUTSPAWN - {SPR_PUMI, 0, 1, {A_RolloutRock}, 63*FRACUNIT/64, 6*FRACUNIT/10, S_ROLLOUTROCK}, // S_ROLLOUTROCK + {SPR_PUMI, 0, 1, {A_RolloutRock}, 63*FRACUNIT/64, 7*FRACUNIT/10, S_ROLLOUTROCK}, // S_ROLLOUTROCK // RVZ scenery {SPR_JPLA, FF_PAPERSPRITE, -1, {NULL}, 0, 0, S_NULL}, // S_BIGFERNLEAF @@ -12860,10 +12860,10 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound - 8, // reactiontime + 8, // reactiontime (sets number of frames the rock cycles through) sfx_None, // attacksound S_NULL, // painstate - 0, // painchance + 12*TICRATE, // painchance (sets how long an unridden rock should last before disappearing - set to 0 to disable) sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate diff --git a/src/p_enemy.c b/src/p_enemy.c index e6ca4f2f1..6792623d3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -13935,6 +13935,14 @@ void A_RolloutSpawn(mobj_t *actor) || P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1) { actor->target = P_SpawnMobj(actor->x, actor->y, actor->z, locvar2); + actor->target->flags2 |= (actor->flags2 & (MF2_AMBUSH | MF2_OBJECTFLIP)) | MF2_SLIDEPUSH; + actor->target->eflags |= (actor->eflags & MFE_VERTICALFLIP); + + if (actor->target->flags2 & MF2_AMBUSH) + { + actor->target->color = SKINCOLOR_SUPERRUST3; + actor->target->colorized = true; + } } } @@ -13955,59 +13963,45 @@ void A_RolloutRock(mobj_t *actor) return; #endif - UINT8 maxframes = actor->info->reactiontime; + UINT8 maxframes = actor->info->reactiontime; // number of frames the mobj cycles through fixed_t pi = (22*FRACUNIT/7); - fixed_t circumference = FixedMul(2 * pi, actor->radius); - fixed_t oldspeed = P_AproxDistance(actor->momx, actor->momy), newspeed, topspeed = actor->info->speed; + fixed_t circumference = FixedMul(2 * pi, actor->radius); // used to calculate when to change frame + fixed_t speed = P_AproxDistance(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); boolean inwater = actor->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER); - actor->friction = FRACUNIT; + actor->friction = FRACUNIT; // turns out riding on solids sucks, so let's just make it easier on ourselves - if (inwater) + if (inwater && !(actor->flags2 & MF2_AMBUSH)) // buoyancy in water (or lava) { - fixed_t height; - if (actor->eflags & MFE_VERTICALFLIP) - { - height = actor->waterbottom + (actor->height>>2); - if (actor->z + actor->height > height) - { - actor->z = height; - actor->momz = 0; - } - } - else - { - height = actor->watertop - (actor->height>>2); - if (actor->z < height) - { - actor->z = height; - actor->momz = 0; - } - } + actor->momz = FixedMul(actor->momz, locvar2); actor->momz += P_MobjFlip(actor) * FixedMul(locvar2, actor->scale); } - if (oldspeed > topspeed) + if (speed > topspeed) // cap speed { - actor->momx = FixedMul(FixedDiv(actor->momx, oldspeed), topspeed); - actor->momy = FixedMul(FixedDiv(actor->momy, oldspeed), topspeed); + actor->momx = FixedMul(FixedDiv(actor->momx, speed), topspeed); + actor->momy = FixedMul(FixedDiv(actor->momy, speed), topspeed); + } + + if (P_IsObjectOnGround(actor) || inwater) // apply drag to speed (compensates for lack of friction but also works in liquids) + { + actor->momx = FixedMul(actor->momx, locvar1); + actor->momy = FixedMul(actor->momy, locvar1); } - actor->momx = FixedMul(actor->momx, locvar1); - actor->momy = FixedMul(actor->momy, locvar1); + speed = P_AproxDistance(actor->momx, actor->momy); // recalculate speed for visual rolling - newspeed = P_AproxDistance(actor->momx, actor->momy); - - if (newspeed < actor->scale >> 1) + if (speed < actor->scale >> 1) // stop moving if speed is insignificant { actor->momx = 0; actor->momy = 0; } - else if (newspeed > actor->scale) + else if (speed > actor->scale) { - actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy); - actor->movefactor += newspeed; - if (actor->movefactor > circumference / maxframes) + actor->movecount = 1; // rock has moved; fuse should be set so we don't have a trillion rocks lying around + actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy); // set rock's angle to movement direction + actor->movefactor += speed; + if (actor->movefactor > circumference / maxframes) // if distance moved is enough to change frame, change it! { actor->reactiontime++; actor->reactiontime %= maxframes; @@ -14015,5 +14009,14 @@ void A_RolloutRock(mobj_t *actor) } } - actor->frame = actor->reactiontime % maxframes; + actor->frame = actor->reactiontime % maxframes; // set frame + + if (!(actor->flags & MF_PUSHABLE)) // if being ridden, don't disappear + actor->fuse = 0; + else if (!actor->fuse && actor->movecount == 1) // otherwise if rock has moved, set its fuse + actor->fuse = actor->info->painchance; + + if (actor->fuse && actor->fuse < 2*TICRATE) + actor->flags2 ^= MF2_DONTDRAW; + } diff --git a/src/p_map.c b/src/p_map.c index 719a637b4..e470de240 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -963,58 +963,59 @@ static boolean PIT_CheckThing(mobj_t *thing) P_DamageMobj(thing, tmthing, tmthing, 1, 0); } - if (thing->type == MT_ROLLOUTROCK) + if (thing->type == MT_ROLLOUTROCK && tmthing->player && tmthing->health) { - if (tmthing->player) + if (tmthing->player->powers[pw_carry] == CR_ROLLOUT) { - if (tmthing->player->powers[pw_carry] == CR_ROLLOUT) - { - return true; - } - if ((thing->flags & MF_PUSHABLE) // carrying a player - && ((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)))) - { - thing->flags &= ~MF_PUSHABLE; - P_SetTarget(&thing->target, tmthing); - P_ResetPlayer(tmthing->player); - P_SetPlayerMobjState(tmthing, S_PLAY_WALK); - tmthing->player->powers[pw_carry] = CR_ROLLOUT; - P_SetTarget(&tmthing->tracer, thing); - P_SetObjectMomZ(thing, tmthing->momz, true); - return false; - } + return true; } - else if (tmthing->type == thing->type) + 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)))) { - if (tmthing->z > thing->z + thing->height || thing->z > tmthing->z + tmthing->height) - return true; - - fixed_t tempmomx = thing->momx, tempmomy = thing->momy; - thing->momx = tmthing->momx; - thing->momy = tmthing->momy; - tmthing->momx = tempmomx; - tmthing->momy = tempmomy; + thing->flags &= ~MF_PUSHABLE; // prevent riding player from applying pushable movement logic + thing->flags2 &= ~MF2_DONTDRAW; // don't leave the rock invisible if it was flashing prior to boarding + P_SetTarget(&thing->tracer, tmthing); + P_ResetPlayer(tmthing->player); + P_SetPlayerMobjState(tmthing, S_PLAY_WALK); + tmthing->player->powers[pw_carry] = CR_ROLLOUT; + P_SetTarget(&tmthing->tracer, thing); + P_SetObjectMomZ(thing, tmthing->momz, true); + return true; } } else if (tmthing->type == MT_ROLLOUTROCK) { if (tmthing->z > thing->z + thing->height || thing->z > tmthing->z + tmthing->height || !thing->health) return true; + + if (thing == tmthing->tracer) // don't collide with rider + return true; - if (thing->flags & MF_SPRING) + if (thing->flags & MF_SPRING) // bounce on springs { P_DoSpring(thing, tmthing); return true; } - else if (thing->flags & MF_MONITOR && thing->flags & MF_SHOOTABLE && !(tmthing->flags & MF_PUSHABLE)) // carrying a player + else if ((thing->flags & (MF_MONITOR|MF_SHOOTABLE)) == (MF_MONITOR|MF_SHOOTABLE) && !(tmthing->flags & MF_PUSHABLE)) // pop monitors while carrying a player { - P_KillMobj(thing, tmthing, tmthing->target, 0); + P_KillMobj(thing, tmthing, tmthing->tracer, 0); return true; } + + if (thing->type == tmthing->type // bounce against other rollout rocks + && (tmthing->momx || tmthing->momy || thing->momx || thing->momy)) + { + fixed_t tempmomx = thing->momx, tempmomy = thing->momy; + thing->momx = tmthing->momx; + thing->momy = tmthing->momy; + tmthing->momx = tempmomx; + tmthing->momy = tempmomy; + } } if (thing->type == MT_PTERABYTE && tmthing->player) @@ -1660,8 +1661,8 @@ static boolean PIT_CheckThing(mobj_t *thing) } } - if ((!tmthing->player) && (thing->player)) - ; // no solid thing should ever be able to step up onto a player + if ((tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM) && (thing->player)) + ; // springs and gas jets should never be able to step up onto a player // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID diff --git a/src/p_user.c b/src/p_user.c index 9d6f3f643..5bfb24df4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1036,7 +1036,7 @@ void P_ResetPlayer(player_t *player) if (player->mo->tracer && !P_MobjWasRemoved(player->mo->tracer)) { player->mo->tracer->flags |= MF_PUSHABLE; - P_SetTarget(&player->mo->tracer->target, NULL); + P_SetTarget(&player->mo->tracer->tracer, NULL); } P_SetTarget(&player->mo->tracer, NULL); player->powers[pw_carry] = CR_NONE; @@ -4321,7 +4321,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->momz = 9*FRACUNIT + player->mo->tracer->momz; player->powers[pw_carry] = CR_NONE; player->mo->tracer->flags |= MF_PUSHABLE; - P_SetTarget(&player->mo->tracer->target, NULL); + P_SetTarget(&player->mo->tracer->tracer, NULL); P_SetTarget(&player->mo->tracer, NULL); } else if (player->mo->eflags & MFE_GOOWATER) @@ -11919,6 +11919,11 @@ void P_PlayerAfterThink(player_t *player) mo->momx = rock->momx; mo->momy = rock->momy; mo->momz = 0; + + if (player->panim == PA_IDLE && (mo->momx || mo->momy)) + { + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + } if (player->panim == PA_WALK && mo->tics > walktics) {