mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-01 17:52:13 +00:00
- ifcansee.
This commit is contained in:
parent
83b47f60b3
commit
83217ee620
1 changed files with 18 additions and 37 deletions
|
@ -1448,67 +1448,48 @@ static int ifcanshoottarget(DDukeActor *actor, int g_p, int g_x)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static bool ifcansee(int g_i, int g_p)
|
static bool ifcansee(DDukeActor* actor, int g_p)
|
||||||
{
|
{
|
||||||
auto g_sp = &sprite[g_i];
|
|
||||||
spritetype* s;
|
|
||||||
int j;
|
int j;
|
||||||
|
DDukeActor* tosee;
|
||||||
|
auto g_sp = &actor->s;
|
||||||
|
|
||||||
// select sprite for monster to target
|
// select sprite for monster to target
|
||||||
// if holoduke is on, let them target holoduke first.
|
// if holoduke is on, let them target holoduke first.
|
||||||
//
|
//
|
||||||
if (ps[g_p].holoduke_on != nullptr && !isRR())
|
if (ps[g_p].holoduke_on != nullptr && !isRR())
|
||||||
{
|
{
|
||||||
s = &ps[g_p].holoduke_on->s;
|
tosee = ps[g_p].holoduke_on;
|
||||||
j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((32 << 8) - 1)), g_sp->sectnum,
|
j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((32 << 8) - 1)), g_sp->sectnum, tosee->s.x, tosee->s.y, tosee->s.z, tosee->s.sectnum);
|
||||||
s->x, s->y, s->z, s->sectnum);
|
|
||||||
|
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
{
|
{
|
||||||
// they can't see player's holoduke
|
// they can't see player's holoduke
|
||||||
// check for player...
|
// check for player..
|
||||||
s = &sprite[ps[g_p].i];
|
tosee = ps[g_p].GetActor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else s = &sprite[ps[g_p].i]; // holoduke not on. look for player
|
else tosee = ps[g_p].GetActor(); // holoduke not on. look for player
|
||||||
|
|
||||||
// can they see player, (or player's holoduke)
|
// can they see player, (or player's holoduke)
|
||||||
j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((47 << 8))), g_sp->sectnum,
|
j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((47 << 8))), g_sp->sectnum, tosee->s.x, tosee->s.y, tosee->s.z - ((isRR()? 28 : 24) << 8), tosee->s.sectnum);
|
||||||
s->x, s->y, s->z - ((isRR()? 28 : 24) << 8), s->sectnum);
|
|
||||||
|
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
{
|
{
|
||||||
// they can't see it.
|
// search around for target player
|
||||||
|
// also modifies 'target' x&y if found.
|
||||||
// Huh?. This does nothing....
|
j = furthestcanseepoint(actor, tosee, &actor->lastvx, &actor->lastvy) != -1;
|
||||||
// (the result is always j==0....)
|
|
||||||
if ((abs(hittype[g_i].lastvx - g_sp->x) + abs(hittype[g_i].lastvy - g_sp->y)) <
|
|
||||||
(abs(hittype[g_i].lastvx - s->x) + abs(hittype[g_i].lastvy - s->y)))
|
|
||||||
j = 0;
|
|
||||||
|
|
||||||
// um yeah, this if() will always fire....
|
|
||||||
if (j == 0)
|
|
||||||
{
|
|
||||||
// search around for target player
|
|
||||||
|
|
||||||
// also modifies 'target' x&y if found..
|
|
||||||
|
|
||||||
j = furthestcanseepoint(&hittype[g_i], ps[g_p].GetActor(), &hittype[g_i].lastvx, &hittype[g_i].lastvy);
|
|
||||||
|
|
||||||
if (j == -1) j = 0;
|
|
||||||
else j = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// else, they did see it.
|
// else, they did see it.
|
||||||
// save where we were looking...
|
// save where we were looking..
|
||||||
hittype[g_i].lastvx = s->x;
|
actor->lastvx = tosee->s.x;
|
||||||
hittype[g_i].lastvy = s->y;
|
actor->lastvy = tosee->s.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == 1 && (g_sp->statnum == 1 || g_sp->statnum == 6))
|
if (j == 1 && (g_sp->statnum == STAT_ACTOR || g_sp->statnum == STAT_STANDABLE))
|
||||||
hittype[g_i].timetosleep = SLEEPTIME;
|
actor->timetosleep = SLEEPTIME;
|
||||||
|
|
||||||
return j == 1;
|
return j == 1;
|
||||||
}
|
}
|
||||||
|
@ -1556,7 +1537,7 @@ int ParseState::parse(void)
|
||||||
parseifelse(hittype[g_i].actorstayput == -1);
|
parseifelse(hittype[g_i].actorstayput == -1);
|
||||||
break;
|
break;
|
||||||
case concmd_ifcansee:
|
case concmd_ifcansee:
|
||||||
parseifelse(ifcansee(g_i, g_p));
|
parseifelse(ifcansee(g_ac, g_p));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case concmd_ifhitweapon:
|
case concmd_ifhitweapon:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue