Skip to content

Commit

Permalink
- Added a Z offsetting parameter to the ZScript LineAttack function.
Browse files Browse the repository at this point in the history
- Added LAF_OVERRIDEZ flag to LineAttack. Disregards all internal offsetting aside the actor's Z position before adding the offset parameter.
  • Loading branch information
MajorCooke authored and coelckers committed May 17, 2017
1 parent ebf3a37 commit 65f13b0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/p_local.h
Expand Up @@ -328,10 +328,11 @@ enum // P_LineAttack flags
LAF_NOIMPACTDECAL = 4,
LAF_NOINTERACT = 8,
LAF_TARGETISSOURCE = 16,
LAF_OVERRIDEZ = 32,
};

AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL);
AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, FName pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL);
AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL, double sz = 0.0);
AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, FName pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL, double sz = 0.0);

void P_TraceBleed(int damage, const DVector3 &pos, AActor *target, DAngle angle, DAngle pitch);
void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch);
Expand Down
15 changes: 11 additions & 4 deletions src/p_map.cpp
Expand Up @@ -4390,7 +4390,7 @@ static ETraceStatus CheckForActor(FTraceResults &res, void *userdata)
//==========================================================================

AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags, FTranslatedLineTarget*victim, int *actualdamage)
DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags, FTranslatedLineTarget*victim, int *actualdamage, double sz)
{
bool nointeract = !!(flags & LAF_NOINTERACT);
DVector3 direction;
Expand Down Expand Up @@ -4435,6 +4435,12 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
shootz += 8;
}

// [MC] If overriding, set it to the base of the actor.
// Offset by the amount specified.
if (flags & LAF_OVERRIDEZ)
shootz = t1->Z();
shootz += sz;

// We need to check the defaults of the replacement here
AActor *puffDefaults = GetDefaultByType(pufftype->GetReplacement());

Expand Down Expand Up @@ -4691,7 +4697,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
}

AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
DAngle pitch, int damage, FName damageType, FName pufftype, int flags, FTranslatedLineTarget *victim, int *actualdamage)
DAngle pitch, int damage, FName damageType, FName pufftype, int flags, FTranslatedLineTarget *victim, int *actualdamage, double sz)
{
PClassActor *type = PClass::FindActor(pufftype);
if (type == NULL)
Expand All @@ -4705,7 +4711,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
}
else
{
return P_LineAttack(t1, angle, distance, pitch, damage, damageType, type, flags, victim, actualdamage);
return P_LineAttack(t1, angle, distance, pitch, damage, damageType, type, flags, victim, actualdamage, sz);
}
}

Expand All @@ -4720,10 +4726,11 @@ DEFINE_ACTION_FUNCTION(AActor, LineAttack)
PARAM_CLASS(puffType, AActor);
PARAM_INT_DEF(flags);
PARAM_POINTER_DEF(victim, FTranslatedLineTarget);
PARAM_FLOAT_DEF(sz);

int acdmg;
if (puffType == nullptr) puffType = PClass::FindActor("BulletPuff"); // P_LineAttack does not work without a puff to take info from.
auto puff = P_LineAttack(self, angle, distance, pitch, damage, damageType, puffType, flags, victim, &acdmg);
auto puff = P_LineAttack(self, angle, distance, pitch, damage, damageType, puffType, flags, victim, &acdmg, sz);
if (numret > 0) ret[0].SetObject(puff);
if (numret > 1) ret[1].SetInt(acdmg), numret = 2;
return numret;
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/zscript/actor.txt
Expand Up @@ -585,7 +585,7 @@ class Actor : Thinker native
native virtual int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags = 0, double angle = 0);
native void PoisonMobj (Actor inflictor, Actor source, int damage, int duration, int period, Name type);
native double AimLineAttack(double angle, double distance, out FTranslatedLineTarget pLineTarget = null, double vrange = 0., int flags = 0, Actor target = null, Actor friender = null);
native Actor, int LineAttack(double angle, double distance, double pitch, int damage, Name damageType, class<Actor> pufftype, int flags = 0, out FTranslatedLineTarget victim = null);
native Actor, int LineAttack(double angle, double distance, double pitch, int damage, Name damageType, class<Actor> pufftype, int flags = 0, out FTranslatedLineTarget victim = null, double sz = 0.);
native bool CheckSight(Actor target, int flags = 0);
native bool IsVisible(Actor other, bool allaround, LookExParams params = null);
native bool HitFriend();
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/constants.txt
Expand Up @@ -881,6 +881,7 @@ enum ELineAttackFlags
LAF_NORANDOMPUFFZ = 2,
LAF_NOIMPACTDECAL = 4,
LAF_NOINTERACT = 8,
LAF_OVERRIDEZ = 32,
}

const DEFMELEERANGE = 64;
Expand Down

0 comments on commit 65f13b0

Please sign in to comment.