From 6c9d0b166aaaee43ff1e3c4334d9305a2fb104f4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 5 Dec 2018 17:34:11 +0100 Subject: [PATCH] Added direct native entry points to a larger number of functions. --- src/actor.h | 11 - src/actorinlines.h | 16 + src/info.cpp | 21 - src/p_acs.cpp | 2 +- src/p_actionfunctions.cpp | 27 +- src/p_linetracedata.h | 4 + src/p_local.h | 7 +- src/p_map.cpp | 343 +-------- src/p_maputl.cpp | 37 - src/p_mobj.cpp | 190 ----- src/p_sight.cpp | 8 - src/p_spec.cpp | 10 - src/s_sound.cpp | 3 +- src/s_sound.h | 2 +- src/scripting/vm/vm.h | 3 + src/scripting/vmthunks_actors.cpp | 1151 ++++++++++++++++++++++++++--- wadsrc/static/zscript/actor.txt | 9 +- 17 files changed, 1118 insertions(+), 726 deletions(-) diff --git a/src/actor.h b/src/actor.h index 260bde8da..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) @@ -1288,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 9da6b6d3d..7eb3bbd30 100644 --- a/src/actorinlines.h +++ b/src/actorinlines.h @@ -63,3 +63,19 @@ inline double AActor::GetBobOffset(double ticfrac) const 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/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/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..0669ab3d4 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -904,31 +904,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 +4906,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_linetracedata.h b/src/p_linetracedata.h index b05b694d5..eab6e63d5 100644 --- a/src/p_linetracedata.h +++ b/src/p_linetracedata.h @@ -23,4 +23,8 @@ struct FLineTraceData ETraceResult HitType; }; +bool 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_local.h b/src/p_local.h index 8e4c415a2..203f30c5c 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); @@ -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 f677c85c9..5fb107942 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) { @@ -4503,19 +4328,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 @@ -4910,29 +4722,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 @@ -5063,33 +4852,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 @@ -5226,17 +4988,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; -} - //========================================================================== // @@ -5284,16 +5035,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; -} - //========================================================================== // @@ -5311,18 +5052,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 @@ -5597,15 +5326,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 @@ -5957,13 +5677,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 @@ -5993,7 +5706,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. @@ -6070,7 +5783,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; @@ -6114,22 +5827,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); @@ -6139,10 +5846,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; } //========================================================================== @@ -6206,7 +5913,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)) @@ -6264,7 +5971,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. @@ -6281,18 +5988,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 e520fdaec..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 @@ -1887,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 d8c24b5fa..740bcb18a 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) //========================================================================== // @@ -7319,23 +7146,6 @@ int AActor::GetGibHealth() const return -SpawnHealth(); } -double AActor::GetCameraHeight() const -{ - return CameraHeight == INT_MIN ? Height / 2 : CameraHeight; -} - - -FDropItem *AActor::GetDropItems() const -{ - return GetInfo()->DropItems; -} - -double AActor::GetGravity() const -{ - if (flags & MF_NOGRAVITY) return 0; - return level.gravity * Sector->gravity * Gravity * 0.00125; -} - // killough 11/98: // Whether an object is "sentient" or not. Used for environmental influences. diff --git a/src/p_sight.cpp b/src/p_sight.cpp index cb6dbb011..9de3f9d61 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -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/s_sound.cpp b/src/s_sound.cpp index c10c9578c..24440835d 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) +bool 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; diff --git a/src/s_sound.h b/src/s_sound.h index 7e2e40845..6dd06dd75 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); +bool 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/vm/vm.h b/src/scripting/vm/vm.h index 202fba2d1..e52d5c188 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -592,6 +592,9 @@ struct DirectNativeDesc 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)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11)) : 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); VP(11); } + template DirectNativeDesc(Ret(*func)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12)) : 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); 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)) { ValidateType(); 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 diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 05bcff74e..b747e587e 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -47,11 +47,55 @@ #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" 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) { @@ -75,6 +119,30 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetPointer, COPY_AAPTR) } +//========================================================================== +// +// 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); @@ -97,7 +165,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckKeys, P_CheckKeys) ACTION_RETURN_BOOL(P_CheckKeys(self, locknum, remote, quiet)); } -DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global? +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); @@ -105,7 +178,12 @@ DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global? ACTION_RETURN_FLOAT(deltaangle(DAngle(a1), DAngle(a2)).Degrees); } -DEFINE_ACTION_FUNCTION(AActor, absangle) // should this be global? +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); @@ -113,35 +191,60 @@ DEFINE_ACTION_FUNCTION(AActor, absangle) // should this be global? ACTION_RETURN_FLOAT(absangle(DAngle(a1), DAngle(a2)).Degrees); } -DEFINE_ACTION_FUNCTION(AActor, Distance2DSquared) +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)); } -DEFINE_ACTION_FUNCTION(AActor, Distance3DSquared) +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)); } -DEFINE_ACTION_FUNCTION(AActor, Distance2D) +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)); } -DEFINE_ACTION_FUNCTION(AActor, Distance3D) +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)); } -DEFINE_ACTION_FUNCTION(AActor, AddZ) +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); @@ -150,7 +253,12 @@ DEFINE_ACTION_FUNCTION(AActor, AddZ) return 0; } -DEFINE_ACTION_FUNCTION(AActor, SetZ) +static void SetZ(AActor *self, double z) +{ + self->SetZ(z); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetZ, SetZ) { PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(z); @@ -158,7 +266,12 @@ DEFINE_ACTION_FUNCTION(AActor, SetZ) return 0; } -DEFINE_ACTION_FUNCTION(AActor, SetDamage) +static void SetDamage(AActor *self, double dmg) +{ + self->SetDamage(dmg); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetDamage, SetDamage) { PARAM_SELF_PROLOGUE(AActor); PARAM_INT(dmg); @@ -167,12 +280,8 @@ DEFINE_ACTION_FUNCTION(AActor, SetDamage) } // This combines all 3 variations of the internal function -DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) +static void VelFromAngle(AActor *self, double speed, double angle) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(speed); - PARAM_ANGLE(angle); - if (speed == 1e37) { self->VelFromAngle(); @@ -180,7 +289,7 @@ DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) else { if (angle == 1e37) - + { self->VelFromAngle(speed); } @@ -189,11 +298,24 @@ DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) 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(AActor, Vel3DFromAngle) +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vel3DFromAngle, Vel3DFromAngle) { PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(speed); @@ -204,12 +326,8 @@ DEFINE_ACTION_FUNCTION(AActor, Vel3DFromAngle) } // This combines all 3 variations of the internal function -DEFINE_ACTION_FUNCTION(AActor, Thrust) +static void Thrust(AActor *self, double speed, double angle) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT(speed); - PARAM_ANGLE(angle); - if (speed == 1e37) { self->Thrust(); @@ -225,10 +343,23 @@ DEFINE_ACTION_FUNCTION(AActor, Thrust) 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; } -DEFINE_ACTION_FUNCTION(AActor, AngleTo) +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); @@ -236,7 +367,12 @@ DEFINE_ACTION_FUNCTION(AActor, AngleTo) ACTION_RETURN_FLOAT(self->AngleTo(targ, absolute).Degrees); } -DEFINE_ACTION_FUNCTION(AActor, AngleToVector) +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); @@ -244,7 +380,12 @@ DEFINE_ACTION_FUNCTION(AActor, AngleToVector) ACTION_RETURN_VEC2(angle.ToVector(length)); } -DEFINE_ACTION_FUNCTION(AActor, RotateVector) +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); @@ -253,14 +394,24 @@ DEFINE_ACTION_FUNCTION(AActor, RotateVector) ACTION_RETURN_VEC2(DVector2(x, y).Rotated(angle)); } -DEFINE_ACTION_FUNCTION(AActor, Normalize180) +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); } -DEFINE_ACTION_FUNCTION(AActor, DistanceBySpeed) +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); @@ -268,7 +419,12 @@ DEFINE_ACTION_FUNCTION(AActor, DistanceBySpeed) ACTION_RETURN_FLOAT(self->DistanceBySpeed(targ, speed)); } -DEFINE_ACTION_FUNCTION(AActor, SetXYZ) +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); @@ -278,7 +434,12 @@ DEFINE_ACTION_FUNCTION(AActor, SetXYZ) return 0; } -DEFINE_ACTION_FUNCTION(AActor, Vec2Angle) +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); @@ -287,22 +448,36 @@ DEFINE_ACTION_FUNCTION(AActor, Vec2Angle) 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(AActor, Vec3To) +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec3To, Vec3To) { PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT_NOT_NULL(t, AActor) ACTION_RETURN_VEC3(self->Vec3To(t)); } -DEFINE_ACTION_FUNCTION(AActor, Vec2To) +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)); } -DEFINE_ACTION_FUNCTION(AActor, Vec3Angle) +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) @@ -312,7 +487,12 @@ DEFINE_ACTION_FUNCTION(AActor, Vec3Angle) ACTION_RETURN_VEC3(self->Vec3Angle(length, angle, z, absolute)); } -DEFINE_ACTION_FUNCTION(AActor, Vec2OffsetZ) +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); @@ -322,7 +502,12 @@ DEFINE_ACTION_FUNCTION(AActor, Vec2OffsetZ) ACTION_RETURN_VEC3(self->Vec2OffsetZ(x, y, z, absolute)); } -DEFINE_ACTION_FUNCTION(AActor, Vec2Offset) +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); @@ -331,7 +516,12 @@ DEFINE_ACTION_FUNCTION(AActor, Vec2Offset) ACTION_RETURN_VEC2(self->Vec2Offset(x, y, absolute)); } -DEFINE_ACTION_FUNCTION(AActor, Vec3Offset) +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); @@ -341,27 +531,48 @@ DEFINE_ACTION_FUNCTION(AActor, Vec3Offset) ACTION_RETURN_VEC3(self->Vec3Offset(x, y, z, absolute)); } -DEFINE_ACTION_FUNCTION(AActor, PosRelative) +static void PosRelative(AActor *self, sector_t *sec, DVector3 *result) +{ + *result = self->PosRelative(sec); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, PosRelative, PosRelative) { PARAM_SELF_PROLOGUE(AActor); PARAM_POINTER(sec, sector_t); ACTION_RETURN_VEC3(self->PosRelative(sec)); } -DEFINE_ACTION_FUNCTION(AActor, RestoreDamage) +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); - self->RestoreDamage(); + RestoreDamage(self); return 0; } -DEFINE_ACTION_FUNCTION(AActor, PlayerNumber) +static int PlayerNumber(AActor *self) { - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_INT(self->player ? int(self->player - players) : 0); + return self->player ? int(self->player - players) : 0; } -DEFINE_ACTION_FUNCTION(AActor, SetFriendPlayer) +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); @@ -369,72 +580,105 @@ DEFINE_ACTION_FUNCTION(AActor, SetFriendPlayer) return 0; } -DEFINE_ACTION_FUNCTION(AActor, ClearBounce) +void ClearBounce(AActor *self) +{ + self->BounceFlags = 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearBounce, ClearBounce) { PARAM_SELF_PROLOGUE(AActor); - self->BounceFlags = 0; + ClearBounce(self); return 0; } -DEFINE_ACTION_FUNCTION(AActor, AccuracyFactor) +static int CountsAsKill(AActor *self) { - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_FLOAT(self->AccuracyFactor()); + return self->CountsAsKill(); } -DEFINE_ACTION_FUNCTION(AActor, CountsAsKill) +DEFINE_ACTION_FUNCTION_NATIVE(AActor, CountsAsKill, CountsAsKill) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_BOOL(self->CountsAsKill()); } -DEFINE_ACTION_FUNCTION(AActor, IsZeroDamage) +static int IsZeroDamage(AActor *self) +{ + return self->IsZeroDamage(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsZeroDamage, IsZeroDamage) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_BOOL(self->IsZeroDamage()); } -DEFINE_ACTION_FUNCTION(AActor, ClearInterpolation) +static void ClearInterpolation(AActor *self) +{ + self->ClearInterpolation(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearInterpolation, ClearInterpolation) { PARAM_SELF_PROLOGUE(AActor); self->ClearInterpolation(); return 0; } -DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactors) +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); - - DmgFactors &df = itemcls->ActorInfo()->DamageFactors; - if (df.Size() != 0) - { - ACTION_RETURN_INT(df.Apply(damagetype, damage)); - } - else - { - ACTION_RETURN_INT(defdamage); - } + ACTION_RETURN_INT(ApplyDamageFactors(itemcls, damagetype.GetIndex(), damage, defdamage)); } -DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) +static void RestoreSpecialPosition(AActor *self) +{ + self->RestoreSpecialPosition(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_RestoreSpecialPosition, RestoreSpecialPosition) { PARAM_SELF_PROLOGUE(AActor); self->RestoreSpecialPosition(); return 0; } -DEFINE_ACTION_FUNCTION(AActor, GetBobOffset) +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)); } -DEFINE_ACTION_FUNCTION(AActor, SetIdle) +static void SetIdle(AActor *self, bool nofunction) +{ + self->SetIdle(nofunction); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetIdle, SetIdle) { PARAM_SELF_PROLOGUE(AActor); PARAM_BOOL(nofunction); @@ -442,63 +686,108 @@ DEFINE_ACTION_FUNCTION(AActor, SetIdle) return 0; } -DEFINE_ACTION_FUNCTION(AActor, SpawnHealth) +static int SpawnHealth(AActor *self) +{ + return self->SpawnHealth(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, SpawnHealth, SpawnHealth) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_INT(self->SpawnHealth()); } -DEFINE_ACTION_FUNCTION(AActor, Revive) +void Revive(AActor *self) +{ + self->Revive(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, Revive, Revive) { PARAM_SELF_PROLOGUE(AActor); self->Revive(); return 0; } -DEFINE_ACTION_FUNCTION(AActor, GetCameraHeight) +static double GetCameraHeight(AActor *self) +{ + return self->GetCameraHeight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetCameraHeight, GetCameraHeight) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_FLOAT(self->GetCameraHeight()); } -DEFINE_ACTION_FUNCTION(AActor, GetDropItems) +static FDropItem *GetDropItems(AActor *self) +{ + return self->GetDropItems(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetDropItems, GetDropItems) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_POINTER(self->GetDropItems()); } -DEFINE_ACTION_FUNCTION(AActor, GetGravity) +static double GetGravity(AActor *self) +{ + return self->GetGravity(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetGravity, GetGravity) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_FLOAT(self->GetGravity()); } - -DEFINE_ACTION_FUNCTION(AActor, GetTag) +static void GetTag(AActor *self, const FString &def, FString *result) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_STRING(def); - ACTION_RETURN_STRING(self->GetTag(def.Len() == 0 ? nullptr : def.GetChars())); + *result = self->GetTag(def.Len() == 0 ? nullptr : def.GetChars()); } - -DEFINE_ACTION_FUNCTION(AActor, SetTag) +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; } -DEFINE_ACTION_FUNCTION(AActor, ClearCounters) +static void ClearCounters(AActor *self) +{ + self->ClearCounters(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearCounters, ClearCounters) { PARAM_SELF_PROLOGUE(AActor); self->ClearCounters(); return 0; } -DEFINE_ACTION_FUNCTION(AActor, GetModifiedDamage) +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); @@ -506,7 +795,13 @@ DEFINE_ACTION_FUNCTION(AActor, GetModifiedDamage) PARAM_BOOL(passive); ACTION_RETURN_INT(self->GetModifiedDamage(type, damage, passive)); } -DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactor) + +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); @@ -516,47 +811,72 @@ DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactor) double GetDefaultSpeed(PClassActor *type); -DEFINE_ACTION_FUNCTION(AActor, GetDefaultSpeed) +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetDefaultSpeed, GetDefaultSpeed) { PARAM_PROLOGUE; PARAM_CLASS(type, AActor); ACTION_RETURN_FLOAT(GetDefaultSpeed(type)); } -DEFINE_ACTION_FUNCTION(AActor, isTeammate) +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)); } -DEFINE_ACTION_FUNCTION(AActor, GetSpecies) +static int GetSpecies(AActor *self) +{ + return self->GetSpecies(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpecies, GetSpecies) { PARAM_SELF_PROLOGUE(AActor); ACTION_RETURN_INT(self->GetSpecies()); } -DEFINE_ACTION_FUNCTION(AActor, isFriend) +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)); } -DEFINE_ACTION_FUNCTION(AActor, isHostile) +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)); } -DEFINE_ACTION_FUNCTION(AActor, GetFloorTerrain) +static FTerrainDef *GetFloorTerrain(AActor *self) { - PARAM_SELF_PROLOGUE(AActor); - ACTION_RETURN_POINTER(&Terrains[P_GetThingFloorType(self)]); + return &Terrains[P_GetThingFloorType(self)]; } -DEFINE_ACTION_FUNCTION(AActor, FindUniqueTid) +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); @@ -564,23 +884,441 @@ DEFINE_ACTION_FUNCTION(AActor, FindUniqueTid) ACTION_RETURN_INT(P_FindUniqueTID(start, limit)); } -DEFINE_ACTION_FUNCTION(AActor, RemoveFromHash) +static void RemoveFromHash(AActor *self) +{ + self->RemoveFromHash(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, RemoveFromHash, RemoveFromHash) { PARAM_SELF_PROLOGUE(AActor); self->RemoveFromHash(); return 0; } -DEFINE_ACTION_FUNCTION(AActor, ChangeTid) +static void ChangeTid(AActor *self, int tid) { - PARAM_SELF_PROLOGUE(AActor); - PARAM_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, LineAttac, 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 bool 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(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; +} + +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; +} @@ -618,3 +1356,234 @@ DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetKeyType, P_GetKeyType) 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/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index e6048080b..01df3f1b0 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -764,7 +764,11 @@ class Actor : Thinker native return level.totaltime - SpawnTime; } - + double AccuracyFactor() + { + return 1. / (1 << (accuracy * 5 / 100)); + } + native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); @@ -773,8 +777,7 @@ class Actor : Thinker native 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);