1. Is it behind a wall (does the monster have line of sight) if no, then go after it, if yes, then check 2.
2. Is the player moving (therefore making noise) if yes, and after then checking distance (prob if MID or NEAR, not decided yet) then pursue it, if no then check 3.
3. Is the player's torch on (therefore giving away position, potentially) if yes, and after checking distance, then pursue, if no, then continue patrolling.
So far, and this, although possibly not complicated for some, is stuff I've not attempted before, I've done the following.
1. I've taken out the distance check, so now the monster knows where the player is at all times and pursues them, and
2. Started to build in a "is the player behind a wall, and therefore not visible to me" check. How I've attempted this is by trying to send a traceline from the monster to it's enemy (the player) and then, as a starting point, if it hits a wall, then telling the monster to ignore it's enemy. Which works, except that it doesn't, it ignores the player when it's stood right in front of it!
Anyway, my 'changes to find target:
I've obviously am not trying to achieve everything (as listed above), just the allowing player to hide behind a wall bit. I'm guessing, it's either a simple error, or I'm going about it a silly way.float() FindTarget =
{
local entity client;
local float r;
// earthQuake AI changes ------------------------
local vector test1, test2;
local entity option;
// ---------------------------------------------
// if the first spawnflag bit is set, the monster will only wake up on
// really seeing the player, not another monster getting angry
// spawnflags & 3 is a big hack, because zombie crucified used the first
// spawn flag prior to the ambush flag, and I forgot about it, so the second
// spawn flag works as well
if (sight_entity_time >= time - 0.1 && !(self.spawnflags & 3) )
{
client = sight_entity;
if (client.enemy == self.enemy)
return;
}
else
{
client = checkclient ();
if (!client)
return FALSE; // current check entity isn't in PVS
}
if (client == self.enemy)
return FALSE;
if (client.flags & FL_NOTARGET)
return FALSE;
if (client.items & IT_INVISIBILITY)
return FALSE;
//
// got one
//
self.enemy = client;
if (self.enemy.classname == "player")
// earthQuake AI changes ---------------------------------
option = self.enemy;
// see if any walls are in the way
test1 = self.origin + self.view_ofs;
test2 = option.origin + option.view_ofs;
traceline (test1, test2, FALSE, self);
if (trace_fraction != 1.0)
return FALSE;
else
FoundTarget ();
// --------------------------------------------------------------
return TRUE;
};
Thanks for reading