922 lines
19 KiB
C++
922 lines
19 KiB
C++
//EW Prototypes
|
|
void() search_for_bots;
|
|
void() monster_search_for_items;
|
|
void() monster_grab_items;
|
|
void() AmBurning;
|
|
void() AmDead;
|
|
|
|
//outrider and scout alert sounds
|
|
void() outrider_alertsound;
|
|
//wraith alert sounds
|
|
void() wraith_alertsound;
|
|
//ew ai enhancements
|
|
void(float gspeed, float stime) adjust_speed;
|
|
void(float gtype, float gtime) adjust_gravity;
|
|
void() ai_dodge;
|
|
void() ai_summon;
|
|
void() search_for_boss;
|
|
void() check_for_liquid;
|
|
|
|
void() movetarget_f;
|
|
void() t_movetarget;
|
|
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;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
/*
|
|
=============
|
|
range
|
|
|
|
returns the range catagorization of an entity reletive to self
|
|
0 melee range, will become hostile even if back is turned
|
|
1 visibility and infront, or visibility and show hostile
|
|
2 infront and show hostile
|
|
3 only triggered by damage
|
|
=============
|
|
*/
|
|
float(entity targ) range =
|
|
{
|
|
local vector spot1, spot2;
|
|
local float r;
|
|
spot1 = self.origin + self.view_ofs;
|
|
spot2 = targ.origin + targ.view_ofs;
|
|
|
|
r = vlen (spot1 - spot2);
|
|
if (r < 120)
|
|
return RANGE_MELEE;
|
|
if (r < 500)
|
|
return RANGE_NEAR;
|
|
if (r < 1000)
|
|
return RANGE_MID;
|
|
return RANGE_FAR;
|
|
};
|
|
|
|
/*
|
|
=============
|
|
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;
|
|
};
|
|
|
|
|
|
//============================================================================
|
|
|
|
/*
|
|
===========
|
|
ChangeYaw
|
|
|
|
Turns towards self.ideal_yaw at self.yaw_speed
|
|
Sets the global variable current_yaw
|
|
Called every 0.1 sec by monsters
|
|
============
|
|
*/
|
|
/*
|
|
|
|
void() ChangeYaw =
|
|
{
|
|
local float ideal, move;
|
|
|
|
//current_yaw = self.ideal_yaw;
|
|
// mod down the current angle
|
|
current_yaw = anglemod( self.angles_y );
|
|
ideal = self.ideal_yaw;
|
|
|
|
if (current_yaw == ideal)
|
|
return;
|
|
|
|
move = ideal - current_yaw;
|
|
if (ideal > current_yaw)
|
|
{
|
|
if (move > 180)
|
|
move = move - 360;
|
|
}
|
|
else
|
|
{
|
|
if (move < -180)
|
|
move = move + 360;
|
|
}
|
|
if (move > 0)
|
|
{
|
|
if (move > self.yaw_speed)
|
|
move = self.yaw_speed;
|
|
}
|
|
else
|
|
{
|
|
if (move < 0-self.yaw_speed )
|
|
move = 0-self.yaw_speed;
|
|
}
|
|
|
|
current_yaw = anglemod (current_yaw + move);
|
|
|
|
self.angles_y = current_yaw;
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
//============================================================================
|
|
|
|
void() HuntTarget =
|
|
{
|
|
self.goalentity = self.enemy;
|
|
if (self.classname == "monster_agath")
|
|
self.think = self.th_emerge;
|
|
else
|
|
self.think = self.th_run;
|
|
self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin);
|
|
self.nextthink = time + 0.1;
|
|
SUB_AttackFinished (1); // wait a while before first attack
|
|
};
|
|
|
|
void() SightSound =
|
|
{
|
|
local float rsnd;
|
|
|
|
//ew sight sounds
|
|
if (self.classname == "monster_agath")
|
|
sound (self, CHAN_VOICE, "enemy/agath/idle2.wav", 1, ATTN_NORM);
|
|
else if (self.classname == "monster_apprentice" || self.classname == "monster_necromancer")
|
|
sound (self, CHAN_VOICE, "enemy/apprent/sight.wav", 1, ATTN_NORM);
|
|
else if (self.classname == "monster_captain")
|
|
{
|
|
if (random() <= 0.8)
|
|
sound (self, CHAN_VOICE, "enemy/captain/alert1.wav", 1, ATTN_NORM);
|
|
else
|
|
sound (self, CHAN_VOICE, "enemy/captain/alert2.wav", 1, ATTN_NORM);
|
|
}
|
|
else if (self.classname == "monster_carnivore")
|
|
sound (self, CHAN_VOICE, "enemy/carnivean/alert.wav", 1, ATTN_NORM);
|
|
else if (self.classname == "monster_dweller")
|
|
sound (self, CHAN_VOICE, "enemy/dweller/alert1.wav", 1, ATTN_NORM);
|
|
else if (self.classname == "monster_hhound")
|
|
sound (self, CHAN_VOICE, "enemy/hhound/rage.wav", 1, ATTN_NORM);
|
|
else if (self.classname == "monster_merca" ||
|
|
self.classname == "monster_mercs" ||
|
|
self.classname == "monster_mercx")
|
|
{
|
|
if (random() <= 0.5)
|
|
sound (self, CHAN_VOICE, "enemy/mercenary/alert1.wav", 1, ATTN_NORM);
|
|
else
|
|
sound (self, CHAN_VOICE, "enemy/mercenary/alert2.wav", 1, ATTN_NORM);
|
|
}
|
|
else if (self.classname == "monster_outrider" || self.classname == "monster_scout")
|
|
outrider_alertsound();
|
|
else if (self.classname == "monster_wraith")
|
|
wraith_alertsound();
|
|
};
|
|
|
|
void() FoundTarget =
|
|
{
|
|
if (self.enemy.classname == "player")
|
|
{ // let other monsters see this monster for a while
|
|
sight_entity = self;
|
|
sight_entity_time = time;
|
|
}
|
|
|
|
self.show_hostile = time + 1; // wake up other monsters
|
|
|
|
SightSound ();
|
|
HuntTarget ();
|
|
};
|
|
|
|
/*
|
|
===========
|
|
FindTarget
|
|
|
|
Self is currently not attacking anything, so try to find a target
|
|
|
|
Returns TRUE if an enemy was sighted
|
|
|
|
When a player fires a missile, the point of impact becomes a fakeplayer so
|
|
that monsters that see the impact will respond as if they had seen the
|
|
player.
|
|
|
|
To avoid spending too much time, only a single client (or fakeclient) is
|
|
checked each frame. This means multi player games will have slightly
|
|
slower noticing monsters.
|
|
============
|
|
*/
|
|
float() FindTarget =
|
|
{
|
|
local entity client;
|
|
local float r;
|
|
|
|
// 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;
|
|
|
|
r = range (client);
|
|
if (r == RANGE_FAR)
|
|
return FALSE;
|
|
|
|
if (!visible (client))
|
|
return FALSE;
|
|
|
|
if (r == RANGE_NEAR)
|
|
{
|
|
if (client.show_hostile < time && !infront (client))
|
|
return FALSE;
|
|
}
|
|
else if (r == RANGE_MID)
|
|
{
|
|
if ( /* client.show_hostile < time || */ !infront (client))
|
|
return FALSE;
|
|
}
|
|
|
|
//
|
|
// got one
|
|
//
|
|
self.enemy = client;
|
|
if (self.enemy.classname != "player")
|
|
{
|
|
self.enemy = self.enemy.enemy;
|
|
if (self.enemy.classname != "player")
|
|
{
|
|
self.enemy = world;
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
FoundTarget ();
|
|
|
|
return TRUE;
|
|
};
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
float() check_for_ledge =
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Return values:
|
|
// 0 = NOMOVE
|
|
// 1 = MOVE
|
|
{
|
|
local float contents;
|
|
local vector start, end;
|
|
|
|
//set up angles stuff
|
|
self.v_angle = self.angles;
|
|
makevectors (self.angles);
|
|
|
|
// need to check for ledges to keep him from moving over them
|
|
|
|
if (!(self.flags & FL_ONGROUND))
|
|
return(0);
|
|
|
|
// SkinSki stair decending code - START
|
|
|
|
start = self.origin - '0 0 24';
|
|
end = start + v_forward * 96;
|
|
|
|
traceline (start, end, TRUE, self);
|
|
|
|
start = trace_endpos;
|
|
end = start - '0 0 50'; //50 units down
|
|
traceline (start, end, TRUE, self);
|
|
|
|
if (trace_fraction != 1)
|
|
return(1); //MOVE
|
|
else
|
|
return(0); // NOMOVE
|
|
// SkinSki stair decending code - END
|
|
|
|
/*
|
|
// Where the monster's feet are now (roughly)
|
|
start = self.origin - '0 0 24';
|
|
end = start + (v_forward * 60) - '0 0 60';
|
|
|
|
// Check 60 Quake units in front of the monster and 60 units down at foot height
|
|
traceline (start, end, TRUE, self);
|
|
|
|
// If there's a wall or obstacle, return MOVE
|
|
if (trace_fraction != 1.0)
|
|
return (1); //MOVE
|
|
else
|
|
return (0); //NOMOVE
|
|
|
|
//was here
|
|
start = end;
|
|
end = start - '0 0 256'; //256 units down
|
|
|
|
// Now look down and see how far we drop and what's there (MAX 256 units)
|
|
traceline (start, end, TRUE, self);
|
|
|
|
contents = pointcontents (trace_endpos);
|
|
// If it's LAVA, SLIME, WATER or a long way down and no ledge to jump to, return DANGER
|
|
if ( (contents == CONTENT_LAVA) || (contents == CONTENT_SLIME) || (contents == CONTENT_WATER) )
|
|
return (0); // NOMOVE
|
|
|
|
// SkinSki stair decending code - START
|
|
|
|
start = self.origin - '0 0 24';
|
|
end = start + v_forward * 48;
|
|
|
|
traceline (start, end, TRUE, self);
|
|
|
|
start = trace_endpos;
|
|
end = start - '0 0 50'; //50 units down
|
|
traceline (start, end, TRUE, self);
|
|
|
|
if (trace_fraction != 1)
|
|
return(1); //MOVE
|
|
// SkinSki stair decending code - END
|
|
|
|
return (0); // NOMOVE
|
|
*/
|
|
};
|
|
|
|
void(float dist) velocity_move =
|
|
{
|
|
//Variable Velocity Movement Code
|
|
|
|
//Check for ledge
|
|
if (check_for_ledge() == 1)
|
|
{
|
|
//its safe to use velocity movement code
|
|
movetogoal(dist);
|
|
makevectors(self.angles);
|
|
self.flags = self.flags - (self.flags & FL_ONGROUND);
|
|
self.velocity = v_forward * self.speed;
|
|
}
|
|
else //use normal movetogoal because quake engine won't let monster walk over ledge
|
|
movetogoal(dist);
|
|
};
|
|
|
|
//=============================================================================
|
|
|
|
void(float dist) ai_forward =
|
|
{
|
|
walkmove (self.angles_y, dist);
|
|
};
|
|
|
|
void(float dist) ai_back =
|
|
{
|
|
walkmove ( (self.angles_y+180), dist);
|
|
};
|
|
|
|
|
|
/*
|
|
=============
|
|
ai_pain
|
|
|
|
stagger back a bit
|
|
=============
|
|
*/
|
|
void(float dist) ai_pain =
|
|
{
|
|
ai_back (dist);
|
|
/*
|
|
local float away;
|
|
|
|
away = anglemod (vectoyaw (self.origin - self.enemy.origin) + 180*(random()- 0.5) );
|
|
|
|
walkmove (away, dist);
|
|
*/
|
|
};
|
|
|
|
/*
|
|
=============
|
|
ai_painforward
|
|
|
|
stagger back a bit
|
|
=============
|
|
*/
|
|
void(float dist) ai_painforward =
|
|
{
|
|
walkmove (self.ideal_yaw, dist);
|
|
};
|
|
|
|
/*
|
|
=============
|
|
ai_walk
|
|
|
|
The monster is walking it's beat
|
|
=============
|
|
*/
|
|
void(float dist) ai_walk =
|
|
{
|
|
local vector mtemp;
|
|
|
|
movedist = dist;
|
|
|
|
// see if we are dead
|
|
AmDead();
|
|
|
|
// check for noticing a player
|
|
if (FindTarget ())
|
|
return;
|
|
|
|
// check for bots
|
|
search_for_bots();
|
|
|
|
// see if we are on fire
|
|
AmBurning();
|
|
|
|
// check for liquid
|
|
check_for_liquid();
|
|
|
|
// if we are playing Flood Co-op then do some roaming
|
|
if (cvar("deathmatch") == 1)
|
|
{
|
|
monster_search_for_items();
|
|
monster_grab_items();
|
|
}
|
|
|
|
// Variable Velocity Movement System
|
|
velocity_move(dist);
|
|
};
|
|
|
|
|
|
/*
|
|
=============
|
|
ai_stand
|
|
|
|
The monster is staying in one place for a while, with slight angle turns
|
|
=============
|
|
*/
|
|
void() ai_stand =
|
|
{
|
|
// see if we are dead
|
|
AmDead();
|
|
|
|
if (self.classname == "monster_bossf1" && sight_wait == 1)
|
|
{
|
|
if (time > self.pausetime)
|
|
{
|
|
self.nextthink = time + 0.1;
|
|
if (self.enemy == world)
|
|
self.think = self.th_walk;
|
|
else
|
|
self.think = self.th_run;
|
|
return;
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
|
|
if (FindTarget ())
|
|
return;
|
|
|
|
// check for bots
|
|
search_for_bots();
|
|
|
|
if (time > self.pausetime)
|
|
{
|
|
self.th_walk ();
|
|
return;
|
|
}
|
|
|
|
// see if we are on fire
|
|
AmBurning();
|
|
|
|
// check for liquid
|
|
check_for_liquid();
|
|
};
|
|
|
|
/*
|
|
=============
|
|
ai_turn
|
|
|
|
don't move, but turn towards ideal_yaw
|
|
=============
|
|
*/
|
|
void() ai_turn =
|
|
{
|
|
if (FindTarget ())
|
|
return;
|
|
|
|
ChangeYaw ();
|
|
};
|
|
|
|
//=============================================================================
|
|
|
|
/*
|
|
=============
|
|
ChooseTurn
|
|
=============
|
|
*/
|
|
void(vector dest3) ChooseTurn =
|
|
{
|
|
local vector dir, newdir;
|
|
|
|
dir = self.origin - dest3;
|
|
|
|
newdir_x = trace_plane_normal_y;
|
|
newdir_y = 0 - trace_plane_normal_x;
|
|
newdir_z = 0;
|
|
|
|
if (dir * newdir > 0)
|
|
{
|
|
dir_x = 0 - trace_plane_normal_y;
|
|
dir_y = trace_plane_normal_x;
|
|
}
|
|
else
|
|
{
|
|
dir_x = trace_plane_normal_y;
|
|
dir_y = 0 - trace_plane_normal_x;
|
|
}
|
|
|
|
dir_z = 0;
|
|
self.ideal_yaw = vectoyaw(dir);
|
|
};
|
|
|
|
/*
|
|
============
|
|
FacingIdeal
|
|
|
|
============
|
|
*/
|
|
float() FacingIdeal =
|
|
{
|
|
local float delta;
|
|
|
|
delta = anglemod(self.angles_y - self.ideal_yaw);
|
|
if (delta > 45 && delta < 315)
|
|
return FALSE;
|
|
return TRUE;
|
|
};
|
|
|
|
|
|
//=============================================================================
|
|
|
|
float() ApprenticeCheckAttack;
|
|
float() hhoundCheckAttack;
|
|
|
|
float() CheckAnyAttack =
|
|
{
|
|
if (!enemy_vis)
|
|
return;
|
|
if (self.classname == "monster_outrider")
|
|
return OutriderCheckAttack ();
|
|
if (self.classname == "monster_carnivore")
|
|
return CarnivoreCheckAttack ();
|
|
if (self.classname == "monster_agath")
|
|
return AgathCheckAttack ();
|
|
if (self.classname == "monster_teneb")
|
|
return tenebCheckAttack ();
|
|
if (self.classname == "monster_hhound")
|
|
return hhoundCheckAttack ();
|
|
if (self.classname == "monster_apprentice" || self.classname == "monster_necromancer")
|
|
return ApprenticeCheckAttack ();
|
|
return CheckAttack ();
|
|
};
|
|
|
|
|
|
/*
|
|
=============
|
|
ai_run_melee
|
|
|
|
Turn and close until within an angle to launch a melee attack
|
|
=============
|
|
*/
|
|
void() ai_run_melee =
|
|
{
|
|
self.ideal_yaw = enemy_yaw;
|
|
ChangeYaw ();
|
|
|
|
if (FacingIdeal())
|
|
{
|
|
self.th_melee ();
|
|
self.attack_state = AS_STRAIGHT;
|
|
}
|
|
};
|
|
|
|
|
|
/*
|
|
=============
|
|
ai_run_missile
|
|
|
|
Turn in place until within an angle to launch a missile attack
|
|
=============
|
|
*/
|
|
void() ai_run_missile =
|
|
{
|
|
self.ideal_yaw = enemy_yaw;
|
|
ChangeYaw ();
|
|
if (FacingIdeal())
|
|
{
|
|
self.th_missile ();
|
|
self.attack_state = AS_STRAIGHT;
|
|
}
|
|
};
|
|
|
|
|
|
/*
|
|
=============
|
|
ai_run_slide
|
|
|
|
Strafe sideways, but stay at aproximately the same range
|
|
=============
|
|
*/
|
|
void() ai_run_slide =
|
|
{
|
|
local float ofs;
|
|
|
|
self.ideal_yaw = enemy_yaw;
|
|
ChangeYaw ();
|
|
if (self.lefty)
|
|
ofs = 90;
|
|
else
|
|
ofs = -90;
|
|
|
|
if (walkmove (self.ideal_yaw + ofs, movedist))
|
|
return;
|
|
|
|
self.lefty = 1 - self.lefty;
|
|
|
|
walkmove (self.ideal_yaw - ofs, movedist);
|
|
};
|
|
|
|
|
|
/*
|
|
=============
|
|
ai_run
|
|
|
|
The monster has an enemy it is trying to kill
|
|
=============
|
|
*/
|
|
void(float dist) ai_run =
|
|
{
|
|
local vector delta;
|
|
local float axis;
|
|
local float direct, ang_rint, ang_floor, ang_ceil;
|
|
|
|
// see if we are dead
|
|
AmDead();
|
|
|
|
// see if we are on fire
|
|
AmBurning();
|
|
|
|
// check for liquid
|
|
check_for_liquid();
|
|
|
|
movedist = dist;
|
|
// see if the enemy is dead
|
|
if (self.enemy.health <= 0)
|
|
{
|
|
self.enemy = world;
|
|
|
|
//make sure game speed is set back to normal
|
|
adjust_speed(0,0);
|
|
|
|
// FIXME: look all around for other targets
|
|
if (self.oldenemy.health > 0)
|
|
{
|
|
self.enemy = self.oldenemy;
|
|
HuntTarget ();
|
|
}
|
|
else
|
|
{
|
|
if (self.movetarget)
|
|
self.th_walk ();
|
|
else
|
|
self.th_stand ();
|
|
return;
|
|
}
|
|
}
|
|
|
|
self.show_hostile = time + 1; // wake up other monsters
|
|
|
|
// see if its appropriate to dodge
|
|
ai_dodge(dist);
|
|
|
|
// see if its appropriate to summon
|
|
ai_summon();
|
|
|
|
// if i'm a shadow clone then I need to see if my boss is still alive
|
|
if (self.classname == "monster_shadowclone")
|
|
search_for_boss();
|
|
|
|
// check knowledge of enemy
|
|
enemy_vis = visible(self.enemy);
|
|
if (enemy_vis)
|
|
self.search_time = time + 5;
|
|
|
|
// look for other coop players
|
|
if (coop && self.search_time < time)
|
|
{
|
|
if (FindTarget ())
|
|
return;
|
|
}
|
|
|
|
enemy_infront = infront(self.enemy);
|
|
enemy_range = range(self.enemy);
|
|
enemy_yaw = vectoyaw(self.enemy.origin - self.origin);
|
|
|
|
if (self.attack_state == AS_MISSILE)
|
|
{
|
|
//dprint ("ai_run_missile\n");
|
|
ai_run_missile ();
|
|
return;
|
|
}
|
|
if (self.attack_state == AS_MELEE)
|
|
{
|
|
//dprint ("ai_run_melee\n");
|
|
ai_run_melee ();
|
|
return;
|
|
}
|
|
|
|
if (CheckAnyAttack ())
|
|
return; // beginning an attack
|
|
|
|
if (self.attack_state == AS_SLIDING)
|
|
{
|
|
ai_run_slide ();
|
|
return;
|
|
}
|
|
|
|
//Variable Velocity Movement Code
|
|
velocity_move(dist);
|
|
};
|
|
|