diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6fa721b7..0ec18032e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1150,7 +1150,9 @@ set (PCH_SOURCES r_data/models/models_ue1.cpp r_data/models/models_obj.cpp scripting/symbols.cpp + scripting/vmiterators.cpp scripting/vmthunks.cpp + scripting/vmthunks_actors.cpp scripting/types.cpp scripting/thingdef.cpp scripting/thingdef_data.cpp diff --git a/src/actor.h b/src/actor.h index 0539edaa5..4f37dcf98 100644 --- a/src/actor.h +++ b/src/actor.h @@ -969,11 +969,6 @@ public: } } - double AccuracyFactor() - { - return 1. / (1 << (accuracy * 5 / 100)); - } - void ClearInterpolation(); void Move(const DVector3 &vel) @@ -1010,11 +1005,6 @@ public: void AttachLight(unsigned int count, const FLightDefaults *lightdef); void SetDynamicLights(); - // When was this actor spawned? (relative to the current level) - int GetLevelSpawnTime() const; - // How many ticks passed since this actor was spawned? - int GetAge() const; - // info for drawing // NOTE: The first member variable *must* be snext. AActor *snext, **sprev; // links in sector (if needed) @@ -1293,12 +1283,6 @@ public: return DamageVal == 0 && DamageFunc == nullptr; } - void RestoreDamage() - { - DamageVal = GetDefault()->DamageVal; - DamageFunc = GetDefault()->DamageFunc; - } - FState *FindState (FName label) const { return GetClass()->FindState(1, &label); diff --git a/src/actorinlines.h b/src/actorinlines.h index 36e90652c..7eb3bbd30 100644 --- a/src/actorinlines.h +++ b/src/actorinlines.h @@ -54,3 +54,28 @@ inline double sector_t::LowestFloorAt(AActor *a, sector_t **resultsec) return ::LowestFloorAt(this, a->X(), a->Y(), resultsec); } +inline double AActor::GetBobOffset(double ticfrac) const +{ + if (!(flags2 & MF2_FLOATBOB)) + { + return 0; + } + return BobSin(FloatBobPhase + level.maptime + ticfrac) * FloatBobStrength; +} + +inline double AActor::GetCameraHeight() const +{ + return CameraHeight == INT_MIN ? Height / 2 : CameraHeight; +} + + +inline FDropItem *AActor::GetDropItems() const +{ + return GetInfo()->DropItems; +} + +inline double AActor::GetGravity() const +{ + if (flags & MF_NOGRAVITY) return 0; + return level.gravity * Sector->gravity * Gravity * 0.00125; +} diff --git a/src/dobject.cpp b/src/dobject.cpp index fc4896054..f5fd176f8 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -484,7 +484,7 @@ size_t DObject::PointerSubstitution (DObject *old, DObject *notOld) // //========================================================================== -size_t DObject::StaticPointerSubstitution (AActor *old, AActor *notOld) +void DObject::StaticPointerSubstitution (AActor *old, AActor *notOld) { DObject *probe; size_t changed = 0; @@ -521,8 +521,6 @@ size_t DObject::StaticPointerSubstitution (AActor *old, AActor *notOld) { if (sec.SoundTarget == old) sec.SoundTarget = notOld; } - - return changed; } //========================================================================== diff --git a/src/dobject.h b/src/dobject.h index 44ffa61fb..c930cbe79 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -254,7 +254,7 @@ public: // This is only needed for swapping out PlayerPawns and absolutely nothing else! virtual size_t PointerSubstitution (DObject *old, DObject *notOld); - static size_t StaticPointerSubstitution (AActor *old, AActor *notOld); + static void StaticPointerSubstitution (AActor *old, AActor *notOld); PClass *GetClass() const { diff --git a/src/dthinker.cpp b/src/dthinker.cpp index 80345d83a..7ed3e8046 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -962,47 +962,6 @@ DThinker *FThinkerIterator::Next (bool exact) return NULL; } -//========================================================================== -// -// This is for scripting, which needs the iterator wrapped into an object with the needed functions exported. -// Unfortunately we cannot have templated type conversions in scripts. -// -//========================================================================== - -class DThinkerIterator : public DObject, public FThinkerIterator -{ - DECLARE_ABSTRACT_CLASS(DThinkerIterator, DObject) - -public: - DThinkerIterator(PClass *cls, int statnum = MAX_STATNUM + 1) - : FThinkerIterator(cls, statnum) - { - } -}; - -IMPLEMENT_CLASS(DThinkerIterator, true, false); -DEFINE_ACTION_FUNCTION(DThinkerIterator, Create) -{ - PARAM_PROLOGUE; - PARAM_CLASS(type, DThinker); - PARAM_INT(statnum); - ACTION_RETURN_OBJECT(Create(type, statnum)); -} - -DEFINE_ACTION_FUNCTION(DThinkerIterator, Next) -{ - PARAM_SELF_PROLOGUE(DThinkerIterator); - PARAM_BOOL(exact); - ACTION_RETURN_OBJECT(self->Next(exact)); -} - -DEFINE_ACTION_FUNCTION(DThinkerIterator, Reinit) -{ - PARAM_SELF_PROLOGUE(DThinkerIterator); - self->Reinit(); - return 0; -} - //========================================================================== // // diff --git a/src/g_inventory/a_weapons.cpp b/src/g_inventory/a_weapons.cpp index 049376506..094cea99a 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -289,36 +289,6 @@ bool FWeaponSlots::LocateWeapon (PClassActor *type, int *const slot, int *const return false; } - -DEFINE_ACTION_FUNCTION(FWeaponSlots, LocateWeapon) -{ - PARAM_SELF_STRUCT_PROLOGUE(FWeaponSlots); - PARAM_CLASS(weap, AActor); - int slot = 0, index = 0; - bool retv = self->LocateWeapon(weap, &slot, &index); - if (numret >= 1) ret[0].SetInt(retv); - if (numret >= 2) ret[1].SetInt(slot); - if (numret >= 3) ret[2].SetInt(index); - return MIN(numret, 3); -} - -DEFINE_ACTION_FUNCTION(FWeaponSlots, GetWeapon) -{ - PARAM_SELF_STRUCT_PROLOGUE(FWeaponSlots); - PARAM_INT(slot); - PARAM_INT(index); - ACTION_RETURN_POINTER(self->GetWeapon(slot, index)); - return 1; -} - -DEFINE_ACTION_FUNCTION(FWeaponSlots, SlotSize) -{ - PARAM_SELF_STRUCT_PROLOGUE(FWeaponSlots); - PARAM_INT(slot); - ACTION_RETURN_INT(self->SlotSize(slot)); - return 1; -} - //=========================================================================== // // FWeaponSlots :: AddExtraWeapons @@ -819,14 +789,6 @@ void FWeaponSlots::SetupWeaponSlots(APlayerPawn *pp) } } -DEFINE_ACTION_FUNCTION(FWeaponSlots, SetupWeaponSlots) -{ - PARAM_PROLOGUE; - PARAM_OBJECT(pawn, APlayerPawn); - FWeaponSlots::SetupWeaponSlots(pawn); - return 0; -} - //=========================================================================== // // P_SetupWeapons_ntohton diff --git a/src/g_level.cpp b/src/g_level.cpp index dca97f219..fe5477bf6 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2031,9 +2031,9 @@ void FLevelLocals::SetMusicVolume(float f) //========================================================================== -bool IsPointInMap(DVector3 p) +int IsPointInMap(double x, double y, double z) { - subsector_t *subsector = R_PointInSubsector(FLOAT2FIXED(p.X), FLOAT2FIXED(p.Y)); + subsector_t *subsector = R_PointInSubsector(FLOAT2FIXED(x), FLOAT2FIXED(y)); if (!subsector) return false; for (uint32_t i = 0; i < subsector->numlines; i++) @@ -2044,26 +2044,26 @@ bool IsPointInMap(DVector3 p) divline_t dline; P_MakeDivline(seg->linedef, &dline); - bool pol = P_PointOnDivlineSide(p.XY(), &dline) < 1; + bool pol = P_PointOnDivlineSide(x, y, &dline) < 1; if (!pol) return false; } - double ceilingZ = subsector->sector->ceilingplane.ZatPoint(p.X, p.Y); - if (p.Z > ceilingZ) return false; + double ceilingZ = subsector->sector->ceilingplane.ZatPoint(x, y); + if (z > ceilingZ) return false; - double floorZ = subsector->sector->floorplane.ZatPoint(p.X, p.Y); - if (p.Z < floorZ) return false; + double floorZ = subsector->sector->floorplane.ZatPoint(x, y); + if (z < floorZ) return false; return true; } -DEFINE_ACTION_FUNCTION(FLevelLocals, IsPointInMap) +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, IsPointInMap, IsPointInMap) { PARAM_PROLOGUE; PARAM_FLOAT(x); PARAM_FLOAT(y); PARAM_FLOAT(z); - ACTION_RETURN_BOOL(IsPointInMap(DVector3(x,y,z))); + ACTION_RETURN_BOOL(IsPointInMap(x, y, z)); } template diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 83b2f3968..4ff0439be 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -30,6 +30,7 @@ #include "p_enemy.h" #include "serializer.h" #include "vm.h" +#include "actorinlines.h" //---------------------------------------------------------------------------- // @@ -81,14 +82,6 @@ void A_Unblock(AActor *self, bool drop) } } -DEFINE_ACTION_FUNCTION(AActor, A_NoBlocking) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(drop); - A_Unblock(self, drop); - return 0; -} - //---------------------------------------------------------------------------- // // CorpseQueue Routines (used by Hexen) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 7caef4a4b..766e18d6a 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -144,6 +144,7 @@ void ST_FormatMapName(FString &mapname, const char *mapnamecolor) cluster_info_t *cluster = FindClusterInfo (level.cluster); bool ishub = (cluster != NULL && (cluster->flags & CLUSTER_HUB)); + mapname = ""; if (am_showmaplabel == 1 || (am_showmaplabel == 2 && !ishub)) { mapname << level.MapName << ": "; diff --git a/src/hwrenderer/postprocessing/hw_postprocessshader.cpp b/src/hwrenderer/postprocessing/hw_postprocessshader.cpp index 95205dac6..dc6a465b6 100644 --- a/src/hwrenderer/postprocessing/hw_postprocessshader.cpp +++ b/src/hwrenderer/postprocessing/hw_postprocessshader.cpp @@ -35,13 +35,8 @@ static bool IsConsolePlayer(player_t *player) return int(activator->player - players) == consoleplayer; } -DEFINE_ACTION_FUNCTION(_Shader, SetEnabled) +static void ShaderSetEnabled(player_t *player, const FString &shaderName, bool value) { - PARAM_PROLOGUE; - PARAM_POINTER(player, player_t); - PARAM_STRING(shaderName); - PARAM_BOOL(value); - if (IsConsolePlayer(player)) { for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) @@ -51,17 +46,21 @@ DEFINE_ACTION_FUNCTION(_Shader, SetEnabled) shader.Enabled = value; } } - return 0; } -DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) +DEFINE_ACTION_FUNCTION_NATIVE(_Shader, SetEnabled, ShaderSetEnabled) { PARAM_PROLOGUE; PARAM_POINTER(player, player_t); PARAM_STRING(shaderName); - PARAM_STRING(uniformName); - PARAM_FLOAT(value); + PARAM_BOOL(value); + ShaderSetEnabled(player, shaderName, value); + return 0; +} + +static void ShaderSetUniform1f(player_t *player, const FString &shaderName, const FString &uniformName, double value) +{ if (IsConsolePlayer(player)) { for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) @@ -77,6 +76,16 @@ DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) } } } +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Shader, SetUniform1f, ShaderSetUniform1f) +{ + PARAM_PROLOGUE; + PARAM_POINTER(player, player_t); + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_FLOAT(value); + ShaderSetUniform1f(player, shaderName, uniformName, value); return 0; } diff --git a/src/info.cpp b/src/info.cpp index edeaabbe6..91a9b6695 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -286,13 +286,6 @@ int GetSpriteIndex(const char * spritename, bool add) return (lastindex = (int)sprites.Push (temp)); } -DEFINE_ACTION_FUNCTION(AActor, GetSpriteIndex) -{ - PARAM_PROLOGUE; - PARAM_NAME(sprt); - ACTION_RETURN_INT(GetSpriteIndex(sprt.GetChars(), false)); -} - //========================================================================== // // Load alt HUD icons. This is meant to be an override of the item's own settings. @@ -574,13 +567,6 @@ PClassActor *PClassActor::GetReplacement(bool lookskill) return rep; } -DEFINE_ACTION_FUNCTION(AActor, GetReplacement) -{ - PARAM_PROLOGUE; - PARAM_POINTER(c, PClassActor); - ACTION_RETURN_POINTER(c->GetReplacement()); -} - //========================================================================== // // PClassActor :: GetReplacee @@ -624,13 +610,6 @@ PClassActor *PClassActor::GetReplacee(bool lookskill) return rep; } -DEFINE_ACTION_FUNCTION(AActor, GetReplacee) -{ - PARAM_PROLOGUE; - PARAM_POINTER(c, PClassActor); - ACTION_RETURN_POINTER(c->GetReplacee()); -} - //========================================================================== // // PClassActor :: SetDamageFactor diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index a09186dcc..a61733a2d 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -83,13 +83,22 @@ CVAR(Color, dimcolor, 0xffd700, CVAR_ARCHIVE) -DEFINE_ACTION_FUNCTION(DMenu, GetCurrentMenu) +static DMenu *GetCurrentMenu() +{ + return CurrentMenu; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, GetCurrentMenu, GetCurrentMenu) { ACTION_RETURN_OBJECT(CurrentMenu); } +static int GetMenuTime() +{ + return MenuTime; +} -DEFINE_ACTION_FUNCTION(DMenu, MenuTime) +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, MenuTime, GetMenuTime) { ACTION_RETURN_INT(MenuTime); } @@ -123,13 +132,17 @@ IMPLEMENT_CLASS(DMenuDescriptor, false, false) IMPLEMENT_CLASS(DListMenuDescriptor, false, false) IMPLEMENT_CLASS(DOptionMenuDescriptor, false, false) -DEFINE_ACTION_FUNCTION(DMenuDescriptor, GetDescriptor) +DMenuDescriptor *GetMenuDescriptor(int name) +{ + DMenuDescriptor **desc = MenuDescriptors.CheckKey(ENamedName(name)); + return desc ? *desc : nullptr; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DMenuDescriptor, GetDescriptor, GetMenuDescriptor) { PARAM_PROLOGUE; PARAM_NAME(name); - DMenuDescriptor **desc = MenuDescriptors.CheckKey(name); - auto retn = desc ? *desc : nullptr; - ACTION_RETURN_OBJECT(retn); + ACTION_RETURN_OBJECT(GetMenuDescriptor(name)); } size_t DListMenuDescriptor::PropagateMark() @@ -240,12 +253,16 @@ bool DMenu::CallMenuEvent(int mkey, bool fromcontroller) // //============================================================================= -DEFINE_ACTION_FUNCTION(DMenu, SetMouseCapture) +static void SetMouseCapture(bool on) +{ + if (on) I_SetMouseCapture(); + else I_ReleaseMouseCapture(); +} +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, SetMouseCapture, SetMouseCapture) { PARAM_PROLOGUE; PARAM_BOOL(on); - if (on) I_SetMouseCapture(); - else I_ReleaseMouseCapture(); + SetMouseCapture(on); return 0; } @@ -271,7 +288,13 @@ void DMenu::Close () } } -DEFINE_ACTION_FUNCTION(DMenu, Close) + +static void Close(DMenu *menu) +{ + menu->Close(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, Close, Close) { PARAM_SELF_PROLOGUE(DMenu); self->Close(); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index d97692a50..44038184d 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -6039,7 +6039,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) // SoundVolume(int tid, int channel, fixed volume) { int chan = args[1]; - float volume = ACSToFloat(args[2]); + double volume = ACSToDouble(args[2]); if (args[0] == 0) { diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 944839130..368184329 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -98,7 +98,7 @@ FRandom pr_cajump("CustomJump"); extern TArray actionParams; // this can use the same storage as CallAction -static bool CallStateChain (AActor *self, AActor *actor, FState *state) +static int CallStateChain (AActor *self, AActor *actor, FState *state) { INTBOOL result = false; int counter = 0; @@ -235,7 +235,7 @@ static bool CallStateChain (AActor *self, AActor *actor, FState *state) return !!result; } -DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain) +DEFINE_ACTION_FUNCTION_NATIVE(ACustomInventory, CallStateChain, CallStateChain) { PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(affectee, AActor); @@ -243,226 +243,6 @@ DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain) ACTION_RETURN_BOOL(CallStateChain(self, affectee, state)); } -//========================================================================== -// -// CheckClass -// -// NON-ACTION function to check a pointer's class. -// -//========================================================================== - -DEFINE_ACTION_FUNCTION(AActor, CheckClass) -{ - if (numret > 0) - { - assert(ret != NULL); - PARAM_SELF_PROLOGUE(AActor); - PARAM_CLASS (checktype, AActor); - PARAM_INT (pick_pointer); - PARAM_BOOL (match_superclass); - - self = COPY_AAPTR(self, pick_pointer); - if (self == nullptr || checktype == nullptr) - { - ret->SetInt(false); - } - else if (match_superclass) - { - ret->SetInt(self->IsKindOf(checktype)); - } - else - { - ret->SetInt(self->GetClass() == checktype); - } - return 1; - } - return 0; -} - -//========================================================================== -// -// CheckClass -// -// NON-ACTION function to calculate missile damage for the given actor -// -//========================================================================== - -DEFINE_ACTION_FUNCTION(AActor, GetMissileDamage) -{ - if (numret > 0) - { - assert(ret != NULL); - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(mask); - PARAM_INT(add); - PARAM_INT(pick_pointer); - - self = COPY_AAPTR(self, pick_pointer); - if (self == NULL) - { - ret->SetInt(0); - } - else - { - ret->SetInt(self->GetMissileDamage(mask, add)); - } - return 1; - } - return 0; -} - -//========================================================================== -// -// GetDistance -// -// NON-ACTION function to get the distance in double. -// -//========================================================================== -DEFINE_ACTION_FUNCTION(AActor, GetDistance) -{ - if (numret > 0) - { - assert(ret != NULL); - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(checkz); - PARAM_INT(ptr); - - AActor *target = COPY_AAPTR(self, ptr); - - if (!target || target == self) - { - ret->SetFloat(0); - } - else - { - DVector3 diff = self->Vec3To(target); - if (checkz) - diff.Z += (target->Height - self->Height) / 2; - else - diff.Z = 0.; - - ret->SetFloat(diff.Length()); - } - return 1; - } - return 0; -} - -//========================================================================== -// -// GetAngle -// -// NON-ACTION function to get the angle in degrees (normalized to -180..180) -// -//========================================================================== -enum GAFlags -{ - GAF_RELATIVE = 1, - GAF_SWITCH = 1 << 1, -}; - -DEFINE_ACTION_FUNCTION(AActor, GetAngle) -{ - if (numret > 0) - { - assert(ret != NULL); - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(flags); - PARAM_INT(ptr) - - AActor *target = COPY_AAPTR(self, ptr); - - if (!target || target == self) - { - ret->SetFloat(0); - } - else - { - DVector3 diff = (flags & GAF_SWITCH) ? target->Vec3To(self) : self->Vec3To(target); - DAngle angto = diff.Angle(); - DAngle yaw = (flags & GAF_SWITCH) ? target->Angles.Yaw : self->Angles.Yaw; - if (flags & GAF_RELATIVE) angto = deltaangle(yaw, angto); - ret->SetFloat(angto.Degrees); - } - return 1; - } - return 0; -} - -//========================================================================== -// -// GetSpawnHealth -// -//========================================================================== -DEFINE_ACTION_FUNCTION(AActor, GetSpawnHealth) -{ - if (numret > 0) - { - PARAM_SELF_PROLOGUE(AActor); - ret->SetInt(self->SpawnHealth()); - return 1; - } - return 0; -} - -//========================================================================== -// -// GetSpriteAngle -// -// NON-ACTION function returns the sprite angle of a pointer. -//========================================================================== -DEFINE_ACTION_FUNCTION(AActor, GetSpriteAngle) -{ - if (numret > 0) - { - assert(ret != NULL); - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(ptr); - - AActor *target = COPY_AAPTR(self, ptr); - if (target == nullptr) - { - ret->SetFloat(0.0); - } - else - { - const double ang = target->SpriteAngle.Degrees; - ret->SetFloat(ang); - } - return 1; - } - return 0; -} - -//========================================================================== -// -// GetSpriteRotation -// -// NON-ACTION function returns the sprite rotation of a pointer. -//========================================================================== -DEFINE_ACTION_FUNCTION(AActor, GetSpriteRotation) -{ - if (numret > 0) - { - assert(ret != NULL); - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(ptr); - - AActor *target = COPY_AAPTR(self, ptr); - if (target == nullptr) - { - ret->SetFloat(0.0); - } - else - { - const double ang = target->SpriteRotation.Degrees; - ret->SetFloat(ang); - } - return 1; - } - return 0; -} - //========================================================================== // // GetZAt @@ -904,31 +684,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_CopyFriendliness) return 0; } -//========================================================================== -// -// Custom sound functions. -// -//========================================================================== - -DEFINE_ACTION_FUNCTION(AActor, A_StopSound) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(slot); - - S_StopSound(self, slot); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_SoundVolume) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(channel); - PARAM_FLOAT(volume); - S_ChangeSoundVolume(self, channel, static_cast(volume)); - return 0; -} - - //========================================================================== // // These come from a time when DECORATE constants did not exist yet and @@ -4931,7 +4686,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckBlock) // If checking for dropoffs, set the z so we can have maximum flexibility. // Otherwise, set origin and set it back after testing. - bool checker = false; + int checker = false; if (flags & CBF_DROPOFF) { // Unfortunately, whenever P_CheckMove returned false, that means it could diff --git a/src/p_destructible.cpp b/src/p_destructible.cpp index e0a28f35a..56ab0ea5d 100755 --- a/src/p_destructible.cpp +++ b/src/p_destructible.cpp @@ -899,10 +899,6 @@ DEFINE_ACTION_FUNCTION(FHealthGroup, SetHealth) return 0; } -// genuine hack. this essentially causes the engine to register a struct called Destructible, and enables use of DEFINE_ACTION_FUNCTION -struct FDestructible { void* none; }; -DEFINE_FIELD_X(Destructible, FDestructible, none); - DEFINE_ACTION_FUNCTION(FDestructible, DamageSector) { PARAM_PROLOGUE; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 527436b6b..aeb5b0ec8 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -567,16 +567,6 @@ void P_DrawSplash (int count, const DVector3 &pos, DAngle angle, int kind) } } -DEFINE_ACTION_FUNCTION(AActor, DrawSplash) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(count); - PARAM_FLOAT(angle); - PARAM_INT(kind); - P_DrawSplash(count, self->Pos(), angle, kind); - return 0; -} - void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind) { int color1, color2, zadd; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 04d2b261b..d65ee7bbe 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -99,9 +99,6 @@ dirtype_t diags[4] = double xspeed[8] = {1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF,0,SQRTHALF}; double yspeed[8] = {0,SQRTHALF,1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF}; -void P_RandomChaseDir (AActor *actor); - - // // ENEMY THINKING // Enemies are always spawned @@ -240,7 +237,7 @@ static void P_RecursiveSound(sector_t *sec, AActor *soundtarget, bool splash, AA // //---------------------------------------------------------------------------- -void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist) +void P_NoiseAlert (AActor *emitter, AActor *target, bool splash, double maxdist) { if (emitter == NULL) return; @@ -257,17 +254,6 @@ void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist) } } -DEFINE_ACTION_FUNCTION(AActor, SoundAlert) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT(target, AActor); - PARAM_BOOL(splash); - PARAM_FLOAT(maxdist); - // Note that the emitter is self, not the target of the alert! Target can be NULL. - P_NoiseAlert(target, self, splash, maxdist); - return 0; -} - //---------------------------------------------------------------------------- // // AActor :: CheckMeleeRange @@ -317,56 +303,6 @@ DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange) ACTION_RETURN_INT(self->CheckMeleeRange()); } -//---------------------------------------------------------------------------- -// -// FUNC P_CheckMeleeRange2 -// -//---------------------------------------------------------------------------- - -bool P_CheckMeleeRange2 (AActor *actor) -{ - AActor *mo; - double dist; - - - if (!actor->target || (actor->Sector->Flags & SECF_NOATTACK)) - { - return false; - } - mo = actor->target; - dist = mo->Distance2D (actor); - if (dist >= 128 || dist < actor->meleerange + mo->radius) - { - return false; - } - if (mo->Z() > actor->Top()) - { // Target is higher than the attacker - return false; - } - else if (actor->Z() > mo->Top()) - { // Attacker is higher - return false; - } - else if (actor->IsFriend(mo)) - { - // killough 7/18/98: friendly monsters don't attack other friends - return false; - } - - if (!P_CheckSight(actor, mo)) - { - return false; - } - return true; -} - -DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange2) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(P_CheckMeleeRange2(self)); -} - - //============================================================================= // // P_CheckMissileRange @@ -459,7 +395,7 @@ bool AActor::SuggestMissileAttack (double dist) // //============================================================================= -bool P_HitFriend(AActor * self) +int P_HitFriend(AActor * self) { FTranslatedLineTarget t; @@ -476,19 +412,13 @@ bool P_HitFriend(AActor * self) return false; } -DEFINE_ACTION_FUNCTION(AActor, HitFriend) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(P_HitFriend(self)); -} - // // P_Move // Move in the current direction, // returns false if the move is blocked. // -bool P_Move (AActor *actor) +int P_Move (AActor *actor) { double tryx, tryy, deltax, deltay, origx, origy; @@ -720,12 +650,6 @@ bool P_Move (AActor *actor) } return true; } -DEFINE_ACTION_FUNCTION(AActor, MonsterMove) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(P_Move(self)); -} - //============================================================================= // @@ -1049,14 +973,6 @@ void P_NewChaseDir(AActor * actor) } -DEFINE_ACTION_FUNCTION(AActor, NewChaseDir) -{ - PARAM_SELF_PROLOGUE(AActor); - P_NewChaseDir(self); - return 0; -} - - //============================================================================= // // P_RandomChaseDir @@ -1215,14 +1131,6 @@ void P_RandomChaseDir (AActor *actor) actor->movedir = DI_NODIR; // cannot move } -DEFINE_ACTION_FUNCTION(AActor, RandomChaseDir) -{ - PARAM_SELF_PROLOGUE(AActor); - P_RandomChaseDir(self); - return 0; -} - - //--------------------------------------------------------------------------- // // P_IsVisible @@ -1232,7 +1140,7 @@ DEFINE_ACTION_FUNCTION(AActor, RandomChaseDir) // //--------------------------------------------------------------------------- -bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params) +int P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params) { double maxdist; double mindist; @@ -1280,15 +1188,6 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams return P_CheckSight(lookee, other, SF_SEEPASTSHOOTABLELINES); } -DEFINE_ACTION_FUNCTION(AActor, IsVisible) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT(other, AActor); - PARAM_BOOL(allaround); - PARAM_POINTER(params, FLookExParams); - ACTION_RETURN_BOOL(P_IsVisible(self, other, allaround, params)); -} - //--------------------------------------------------------------------------- // // FUNC P_LookForMonsters @@ -1298,7 +1197,7 @@ DEFINE_ACTION_FUNCTION(AActor, IsVisible) #define MONS_LOOK_RANGE (20*64) #define MONS_LOOK_LIMIT 64 -bool P_LookForMonsters (AActor *actor) +int P_LookForMonsters (AActor *actor) { int count; AActor *mo; @@ -1342,12 +1241,6 @@ bool P_LookForMonsters (AActor *actor) return false; } -DEFINE_ACTION_FUNCTION(AActor, LookForMonsters) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(P_LookForMonsters(self)); -} - //============================================================================ // // LookForTIDinBlock @@ -1419,7 +1312,7 @@ AActor *LookForTIDInBlock (AActor *lookee, int index, void *extparams) // //============================================================================ -bool P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params) +int P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params) { AActor *other; bool reachedend = false; @@ -1520,14 +1413,6 @@ bool P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params) return false; } -DEFINE_ACTION_FUNCTION(AActor, LookForTID) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(allaround); - PARAM_POINTER(params, FLookExParams); - ACTION_RETURN_BOOL(P_LookForTID(self, allaround, params)); -} - //============================================================================ // // LookForEnemiesinBlock @@ -1625,7 +1510,7 @@ AActor *LookForEnemiesInBlock (AActor *lookee, int index, void *extparam) // //============================================================================ -bool P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params) +int P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params) { AActor *other; @@ -1667,14 +1552,6 @@ bool P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params) return false; } -DEFINE_ACTION_FUNCTION(AActor, LookForEnemies) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(allaround); - PARAM_POINTER(params, FLookExParams); - ACTION_RETURN_BOOL(P_LookForEnemies(self, allaround, params)); -} - /* ================ @@ -1686,7 +1563,7 @@ DEFINE_ACTION_FUNCTION(AActor, LookForEnemies) ================ */ -bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) +int P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) { int c; int pnum; @@ -1862,14 +1739,6 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) } } -DEFINE_ACTION_FUNCTION(AActor, LookForPlayers) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(allaround); - PARAM_POINTER(params, FLookExParams); - ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params)); -} - // // ACTION ROUTINES // @@ -2216,14 +2085,6 @@ enum ChaseFlags CHF_STOPIFBLOCKED = 256, }; -DEFINE_ACTION_FUNCTION(AActor, A_Wander) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(flags); - A_Wander(self, flags); - return 0; -} - void A_Wander(AActor *self, int flags) { // [RH] Strife probably clears this flag somewhere, but I couldn't find where. @@ -2752,7 +2613,7 @@ bool P_CanResurrect(AActor *raiser, AActor *thing) // //========================================================================== -static bool P_CheckForResurrection(AActor *self, bool usevilestates) +bool P_CheckForResurrection(AActor *self, bool usevilestates) { const AActor *info; AActor *temp; @@ -2898,26 +2759,27 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) return false; } -//========================================================================== -// -// A_Chase and variations -// -//========================================================================== + +// for internal use +void A_Chase(AActor *self) +{ + A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); +} DEFINE_ACTION_FUNCTION(AActor, A_Chase) { PARAM_SELF_PROLOGUE(AActor); - PARAM_STATE (melee) - PARAM_STATE (missile) - PARAM_INT (flags) + PARAM_STATE(melee); + PARAM_STATE(missile); + PARAM_INT(flags); if (melee != nullptr || missile != nullptr || flags != 0x40000000) { if ((flags & CHF_RESURRECT) && P_CheckForResurrection(self, false)) return 0; - - A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), - !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags & 0x3fffffff); + + A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), + !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags & 0x3fffffff); } else // this is the old default A_Chase { @@ -2926,50 +2788,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_Chase) return 0; } -DEFINE_ACTION_FUNCTION(AActor, A_FastChase) -{ - PARAM_SELF_PROLOGUE(AActor); - A_DoChase(self, true, self->MeleeState, self->MissileState, true, true, false, 0); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_VileChase) -{ - PARAM_SELF_PROLOGUE(AActor); - if (!P_CheckForResurrection(self, true)) - { - A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); - } - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_ExtChase) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL (domelee); - PARAM_BOOL (domissile); - PARAM_BOOL (playactive); - PARAM_BOOL (nightmarefast); - - // Now that A_Chase can handle state label parameters, this function has become rather useless... - A_DoChase(self, false, - domelee ? self->MeleeState : NULL, domissile ? self->MissileState : NULL, - playactive, nightmarefast, false, 0); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_CheckForResurrection) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(P_CheckForResurrection(self, false)); -} - -// for internal use -void A_Chase(AActor *self) -{ - A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); -} - //============================================================================= // // A_FaceTarget @@ -3089,21 +2907,6 @@ void A_FaceTarget(AActor *self) A_Face(self, self->target); } -DEFINE_ACTION_FUNCTION(AActor, A_Face) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT(faceto, AActor) - PARAM_ANGLE(max_turn) - PARAM_ANGLE(max_pitch) - PARAM_ANGLE(ang_offset) - PARAM_ANGLE(pitch_offset) - PARAM_INT(flags) - PARAM_FLOAT(z_add) - - A_Face(self, faceto, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add); - return 0; -} - //=========================================================================== // // [RH] A_MonsterRail @@ -3224,7 +3027,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain) return 0; } -bool CheckBossDeath (AActor *actor) +int CheckBossDeath (AActor *actor) { int i; @@ -3254,12 +3057,6 @@ bool CheckBossDeath (AActor *actor) return true; } -DEFINE_ACTION_FUNCTION(AActor, CheckBossDeath) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(CheckBossDeath(self)); -} - // // A_BossDeath // Possibly trigger special effects if on a boss level @@ -3364,13 +3161,6 @@ void A_BossDeath(AActor *self) G_ExitLevel (0, false); } -DEFINE_ACTION_FUNCTION(AActor, A_BossDeath) -{ - PARAM_SELF_PROLOGUE(AActor); - A_BossDeath(self); - return 0; -} - //---------------------------------------------------------------------------- // // PROC P_Massacre diff --git a/src/p_enemy.h b/src/p_enemy.h index 3a4a4e3ea..3086cbb50 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -45,27 +45,35 @@ struct FLookExParams FState *seestate; }; -bool P_HitFriend (AActor *self); -void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false, double maxdist=0); +int P_HitFriend (AActor *self); +void P_NoiseAlert (AActor *emmiter, AActor *target, bool splash=false, double maxdist=0); bool P_CheckMeleeRange2 (AActor *actor); -bool P_Move (AActor *actor); +int P_Move (AActor *actor); bool P_TryWalk (AActor *actor); void P_NewChaseDir (AActor *actor); +void P_RandomChaseDir(AActor *actor);; +int P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams *params); + AActor *P_DropItem (AActor *source, PClassActor *type, int special, int chance); void P_TossItem (AActor *item); -bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params); +int P_LookForMonsters(AActor *actor); +int P_LookForTID(AActor *actor, INTBOOL allaround, FLookExParams *params); +int P_LookForEnemies(AActor *actor, INTBOOL allaround, FLookExParams *params); +int P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params); void A_Weave(AActor *self, int xyspeed, int zspeed, double xydist, double zdist); void A_Unblock(AActor *self, bool drop); void A_BossDeath(AActor *self); void A_Wander(AActor *self, int flags = 0); +void A_DoChase(AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags); void A_Chase(AActor *self); void A_FaceTarget(AActor *actor); void A_Face(AActor *self, AActor *other, DAngle max_turn = 0., DAngle max_pitch = 270., DAngle ang_offset = 0., DAngle pitch_offset = 0., int flags = 0, double z_add = 0); +bool P_CheckForResurrection(AActor *self, bool usevilestates); -bool CheckBossDeath (AActor *); +int CheckBossDeath (AActor *); int P_Massacre (bool baddies = false, PClassActor *cls = nullptr); bool P_CheckMissileRange (AActor *actor); diff --git a/src/p_linetracedata.h b/src/p_linetracedata.h index b05b694d5..7dc74b334 100644 --- a/src/p_linetracedata.h +++ b/src/p_linetracedata.h @@ -23,4 +23,8 @@ struct FLineTraceData ETraceResult HitType; }; +int P_LineTrace(AActor *t1, DAngle angle, double distance, + DAngle pitch, int flags, double sz, double offsetforward, + double offsetside, FLineTraceData *outdata); + #endif diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index fd98b9515..24f23fab3 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3177,7 +3177,7 @@ FUNC(LS_NoiseAlert) emitter = iter.Next(); } - P_NoiseAlert (target, emitter); + P_NoiseAlert (emitter, target); return true; } diff --git a/src/p_local.h b/src/p_local.h index 8e4c415a2..80f4770e7 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -257,8 +257,8 @@ extern TArray spechit; extern TArray portalhit; -bool P_TestMobjLocation (AActor *mobj); -bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); +int P_TestMobjLocation (AActor *mobj); +int P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false); bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false); AActor *P_CheckOnmobj (AActor *thing); @@ -266,6 +266,7 @@ void P_FakeZMovement (AActor *mo); bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false); bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL, bool missilecheck = false); +bool P_CheckMove(AActor *thing, const DVector2 &pos, FCheckPosition& tm, int flags); bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags = 0); void P_ApplyTorque(AActor *mo); @@ -275,7 +276,7 @@ void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on t void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps); bool P_BounceWall (AActor *mo); bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop); -bool P_CheckSight (AActor *t1, AActor *t2, int flags=0); +int P_CheckSight (AActor *t1, AActor *t2, int flags=0); enum ESightFlags { @@ -288,7 +289,7 @@ enum ESightFlags void P_ResetSightCounters (bool full); bool P_TalkFacing (AActor *player); void P_UseLines (player_t* player); -bool P_UsePuzzleItem (AActor *actor, int itemType); +int P_UsePuzzleItem (AActor *actor, int itemType); enum { @@ -358,6 +359,7 @@ void P_TraceBleed (int damage, AActor *target); // random direction version bool P_HitFloor (AActor *thing); bool P_HitWater (AActor *thing, sector_t *sec, const DVector3 &pos, bool checkabove = false, bool alert = true, bool force = false); + struct FRailParams { AActor *source = nullptr; @@ -409,6 +411,7 @@ enum RADF_THRUSTZ = 16, RADF_OLDRADIUSDAMAGE = 32 }; +int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int fulldmgdistance, bool oldradiusdmg); int P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, FName damageType, int flags, int fulldamagedistance=0); diff --git a/src/p_map.cpp b/src/p_map.cpp index 3adb5fbe1..d84d3ae65 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -112,69 +112,6 @@ TArray spechit; TArray portalhit; -// FCheckPosition requires explicit contstruction and destruction when used in the VM -DEFINE_ACTION_FUNCTION(_FCheckPosition, _Constructor) -{ - PARAM_SELF_STRUCT_PROLOGUE(FCheckPosition); - new(self) FCheckPosition; - return 0; -} - -DEFINE_ACTION_FUNCTION(_FCheckPosition, _Destructor) -{ - PARAM_SELF_STRUCT_PROLOGUE(FCheckPosition); - self->~FCheckPosition(); - return 0; -} - -DEFINE_ACTION_FUNCTION(_FCheckPosition, ClearLastRipped) -{ - PARAM_SELF_STRUCT_PROLOGUE(FCheckPosition); - self->LastRipped.Clear(); - return 0; -} - -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos); -DEFINE_FIELD_NAMED_X(FCheckPosition, FCheckPosition, sector, cursector); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorz); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingz); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, dropoffz); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorpic); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorterrain); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorsector); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingpic); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingsector); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, touchmidtex); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, abovemidtex); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floatok); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, FromPMove); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingline); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, stepthing); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, DoRipping); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, portalstep); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, portalgroup); -DEFINE_FIELD_X(FCheckPosition, FCheckPosition, PushTime); - -DEFINE_FIELD_X(FRailParams, FRailParams, source); -DEFINE_FIELD_X(FRailParams, FRailParams, damage); -DEFINE_FIELD_X(FRailParams, FRailParams, offset_xy); -DEFINE_FIELD_X(FRailParams, FRailParams, offset_z); -DEFINE_FIELD_X(FRailParams, FRailParams, color1); -DEFINE_FIELD_X(FRailParams, FRailParams, color2); -DEFINE_FIELD_X(FRailParams, FRailParams, maxdiff); -DEFINE_FIELD_X(FRailParams, FRailParams, flags); -DEFINE_FIELD_X(FRailParams, FRailParams, puff); -DEFINE_FIELD_X(FRailParams, FRailParams, angleoffset); -DEFINE_FIELD_X(FRailParams, FRailParams, pitchoffset); -DEFINE_FIELD_X(FRailParams, FRailParams, distance); -DEFINE_FIELD_X(FRailParams, FRailParams, duration); -DEFINE_FIELD_X(FRailParams, FRailParams, sparsity); -DEFINE_FIELD_X(FRailParams, FRailParams, drift); -DEFINE_FIELD_X(FRailParams, FRailParams, spawnclass); -DEFINE_FIELD_X(FRailParams, FRailParams, SpiralOffset); -DEFINE_FIELD_X(FRailParams, FRailParams, limit); - //========================================================================== // // CanCollideWith @@ -433,13 +370,6 @@ void P_FindFloorCeiling(AActor *actor, int flags) } } -DEFINE_ACTION_FUNCTION(AActor, FindFloorCeiling) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(flags); - P_FindFloorCeiling(self, flags); - return 0; -} // Debug CCMD for checking errors in the MultiBlockLinesIterator (needs to be removed when this code is complete) CCMD(ffcf) @@ -595,17 +525,6 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi return true; } -DEFINE_ACTION_FUNCTION(AActor, TeleportMove) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - PARAM_BOOL(telefrag); - PARAM_BOOL(modify); - ACTION_RETURN_BOOL(P_TeleportMove(self, DVector3(x, y, z), telefrag, modify)); -} - //========================================================================== // // [RH] P_PlayerStartStomp @@ -812,22 +731,6 @@ double P_GetMoveFactor(const AActor *mo, double *frictionp) return movefactor; } -DEFINE_ACTION_FUNCTION(AActor, GetFriction) -{ - PARAM_SELF_PROLOGUE(AActor); - double friction, movefactor = P_GetMoveFactor(self, &friction); - if (numret > 1) - { - numret = 2; - ret[1].SetFloat(movefactor); - } - if (numret > 0) - { - ret[0].SetFloat(friction); - } - return numret; -} - //========================================================================== // // Checks if the line intersects with the actor @@ -1973,23 +1876,6 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly) return P_CheckPosition(thing, pos, tm, actorsonly); } -DEFINE_ACTION_FUNCTION(AActor, CheckPosition) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_BOOL(actorsonly); - PARAM_POINTER(tm, FCheckPosition); - if (tm) - { - ACTION_RETURN_BOOL(P_CheckPosition(self, DVector2(x, y), *tm, actorsonly)); - } - else - { - ACTION_RETURN_BOOL(P_CheckPosition(self, DVector2(x, y), actorsonly)); - } -} - //---------------------------------------------------------------------------- // @@ -2000,7 +1886,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckPosition) // //---------------------------------------------------------------------------- -bool P_TestMobjLocation(AActor *mobj) +int P_TestMobjLocation(AActor *mobj) { ActorFlags flags; @@ -2019,12 +1905,6 @@ bool P_TestMobjLocation(AActor *mobj) return false; } -DEFINE_ACTION_FUNCTION(AActor, TestMobjLocation) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(P_TestMobjLocation(self)); -} - //============================================================================= // // P_CheckOnmobj(AActor *thing) @@ -2035,7 +1915,7 @@ DEFINE_ACTION_FUNCTION(AActor, TestMobjLocation) AActor *P_CheckOnmobj(AActor *thing) { double oldz; - bool good; + int good; AActor *onmobj; oldz = thing->Z(); @@ -2052,12 +1932,12 @@ AActor *P_CheckOnmobj(AActor *thing) // //============================================================================= -bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) +int P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { - AActor *onmobj = NULL; + AActor *onmobj = nullptr; + if (pOnmobj) *pOnmobj = nullptr; if (actor->flags & MF_NOCLIP) { - if (pOnmobj) *pOnmobj = NULL; return true; } @@ -2133,25 +2013,6 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) return onmobj == NULL; } -DEFINE_ACTION_FUNCTION(AActor, TestMobjZ) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(quick); - - AActor *on = nullptr;; - bool retv = P_TestMobjZ(self, quick, &on); - if (numret > 1) - { - numret = 2; - ret[1].SetObject(on); - } - if (numret > 0) - { - ret[0].SetInt(retv); - } - return numret; -} - //============================================================================= // @@ -2384,9 +2245,8 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, else if (thing->Z() < tm.floorz) { // [RH] Check to make sure there's nothing in the way for the step up double savedz = thing->Z(); - bool good; thing->SetZ(tm.floorz); - good = P_TestMobjZ(thing); + auto good = P_TestMobjZ(thing); thing->SetZ(savedz); if (!good) { @@ -2786,24 +2646,6 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, return P_TryMove(thing, pos, dropoff, onfloor, tm, missilecheck); } -DEFINE_ACTION_FUNCTION(AActor, TryMove) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_INT(dropoff); - PARAM_BOOL(missilecheck); - PARAM_POINTER(tm, FCheckPosition); - if (tm == nullptr) - { - ACTION_RETURN_BOOL(P_TryMove(self, DVector2(x, y), dropoff, nullptr, missilecheck)); - } - else - { - ACTION_RETURN_BOOL(P_TryMove(self, DVector2(x, y), dropoff, nullptr, *tm, missilecheck)); - } -} - //========================================================================== // @@ -2812,7 +2654,7 @@ DEFINE_ACTION_FUNCTION(AActor, TryMove) // //========================================================================== -static bool P_CheckMove(AActor *thing, const DVector2 &pos, FCheckPosition& tm, int flags) +bool P_CheckMove(AActor *thing, const DVector2 &pos, FCheckPosition& tm, int flags) { double newz = thing->Z(); @@ -2879,7 +2721,7 @@ static bool P_CheckMove(AActor *thing, const DVector2 &pos, FCheckPosition& tm, { // [RH] Check to make sure there's nothing in the way for the step up double savedz = thing->Z(); thing->SetZ(newz = tm.floorz); - bool good = P_TestMobjZ(thing); + int good = P_TestMobjZ(thing); thing->SetZ(savedz); if (!good) { @@ -2912,23 +2754,6 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) return P_CheckMove(thing, pos, tm, flags); } -DEFINE_ACTION_FUNCTION(AActor, CheckMove) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_INT(flags); - PARAM_POINTER(tm, FCheckPosition); - if (tm == nullptr) - { - ACTION_RETURN_BOOL(P_CheckMove(self, DVector2(x, y), flags)); - } - else - { - ACTION_RETURN_BOOL(P_CheckMove(self, DVector2(x, y), *tm, flags)); - } -} - //========================================================================== // @@ -3159,7 +2984,7 @@ void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end) { // [RH] Check to make sure there's nothing in the way for the step up double savedz = slidemo->Z(); slidemo->SetZ(open.bottom); - bool good = P_TestMobjZ(slidemo); + int good = P_TestMobjZ(slidemo); slidemo->SetZ(savedz); if (!good) { @@ -4501,19 +4326,6 @@ DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLin return result->linetarget ? result->pitch : t1->Angles.Pitch; } -DEFINE_ACTION_FUNCTION(AActor, AimLineAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_ANGLE(angle); - PARAM_FLOAT(distance); - PARAM_OUTPOINTER(pLineTarget, FTranslatedLineTarget); - PARAM_ANGLE(vrange); - PARAM_INT(flags); - PARAM_OBJECT(target, AActor); - PARAM_OBJECT(friender, AActor); - ACTION_RETURN_FLOAT(P_AimLineAttack(self, angle, distance, pLineTarget, vrange, flags, target, friender).Degrees); -} - //========================================================================== // // Helper stuff for P_LineAttack @@ -4908,29 +4720,6 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, } } -DEFINE_ACTION_FUNCTION(AActor, LineAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_ANGLE(angle); - PARAM_FLOAT(distance); - PARAM_ANGLE(pitch); - PARAM_INT(damage); - PARAM_NAME(damageType); - PARAM_CLASS(puffType, AActor); - PARAM_INT(flags); - PARAM_OUTPOINTER(victim, FTranslatedLineTarget); - PARAM_FLOAT(offsetz); - PARAM_FLOAT(offsetforward); - PARAM_FLOAT(offsetside); - - int acdmg; - if (puffType == nullptr) puffType = PClass::FindActor("BulletPuff"); // P_LineAttack does not work without a puff to take info from. - auto puff = P_LineAttack(self, angle, distance, pitch, damage, damageType, puffType, flags, victim, &acdmg, offsetz, offsetforward, offsetside); - if (numret > 0) ret[0].SetObject(puff); - if (numret > 1) ret[1].SetInt(acdmg), numret = 2; - return numret; -} - //========================================================================== // // P_LineTrace @@ -4963,7 +4752,7 @@ static ETraceStatus CheckLineTrace(FTraceResults &res, void *userdata) return TRACE_Stop; } -bool P_LineTrace(AActor *t1, DAngle angle, double distance, +int P_LineTrace(AActor *t1, DAngle angle, double distance, DAngle pitch, int flags, double sz, double offsetforward, double offsetside, FLineTraceData *outdata) { @@ -5061,33 +4850,6 @@ bool P_LineTrace(AActor *t1, DAngle angle, double distance, return ret; } -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitActor); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitLine); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitSector); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, Hit3DFloor); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitTexture); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitLocation); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, Distance); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, NumPortals); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, LineSide); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, LinePart); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, SectorPlane); -DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitType); - -DEFINE_ACTION_FUNCTION(AActor, LineTrace) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_ANGLE(angle); - PARAM_FLOAT(distance); - PARAM_ANGLE(pitch); - PARAM_INT(flags); - PARAM_FLOAT(offsetz); - PARAM_FLOAT(offsetforward); - PARAM_FLOAT(offsetside); - PARAM_OUTPOINTER(data, FLineTraceData); - ACTION_RETURN_BOOL(P_LineTrace(self,angle,distance,pitch,flags,offsetz,offsetforward,offsetside,data)); -} - //========================================================================== // // P_LinePickActor @@ -5224,17 +4986,6 @@ void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch) P_TraceBleed(damage, target->PosPlusZ(target->Height/2), target, angle, pitch); } -DEFINE_ACTION_FUNCTION(AActor, TraceBleedAngle) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(damage); - PARAM_FLOAT(angle); - PARAM_FLOAT(pitch); - - P_TraceBleed(damage, self, angle, pitch); - return 0; -} - //========================================================================== // @@ -5282,16 +5033,6 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff) P_TraceBleed(damage, t->linetarget->PosPlusZ(t->linetarget->Height/2), t->linetarget, t->angleFromSource, pitch); } -DEFINE_ACTION_FUNCTION(_FTranslatedLineTarget, TraceBleed) -{ - PARAM_SELF_STRUCT_PROLOGUE(FTranslatedLineTarget); - PARAM_INT(damage); - PARAM_OBJECT_NOT_NULL(missile, AActor); - - P_TraceBleed(damage, self, missile); - return 0; -} - //========================================================================== // @@ -5309,18 +5050,6 @@ void P_TraceBleed(int damage, AActor *target) } } -DEFINE_ACTION_FUNCTION(AActor, TraceBleed) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(damage); - PARAM_OBJECT(missile, AActor); - - if (missile) P_TraceBleed(damage, self, missile); - else P_TraceBleed(damage, self); - return 0; -} - - //========================================================================== // // [RH] Rail gun stuffage @@ -5595,15 +5324,6 @@ void P_RailAttack(FRailParams *p) P_DrawRailTrail(source, rail_data.PortalHits, p->color1, p->color2, p->maxdiff, p->flags, p->spawnclass, angle, p->duration, p->sparsity, p->drift, p->SpiralOffset, pitch); } -DEFINE_ACTION_FUNCTION(AActor, RailAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_POINTER(p, FRailParams); - p->source = self; - P_RailAttack(p); - return 0; -} - //========================================================================== // // [RH] P_AimCamera @@ -5890,7 +5610,7 @@ void P_UseLines(player_t *player) // //========================================================================== -bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) +int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { DVector2 start; DVector2 end; @@ -5955,13 +5675,6 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) return false; } -DEFINE_ACTION_FUNCTION(AActor, UsePuzzleItem) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(puzznum); - ACTION_RETURN_BOOL(P_UsePuzzleItem(self, puzznum)); -} - //========================================================================== // // RADIUS ATTACK @@ -5991,7 +5704,7 @@ CUSTOM_CVAR(Float, splashfactor, 1.f, CVAR_SERVERINFO) // Used by anything without OLDRADIUSDMG flag //========================================================================== -static double P_GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, int bombdistance, int fulldamagedistance, bool thingbombsource) +static double GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, int bombdistance, int fulldamagedistance, bool thingbombsource) { // [RH] New code. The bounding box only covers the // height of the thing and not the height of the map. @@ -6068,7 +5781,7 @@ static double P_GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing // based on XY distance. //========================================================================== -static int P_GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, int bombdistance, int fulldamagedistance) +static int GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, int bombdistance, int fulldamagedistance) { const int ret = fromaction ? 0 : -1; // -1 is specifically for P_RadiusAttack; continue onto another actor. double dx, dy, dist; @@ -6112,22 +5825,16 @@ static int P_GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing // damage and not taking into account any damage reduction. //========================================================================== -DEFINE_ACTION_FUNCTION(AActor, GetRadiusDamage) +int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int fulldmgdistance, bool oldradiusdmg) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT(thing, AActor); - PARAM_INT(damage); - PARAM_INT(distance); - PARAM_INT(fulldmgdistance); - PARAM_BOOL(oldradiusdmg); if (!thing) { - ACTION_RETURN_INT(0); + return 0; } else if (thing == self) { // No point in calculating falloff in this case since it is the bomb spot. - ACTION_RETURN_INT(damage); + return damage; } fulldmgdistance = clamp(fulldmgdistance, 0, distance - 1); @@ -6137,10 +5844,10 @@ DEFINE_ACTION_FUNCTION(AActor, GetRadiusDamage) distance = damage; const int newdam = oldradiusdmg - ? P_GetOldRadiusDamage(true, self, thing, damage, distance, fulldmgdistance) - : int(P_GetRadiusDamage(true, self, thing, damage, distance, fulldmgdistance, false)); + ? GetOldRadiusDamage(true, self, thing, damage, distance, fulldmgdistance) + : int(GetRadiusDamage(true, self, thing, damage, distance, fulldmgdistance, false)); - ACTION_RETURN_INT(newdam); + return newdam; } //========================================================================== @@ -6204,7 +5911,7 @@ int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bom // which can make them near impossible to hit with the new code. if (((flags & RADF_NODAMAGE) || !((bombspot->flags5 | thing->flags5) & MF5_OLDRADIUSDMG)) && !(flags & RADF_OLDRADIUSDAMAGE)) { - double points = P_GetRadiusDamage(false, bombspot, thing, bombdamage, bombdistance, fulldamagedistance, bombsource == thing); + double points = GetRadiusDamage(false, bombspot, thing, bombdamage, bombdistance, fulldamagedistance, bombsource == thing); double check = int(points) * bombdamage; // points and bombdamage should be the same sign (the double cast of 'points' is needed to prevent overflows and incorrect values slipping through.) if ((check > 0 || (check == 0 && bombspot->flags7 & MF7_FORCEZERORADIUSDMG)) && P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) @@ -6262,7 +5969,7 @@ int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bom else { // [RH] Old code just for barrels - int damage = P_GetOldRadiusDamage(false, bombspot, thing, bombdamage, bombdistance, fulldamagedistance); + int damage = GetOldRadiusDamage(false, bombspot, thing, bombdamage, bombdistance, fulldamagedistance); if (damage < 0) continue; // Sight check failed. @@ -6279,18 +5986,6 @@ int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bom return count; } -DEFINE_ACTION_FUNCTION(AActor, RadiusAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT(bombsource, AActor); - PARAM_INT(bombdamage); - PARAM_INT(bombdistance); - PARAM_NAME(damagetype); - PARAM_INT(flags); - PARAM_INT(fulldamagedistance); - ACTION_RETURN_INT(P_RadiusAttack(self, bombsource, bombdamage, bombdistance, damagetype, flags, fulldamagedistance)); -} - //========================================================================== // // SECTOR HEIGHT CHANGING diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 13f6bc5d4..aa00a9047 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -345,15 +345,6 @@ void AActor::UnlinkFromWorld (FLinkContext *ctx) ClearRenderLineList(); } -DEFINE_ACTION_FUNCTION(AActor, UnlinkFromWorld) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_POINTER(ctx, FLinkContext); - self->UnlinkFromWorld(ctx); // fixme - return 0; -} - - //========================================================================== // // If the thing is exactly on a line, move it into the sector @@ -564,14 +555,6 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec if (!spawningmapthing) UpdateRenderSectorList(); } -DEFINE_ACTION_FUNCTION(AActor, LinkToWorld) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_POINTER(ctx, FLinkContext); - self->LinkToWorld(ctx); - return 0; -} - void AActor::SetOrigin(double x, double y, double z, bool moving) { FLinkContext ctx; @@ -582,17 +565,6 @@ void AActor::SetOrigin(double x, double y, double z, bool moving) if (!moving) ClearInterpolation(); } -DEFINE_ACTION_FUNCTION(AActor, SetOrigin) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - PARAM_BOOL(moving); - self->SetOrigin(x, y, z, moving); - return 0; -} - //=========================================================================== // // FBlockNode - allows to link actors into multiple blocks in the blockmap @@ -938,74 +910,6 @@ void FMultiBlockLinesIterator::Reset() startIteratorForGroup(basegroup); } -//=========================================================================== -// -// and the scriptable version -// -//=========================================================================== - -class DBlockLinesIterator : public DObject, public FMultiBlockLinesIterator -{ - DECLARE_ABSTRACT_CLASS(DBlockLinesIterator, DObject); - FPortalGroupArray check; - -public: - FMultiBlockLinesIterator::CheckResult cres; - - bool Next() - { - return FMultiBlockLinesIterator::Next(&cres); - } - - DBlockLinesIterator(AActor *actor, double checkradius) - : FMultiBlockLinesIterator(check, actor, checkradius) - { - cres.line = nullptr; - cres.Position.Zero(); - cres.portalflags = 0; - } - - DBlockLinesIterator(double x, double y, double z, double height, double radius, sector_t *sec) - :FMultiBlockLinesIterator(check, x, y, z, height, radius, sec) - { - cres.line = nullptr; - cres.Position.Zero(); - cres.portalflags = 0; - } -}; - -IMPLEMENT_CLASS(DBlockLinesIterator, true, false); - -DEFINE_ACTION_FUNCTION(DBlockLinesIterator, Create) -{ - PARAM_PROLOGUE; - PARAM_OBJECT_NOT_NULL(origin, AActor); - PARAM_FLOAT(radius); - ACTION_RETURN_OBJECT(Create(origin, radius)); -} - -DEFINE_ACTION_FUNCTION(DBlockLinesIterator, CreateFromPos) -{ - PARAM_PROLOGUE; - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - PARAM_FLOAT(h); - PARAM_FLOAT(radius); - PARAM_POINTER(sec, sector_t); - ACTION_RETURN_OBJECT(Create(x, y, z, h, radius, sec)); -} - -DEFINE_ACTION_FUNCTION(DBlockLinesIterator, Next) -{ - PARAM_SELF_PROLOGUE(DBlockLinesIterator); - ACTION_RETURN_BOOL(self->Next()); -} - -DEFINE_FIELD_NAMED(DBlockLinesIterator, cres.line, curline); -DEFINE_FIELD_NAMED(DBlockLinesIterator, cres.Position, position); -DEFINE_FIELD_NAMED(DBlockLinesIterator, cres.portalflags, portalflags); - //=========================================================================== // // FBlockThingsIterator :: FBlockThingsIterator @@ -1277,75 +1181,6 @@ void FMultiBlockThingsIterator::Reset() startIteratorForGroup(basegroup); } -//=========================================================================== -// -// and the scriptable version -// -//=========================================================================== - -class DBlockThingsIterator : public DObject -{ - DECLARE_ABSTRACT_CLASS(DBlockThingsIterator, DObject); - FPortalGroupArray check; - FMultiBlockThingsIterator iterator; -public: - FMultiBlockThingsIterator::CheckResult cres; - - bool Next() - { - return iterator.Next(&cres); - } - - DBlockThingsIterator(AActor *origin, double checkradius = -1, bool ignorerestricted = false) - : iterator(check, origin, checkradius, ignorerestricted) - { - cres.thing = nullptr; - cres.Position.Zero(); - cres.portalflags = 0; - } - - DBlockThingsIterator(double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec) - : iterator(check, checkx, checky, checkz, checkh, checkradius, ignorerestricted, newsec) - { - cres.thing = nullptr; - cres.Position.Zero(); - cres.portalflags = 0; - } -}; - -IMPLEMENT_CLASS(DBlockThingsIterator, true, false); - -DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Create) -{ - PARAM_PROLOGUE; - PARAM_OBJECT_NOT_NULL(origin, AActor); - PARAM_FLOAT(radius); - PARAM_BOOL(ignore); - ACTION_RETURN_OBJECT(Create(origin, radius, ignore)); -} - -DEFINE_ACTION_FUNCTION(DBlockThingsIterator, CreateFromPos) -{ - PARAM_PROLOGUE; - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - PARAM_FLOAT(h); - PARAM_FLOAT(radius); - PARAM_BOOL(ignore); - ACTION_RETURN_OBJECT(Create(x, y, z, h, radius, ignore, nullptr)); -} - -DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Next) -{ - PARAM_SELF_PROLOGUE(DBlockThingsIterator); - ACTION_RETURN_BOOL(self->Next()); -} - -DEFINE_FIELD_NAMED(DBlockThingsIterator, cres.thing, thing); -DEFINE_FIELD_NAMED(DBlockThingsIterator, cres.Position, position); -DEFINE_FIELD_NAMED(DBlockThingsIterator, cres.portalflags, portalflags); - //=========================================================================== // // FPathTraverse :: Intercepts @@ -2024,15 +1859,6 @@ AActor *P_RoughMonsterSearch(AActor *mo, int distance, bool onlyseekable, bool f return P_BlockmapSearch(mo, distance, RoughBlockCheck, (void *)&info); } -DEFINE_ACTION_FUNCTION(AActor, RoughMonsterSearch) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(distance); - PARAM_BOOL(onlyseekable); - PARAM_BOOL(frontonly); - ACTION_RETURN_OBJECT(P_RoughMonsterSearch(self, distance, onlyseekable, frontonly)); -} - //========================================================================== // // [RH] LinkToWorldForMapThing diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 497cd7e91..ea05706d5 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -178,179 +178,6 @@ AActor::~AActor () // Use Destroy() instead. } -DEFINE_FIELD(AActor, snext) -DEFINE_FIELD(AActor, player) -DEFINE_FIELD_NAMED(AActor, __Pos, pos) -DEFINE_FIELD_NAMED(AActor, __Pos.X, x) -DEFINE_FIELD_NAMED(AActor, __Pos.Y, y) -DEFINE_FIELD_NAMED(AActor, __Pos.Z, z) -DEFINE_FIELD(AActor, Prev) -DEFINE_FIELD(AActor, SpriteAngle) -DEFINE_FIELD(AActor, SpriteRotation) -DEFINE_FIELD(AActor, VisibleStartAngle) -DEFINE_FIELD(AActor, VisibleStartPitch) -DEFINE_FIELD(AActor, VisibleEndAngle) -DEFINE_FIELD(AActor, VisibleEndPitch) -DEFINE_FIELD_NAMED(AActor, Angles.Yaw, angle) -DEFINE_FIELD_NAMED(AActor, Angles.Pitch, pitch) -DEFINE_FIELD_NAMED(AActor, Angles.Roll, roll) -DEFINE_FIELD(AActor, Vel) -DEFINE_FIELD_NAMED(AActor, Vel.X, velx) -DEFINE_FIELD_NAMED(AActor, Vel.Y, vely) -DEFINE_FIELD_NAMED(AActor, Vel.Z, velz) -DEFINE_FIELD_NAMED(AActor, Vel.X, momx) -DEFINE_FIELD_NAMED(AActor, Vel.Y, momy) -DEFINE_FIELD_NAMED(AActor, Vel.Z, momz) -DEFINE_FIELD(AActor, Speed) -DEFINE_FIELD(AActor, FloatSpeed) -DEFINE_FIELD(AActor, sprite) -DEFINE_FIELD(AActor, frame) -DEFINE_FIELD(AActor, Scale) -DEFINE_FIELD_NAMED(AActor, Scale.X, scalex) -DEFINE_FIELD_NAMED(AActor, Scale.Y, scaley) -DEFINE_FIELD(AActor, RenderStyle) -DEFINE_FIELD(AActor, picnum) -DEFINE_FIELD(AActor, Alpha) -DEFINE_FIELD(AActor, fillcolor) -DEFINE_FIELD_NAMED(AActor, Sector, CurSector) // clashes with type 'sector'. -DEFINE_FIELD(AActor, subsector) -DEFINE_FIELD(AActor, ceilingz) -DEFINE_FIELD(AActor, floorz) -DEFINE_FIELD(AActor, dropoffz) -DEFINE_FIELD(AActor, floorsector) -DEFINE_FIELD(AActor, floorpic) -DEFINE_FIELD(AActor, floorterrain) -DEFINE_FIELD(AActor, ceilingsector) -DEFINE_FIELD(AActor, ceilingpic) -DEFINE_FIELD(AActor, Height) -DEFINE_FIELD(AActor, radius) -DEFINE_FIELD(AActor, renderradius) -DEFINE_FIELD(AActor, projectilepassheight) -DEFINE_FIELD(AActor, tics) -DEFINE_FIELD_NAMED(AActor, state, curstate) // clashes with type 'state'. -DEFINE_FIELD_NAMED(AActor, DamageVal, Damage) // name differs for historic reasons -DEFINE_FIELD(AActor, projectileKickback) -DEFINE_FIELD(AActor, VisibleToTeam) -DEFINE_FIELD(AActor, special1) -DEFINE_FIELD(AActor, special2) -DEFINE_FIELD(AActor, specialf1) -DEFINE_FIELD(AActor, specialf2) -DEFINE_FIELD(AActor, weaponspecial) -DEFINE_FIELD(AActor, health) -DEFINE_FIELD(AActor, movedir) -DEFINE_FIELD(AActor, visdir) -DEFINE_FIELD(AActor, movecount) -DEFINE_FIELD(AActor, strafecount) -DEFINE_FIELD(AActor, target) -DEFINE_FIELD(AActor, master) -DEFINE_FIELD(AActor, tracer) -DEFINE_FIELD(AActor, LastHeard) -DEFINE_FIELD(AActor, lastenemy) -DEFINE_FIELD(AActor, LastLookActor) -DEFINE_FIELD(AActor, reactiontime) -DEFINE_FIELD(AActor, threshold) -DEFINE_FIELD(AActor, DefThreshold) -DEFINE_FIELD(AActor, SpawnPoint) -DEFINE_FIELD(AActor, SpawnAngle) -DEFINE_FIELD(AActor, StartHealth) -DEFINE_FIELD(AActor, WeaveIndexXY) -DEFINE_FIELD(AActor, WeaveIndexZ) -DEFINE_FIELD(AActor, skillrespawncount) -DEFINE_FIELD(AActor, args) -DEFINE_FIELD(AActor, Mass) -DEFINE_FIELD(AActor, special) -DEFINE_FIELD(AActor, tid) -DEFINE_FIELD(AActor, TIDtoHate) -DEFINE_FIELD(AActor, waterlevel) -DEFINE_FIELD(AActor, Score) -DEFINE_FIELD(AActor, accuracy) -DEFINE_FIELD(AActor, stamina) -DEFINE_FIELD(AActor, meleerange) -DEFINE_FIELD(AActor, PainThreshold) -DEFINE_FIELD(AActor, Gravity) -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) -DEFINE_FIELD(AActor, Species) -DEFINE_FIELD(AActor, alternative) -DEFINE_FIELD(AActor, goal) -DEFINE_FIELD(AActor, MinMissileChance) -DEFINE_FIELD(AActor, LastLookPlayerNumber) -DEFINE_FIELD(AActor, SpawnFlags) -DEFINE_FIELD(AActor, meleethreshold) -DEFINE_FIELD(AActor, maxtargetrange) -DEFINE_FIELD(AActor, bouncefactor) -DEFINE_FIELD(AActor, wallbouncefactor) -DEFINE_FIELD(AActor, bouncecount) -DEFINE_FIELD(AActor, Friction) -DEFINE_FIELD(AActor, FastChaseStrafeCount) -DEFINE_FIELD(AActor, pushfactor) -DEFINE_FIELD(AActor, lastpush) -DEFINE_FIELD(AActor, activationtype) -DEFINE_FIELD(AActor, lastbump) -DEFINE_FIELD(AActor, DesignatedTeam) -DEFINE_FIELD(AActor, BlockingMobj) -DEFINE_FIELD(AActor, BlockingLine) -DEFINE_FIELD(AActor, Blocking3DFloor) -DEFINE_FIELD(AActor, BlockingCeiling) -DEFINE_FIELD(AActor, BlockingFloor) -DEFINE_FIELD(AActor, PoisonDamage) -DEFINE_FIELD(AActor, PoisonDamageType) -DEFINE_FIELD(AActor, PoisonDuration) -DEFINE_FIELD(AActor, PoisonPeriod) -DEFINE_FIELD(AActor, PoisonDamageReceived) -DEFINE_FIELD(AActor, PoisonDamageTypeReceived) -DEFINE_FIELD(AActor, PoisonDurationReceived) -DEFINE_FIELD(AActor, PoisonPeriodReceived) -DEFINE_FIELD(AActor, Poisoner) -DEFINE_FIELD_NAMED(AActor, Inventory, Inv) // clashes with type 'Inventory'. -DEFINE_FIELD(AActor, smokecounter) -DEFINE_FIELD(AActor, FriendPlayer) -DEFINE_FIELD(AActor, Translation) -DEFINE_FIELD(AActor, AttackSound) -DEFINE_FIELD(AActor, DeathSound) -DEFINE_FIELD(AActor, SeeSound) -DEFINE_FIELD(AActor, PainSound) -DEFINE_FIELD(AActor, ActiveSound) -DEFINE_FIELD(AActor, UseSound) -DEFINE_FIELD(AActor, BounceSound) -DEFINE_FIELD(AActor, WallBounceSound) -DEFINE_FIELD(AActor, CrushPainSound) -DEFINE_FIELD(AActor, MaxDropOffHeight) -DEFINE_FIELD(AActor, MaxStepHeight) -DEFINE_FIELD(AActor, PainChance) -DEFINE_FIELD(AActor, PainType) -DEFINE_FIELD(AActor, DeathType) -DEFINE_FIELD(AActor, DamageFactor) -DEFINE_FIELD(AActor, DamageMultiply) -DEFINE_FIELD(AActor, TeleFogSourceType) -DEFINE_FIELD(AActor, TeleFogDestType) -DEFINE_FIELD(AActor, SpawnState) -DEFINE_FIELD(AActor, SeeState) -DEFINE_FIELD(AActor, MeleeState) -DEFINE_FIELD(AActor, MissileState) -DEFINE_FIELD(AActor, ConversationRoot) -DEFINE_FIELD(AActor, Conversation) -DEFINE_FIELD(AActor, DecalGenerator) -DEFINE_FIELD(AActor, fountaincolor) -DEFINE_FIELD(AActor, CameraHeight) -DEFINE_FIELD(AActor, CameraFOV) -DEFINE_FIELD(AActor, RadiusDamageFactor) -DEFINE_FIELD(AActor, SelfDamageFactor) -DEFINE_FIELD(AActor, StealthAlpha) -DEFINE_FIELD(AActor, WoundHealth) -DEFINE_FIELD(AActor, BloodColor) -DEFINE_FIELD(AActor, BloodTranslation) -DEFINE_FIELD(AActor, RenderHidden) -DEFINE_FIELD(AActor, RenderRequired) -DEFINE_FIELD(AActor, friendlyseeblocks) -DEFINE_FIELD(AActor, SpawnTime) -DEFINE_FIELD(AActor, InventoryID) //========================================================================== // @@ -3158,25 +2985,6 @@ void AActor::RemoveFromHash () tid = 0; } -DEFINE_ACTION_FUNCTION(AActor, RemoveFromHash) -{ - PARAM_SELF_PROLOGUE(AActor); - self->RemoveFromHash(); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, ChangeTid) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(tid); - self->RemoveFromHash(); - self->tid = tid; - self->AddToHash(); - return 0; -} - - - //========================================================================== // // P_IsTIDUsed @@ -3259,16 +3067,6 @@ int P_FindUniqueTID(int start_tid, int limit) return 0; } -DEFINE_ACTION_FUNCTION(AActor, FindUniqueTid) -{ - PARAM_PROLOGUE; - PARAM_INT(start); - PARAM_INT(limit); - ACTION_RETURN_INT(P_FindUniqueTID(start, limit)); -} - - - CCMD(utid) { @@ -6130,12 +5928,6 @@ int P_GetThingFloorType (AActor *thing) } } -DEFINE_ACTION_FUNCTION(AActor, GetFloorTerrain) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_POINTER(&Terrains[P_GetThingFloorType(self)]); -} - //--------------------------------------------------------------------------- // @@ -6499,7 +6291,8 @@ DEFINE_ACTION_FUNCTION(AActor, PlaySpawnSound) } -static double GetDefaultSpeed(PClassActor *type) + +double GetDefaultSpeed(PClassActor *type) { if (type == NULL) return 0; @@ -6513,13 +6306,6 @@ static double GetDefaultSpeed(PClassActor *type) return def->Speed; } -DEFINE_ACTION_FUNCTION(AActor, GetDefaultSpeed) -{ - PARAM_PROLOGUE; - PARAM_CLASS(type, AActor); - ACTION_RETURN_FLOAT(GetDefaultSpeed(type)); -} - //--------------------------------------------------------------------------- // // FUNC P_SpawnMissile @@ -7013,13 +6799,6 @@ bool AActor::IsTeammate (AActor *other) return false; } -DEFINE_ACTION_FUNCTION(AActor, isTeammate) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_BOOL(self->IsTeammate(other)); -} - //========================================================================== // // AActor :: GetSpecies @@ -7053,12 +6832,6 @@ FName AActor::GetSpecies() return Species = thistype->TypeName; // [GZ] Speeds up future calls. } -DEFINE_ACTION_FUNCTION(AActor, GetSpecies) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(self->GetSpecies()); -} - //========================================================================== // // AActor :: IsFriend @@ -7088,13 +6861,6 @@ bool AActor::IsFriend (AActor *other) return false; } -DEFINE_ACTION_FUNCTION(AActor, isFriend) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_BOOL(self->IsFriend(other)); -} - //========================================================================== // // AActor :: IsHostile @@ -7125,14 +6891,6 @@ bool AActor::IsHostile (AActor *other) return true; } -DEFINE_ACTION_FUNCTION(AActor, isHostile) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_BOOL(self->IsHostile(other)); -} - - //========================================================================== // // AActor :: DoSpecialDamage @@ -7239,6 +6997,7 @@ DEFINE_ACTION_FUNCTION(AActor, TakeSpecialDamage) ACTION_RETURN_INT(self->TakeSpecialDamage(inflictor, source, damage, damagetype)); } + int AActor::CallTakeSpecialDamage(AActor *inflictor, AActor *source, int damage, FName damagetype) { IFVIRTUAL(AActor, TakeSpecialDamage) @@ -7304,13 +7063,6 @@ void AActor::SetIdle(bool nofunction) SetState(idle, nofunction); } -DEFINE_ACTION_FUNCTION(AActor, SetIdle) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(nofunction); - self->SetIdle(nofunction); - return 0; -} int AActor::SpawnHealth() const { @@ -7331,12 +7083,6 @@ int AActor::SpawnHealth() const } } -DEFINE_ACTION_FUNCTION(AActor, SpawnHealth) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(self->SpawnHealth()); -} - FState *AActor::GetRaiseState() { if (!(flags & MF_CORPSE)) @@ -7390,13 +7136,6 @@ void AActor::Revive() E_WorldThingRevived(this); } -DEFINE_ACTION_FUNCTION(AActor, Revive) -{ - PARAM_SELF_PROLOGUE(AActor); - self->Revive(); - return 0; -} - int AActor::GetGibHealth() const { IFVIRTUAL(AActor, GetGibHealth) @@ -7410,41 +7149,6 @@ int AActor::GetGibHealth() const return -SpawnHealth(); } -double AActor::GetCameraHeight() const -{ - return CameraHeight == INT_MIN ? Height / 2 : CameraHeight; -} - -DEFINE_ACTION_FUNCTION(AActor, GetCameraHeight) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_FLOAT(self->GetCameraHeight()); -} - - -FDropItem *AActor::GetDropItems() const -{ - return GetInfo()->DropItems; -} - -DEFINE_ACTION_FUNCTION(AActor, GetDropItems) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_POINTER(self->GetDropItems()); -} - -double AActor::GetGravity() const -{ - if (flags & MF_NOGRAVITY) return 0; - return level.gravity * Sector->gravity * Gravity * 0.00125; -} - -DEFINE_ACTION_FUNCTION(AActor, GetGravity) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_FLOAT(self->GetGravity()); -} - // killough 11/98: // Whether an object is "sentient" or not. Used for environmental influences. @@ -7481,28 +7185,12 @@ const char *AActor::GetTag(const char *def) const } } -DEFINE_ACTION_FUNCTION(AActor, GetTag) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_STRING(def); - ACTION_RETURN_STRING(self->GetTag(def.Len() == 0? nullptr : def.GetChars())); -} - void AActor::SetTag(const char *def) { if (def == NULL || *def == 0) Tag = nullptr; else Tag = mStringPropertyData.Alloc(def); } -DEFINE_ACTION_FUNCTION(AActor, SetTag) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_STRING(def); - if (def.IsEmpty()) self->Tag = nullptr; - else self->Tag = self->mStringPropertyData.Alloc(def); - return 0; -} - void AActor::ClearCounters() { @@ -7525,13 +7213,6 @@ void AActor::ClearCounters() } } -DEFINE_ACTION_FUNCTION(AActor, ClearCounters) -{ - PARAM_SELF_PROLOGUE(AActor); - self->ClearCounters(); - return 0; -} - int AActor::GetModifiedDamage(FName damagetype, int damage, bool passive) { auto inv = Inventory; @@ -7547,14 +7228,6 @@ int AActor::GetModifiedDamage(FName damagetype, int damage, bool passive) return damage; } -DEFINE_ACTION_FUNCTION(AActor, GetModifiedDamage) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_NAME(type); - PARAM_INT(damage); - PARAM_BOOL(passive); - ACTION_RETURN_INT(self->GetModifiedDamage(type, damage, passive)); -} int AActor::ApplyDamageFactor(FName damagetype, int damage) const { @@ -7566,15 +7239,6 @@ int AActor::ApplyDamageFactor(FName damagetype, int damage) const return damage; } -DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactor) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_NAME(type); - PARAM_INT(damage); - ACTION_RETURN_INT(self->ApplyDamageFactor(type, damage)); -} - - void AActor::SetTranslation(FName trname) { // There is no constant for the empty name... @@ -7593,43 +7257,6 @@ void AActor::SetTranslation(FName trname) // silently ignore if the name does not exist, this would create some insane message spam otherwise. } -//========================================================================== -// -// AActor :: GetLevelSpawnTime -// -// Returns the time when this actor was spawned, -// relative to the current level. -// -//========================================================================== -int AActor::GetLevelSpawnTime() const -{ - return SpawnTime - level.totaltime + level.time; -} - -DEFINE_ACTION_FUNCTION(AActor, GetLevelSpawnTime) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(self->GetLevelSpawnTime()); -} - -//========================================================================== -// -// AActor :: GetAge -// -// Returns the number of ticks passed since this actor was spawned. -// -//========================================================================== -int AActor::GetAge() const -{ - return level.totaltime - SpawnTime; -} - -DEFINE_ACTION_FUNCTION(AActor, GetAge) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(self->GetAge()); -} - //--------------------------------------------------------------------------- // // PROP A_RestoreSpecialPosition @@ -7686,391 +7313,6 @@ void AActor::RestoreSpecialPosition() ClearInterpolation(); } -DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) -{ - PARAM_SELF_PROLOGUE(AActor); - self->RestoreSpecialPosition(); - return 0; -} - -double AActor::GetBobOffset(double ticfrac) const -{ - if (!(flags2 & MF2_FLOATBOB)) - { - return 0; - } - return BobSin(FloatBobPhase + level.maptime + ticfrac) * FloatBobStrength; -} - -DEFINE_ACTION_FUNCTION(AActor, GetBobOffset) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(frac); - ACTION_RETURN_FLOAT(self->GetBobOffset(frac)); -} - - - - -class DActorIterator : public DObject, public NActorIterator -{ - DECLARE_ABSTRACT_CLASS(DActorIterator, DObject) - -public: - DActorIterator(PClassActor *cls= nullptr, int tid = 0) - : NActorIterator(cls, tid) - { - } -}; - -IMPLEMENT_CLASS(DActorIterator, true, false); -DEFINE_ACTION_FUNCTION(DActorIterator, Create) -{ - PARAM_PROLOGUE; - PARAM_INT(tid); - PARAM_CLASS(type, AActor); - ACTION_RETURN_OBJECT(Create(type, tid)); -} - -DEFINE_ACTION_FUNCTION(DActorIterator, Next) -{ - PARAM_SELF_PROLOGUE(DActorIterator); - ACTION_RETURN_OBJECT(self->Next()); -} - -DEFINE_ACTION_FUNCTION(DActorIterator, Reinit) -{ - PARAM_SELF_PROLOGUE(DActorIterator); - self->Reinit(); - return 0; -} - - - -DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global? -{ - PARAM_PROLOGUE; - PARAM_FLOAT(a1); - PARAM_FLOAT(a2); - ACTION_RETURN_FLOAT(deltaangle(DAngle(a1), DAngle(a2)).Degrees); -} - -DEFINE_ACTION_FUNCTION(AActor, absangle) // should this be global? -{ - PARAM_PROLOGUE; - PARAM_FLOAT(a1); - PARAM_FLOAT(a2); - ACTION_RETURN_FLOAT(absangle(DAngle(a1), DAngle(a2)).Degrees); -} - -DEFINE_ACTION_FUNCTION(AActor, Distance2DSquared) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_FLOAT(self->Distance2DSquared(other)); -} - -DEFINE_ACTION_FUNCTION(AActor, Distance3DSquared) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_FLOAT(self->Distance3DSquared(other)); -} - -DEFINE_ACTION_FUNCTION(AActor, Distance2D) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_FLOAT(self->Distance2D(other)); -} - -DEFINE_ACTION_FUNCTION(AActor, Distance3D) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(other, AActor); - ACTION_RETURN_FLOAT(self->Distance3D(other)); -} - -DEFINE_ACTION_FUNCTION(AActor, AddZ) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(addz); - PARAM_BOOL(moving); - self->AddZ(addz, moving); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, SetZ) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(z); - self->SetZ(z); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, SetDamage) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(dmg); - self->SetDamage(dmg); - return 0; -} - -// This combines all 3 variations of the internal function -DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(speed); - PARAM_ANGLE(angle); - - if (speed == 1e37) - { - self->VelFromAngle(); - } - else - { - if (angle == 1e37) - - { - self->VelFromAngle(speed); - } - else - { - self->VelFromAngle(speed, angle); - } - } - return 0; -} - -// This combines all 3 variations of the internal function -DEFINE_ACTION_FUNCTION(AActor, Vel3DFromAngle) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(speed); - PARAM_ANGLE(angle); - PARAM_ANGLE(pitch); - self->Vel3DFromAngle(angle, pitch, speed); - return 0; -} - -// This combines all 3 variations of the internal function -DEFINE_ACTION_FUNCTION(AActor, Thrust) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(speed); - PARAM_ANGLE(angle); - - if (speed == 1e37) - { - self->Thrust(); - } - else - { - if (angle == 1e37) - { - self->Thrust(speed); - } - else - { - self->Thrust(angle, speed); - } - } - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, AngleTo) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(targ, AActor); - PARAM_BOOL(absolute); - ACTION_RETURN_FLOAT(self->AngleTo(targ, absolute).Degrees); -} - -DEFINE_ACTION_FUNCTION(AActor, AngleToVector) -{ - PARAM_PROLOGUE; - PARAM_ANGLE(angle); - PARAM_FLOAT(length); - ACTION_RETURN_VEC2(angle.ToVector(length)); -} - -DEFINE_ACTION_FUNCTION(AActor, RotateVector) -{ - PARAM_PROLOGUE; - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_ANGLE(angle); - ACTION_RETURN_VEC2(DVector2(x, y).Rotated(angle)); -} - -DEFINE_ACTION_FUNCTION(AActor, Normalize180) -{ - PARAM_PROLOGUE; - PARAM_ANGLE(angle); - ACTION_RETURN_FLOAT(angle.Normalized180().Degrees); -} - -DEFINE_ACTION_FUNCTION(AActor, DistanceBySpeed) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(targ, AActor); - PARAM_FLOAT(speed); - ACTION_RETURN_FLOAT(self->DistanceBySpeed(targ, speed)); -} - -DEFINE_ACTION_FUNCTION(AActor, SetXYZ) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - self->SetXYZ(x, y, z); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, Vec2Angle) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(length); - PARAM_ANGLE(angle); - PARAM_BOOL(absolute); - ACTION_RETURN_VEC2(self->Vec2Angle(length, angle, absolute)); -} - - -DEFINE_ACTION_FUNCTION(AActor, Vec3To) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(t, AActor) - ACTION_RETURN_VEC3(self->Vec3To(t)); -} - -DEFINE_ACTION_FUNCTION(AActor, Vec2To) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(t, AActor) - ACTION_RETURN_VEC2(self->Vec2To(t)); -} - -DEFINE_ACTION_FUNCTION(AActor, Vec3Angle) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(length) - PARAM_ANGLE(angle); - PARAM_FLOAT(z); - PARAM_BOOL(absolute); - ACTION_RETURN_VEC3(self->Vec3Angle(length, angle, z, absolute)); -} - -DEFINE_ACTION_FUNCTION(AActor, Vec2OffsetZ) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - PARAM_BOOL(absolute); - ACTION_RETURN_VEC3(self->Vec2OffsetZ(x, y, z, absolute)); -} - -DEFINE_ACTION_FUNCTION(AActor, Vec2Offset) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_BOOL(absolute); - ACTION_RETURN_VEC2(self->Vec2Offset(x, y, absolute)); -} - -DEFINE_ACTION_FUNCTION(AActor, Vec3Offset) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - PARAM_BOOL(absolute); - ACTION_RETURN_VEC3(self->Vec3Offset(x, y, z, absolute)); -} - -DEFINE_ACTION_FUNCTION(AActor, PosRelative) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_POINTER(sec, sector_t); - ACTION_RETURN_VEC3(self->PosRelative(sec)); -} - -DEFINE_ACTION_FUNCTION(AActor, RestoreDamage) -{ - PARAM_SELF_PROLOGUE(AActor); - self->RestoreDamage(); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, PlayerNumber) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(self->player ? int(self->player - players) : 0); -} - -DEFINE_ACTION_FUNCTION(AActor, SetFriendPlayer) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_POINTER(player, player_t); - self->SetFriendPlayer(player); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, ClearBounce) -{ - PARAM_SELF_PROLOGUE(AActor); - self->BounceFlags = 0; - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, AccuracyFactor) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_FLOAT(self->AccuracyFactor()); -} - -DEFINE_ACTION_FUNCTION(AActor, CountsAsKill) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(self->CountsAsKill()); -} - -DEFINE_ACTION_FUNCTION(AActor, IsZeroDamage) -{ - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_BOOL(self->IsZeroDamage()); -} - -DEFINE_ACTION_FUNCTION(AActor, ClearInterpolation) -{ - PARAM_SELF_PROLOGUE(AActor); - self->ClearInterpolation(); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactors) -{ - PARAM_PROLOGUE; - PARAM_CLASS(itemcls, AActor); - PARAM_NAME(damagetype); - PARAM_INT(damage); - PARAM_INT(defdamage); - - DmgFactors &df = itemcls->ActorInfo()->DamageFactors; - if (df.Size() != 0) - { - ACTION_RETURN_INT(df.Apply(damagetype, damage)); - } - else - { - ACTION_RETURN_INT(defdamage); - } -} - - //---------------------------------------------------------------------------- // // DropItem handling @@ -8150,8 +7392,5 @@ void PrintMiscActorInfo(AActor *query) Printf("FriendlySeeBlocks: %d\n", query->friendlyseeblocks); Printf("Target: %s\n", query->target ? query->target->GetClass()->TypeName.GetChars() : "-"); Printf("Last enemy: %s\n", query->lastenemy ? query->lastenemy->GetClass()->TypeName.GetChars() : "-"); - Printf("Spawn time: %d ticks (%f seconds) after game start, %d ticks (%f seconds) after level start\n", - query->SpawnTime, (double) query->SpawnTime / TICRATE, - query->GetLevelSpawnTime(), (double) query->GetLevelSpawnTime() / TICRATE); } } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index b896ed08e..0f8285e93 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -798,7 +798,7 @@ void sector_t::ClosestPoint(const DVector2 &in, DVector2 &out) const // //===================================================================================== -bool PlaneMoving(sector_t *sector, int pos) +int PlaneMoving(sector_t *sector, int pos) { if (pos == sector_t::floor) return (sector->floordata != nullptr || (sector->planes[sector_t::floor].Flags & PLANEF_BLOCKED)); @@ -1092,7 +1092,7 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac) } } - //=========================================================================== + //=========================================================================== // // // diff --git a/src/p_setup.h b/src/p_setup.h index dd3a1e1e3..d7e7eeae5 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -162,6 +162,7 @@ int P_TranslateSectorSpecial (int); int GetUDMFInt(int type, int index, FName key); double GetUDMFFloat(int type, int index, FName key); +FString GetUDMFString(int type, int index, FName key); bool P_LoadGLNodes(MapData * map); bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime); diff --git a/src/p_sight.cpp b/src/p_sight.cpp index cb6dbb011..5f15e844b 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -834,7 +834,7 @@ sightcounts[2]++; ===================== */ -bool P_CheckSight (AActor *t1, AActor *t2, int flags) +int P_CheckSight (AActor *t1, AActor *t2, int flags) { SightCycles.Clock(); @@ -936,14 +936,6 @@ done: return res; } -DEFINE_ACTION_FUNCTION(AActor, CheckSight) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(target, AActor); - PARAM_INT(flags); - ACTION_RETURN_BOOL(P_CheckSight(self, target, flags)); -} - ADD_STAT (sight) { FString out; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index d1d63603e..566756393 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -614,16 +614,6 @@ void P_GiveSecret(AActor *actor, bool printmessage, bool playsound, int sectornu level.found_secrets++; } -DEFINE_ACTION_FUNCTION(AActor, GiveSecret) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_BOOL(printmessage); - PARAM_BOOL(playsound); - P_GiveSecret(self, printmessage, playsound, -1); - return 0; -} - - DEFINE_ACTION_FUNCTION(FLevelLocals, GiveSecret) { PARAM_PROLOGUE; diff --git a/src/p_tags.cpp b/src/p_tags.cpp index 458a456fc..861866b2c 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -364,64 +364,3 @@ int FLineIdIterator::Next() return ret; } -class DSectorTagIterator : public DObject, public FSectorTagIterator -{ - DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject); -public: - DSectorTagIterator(int tag, line_t *line) - { - if (line == nullptr) Init(tag); - else Init(tag, line); - } -}; - -IMPLEMENT_CLASS(DSectorTagIterator, true, false); - -DEFINE_ACTION_FUNCTION(DSectorTagIterator, Create) -{ - PARAM_PROLOGUE; - PARAM_INT(tag); - PARAM_POINTER(line, line_t); - ACTION_RETURN_POINTER(Create(tag, line)); -} - -DEFINE_ACTION_FUNCTION(DSectorTagIterator, Next) -{ - PARAM_SELF_PROLOGUE(DSectorTagIterator); - ACTION_RETURN_INT(self->Next()); -} - -DEFINE_ACTION_FUNCTION(DSectorTagIterator, NextCompat) -{ - PARAM_SELF_PROLOGUE(DSectorTagIterator); - PARAM_BOOL(compat); - PARAM_INT(secnum); - ACTION_RETURN_INT(self->NextCompat(compat, secnum)); -} - - -class DLineIdIterator : public DObject, public FLineIdIterator -{ - DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject); -public: - DLineIdIterator(int tag) - : FLineIdIterator(tag) - { - } -}; - -IMPLEMENT_CLASS(DLineIdIterator, true, false); - -DEFINE_ACTION_FUNCTION(DLineIdIterator, Create) -{ - PARAM_PROLOGUE; - PARAM_INT(tag); - ACTION_RETURN_POINTER(Create(tag)); -} - -DEFINE_ACTION_FUNCTION(DLineIdIterator, Next) -{ - PARAM_SELF_PROLOGUE(DLineIdIterator); - ACTION_RETURN_INT(self->Next()); -} - diff --git a/src/p_things.cpp b/src/p_things.cpp index 4cac8866f..f6d5139f6 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -552,13 +552,6 @@ PClassActor *P_GetSpawnableType(int spawnnum) return NULL; } -DEFINE_ACTION_FUNCTION(AActor, GetSpawnableType) -{ - PARAM_PROLOGUE; - PARAM_INT(num); - ACTION_RETURN_POINTER(P_GetSpawnableType(num)); -} - struct MapinfoSpawnItem { FName classname; // DECORATE is read after MAPINFO so we do not have the actual classes available here yet. diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index b32d3b9c0..b9e3f139e 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -373,15 +373,6 @@ int GetUDMFInt(int type, int index, FName key) return 0; } -DEFINE_ACTION_FUNCTION(FLevelLocals, GetUDMFInt) -{ - PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); - PARAM_INT(type); - PARAM_INT(index); - PARAM_NAME(key); - ACTION_RETURN_INT(GetUDMFInt(type, index, key)); -} - double GetUDMFFloat(int type, int index, FName key) { assert(type >=0 && type <=3); @@ -399,15 +390,6 @@ double GetUDMFFloat(int type, int index, FName key) return 0; } -DEFINE_ACTION_FUNCTION(FLevelLocals, GetUDMFFloat) -{ - PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); - PARAM_INT(type); - PARAM_INT(index); - PARAM_NAME(key); - ACTION_RETURN_FLOAT(GetUDMFFloat(type, index, key)); -} - FString GetUDMFString(int type, int index, FName key) { assert(type >= 0 && type <= 3); @@ -425,16 +407,6 @@ FString GetUDMFString(int type, int index, FName key) return ""; } -DEFINE_ACTION_FUNCTION(FLevelLocals, GetUDMFString) -{ - PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); - PARAM_INT(type); - PARAM_INT(index); - PARAM_NAME(key); - ACTION_RETURN_STRING(GetUDMFString(type, index, key)); -} - - //=========================================================================== // // UDMF parser diff --git a/src/p_user.cpp b/src/p_user.cpp index 7dda18719..4bae6ee5e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -293,14 +293,6 @@ CCMD (playerclasses) } } -DEFINE_ACTION_FUNCTION(AActor, Substitute) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT(replace, AActor); - DObject::StaticPointerSubstitution(self, replace); - return 0; -} - // // Movement. // @@ -1245,23 +1237,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullPop) return 0; } -//---------------------------------------------------------------------------- -// -// PROC A_CheckSkullDone -// -//---------------------------------------------------------------------------- - -DEFINE_ACTION_FUNCTION(AActor, A_CheckPlayerDone) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (self->player == NULL) - { - self->Destroy(); - } - return 0; -} - //=========================================================================== // // P_CheckPlayerSprites diff --git a/src/polyrenderer/drawers/poly_triangle.cpp b/src/polyrenderer/drawers/poly_triangle.cpp index f75b5e43d..0e834dee5 100644 --- a/src/polyrenderer/drawers/poly_triangle.cpp +++ b/src/polyrenderer/drawers/poly_triangle.cpp @@ -169,16 +169,7 @@ void PolyTriangleThreadData::DrawElements(const PolyDrawArgs &drawargs, const vo return; TriDrawTriangleArgs args; - args.dest = dest; - args.pitch = dest_pitch; - args.clipright = dest_width; - args.clipbottom = dest_height; args.uniforms = &drawargs; - args.destBgra = dest_bgra; - args.stencilbuffer = PolyStencilBuffer::Instance()->Values(); - args.stencilpitch = PolyStencilBuffer::Instance()->Width(); - args.zbuffer = PolyZBuffer::Instance()->Values(); - args.depthOffset = weaponScene ? 1.0f : 0.0f; ShadedTriVertex vert[3]; if (drawmode == PolyDrawMode::Triangles) @@ -223,16 +214,7 @@ void PolyTriangleThreadData::DrawArray(const PolyDrawArgs &drawargs, const void return; TriDrawTriangleArgs args; - args.dest = dest; - args.pitch = dest_pitch; - args.clipright = dest_width; - args.clipbottom = dest_height; args.uniforms = &drawargs; - args.destBgra = dest_bgra; - args.stencilbuffer = PolyStencilBuffer::Instance()->Values(); - args.stencilpitch = PolyStencilBuffer::Instance()->Width(); - args.zbuffer = PolyZBuffer::Instance()->Values(); - args.depthOffset = weaponScene ? 1.0f : 0.0f; int vinput = 0; diff --git a/src/polyrenderer/drawers/poly_triangle.h b/src/polyrenderer/drawers/poly_triangle.h index 132823af4..fadc799d6 100644 --- a/src/polyrenderer/drawers/poly_triangle.h +++ b/src/polyrenderer/drawers/poly_triangle.h @@ -29,6 +29,8 @@ #include "polyrenderer/drawers/poly_buffer.h" #include "polyrenderer/drawers/poly_draw_args.h" +class PolyDrawerCommand; + class PolyTriangleDrawer { public: @@ -88,6 +90,13 @@ public: static PolyTriangleThreadData *Get(DrawerThread *thread); + int dest_pitch = 0; + int dest_width = 0; + int dest_height = 0; + bool dest_bgra = false; + uint8_t *dest = nullptr; + bool weaponScene = false; + private: ShadedTriVertex ShadeVertex(const PolyDrawArgs &drawargs, const void *vertices, int index); void DrawShadedTriangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args); @@ -99,14 +108,8 @@ private: int viewport_y = 0; int viewport_width = 0; int viewport_height = 0; - int dest_pitch = 0; - int dest_width = 0; - int dest_height = 0; - bool dest_bgra = false; - uint8_t *dest = nullptr; bool ccw = true; bool twosided = false; - bool weaponScene = false; const Mat4f *objectToClip = nullptr; const Mat4f *objectToWorld = nullptr; int modelFrame1 = -1; @@ -116,7 +119,12 @@ private: enum { max_additional_vertices = 16 }; }; -class PolySetTransformCommand : public DrawerCommand +class PolyDrawerCommand : public DrawerCommand +{ +public: +}; + +class PolySetTransformCommand : public PolyDrawerCommand { public: PolySetTransformCommand(const Mat4f *objectToClip, const Mat4f *objectToWorld); @@ -128,7 +136,7 @@ private: const Mat4f *objectToWorld; }; -class PolySetCullCCWCommand : public DrawerCommand +class PolySetCullCCWCommand : public PolyDrawerCommand { public: PolySetCullCCWCommand(bool ccw); @@ -139,7 +147,7 @@ private: bool ccw; }; -class PolySetTwoSidedCommand : public DrawerCommand +class PolySetTwoSidedCommand : public PolyDrawerCommand { public: PolySetTwoSidedCommand(bool twosided); @@ -150,7 +158,7 @@ private: bool twosided; }; -class PolySetWeaponSceneCommand : public DrawerCommand +class PolySetWeaponSceneCommand : public PolyDrawerCommand { public: PolySetWeaponSceneCommand(bool value); @@ -161,7 +169,7 @@ private: bool value; }; -class PolySetModelVertexShaderCommand : public DrawerCommand +class PolySetModelVertexShaderCommand : public PolyDrawerCommand { public: PolySetModelVertexShaderCommand(int frame1, int frame2, float interpolationFactor); @@ -174,7 +182,7 @@ private: float interpolationFactor; }; -class PolyClearStencilCommand : public DrawerCommand +class PolyClearStencilCommand : public PolyDrawerCommand { public: PolyClearStencilCommand(uint8_t value); @@ -185,7 +193,7 @@ private: uint8_t value; }; -class PolySetViewportCommand : public DrawerCommand +class PolySetViewportCommand : public PolyDrawerCommand { public: PolySetViewportCommand(int x, int y, int width, int height, uint8_t *dest, int dest_width, int dest_height, int dest_pitch, bool dest_bgra); @@ -204,7 +212,7 @@ private: bool dest_bgra; }; -class DrawPolyTrianglesCommand : public DrawerCommand +class DrawPolyTrianglesCommand : public PolyDrawerCommand { public: DrawPolyTrianglesCommand(const PolyDrawArgs &args, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode); @@ -219,7 +227,7 @@ private: PolyDrawMode mode; }; -class DrawRectCommand : public DrawerCommand +class DrawRectCommand : public PolyDrawerCommand { public: DrawRectCommand(const RectDrawArgs &args) : args(args) { } diff --git a/src/polyrenderer/drawers/screen_triangle.cpp b/src/polyrenderer/drawers/screen_triangle.cpp index e914551c5..551753c20 100644 --- a/src/polyrenderer/drawers/screen_triangle.cpp +++ b/src/polyrenderer/drawers/screen_triangle.cpp @@ -54,13 +54,15 @@ static void SortVertices(const TriDrawTriangleArgs *args, ShadedTriVertex **sort void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread) { + using namespace TriScreenDrawerModes; + // Sort vertices by Y position ShadedTriVertex *sortedVertices[3]; SortVertices(args, sortedVertices); - int clipright = args->clipright; + int clipright = thread->dest_width; int cliptop = thread->numa_start_y; - int clipbottom = MIN(args->clipbottom, thread->numa_end_y); + int clipbottom = MIN(thread->dest_height, thread->numa_end_y); int topY = (int)(sortedVertices[0]->y + 0.5f); int midY = (int)(sortedVertices[1]->y + 0.5f); @@ -75,8 +77,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat // Find start/end X positions for each line covered by the triangle: - int leftEdge[MAXHEIGHT]; - int rightEdge[MAXHEIGHT]; + int16_t edges[MAXHEIGHT * 2]; float longDX = sortedVertices[2]->x - sortedVertices[0]->x; float longDY = sortedVertices[2]->y - sortedVertices[0]->y; @@ -98,8 +99,8 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat x0 = clamp(x0, 0, clipright); x1 = clamp(x1, 0, clipright); - leftEdge[y] = x0; - rightEdge[y] = x1; + edges[y << 1] = x0; + edges[(y << 1) + 1] = x1; shortPos += shortStep; longPos += longStep; @@ -121,64 +122,108 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat x0 = clamp(x0, 0, clipright); x1 = clamp(x1, 0, clipright); - leftEdge[y] = x0; - rightEdge[y] = x1; + edges[y << 1] = x0; + edges[(y << 1) + 1] = x1; shortPos += shortStep; longPos += longStep; } } - // Draw the triangle: + int opt = 0; + if (args->uniforms->DepthTest()) opt |= SWTRI_DepthTest; + /*if (args->uniforms->StencilTest())*/ opt |= SWTRI_StencilTest; + if (args->uniforms->WriteColor()) opt |= SWTRI_WriteColor; + if (args->uniforms->WriteDepth()) opt |= SWTRI_WriteDepth; + if (args->uniforms->WriteStencil()) opt |= SWTRI_WriteStencil; + + TriangleDrawers[opt](args, thread, edges, topY, bottomY); +} - int bmode = (int)args->uniforms->BlendMode(); - auto drawfunc = args->destBgra ? ScreenTriangle::SpanDrawers32[bmode] : ScreenTriangle::SpanDrawers8[bmode]; +template +void DrawTriangle(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread, int16_t *edges, int topY, int bottomY) +{ + using namespace TriScreenDrawerModes; - float stepXW = args->gradientX.W; - float v1X = args->v1->x; - float v1Y = args->v1->y; - float v1W = args->v1->w; + void(*drawfunc)(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread); + float stepXW, v1X, v1Y, v1W, posXW; + uint8_t stencilTestValue, stencilWriteValue; + float *zbuffer; + float *zbufferLine; + uint8_t *stencilbuffer; + uint8_t *stencilLine; + int pitch; - bool depthTest = args->uniforms->DepthTest(); - bool stencilTest = true; - bool writeColor = args->uniforms->WriteColor(); - bool writeStencil = args->uniforms->WriteStencil(); - bool writeDepth = args->uniforms->WriteDepth(); - uint8_t stencilTestValue = args->uniforms->StencilTestValue(); - uint8_t stencilWriteValue = args->uniforms->StencilWriteValue(); + if (OptT::Flags & SWTRI_WriteColor) + { + int bmode = (int)args->uniforms->BlendMode(); + drawfunc = thread->dest_bgra ? ScreenTriangle::SpanDrawers32[bmode] : ScreenTriangle::SpanDrawers8[bmode]; + } + + if ((OptT::Flags & SWTRI_DepthTest) || (OptT::Flags & SWTRI_WriteDepth)) + { + stepXW = args->gradientX.W; + v1X = args->v1->x; + v1Y = args->v1->y; + v1W = args->v1->w; + zbuffer = PolyZBuffer::Instance()->Values(); + } + + if ((OptT::Flags & SWTRI_StencilTest) || (OptT::Flags & SWTRI_WriteStencil)) + { + stencilbuffer = PolyStencilBuffer::Instance()->Values(); + } + + if ((OptT::Flags & SWTRI_StencilTest) || (OptT::Flags & SWTRI_WriteStencil) || (OptT::Flags & SWTRI_DepthTest) || (OptT::Flags & SWTRI_WriteDepth)) + pitch = PolyStencilBuffer::Instance()->Width(); + + if (OptT::Flags & SWTRI_StencilTest) + stencilTestValue = args->uniforms->StencilTestValue(); + + if (OptT::Flags & SWTRI_WriteStencil) + stencilWriteValue = args->uniforms->StencilWriteValue(); int num_cores = thread->num_cores; for (int y = topY + thread->skipped_by_thread(topY); y < bottomY; y += num_cores) { - int x = leftEdge[y]; - int xend = rightEdge[y]; + int x = edges[y << 1]; + int xend = edges[(y << 1) + 1]; - float *zbufferLine = args->zbuffer + args->stencilpitch * y; - uint8_t *stencilLine = args->stencilbuffer + args->stencilpitch * y; + if ((OptT::Flags & SWTRI_StencilTest) || (OptT::Flags & SWTRI_WriteStencil)) + stencilLine = stencilbuffer + pitch * y; - float startX = x + (0.5f - v1X); - float startY = y + (0.5f - v1Y); - float posXW = v1W + stepXW * startX + args->gradientY.W * startY + args->depthOffset; + if ((OptT::Flags & SWTRI_DepthTest) || (OptT::Flags & SWTRI_WriteDepth)) + { + zbufferLine = zbuffer + pitch * y; + + float startX = x + (0.5f - v1X); + float startY = y + (0.5f - v1Y); + posXW = v1W + stepXW * startX + args->gradientY.W * startY + (thread->weaponScene ? 1.0f : 0.0f); + } #ifndef NO_SSE - __m128 mstepXW = _mm_set1_ps(stepXW * 4.0f); - __m128 mfirstStepXW = _mm_setr_ps(0.0f, stepXW, stepXW + stepXW, stepXW + stepXW + stepXW); + __m128 mstepXW, mfirstStepXW; + if ((OptT::Flags & SWTRI_DepthTest) || (OptT::Flags & SWTRI_WriteDepth)) + { + mstepXW = _mm_set1_ps(stepXW * 4.0f); + mfirstStepXW = _mm_setr_ps(0.0f, stepXW, stepXW + stepXW, stepXW + stepXW + stepXW); + } while (x < xend) { int xstart = x; - if (depthTest && stencilTest) + if ((OptT::Flags & SWTRI_DepthTest) && (OptT::Flags & SWTRI_StencilTest)) { int xendsse = x + ((xend - x) / 4); __m128 mposXW = _mm_add_ps(_mm_set1_ps(posXW), mfirstStepXW); - while (_mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 15 && + while (x < xendsse && + _mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 15 && stencilLine[x] == stencilTestValue && stencilLine[x + 1] == stencilTestValue && stencilLine[x + 2] == stencilTestValue && - stencilLine[x + 3] == stencilTestValue && - x < xendsse) + stencilLine[x + 3] == stencilTestValue) { - if (writeDepth) + if (OptT::Flags & SWTRI_WriteDepth) _mm_storeu_ps(zbufferLine + x, mposXW); mposXW = _mm_add_ps(mposXW, mstepXW); x += 4; @@ -187,19 +232,19 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat while (zbufferLine[x] <= posXW && stencilLine[x] == stencilTestValue && x < xend) { - if (writeDepth) + if (OptT::Flags & SWTRI_WriteDepth) zbufferLine[x] = posXW; posXW += stepXW; x++; } } - else if (depthTest) + else if (OptT::Flags & SWTRI_DepthTest) { int xendsse = x + ((xend - x) / 4); __m128 mposXW = _mm_add_ps(_mm_set1_ps(posXW), mfirstStepXW); - while (_mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 15 && x < xendsse) + while (x < xendsse && _mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 15) { - if (writeDepth) + if (OptT::Flags & SWTRI_WriteDepth) _mm_storeu_ps(zbufferLine + x, mposXW); mposXW = _mm_add_ps(mposXW, mstepXW); x += 4; @@ -208,14 +253,20 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat while (zbufferLine[x] <= posXW && x < xend) { - if (writeDepth) + if (OptT::Flags & SWTRI_WriteDepth) zbufferLine[x] = posXW; posXW += stepXW; x++; } } - else if (stencilTest) + else if (OptT::Flags & SWTRI_StencilTest) { + int xendsse = x + ((xend - x) / 16); + while (x < xendsse && _mm_movemask_epi8(_mm_cmpeq_epi8(_mm_loadu_si128((const __m128i*)&stencilLine[x]), _mm_set1_epi8(stencilTestValue))) == 0xffff) + { + x += 16; + } + while (stencilLine[x] == stencilTestValue && x < xend) x++; } @@ -226,16 +277,24 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat if (x > xstart) { - if (writeColor) + if (OptT::Flags & SWTRI_WriteColor) drawfunc(y, xstart, x, args, thread); - if (writeStencil) + if (OptT::Flags & SWTRI_WriteStencil) { - for (int i = xstart; i < x; i++) - stencilLine[i] = stencilWriteValue; + int i = xstart; + int xendsse = xstart + ((x - xstart) / 16); + while (i < xendsse) + { + _mm_storeu_si128((__m128i*)&stencilLine[i], _mm_set1_epi8(stencilWriteValue)); + i += 16; + } + + while (i < x) + stencilLine[i++] = stencilWriteValue; } - if (!depthTest && writeDepth) + if (!(OptT::Flags & SWTRI_DepthTest) && (OptT::Flags & SWTRI_WriteDepth)) { for (int i = xstart; i < x; i++) { @@ -245,16 +304,16 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat } } - if (depthTest && stencilTest) + if ((OptT::Flags & SWTRI_DepthTest) && (OptT::Flags & SWTRI_StencilTest)) { int xendsse = x + ((xend - x) / 4); __m128 mposXW = _mm_add_ps(_mm_set1_ps(posXW), mfirstStepXW); - while ((_mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 0 || + while (x < xendsse && + (_mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 0 || stencilLine[x] != stencilTestValue || stencilLine[x + 1] != stencilTestValue || stencilLine[x + 2] != stencilTestValue || - stencilLine[x + 3] != stencilTestValue) && - x < xendsse) + stencilLine[x + 3] != stencilTestValue)) { mposXW = _mm_add_ps(mposXW, mstepXW); x += 4; @@ -267,11 +326,11 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat x++; } } - else if (depthTest) + else if (OptT::Flags & SWTRI_DepthTest) { int xendsse = x + ((xend - x) / 4); __m128 mposXW = _mm_add_ps(_mm_set1_ps(posXW), mfirstStepXW); - while (_mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 0 && x < xendsse) + while (x < xendsse && _mm_movemask_ps(_mm_cmple_ps(_mm_loadu_ps(zbufferLine + x), mposXW)) == 0) { mposXW = _mm_add_ps(mposXW, mstepXW); x += 4; @@ -284,11 +343,16 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat x++; } } - else if (stencilTest) + else if (OptT::Flags & SWTRI_StencilTest) { + int xendsse = x + ((xend - x) / 16); + while (x < xendsse && _mm_movemask_epi8(_mm_cmpeq_epi8(_mm_loadu_si128((const __m128i*)&stencilLine[x]), _mm_set1_epi8(stencilTestValue))) == 0) + { + x += 16; + } + while (stencilLine[x] != stencilTestValue && x < xend) { - posXW += stepXW; x++; } } @@ -298,27 +362,27 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat { int xstart = x; - if (depthTest && stencilTest) + if ((OptT::Flags & SWTRI_DepthTest) && (OptT::Flags & SWTRI_StencilTest)) { while (zbufferLine[x] <= posXW && stencilLine[x] == stencilTestValue && x < xend) { - if (writeDepth) + if (OptT::Flags & SWTRI_WriteDepth) zbufferLine[x] = posXW; posXW += stepXW; x++; } } - else if (depthTest) + else if (OptT::Flags & SWTRI_DepthTest) { while (zbufferLine[x] <= posXW && x < xend) { - if (writeDepth) + if (OptT::Flags & SWTRI_WriteDepth) zbufferLine[x] = posXW; posXW += stepXW; x++; } } - else if (stencilTest) + else if (OptT::Flags & SWTRI_StencilTest) { while (stencilLine[x] == stencilTestValue && x < xend) x++; @@ -330,16 +394,16 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat if (x > xstart) { - if (writeColor) + if (OptT::Flags & SWTRI_WriteColor) drawfunc(y, xstart, x, args, thread); - if (writeStencil) + if (OptT::Flags & SWTRI_WriteStencil) { for (int i = xstart; i < x; i++) stencilLine[i] = stencilWriteValue; } - if (!depthTest && writeDepth) + if (!(OptT::Flags & SWTRI_DepthTest) && (OptT::Flags & SWTRI_WriteDepth)) { for (int i = xstart; i < x; i++) { @@ -349,7 +413,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat } } - if (depthTest && stencilTest) + if ((OptT::Flags & SWTRI_DepthTest) && (OptT::Flags & SWTRI_StencilTest)) { while ((zbufferLine[x] > posXW || stencilLine[x] != stencilTestValue) && x < xend) { @@ -357,7 +421,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat x++; } } - else if (depthTest) + else if (OptT::Flags & SWTRI_DepthTest) { while (zbufferLine[x] > posXW && x < xend) { @@ -365,11 +429,10 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat x++; } } - else if (stencilTest) + else if (OptT::Flags & SWTRI_StencilTest) { while (stencilLine[x] != stencilTestValue && x < xend) { - posXW += stepXW; x++; } } @@ -808,8 +871,8 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyT _fuzzpos = swrenderer::fuzzpos; } - uint32_t *dest = (uint32_t*)args->dest; - uint32_t *destLine = dest + args->pitch * y; + uint32_t *dest = (uint32_t*)thread->dest; + uint32_t *destLine = dest + thread->dest_pitch * y; int sseend = x0; #ifndef NO_SSE @@ -1235,8 +1298,8 @@ void DrawSpanOpt8(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTr _fuzzpos = swrenderer::fuzzpos; } - uint8_t *dest = (uint8_t*)args->dest; - uint8_t *destLine = dest + args->pitch * y; + uint8_t *dest = (uint8_t*)thread->dest; + uint8_t *destLine = dest + thread->dest_pitch * y; for (int x = x0; x < x1; x++) { @@ -2164,4 +2227,40 @@ void(*ScreenTriangle::RectDrawers32[])(const void *, int, int, int, const RectDr &DrawRect32 }; +void(*ScreenTriangle::TriangleDrawers[])(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread, int16_t *edges, int topY, int bottomY) = +{ + nullptr, + nullptr, + nullptr, + nullptr, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle, + &DrawTriangle +}; + int ScreenTriangle::FuzzStart = 0; diff --git a/src/polyrenderer/drawers/screen_triangle.h b/src/polyrenderer/drawers/screen_triangle.h index dc8809b0d..e99260a3f 100644 --- a/src/polyrenderer/drawers/screen_triangle.h +++ b/src/polyrenderer/drawers/screen_triangle.h @@ -45,21 +45,12 @@ struct ScreenTriangleStepVariables struct TriDrawTriangleArgs { - uint8_t *dest; - int32_t pitch; ShadedTriVertex *v1; ShadedTriVertex *v2; ShadedTriVertex *v3; - int32_t clipright; - int32_t clipbottom; - uint8_t *stencilbuffer; - int stencilpitch; - float *zbuffer; const PolyDrawArgs *uniforms; - bool destBgra; ScreenTriangleStepVariables gradientX; ScreenTriangleStepVariables gradientY; - float depthOffset; bool CalculateGradients() { @@ -142,6 +133,8 @@ class ScreenTriangle public: static void Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread); + static void(*TriangleDrawers[])(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread, int16_t *edges, int topY, int bottomY); + static void(*SpanDrawers8[])(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread); static void(*SpanDrawers32[])(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread); static void(*RectDrawers8[])(const void *, int, int, int, const RectDrawArgs *, PolyTriangleThreadData *); @@ -216,4 +209,42 @@ namespace TriScreenDrawerModes 11, 6, 6, 11, 15, 6, 6, 11, 15, 18, 21, 6, 6, 6, 6, 11, 6, 6, 11, 6, }; + + enum SWTriangleFlags + { + SWTRI_DepthTest = 1, + SWTRI_StencilTest = 2, + SWTRI_WriteColor = 4, + SWTRI_WriteDepth = 8, + SWTRI_WriteStencil = 16 + }; + + struct TriangleOpt4 { static const int Flags = 4; }; + struct TriangleOpt5 { static const int Flags = 5; }; + struct TriangleOpt6 { static const int Flags = 6; }; + struct TriangleOpt7 { static const int Flags = 7; }; + struct TriangleOpt8 { static const int Flags = 8; }; + struct TriangleOpt9 { static const int Flags = 9; }; + struct TriangleOpt10 { static const int Flags = 10; }; + struct TriangleOpt11 { static const int Flags = 11; }; + struct TriangleOpt12 { static const int Flags = 12; }; + struct TriangleOpt13 { static const int Flags = 13; }; + struct TriangleOpt14 { static const int Flags = 14; }; + struct TriangleOpt15 { static const int Flags = 15; }; + struct TriangleOpt16 { static const int Flags = 16; }; + struct TriangleOpt17 { static const int Flags = 17; }; + struct TriangleOpt18 { static const int Flags = 18; }; + struct TriangleOpt19 { static const int Flags = 19; }; + struct TriangleOpt20 { static const int Flags = 20; }; + struct TriangleOpt21 { static const int Flags = 21; }; + struct TriangleOpt22 { static const int Flags = 22; }; + struct TriangleOpt23 { static const int Flags = 23; }; + struct TriangleOpt24 { static const int Flags = 24; }; + struct TriangleOpt25 { static const int Flags = 25; }; + struct TriangleOpt26 { static const int Flags = 26; }; + struct TriangleOpt27 { static const int Flags = 27; }; + struct TriangleOpt28 { static const int Flags = 28; }; + struct TriangleOpt29 { static const int Flags = 29; }; + struct TriangleOpt30 { static const int Flags = 30; }; + struct TriangleOpt31 { static const int Flags = 31; }; } diff --git a/src/r_defs.h b/src/r_defs.h index 79c68a2dd..4c34163b0 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1612,7 +1612,7 @@ double NextLowestFloorAt(sector_t *sec, double x, double y, double z, int flags // This setup is to allow the VM call directily into the implementation. // With a member function this may be subject to OS implementation details, e.g. on Windows 32 bit members use a different calling convention than regular functions. void RemoveForceField(sector_t *sec); -bool PlaneMoving(sector_t *sector, int pos); +int PlaneMoving(sector_t *sector, int pos); void TransferSpecial(sector_t *self, sector_t *model); void GetSpecial(sector_t *self, secspecial_t *spec); void SetSpecial(sector_t *self, const secspecial_t *spec); @@ -1628,7 +1628,7 @@ double HighestCeilingAt(sector_t *sec, double x, double y, sector_t **resultsec double LowestFloorAt(sector_t *sec, double x, double y, sector_t **resultsec = nullptr); inline void sector_t::RemoveForceField() { return ::RemoveForceField(this); } -inline bool sector_t::PlaneMoving(int pos) { return ::PlaneMoving(this, pos); } +inline bool sector_t::PlaneMoving(int pos) { return !!::PlaneMoving(this, pos); } inline void sector_t::TransferSpecial(sector_t *model) { return ::TransferSpecial(this, model); } inline void sector_t::GetSpecial(secspecial_t *spec) { ::GetSpecial(this, spec); } inline void sector_t::SetSpecial(const secspecial_t *spec) { ::SetSpecial(this, spec); } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index a37b61259..52d9a4bd4 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -61,6 +61,7 @@ #include "sbar.h" #include "vm.h" #include "i_time.h" +#include "actorinlines.h" // EXTERNAL DATA DECLARATIONS ---------------------------------------------- diff --git a/src/s_sound.cpp b/src/s_sound.cpp index c10c9578c..14977820f 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1813,8 +1813,9 @@ void S_RelinkSound (AActor *from, AActor *to) // //========================================================================== -bool S_ChangeSoundVolume(AActor *actor, int channel, float volume) +void S_ChangeSoundVolume(AActor *actor, int channel, double dvolume) { + float volume = float(dvolume); // don't let volume get out of bounds if (volume < 0.0) volume = 0.0; @@ -1829,10 +1830,10 @@ bool S_ChangeSoundVolume(AActor *actor, int channel, float volume) { GSnd->ChannelVolume(chan, volume); chan->Volume = volume; - return true; + return; } } - return false; + return; } //========================================================================== diff --git a/src/s_sound.h b/src/s_sound.h index 7e2e40845..c6ee76236 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -307,7 +307,7 @@ bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id); bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id); // Change a playing sound's volume -bool S_ChangeSoundVolume(AActor *actor, int channel, float volume); +void S_ChangeSoundVolume(AActor *actor, int channel, double volume); // Moves all sounds from one mobj to another void S_RelinkSound (AActor *from, AActor *to); diff --git a/src/scripting/backend/dynarrays.cpp b/src/scripting/backend/dynarrays.cpp index bcfff6520..15b016166 100644 --- a/src/scripting/backend/dynarrays.cpp +++ b/src/scripting/backend/dynarrays.cpp @@ -80,7 +80,7 @@ template int ArrayPush(T *self, U val) return self->Push(static_cast(val)); } -template bool ArrayPop(T *self) +template int ArrayPop(T *self) { return self->Pop(); } diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 202fba2d1..6e3a1f08b 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -564,14 +564,14 @@ struct FieldDesc namespace { // Traits for the types we are interested in - template struct native_is_valid { static const bool value = false; }; - template struct native_is_valid { static const bool value = true; }; - template struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; - template<> struct native_is_valid { static const bool value = true; }; + template struct native_is_valid { static const bool value = false; static const bool retval = false; }; + template struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = true; }; + template<> struct native_is_valid { static const bool value = true; static const bool retval = false;}; // Bool as return does not work! } // Compile time validation of direct native functions @@ -581,21 +581,25 @@ struct DirectNativeDesc #define TP(n) typename P##n #define VP(n) ValidateType() - template DirectNativeDesc(Ret(*func)()) : Ptr(reinterpret_cast(func)) { ValidateType(); } - template DirectNativeDesc(Ret(*func)(P1)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); } - template DirectNativeDesc(Ret(*func)(P1,P2)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); } - template DirectNativeDesc(Ret(*func)(P1,P2,P3)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); } - template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)) : Ptr(reinterpret_cast(func)) { ValidateType(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); } + template DirectNativeDesc(Ret(*func)()) : Ptr(reinterpret_cast(func)) { ValidateRet(); } + template DirectNativeDesc(Ret(*func)(P1)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); } + template DirectNativeDesc(Ret(*func)(P1,P2)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); } + template DirectNativeDesc(Ret(*func)(P1,P2,P3)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); VP(12); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13)) : Ptr(reinterpret_cast(func)) { ValidateRet(); VP(1); VP(2); VP(3); VP(4); VP(5); VP(6); VP(7); VP(8); VP(9); VP(10); VP(11); VP(12); VP(13); } #undef TP #undef VP template void ValidateType() { static_assert(native_is_valid::value, "Argument type is not valid as a direct native parameter or return type"); } + template void ValidateRet() { static_assert(native_is_valid::retval, "Return type is not valid as a direct native parameter or return type"); } operator void *() const { return Ptr; } diff --git a/src/scripting/vmiterators.cpp b/src/scripting/vmiterators.cpp new file mode 100644 index 000000000..65d359c32 --- /dev/null +++ b/src/scripting/vmiterators.cpp @@ -0,0 +1,395 @@ +//----------------------------------------------------------------------------- +// +// Copyright 2016-2018 Christoph Oelckers +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//----------------------------------------------------------------------------- +// +// VM iterators +// +// These classes are thin wrappers which wrap the standars iterators into a DObject +// so that the VM can use them +// +//----------------------------------------------------------------------------- + +#include "actor.h" +#include "p_tags.h" +#include "p_maputl.h" +#include "g_levellocals.h" +#include "vm.h" + +//========================================================================== +// +// scriptable thinker iterator +// +//========================================================================== + +class DThinkerIterator : public DObject, public FThinkerIterator +{ + DECLARE_ABSTRACT_CLASS(DThinkerIterator, DObject) + +public: + DThinkerIterator(PClass *cls, int statnum = MAX_STATNUM + 1) + : FThinkerIterator(cls, statnum) + { + } +}; + +IMPLEMENT_CLASS(DThinkerIterator, true, false); + +static DThinkerIterator *CreateThinkerIterator(PClass *type, int statnum) +{ + return Create(type, statnum); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DThinkerIterator, Create, CreateThinkerIterator) +{ + PARAM_PROLOGUE; + PARAM_CLASS(type, DThinker); + PARAM_INT(statnum); + ACTION_RETURN_OBJECT(Create(type, statnum)); +} + +static DThinker *NextThinker(DThinkerIterator *self, bool exact) +{ + return self->Next(exact); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DThinkerIterator, Next, NextThinker) +{ + PARAM_SELF_PROLOGUE(DThinkerIterator); + PARAM_BOOL(exact); + ACTION_RETURN_OBJECT(self->Next(exact)); +} + +static void ReinitThinker(DThinkerIterator *self) +{ + self->Reinit(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DThinkerIterator, Reinit, ReinitThinker) +{ + PARAM_SELF_PROLOGUE(DThinkerIterator); + self->Reinit(); + return 0; +} + +//=========================================================================== +// +// scriptable BlockLines iterator +// +//=========================================================================== + +class DBlockLinesIterator : public DObject, public FMultiBlockLinesIterator +{ + DECLARE_ABSTRACT_CLASS(DBlockLinesIterator, DObject); + FPortalGroupArray check; + +public: + FMultiBlockLinesIterator::CheckResult cres; + + DBlockLinesIterator(AActor *actor, double checkradius) + : FMultiBlockLinesIterator(check, actor, checkradius) + { + cres.line = nullptr; + cres.Position.Zero(); + cres.portalflags = 0; + } + + DBlockLinesIterator(double x, double y, double z, double height, double radius, sector_t *sec) + :FMultiBlockLinesIterator(check, x, y, z, height, radius, sec) + { + cres.line = nullptr; + cres.Position.Zero(); + cres.portalflags = 0; + } +}; + +IMPLEMENT_CLASS(DBlockLinesIterator, true, false); + +static DBlockLinesIterator *CreateBLI(AActor *origin, double radius) +{ + return Create(origin, radius); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DBlockLinesIterator, Create, CreateBLI) +{ + PARAM_PROLOGUE; + PARAM_OBJECT_NOT_NULL(origin, AActor); + PARAM_FLOAT(radius); + ACTION_RETURN_OBJECT(Create(origin, radius)); +} + +static DBlockLinesIterator *CreateBLIFromPos(double x, double y, double z, double h, double radius, sector_t *sec) +{ + return Create(x, y, z, h, radius, sec); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DBlockLinesIterator, CreateFromPos, CreateBLIFromPos) +{ + PARAM_PROLOGUE; + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_FLOAT(h); + PARAM_FLOAT(radius); + PARAM_POINTER(sec, sector_t); + ACTION_RETURN_OBJECT(Create(x, y, z, h, radius, sec)); +} + +static int BLINext(DBlockLinesIterator *self) +{ + return self->Next(&self->cres); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DBlockLinesIterator, Next, BLINext) +{ + PARAM_SELF_PROLOGUE(DBlockLinesIterator); + ACTION_RETURN_BOOL(BLINext(self)); +} + +//=========================================================================== +// +// scriptable BlockThings iterator +// +//=========================================================================== + +class DBlockThingsIterator : public DObject +{ + DECLARE_ABSTRACT_CLASS(DBlockThingsIterator, DObject); + FPortalGroupArray check; +public: + FMultiBlockThingsIterator iterator; + FMultiBlockThingsIterator::CheckResult cres; + + DBlockThingsIterator(AActor *origin, double checkradius = -1, bool ignorerestricted = false) + : iterator(check, origin, checkradius, ignorerestricted) + { + cres.thing = nullptr; + cres.Position.Zero(); + cres.portalflags = 0; + } + + DBlockThingsIterator(double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec) + : iterator(check, checkx, checky, checkz, checkh, checkradius, ignorerestricted, newsec) + { + cres.thing = nullptr; + cres.Position.Zero(); + cres.portalflags = 0; + } +}; + +IMPLEMENT_CLASS(DBlockThingsIterator, true, false); + + +static DBlockThingsIterator *CreateBTI(AActor *origin, double radius, bool ignore) +{ + return Create(origin, radius, ignore); +} + + +DEFINE_ACTION_FUNCTION_NATIVE(DBlockThingsIterator, Create, CreateBTI) +{ + PARAM_PROLOGUE; + PARAM_OBJECT_NOT_NULL(origin, AActor); + PARAM_FLOAT(radius); + PARAM_BOOL(ignore); + ACTION_RETURN_OBJECT(Create(origin, radius, ignore)); +} + +static DBlockThingsIterator *CreateBTIFromPos(double x, double y, double z, double h, double radius, bool ignore) +{ + return Create(x, y, z, h, radius, ignore, nullptr); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DBlockThingsIterator, CreateFromPos, CreateBTIFromPos) +{ + PARAM_PROLOGUE; + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_FLOAT(h); + PARAM_FLOAT(radius); + PARAM_BOOL(ignore); + ACTION_RETURN_OBJECT(Create(x, y, z, h, radius, ignore, nullptr)); +} + +static int NextBTI(DBlockThingsIterator *bti) +{ + return bti->iterator.Next(&bti->cres); +} + + +DEFINE_ACTION_FUNCTION_NATIVE(DBlockThingsIterator, Next, NextBTI) +{ + PARAM_SELF_PROLOGUE(DBlockThingsIterator); + ACTION_RETURN_BOOL(NextBTI(self)); +} + + +class DSectorTagIterator : public DObject, public FSectorTagIterator +{ + DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject); +public: + DSectorTagIterator(int tag, line_t *line) + { + if (line == nullptr) Init(tag); + else Init(tag, line); + } +}; + +IMPLEMENT_CLASS(DSectorTagIterator, true, false); + +static DSectorTagIterator *CreateSTI(int tag, line_t *line) +{ + return Create(tag, line); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DSectorTagIterator, Create, CreateSTI) +{ + PARAM_PROLOGUE; + PARAM_INT(tag); + PARAM_POINTER(line, line_t); + ACTION_RETURN_POINTER(Create(tag, line)); +} + +int NextSTI(DSectorTagIterator *self) +{ + return self->Next(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DSectorTagIterator, Next, NextSTI) +{ + PARAM_SELF_PROLOGUE(DSectorTagIterator); + ACTION_RETURN_INT(self->Next()); +} + +int NextCompatSTI(DSectorTagIterator *self, bool compat, int secnum) +{ + return self->NextCompat(compat, secnum); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DSectorTagIterator, NextCompat, NextCompatSTI) +{ + PARAM_SELF_PROLOGUE(DSectorTagIterator); + PARAM_BOOL(compat); + PARAM_INT(secnum); + ACTION_RETURN_INT(self->NextCompat(compat, secnum)); +} + +//=========================================================================== +// +// scriptable line id iterator +// +//=========================================================================== + +class DLineIdIterator : public DObject, public FLineIdIterator +{ + DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject); +public: + DLineIdIterator(int tag) + : FLineIdIterator(tag) + { + } +}; + +IMPLEMENT_CLASS(DLineIdIterator, true, false); + + +static DLineIdIterator *CreateLTI(int tag) +{ + return Create(tag); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DLineIdIterator, Create, CreateLTI) +{ + PARAM_PROLOGUE; + PARAM_INT(tag); + ACTION_RETURN_POINTER(Create(tag)); +} + +int NextLTI(DLineIdIterator *self) +{ + return self->Next(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DLineIdIterator, Next, NextLTI) +{ + PARAM_SELF_PROLOGUE(DLineIdIterator); + ACTION_RETURN_INT(self->Next()); +} + +//=========================================================================== +// +// scriptable actor iterator +// +//=========================================================================== + +class DActorIterator : public DObject, public NActorIterator +{ + DECLARE_ABSTRACT_CLASS(DActorIterator, DObject) + +public: + DActorIterator(PClassActor *cls = nullptr, int tid = 0) + : NActorIterator(cls, tid) + { + } +}; + +IMPLEMENT_CLASS(DActorIterator, true, false); + +static DActorIterator *CreateActI(int tid, PClassActor *type) +{ + return Create(type, tid); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DActorIterator, Create, CreateActI) +{ + PARAM_PROLOGUE; + PARAM_INT(tid); + PARAM_CLASS(type, AActor); + ACTION_RETURN_OBJECT(Create(type, tid)); +} + +static AActor *NextActI(DActorIterator *self) +{ + return self->Next(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DActorIterator, Next, NextActI) +{ + PARAM_SELF_PROLOGUE(DActorIterator); + ACTION_RETURN_OBJECT(self->Next()); +} + +static void ReinitActI(DActorIterator *self) +{ + self->Reinit(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DActorIterator, Reinit, ReinitActI) +{ + PARAM_SELF_PROLOGUE(DActorIterator); + self->Reinit(); + return 0; +} + +DEFINE_FIELD_NAMED(DBlockLinesIterator, cres.line, curline); +DEFINE_FIELD_NAMED(DBlockLinesIterator, cres.Position, position); +DEFINE_FIELD_NAMED(DBlockLinesIterator, cres.portalflags, portalflags); + +DEFINE_FIELD_NAMED(DBlockThingsIterator, cres.thing, thing); +DEFINE_FIELD_NAMED(DBlockThingsIterator, cres.Position, position); +DEFINE_FIELD_NAMED(DBlockThingsIterator, cres.portalflags, portalflags); diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index a7b759da0..c6998fec2 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -42,11 +42,16 @@ #include "a_pickups.h" #include "a_specialspot.h" #include "actorptrselect.h" +#include "a_weapons.h" +#include "d_player.h" +#include "p_setup.h" +#include "i_music.h" DVector2 AM_GetPosition(); int Net_GetLatency(int *ld, int *ad); void PrintPickupMessage(bool localview, const FString &str); + //===================================================================================== // // FString exports @@ -1808,75 +1813,62 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetCursor, GetCursor) //===================================================================================== // -// AActor exports (this will be expanded) +// WeaponSlots exports // //===================================================================================== -DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetPointer, COPY_AAPTR) +static int LocateWeapon(FWeaponSlots *self, PClassActor *weap, int *pslot, int *pindex) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(ptr); - ACTION_RETURN_OBJECT(COPY_AAPTR(self, ptr)); + return self->LocateWeapon(weap, pslot, pindex); } - -DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_PlaySound, A_PlaySound) +DEFINE_ACTION_FUNCTION_NATIVE(FWeaponSlots, LocateWeapon, LocateWeapon) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_SOUND(soundid); - PARAM_INT(channel); - PARAM_FLOAT(volume); - PARAM_BOOL(looping); - PARAM_FLOAT(attenuation); - PARAM_BOOL(local); - A_PlaySound(self, soundid, channel, volume, looping, attenuation, local); + PARAM_SELF_STRUCT_PROLOGUE(FWeaponSlots); + PARAM_CLASS(weap, AActor); + int slot = 0, index = 0; + bool retv = self->LocateWeapon(weap, &slot, &index); + if (numret >= 1) ret[0].SetInt(retv); + if (numret >= 2) ret[1].SetInt(slot); + if (numret >= 3) ret[2].SetInt(index); + return MIN(numret, 3); +} + +static PClassActor *GetWeapon(FWeaponSlots *self, int slot, int index) +{ + return self->GetWeapon(slot, index); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FWeaponSlots, GetWeapon, GetWeapon) +{ + PARAM_SELF_STRUCT_PROLOGUE(FWeaponSlots); + PARAM_INT(slot); + PARAM_INT(index); + ACTION_RETURN_POINTER(self->GetWeapon(slot, index)); + return 1; +} + +static int SlotSize(FWeaponSlots *self, int slot) +{ + return self->SlotSize(slot); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FWeaponSlots, SlotSize, SlotSize) +{ + PARAM_SELF_STRUCT_PROLOGUE(FWeaponSlots); + PARAM_INT(slot); + ACTION_RETURN_INT(self->SlotSize(slot)); + return 1; +} + +DEFINE_ACTION_FUNCTION_NATIVE(FWeaponSlots, SetupWeaponSlots, FWeaponSlots::SetupWeaponSlots) +{ + PARAM_PROLOGUE; + PARAM_OBJECT(pawn, APlayerPawn); + FWeaponSlots::SetupWeaponSlots(pawn); return 0; } -DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckKeys, P_CheckKeys) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_INT(locknum); - PARAM_BOOL(remote); - PARAM_BOOL(quiet); - ACTION_RETURN_BOOL(P_CheckKeys(self, locknum, remote, quiet)); -} - - -//===================================================================================== -// -// Inventory exports -// -//===================================================================================== - -DEFINE_ACTION_FUNCTION_NATIVE(AInventory, PrintPickupMessage, PrintPickupMessage) -{ - PARAM_PROLOGUE; - PARAM_BOOL(localview); - PARAM_STRING(str); - PrintPickupMessage(localview, str); - return 0; -} - -//===================================================================================== -// -// Key exports -// -//===================================================================================== - -DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetKeyTypeCount, P_GetKeyTypeCount) -{ - PARAM_PROLOGUE; - ACTION_RETURN_INT(P_GetKeyTypeCount()); -} - -DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetKeyType, P_GetKeyType) -{ - PARAM_PROLOGUE; - PARAM_INT(num); - ACTION_RETURN_POINTER(P_GetKeyType(num)); -} - //===================================================================================== // // SpotState exports @@ -2459,6 +2451,53 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetAutomapPosition, GetAutomapPositi ACTION_RETURN_VEC2(AM_GetPosition()); } +static int ZGetUDMFInt(int type, int index, int key) +{ + return GetUDMFInt(type, index, ENamedName(key)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFInt, ZGetUDMFInt) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(type); + PARAM_INT(index); + PARAM_NAME(key); + ACTION_RETURN_INT(GetUDMFInt(type, index, key)); +} + +static double ZGetUDMFFloat(int type, int index, int key) +{ + return GetUDMFFloat(type, index, ENamedName(key)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFFloat, ZGetUDMFFloat) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(type); + PARAM_INT(index); + PARAM_NAME(key); + ACTION_RETURN_FLOAT(GetUDMFFloat(type, index, key)); +} + +static void ZGetUDMFString(int type, int index, int key, FString *result) +{ + *result = GetUDMFString(type, index, ENamedName(key)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFString, ZGetUDMFString) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(type); + PARAM_INT(index); + PARAM_NAME(key); + ACTION_RETURN_STRING(GetUDMFString(type, index, key)); +} + +//===================================================================================== +// +// +// +//===================================================================================== static int GetRealTime() { @@ -2485,8 +2524,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(_AltHUD, GetLatency, Net_GetLatency) return numret; } - - DEFINE_FIELD_X(Sector, sector_t, floorplane) DEFINE_FIELD_X(Sector, sector_t, ceilingplane) DEFINE_FIELD_X(Sector, sector_t, Colormap) diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp new file mode 100644 index 000000000..97e5066fb --- /dev/null +++ b/src/scripting/vmthunks_actors.cpp @@ -0,0 +1,1815 @@ +//----------------------------------------------------------------------------- +// +// Copyright 2016-2018 Christoph Oelckers +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//----------------------------------------------------------------------------- +// +// VM thunks for internal functions of actor classes +// +// Important note about this file: Since everything in here is supposed to be called +// from JIT-compiled VM code it needs to be very careful about calling conventions. +// As a result none of the integer sized struct types may be used as function +// arguments, because current C++ calling conventions require them to be passed +// by reference. The JIT code, however will pass them by value so any direct native function +// taking such an argument needs to receive it as a naked int. +// +//----------------------------------------------------------------------------- + +#include "vm.h" +#include "r_defs.h" +#include "g_levellocals.h" +#include "s_sound.h" +#include "p_local.h" +#include "v_font.h" +#include "gstrings.h" +#include "a_keys.h" +#include "sbar.h" +#include "doomstat.h" +#include "p_acs.h" +#include "a_pickups.h" +#include "a_specialspot.h" +#include "actorptrselect.h" +#include "a_weapons.h" +#include "d_player.h" +#include "p_setup.h" +#include "i_music.h" +#include "p_terrain.h" +#include "p_checkposition.h" +#include "p_linetracedata.h" +#include "p_local.h" +#include "p_effect.h" +#include "p_spec.h" +#include "actorinlines.h" +#include "p_enemy.h" +#include "gi.h" + +DVector2 AM_GetPosition(); +int Net_GetLatency(int *ld, int *ad); +void PrintPickupMessage(bool localview, const FString &str); + +// FCheckPosition requires explicit construction and destruction when used in the VM + +static void FCheckPosition_C(void *mem) +{ + new(mem) FCheckPosition; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_FCheckPosition, _Constructor, FCheckPosition_C) +{ + PARAM_SELF_STRUCT_PROLOGUE(FCheckPosition); + FCheckPosition_C(self); + return 0; +} + +static void FCheckPosition_D(FCheckPosition *self) +{ + self->~FCheckPosition(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_FCheckPosition, _Destructor, FCheckPosition_D) +{ + PARAM_SELF_STRUCT_PROLOGUE(FCheckPosition); + self->~FCheckPosition(); + return 0; +} + +static void ClearLastRipped(FCheckPosition *self) +{ + self->LastRipped.Clear(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_FCheckPosition, ClearLastRipped, ClearLastRipped) +{ + PARAM_SELF_STRUCT_PROLOGUE(FCheckPosition); + self->LastRipped.Clear(); + return 0; +} + + + +DEFINE_ACTION_FUNCTION_NATIVE(DObject, SetMusicVolume, I_SetMusicVolume) +{ + PARAM_PROLOGUE; + PARAM_FLOAT(vol); + I_SetMusicVolume(vol); + return 0; +} + +//===================================================================================== +// +// AActor exports (this will be expanded) +// +//===================================================================================== + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetPointer, COPY_AAPTR) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(ptr); + ACTION_RETURN_OBJECT(COPY_AAPTR(self, ptr)); +} + + +//========================================================================== +// +// Custom sound functions. +// +//========================================================================== + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopSound, S_StopSound) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(slot); + + S_StopSound(self, slot); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_SoundVolume, S_ChangeSoundVolume) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(channel); + PARAM_FLOAT(volume); + S_ChangeSoundVolume(self, channel, volume); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_PlaySound, A_PlaySound) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_SOUND(soundid); + PARAM_INT(channel); + PARAM_FLOAT(volume); + PARAM_BOOL(looping); + PARAM_FLOAT(attenuation); + PARAM_BOOL(local); + A_PlaySound(self, soundid, channel, volume, looping, attenuation, local); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckKeys, P_CheckKeys) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(locknum); + PARAM_BOOL(remote); + PARAM_BOOL(quiet); + ACTION_RETURN_BOOL(P_CheckKeys(self, locknum, remote, quiet)); +} + +static double deltaangleDbl(double a1, double a2) +{ + return deltaangle(DAngle(a1), DAngle(a2)).Degrees; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, deltaangle, deltaangleDbl) // should this be global? +{ + PARAM_PROLOGUE; + PARAM_FLOAT(a1); + PARAM_FLOAT(a2); + ACTION_RETURN_FLOAT(deltaangle(DAngle(a1), DAngle(a2)).Degrees); +} + +static double absangleDbl(double a1, double a2) +{ + return absangle(DAngle(a1), DAngle(a2)).Degrees; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, absangle, absangleDbl) // should this be global? +{ + PARAM_PROLOGUE; + PARAM_FLOAT(a1); + PARAM_FLOAT(a2); + ACTION_RETURN_FLOAT(absangle(DAngle(a1), DAngle(a2)).Degrees); +} + +static double Distance2DSquared(AActor *self, AActor *other) +{ + return self->Distance2DSquared(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Distance2DSquared, Distance2DSquared) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_FLOAT(self->Distance2DSquared(other)); +} + +static double Distance3DSquared(AActor *self, AActor *other) +{ + return self->Distance3DSquared(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Distance3DSquared, Distance3DSquared) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_FLOAT(self->Distance3DSquared(other)); +} + +static double Distance2D(AActor *self, AActor *other) +{ + return self->Distance2D(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Distance2D, Distance2D) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_FLOAT(self->Distance2D(other)); +} + +static double Distance3D(AActor *self, AActor *other) +{ + return self->Distance3D(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Distance3D, Distance3D) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_FLOAT(self->Distance3D(other)); +} + +static void AddZ(AActor *self, double addz, bool moving) +{ + self->AddZ(addz, moving); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, AddZ, AddZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(addz); + PARAM_BOOL(moving); + self->AddZ(addz, moving); + return 0; +} + +static void SetZ(AActor *self, double z) +{ + self->SetZ(z); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetZ, SetZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(z); + self->SetZ(z); + return 0; +} + +static void SetDamage(AActor *self, int dmg) +{ + self->SetDamage(dmg); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetDamage, SetDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(dmg); + self->SetDamage(dmg); + return 0; +} + +// This combines all 3 variations of the internal function +static void VelFromAngle(AActor *self, double speed, double angle) +{ + if (speed == 1e37) + { + self->VelFromAngle(); + } + else + { + if (angle == 1e37) + + { + self->VelFromAngle(speed); + } + else + { + self->VelFromAngle(speed, angle); + } + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, VelFromAngle, VelFromAngle) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(speed); + PARAM_FLOAT(angle); + VelFromAngle(self, speed, angle); + return 0; +} + +static void Vel3DFromAngle(AActor *self, double speed, double angle, double pitch) +{ + self->Vel3DFromAngle(angle, pitch, speed); +} + +// This combines all 3 variations of the internal function +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vel3DFromAngle, Vel3DFromAngle) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(speed); + PARAM_ANGLE(angle); + PARAM_ANGLE(pitch); + self->Vel3DFromAngle(angle, pitch, speed); + return 0; +} + +// This combines all 3 variations of the internal function +static void Thrust(AActor *self, double speed, double angle) +{ + if (speed == 1e37) + { + self->Thrust(); + } + else + { + if (angle == 1e37) + { + self->Thrust(speed); + } + else + { + self->Thrust(angle, speed); + } + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Thrust, Thrust) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(speed); + PARAM_FLOAT(angle); + Thrust(self, speed, angle); + return 0; +} + +static double AngleTo(AActor *self, AActor *targ, bool absolute) +{ + return self->AngleTo(PARAM_NULLCHECK(targ, targ), absolute).Degrees; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, AngleTo, AngleTo) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(targ, AActor); + PARAM_BOOL(absolute); + ACTION_RETURN_FLOAT(self->AngleTo(targ, absolute).Degrees); +} + +static void AngleToVector(double angle, double length, DVector2 *result) +{ + *result = DAngle(angle).ToVector(length); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, AngleToVector, AngleToVector) +{ + PARAM_PROLOGUE; + PARAM_ANGLE(angle); + PARAM_FLOAT(length); + ACTION_RETURN_VEC2(angle.ToVector(length)); +} + +static void RotateVector(double x, double y, double angle, DVector2 *result) +{ + *result = DVector2(x, y).Rotated(angle); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RotateVector, RotateVector) +{ + PARAM_PROLOGUE; + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_ANGLE(angle); + ACTION_RETURN_VEC2(DVector2(x, y).Rotated(angle)); +} + +static double Normalize180(double angle) +{ + return DAngle(angle).Normalized180().Degrees; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Normalize180, Normalize180) +{ + PARAM_PROLOGUE; + PARAM_ANGLE(angle); + ACTION_RETURN_FLOAT(angle.Normalized180().Degrees); +} + +static double DistanceBySpeed(AActor *self, AActor *targ, double speed) +{ + return self->DistanceBySpeed(PARAM_NULLCHECK(targ, targ), speed); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, DistanceBySpeed, DistanceBySpeed) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(targ, AActor); + PARAM_FLOAT(speed); + ACTION_RETURN_FLOAT(self->DistanceBySpeed(targ, speed)); +} + +static void SetXYZ(AActor *self, double x, double y, double z) +{ + self->SetXYZ(x, y, z); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetXYZ, SetXYZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + self->SetXYZ(x, y, z); + return 0; +} + +static void Vec2Angle(AActor *self, double length, double angle, bool absolute, DVector2 *result) +{ + *result = self->Vec2Angle(length, angle, absolute); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec2Angle, Vec2Angle) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(length); + PARAM_ANGLE(angle); + PARAM_BOOL(absolute); + ACTION_RETURN_VEC2(self->Vec2Angle(length, angle, absolute)); +} + +static void Vec3To(AActor *self, AActor *t, DVector3 *result) +{ + *result = self->Vec3To(PARAM_NULLCHECK(t, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec3To, Vec3To) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(t, AActor) + ACTION_RETURN_VEC3(self->Vec3To(t)); +} + +static void Vec2To(AActor *self, AActor *t, DVector2 *result) +{ + *result = self->Vec2To(PARAM_NULLCHECK(t, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec2To, Vec2To) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(t, AActor) + ACTION_RETURN_VEC2(self->Vec2To(t)); +} + +static void Vec3Angle(AActor *self, double length, double angle, double z, bool absolute, DVector2 *result) +{ + *result = self->Vec3Angle(length, angle, z, absolute); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec3Angle, Vec3Angle) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(length) + PARAM_ANGLE(angle); + PARAM_FLOAT(z); + PARAM_BOOL(absolute); + ACTION_RETURN_VEC3(self->Vec3Angle(length, angle, z, absolute)); +} + +static void Vec2OffsetZ(AActor *self, double x, double y, double z, bool absolute, DVector3 *result) +{ + *result = self->Vec2OffsetZ(x, y, z, absolute); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec2OffsetZ, Vec2OffsetZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_BOOL(absolute); + ACTION_RETURN_VEC3(self->Vec2OffsetZ(x, y, z, absolute)); +} + +static void Vec2Offset(AActor *self, double x, double y, bool absolute, DVector2 *result) +{ + *result = self->Vec2OffsetZ(x, y, absolute); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec2Offset, Vec2Offset) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_BOOL(absolute); + ACTION_RETURN_VEC2(self->Vec2Offset(x, y, absolute)); +} + +static void Vec3Offset(AActor *self, double x, double y, double z, bool absolute, DVector3 *result) +{ + *result = self->Vec3Offset(x, y, z, absolute); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec3Offset, Vec3Offset) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_BOOL(absolute); + ACTION_RETURN_VEC3(self->Vec3Offset(x, y, z, absolute)); +} + +static void ZS_PosRelative(AActor *self, sector_t *sec, DVector3 *result) +{ + *result = self->PosRelative(sec); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, PosRelative, ZS_PosRelative) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(sec, sector_t); + ACTION_RETURN_VEC3(self->PosRelative(sec)); +} + +static void RestoreDamage(AActor *self) +{ + self->DamageVal = self->GetDefault()->DamageVal; + self->DamageFunc = self->GetDefault()->DamageFunc; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RestoreDamage, RestoreDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + RestoreDamage(self); + return 0; +} + +static int PlayerNumber(AActor *self) +{ + return self->player ? int(self->player - players) : 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, PlayerNumber, PlayerNumber) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_INT(PlayerNumber(self)); +} + +static void SetFriendPlayer(AActor *self, player_t *player) +{ + self->SetFriendPlayer(player); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetFriendPlayer, SetFriendPlayer) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(player, player_t); + self->SetFriendPlayer(player); + return 0; +} + +void ClearBounce(AActor *self) +{ + self->BounceFlags = 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearBounce, ClearBounce) +{ + PARAM_SELF_PROLOGUE(AActor); + ClearBounce(self); + return 0; +} + +static int CountsAsKill(AActor *self) +{ + return self->CountsAsKill(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CountsAsKill, CountsAsKill) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(self->CountsAsKill()); +} + +static int IsZeroDamage(AActor *self) +{ + return self->IsZeroDamage(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsZeroDamage, IsZeroDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(self->IsZeroDamage()); +} + +static void ClearInterpolation(AActor *self) +{ + self->ClearInterpolation(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearInterpolation, ClearInterpolation) +{ + PARAM_SELF_PROLOGUE(AActor); + self->ClearInterpolation(); + return 0; +} + +static int ApplyDamageFactors(PClassActor *itemcls, int damagetype, int damage, int defdamage) +{ + DmgFactors &df = itemcls->ActorInfo()->DamageFactors; + if (df.Size() != 0) + { + return (df.Apply(ENamedName(damagetype), damage)); + } + else + { + return (defdamage); + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ApplyDamageFactors, ApplyDamageFactors) +{ + PARAM_PROLOGUE; + PARAM_CLASS(itemcls, AActor); + PARAM_NAME(damagetype); + PARAM_INT(damage); + PARAM_INT(defdamage); + ACTION_RETURN_INT(ApplyDamageFactors(itemcls, damagetype.GetIndex(), damage, defdamage)); +} + +static void RestoreSpecialPosition(AActor *self) +{ + self->RestoreSpecialPosition(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_RestoreSpecialPosition, RestoreSpecialPosition) +{ + PARAM_SELF_PROLOGUE(AActor); + self->RestoreSpecialPosition(); + return 0; +} + +static double GetBobOffset(AActor *self, double frac) +{ + return self->GetBobOffset(frac); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetBobOffset, GetBobOffset) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(frac); + ACTION_RETURN_FLOAT(self->GetBobOffset(frac)); +} + +static void SetIdle(AActor *self, bool nofunction) +{ + self->SetIdle(nofunction); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetIdle, SetIdle) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(nofunction); + self->SetIdle(nofunction); + return 0; +} + +static int SpawnHealth(AActor *self) +{ + return self->SpawnHealth(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SpawnHealth, SpawnHealth) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_INT(self->SpawnHealth()); +} + +// Why does this exist twice? +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpawnHealth, SpawnHealth) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_INT(self->SpawnHealth()); +} + + + +void Revive(AActor *self) +{ + self->Revive(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Revive, Revive) +{ + PARAM_SELF_PROLOGUE(AActor); + self->Revive(); + return 0; +} + +static double GetCameraHeight(AActor *self) +{ + return self->GetCameraHeight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetCameraHeight, GetCameraHeight) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_FLOAT(self->GetCameraHeight()); +} + +static FDropItem *GetDropItems(AActor *self) +{ + return self->GetDropItems(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetDropItems, GetDropItems) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_POINTER(self->GetDropItems()); +} + +static double GetGravity(AActor *self) +{ + return self->GetGravity(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetGravity, GetGravity) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_FLOAT(self->GetGravity()); +} + +static void GetTag(AActor *self, const FString &def, FString *result) +{ + *result = self->GetTag(def.Len() == 0 ? nullptr : def.GetChars()); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetTag, GetTag) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_STRING(def); + FString res; + GetTag(self, def, &res); + ACTION_RETURN_STRING(res); +} + +static void SetTag(AActor *self, const FString &def) +{ + if (def.IsEmpty()) self->Tag = nullptr; + else self->Tag = self->mStringPropertyData.Alloc(def); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetTag, SetTag) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_STRING(def); + SetTag(self, def); + return 0; +} + +static void ClearCounters(AActor *self) +{ + self->ClearCounters(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearCounters, ClearCounters) +{ + PARAM_SELF_PROLOGUE(AActor); + self->ClearCounters(); + return 0; +} + +static int GetModifiedDamage(AActor *self, int type, int damage, bool passive) +{ + return self->GetModifiedDamage(ENamedName(type), damage, passive); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetModifiedDamage, GetModifiedDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_NAME(type); + PARAM_INT(damage); + PARAM_BOOL(passive); + ACTION_RETURN_INT(self->GetModifiedDamage(type, damage, passive)); +} + +static int ApplyDamageFactor(AActor *self, int type, int damage) +{ + return self->ApplyDamageFactor(ENamedName(type), damage); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ApplyDamageFactor, ApplyDamageFactor) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_NAME(type); + PARAM_INT(damage); + ACTION_RETURN_INT(self->ApplyDamageFactor(type, damage)); +} + +double GetDefaultSpeed(PClassActor *type); + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetDefaultSpeed, GetDefaultSpeed) +{ + PARAM_PROLOGUE; + PARAM_CLASS(type, AActor); + ACTION_RETURN_FLOAT(GetDefaultSpeed(type)); +} + +static int isTeammate(AActor *self, AActor *other) +{ + return self->IsTeammate(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, isTeammate, isTeammate) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_BOOL(self->IsTeammate(other)); +} + +static int GetSpecies(AActor *self) +{ + return self->GetSpecies(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpecies, GetSpecies) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_INT(self->GetSpecies()); +} + +static int isFriend(AActor *self, AActor *other) +{ + return self->IsFriend(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, isFriend, isFriend) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_BOOL(self->IsFriend(other)); +} + +static int isHostile(AActor *self, AActor *other) +{ + return self->IsHostile(PARAM_NULLCHECK(other, other)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, isHostile, isHostile) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(other, AActor); + ACTION_RETURN_BOOL(self->IsHostile(other)); +} + +static FTerrainDef *GetFloorTerrain(AActor *self) +{ + return &Terrains[P_GetThingFloorType(self)]; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetFloorTerrain, GetFloorTerrain) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_POINTER(GetFloorTerrain(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, FindUniqueTid, P_FindUniqueTID) +{ + PARAM_PROLOGUE; + PARAM_INT(start); + PARAM_INT(limit); + ACTION_RETURN_INT(P_FindUniqueTID(start, limit)); +} + +static void RemoveFromHash(AActor *self) +{ + self->RemoveFromHash(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RemoveFromHash, RemoveFromHash) +{ + PARAM_SELF_PROLOGUE(AActor); + self->RemoveFromHash(); + return 0; +} + +static void ChangeTid(AActor *self, int tid) +{ + self->RemoveFromHash(); + self->tid = tid; + self->AddToHash(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ChangeTid, ChangeTid) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(tid); + ChangeTid(self, tid); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, FindFloorCeiling, P_FindFloorCeiling) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(flags); + P_FindFloorCeiling(self, flags); + return 0; +} + +static int TeleportMove(AActor *self, double x, double y, double z, bool telefrag, bool modify) +{ + return P_TeleportMove(self, DVector3(x, y, z), telefrag, modify); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, TeleportMove, TeleportMove) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_BOOL(telefrag); + PARAM_BOOL(modify); + ACTION_RETURN_BOOL(P_TeleportMove(self, DVector3(x, y, z), telefrag, modify)); +} + +static double ZS_GetFriction(AActor *self, double *mf) +{ + double friction; + *mf = P_GetMoveFactor(self, &friction); + return friction; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetFriction, ZS_GetFriction) +{ + PARAM_SELF_PROLOGUE(AActor); + double friction, movefactor = P_GetMoveFactor(self, &friction); + if (numret > 1) ret[1].SetFloat(movefactor); + if (numret > 0) ret[0].SetFloat(friction); + return numret; +} + +static int CheckPosition(AActor *self, double x, double y, bool actorsonly, FCheckPosition *tm) +{ + if (tm) + { + return (P_CheckPosition(self, DVector2(x, y), *tm, actorsonly)); + } + else + { + return (P_CheckPosition(self, DVector2(x, y), actorsonly)); + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckPosition, CheckPosition) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_BOOL(actorsonly); + PARAM_POINTER(tm, FCheckPosition); + ACTION_RETURN_BOOL(CheckPosition(self, x, y, actorsonly, tm)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, TestMobjLocation, P_TestMobjLocation) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(P_TestMobjLocation(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, TestMobjZ, P_TestMobjZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(quick); + + AActor *on = nullptr; + bool retv = P_TestMobjZ(self, quick, &on); + if (numret > 1) ret[1].SetObject(on); + if (numret > 0) ret[0].SetInt(retv); + return numret; +} + +static int TryMove(AActor *self ,double x, double y, int dropoff, bool missilecheck, FCheckPosition *tm) +{ + if (tm == nullptr) + { + return (P_TryMove(self, DVector2(x, y), dropoff, nullptr, missilecheck)); + } + else + { + return (P_TryMove(self, DVector2(x, y), dropoff, nullptr, *tm, missilecheck)); + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, TryMove, TryMove) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_INT(dropoff); + PARAM_BOOL(missilecheck); + PARAM_POINTER(tm, FCheckPosition); + ACTION_RETURN_BOOL(TryMove(self, x, y, dropoff, missilecheck, tm)); +} + +static int CheckMove(AActor *self ,double x, double y, int flags, FCheckPosition *tm) +{ + if (tm == nullptr) + { + return (P_CheckMove(self, DVector2(x, y), flags)); + } + else + { + return (P_CheckMove(self, DVector2(x, y), *tm, flags)); + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckMove, CheckMove) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_INT(flags); + PARAM_POINTER(tm, FCheckPosition); + ACTION_RETURN_BOOL(CheckMove(self, x, y, flags, tm)); +} + +static double AimLineAttack(AActor *self, double angle, double distance, FTranslatedLineTarget *pLineTarget, double vrange, int flags, AActor *target, AActor *friender) +{ + return P_AimLineAttack(self, angle, distance, pLineTarget, vrange, flags, target, friender).Degrees; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, AimLineAttack, AimLineAttack) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_ANGLE(angle); + PARAM_FLOAT(distance); + PARAM_OUTPOINTER(pLineTarget, FTranslatedLineTarget); + PARAM_ANGLE(vrange); + PARAM_INT(flags); + PARAM_OBJECT(target, AActor); + PARAM_OBJECT(friender, AActor); + ACTION_RETURN_FLOAT(P_AimLineAttack(self, angle, distance, pLineTarget, vrange, flags, target, friender).Degrees); +} + +static AActor *ZS_LineAttack(AActor *self, double angle, double distance, double pitch, int damage, int damageType, PClassActor *puffType, int flags, FTranslatedLineTarget *victim, double offsetz, double offsetforward, double offsetside, int *actualdamage) +{ + if (puffType == nullptr) puffType = PClass::FindActor(NAME_BulletPuff); // P_LineAttack does not work without a puff to take info from. + return P_LineAttack(self, angle, distance, pitch, damage, ENamedName(damageType), puffType, flags, victim, actualdamage, offsetz, offsetforward, offsetside); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LineAttack, ZS_LineAttack) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(angle); + PARAM_FLOAT(distance); + PARAM_FLOAT(pitch); + PARAM_INT(damage); + PARAM_INT(damageType); + PARAM_CLASS(puffType, AActor); + PARAM_INT(flags); + PARAM_OUTPOINTER(victim, FTranslatedLineTarget); + PARAM_FLOAT(offsetz); + PARAM_FLOAT(offsetforward); + PARAM_FLOAT(offsetside); + + int acdmg; + auto puff = ZS_LineAttack(self, angle, distance, pitch, damage, damageType, puffType, flags, victim, offsetz, offsetforward, offsetside, &acdmg); + if (numret > 0) ret[0].SetObject(puff); + if (numret > 1) ret[1].SetInt(acdmg), numret = 2; + return numret; +} + +static int LineTrace(AActor *self, double angle, double distance, double pitch, int flags, double offsetz, double offsetforward, double offsetside, FLineTraceData *data) +{ + return P_LineTrace(self,angle,distance,pitch,flags,offsetz,offsetforward,offsetside,data); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LineTrace, LineTrace) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(angle); + PARAM_FLOAT(distance); + PARAM_FLOAT(pitch); + PARAM_INT(flags); + PARAM_FLOAT(offsetz); + PARAM_FLOAT(offsetforward); + PARAM_FLOAT(offsetside); + PARAM_OUTPOINTER(data, FLineTraceData); + ACTION_RETURN_BOOL(P_LineTrace(self,angle,distance,pitch,flags,offsetz,offsetforward,offsetside,data)); +} + +static void TraceBleedAngle(AActor *self, int damage, double angle, double pitch) +{ + P_TraceBleed(damage, self, angle, pitch); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, TraceBleedAngle, TraceBleedAngle) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(damage); + PARAM_FLOAT(angle); + PARAM_FLOAT(pitch); + + P_TraceBleed(damage, self, angle, pitch); + return 0; +} + +static void TraceBleedTLT(FTranslatedLineTarget *self, int damage, AActor *missile) +{ + P_TraceBleed(damage, self, PARAM_NULLCHECK(missile, missile)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_FTranslatedLineTarget, TraceBleed, TraceBleedTLT) +{ + PARAM_SELF_STRUCT_PROLOGUE(FTranslatedLineTarget); + PARAM_INT(damage); + PARAM_OBJECT_NOT_NULL(missile, AActor); + + P_TraceBleed(damage, self, missile); + return 0; +} + +static void TraceBleedA(AActor *self, int damage, AActor *missile) +{ + if (missile) P_TraceBleed(damage, self, missile); + else P_TraceBleed(damage, self); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, TraceBleed, TraceBleedA) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(damage); + PARAM_OBJECT(missile, AActor); + TraceBleedA(self, damage, missile); + return 0; +} + +static void RailAttack(AActor *self, FRailParams *p) +{ + p->source = self; + P_RailAttack(p); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RailAttack, RailAttack) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(p, FRailParams); + RailAttack(self, p); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, UsePuzzleItem, P_UsePuzzleItem) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(puzznum); + ACTION_RETURN_BOOL(P_UsePuzzleItem(self, puzznum)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetRadiusDamage, P_GetRadiusDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(thing, AActor); + PARAM_INT(damage); + PARAM_INT(distance); + PARAM_INT(fulldmgdistance); + PARAM_BOOL(oldradiusdmg); + ACTION_RETURN_INT(P_GetRadiusDamage(self, thing, damage, distance, fulldmgdistance, oldradiusdmg)); +} + +static int RadiusAttack(AActor *self, AActor *bombsource, int bombdamage, int bombdistance, int damagetype, int flags, int fulldamagedistance) +{ + return P_RadiusAttack(self, bombsource, bombdamage, bombdistance, ENamedName(damagetype), flags, fulldamagedistance); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RadiusAttack, RadiusAttack) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(bombsource, AActor); + PARAM_INT(bombdamage); + PARAM_INT(bombdistance); + PARAM_INT(damagetype); + PARAM_INT(flags); + PARAM_INT(fulldamagedistance); + ACTION_RETURN_INT(RadiusAttack(self, bombsource, bombdamage, bombdistance, damagetype, flags, fulldamagedistance)); +} + +static int ZS_GetSpriteIndex(int sprt) +{ + return GetSpriteIndex(FName(ENamedName(sprt)).GetChars(), false); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpriteIndex, ZS_GetSpriteIndex) +{ + PARAM_PROLOGUE; + PARAM_INT(sprt); + ACTION_RETURN_INT(ZS_GetSpriteIndex(sprt)); +} + +static PClassActor *ZS_GetReplacement(PClassActor *c) +{ + return c->GetReplacement(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetReplacement, ZS_GetReplacement) +{ + PARAM_PROLOGUE; + PARAM_POINTER(c, PClassActor); + ACTION_RETURN_POINTER(c->GetReplacement()); +} + +static PClassActor *ZS_GetReplacee(PClassActor *c) +{ + return c->GetReplacee(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetReplacee, ZS_GetReplacee) +{ + PARAM_PROLOGUE; + PARAM_POINTER(c, PClassActor); + ACTION_RETURN_POINTER(c->GetReplacee()); +} + +static void DrawSplash(AActor *self, int count, double angle, int kind) +{ + P_DrawSplash(count, self->Pos(), angle, kind); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, DrawSplash, DrawSplash) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(count); + PARAM_FLOAT(angle); + PARAM_INT(kind); + P_DrawSplash(count, self->Pos(), angle, kind); + return 0; +} + +static void UnlinkFromWorld(AActor *self, FLinkContext *ctx) +{ + self->UnlinkFromWorld(ctx); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, UnlinkFromWorld, UnlinkFromWorld) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(ctx, FLinkContext); + self->UnlinkFromWorld(ctx); // fixme + return 0; +} + +static void LinkToWorld(AActor *self, FLinkContext *ctx) +{ + self->LinkToWorld(ctx); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LinkToWorld, LinkToWorld) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(ctx, FLinkContext); + self->LinkToWorld(ctx); + return 0; +} + +static void SetOrigin(AActor *self, double x, double y, double z, bool moving) +{ + self->SetOrigin(x, y, z, moving); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetOrigin, SetOrigin) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_BOOL(moving); + self->SetOrigin(x, y, z, moving); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RoughMonsterSearch, P_RoughMonsterSearch) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(distance); + PARAM_BOOL(onlyseekable); + PARAM_BOOL(frontonly); + ACTION_RETURN_OBJECT(P_RoughMonsterSearch(self, distance, onlyseekable, frontonly)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckSight, P_CheckSight) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(target, AActor); + PARAM_INT(flags); + ACTION_RETURN_BOOL(P_CheckSight(self, target, flags)); +} + +static void GiveSecret(AActor *self, bool printmessage, bool playsound) +{ + P_GiveSecret(self, printmessage, playsound, -1); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GiveSecret, GiveSecret) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(printmessage); + PARAM_BOOL(playsound); + P_GiveSecret(self, printmessage, playsound, -1); + return 0; +} + +static int ZS_GetMissileDamage(AActor *self, int mask, int add, int pick_pointer) +{ + self = COPY_AAPTR(self, pick_pointer); + return self ? self->GetMissileDamage(mask, add) : 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetMissileDamage, ZS_GetMissileDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(mask); + PARAM_INT(add); + PARAM_INT(pick_pointer); + ACTION_RETURN_INT(ZS_GetMissileDamage(self, mask, add, pick_pointer)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SoundAlert, P_NoiseAlert) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(target, AActor); + PARAM_BOOL(splash); + PARAM_FLOAT(maxdist); + P_NoiseAlert(self, target, splash, maxdist); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, HitFriend, P_HitFriend) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(P_HitFriend(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, MonsterMove, P_Move) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(P_Move(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, NewChaseDir, P_NewChaseDir) +{ + PARAM_SELF_PROLOGUE(AActor); + P_NewChaseDir(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RandomChaseDir, P_RandomChaseDir) +{ + PARAM_SELF_PROLOGUE(AActor); + P_RandomChaseDir(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsVisible, P_IsVisible) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(other, AActor); + PARAM_BOOL(allaround); + PARAM_POINTER(params, FLookExParams); + ACTION_RETURN_BOOL(P_IsVisible(self, other, allaround, params)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForMonsters, P_LookForMonsters) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(P_LookForMonsters(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForTID, P_LookForTID) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(allaround); + PARAM_POINTER(params, FLookExParams); + ACTION_RETURN_BOOL(P_LookForTID(self, allaround, params)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForEnemies, P_LookForEnemies) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(allaround); + PARAM_POINTER(params, FLookExParams); + ACTION_RETURN_BOOL(P_LookForEnemies(self, allaround, params)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForPlayers, P_LookForPlayers) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(allaround); + PARAM_POINTER(params, FLookExParams); + ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Wander, A_Wander) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(flags); + A_Wander(self, flags); + return 0; +} +//========================================================================== +// +// A_Chase and variations +// +//========================================================================== + +static void A_FastChase(AActor *self) +{ + A_DoChase(self, true, self->MeleeState, self->MissileState, true, true, false, 0); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_FastChase, A_FastChase) +{ + PARAM_SELF_PROLOGUE(AActor); + A_FastChase(self); + return 0; +} + +static void A_VileChase(AActor *self) +{ + if (!P_CheckForResurrection(self, true)) + { + A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_VileChase, A_VileChase) +{ + PARAM_SELF_PROLOGUE(AActor); + A_VileChase(self); + return 0; +} + +static void A_ExtChase(AActor *self, bool domelee, bool domissile, bool playactive, bool nightmarefast) +{ + // Now that A_Chase can handle state label parameters, this function has become rather useless... + A_DoChase(self, false, + domelee ? self->MeleeState : NULL, domissile ? self->MissileState : NULL, + playactive, nightmarefast, false, 0); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_ExtChase, A_ExtChase) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(domelee); + PARAM_BOOL(domissile); + PARAM_BOOL(playactive); + PARAM_BOOL(nightmarefast); + A_ExtChase(self, domelee, domissile, playactive, nightmarefast); + return 0; +} + +int CheckForResurrection(AActor *self) +{ + return P_CheckForResurrection(self, false); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_CheckForResurrection, CheckForResurrection) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(P_CheckForResurrection(self, false)); +} + +static void ZS_Face(AActor *self, AActor *faceto, double max_turn, double max_pitch, double ang_offset, double pitch_offset, int flags, double z_add) +{ + A_Face(self, faceto, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Face, ZS_Face) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(faceto, AActor) + PARAM_ANGLE(max_turn) + PARAM_ANGLE(max_pitch) + PARAM_ANGLE(ang_offset) + PARAM_ANGLE(pitch_offset) + PARAM_INT(flags) + PARAM_FLOAT(z_add) + + A_Face(self, faceto, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_add); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckBossDeath, CheckBossDeath) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(CheckBossDeath(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_BossDeath, A_BossDeath) +{ + PARAM_SELF_PROLOGUE(AActor); + A_BossDeath(self); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Substitute, DObject::StaticPointerSubstitution) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(replace, AActor); + DObject::StaticPointerSubstitution(self, replace); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpawnableType, P_GetSpawnableType) +{ + PARAM_PROLOGUE; + PARAM_INT(num); + ACTION_RETURN_POINTER(P_GetSpawnableType(num)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_NoBlocking, A_Unblock) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL(drop); + A_Unblock(self, drop); + return 0; +} + +//===================================================================================== +// +// Inventory exports +// +//===================================================================================== + +DEFINE_ACTION_FUNCTION_NATIVE(AInventory, PrintPickupMessage, PrintPickupMessage) +{ + PARAM_PROLOGUE; + PARAM_BOOL(localview); + PARAM_STRING(str); + PrintPickupMessage(localview, str); + return 0; +} + +//===================================================================================== +// +// Key exports +// +//===================================================================================== + +DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetKeyTypeCount, P_GetKeyTypeCount) +{ + PARAM_PROLOGUE; + ACTION_RETURN_INT(P_GetKeyTypeCount()); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetKeyType, P_GetKeyType) +{ + PARAM_PROLOGUE; + PARAM_INT(num); + ACTION_RETURN_POINTER(P_GetKeyType(num)); +} + + + +DEFINE_FIELD(AActor, snext) +DEFINE_FIELD(AActor, player) +DEFINE_FIELD_NAMED(AActor, __Pos, pos) +DEFINE_FIELD_NAMED(AActor, __Pos.X, x) +DEFINE_FIELD_NAMED(AActor, __Pos.Y, y) +DEFINE_FIELD_NAMED(AActor, __Pos.Z, z) +DEFINE_FIELD(AActor, Prev) +DEFINE_FIELD(AActor, SpriteAngle) +DEFINE_FIELD(AActor, SpriteRotation) +DEFINE_FIELD(AActor, VisibleStartAngle) +DEFINE_FIELD(AActor, VisibleStartPitch) +DEFINE_FIELD(AActor, VisibleEndAngle) +DEFINE_FIELD(AActor, VisibleEndPitch) +DEFINE_FIELD_NAMED(AActor, Angles.Yaw, angle) +DEFINE_FIELD_NAMED(AActor, Angles.Pitch, pitch) +DEFINE_FIELD_NAMED(AActor, Angles.Roll, roll) +DEFINE_FIELD(AActor, Vel) +DEFINE_FIELD_NAMED(AActor, Vel.X, velx) +DEFINE_FIELD_NAMED(AActor, Vel.Y, vely) +DEFINE_FIELD_NAMED(AActor, Vel.Z, velz) +DEFINE_FIELD_NAMED(AActor, Vel.X, momx) +DEFINE_FIELD_NAMED(AActor, Vel.Y, momy) +DEFINE_FIELD_NAMED(AActor, Vel.Z, momz) +DEFINE_FIELD(AActor, Speed) +DEFINE_FIELD(AActor, FloatSpeed) +DEFINE_FIELD(AActor, sprite) +DEFINE_FIELD(AActor, frame) +DEFINE_FIELD(AActor, Scale) +DEFINE_FIELD_NAMED(AActor, Scale.X, scalex) +DEFINE_FIELD_NAMED(AActor, Scale.Y, scaley) +DEFINE_FIELD(AActor, RenderStyle) +DEFINE_FIELD(AActor, picnum) +DEFINE_FIELD(AActor, Alpha) +DEFINE_FIELD(AActor, fillcolor) +DEFINE_FIELD_NAMED(AActor, Sector, CurSector) // clashes with type 'sector'. +DEFINE_FIELD(AActor, subsector) +DEFINE_FIELD(AActor, ceilingz) +DEFINE_FIELD(AActor, floorz) +DEFINE_FIELD(AActor, dropoffz) +DEFINE_FIELD(AActor, floorsector) +DEFINE_FIELD(AActor, floorpic) +DEFINE_FIELD(AActor, floorterrain) +DEFINE_FIELD(AActor, ceilingsector) +DEFINE_FIELD(AActor, ceilingpic) +DEFINE_FIELD(AActor, Height) +DEFINE_FIELD(AActor, radius) +DEFINE_FIELD(AActor, renderradius) +DEFINE_FIELD(AActor, projectilepassheight) +DEFINE_FIELD(AActor, tics) +DEFINE_FIELD_NAMED(AActor, state, curstate) // clashes with type 'state'. +DEFINE_FIELD_NAMED(AActor, DamageVal, Damage) // name differs for historic reasons +DEFINE_FIELD(AActor, projectileKickback) +DEFINE_FIELD(AActor, VisibleToTeam) +DEFINE_FIELD(AActor, special1) +DEFINE_FIELD(AActor, special2) +DEFINE_FIELD(AActor, specialf1) +DEFINE_FIELD(AActor, specialf2) +DEFINE_FIELD(AActor, weaponspecial) +DEFINE_FIELD(AActor, health) +DEFINE_FIELD(AActor, movedir) +DEFINE_FIELD(AActor, visdir) +DEFINE_FIELD(AActor, movecount) +DEFINE_FIELD(AActor, strafecount) +DEFINE_FIELD(AActor, target) +DEFINE_FIELD(AActor, master) +DEFINE_FIELD(AActor, tracer) +DEFINE_FIELD(AActor, LastHeard) +DEFINE_FIELD(AActor, lastenemy) +DEFINE_FIELD(AActor, LastLookActor) +DEFINE_FIELD(AActor, reactiontime) +DEFINE_FIELD(AActor, threshold) +DEFINE_FIELD(AActor, DefThreshold) +DEFINE_FIELD(AActor, SpawnPoint) +DEFINE_FIELD(AActor, SpawnAngle) +DEFINE_FIELD(AActor, StartHealth) +DEFINE_FIELD(AActor, WeaveIndexXY) +DEFINE_FIELD(AActor, WeaveIndexZ) +DEFINE_FIELD(AActor, skillrespawncount) +DEFINE_FIELD(AActor, args) +DEFINE_FIELD(AActor, Mass) +DEFINE_FIELD(AActor, special) +DEFINE_FIELD(AActor, tid) +DEFINE_FIELD(AActor, TIDtoHate) +DEFINE_FIELD(AActor, waterlevel) +DEFINE_FIELD(AActor, Score) +DEFINE_FIELD(AActor, accuracy) +DEFINE_FIELD(AActor, stamina) +DEFINE_FIELD(AActor, meleerange) +DEFINE_FIELD(AActor, PainThreshold) +DEFINE_FIELD(AActor, Gravity) +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) +DEFINE_FIELD(AActor, Species) +DEFINE_FIELD(AActor, alternative) +DEFINE_FIELD(AActor, goal) +DEFINE_FIELD(AActor, MinMissileChance) +DEFINE_FIELD(AActor, LastLookPlayerNumber) +DEFINE_FIELD(AActor, SpawnFlags) +DEFINE_FIELD(AActor, meleethreshold) +DEFINE_FIELD(AActor, maxtargetrange) +DEFINE_FIELD(AActor, bouncefactor) +DEFINE_FIELD(AActor, wallbouncefactor) +DEFINE_FIELD(AActor, bouncecount) +DEFINE_FIELD(AActor, Friction) +DEFINE_FIELD(AActor, FastChaseStrafeCount) +DEFINE_FIELD(AActor, pushfactor) +DEFINE_FIELD(AActor, lastpush) +DEFINE_FIELD(AActor, activationtype) +DEFINE_FIELD(AActor, lastbump) +DEFINE_FIELD(AActor, DesignatedTeam) +DEFINE_FIELD(AActor, BlockingMobj) +DEFINE_FIELD(AActor, BlockingLine) +DEFINE_FIELD(AActor, Blocking3DFloor) +DEFINE_FIELD(AActor, BlockingCeiling) +DEFINE_FIELD(AActor, BlockingFloor) +DEFINE_FIELD(AActor, PoisonDamage) +DEFINE_FIELD(AActor, PoisonDamageType) +DEFINE_FIELD(AActor, PoisonDuration) +DEFINE_FIELD(AActor, PoisonPeriod) +DEFINE_FIELD(AActor, PoisonDamageReceived) +DEFINE_FIELD(AActor, PoisonDamageTypeReceived) +DEFINE_FIELD(AActor, PoisonDurationReceived) +DEFINE_FIELD(AActor, PoisonPeriodReceived) +DEFINE_FIELD(AActor, Poisoner) +DEFINE_FIELD_NAMED(AActor, Inventory, Inv) // clashes with type 'Inventory'. +DEFINE_FIELD(AActor, smokecounter) +DEFINE_FIELD(AActor, FriendPlayer) +DEFINE_FIELD(AActor, Translation) +DEFINE_FIELD(AActor, AttackSound) +DEFINE_FIELD(AActor, DeathSound) +DEFINE_FIELD(AActor, SeeSound) +DEFINE_FIELD(AActor, PainSound) +DEFINE_FIELD(AActor, ActiveSound) +DEFINE_FIELD(AActor, UseSound) +DEFINE_FIELD(AActor, BounceSound) +DEFINE_FIELD(AActor, WallBounceSound) +DEFINE_FIELD(AActor, CrushPainSound) +DEFINE_FIELD(AActor, MaxDropOffHeight) +DEFINE_FIELD(AActor, MaxStepHeight) +DEFINE_FIELD(AActor, PainChance) +DEFINE_FIELD(AActor, PainType) +DEFINE_FIELD(AActor, DeathType) +DEFINE_FIELD(AActor, DamageFactor) +DEFINE_FIELD(AActor, DamageMultiply) +DEFINE_FIELD(AActor, TeleFogSourceType) +DEFINE_FIELD(AActor, TeleFogDestType) +DEFINE_FIELD(AActor, SpawnState) +DEFINE_FIELD(AActor, SeeState) +DEFINE_FIELD(AActor, MeleeState) +DEFINE_FIELD(AActor, MissileState) +DEFINE_FIELD(AActor, ConversationRoot) +DEFINE_FIELD(AActor, Conversation) +DEFINE_FIELD(AActor, DecalGenerator) +DEFINE_FIELD(AActor, fountaincolor) +DEFINE_FIELD(AActor, CameraHeight) +DEFINE_FIELD(AActor, CameraFOV) +DEFINE_FIELD(AActor, RadiusDamageFactor) +DEFINE_FIELD(AActor, SelfDamageFactor) +DEFINE_FIELD(AActor, StealthAlpha) +DEFINE_FIELD(AActor, WoundHealth) +DEFINE_FIELD(AActor, BloodColor) +DEFINE_FIELD(AActor, BloodTranslation) +DEFINE_FIELD(AActor, RenderHidden) +DEFINE_FIELD(AActor, RenderRequired) +DEFINE_FIELD(AActor, friendlyseeblocks) +DEFINE_FIELD(AActor, SpawnTime) +DEFINE_FIELD(AActor, InventoryID) + +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos); +DEFINE_FIELD_NAMED_X(FCheckPosition, FCheckPosition, sector, cursector); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorz); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingz); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, dropoffz); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorpic); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorterrain); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floorsector); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingpic); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingsector); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, touchmidtex); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, abovemidtex); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, floatok); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, FromPMove); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, ceilingline); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, stepthing); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, DoRipping); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, portalstep); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, portalgroup); +DEFINE_FIELD_X(FCheckPosition, FCheckPosition, PushTime); + +DEFINE_FIELD_X(FRailParams, FRailParams, source); +DEFINE_FIELD_X(FRailParams, FRailParams, damage); +DEFINE_FIELD_X(FRailParams, FRailParams, offset_xy); +DEFINE_FIELD_X(FRailParams, FRailParams, offset_z); +DEFINE_FIELD_X(FRailParams, FRailParams, color1); +DEFINE_FIELD_X(FRailParams, FRailParams, color2); +DEFINE_FIELD_X(FRailParams, FRailParams, maxdiff); +DEFINE_FIELD_X(FRailParams, FRailParams, flags); +DEFINE_FIELD_X(FRailParams, FRailParams, puff); +DEFINE_FIELD_X(FRailParams, FRailParams, angleoffset); +DEFINE_FIELD_X(FRailParams, FRailParams, pitchoffset); +DEFINE_FIELD_X(FRailParams, FRailParams, distance); +DEFINE_FIELD_X(FRailParams, FRailParams, duration); +DEFINE_FIELD_X(FRailParams, FRailParams, sparsity); +DEFINE_FIELD_X(FRailParams, FRailParams, drift); +DEFINE_FIELD_X(FRailParams, FRailParams, spawnclass); +DEFINE_FIELD_X(FRailParams, FRailParams, SpiralOffset); +DEFINE_FIELD_X(FRailParams, FRailParams, limit); + +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitActor); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitLine); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitSector); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, Hit3DFloor); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitTexture); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitLocation); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, Distance); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, NumPortals); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, LineSide); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, LinePart); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, SectorPlane); +DEFINE_FIELD_X(FLineTraceData, FLineTraceData, HitType); + + diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index db8030bba..ead98b35e 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -624,21 +624,13 @@ void I_UpdateMusic() // //========================================================================== -void I_SetMusicVolume (float factor) +void I_SetMusicVolume (double factor) { - factor = clamp(factor, 0, 2.0f); - relative_volume = saved_relative_volume * factor; + factor = clamp(factor, 0., 2.0); + relative_volume = saved_relative_volume * float(factor); snd_musicvolume.Callback(); } -DEFINE_ACTION_FUNCTION(DObject, SetMusicVolume) -{ - PARAM_PROLOGUE; - PARAM_FLOAT(vol); - I_SetMusicVolume((float)vol); - return 0; -} - //========================================================================== // // test a relative music volume diff --git a/src/sound/i_music.h b/src/sound/i_music.h index 7976c1d48..be910bf9b 100644 --- a/src/sound/i_music.h +++ b/src/sound/i_music.h @@ -50,7 +50,7 @@ void I_BuildMIDIMenuList (FOptionValues *); void I_UpdateMusic (); // Volume. -void I_SetMusicVolume (float volume); +void I_SetMusicVolume (double volume); // Registers a song handle to song data. class MusInfo; diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 00671c802..eed1118f4 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -663,7 +663,6 @@ class Actor : Thinker native native void SetIdle(bool nofunction = false); native bool CheckMeleeRange(); - native bool CheckMeleeRange2(); native virtual int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags = 0, double angle = 0); native void PoisonMobj (Actor inflictor, Actor source, int damage, int duration, int period, Name type); native double AimLineAttack(double angle, double distance, out FTranslatedLineTarget pLineTarget = null, double vrange = 0., int flags = 0, Actor target = null, Actor friender = null); @@ -737,23 +736,50 @@ class Actor : Thinker native native void GiveSecret(bool printmsg = true, bool playsound = true); native clearscope double GetCameraHeight() const; native clearscope double GetGravity() const; - native clearscope int GetLevelSpawnTime() const; - native clearscope int GetAge() const; - native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); + //========================================================================== + // + // AActor :: GetLevelSpawnTime + // + // Returns the time when this actor was spawned, + // relative to the current level. + // + //========================================================================== + clearscope int GetLevelSpawnTime() const + { + return SpawnTime - level.totaltime + level.time; + } + + //========================================================================== + // + // AActor :: GetAge + // + // Returns the number of ticks passed since this actor was spawned. + // + //========================================================================== + + clearscope int GetAge() const + { + return level.totaltime - SpawnTime; + } + + double AccuracyFactor() + { + return 1. / (1 << (accuracy * 5 / 100)); + } + + + protected native void DestroyAllInventory(); // This is not supposed to be called by user code! native clearscope Inventory FindInventory(class itemtype, bool subclass = false) const; native Inventory GiveInventoryType(class itemtype); native void ObtainInventory(Actor other); native bool UsePuzzleItem(int PuzzleItemType); - native float AccuracyFactor(); - + action native void SetCamera(Actor cam, bool revert = false); native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0); // DECORATE compatible functions - native double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const; - native double GetAngle(int flags, int ptr = AAPTR_TARGET) const; native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT); native clearscope int GetSpawnHealth() const; native double GetCrouchFactor(int ptr = AAPTR_PLAYER1); @@ -761,8 +787,6 @@ class Actor : Thinker native native double GetCVarString(string cvar); native int GetPlayerInput(int inputnum, int ptr = AAPTR_DEFAULT); native int CountProximity(class classname, double distance, int flags = 0, int ptr = AAPTR_DEFAULT); - native double GetSpriteAngle(int ptr = AAPTR_DEFAULT); - native double GetSpriteRotation(int ptr = AAPTR_DEFAULT); native int GetMissileDamage(int mask, int add, int ptr = AAPTR_DEFAULT); action native int OverlayID(); action native double OverlayX(int layer = 0); @@ -1002,7 +1026,6 @@ class Actor : Thinker native native void A_FastChase(); native void A_PlayerScream(); native void A_SkullPop(class skulltype = "BloodySkull"); - native void A_CheckPlayerDone(); native void A_CheckTerrain(); native void A_Wander(int flags = 0); @@ -1184,6 +1207,19 @@ class Actor : Thinker native } } + //---------------------------------------------------------------------------- + // + // PROC A_CheckSkullDone + // + //---------------------------------------------------------------------------- + + void A_CheckPlayerDone() + { + if (player == NULL) Destroy(); + } + + + States(Actor, Overlay, Weapon, Item) { Spawn: diff --git a/wadsrc/static/zscript/compatibility.txt b/wadsrc/static/zscript/compatibility.txt index 43280bdcc..90ba082b9 100644 --- a/wadsrc/static/zscript/compatibility.txt +++ b/wadsrc/static/zscript/compatibility.txt @@ -18,6 +18,116 @@ extend class Object extend class Actor { + //========================================================================== + // + // CheckClass + // + // NON-ACTION function to check a pointer's class. + // deprecated because functionality is directly accessible. + // + //========================================================================== + + deprecated("3.7") bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false) + { + let check = GetPointer(ptr_select); + if (check == null || checkclass == null) + { + return false; + } + else if (match_superclass) + { + return check is checkclass; + } + else + { + return check.GetClass() == checkclass; + } + } + + //========================================================================== + // + // GetDistance + // + // NON-ACTION function to get the distance in double. + // deprecated because it requires AAPTR to work. + // + //========================================================================== + deprecated("3.7") double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const + { + let target = GetPointer(ptr); + + if (!target || target == self) + { + return 0; + } + else + { + let diff = Vec3To(target); + if (checkz) + diff.Z += (target.Height - self.Height) / 2; + else + diff.Z = 0.; + + return diff.Length(); + } + } + + //========================================================================== + // + // GetAngle + // + // NON-ACTION function to get the angle in degrees (normalized to -180..180) + // deprecated because it requires AAPTR to work. + // + //========================================================================== + + deprecated("3.7") double GetAngle(int flags, int ptr = AAPTR_TARGET) + { + let target = GetPointer(ptr); + + if (!target || target == self) + { + return 0; + } + else + { + let angto = (flags & GAF_SWITCH) ? target.AngleTo(self) : self.AngleTo(target); + let yaw = (flags & GAF_SWITCH) ? target.Angle : self.Angle; + if (flags & GAF_RELATIVE) angto = deltaangle(yaw, angto); + return angto; + } + } + + //========================================================================== + // + // GetSpriteAngle + // + // NON-ACTION function returns the sprite angle of a pointer. + // deprecated because direct access to the data is now possible. + // + //========================================================================== + + deprecated("3.7") double GetSpriteAngle(int ptr = AAPTR_DEFAULT) + { + let target = GetPointer(ptr); + return target? target.SpriteAngle : 0; + } + + //========================================================================== + // + // GetSpriteRotation + // + // NON-ACTION function returns the sprite rotation of a pointer. + // deprecated because direct access to the data is now possible. + // + //========================================================================== + + deprecated("3.7") double GetSpriteRotation(int ptr = AAPTR_DEFAULT) + { + let target = GetPointer(ptr); + return target? target.SpriteRotation : 0; + } + deprecated("2.3") void A_CustomMissile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET) { A_SpawnProjectile(missiletype, spawnheight, spawnofs_xy, angle, flags|CMF_BADPITCH, pitch, ptr); diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 9d6826381..7688dbd0e 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -290,6 +290,50 @@ class Serpent : Actor } } +extend class Actor +{ + //---------------------------------------------------------------------------- + // + // FUNC P_CheckMeleeRange2 + // + // This belongs to the Serpent but was initially exported on Actor + // so it needs to remain there. + // + //---------------------------------------------------------------------------- + + bool CheckMeleeRange2 () + { + Actor mo; + double dist; + + + if (!target || (CurSector.Flags & Sector.SECF_NOATTACK)) + { + return false; + } + mo = target; + dist = mo.Distance2D (self); + if (dist >= 128 || dist < meleerange + mo.radius) + { + return false; + } + if (mo.pos.Z > pos.Z + height) + { // Target is higher than the attacker + return false; + } + else if (pos.Z > mo.pos.Z + mo.height) + { // Attacker is higher + return false; + } + else if (IsFriend(mo)) + { + // killough 7/18/98: friendly monsters don't attack other friends + return false; + } + return CheckSight(mo); + } +} + // Serpent Leader ----------------------------------------------------------- class SerpentLeader : Serpent diff --git a/wadsrc/static/zscript/inventory/weapons.txt b/wadsrc/static/zscript/inventory/weapons.txt index dc4c412a5..1c2d1d2e9 100644 --- a/wadsrc/static/zscript/inventory/weapons.txt +++ b/wadsrc/static/zscript/inventory/weapons.txt @@ -34,7 +34,7 @@ class Weapon : StateProvider readonly bool bDehAmmo; // Uses Doom's original amount of ammo for the respective attack functions so that old DEHACKED patches work as intended. // AmmoUse1 will be set to the first attack's ammo use so that checking for empty weapons still works meta int SlotNumber; - meta int SlotPriority; + meta double SlotPriority; property AmmoGive: AmmoGive1; property AmmoGive1: AmmoGive1; @@ -121,7 +121,7 @@ class Weapon : StateProvider { if (GetReplacement(GetClass()) == GetClass() && !bPowered_Up) { - return SlotNumber, SlotPriority*65536; + return SlotNumber, int(SlotPriority*65536); } return -1, 0; } diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index cf2458c10..601031f22 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -334,6 +334,7 @@ struct Sector native play SECF_ENDGODMODE = 256, // getting damaged by this sector ends god mode SECF_ENDLEVEL = 512, // ends level when health goes below 10 SECF_HAZARD = 1024, // Change to Strife's delayed damage handling. + SECF_NOATTACK = 2048, // monsters cannot start attacks in this sector. SECF_WASSECRET = 1 << 30, // a secret that was discovered SECF_SECRET = 1 << 31, // a secret sector