- preparations for allowing hitscans through portals.

To allow processing the hit through an arbitrary portal without reference to the portal group table, P_AimLineAttack and P_LineAttack need to pass some more info than just the linetarget.
We need the relative positions of shooter and target within the visual reference of the other to calculate proper angles and we need to know if such a portal was crossed at all, because a few things, e.g. seeker missiles won't work with them.

- fixed setup of target acquisition for the Mage Staff.

The pre-acquired seeker target was never passed to the spawned projectiles.
This commit is contained in:
Christoph Oelckers 2016-03-01 16:38:45 +01:00
commit b4a002a07f
28 changed files with 331 additions and 279 deletions

View file

@ -960,7 +960,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser)
else
{
// Does the player aim at something that can be shot?
P_BulletSlope(self, &target);
FTranslatedLineTarget t;
P_BulletSlope(self, &t, ALF_PORTALRESTRICT);
target = t.linetarget;
}
return DoJumpIfCloser(target, VM_ARGS_NAMES);
}
@ -1637,7 +1639,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
player_t *player = self->player;
AWeapon *weapon = player->ReadyWeapon;
AActor *linetarget;
FTranslatedLineTarget t;
// Only use ammo if called from a weapon
if (useammo && ACTION_CALL_FROM_WEAPON() && weapon)
@ -1659,7 +1661,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
// Temporarily adjusts the pitch
fixed_t saved_player_pitch = self->pitch;
self->pitch -= pitch;
AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &linetarget, NULL, false, (flags & FPF_NOAUTOAIM) != 0);
AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0);
self->pitch = saved_player_pitch;
// automatic handling of seeker missiles
@ -1667,8 +1669,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
{
if (flags & FPF_TRANSFERTRANSLATION)
misl->Translation = self->Translation;
if (linetarget && (misl->flags2 & MF2_SEEKERMISSILE))
misl->tracer = linetarget;
if (t.linetarget && !t.unlinked && (misl->flags2 & MF2_SEEKERMISSILE))
misl->tracer = t.linetarget;
if (!(flags & FPF_AIMATANGLE))
{
// This original implementation is to aim straight ahead and then offset
@ -1727,7 +1729,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
angle_t angle;
int pitch;
AActor * linetarget;
FTranslatedLineTarget t;
int actualdamage;
if (!norandom)
@ -1736,10 +1738,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
angle = self->angle + (pr_cwpunch.Random2() << 18);
if (range == 0)
range = MELEERANGE;
pitch = P_AimLineAttack (self, angle, range, &linetarget);
pitch = P_AimLineAttack (self, angle, range, &t);
// only use ammo when actually hitting something!
if ((flags & CPF_USEAMMO) && linetarget && weapon && ACTION_CALL_FROM_WEAPON())
if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return 0; // out of ammo
@ -1749,15 +1751,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
pufftype = PClass::FindActor(NAME_BulletPuff);
int puffFlags = LAF_ISMELEEATTACK | ((flags & CPF_NORANDOMPUFFZ) ? LAF_NORANDOMPUFFZ : 0);
P_LineAttack (self, angle, range, pitch, damage, NAME_Melee, pufftype, puffFlags, &linetarget, &actualdamage);
P_LineAttack (self, angle, range, pitch, damage, NAME_Melee, pufftype, puffFlags, &t, &actualdamage);
if (!linetarget)
if (!t.linetarget)
{
if (MissSound) S_Sound(self, CHAN_WEAPON, MissSound, 1, ATTN_NORM);
}
else
{
if (lifesteal && !(linetarget->flags5 & MF5_DONTDRAIN))
if (lifesteal && !(t.linetarget->flags5 & MF5_DONTDRAIN))
{
if (flags & CPF_STEALARMOR)
{
@ -1794,11 +1796,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
if (!(flags & CPF_NOTURN))
{
// turn to face target
self->angle = self->AngleTo(linetarget);
self->angle = t.SourceAngleToTarget();
}
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
if (flags & CPF_DAGGER) P_DaggerAlert (self, linetarget);
if (flags & CPF_DAGGER) P_DaggerAlert (self, t.linetarget);
}
return 0;
}
@ -1900,7 +1902,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
if (range == 0) range = 8192*FRACUNIT;
if (sparsity == 0) sparsity = 1;
AActor *linetarget;
FTranslatedLineTarget t;
fixedvec3 savedpos = self->Pos();
angle_t saved_angle = self->angle;
@ -1923,8 +1925,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
{
self->angle = self->AngleTo(self->target);
}
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, aim ? self->target : NULL);
if (linetarget == NULL && aim)
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &t, ANGLE_1*60, 0, aim ? self->target : NULL);
if (t.linetarget == NULL && aim)
{
// We probably won't hit the target, but aim at it anyway so we don't look stupid.
fixedvec2 pos = self->Vec2To(self->target);
@ -3929,6 +3931,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
angle_t an;
AActor *target, *viewport;
FTranslatedLineTarget t;
bool doCheckSight;
@ -3964,12 +3967,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
else
{
// Does the player aim at something that can be shot?
P_AimLineAttack(self, self->angle, MISSILERANGE, &target, (flags & JLOSF_NOAUTOAIM) ? ANGLE_1/2 : 0);
P_AimLineAttack(self, self->angle, MISSILERANGE, &t, (flags & JLOSF_NOAUTOAIM) ? ANGLE_1/2 : 0, ALF_PORTALRESTRICT);
if (!target)
if (!t.linetarget)
{
ACTION_RETURN_STATE(NULL);
}
target = t.linetarget;
switch (flags & (JLOSF_TARGETLOS|JLOSF_FLIPFOV))
{