diff --git a/src/d_player.h b/src/d_player.h index d1678b619..95a288ebd 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -105,29 +105,36 @@ public: virtual void Serialize(FSerializer &arc); - virtual void PostBeginPlay(); - virtual void Tick(); - virtual void AddInventory (AInventory *item); - virtual void RemoveInventory (AInventory *item); - virtual bool UseInventory (AInventory *item); - virtual void MarkPrecacheSounds () const; + virtual void PostBeginPlay() override; + virtual void Tick() override; + virtual void AddInventory (AInventory *item) override; + virtual void RemoveInventory (AInventory *item) override; + virtual bool UseInventory (AInventory *item) override; + virtual void MarkPrecacheSounds () const override; + virtual void BeginPlay () override; + virtual void Die (AActor *source, AActor *inflictor, int dmgflags) override; + virtual bool UpdateWaterLevel (bool splash) override; - virtual void PlayIdle (); - virtual void PlayRunning (); - virtual void ThrowPoisonBag (); - virtual void TweakSpeeds (double &forwardmove, double &sidemove); + bool ResetAirSupply (bool playgasp = true); + int GetMaxHealth() const; + void TweakSpeeds (double &forwardmove, double &sidemove); void MorphPlayerThink (); - virtual void ActivateMorphWeapon (); + void ActivateMorphWeapon (); AWeapon *PickNewWeapon (PClassAmmo *ammotype); AWeapon *BestWeapon (PClassAmmo *ammotype); void CheckWeaponSwitch(PClassAmmo *ammotype); - virtual void GiveDeathmatchInventory (); - virtual void FilterCoopRespawnInventory (APlayerPawn *oldplayer); + void GiveDeathmatchInventory (); + void FilterCoopRespawnInventory (APlayerPawn *oldplayer); void SetupWeaponSlots (); void GiveDefaultInventory (); + + // These are virtual on the script side only. + void PlayIdle(); + void PlayRunning(); void PlayAttacking (); void PlayAttacking2 (); + const char *GetSoundClass () const; enum EInvulState @@ -138,8 +145,6 @@ public: INVUL_GetAlpha }; - void BeginPlay (); - void Die (AActor *source, AActor *inflictor, int dmgflags); int crouchsprite; int MaxHealth; @@ -171,10 +176,6 @@ public: // [SP] ViewBob Multiplier double ViewBob; - bool UpdateWaterLevel (bool splash); - bool ResetAirSupply (bool playgasp = true); - - int GetMaxHealth() const; }; class APlayerChunk : public APlayerPawn diff --git a/src/info.cpp b/src/info.cpp index 8a2842ff4..69605d454 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -151,6 +151,13 @@ 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)); +} + IMPLEMENT_CLASS(PClassActor, false, true) IMPLEMENT_POINTERS_START(PClassActor) diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index a38a17f9c..932b4c649 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -458,6 +458,22 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t return ceiling != NULL; } +DEFINE_ACTION_FUNCTION(DCeiling, CreateCeiling) +{ + PARAM_PROLOGUE; + PARAM_POINTER(sec, sector_t); + PARAM_INT(type); + PARAM_POINTER(ln, line_t); + PARAM_FLOAT(speed); + PARAM_FLOAT(speed2); + PARAM_FLOAT_DEF(height); + PARAM_INT_DEF(crush); + PARAM_INT_DEF(silent); + PARAM_INT_DEF(change); + PARAM_INT_DEF(crushmode); + ACTION_RETURN_BOOL(P_CreateCeiling(sec, (DCeiling::ECeiling)type, ln, 0, speed, speed2, height, crush, silent, change, (DCeiling::ECrushMode)crushmode)); +} + //============================================================================ // // EV_DoCeiling diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 64e4feb4a..5b2ba6d65 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1283,6 +1283,14 @@ 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 @@ -1335,6 +1343,15 @@ 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_DEF(params, FLookExParams); + ACTION_RETURN_BOOL(P_IsVisible(self, other, allaround, params)); +} + //--------------------------------------------------------------------------- // // FUNC P_LookForMonsters @@ -1388,6 +1405,12 @@ bool P_LookForMonsters (AActor *actor) return false; } +DEFINE_ACTION_FUNCTION(AActor, LookForMonsters) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(P_LookForMonsters(self)); +} + //============================================================================ // // LookForTIDinBlock @@ -1560,6 +1583,14 @@ 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_DEF(params, FLookExParams); + ACTION_RETURN_BOOL(P_LookForTID(self, allaround, params)); +} + //============================================================================ // // LookForEnemiesinBlock @@ -1699,6 +1730,15 @@ 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_DEF(params, FLookExParams); + ACTION_RETURN_BOOL(P_LookForEnemies(self, allaround, params)); +} + + /* ================ = @@ -1886,7 +1926,8 @@ DEFINE_ACTION_FUNCTION(AActor, LookForPlayers) { PARAM_SELF_PROLOGUE(AActor); PARAM_BOOL(allaround); - ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, nullptr)); + PARAM_POINTER_DEF(params, FLookExParams); + ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params)); } // diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index a5fcc2dda..e0e3e62b9 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1636,6 +1636,20 @@ void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage } +DEFINE_ACTION_FUNCTION(AActor, PoisonMobj) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(inflictor, AActor); + PARAM_OBJECT(source, AActor); + PARAM_INT(damage); + PARAM_INT(duration); + PARAM_INT(period); + PARAM_NAME(mod); + P_PoisonMobj(self, inflictor, source, damage, duration, period, mod); + return 0; +} + + bool AActor::OkayToSwitchTarget (AActor *other) { if (other == this) diff --git a/src/p_map.cpp b/src/p_map.cpp index c5780eedc..11036d171 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -297,6 +297,14 @@ void P_FindFloorCeiling(AActor *actor, int flags) } } +DEFINE_ACTION_FUNCTION(AActor, FindFloorCeiling) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT_DEF(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) { @@ -661,6 +669,21 @@ 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; +} //========================================================================== // @@ -1885,6 +1908,26 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) return onmobj == NULL; } +DEFINE_ACTION_FUNCTION(AActor, TestMobjZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL_DEF(quick); + + AActor *on = nullptr;; + bool retv = P_TestMobjZ(self, quick, &on); + if (numret > 1) + { + numret = 2; + ret[1].SetPointer(on, ATAG_OBJECT); + } + if (numret > 0) + { + ret[0].SetInt(retv); + } + return numret; +} + + //============================================================================= // // P_FakeZMovement diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9c0f587eb..d099a8e77 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -568,6 +568,13 @@ bool AActor::InStateSequence(FState * newstate, FState * basestate) return false; } +DEFINE_ACTION_FUNCTION(AActor, InStateSequence) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(newstate, FState); + PARAM_POINTER(basestate, FState); + ACTION_RETURN_BOOL(self->InStateSequence(newstate, basestate)); +} //========================================================================== // // AActor::GetTics @@ -736,6 +743,15 @@ void AActor::AddInventory (AInventory *item) Inventory->InventoryID = InventoryID++; } +DEFINE_ACTION_FUNCTION(AActor, AddInventory) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(item, AInventory); + self->AddInventory(item); + return 0; +} + + //============================================================================ // // AActor :: GiveInventory @@ -795,6 +811,14 @@ bool AActor::GiveInventory(PClassInventory *type, int amount, bool givecheat) return result; } +DEFINE_ACTION_FUNCTION(AActor, Inventory) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(item, AInventory); + ACTION_RETURN_BOOL(self->UseInventory(item)); +} + + //============================================================================ // // AActor :: RemoveInventory @@ -822,6 +846,15 @@ void AActor::RemoveInventory(AInventory *item) } } +DEFINE_ACTION_FUNCTION(AActor, RemoveInventory) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(item, AInventory); + self->RemoveInventory(item); + return 0; +} + + //============================================================================ // // AActor :: TakeInventory @@ -1186,6 +1219,14 @@ void AActor::ClearInventory() } } +DEFINE_ACTION_FUNCTION(AActor, ClearInventory) +{ + PARAM_SELF_PROLOGUE(AActor); + self->ClearInventory(); + return 0; +} + + //============================================================================ // // AActor :: CopyFriendliness @@ -3176,6 +3217,18 @@ DEFINE_ACTION_FUNCTION(AActor, 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 @@ -3258,6 +3311,17 @@ int P_FindUniqueTID(int start_tid, int limit) return 0; } +DEFINE_ACTION_FUNCTION(AActor, FindUniqueTid) +{ + PARAM_PROLOGUE; + PARAM_INT_DEF(start); + PARAM_INT_DEF(limit); + ACTION_RETURN_INT(P_FindUniqueTID(start, limit)); +} + + + + CCMD(utid) { Printf("%d\n", @@ -3537,6 +3601,14 @@ void AActor::SetShade (int r, int g, int b) fillcolor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b); } +DEFINE_ACTION_FUNCTION(AActor, SetShade) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(color); + self->SetShade(color); + return 0; +} + void AActor::SetPitch(DAngle p, bool interpolate, bool forceclamp) { if (player != NULL || forceclamp) @@ -5777,6 +5849,19 @@ void P_SpawnBlood (const DVector3 &pos1, DAngle dir, int damage, AActor *origina P_DrawSplash2 (40, pos, dir, 2, bloodcolor); } +DEFINE_ACTION_FUNCTION(AActor, SpawnBlood) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_ANGLE(dir); + PARAM_INT(damage); + P_SpawnBlood(DVector3(x, y, z), dir, damage, self); + return 0; +} + + //--------------------------------------------------------------------------- // // PROC P_BloodSplatter @@ -5859,6 +5944,20 @@ void P_BloodSplatter2 (const DVector3 &pos, AActor *originator, DAngle hitangle) } } +DEFINE_ACTION_FUNCTION(AActor, BloodSplatter) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_ANGLE(dir); + PARAM_BOOL_DEF(axe); + if (axe) P_BloodSplatter2(DVector3(x, y, z), self, dir); + else P_BloodSplatter(DVector3(x, y, z), self, dir); + return 0; +} + + //--------------------------------------------------------------------------- // // PROC P_RipperBlood @@ -6078,6 +6177,20 @@ foundone: return plane == &sec->floorplane ? Terrains[terrainnum].IsLiquid : false; } +DEFINE_ACTION_FUNCTION(AActor, HitWater) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(sec, sector_t); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_BOOL_DEF(checkabove); + PARAM_BOOL_DEF(alert); + PARAM_BOOL_DEF(force); + ACTION_RETURN_BOOL(P_HitWater(self, sec, DVector3(x, y, z), checkabove, alert, force)); +} + + //--------------------------------------------------------------------------- // // FUNC P_HitFloor @@ -6284,6 +6397,15 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner) } } +DEFINE_ACTION_FUNCTION(AActor, PlaySpawnSound) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(missile, AActor); + P_PlaySpawnSound(missile, self); + return 0; +} + + static double GetDefaultSpeed(PClassActor *type) { if (type == NULL) @@ -6911,6 +7033,14 @@ bool AActor::IsHostile (AActor *other) return true; } +DEFINE_ACTION_FUNCTION(AActor, isHostile) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(other, AActor); + ACTION_RETURN_BOOL(self->IsHostile(other)); +} + + //========================================================================== // // AActor :: DoSpecialDamage @@ -7179,6 +7309,13 @@ double AActor::GetCameraHeight() const return GetClass()->CameraHeight == INT_MIN ? Height / 2 : GetClass()->CameraHeight; } +DEFINE_ACTION_FUNCTION(AActor, GetCameraHeight) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_FLOAT(self->GetCameraHeight()); +} + + DDropItem *AActor::GetDropItems() const { return GetClass()->DropItems; @@ -7196,6 +7333,13 @@ double AActor::GetGravity() const 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. // (left precisely the same as MBF even though it doesn't make much sense.) @@ -7240,14 +7384,17 @@ DEFINE_ACTION_FUNCTION(AActor, GetTag) void AActor::SetTag(const char *def) { - if (def == NULL || *def == 0) - { - Tag = NULL; - } - else - { - Tag = mStringPropertyData.Alloc(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; } @@ -7392,6 +7539,13 @@ DEFINE_ACTION_FUNCTION(AActor, Distance2D) ACTION_RETURN_FLOAT(self->Distance2D(other)); } +DEFINE_ACTION_FUNCTION(AActor, Distance3D) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(other, AActor); + ACTION_RETURN_FLOAT(self->Distance3D(other)); +} + DEFINE_ACTION_FUNCTION(AActor, AddZ) { PARAM_SELF_PROLOGUE(AActor); @@ -7455,6 +7609,17 @@ DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) 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(pitch, angle, speed); + return 0; +} + // This combines all 3 variations of the internal function DEFINE_ACTION_FUNCTION(AActor, Thrust) { @@ -7619,6 +7784,12 @@ DEFINE_ACTION_FUNCTION(AActor, AccuracyFactor) ACTION_RETURN_FLOAT(self->AccuracyFactor()); } +DEFINE_ACTION_FUNCTION(AActor, CountsAsKill) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_FLOAT(self->CountsAsKill()); +} + //---------------------------------------------------------------------------- // // DropItem handling diff --git a/src/p_user.cpp b/src/p_user.cpp index 1ac60ba35..66437d430 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1285,6 +1285,13 @@ bool APlayerPawn::ResetAirSupply (bool playgasp) return wasdrowning; } +DEFINE_ACTION_FUNCTION(APlayerPawn, ResetAirSupply) +{ + PARAM_SELF_PROLOGUE(APlayerPawn); + PARAM_BOOL_DEF(playgasp); + ACTION_RETURN_BOOL(self->ResetAirSupply(playgasp)); +} + //=========================================================================== // // Animations @@ -1293,14 +1300,22 @@ bool APlayerPawn::ResetAirSupply (bool playgasp) void APlayerPawn::PlayIdle () { - if (InStateSequence(state, SeeState)) - SetState (SpawnState); + IFVIRTUAL(APlayerPawn, PlayIdle) + { + VMValue params[1] = { (DObject*)this }; + VMFrameStack stack; + stack.Call(func, params, 1, nullptr, 0, nullptr); + } } void APlayerPawn::PlayRunning () { - if (InStateSequence(state, SpawnState) && SeeState != NULL) - SetState (SeeState); + IFVIRTUAL(APlayerPawn, PlayRunning) + { + VMValue params[1] = { (DObject*)this }; + VMFrameStack stack; + stack.Call(func, params, 1, nullptr, 0, nullptr); + } } void APlayerPawn::PlayAttacking () @@ -1323,10 +1338,6 @@ void APlayerPawn::PlayAttacking2 () } } -void APlayerPawn::ThrowPoisonBag () -{ -} - //=========================================================================== // // APlayerPawn :: GiveDefaultInventory diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 81b94b0f2..fd15b9491 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -2607,6 +2607,17 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) return false; } +DEFINE_ACTION_FUNCTION(DObject, S_ChangeMusic) +{ + PARAM_PROLOGUE; + PARAM_STRING(music); + PARAM_INT_DEF(order); + PARAM_BOOL(looping); + PARAM_BOOL(force); + ACTION_RETURN_BOOL(S_ChangeMusic(music, order, looping, force)); +} + + //========================================================================== // // S_RestartMusic diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 15c643047..5eebb7350 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -33,7 +33,7 @@ class Actor : Thinker native native vector2 Scale; native TextureID picnum; native double Alpha; - native color fillcolor; + native readonly color fillcolor; // must be set with SetShade to initialize correctly. native Sector CurSector; native double CeilingZ; native double FloorZ; @@ -276,10 +276,16 @@ class Actor : Thinker native } + native static int GetSpriteIndex(name sprt); native static double GetDefaultSpeed(class type); native static class GetSpawnableType(int spawnnum); native void RemoveFromHash(); + native void ChangeTid(int newtid); + native static int FindUniqueTid(int start = 0, int limit = 0); + native void SetShade(color col); + native string GetTag(string defstr = ""); + native void SetTag(string defstr = ""); native double GetBobOffset(double frac = 0); native void ClearCounters(); native bool GiveBody (int num, int max=0); @@ -299,6 +305,7 @@ class Actor : Thinker native native int SpawnHealth(); native void SetDamage(int dmg); native double Distance2D(Actor other); + native double Distance3D(Actor other); native void SetOrigin(vector3 newpos, bool moving); native void SetXYZ(vector3 newpos); native Actor GetPointer(int aaptr); @@ -328,7 +335,12 @@ class Actor : Thinker native void A_LightInverse() { if (player) player.extralight = 0x80000000; } native Actor OldSpawnMissile(Actor dest, class type, Actor owner = null); - native Actor SpawnPuff(class pufftype, vector3 pos, double hitdir, double particledir, int updown, int flags = 0, Actor vict = null); + native Actor SpawnPuff(class pufftype, vector3 pos, double hitdir, double particledir, int updown, int flags = 0, Actor victim = null); + native void SpawnBlood (Vector3 pos1, double dir, int damage); + native void BloodSplatter (Vector3 pos, double hitangle, bool axe = false); + native bool HitWater (sector sec, Vector3 pos, bool checkabove = false, bool alert = true, bool force = false); + native void PlaySpawnSound(Actor missile); + native bool CountsAsKill(); native bool Teleport(Vector3 pos, double angle, int flags); native void TraceBleed(int damage, Actor missile); @@ -338,13 +350,32 @@ class Actor : Thinker native native bool CheckMeleeRange(); native bool CheckMeleeRange2(); native 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); native Actor, int LineAttack(double angle, double distance, double pitch, int damage, Name damageType, class pufftype, int flags = 0, out FTranslatedLineTarget victim = null); native bool CheckSight(Actor target, int flags = 0); + native bool IsVisible(Actor other, bool allaround, LookExParams params = null); native bool HitFriend(); native bool MonsterMove(); + + native void FindFloorCeiling(int flags = 0); + native double, double GetFriction(); + native bool, Actor TestMobjZ(bool quick = false); + native bool InStateSequence(State newstate, State basestate); + + bool TryWalk () + { + if (!MonsterMove ()) + { + return false; + } + movecount = random[TryWalk]() & 15; + return true; + } + native bool TryMove(vector2 newpos, int dropoff); native void NewChaseDir(); + native void RandomChaseDir(); native bool CheckMissileRange(); native bool SetState(state st, bool nofunction = false); native state FindState(statelabel st, bool exact = false); @@ -364,12 +395,17 @@ class Actor : Thinker native native vector2 Vec2Offset(double x, double y, bool absolute = false); native vector3 Vec2OffsetZ(double x, double y, double atz, bool absolute = false); native void VelFromAngle(double speed = 0, double angle = 0); + native void Vel3DFromAngle(double speed, double angle, double pitch); native void Thrust(double speed = 0, double angle = 0); native bool isFriend(Actor other); + native bool isHostile(Actor other); native void AdjustFloorClip(); native DropItem GetDropItems(); native void CopyFriendliness (Actor other, bool changeTarget, bool resetHealth = true); - native bool LookForPlayers(bool allaround); + native bool LookForMonsters(); + native bool LookForTid(bool allaround, LookExParams params = null); + native bool LookForEnemies(bool allaround, LookExParams params = null); + native bool LookForPlayers(bool allaround, LookExParams params = null); native bool TeleportMove(Vector3 pos, bool telefrag, bool modifyactor = true); native double DistanceBySpeed(Actor other, double speed); native name GetSpecies(); @@ -377,8 +413,13 @@ class Actor : Thinker native native void Howl(); native void DrawSplash (int count, double angle, int kind); native void GiveSecret(bool printmsg = true, bool playsound = true); + native void GetCameraHeight(); + native void GetGravity(); native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); + native void AddInventory(Inventory inv); + native void RemoveInventory(Inventory inv); + native void ClearInventory(); native Inventory FindInventory(class itemtype, bool subclass = false); native Inventory GiveInventoryType(class itemtype); native Inventory DropInventory (Inventory item); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index b1d9526ce..6db88ab0a 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -9,6 +9,7 @@ class Object native native static vector3, int G_PickPlayerStart(int pnum, int flags = 0); native static int GameType(); native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM); + native static bool S_ChangeMusic(String music_name, int order = 0, bool looping = true, bool force = false); native static void C_MidPrint(string fontname, string textlabel, bool bold = false); // always uses the stringtable. native static uint BAM(double angle); @@ -180,6 +181,40 @@ struct F3DFloor native struct Line native { + enum ELineFlags + { + ML_BLOCKING =0x00000001, // solid, is an obstacle + ML_BLOCKMONSTERS =0x00000002, // blocks monsters only + ML_TWOSIDED =0x00000004, // backside will not be present at all if not two sided + ML_DONTPEGTOP = 0x00000008, // upper texture unpegged + ML_DONTPEGBOTTOM = 0x00000010, // lower texture unpegged + ML_SECRET = 0x00000020, // don't map as two sided: IT'S A SECRET! + ML_SOUNDBLOCK = 0x00000040, // don't let sound cross two of these + ML_DONTDRAW = 0x00000080, // don't draw on the automap + ML_MAPPED = 0x00000100, // set if already drawn in automap + ML_REPEAT_SPECIAL = 0x00000200, // special is repeatable + ML_ADDTRANS = 0x00000400, // additive translucency (can only be set internally) + + // Extended flags + ML_MONSTERSCANACTIVATE = 0x00002000, // [RH] Monsters (as well as players) can activate the line + ML_BLOCK_PLAYERS = 0x00004000, + ML_BLOCKEVERYTHING = 0x00008000, // [RH] Line blocks everything + ML_ZONEBOUNDARY = 0x00010000, + ML_RAILING = 0x00020000, + ML_BLOCK_FLOATERS = 0x00040000, + ML_CLIP_MIDTEX = 0x00080000, // Automatic for every Strife line + ML_WRAP_MIDTEX = 0x00100000, + ML_3DMIDTEX = 0x00200000, + ML_CHECKSWITCHRANGE = 0x00400000, + ML_FIRSTSIDEONLY = 0x00800000, // activated only when crossed from front side + ML_BLOCKPROJECTILE = 0x01000000, + ML_BLOCKUSE = 0x02000000, // blocks all use actions through this line + ML_BLOCKSIGHT = 0x04000000, // blocks monster line of sight + ML_BLOCKHITSCAN = 0x08000000, // blocks hitscan attacks + ML_3DMIDTEX_IMPASS = 0x10000000, // [TP] if 3D midtex, behaves like a height-restricted ML_BLOCKING + }; + + //native readonly vertex v1, v2; // vertices, from v1 to v2 native readonly Vector2 delta; // precalculated v2 - v1 for side checking native uint flags; @@ -411,6 +446,59 @@ class Floor : Thinker native genFloorChg }; - native static bool CreateFloor(sector sec, EFloor floortype, line ln, double speed, double height = 0, int crush = -1, int change = 0, bool hexencrush = false, bool hereticlower = false); + native static bool CreateFloor(sector sec, EFloor floortype, line ln, double speed, double height = 0, int crush = -1, int change = 0, bool crushmode = false, bool hereticlower = false); +} + +class Ceiling : Thinker native +{ + enum ECeiling + { + ceilLowerByValue, + ceilRaiseByValue, + ceilMoveToValue, + ceilLowerToHighestFloor, + ceilLowerInstant, + ceilRaiseInstant, + ceilCrushAndRaise, + ceilLowerAndCrush, + ceil_placeholder, + ceilCrushRaiseAndStay, + ceilRaiseToNearest, + ceilLowerToLowest, + ceilLowerToFloor, + + // The following are only used by Generic_Ceiling + ceilRaiseToHighest, + ceilLowerToHighest, + ceilRaiseToLowest, + ceilLowerToNearest, + ceilRaiseToHighestFloor, + ceilRaiseToFloor, + ceilRaiseByTexture, + ceilLowerByTexture, + + genCeilingChg0, + genCeilingChgT, + genCeilingChg + } + + enum ECrushMode + { + crushDoom = 0, + crushHexen = 1, + crushSlowdown = 2 + } -} \ No newline at end of file + native bool CreateCeiling(sector sec, int type, line ln, double speed, double speed2, double height = 0, int crush = -1, int silent = 0, int change = 0, int crushmode = crushDoom); + +} + +struct LookExParams +{ + double Fov; + double minDist; + double maxDist; + double maxHeardist; + int flags; + State seestate; +}; diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index aa9b4a066..2f6dc4bc1 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -77,6 +77,18 @@ class PlayerPawn : Actor native Obituary "$OB_MPDEFAULT"; } + virtual void PlayIdle () + { + if (InStateSequence(CurState, SeeState)) + SetState (SpawnState); + } + + virtual void PlayRunning () + { + if (InStateSequence(CurState, SpawnState) && SeeState != NULL) + SetState (SeeState); + } + virtual void PlayAttacking () { if (MissileState != null) SetState (MissileState); @@ -92,6 +104,7 @@ class PlayerPawn : Actor native } native int GetMaxHealth(); + native bool ResetAirSupply (bool playgasp = false); } class PlayerChunk : PlayerPawn native