diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 793cd5e2a..0976991f1 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -13,6 +13,12 @@ January 15, 2007 - Added a GTK+ version of the IWAD selection dialog box. That brings the Linux port one step closer to feature parity with the Windows version. +January 15, 2007 (Changes by Graf Zahl) +- added Grubber's submission for customizable gravity per actor. + +January 14, 2007 (Changes by Graf Zahl) +- Fixed: A_Jump didn't work for weapons or CustomInventory items. + January 13, 2007 (Changes by Graf Zahl) - Adjusted AlterWeaponSprite so that it properly handles multiple invisibility powerups at the same time. diff --git a/src/actor.h b/src/actor.h index 888d7b182..b9e86a88b 100644 --- a/src/actor.h +++ b/src/actor.h @@ -154,7 +154,6 @@ enum // --- mobj.flags2 --- - MF2_LOGRAV = 0x00000001, // alternate gravity setting MF2_WINDTHRUST = 0x00000002, // gets pushed around by the wind specials MF2_BOUNCE1 = 0x00000004, MF2_BLASTED = 0x00000008, // actor will temporarily take damage from impact @@ -683,6 +682,7 @@ public: fixed_t meleerange; fixed_t bouncefactor; // Strife's grenades use 50%, Hexen's Flechettes 70. int bouncecount; // Strife's grenades only bounce twice before exploding + fixed_t gravity; // [GRB] Gravity factor // a linked list of sectors where this object appears struct msecnode_s *touching_sectorlist; // phares 3/14/98 diff --git a/src/codepointers.h b/src/codepointers.h index b3edadd25..79cf805f9 100644 --- a/src/codepointers.h +++ b/src/codepointers.h @@ -96,6 +96,7 @@ ACTOR(Respawn) ACTOR(BarrelDestroy) ACTOR(PlayerSkinCheck) ACTOR(QueueCorpse) +ACTOR(SetGravity) // Special code pointers for Strife's player - not to be used elsewhere! ACTOR(ItBurnsItBurns) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 622c2253c..d87d274b9 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1000,6 +1000,11 @@ static int PatchThing (int thingy) info->DamageType = NAME_Fire; info->flags2 &= ~0x10000; } + if (info->flags2 & 1) + { + info->gravity = FRACUNIT/4; + info->flags2 &= ~1; + } } if (vchanged[2]) { diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index a854f6a4a..fb554d2ea 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -142,8 +142,9 @@ IMPLEMENT_ACTOR (AChickenPlayer, Heretic, -1, 0) PROP_HeightFixed (24) PROP_PainChance (255) PROP_SpeedFixed (1) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_NOTDMATCH|MF_FRIENDLY) - PROP_Flags2 (MF2_WINDTHRUST|MF2_SLIDE|MF2_PASSMOBJ|MF2_PUSHWALL|MF2_FLOORCLIP|MF2_LOGRAV|MF2_TELESTOMP) + PROP_Flags2 (MF2_WINDTHRUST|MF2_SLIDE|MF2_PASSMOBJ|MF2_PUSHWALL|MF2_FLOORCLIP|MF2_TELESTOMP) PROP_Flags3 (MF3_NOBLOCKMONST) PROP_Flags4 (MF4_NOSKIN) @@ -281,8 +282,9 @@ FState AFeather::States[] = IMPLEMENT_ACTOR (AFeather, Heretic, -1, 121) PROP_RadiusFixed (2) PROP_HeightFixed (4) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_NOTELEPORT|MF2_LOGRAV|MF2_CANNOTPUSH|MF2_WINDTHRUST) + PROP_Flags2 (MF2_NOTELEPORT|MF2_CANNOTPUSH|MF2_WINDTHRUST) PROP_Flags3 (MF3_DONTSPLASH) PROP_SpawnState (S_FEATHER) diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index 75d7f4ef4..773ad6ca2 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -115,8 +115,9 @@ FState APodGoo::States[] = IMPLEMENT_ACTOR (APodGoo, Heretic, -1, 0) PROP_RadiusFixed (2) PROP_HeightFixed (4) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_NOTELEPORT|MF2_LOGRAV|MF2_CANNOTPUSH) + PROP_Flags2 (MF2_NOTELEPORT|MF2_CANNOTPUSH) PROP_SpawnState (S_PODGOO) END_DEFAULTS @@ -421,8 +422,9 @@ IMPLEMENT_ACTOR (AVolcanoBlast, Heretic, -1, 123) PROP_SpeedFixed (2) PROP_Damage (2) PROP_DamageType (NAME_Fire) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_NOTELEPORT) + PROP_Flags2 (MF2_NOTELEPORT) PROP_SpawnState (S_VOLCANOBALL) PROP_DeathState (S_VOLCANOBALLX) @@ -459,8 +461,9 @@ IMPLEMENT_ACTOR (AVolcanoTBlast, Heretic, -1, 124) PROP_SpeedFixed (2) PROP_Damage (1) PROP_DamageType (NAME_Fire) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_NOTELEPORT) + PROP_Flags2 (MF2_NOTELEPORT) PROP_SpawnState (S_VOLCANOTBALL) PROP_DeathState (S_VOLCANOTBALLX) @@ -539,7 +542,7 @@ void A_VolcBallImpact (AActor *ball) if (ball->z <= ball->floorz) { ball->flags |= MF_NOGRAVITY; - ball->flags2 &= ~MF2_LOGRAV; + ball->gravity = FRACUNIT; ball->z += 28*FRACUNIT; //ball->momz = 3*FRACUNIT; } diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index c51fc19e7..3e5908c92 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -698,7 +698,7 @@ FState ACrossbowFX4::States[] = IMPLEMENT_ACTOR (ACrossbowFX4, Heretic, -1, 0) PROP_Flags (MF_NOBLOCKMAP) - PROP_Flags2 (MF2_LOGRAV) + PROP_Gravity (FRACUNIT/8) PROP_RenderStyle (STYLE_Add) PROP_SpawnState (S_CRBOWFX4) END_DEFAULTS @@ -944,8 +944,9 @@ IMPLEMENT_ACTOR (AMaceFX2, Heretic, -1, 156) PROP_HeightFixed (6) PROP_SpeedFixed (10) PROP_Damage (6) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_HERETICBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT|MF2_PCROSS|MF2_IMPACT) + PROP_Flags2 (MF2_HERETICBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT|MF2_PCROSS|MF2_IMPACT) PROP_SpawnState (S_MACEFX2) PROP_DeathState (S_MACEFXI2) @@ -968,8 +969,9 @@ FState AMaceFX3::States[] = IMPLEMENT_ACTOR (AMaceFX3, Heretic, -1, 155) PROP_SpeedFixed (7) PROP_Damage (4) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_HERETICBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT|MF2_PCROSS|MF2_IMPACT) + PROP_Flags2 (MF2_HERETICBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT|MF2_PCROSS|MF2_IMPACT) PROP_SpawnState (S_MACEFX3) END_DEFAULTS @@ -997,8 +999,9 @@ IMPLEMENT_ACTOR (AMaceFX4, Heretic, -1, 153) PROP_HeightFixed (6) PROP_SpeedFixed (7) PROP_Damage (18) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_HERETICBOUNCE|MF2_THRUGHOST|MF2_TELESTOMP|MF2_PCROSS|MF2_IMPACT) + PROP_Flags2 (MF2_HERETICBOUNCE|MF2_THRUGHOST|MF2_TELESTOMP|MF2_PCROSS|MF2_IMPACT) PROP_SpawnState (S_MACEFX4) PROP_DeathState (S_MACEFXI4) @@ -1213,7 +1216,7 @@ void A_MacePL1Check (AActor *ball) } ball->special1 = 0; ball->flags &= ~MF_NOGRAVITY; - ball->flags2 |= MF2_LOGRAV; + ball->gravity = FRACUNIT/8; // [RH] Avoid some precision loss by scaling the momentum directly #if 0 angle_t angle = ball->angle>>ANGLETOFINESHIFT; @@ -1249,7 +1252,7 @@ void A_MaceBallImpact (AActor *ball) { // Explode ball->momx = ball->momy = ball->momz = 0; ball->flags |= MF_NOGRAVITY; - ball->flags2 &= ~MF2_LOGRAV; + ball->gravity = FRACUNIT; S_Sound (ball, CHAN_BODY, "weapons/macehit", 1, ATTN_NORM); } } @@ -1317,7 +1320,8 @@ void A_MaceBallImpact2 (AActor *ball) boom: ball->momx = ball->momy = ball->momz = 0; ball->flags |= MF_NOGRAVITY; - ball->flags2 &= ~(MF2_LOGRAV|MF2_BOUNCETYPE); + ball->flags2 &= ~MF2_BOUNCETYPE; + ball->gravity = FRACUNIT; } } @@ -1443,7 +1447,7 @@ void A_DeathBallImpact (AActor *ball) boom: ball->momx = ball->momy = ball->momz = 0; ball->flags |= MF_NOGRAVITY; - ball->flags2 &= ~MF2_LOGRAV; + ball->gravity = FRACUNIT; S_Sound (ball, CHAN_BODY, "weapons/maceexplode", 1, ATTN_NORM); } } diff --git a/src/g_heretic/a_knight.cpp b/src/g_heretic/a_knight.cpp index 93b76a0ef..43006e7c8 100644 --- a/src/g_heretic/a_knight.cpp +++ b/src/g_heretic/a_knight.cpp @@ -191,7 +191,7 @@ void A_DripBlood (AActor *actor) mo = Spawn ("Blood", x, y, actor->z, ALLOW_REPLACE); mo->momx = pr_dripblood.Random2 () << 10; mo->momy = pr_dripblood.Random2 () << 10; - mo->flags2 |= MF2_LOGRAV; + mo->gravity = FRACUNIT/8; } //---------------------------------------------------------------------------- diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 39005401e..cf3fad2d4 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -613,8 +613,9 @@ FState ASorcSpark1::States[] = IMPLEMENT_ACTOR (ASorcSpark1, Hexen, -1, 0) PROP_RadiusFixed (5) PROP_HeightFixed (5) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_NOTELEPORT) + PROP_Flags2 (MF2_NOTELEPORT) PROP_RenderStyle (STYLE_Add) PROP_SpawnState (S_SORCSPARK1) @@ -1337,7 +1338,7 @@ void A_SorcBallPop(AActor *actor) { S_Sound (actor, CHAN_BODY, "SorcererBallPop", 1, ATTN_NONE); actor->flags &= ~MF_NOGRAVITY; - actor->flags2 |= MF2_LOGRAV; + actor->gravity = FRACUNIT/8; actor->momx = ((pr_heresiarch()%10)-5) << FRACBITS; actor->momy = ((pr_heresiarch()%10)-5) << FRACBITS; actor->momz = (2+(pr_heresiarch()%3)) << FRACBITS; diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index 001246be3..471cca509 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -313,8 +313,8 @@ FState ACorpseBloodDrip::States[] = IMPLEMENT_ACTOR (ACorpseBloodDrip, Hexen, -1, 0) PROP_RadiusFixed (1) PROP_HeightFixed (4) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_MISSILE) - PROP_Flags2 (MF2_LOGRAV) PROP_Flags4 (MF4_NOICEDEATH) PROP_SpawnState (S_CORPSEBLOODDRIP) @@ -480,8 +480,9 @@ FState ALeaf1::States[] = IMPLEMENT_ACTOR (ALeaf1, Hexen, -1, 0) PROP_RadiusFixed (2) PROP_HeightFixed (4) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE) - PROP_Flags2 (MF2_NOTELEPORT|MF2_LOGRAV) + PROP_Flags2 (MF2_NOTELEPORT) PROP_Flags3 (MF3_DONTSPLASH) PROP_Flags4 (MF4_NOICEDEATH) diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp index ae5d64b82..36572c0e6 100644 --- a/src/g_hexen/a_iceguy.cpp +++ b/src/g_hexen/a_iceguy.cpp @@ -170,8 +170,9 @@ IMPLEMENT_ACTOR (AIceGuyFX2, Hexen, -1, 0) PROP_HeightFixed (4) PROP_Damage (1) PROP_DamageType (NAME_Ice) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_DROPOFF|MF_MISSILE) - PROP_Flags2 (MF2_LOGRAV|MF2_NOTELEPORT) + PROP_Flags2 (MF2_NOTELEPORT) PROP_SpawnState (0) END_DEFAULTS @@ -198,8 +199,9 @@ FState AIceGuyBit::States[] = IMPLEMENT_ACTOR (AIceGuyBit, Hexen, -1, 0) PROP_RadiusFixed (1) PROP_HeightFixed (1) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP|MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_NOTELEPORT) + PROP_Flags2 (MF2_NOTELEPORT) PROP_SpawnState (0) END_DEFAULTS diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index 949c3f439..e8c60a138 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -268,8 +268,8 @@ FState ASerpentHead::States[] = IMPLEMENT_ACTOR (ASerpentHead, Hexen, -1, 0) PROP_RadiusFixed (5) PROP_HeightFixed (10) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_NOBLOCKMAP) - PROP_Flags2 (MF2_LOGRAV) PROP_SpawnState (S_SERPENT_HEAD1) PROP_DeathState (S_SERPENT_HEAD_X1) diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index a707a42a5..8aca40898 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -35,8 +35,9 @@ IMPLEMENT_ACTOR (AIceChunk, Any, -1, 0) PROP_RadiusFixed (3) PROP_HeightFixed (4) PROP_Mass(5) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_CANNOTPUSH|MF2_FLOORCLIP|MF2_NOTELEPORT) + PROP_Flags2 (MF2_CANNOTPUSH|MF2_FLOORCLIP|MF2_NOTELEPORT) PROP_SpawnState (0) END_DEFAULTS @@ -61,8 +62,9 @@ IMPLEMENT_ACTOR (AIceChunkHead, Any, -1, 0) PROP_HeightFixed (4) PROP_Mass(5) PROP_DamageType (NAME_Ice) + PROP_Gravity (FRACUNIT/8) PROP_Flags (MF_DROPOFF) - PROP_Flags2 (MF2_LOGRAV|MF2_CANNOTPUSH) + PROP_Flags2 (MF2_CANNOTPUSH) PROP_SpawnState (0) END_DEFAULTS @@ -545,7 +547,7 @@ void A_NoGravity (AActor *actor) void A_Gravity (AActor *actor) { actor->flags &= ~MF_NOGRAVITY; - actor->flags2 &= ~MF2_LOGRAV; + actor->gravity = FRACUNIT; } //=========================================================================== @@ -557,7 +559,7 @@ void A_Gravity (AActor *actor) void A_LowGravity (AActor *actor) { actor->flags &= ~MF_NOGRAVITY; - actor->flags2 |= MF2_LOGRAV; + actor->gravity = FRACUNIT/8; } //=========================================================================== diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index e877bfa64..93c2d8129 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -170,7 +170,7 @@ class ACustomInventory : public AInventory public: // This is used when an inventory item's use state sequence is executed. - static bool CallStateChain (AActor *actor, FState *state); + bool CallStateChain (AActor *actor, FState *state); bool TryPickup (AActor *toucher); bool Use (bool pickup); diff --git a/src/info.h b/src/info.h index 9f6b66eca..db3226cec 100644 --- a/src/info.h +++ b/src/info.h @@ -290,6 +290,7 @@ enum ADEF_FloatSpeed, ADEF_RDFactor, ADEF_FXFlags, + ADEF_Gravity, ADEF_SpawnState, ADEF_SeeState, diff --git a/src/infodefaults.cpp b/src/infodefaults.cpp index d1ae62c01..2c418b96a 100644 --- a/src/infodefaults.cpp +++ b/src/infodefaults.cpp @@ -226,6 +226,7 @@ static void ApplyActorDefault (int defnum, const char *datastr, int dataint) case ADEF_BounceCount: actor->bouncecount = dataint; break; case ADEF_RDFactor: sgClass->Meta.SetMetaFixed (AMETA_RDFactor, dataint); break; case ADEF_FXFlags: actor->effects = dataint; break; + case ADEF_Gravity: actor->gravity = dataint; break; case ADEF_SpawnState: AddState("Spawn", datastate); break; case ADEF_SeeState: AddState("See", datastate); break; diff --git a/src/infomacros.h b/src/infomacros.h index 6f7e79204..1b02edc18 100644 --- a/src/infomacros.h +++ b/src/infomacros.h @@ -267,6 +267,7 @@ public: #define PROP_BounceCount(x) ADD_LONG_PROP(ADEF_BounceCount,x) #define PROP_RadiusdamageFactor(x) ADD_LONG_PROP(ADEF_RDFactor,x) #define PROP_FXFlags(x) ADD_LONG_PROP(ADEF_FXFlags,x) +#define PROP_Gravity(x) ADD_LONG_PROP(ADEF_Gravity,x) #define PROP_SpawnState(x) ADD_BYTE_PROP(ADEF_SpawnState,x) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 7dc084a26..4e804920f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2071,6 +2071,7 @@ void DLevelScript::DoSetFont (int fontnum) #define APROP_JumpZ 12 // [GRB] #define APROP_ChaseGoal 13 #define APROP_Frightened 14 +#define APROP_Gravity 15 #define APROP_SeeSound 5 // Sounds can only be set, not gotten #define APROP_AttackSound 6 #define APROP_PainSound 7 @@ -2153,6 +2154,10 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) else actor->flags4 &= ~MF4_FRIGHTENED; break; + + case APROP_Gravity: + actor->gravity = value; + break; case APROP_SeeSound: actor->SeeSound = S_FindSound (FBehavior::StaticLookupString (value)); @@ -2204,6 +2209,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_Damage: return actor->Damage; // Should this call GetMissileDamage() instead? case APROP_Alpha: return actor->alpha; case APROP_RenderStyle: return actor->RenderStyle; + case APROP_Gravity: return actor->gravity; case APROP_Ambush: return !!(actor->flags & MF_AMBUSH); case APROP_ChaseGoal: return !!(actor->flags5 & MF5_CHASEGOAL); case APROP_Frightened: return !!(actor->flags4 & MF4_FRIGHTENED); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index fa957e25e..5d3b7299a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -312,7 +312,8 @@ void AActor::Serialize (FArchive &arc) << bouncefactor << bouncecount << meleerange - << DamageType; + << DamageType + << gravity; if (arc.IsStoring ()) { @@ -1843,7 +1844,7 @@ void P_ZMovement (AActor *mo) !(mo->player->cmd.ucmd.forwardmove | mo->player->cmd.ucmd.sidemove))) { mo->momz -= (fixed_t)(level.gravity * mo->Sector->gravity * - (mo->flags2 & MF2_LOGRAV ? 10.24 : 81.92)); + FIXED2FLOAT(mo->gravity) * 81.92); } if (mo->waterlevel > 1) { @@ -3000,7 +3001,8 @@ void A_FreeTargMobj (AActor *mo) mo->z = mo->ceilingz + 4*FRACUNIT; mo->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY|MF_SOLID); mo->flags |= MF_CORPSE|MF_DROPOFF|MF_NOGRAVITY; - mo->flags2 &= ~(MF2_PASSMOBJ|MF2_LOGRAV); + mo->flags2 &= ~MF2_PASSMOBJ; + mo->gravity = FRACUNIT; mo->player = NULL; } @@ -3051,6 +3053,7 @@ BEGIN_DEFAULTS (AActor, Any, -1, 0) PROP_BounceFactor(FRACUNIT*7/10) PROP_BounceCount(-1) PROP_FloatSpeed(4) + PROP_Gravity(FRACUNIT) END_DEFAULTS //========================================================================== diff --git a/src/p_things.cpp b/src/p_things.cpp index 5469ac026..760b5520f 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -247,7 +247,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_na mobj->flags &= ~MF_NOGRAVITY; if (!(mobj->flags3 & MF3_ISMONSTER) && gravity == 1) { - mobj->flags2 |= MF2_LOGRAV; + mobj->gravity = FRACUNIT/8; } } else diff --git a/src/thingdef.cpp b/src/thingdef.cpp index 77f690caf..2943ff1dc 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -129,7 +129,6 @@ static flagdef ActorFlags[]= DEFINE_FLAG(MF, NOLIFTDROP, AActor, flags), DEFINE_FLAG(MF, STEALTH, AActor, flags), DEFINE_FLAG(MF, ICECORPSE, AActor, flags), - DEFINE_FLAG2(MF2_LOGRAV, LOWGRAVITY, AActor, flags2), DEFINE_FLAG(MF2, WINDTHRUST, AActor, flags2), DEFINE_FLAG(MF2, HERETICBOUNCE , AActor, flags2), DEFINE_FLAG(MF2, BLASTED, AActor, flags2), @@ -3224,6 +3223,22 @@ static void ActorVSpeed (AActor *defaults, Baggage &bag) defaults->momz = fixed_t(sc_Float*FRACUNIT); } +//========================================================================== +// +//========================================================================== +static void ActorGravity (AActor *defaults, Baggage &bag) +{ + SC_MustGetFloat (); + + if (sc_Float < 0.f || sc_Float > 1.f) + SC_ScriptError ("Gravity must be in the range [0,1]"); + + defaults->gravity = FLOAT2FIXED (sc_Float); + + if (sc_Float == 0.f) + defaults->flags |= MF_NOGRAVITY; +} + //========================================================================== // //========================================================================== @@ -3276,6 +3291,11 @@ static void ActorFlagSetOrReset (AActor *defaults, Baggage &bag) if (mod == '+') defaults->DamageType = NAME_Ice; else defaults->DamageType = NAME_None; } + else if (SC_Compare ("LOWGRAVITY")) + { + if (mod == '+') defaults->gravity = FRACUNIT/8; + else defaults->gravity = FRACUNIT; + } else { FString part1 = sc_String; @@ -4099,6 +4119,7 @@ static const ActorProps props[] = { "floatspeed", ActorFloatSpeed, RUNTIME_CLASS(AActor) }, { "game", ActorGame, RUNTIME_CLASS(AActor) }, { "gibhealth", ActorGibHealth, RUNTIME_CLASS(AActor) }, + { "gravity", ActorGravity, RUNTIME_CLASS(AActor) }, { "heal", ActorHealState, RUNTIME_CLASS(AActor) }, { "health", ActorHealth, RUNTIME_CLASS(AActor) }, { "health.lowmessage", (apf)HealthLowMessage, RUNTIME_CLASS(AHealth) }, diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index bb86b3c29..f82f83b89 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -88,6 +88,7 @@ FState * CallingState; struct StateCallData { FState * State; + AActor * Item; bool Result; }; @@ -110,6 +111,7 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState * State) int counter = 0; pStateCall = &StateCall; + StateCall.Item = this; while (State != NULL) { // Assume success. The code pointer will set this to false if necessary @@ -387,7 +389,7 @@ FState *P_GetState(AActor *self, FState *CallingState, int offset) { return CallingState + offset; } - else + else if (self != NULL) { offset = -offset; @@ -412,6 +414,7 @@ FState *P_GetState(AActor *self, FState *CallingState, int offset) } return jumpto; } + else return NULL; } //========================================================================== @@ -421,24 +424,29 @@ FState *P_GetState(AActor *self, FState *CallingState, int offset) //========================================================================== static void DoJump(AActor * self, FState * CallingState, int offset) { - FState *jumpto = P_GetState(self, CallingState, offset); - - if (jumpto == NULL) return; if (pStateCall != NULL && CallingState == pStateCall->State) { + FState *jumpto = P_GetState(pStateCall->Item, CallingState, offset); + if (jumpto == NULL) return; pStateCall->State = jumpto; } else if (self->player != NULL && CallingState == self->player->psprites[ps_weapon].state) { + FState *jumpto = P_GetState(self->player->ReadyWeapon, CallingState, offset); + if (jumpto == NULL) return; P_SetPsprite(self->player, ps_weapon, jumpto); } else if (self->player != NULL && CallingState == self->player->psprites[ps_flash].state) { + FState *jumpto = P_GetState(self->player->ReadyWeapon, CallingState, offset); + if (jumpto == NULL) return; P_SetPsprite(self->player, ps_flash, jumpto); } else { + FState *jumpto = P_GetState(self, CallingState, offset); + if (jumpto == NULL) return; self->SetState (jumpto); } } @@ -2045,3 +2053,18 @@ void A_PlayerSkinCheck (AActor *actor) } } } + +//=========================================================================== +// +// A_SetGravity +// +//=========================================================================== +void A_SetGravity(AActor * self) +{ + int index=CheckIndex(1); + if (index<0) return; + + self->gravity = clamp (EvalExpressionF (StateParameters[index], self), 0, FRACUNIT); +} + + diff --git a/wadsrc/decorate/nativeclasses.txt b/wadsrc/decorate/nativeclasses.txt index 3f2392249..963bd6fc4 100644 --- a/wadsrc/decorate/nativeclasses.txt +++ b/wadsrc/decorate/nativeclasses.txt @@ -73,6 +73,7 @@ class Actor extends Thinker action native A_NoGravity(); action native A_Gravity(); action native A_LowGravity(); + action native A_SetGravity(eval float gravity); action native A_Fall(); action native A_SetSolid(); action native A_UnsetSolid();