- Fixed: It was no longer possible to talk to non-shootable NPCs. Also took

the opportunity to merge the various boolean parameters to P_AimLineAttack into one flag parameter.



SVN r2254 (trunk)
This commit is contained in:
Christoph Oelckers 2010-03-28 10:51:35 +00:00
parent 7f96531dc0
commit 1436f0a4fa
9 changed files with 64 additions and 41 deletions

View file

@ -788,8 +788,8 @@ CCMD(info)
AActor *linetarget; AActor *linetarget;
if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; if (CheckCheatmode () || players[consoleplayer].mo == NULL) return;
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, &linetarget, 0, P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE,
false, false, true); &linetarget, 0, ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART);
if (linetarget) if (linetarget)
{ {
Printf("Target=%s, Health=%d, Spawnhealth=%d\n", Printf("Target=%s, Health=%d, Spawnhealth=%d\n",
@ -923,3 +923,16 @@ CCMD(nextsecret)
Printf("no next secret map!\n"); Printf("no next secret map!\n");
} }
} }
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
CCMD(currentpos)
{
AActor *mo = players[consoleplayer].mo;
Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n",
FIXED2FLOAT(mo->x), FIXED2FLOAT(mo->y), FIXED2FLOAT(mo->z), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel);
}

View file

@ -67,7 +67,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
angle = pmo->angle+i*(ANG45/16); angle = pmo->angle+i*(ANG45/16);
slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, false, true); slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff")); P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"));
@ -91,7 +91,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
break; break;
} }
angle = pmo->angle-i*(ANG45/16); angle = pmo->angle-i*(ANG45/16);
slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, false, true); slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff")); P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"));

View file

@ -46,7 +46,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
angle = pmo->angle + i*(ANG45/32); angle = pmo->angle + i*(ANG45/32);
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, false, true); slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true);
@ -59,7 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
goto hammerdone; goto hammerdone;
} }
angle = pmo->angle-i*(ANG45/32); angle = pmo->angle-i*(ANG45/32);
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget, 0, false, true); slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
if(linetarget) if(linetarget)
{ {
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true);
@ -74,7 +74,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
} }
// didn't find any targets in meleerange, so set to throw out a hammer // didn't find any targets in meleerange, so set to throw out a hammer
angle = pmo->angle; angle = pmo->angle;
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, false, true); slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true) != NULL) if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true) != NULL)
{ {
pmo->special1 = false; pmo->special1 = false;

View file

@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1)
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
angle = self->angle+i*(ANG45/16); angle = self->angle+i*(ANG45/16);
slope = P_AimLineAttack (self, angle, MELEERANGE, &linetarget, 0, false, true); slope = P_AimLineAttack (self, angle, MELEERANGE, &linetarget, 0, ALF_CHECK3D);
if (linetarget) if (linetarget)
{ {
P_DamageMobj (linetarget, self, self, damage, NAME_Ice); P_DamageMobj (linetarget, self, self, damage, NAME_Ice);

View file

@ -9,7 +9,7 @@
#include "thingdef/thingdef.h" #include "thingdef/thingdef.h"
*/ */
bool Sys_1ed64 (AActor *self) static bool CrusaderCheckRange (AActor *self)
{ {
if (P_CheckSight (self, self->target) && self->reactiontime == 0) if (P_CheckSight (self, self->target) && self->reactiontime == 0)
{ {
@ -23,7 +23,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose)
if (self->target == NULL) if (self->target == NULL)
return; return;
if (Sys_1ed64 (self)) if (CrusaderCheckRange (self))
{ {
A_FaceTarget (self); A_FaceTarget (self);
self->angle -= ANGLE_180/16; self->angle -= ANGLE_180/16;

View file

@ -2726,7 +2726,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
self->target->x, self->target->x,
self->target->y); self->target->y);
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, false, false, false, self->target); self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, self->target);
if (linetarget == NULL) if (linetarget == NULL)
{ {
// We probably won't hit the target, but aim at it anyway so we don't look stupid. // We probably won't hit the target, but aim at it anyway so we don't look stupid.

View file

@ -407,7 +407,16 @@ void P_FindFloorCeiling (AActor *actor, bool onlymidtex = false);
bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset);
fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget = NULL, fixed_t vrange=0, bool forcenosmart=false, bool check3d = false, bool checknonshootable = false, AActor *target=NULL); fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget = NULL, fixed_t vrange=0, int flags = 0, AActor *target=NULL);
enum
{
ALF_FORCENOSMART = 1,
ALF_CHECK3D = 2,
ALF_CHECKNONSHOOTABLE = 4,
ALF_CHECKCONVERSATION = 8,
};
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, bool ismelee = false); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, bool ismelee = false);
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, bool ismelee = false); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, bool ismelee = false);
void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch);

View file

@ -2807,8 +2807,7 @@ struct aim_t
AActor * linetarget; AActor * linetarget;
AActor * thing_friend, * thing_other; AActor * thing_friend, * thing_other;
angle_t pitch_friend, pitch_other; angle_t pitch_friend, pitch_other;
bool notsmart; int flags;
bool check3d;
#ifdef _3DFLOORS #ifdef _3DFLOORS
sector_t * lastsector; sector_t * lastsector;
secplane_t * lastfloorplane; secplane_t * lastfloorplane;
@ -2819,7 +2818,7 @@ struct aim_t
bool AimTraverse3DFloors(const divline_t &trace, intercept_t * in); bool AimTraverse3DFloors(const divline_t &trace, intercept_t * in);
#endif #endif
void AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, bool checknonshootable = false, AActor *target=NULL); void AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target=NULL);
}; };
@ -2936,7 +2935,7 @@ bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in)
// //
//============================================================================ //============================================================================
void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, bool checknonshootable, AActor *target) void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target)
{ {
FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES|PT_ADDTHINGS); FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES|PT_ADDTHINGS);
intercept_t *in; intercept_t *in;
@ -2994,7 +2993,11 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
if (target != NULL && th != target) if (target != NULL && th != target)
continue; // only care about target, and you're not it continue; // only care about target, and you're not it
if (!checknonshootable) // For info CCMD, ignore stuff about GHOST and SHOOTABLE flags // If we want to start a conversation anything that has one should be
// found, regardless of other settings.
if (!(flags & ALF_CHECKCONVERSATION) || th->Conversation == NULL)
{
if (!(flags & ALF_CHECKNONSHOOTABLE)) // For info CCMD, ignore stuff about GHOST and SHOOTABLE flags
{ {
if (!(th->flags&MF_SHOOTABLE)) if (!(th->flags&MF_SHOOTABLE))
continue; // corpse or something continue; // corpse or something
@ -3008,6 +3011,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
continue; continue;
} }
} }
}
dist = FixedMul (attackrange, in->frac); dist = FixedMul (attackrange, in->frac);
#ifdef _3DFLOORS #ifdef _3DFLOORS
@ -3079,7 +3083,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
thingpitch = thingtoppitch/2 + thingbottompitch/2; thingpitch = thingtoppitch/2 + thingbottompitch/2;
if (check3d) if (flags & ALF_CHECK3D)
{ {
// We need to do a 3D distance check here because this is nearly always used in // We need to do a 3D distance check here because this is nearly always used in
// combination with P_LineAttack. P_LineAttack uses 3D distance but FPathTraverse // combination with P_LineAttack. P_LineAttack uses 3D distance but FPathTraverse
@ -3096,7 +3100,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
} }
} }
if (sv_smartaim && !notsmart) if (sv_smartaim != 0 && !(flags & ALF_FORCENOSMART))
{ {
// try to be a little smarter about what to aim at! // try to be a little smarter about what to aim at!
// In particular avoid autoaiming at friends amd barrels. // In particular avoid autoaiming at friends amd barrels.
@ -3131,11 +3135,6 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
aimpitch = thingpitch; aimpitch = thingpitch;
return; return;
} }
if (checknonshootable)
{
linetarget = th;
aimpitch = thingpitch;
}
} }
} }
@ -3145,15 +3144,16 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
// //
//============================================================================ //============================================================================
fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, bool forcenosmart, bool check3d, bool checknonshootable, AActor *target) fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange,
int flags, AActor *target)
{ {
fixed_t x2; fixed_t x2;
fixed_t y2; fixed_t y2;
aim_t aim; aim_t aim;
angle >>= ANGLETOFINESHIFT; angle >>= ANGLETOFINESHIFT;
aim.flags = flags;
aim.shootthing = t1; aim.shootthing = t1;
aim.check3d = check3d;
x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; x2 = t1->x + (distance>>FRACBITS)*finecosine[angle];
y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; y2 = t1->y + (distance>>FRACBITS)*finesine[angle];
@ -3194,7 +3194,6 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p
} }
aim.toppitch = t1->pitch - vrange; aim.toppitch = t1->pitch - vrange;
aim.bottompitch = t1->pitch + vrange; aim.bottompitch = t1->pitch + vrange;
aim.notsmart = forcenosmart;
aim.attackrange = distance; aim.attackrange = distance;
aim.linetarget = NULL; aim.linetarget = NULL;
@ -3223,7 +3222,7 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p
} }
#endif #endif
aim.AimTraverse (t1->x, t1->y, x2, y2, checknonshootable, target); aim.AimTraverse (t1->x, t1->y, x2, y2, target);
if (!aim.linetarget) if (!aim.linetarget)
{ {
@ -3239,7 +3238,9 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p
} }
} }
if (pLineTarget) if (pLineTarget)
{
*pLineTarget = aim.linetarget; *pLineTarget = aim.linetarget;
}
return aim.linetarget ? aim.aimpitch : t1->pitch; return aim.linetarget ? aim.aimpitch : t1->pitch;
} }
@ -3918,13 +3919,13 @@ bool P_TalkFacing(AActor *player)
{ {
AActor *linetarget; AActor *linetarget;
P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1*35, true); P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION);
if (linetarget == NULL) if (linetarget == NULL)
{ {
P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, true); P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION);
if (linetarget == NULL) if (linetarget == NULL)
{ {
P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, true); P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION);
if (linetarget == NULL) if (linetarget == NULL)
{ {
return false; return false;

View file

@ -1206,7 +1206,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
self->target->x, self->target->x,
self->target->y); self->target->y);
} }
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, false, false, false, aim ? self->target : NULL); self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, aim ? self->target : NULL);
if (linetarget == NULL && aim) if (linetarget == NULL && aim)
{ {
// We probably won't hit the target, but aim at it anyway so we don't look stupid. // We probably won't hit the target, but aim at it anyway so we don't look stupid.