From 91bfe4cceb8648b0c1c84622d212f4e03a4988e1 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 21 Dec 2014 12:29:19 -0600 Subject: [PATCH] - Added pointers for A_CustomMissile and A_CustomBulletAttack. --- src/p_enemy.h | 2 ++ src/thingdef/thingdef_codeptr.cpp | 25 ++++++++++++++++++------- wadsrc/static/actors/actor.txt | 4 ++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/p_enemy.h b/src/p_enemy.h index ff40c7003b..8c5516eadc 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -73,6 +73,8 @@ DECLARE_ACTION(A_BossDeath) void A_Chase(AActor *self); void A_FaceTarget (AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270); +void A_FaceMaster(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270); +void A_FaceTracer(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270); bool A_RaiseMobj (AActor *, fixed_t speed); bool A_SinkMobj (AActor *, fixed_t speed); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 98451795b0..0f37efa185 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -907,20 +907,23 @@ enum CM_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { - ACTION_PARAM_START(6); + ACTION_PARAM_START(7); ACTION_PARAM_CLASS(ti, 0); ACTION_PARAM_FIXED(SpawnHeight, 1); ACTION_PARAM_INT(Spawnofs_XY, 2); ACTION_PARAM_ANGLE(Angle, 3); ACTION_PARAM_INT(flags, 4); ACTION_PARAM_ANGLE(pitch, 5); + ACTION_PARAM_INT(ptr, 6); + + AActor *ref = COPY_AAPTR(self, ptr); int aimmode = flags & CMF_AIMMODE; AActor * targ; AActor * missile; - if (self->target != NULL || aimmode==2) + if (ref != NULL || aimmode==2) { if (ti) { @@ -937,14 +940,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) self->x += x; self->y += y; self->z += z; - missile = P_SpawnMissileXYZ(self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false); + missile = P_SpawnMissileXYZ(self->x, self->y, self->z + 32*FRACUNIT, self, ref, ti, false); self->x -= x; self->y -= y; self->z -= z; break; case 1: - missile = P_SpawnMissileXYZ(self->x+x, self->y+y, self->z + self->GetBobOffset() + SpawnHeight, self, self->target, ti, false); + missile = P_SpawnMissileXYZ(self->x+x, self->y+y, self->z + self->GetBobOffset() + SpawnHeight, self, ref, ti, false); break; case 2: @@ -1056,7 +1059,7 @@ enum CBA_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { - ACTION_PARAM_START(7); + ACTION_PARAM_START(8); ACTION_PARAM_ANGLE(Spread_XY, 0); ACTION_PARAM_ANGLE(Spread_Z, 1); ACTION_PARAM_INT(NumBullets, 2); @@ -1064,6 +1067,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) ACTION_PARAM_CLASS(pufftype, 4); ACTION_PARAM_FIXED(Range, 5); ACTION_PARAM_INT(Flags, 6); + ACTION_PARAM_INT(ptr, 7); + + AActor *ref = COPY_AAPTR(self, ptr); if(Range==0) Range=MISSILERANGE; @@ -1072,9 +1078,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) int bslope = 0; int laflags = (Flags & CBAF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; - if (self->target || (Flags & CBAF_AIMFACING)) + if (ref || (Flags & CBAF_AIMFACING)) { - if (!(Flags & CBAF_AIMFACING)) A_FaceTarget (self); + if (!(Flags & CBAF_AIMFACING)) + { + if (ref == self->target) A_FaceTarget(self); + else if (ref == self->master) A_FaceMaster(self); + else if (ref == self->tracer) A_FaceTracer(self); + } bangle = self->angle; if (!pufftype) pufftype = PClass::FindClass(NAME_BulletPuff); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index cd718b1c0d..17b762d686 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -204,8 +204,8 @@ ACTOR Actor native //: Thinker action native A_StopSoundEx(coerce name slot); action native A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); action native A_Jump(int chance = 256, state label, ...); - action native A_CustomMissile(class missiletype, float spawnheight = 32, int spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0); - action native A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, int flags = 0); + action native A_CustomMissile(class missiletype, float spawnheight = 32, int spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET); + action native A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET); action native A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, bool aim = false, float maxdiff = 0, class pufftype = "BulletPuff", float spread_xy = 0, float spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0); action native A_JumpIfHealthLower(int health, state label, int ptr_selector = AAPTR_DEFAULT); action native A_JumpIfCloser(float distance, state label);