From 119bcb924d134db5befa459d89ee5b6664081508 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Nov 2016 18:59:57 +0100 Subject: [PATCH] - scriptified the Loremaster. --- src/CMakeLists.txt | 1 - src/g_strife/a_loremaster.cpp | 43 --------------------- src/g_strife/a_strifestuff.cpp | 1 - src/p_mobj.cpp | 11 +++++- wadsrc/static/zscript/actor.txt | 1 + wadsrc/static/zscript/strife/loremaster.txt | 24 ++++++++++-- 6 files changed, 31 insertions(+), 50 deletions(-) delete mode 100644 src/g_strife/a_loremaster.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74760f138..eddf2d9e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -861,7 +861,6 @@ set( NOT_COMPILED_SOURCE_FILES sc_man_scanner.re g_hexen/a_heresiarch.cpp g_hexen/a_spike.cpp - g_strife/a_loremaster.cpp g_strife/a_oracle.cpp g_strife/a_programmer.cpp g_strife/a_rebels.cpp diff --git a/src/g_strife/a_loremaster.cpp b/src/g_strife/a_loremaster.cpp deleted file mode 100644 index 747ba326a..000000000 --- a/src/g_strife/a_loremaster.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -#include "actor.h" -#include "a_action.h" -#include "a_strifeglobal.h" -#include "m_random.h" -#include "p_local.h" -#include "s_sound.h" -#include "vm.h" -*/ - -// Loremaster (aka Priest) -------------------------------------------------- - -class ALoreShot : public AActor -{ - DECLARE_CLASS (ALoreShot, AActor) -public: - int DoSpecialDamage (AActor *victim, int damage, FName damagetype); -}; - -IMPLEMENT_CLASS(ALoreShot, false, false) - -int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype) -{ - - if (victim != NULL && target != NULL && !(victim->flags7 & MF7_DONTTHRUST)) - { - DVector3 thrust = victim->Vec3To(target); - thrust.MakeResize(255. * 50 / MAX(victim->Mass, 1)); - victim->Vel += thrust; - } - return damage; -} - -DEFINE_ACTION_FUNCTION(AActor, A_LoremasterChain) -{ - PARAM_SELF_PROLOGUE(AActor); - - S_Sound (self, CHAN_BODY, "loremaster/active", 1, ATTN_NORM); - Spawn("LoreShot2", self->Pos(), ALLOW_REPLACE); - Spawn("LoreShot2", self->Vec3Offset(-self->Vel/2.), ALLOW_REPLACE); - Spawn("LoreShot2", self->Vec3Offset(-self->Vel), ALLOW_REPLACE); - return 0; -} diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index ba316175d..e8ae59c18 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -24,7 +24,6 @@ #include "vm.h" // Include all the other Strife stuff here to reduce compile time -#include "a_loremaster.cpp" #include "a_oracle.cpp" #include "a_programmer.cpp" #include "a_rebels.cpp" diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 93c9b80f3..8424caee8 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -7509,13 +7509,20 @@ DEFINE_ACTION_FUNCTION(AActor, Vec2Angle) } +DEFINE_ACTION_FUNCTION(AActor, Vec3To) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT(t, AActor) + ACTION_RETURN_VEC3(self->Vec3To(t)); +} + DEFINE_ACTION_FUNCTION(AActor, Vec3Angle) { PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(length) - PARAM_ANGLE(angle); + PARAM_ANGLE(angle); PARAM_FLOAT(z); - PARAM_BOOL_DEF(absolute); + PARAM_BOOL_DEF(absolute); ACTION_RETURN_VEC3(self->Vec3Angle(length, angle, z, absolute)); } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 3b49e3e3c..2d2725d1e 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -354,6 +354,7 @@ class Actor : Thinker native native double AngleTo(Actor target, bool absolute = false); native void AddZ(double zadd, bool moving = true); native void SetZ(double z); + native vector3 Vec3To(Actor other); native vector3 Vec3Offset(double x, double y, double z, bool absolute = false); native vector3 Vec3Angle(double length, double angle, double z = 0, bool absolute = false); native vector2 Vec2Angle(double length, double angle, bool absolute = false); diff --git a/wadsrc/static/zscript/strife/loremaster.txt b/wadsrc/static/zscript/strife/loremaster.txt index 4a48cf4d3..14571f91c 100644 --- a/wadsrc/static/zscript/strife/loremaster.txt +++ b/wadsrc/static/zscript/strife/loremaster.txt @@ -76,7 +76,7 @@ class Loremaster : Actor // Loremaster Projectile ---------------------------------------------------- -class LoreShot : Actor native +class LoreShot : Actor { Default { @@ -91,8 +91,6 @@ class LoreShot : Actor native ActiveSound "loremaster/swish"; } - native void A_LoremasterChain (); - States { Spawn: @@ -102,6 +100,26 @@ class LoreShot : Actor native OCLW A 6; Stop; } + + override int DoSpecialDamage (Actor victim, int damage, Name damagetype) + { + + if (victim != NULL && target != NULL && !victim.bDontThrust) + { + Vector3 thrust = victim.Vec3To(target); + victim.Vel += thrust.Unit() * (255. * 50 / max(victim.Mass, 1)); + } + return damage; + } + + void A_LoremasterChain () + { + A_PlaySound ("loremaster/active", CHAN_BODY); + Spawn("LoreShot2", Pos, ALLOW_REPLACE); + Spawn("LoreShot2", Vec3Offset(-Vel.x/2., -Vel.y/2., -Vel.z/2.), ALLOW_REPLACE); + Spawn("LoreShot2", Vec3Offset(-Vel.x, -Vel.y, -Vel.z), ALLOW_REPLACE); + } + } // Loremaster Subprojectile -------------------------------------------------