mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- Added A_CheckSightOrRange, with changes.
SVN r2179 (trunk)
This commit is contained in:
parent
5523140890
commit
8ecafcc15a
2 changed files with 55 additions and 0 deletions
|
@ -1897,7 +1897,60 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight)
|
||||||
}
|
}
|
||||||
|
|
||||||
ACTION_JUMP(jump);
|
ACTION_JUMP(jump);
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// A_CheckSightOrRange
|
||||||
|
// Jumps if this actor is out of range of all players *and* out of sight.
|
||||||
|
// Useful for maps with many multi-actor special effects.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange)
|
||||||
|
{
|
||||||
|
ACTION_PARAM_START(2);
|
||||||
|
double range = EvalExpressionF(ParameterIndex+0, self);
|
||||||
|
ACTION_PARAM_STATE(jump, 1);
|
||||||
|
|
||||||
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
||||||
|
|
||||||
|
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
|
||||||
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
||||||
|
{
|
||||||
|
if (playeringame[i])
|
||||||
|
{
|
||||||
|
AActor *camera = players[i].camera;
|
||||||
|
|
||||||
|
// Check distance first, since it's cheaper than checking sight.
|
||||||
|
double dx = self->x - camera->x;
|
||||||
|
double dy = self->y - camera->y;
|
||||||
|
double dz;
|
||||||
|
fixed_t eyez = (camera->z + camera->height - (camera->height>>2)); // same eye height as P_CheckSight
|
||||||
|
if (eyez > self->z + self->height)
|
||||||
|
{
|
||||||
|
dz = self->z + self->height - eyez;
|
||||||
|
}
|
||||||
|
else if (eyez < self->z)
|
||||||
|
{
|
||||||
|
dz = self->z - eyez;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dz = 0;
|
||||||
|
}
|
||||||
|
if ((dx*dx) + (dy*dy) + (dz*dz) <= range)
|
||||||
|
{ // Within range
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now check LOS.
|
||||||
|
if (P_CheckSight(camera, self, true))
|
||||||
|
{ // Visible
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ACTION_JUMP(jump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,8 @@ ACTOR Actor native //: Thinker
|
||||||
action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
|
action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
|
||||||
action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
|
action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
|
||||||
|
|
||||||
|
action native A_CheckSightOrRange(float distance, state label);
|
||||||
|
|
||||||
States
|
States
|
||||||
{
|
{
|
||||||
Spawn:
|
Spawn:
|
||||||
|
|
Loading…
Reference in a new issue