From 7ff506961761773026cbb4f683029f54c8d5494e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 18 Nov 2016 22:12:53 +0100 Subject: [PATCH] - 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. --- src/CMakeLists.txt | 1 - src/g_doom/a_bossbrain.cpp | 80 ------------------------ src/g_doom/a_doommisc.cpp | 1 - src/g_shared/a_specialspot.cpp | 15 ++++- src/g_skill.cpp | 14 +++++ wadsrc/static/zscript/base.txt | 9 +++ wadsrc/static/zscript/constants.txt | 28 +++++++++ wadsrc/static/zscript/doom/bossbrain.txt | 9 +-- 8 files changed, 68 insertions(+), 89 deletions(-) delete mode 100644 src/g_doom/a_bossbrain.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5f307d56f..b7f2eb3b2e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp deleted file mode 100644 index 8adb5c1dfc..0000000000 --- a/src/g_doom/a_bossbrain.cpp +++ /dev/null @@ -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; -} - diff --git a/src/g_doom/a_doommisc.cpp b/src/g_doom/a_doommisc.cpp index 30fd6c671e..4672977614 100644 --- a/src/g_doom/a_doommisc.cpp +++ b/src/g_doom/a_doommisc.cpp @@ -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" diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index c094ee8ba3..e96f5a9036 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -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. diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 44c2cef8c7..70daadc23f 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -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)); +} + //========================================================================== diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 6cf2835e81..1089476a1a 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -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 GetClass(); } @@ -37,3 +41,8 @@ class DropItem : Object native */ } +class SpotState : Object native +{ + native static SpotState GetSpotState(); + native SpecialSpot GetNextInList(class type, int skipcounter); +} \ No newline at end of file diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 3f7a26461d..08eee789e4 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -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, +}; + diff --git a/wadsrc/static/zscript/doom/bossbrain.txt b/wadsrc/static/zscript/doom/bossbrain.txt index 6a72de2bfb..9a2ad759c3 100644 --- a/wadsrc/static/zscript/doom/bossbrain.txt +++ b/wadsrc/static/zscript/doom/bossbrain.txt @@ -212,9 +212,7 @@ extend class Actor Exit_Normal(0); } - native - void A_BrainSpit(class spawntype = null) // needs special treatment for default - ;/* + void A_BrainSpit(class 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 spawntype, sound snd) {