mirror of
https://git.code.sf.net/p/quake/game-source
synced 2024-11-25 13:21:30 +00:00
186 lines
3.9 KiB
C++
186 lines
3.9 KiB
C++
|
void() movetarget_f;
|
||
|
void() t_movetarget;
|
||
|
//void() knight_walk1;
|
||
|
//void() knight_bow6;
|
||
|
//void() knight_bow1;
|
||
|
void(entity etemp, entity stemp, entity stemp, float dmg) T_Damage;
|
||
|
/*
|
||
|
|
||
|
.enemy
|
||
|
Will be world if not currently angry at anyone.
|
||
|
|
||
|
.movetarget
|
||
|
The next path spot to walk toward. If .enemy, ignore .movetarget.
|
||
|
When an enemy is killed, the monster will try to return to it's path.
|
||
|
|
||
|
.huntt_ime
|
||
|
Set to time + something when the player is in sight, but movement straight for
|
||
|
him is blocked. This causes the monster to use wall following code for
|
||
|
movement direction instead of sighting on the player.
|
||
|
|
||
|
.ideal_yaw
|
||
|
A yaw angle of the intended direction, which will be turned towards at up
|
||
|
to 45 deg / state. If the enemy is in view and hunt_time is not active,
|
||
|
this will be the exact line towards the enemy.
|
||
|
|
||
|
.pausetime
|
||
|
A monster will leave it's stand state and head towards it's .movetarget when
|
||
|
time > .pausetime.
|
||
|
|
||
|
walkmove(angle, speed) primitive is all or nothing
|
||
|
*/
|
||
|
|
||
|
|
||
|
//
|
||
|
// globals
|
||
|
//
|
||
|
float current_yaw;
|
||
|
|
||
|
//
|
||
|
// when a monster becomes angry at a player, that monster will be used
|
||
|
// as the sight target the next frame so that monsters near that one
|
||
|
// will wake up even if they wouldn't have noticed the player
|
||
|
//
|
||
|
entity sight_entity;
|
||
|
float sight_entity_time;
|
||
|
|
||
|
float(float v) anglemod =
|
||
|
{
|
||
|
while (v >= 360)
|
||
|
v = v - 360;
|
||
|
while (v < 0)
|
||
|
v = v + 360;
|
||
|
return v;
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
==============================================================================
|
||
|
|
||
|
MOVETARGET CODE
|
||
|
|
||
|
The angle of the movetarget effects standing and bowing direction, but has no effect on movement, which allways heads to the next target.
|
||
|
|
||
|
targetname
|
||
|
must be present. The name of this movetarget.
|
||
|
|
||
|
target
|
||
|
the next spot to move to. If not present, stop here for good.
|
||
|
|
||
|
pausetime
|
||
|
The number of seconds to spend standing or bowing for path_stand or path_bow
|
||
|
|
||
|
==============================================================================
|
||
|
*/
|
||
|
|
||
|
|
||
|
void() movetarget_f =
|
||
|
{
|
||
|
if (!self.targetname)
|
||
|
objerror ("monster_movetarget: no targetname");
|
||
|
|
||
|
self.solid = SOLID_TRIGGER;
|
||
|
self.touch = t_movetarget;
|
||
|
setsize (self, '-8 -8 -8', '8 8 8');
|
||
|
|
||
|
};
|
||
|
|
||
|
//*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8)
|
||
|
//Monsters will continue walking towards the next target corner.
|
||
|
|
||
|
void() path_corner =
|
||
|
{
|
||
|
movetarget_f ();
|
||
|
};
|
||
|
|
||
|
|
||
|
/*
|
||
|
=============
|
||
|
t_movetarget
|
||
|
|
||
|
Something has bumped into a movetarget. If it is a monster
|
||
|
moving towards it, change the next destination and continue.
|
||
|
==============
|
||
|
*/
|
||
|
void() t_movetarget =
|
||
|
{
|
||
|
local entity temp;
|
||
|
|
||
|
if (other.movetarget != self)
|
||
|
return;
|
||
|
|
||
|
if (other.enemy)
|
||
|
return; // fighting, not following a path
|
||
|
|
||
|
temp = self;
|
||
|
self = other;
|
||
|
other = temp;
|
||
|
|
||
|
//if (self.classname == "monster_ogre")
|
||
|
// sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound
|
||
|
|
||
|
//dprint ("t_movetarget\n");
|
||
|
self.goalentity = self.movetarget = find (world, targetname, other.target);
|
||
|
self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
|
||
|
if (!self.movetarget)
|
||
|
{
|
||
|
self.pausetime = time + 999999;
|
||
|
self.th_stand ();
|
||
|
return;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
//============================================================================
|
||
|
|
||
|
|
||
|
/*
|
||
|
=============
|
||
|
visible
|
||
|
|
||
|
returns 1 if the entity is visible to self, even if not infront ()
|
||
|
=============
|
||
|
*/
|
||
|
float (entity targ) visible =
|
||
|
{
|
||
|
local vector spot1, spot2;
|
||
|
|
||
|
spot1 = self.origin + self.view_ofs;
|
||
|
spot2 = targ.origin + targ.view_ofs;
|
||
|
traceline (spot1, spot2, TRUE, self); // see through other monsters
|
||
|
|
||
|
if (trace_inopen && trace_inwater)
|
||
|
return FALSE; // sight line crossed contents
|
||
|
|
||
|
if (trace_fraction == 1)
|
||
|
return TRUE;
|
||
|
return FALSE;
|
||
|
};
|
||
|
|
||
|
|
||
|
/*
|
||
|
=============
|
||
|
infront
|
||
|
|
||
|
returns 1 if the entity is in front (in sight) of self
|
||
|
=============
|
||
|
*/
|
||
|
float(entity targ) infront =
|
||
|
{
|
||
|
local vector vec;
|
||
|
local float dot;
|
||
|
|
||
|
makevectors (self.angles);
|
||
|
vec = normalize (targ.origin - self.origin);
|
||
|
dot = vec * v_forward;
|
||
|
|
||
|
if ( dot > 0.3)
|
||
|
{
|
||
|
return TRUE;
|
||
|
}
|
||
|
return FALSE;
|
||
|
};
|
||
|
|
||
|
|
||
|
//============================================================================
|