Expose LandingSpeed to ZScript. This controls the minimum Z velocity from falling down that's needed to "squat" the player's view (defaults to -8).

This commit is contained in:
nashmuhandes 2024-03-13 05:30:35 +08:00 committed by Rachael Alexanderson
parent 730ef1a23a
commit 0d9855cfe7
4 changed files with 12 additions and 6 deletions

View file

@ -1369,6 +1369,9 @@ public:
int SpawnTime; int SpawnTime;
uint32_t SpawnOrder; uint32_t SpawnOrder;
// landing speed from a jump with normal gravity (squats the player's view)
// (note: this is put into AActor instead of the PlayerPawn because non-players also use the value)
double LandingSpeed;
// ThingIDs // ThingIDs
void SetTID (int newTID); void SetTID (int newTID);

View file

@ -391,7 +391,8 @@ void AActor::Serialize(FSerializer &arc)
A("lightlevel", LightLevel) A("lightlevel", LightLevel)
A("userlights", UserLights) A("userlights", UserLights)
A("WorldOffset", WorldOffset) A("WorldOffset", WorldOffset)
("modelData", modelData); ("modelData", modelData)
A("LandingSpeed", LandingSpeed);
SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain); SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain);
SerializeArgs(arc, "args", args, def->args, special); SerializeArgs(arc, "args", args, def->args, special);
@ -2584,11 +2585,9 @@ static void P_ZMovement (AActor *mo, double oldfloorz)
mo->SetZ(mo->floorz); mo->SetZ(mo->floorz);
if (mo->Vel.Z < 0) if (mo->Vel.Z < 0)
{ {
const double minvel = -8; // landing speed from a jump with normal gravity
// Spawn splashes, etc. // Spawn splashes, etc.
P_HitFloor (mo); P_HitFloor (mo);
if (mo->DamageType == NAME_Ice && mo->Vel.Z < minvel) if (mo->DamageType == NAME_Ice && mo->Vel.Z < mo->LandingSpeed)
{ {
mo->tics = 1; mo->tics = 1;
mo->Vel.Zero(); mo->Vel.Zero();
@ -2601,11 +2600,11 @@ static void P_ZMovement (AActor *mo, double oldfloorz)
} }
if (mo->player) if (mo->player)
{ {
if (mo->player->jumpTics < 0 || mo->Vel.Z < minvel) if (mo->player->jumpTics < 0 || mo->Vel.Z < mo->LandingSpeed)
{ // delay any jumping for a short while { // delay any jumping for a short while
mo->player->jumpTics = 7; mo->player->jumpTics = 7;
} }
if (mo->Vel.Z < minvel && !(mo->flags & MF_NOGRAVITY)) if (mo->Vel.Z < mo->LandingSpeed && !(mo->flags & MF_NOGRAVITY))
{ {
// Squat down. // Squat down.
// Decrease viewheight for a moment after hitting the ground (hard), // Decrease viewheight for a moment after hitting the ground (hard),

View file

@ -2126,6 +2126,7 @@ DEFINE_FIELD(AActor, ShadowAimFactor)
DEFINE_FIELD(AActor, ShadowPenaltyFactor) DEFINE_FIELD(AActor, ShadowPenaltyFactor)
DEFINE_FIELD(AActor, AutomapOffsets) DEFINE_FIELD(AActor, AutomapOffsets)
DEFINE_FIELD(AActor, Path) DEFINE_FIELD(AActor, Path)
DEFINE_FIELD(AActor, LandingSpeed)
DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing); DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing);
DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos); DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos);

View file

@ -262,6 +262,7 @@ class Actor : Thinker native
native uint freezetics; native uint freezetics;
native Vector2 AutomapOffsets; native Vector2 AutomapOffsets;
native Array<PathNode> Path; native Array<PathNode> Path;
native double LandingSpeed;
meta String Obituary; // Player was killed by this actor meta String Obituary; // Player was killed by this actor
meta String HitObituary; // Player was killed by this actor in melee meta String HitObituary; // Player was killed by this actor in melee
@ -367,6 +368,7 @@ class Actor : Thinker native
property ShadowAimFactor: ShadowAimFactor; property ShadowAimFactor: ShadowAimFactor;
property ShadowPenaltyFactor: ShadowPenaltyFactor; property ShadowPenaltyFactor: ShadowPenaltyFactor;
property AutomapOffsets : AutomapOffsets; property AutomapOffsets : AutomapOffsets;
property LandingSpeed: LandingSpeed;
// need some definition work first // need some definition work first
//FRenderStyle RenderStyle; //FRenderStyle RenderStyle;
@ -455,6 +457,7 @@ class Actor : Thinker native
RenderHidden 0; RenderHidden 0;
RenderRequired 0; RenderRequired 0;
FriendlySeeBlocks 10; // 10 (blocks) * 128 (one map unit block) FriendlySeeBlocks 10; // 10 (blocks) * 128 (one map unit block)
LandingSpeed -8; // landing speed from a jump with normal gravity (squats the player's view)
} }
// Functions // Functions