From 2c7a0c87c860bd66fd9b892369fef45728829949 Mon Sep 17 00:00:00 2001 From: jplebreton Date: Sat, 3 Jun 2017 08:42:57 -0700 Subject: [PATCH] add FloatBobStrength Actor property, a multiplier on Z offset created by FloatBob behavior. default of 1.0 is current behavior, set higher/lower for more/less extreme bobbing. --- src/actor.h | 1 + src/namedef.h | 1 + src/p_mobj.cpp | 4 +++- src/scripting/thingdef_properties.cpp | 9 +++++++++ wadsrc/static/zscript/actor.txt | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/actor.h b/src/actor.h index be3f28ec6..b1cf58676 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1169,6 +1169,7 @@ public: uint8_t smokecounter; uint8_t FloatBobPhase; + double FloatBobStrength; uint8_t FriendPlayer; // [RH] Player # + 1 this friendly monster works for (so 0 is no player, 1 is player 0, etc) PalEntry BloodColor; uint32_t BloodTranslation; diff --git a/src/namedef.h b/src/namedef.h index a22a5de5f..c2c23f497 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -503,6 +503,7 @@ xx(Scale) xx(ScaleX) xx(ScaleY) xx(Floatbobphase) +xx(Floatbobstrength) xx(Target) xx(Master) xx(Tracer) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 54be4a2de..fc0abc373 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -282,6 +282,7 @@ DEFINE_FIELD(AActor, Floorclip) DEFINE_FIELD(AActor, DamageType) DEFINE_FIELD(AActor, DamageTypeReceived) DEFINE_FIELD(AActor, FloatBobPhase) +DEFINE_FIELD(AActor, FloatBobStrength) DEFINE_FIELD(AActor, RipperLevel) DEFINE_FIELD(AActor, RipLevelMin) DEFINE_FIELD(AActor, RipLevelMax) @@ -443,6 +444,7 @@ void AActor::Serialize(FSerializer &arc) ("inventory", Inventory) A("inventoryid", InventoryID) A("floatbobphase", FloatBobPhase) + A("floatbobstrength", FloatBobStrength) A("translation", Translation) A("bloodcolor", BloodColor) A("bloodtranslation", BloodTranslation) @@ -7988,7 +7990,7 @@ double AActor::GetBobOffset(double ticfrac) const { return 0; } - return BobSin(FloatBobPhase + level.maptime + ticfrac); + return BobSin(FloatBobPhase + level.maptime + ticfrac) * FloatBobStrength; } DEFINE_ACTION_FUNCTION(AActor, GetBobOffset) diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 170fa1148..d10f50517 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -653,6 +653,15 @@ DEFINE_PROPERTY(floatbobphase, I, Actor) defaults->FloatBobPhase = id; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(floatbobstrength, F, Actor) +{ + PROP_DOUBLE_PARM(id, 0); + defaults->FloatBobStrength = id; +} + //========================================================================== // //========================================================================== diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 49d294465..3195f18cf 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -131,6 +131,7 @@ class Actor : Thinker native native name DamageType; native name DamageTypeReceived; native uint8 FloatBobPhase; + native double FloatBobStrength; native int RipperLevel; native int RipLevelMin; native int RipLevelMax; @@ -325,6 +326,7 @@ class Actor : Thinker native BounceCount -1; FloatSpeed 4; FloatBobPhase -1; // randomly initialize by default + FloatBobStrength 1.0; Gravity 1; Friction 1; DamageFactor 1.0; // damage multiplier as target of damage.