- added all missing things to enable the scriptified version of A_BrainSpit.

This uses a global function, this has been placed into DObject for now because the scripting interface does not allow non-class-owned functions yet.
This commit is contained in:
Christoph Oelckers 2016-11-18 22:12:53 +01:00
parent aa32d8970b
commit 7ff5069617
8 changed files with 68 additions and 89 deletions

View file

@ -866,7 +866,6 @@ set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES}
sc_man_scanner.h
sc_man_scanner.re
g_doom/a_bossbrain.cpp
g_doom/a_doomweaps.cpp
g_doom/a_painelemental.cpp
g_doom/a_scriptedmarine.cpp

View file

@ -1,80 +0,0 @@
/*
#include "actor.h"
#include "info.h"
#include "m_random.h"
#include "p_local.h"
#include "p_enemy.h"
#include "s_sound.h"
#include "statnums.h"
#include "a_specialspot.h"
#include "vm.h"
#include "doomstat.h"
#include "g_level.h"
*/
static FRandom pr_spawnfly ("SpawnFly");
DEFINE_ACTION_FUNCTION(AActor, A_BrainSpit)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(spawntype, AActor);
DSpotState *state = DSpotState::GetSpotState();
AActor *targ;
AActor *spit;
bool isdefault = false;
// shoot a cube at current target
targ = state->GetNextInList(PClass::FindActor("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain));
if (targ != NULL)
{
if (spawntype == NULL)
{
spawntype = PClass::FindActor("SpawnShot");
isdefault = true;
}
// spawn brain missile
spit = P_SpawnMissile (self, targ, spawntype);
if (spit != NULL)
{
// Boss cubes should move freely to their destination so it's
// probably best to disable all collision detection for them.
if (spit->flags & MF_NOCLIP) spit->flags5 |= MF5_NOINTERACTION;
spit->target = targ;
spit->master = self;
// [RH] Do this correctly for any trajectory. Doom would divide by 0
// if the target had the same y coordinate as the spitter.
if (spit->Vel.X == 0 && spit->Vel.Y == 0)
{
spit->special2 = 0;
}
else if (fabs(spit->Vel.Y) > fabs(spit->Vel.X))
{
spit->special2 = int((targ->Y() - self->Y()) / spit->Vel.Y);
}
else
{
spit->special2 = int((targ->X() - self->X()) / spit->Vel.X);
}
// [GZ] Calculates when the projectile will have reached destination
spit->special2 += level.maptime;
spit->flags6 |= MF6_BOSSCUBE;
}
if (!isdefault)
{
S_Sound(self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NONE);
}
else
{
// compatibility fallback
S_Sound (self, CHAN_WEAPON, "brain/spit", 1, ATTN_NONE);
}
}
return 0;
}

View file

@ -20,7 +20,6 @@
#include "g_shared/a_pickups.h"
// Include all the other Doom stuff here to reduce compile time
#include "a_bossbrain.cpp"
#include "a_doomweaps.cpp"
#include "a_painelemental.cpp"
#include "a_scriptedmarine.cpp"

View file

@ -251,6 +251,12 @@ DSpotState *DSpotState::GetSpotState(bool create)
return SpotState;
}
DEFINE_ACTION_FUNCTION(DSpotState, GetSpotState)
{
PARAM_PROLOGUE;
ACTION_RETURN_OBJECT(DSpotState::GetSpotState());
}
//----------------------------------------------------------------------------
//
//
@ -317,6 +323,14 @@ ASpecialSpot *DSpotState::GetNextInList(PClassActor *type, int skipcounter)
return NULL;
}
DEFINE_ACTION_FUNCTION(DSpotState, GetNextInList)
{
PARAM_SELF_PROLOGUE(DSpotState);
PARAM_CLASS(type, AActor);
PARAM_INT(skipcounter);
ACTION_RETURN_OBJECT(self->GetNextInList(type, skipcounter));
}
//----------------------------------------------------------------------------
//
//
@ -371,7 +385,6 @@ void ASpecialSpot::Destroy()
// Mace spawn spot ----------------------------------------------------------
// Every mace spawn spot will execute this action. The first one
// will build a list of all mace spots in the level and spawn a
// mace. The rest of the spots will do nothing.

View file

@ -388,6 +388,13 @@ int G_SkillProperty(ESkillProperty prop)
return 0;
}
DEFINE_ACTION_FUNCTION(DObject, G_SkillPropertyInt)
{
PARAM_PROLOGUE;
PARAM_INT(which);
ACTION_RETURN_INT(G_SkillProperty((ESkillProperty)which));
}
//==========================================================================
//
//
@ -433,6 +440,13 @@ double G_SkillProperty(EFSkillProperty prop)
return 0;
}
DEFINE_ACTION_FUNCTION(DObject, G_SkillPropertyFloat)
{
PARAM_PROLOGUE;
PARAM_INT(which);
ACTION_RETURN_FLOAT(G_SkillProperty((EFSkillProperty)which));
}
//==========================================================================

View file

@ -1,5 +1,9 @@
class Object native
{
// These really should be global functions...
native static int G_SkillPropertyInt(int p);
native static double G_SkillPropertyFloat(int p);
virtual native void Destroy();
native class<Object> GetClass();
}
@ -37,3 +41,8 @@ class DropItem : Object native
*/
}
class SpotState : Object native
{
native static SpotState GetSpotState();
native SpecialSpot GetNextInList(class<Actor> type, int skipcounter);
}

View file

@ -917,3 +917,31 @@ enum EMapThingFlags
MTF_SECRET = 0x080000, // Secret pickup
MTF_NOINFIGHTING = 0x100000,
};
enum ESkillProperty
{
SKILLP_FastMonsters,
SKILLP_Respawn,
SKILLP_RespawnLimit,
SKILLP_DisableCheats,
SKILLP_AutoUseHealth,
SKILLP_SpawnFilter,
SKILLP_EasyBossBrain,
SKILLP_ACSReturn,
SKILLP_NoPain,
SKILLP_EasyKey,
SKILLP_SlowMonsters,
SKILLP_Infight,
};
enum EFSkillProperty // floating point properties
{
SKILLP_AmmoFactor,
SKILLP_DropAmmoFactor,
SKILLP_ArmorFactor,
SKILLP_HealthFactor,
SKILLP_DamageFactor,
SKILLP_Aggressiveness,
SKILLP_MonsterHealth,
SKILLP_FriendlyHealth,
};

View file

@ -212,9 +212,7 @@ extend class Actor
Exit_Normal(0);
}
native
void A_BrainSpit(class<Actor> spawntype = null) // needs special treatment for default
;/*
void A_BrainSpit(class<Actor> spawntype = null)
{
SpotState spstate = SpotState.GetSpotState();
Actor targ;
@ -222,7 +220,7 @@ extend class Actor
bool isdefault = false;
// shoot a cube at current target
targ = spstate.GetNextInList("BossTarget", G_SkillProperty(SKILLP_EasyBossBrain));
targ = spstate.GetNextInList("BossTarget", G_SkillPropertyInt(SKILLP_EasyBossBrain));
if (targ)
{
@ -249,7 +247,7 @@ extend class Actor
{
spit.special2 = 0;
}
else if (abs(spit.Vel.y) > fabs(spit.Vel.x))
else if (abs(spit.Vel.y) > abs(spit.Vel.x))
{
spit.special2 = int((targ.pos.y - pos.y) / spit.Vel.y);
}
@ -273,7 +271,6 @@ extend class Actor
}
}
}
*/
private void SpawnFly(class<Actor> spawntype, sound snd)
{