mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 23:54:35 +00:00
- Split conversation initiation out of P_UseTraverse() and into a separate function. It no
longer piggy-backs off of Hexen's puzzle item traversal but instead works like Strife, using P_AimLineAttack() to find something to talk to and includes some slight left and right "autoaim". I can think of a few consequences of this: * Using puzzle items on actors has been restored to its original range of 64. * Since talking now depends on P_AimLineAttack() instead of a line use traversal, you can probably set up situations where you can talk to somebody that you couldn't talk to before because some special line was in the way. * You don't need to stick a guard flush against the wall to block players from using a switch behind them, because now the autoaim will get the player. SVN r2102 (trunk)
This commit is contained in:
parent
4b65749f92
commit
870628dda5
3 changed files with 55 additions and 35 deletions
|
@ -52,6 +52,7 @@
|
||||||
//#define GRAVITY FRACUNIT
|
//#define GRAVITY FRACUNIT
|
||||||
#define MAXMOVE (30*FRACUNIT)
|
#define MAXMOVE (30*FRACUNIT)
|
||||||
|
|
||||||
|
#define TALKRANGE (128*FRACUNIT)
|
||||||
#define USERANGE (64*FRACUNIT)
|
#define USERANGE (64*FRACUNIT)
|
||||||
#define MELEERANGE (64*FRACUNIT)
|
#define MELEERANGE (64*FRACUNIT)
|
||||||
#define MISSILERANGE (32*64*FRACUNIT)
|
#define MISSILERANGE (32*64*FRACUNIT)
|
||||||
|
@ -390,6 +391,7 @@ bool P_BounceWall (AActor *mo);
|
||||||
bool P_BounceActor (AActor *mo, AActor * BlockingMobj);
|
bool P_BounceActor (AActor *mo, AActor * BlockingMobj);
|
||||||
bool P_CheckSight (const AActor* t1, const AActor* t2, int flags=0);
|
bool P_CheckSight (const AActor* t1, const AActor* t2, int flags=0);
|
||||||
void P_ResetSightCounters (bool full);
|
void P_ResetSightCounters (bool full);
|
||||||
|
bool P_TalkFacing (AActor *player);
|
||||||
void P_UseLines (player_t* player);
|
void P_UseLines (player_t* player);
|
||||||
bool P_UsePuzzleItem (AActor *actor, int itemType);
|
bool P_UsePuzzleItem (AActor *actor, int itemType);
|
||||||
void P_FindFloorCeiling (AActor *actor, bool onlymidtex = false);
|
void P_FindFloorCeiling (AActor *actor, bool onlymidtex = false);
|
||||||
|
|
|
@ -3905,6 +3905,52 @@ void P_AimCamera (AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// P_TalkFacing
|
||||||
|
//
|
||||||
|
// Looks for something within 5.625 degrees left or right of the player
|
||||||
|
// to talk to.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
bool P_TalkFacing(AActor *player)
|
||||||
|
{
|
||||||
|
AActor *linetarget;
|
||||||
|
|
||||||
|
P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1*35, true);
|
||||||
|
if (linetarget == NULL)
|
||||||
|
{
|
||||||
|
P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, true);
|
||||||
|
if (linetarget == NULL)
|
||||||
|
{
|
||||||
|
P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, true);
|
||||||
|
if (linetarget == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Dead things can't talk.
|
||||||
|
if (linetarget->health <= 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Fighting things don't talk either.
|
||||||
|
if (linetarget->flags4 & MF4_INCOMBAT)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (linetarget->Conversation != NULL)
|
||||||
|
{
|
||||||
|
// Give the NPC a chance to play a brief animation
|
||||||
|
linetarget->ConversationAnimation (0);
|
||||||
|
P_StartConversation (linetarget, player, true, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// USE LINES
|
// USE LINES
|
||||||
|
@ -3921,7 +3967,8 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline
|
||||||
// [RH] Check for things to talk with or use a puzzle item on
|
// [RH] Check for things to talk with or use a puzzle item on
|
||||||
if (!in->isaline)
|
if (!in->isaline)
|
||||||
{
|
{
|
||||||
if (usething==in->d.thing) continue;
|
if (usething == in->d.thing)
|
||||||
|
continue;
|
||||||
// Check thing
|
// Check thing
|
||||||
|
|
||||||
// Check for puzzle item use or USESPECIAL flag
|
// Check for puzzle item use or USESPECIAL flag
|
||||||
|
@ -3931,38 +3978,10 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline
|
||||||
if (P_ActivateThingSpecial(in->d.thing, usething))
|
if (P_ActivateThingSpecial(in->d.thing, usething))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Dead things can't talk.
|
|
||||||
if (in->d.thing->health <= 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Fighting things don't talk either.
|
|
||||||
if (in->d.thing->flags4 & MF4_INCOMBAT)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (in->d.thing->Conversation != NULL)
|
|
||||||
{
|
|
||||||
// Give the NPC a chance to play a brief animation
|
|
||||||
in->d.thing->ConversationAnimation (0);
|
|
||||||
P_StartConversation (in->d.thing, usething, true, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLineOpening open;
|
FLineOpening open;
|
||||||
// [RH] The range passed to P_PathTraverse was doubled so that it could
|
|
||||||
// find things up to 128 units away (for Strife), but it should still reject
|
|
||||||
// lines further than 64 units away.
|
|
||||||
if (in->frac > FRACUNIT/2)
|
|
||||||
{
|
|
||||||
// don't pass usething here. It will not do what might be expected!
|
|
||||||
P_LineOpening (open, NULL, in->d.line, it.Trace().x + FixedMul (it.Trace().dx, in->frac),
|
|
||||||
it.Trace().y + FixedMul (it.Trace().dy, in->frac));
|
|
||||||
if (open.range <= 0) return false;
|
|
||||||
else continue;
|
|
||||||
}
|
|
||||||
if (in->d.line->special == 0 || !(in->d.line->activation & (SPAC_Use|SPAC_UseThrough)))
|
if (in->d.line->special == 0 || !(in->d.line->activation & (SPAC_Use|SPAC_UseThrough)))
|
||||||
{
|
{
|
||||||
blocked:
|
blocked:
|
||||||
|
@ -4082,7 +4101,6 @@ void P_UseLines (player_t *player)
|
||||||
{
|
{
|
||||||
angle_t angle;
|
angle_t angle;
|
||||||
fixed_t x1, y1;
|
fixed_t x1, y1;
|
||||||
fixed_t x2, y2;
|
|
||||||
bool foundline;
|
bool foundline;
|
||||||
|
|
||||||
foundline = false;
|
foundline = false;
|
||||||
|
@ -4091,16 +4109,13 @@ void P_UseLines (player_t *player)
|
||||||
x1 = player->mo->x + (USERANGE>>FRACBITS)*finecosine[angle];
|
x1 = player->mo->x + (USERANGE>>FRACBITS)*finecosine[angle];
|
||||||
y1 = player->mo->y + (USERANGE>>FRACBITS)*finesine[angle];
|
y1 = player->mo->y + (USERANGE>>FRACBITS)*finesine[angle];
|
||||||
|
|
||||||
x2 = player->mo->x + (USERANGE>>FRACBITS)*finecosine[angle]*2;
|
|
||||||
y2 = player->mo->y + (USERANGE>>FRACBITS)*finesine[angle]*2;
|
|
||||||
|
|
||||||
// old code:
|
// old code:
|
||||||
//
|
//
|
||||||
// P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse );
|
// P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse );
|
||||||
//
|
//
|
||||||
// This added test makes the "oof" sound work on 2s lines -- killough:
|
// This added test makes the "oof" sound work on 2s lines -- killough:
|
||||||
|
|
||||||
if (!P_UseTraverse (player->mo, x2, y2, foundline))
|
if (!P_UseTraverse (player->mo, x1, y1, foundline))
|
||||||
{ // [RH] Give sector a chance to eat the use
|
{ // [RH] Give sector a chance to eat the use
|
||||||
sector_t *sec = player->mo->Sector;
|
sector_t *sec = player->mo->Sector;
|
||||||
int spac = SECSPAC_Use;
|
int spac = SECSPAC_Use;
|
||||||
|
|
|
@ -2293,7 +2293,10 @@ void P_PlayerThink (player_t *player)
|
||||||
if (!player->usedown)
|
if (!player->usedown)
|
||||||
{
|
{
|
||||||
player->usedown = true;
|
player->usedown = true;
|
||||||
P_UseLines (player);
|
if (!P_TalkFacing(player->mo))
|
||||||
|
{
|
||||||
|
P_UseLines(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue