mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- scriptified Hexen's bats.
- removed AMinotaurFriend::IsOkayToAttack. The condition it checks (i.e. friendliness with player) is already covered by the base version of this function so this is quite redundant. - removed a few 'virtual' qualifiers from functions that never get overridden.
This commit is contained in:
parent
5bc89e7efc
commit
34fc6323a4
9 changed files with 98 additions and 123 deletions
|
@ -614,7 +614,7 @@ public:
|
|||
|
||||
virtual void BeginPlay(); // Called immediately after the actor is created
|
||||
virtual void PostBeginPlay(); // Called immediately before the actor's first tick
|
||||
virtual void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world
|
||||
void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world
|
||||
virtual void HandleSpawnFlags(); // Translates SpawnFlags into in-game flags.
|
||||
|
||||
virtual void MarkPrecacheSounds() const; // Marks sounds used by this actor for precaching.
|
||||
|
@ -733,7 +733,7 @@ public:
|
|||
void ObtainInventory (AActor *other);
|
||||
|
||||
// Die. Now.
|
||||
virtual bool Massacre ();
|
||||
bool Massacre ();
|
||||
|
||||
// Transforms the actor into a finely-ground paste
|
||||
virtual bool Grind(bool items);
|
||||
|
@ -958,7 +958,7 @@ public:
|
|||
{
|
||||
SetOrigin(Pos() + vel, true);
|
||||
}
|
||||
virtual void SetOrigin(double x, double y, double z, bool moving);
|
||||
void SetOrigin(double x, double y, double z, bool moving);
|
||||
void SetOrigin(const DVector3 & npos, bool moving)
|
||||
{
|
||||
SetOrigin(npos.X, npos.Y, npos.Z, moving);
|
||||
|
@ -970,7 +970,7 @@ public:
|
|||
bool IsInsideVisibleAngles() const;
|
||||
|
||||
// Calculate amount of missile damage
|
||||
virtual int GetMissileDamage(int mask, int add);
|
||||
int GetMissileDamage(int mask, int add);
|
||||
|
||||
bool CanSeek(AActor *target) const;
|
||||
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
#include "actor.h"
|
||||
#include "info.h"
|
||||
#include "m_random.h"
|
||||
#include "p_local.h"
|
||||
#include "s_sound.h"
|
||||
#include "vm.h"
|
||||
*/
|
||||
|
||||
static FRandom pr_batspawn ("BatSpawn");
|
||||
static FRandom pr_batmove ("BatMove");
|
||||
|
||||
//===========================================================================
|
||||
// Bat Spawner Variables
|
||||
// special1 frequency counter
|
||||
// special2
|
||||
// args[0] frequency of spawn (1=fastest, 10=slowest)
|
||||
// args[1] spread angle (0..255)
|
||||
// args[2]
|
||||
// args[3] duration of bats (in octics)
|
||||
// args[4] turn amount per move (in degrees)
|
||||
//
|
||||
// Bat Variables
|
||||
// special2 lifetime counter
|
||||
// args[4] turn amount per move (in degrees)
|
||||
//===========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_BatSpawnInit)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
||||
self->special1 = 0; // Frequency count
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_BatSpawn)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
||||
AActor *mo;
|
||||
int delta;
|
||||
DAngle angle;
|
||||
|
||||
// Countdown until next spawn
|
||||
if (self->special1-- > 0) return 0;
|
||||
self->special1 = self->args[0]; // Reset frequency count
|
||||
|
||||
delta = self->args[1];
|
||||
if (delta==0) delta=1;
|
||||
|
||||
angle = self->Angles.Yaw + (((pr_batspawn() % delta) - (delta >> 1)) * (360 / 256.));
|
||||
|
||||
mo = P_SpawnMissileAngle (self, PClass::FindActor("Bat"), angle, 0);
|
||||
if (mo)
|
||||
{
|
||||
mo->args[0] = pr_batspawn()&63; // floatbob index
|
||||
mo->args[4] = self->args[4]; // turn degrees
|
||||
mo->special2 = self->args[3]<<3; // Set lifetime
|
||||
mo->target = self;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_BatMove)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
||||
DAngle newangle;
|
||||
|
||||
if (self->special2 < 0)
|
||||
{
|
||||
self->SetState (self->FindState(NAME_Death));
|
||||
}
|
||||
self->special2 -= 2; // Called every 2 tics
|
||||
|
||||
if (pr_batmove()<128)
|
||||
{
|
||||
newangle = self->Angles.Yaw + self->args[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
newangle = self->Angles.Yaw - self->args[4];
|
||||
}
|
||||
|
||||
// Adjust velocity vector to new direction
|
||||
self->VelFromAngle(self->Speed, newangle);
|
||||
|
||||
if (pr_batmove()<15)
|
||||
{
|
||||
S_Sound (self, CHAN_VOICE, "BatScream", 1, ATTN_IDLE);
|
||||
}
|
||||
|
||||
// Handle Z movement
|
||||
self->SetZ(self->target->Z() + 2 * BobSin(self->args[0]));
|
||||
self->args[0] = (self->args[0]+3)&63;
|
||||
return 0;
|
||||
}
|
|
@ -27,7 +27,6 @@
|
|||
#include "vm.h"
|
||||
|
||||
// Include all the Hexen stuff here to reduce compile time
|
||||
#include "a_bats.cpp"
|
||||
#include "a_bishop.cpp"
|
||||
#include "a_blastradius.cpp"
|
||||
#include "a_boostarmor.cpp"
|
||||
|
|
|
@ -117,12 +117,6 @@ void AMinotaurFriend::Die (AActor *source, AActor *inflictor, int dmgflags)
|
|||
}
|
||||
}
|
||||
|
||||
bool AMinotaurFriend::OkayToSwitchTarget (AActor *other)
|
||||
{
|
||||
if (other == tracer) return false; // Do not target the master
|
||||
return Super::OkayToSwitchTarget (other);
|
||||
}
|
||||
|
||||
// Action functions for the minotaur ----------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -21,7 +21,6 @@ public:
|
|||
int StartTime;
|
||||
|
||||
void Die (AActor *source, AActor *inflictor, int dmgflags);
|
||||
bool OkayToSwitchTarget (AActor *other);
|
||||
void BeginPlay ();
|
||||
|
||||
void Serialize(FSerializer &arc);
|
||||
|
|
|
@ -6885,6 +6885,14 @@ DEFINE_ACTION_FUNCTION(AActor, AddZ)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, SetZ)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_FLOAT(z);
|
||||
self->SetZ(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, SetDamage)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
|
|
@ -35,7 +35,6 @@ VMEXPORTED_NATIVES_START
|
|||
VMEXPORTED_NATIVES_FUNC(Destroy)
|
||||
VMEXPORTED_NATIVES_FUNC(Tick)
|
||||
VMEXPORTED_NATIVES_FUNC(PostBeginPlay)
|
||||
VMEXPORTED_NATIVES_FUNC(DropInventory)
|
||||
VMEXPORTED_NATIVES_END
|
||||
|
||||
template<class T>
|
||||
|
@ -103,11 +102,6 @@ public:
|
|||
{
|
||||
ExportedNatives<T>::Get()->template PostBeginPlay<void, T>(this);
|
||||
}
|
||||
|
||||
AInventory *DropInventory(AInventory *item)
|
||||
{
|
||||
return ExportedNatives<T>::Get()->template DropInventory<AInventory *, T>(this, item);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
@ -134,7 +128,7 @@ VMEXPORT_NATIVES_START(DThinker, DObject)
|
|||
VMEXPORT_NATIVES_FUNC(PostBeginPlay)
|
||||
VMEXPORT_NATIVES_END(DThinker)
|
||||
|
||||
/*
|
||||
VMEXPORT_NATIVES_START(AActor, DThinker)
|
||||
VMEXPORT_NATIVES_FUNC(DropInventory)
|
||||
VMEXPORT_NATIVES_END(AActor)
|
||||
|
||||
*/
|
|
@ -54,6 +54,12 @@ class Actor : Thinker native
|
|||
return GetPointer(ptr_select1) == GetPointer(ptr_select2);
|
||||
}
|
||||
|
||||
static double BobSin(double fb)
|
||||
{
|
||||
return sin(fb * (180./32)) * 8;
|
||||
}
|
||||
|
||||
|
||||
native static readonly<Actor> GetDefaultByType(class<Actor> cls);
|
||||
native static float deltaangle(float ang1, float ang2);
|
||||
native static float GetDefaultSpeed(class<Actor> type);
|
||||
|
@ -84,6 +90,7 @@ class Actor : Thinker native
|
|||
native bool CanSeek(Actor target);
|
||||
native double AngleTo(Actor target, bool absolute = false);
|
||||
native void AddZ(float zadd);
|
||||
native void SetZ(float z);
|
||||
native vector3 Vec3Offset(float x, float y, float z, bool absolute = false);
|
||||
native vector3 Vec3Angle(float length, float angle, float z = 0, bool absolute = false);
|
||||
native vector3 Vec2OffsetZ(float x, float y, float atz, bool absolute = false);
|
||||
|
|
|
@ -9,9 +9,6 @@ class BatSpawner : SwitchableDecoration
|
|||
RenderStyle "None";
|
||||
}
|
||||
|
||||
native void A_BatSpawnInit();
|
||||
native void A_BatSpawn();
|
||||
|
||||
States
|
||||
{
|
||||
Spawn:
|
||||
|
@ -24,6 +21,48 @@ class BatSpawner : SwitchableDecoration
|
|||
TNT1 A -1;
|
||||
Stop;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Bat Spawner Variables
|
||||
// special1 frequency counter
|
||||
// special2
|
||||
// args[0] frequency of spawn (1=fastest, 10=slowest)
|
||||
// args[1] spread angle (0..255)
|
||||
// args[2]
|
||||
// args[3] duration of bats (in octics)
|
||||
// args[4] turn amount per move (in degrees)
|
||||
//
|
||||
// Bat Variables
|
||||
// special2 lifetime counter
|
||||
// args[4] turn amount per move (in degrees)
|
||||
//===========================================================================
|
||||
|
||||
void A_BatSpawnInit()
|
||||
{
|
||||
special1 = 0; // Frequency count
|
||||
}
|
||||
|
||||
void A_BatSpawn()
|
||||
{
|
||||
// Countdown until next spawn
|
||||
if (special1-- > 0) return;
|
||||
special1 = args[0]; // Reset frequency count
|
||||
|
||||
int delta = args[1];
|
||||
if (delta == 0) delta = 1;
|
||||
|
||||
double ang = Angle + (((random[BatSpawn]() % delta) - (delta >> 1)) * (360 / 256.));
|
||||
|
||||
Actor mo = SpawnMissileAngle ("Bat", ang, 0);
|
||||
if (mo)
|
||||
{
|
||||
mo.args[0] = random[BatSpawn]() & 63; // floatbob index
|
||||
mo.args[4] = args[4]; // turn degrees
|
||||
mo.special2 = args[3] << 3; // Set lifetime
|
||||
mo.target = self;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Bat ----------------------------------------------------------------------
|
||||
|
@ -39,8 +78,6 @@ class Bat : Actor
|
|||
+NOTELEPORT +CANPASS
|
||||
}
|
||||
|
||||
native void A_BatMove();
|
||||
|
||||
States
|
||||
{
|
||||
Spawn:
|
||||
|
@ -50,4 +87,39 @@ class Bat : Actor
|
|||
ABAT A 2;
|
||||
Stop;
|
||||
}
|
||||
|
||||
void A_BatMove()
|
||||
{
|
||||
if (special2 < 0)
|
||||
{
|
||||
SetState ("Death");
|
||||
}
|
||||
special2 -= 2; // Called every 2 tics
|
||||
|
||||
double newangle;
|
||||
if (random[BatMove]() < 128)
|
||||
{
|
||||
newangle = Angle + args[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
newangle = Angle - args[4];
|
||||
}
|
||||
|
||||
// Adjust velocity vector to new direction
|
||||
VelFromAngle(Speed, newangle);
|
||||
|
||||
if (random[BatMove]() < 15)
|
||||
{
|
||||
A_PlaySound ("BatScream", CHAN_VOICE, 1, false, ATTN_IDLE);
|
||||
}
|
||||
|
||||
// Handle Z movement
|
||||
SetZ(target.pos.Z + 2 * BobSin(args[0]));
|
||||
args[0] = (args[0] + 3) & 63;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue