diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 2e4597617f..187b215b8f 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -13,7 +13,6 @@ #include "r_data/r_translate.h" static FRandom pr_freezedeath ("FreezeDeath"); -static FRandom pr_icesettics ("IceSetTics"); static FRandom pr_freeze ("FreezeDeathChunks"); @@ -121,36 +120,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath) return 0; } -//============================================================================ -// -// A_IceSetTics -// -//============================================================================ - -void IceSetTics(AActor *self) -{ - - int floor; - - self->tics = 70 + (pr_icesettics() & 63); - floor = P_GetThingFloorType(self); - if (Terrains[floor].DamageMOD == NAME_Fire) - { - self->tics >>= 2; - } - else if (Terrains[floor].DamageMOD == NAME_Ice) - { - self->tics <<= 1; - } -} - -DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics) -{ - PARAM_SELF_PROLOGUE(AActor); - IceSetTics(self); - return 0; -} - //============================================================================ // // A_FreezeDeathChunks @@ -193,7 +162,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) mo->Vel.X = pr_freeze.Random2() / 128.; mo->Vel.Y = pr_freeze.Random2() / 128.; mo->Vel.Z = (mo->Z() - self->Z()) / self->Height * 4; - IceSetTics(mo); // set a random tic wait mo->RenderStyle = self->RenderStyle; mo->Alpha = self->Alpha; } diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index 138210061e..cb66577967 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -114,7 +114,7 @@ static void BridgeOrbit(AActor *self) self->ceilingz = self->target->ceilingz; } -DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) +DEFINE_ACTION_FUNCTION(ABridgeBall, A_BridgeOrbit) { PARAM_SELF_PROLOGUE(AActor); BridgeOrbit(self); @@ -122,7 +122,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) } -DEFINE_ACTION_FUNCTION(AActor, A_BridgeInit) +DEFINE_ACTION_FUNCTION(ACustomBridge, A_BridgeInit) { PARAM_SELF_PROLOGUE(AActor); PARAM_CLASS_DEF(balltype, AActor); diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index b5debf2df4..335f10aced 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -402,9 +402,9 @@ void ASpecialSpot::Destroy() // will build a list of all mace spots in the level and spawn a // mace. The rest of the spots will do nothing. -DEFINE_ACTION_FUNCTION(AActor, A_SpawnSingleItem) +DEFINE_ACTION_FUNCTION(ASpecialSpot, A_SpawnSingleItem) { - PARAM_SELF_PROLOGUE(AActor); + PARAM_SELF_PROLOGUE(ASpecialSpot); PARAM_CLASS_NOT_NULL(cls, AActor); PARAM_INT_DEF (fail_sp) PARAM_INT_DEF (fail_co) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 115bc1f54e..83844ffd76 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1773,9 +1773,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomComboAttack) // State jump function // //========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_JumpIfNoAmmo) +DEFINE_ACTION_FUNCTION(AStateProvider, A_JumpIfNoAmmo) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_STATE_ACTION(jump); if (!ACTION_CALL_FROM_PSPRITE() || self->player->ReadyWeapon == nullptr) @@ -1844,9 +1844,9 @@ static void AimBulletMissile(AActor *proj, AActor *puff, int flags, bool temp, b } } -DEFINE_ACTION_FUNCTION(AActor, A_FireBullets) +DEFINE_ACTION_FUNCTION(AStateProvider, A_FireBullets) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_ANGLE (spread_xy); PARAM_ANGLE (spread_z); PARAM_INT (numbullets); @@ -1974,9 +1974,9 @@ enum FP_Flags FPF_TRANSFERTRANSLATION = 2, FPF_NOAUTOAIM = 4, }; -DEFINE_ACTION_FUNCTION(AActor, A_FireCustomMissile) +DEFINE_ACTION_FUNCTION(AStateProvider, A_FireCustomMissile) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_CLASS (ti, AActor); PARAM_ANGLE_DEF (angle); PARAM_BOOL_DEF (useammo); @@ -2051,9 +2051,9 @@ enum CPF_STEALARMOR = 32, }; -DEFINE_ACTION_FUNCTION(AActor, A_CustomPunch) +DEFINE_ACTION_FUNCTION(AStateProvider, A_CustomPunch) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_INT (damage); PARAM_BOOL_DEF (norandom); PARAM_INT_DEF (flags); @@ -2155,9 +2155,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomPunch) // customizable railgun attack function // //========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_RailAttack) +DEFINE_ACTION_FUNCTION(AStateProvider, A_RailAttack) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_INT (damage); PARAM_INT_DEF (spawnofs_xy); PARAM_BOOL_DEF (useammo); @@ -4443,9 +4443,9 @@ DEFINE_ACTION_FUNCTION(AActor, CheckIfInTargetLOS) // //=========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_CheckForReload) +DEFINE_ACTION_FUNCTION(AStateProvider, A_CheckForReload) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); if ( self->player == NULL || self->player->ReadyWeapon == NULL ) { @@ -4496,9 +4496,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckForReload) // //=========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_ResetReloadCounter) +DEFINE_ACTION_FUNCTION(AStateProvider, A_ResetReloadCounter) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); if (self->player == NULL || self->player->ReadyWeapon == NULL) return 0; diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 733741cb29..2bd3696d42 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -828,7 +828,7 @@ void DoReadyWeapon(AActor *self) DEFINE_ACTION_FUNCTION(AStateProvider, A_WeaponReady) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_INT_DEF(flags); DoReadyWeaponToSwitch(self, !(flags & WRF_NoSwitch)); @@ -960,7 +960,7 @@ static void P_CheckWeaponButtons (player_t *player) DEFINE_ACTION_FUNCTION(AStateProvider, A_ReFire) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_STATE_ACTION_DEF(state); A_ReFire(self, state); return 0; @@ -998,7 +998,7 @@ void A_ReFire(AActor *self, FState *state) DEFINE_ACTION_FUNCTION(AStateProvider, A_ClearReFire) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); player_t *player = self->player; if (NULL != player) @@ -1020,7 +1020,7 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_ClearReFire) DEFINE_ACTION_FUNCTION(AStateProvider, A_CheckReload) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); if (self->player != NULL) { @@ -1208,7 +1208,7 @@ DEFINE_ACTION_FUNCTION(AActor, OverlayID) DEFINE_ACTION_FUNCTION(AStateProvider, A_Lower) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); player_t *player = self->player; DPSprite *psp; @@ -1254,9 +1254,9 @@ DEFINE_ACTION_FUNCTION(AStateProvider, A_Lower) // //--------------------------------------------------------------------------- -DEFINE_ACTION_FUNCTION(AActor, A_Raise) +DEFINE_ACTION_FUNCTION(AStateProvider, A_Raise) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); if (self == nullptr) { @@ -1368,7 +1368,7 @@ enum GF_Flags DEFINE_ACTION_FUNCTION(AStateProvider, A_GunFlash) { - PARAM_ACTION_PROLOGUE(AActor); + PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_STATE_ACTION_DEF(flash); PARAM_INT_DEF(flags); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index b34157b36a..18962fbca0 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -583,35 +583,24 @@ FPropertyInfo *FindProperty(const char * string) AFuncDesc *FindFunction(PStruct *cls, const char * string) { - for (int i = 0; i < 2; i++) + int min = 0, max = AFTable.Size() - 1; + + while (min <= max) { - // Since many functions have been declared with Actor as owning class, despite being members of something else, let's hack around this until they have been fixed or exported. - // Since most of these are expected to be scriptified anyway, there's no point fixing them all before they get exported. - if (i == 1) + int mid = (min + max) / 2; + int lexval = stricmp(cls->TypeName.GetChars(), AFTable[mid].ClassName + 1); + if (lexval == 0) lexval = stricmp(string, AFTable[mid].FuncName); + if (lexval == 0) { - if (!cls->IsKindOf(RUNTIME_CLASS(PClassActor))) break; - cls = RUNTIME_CLASS(AActor); + return &AFTable[mid]; } - - int min = 0, max = AFTable.Size() - 1; - - while (min <= max) + else if (lexval > 0) { - int mid = (min + max) / 2; - int lexval = stricmp(cls->TypeName.GetChars(), AFTable[mid].ClassName + 1); - if (lexval == 0) lexval = stricmp(string, AFTable[mid].FuncName); - if (lexval == 0) - { - return &AFTable[mid]; - } - else if (lexval > 0) - { - min = mid + 1; - } - else - { - max = mid - 1; - } + min = mid + 1; + } + else + { + max = mid - 1; } } return nullptr; diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 7285fb48d4..aeb52dabb3 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -1140,8 +1140,8 @@ class AActor; // callingstate - State this action was called from #define PARAM_ACTION_PROLOGUE(type) \ PARAM_PROLOGUE; \ - PARAM_OBJECT (self, type); \ - PARAM_OBJECT (stateowner, AActor) \ + PARAM_OBJECT (self, AActor); \ + PARAM_OBJECT (stateowner, type) \ PARAM_POINTER (stateinfo, FStateParamInfo) \ // Number of action paramaters diff --git a/wadsrc/static/zscript/shared/ice.txt b/wadsrc/static/zscript/shared/ice.txt index 5341137855..9b72e2455d 100644 --- a/wadsrc/static/zscript/shared/ice.txt +++ b/wadsrc/static/zscript/shared/ice.txt @@ -21,12 +21,24 @@ class IceChunk : Actor +NOBLOCKMAP +MOVEWITHSECTOR } - native void A_IceSetTics (); + + void A_IceSetTics () + { + tics = 70 + (random[IceTics]() & 63); + Name dtype = GetFloorTerrain().DamageMOD; + if (dtype == 'Fire') + { + tics >>= 2; + } + else if (dtype == 'Ice') + { + tics <<= 1; + } + } States { Spawn: - ICEC A 1; ICEC ABCD 10 A_IceSetTics; Stop; }