mirror of https://github.com/nzp-team/quakec.git
Server: Some AI targeting improvements
This commit is contained in:
parent
950c072fa1
commit
3802fadefa
|
@ -67,44 +67,71 @@ void() Respawn =
|
||||||
|
|
||||||
entity(entity blarg) find_new_enemy =
|
entity(entity blarg) find_new_enemy =
|
||||||
{
|
{
|
||||||
local entity player;
|
entity targets;
|
||||||
local entity closest;
|
entity best_target;
|
||||||
local float bestdist;
|
float best_distance;
|
||||||
local float dist;
|
float distance;
|
||||||
bestdist = 10000;
|
|
||||||
closest = 0;
|
best_distance = 10000;
|
||||||
|
best_target = world;
|
||||||
|
|
||||||
if(self.classname == "ai_zombie" || self.classname == "ai_dog") {
|
if (blarg.classname == "ai_zombie" || blarg.classname == "ai_dog") {
|
||||||
player = find(world,classname,"monkey");
|
// Monkey Bomb (TODO -- if multiple, target first one thrown)
|
||||||
if(player) {
|
targets = find(world, classname, "monkey_bomb");
|
||||||
return player;
|
if (targets != world && blarg.classname != "ai_dog") {
|
||||||
|
best_target = targets;
|
||||||
|
return best_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = find(world,classname,"player");
|
// Now, try and find a viable player
|
||||||
///////////////////////////////
|
targets = find(world, classname, "player");
|
||||||
if(!player) {
|
|
||||||
return world;
|
while(targets != world) {
|
||||||
}
|
// Don't target downed players.
|
||||||
//////////////////////////////
|
if (targets.downed == true) {
|
||||||
while(player) {
|
targets = find(targets, classname, "player");
|
||||||
if (player.downed == true) {
|
|
||||||
player = find(player,classname,"player");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dist = vlen(self.origin - player.origin);
|
// Found one, let's see if it's closer than our last ideal target.
|
||||||
if (dist < bestdist) {
|
distance = vlen(blarg.origin - targets.origin);
|
||||||
closest = player;
|
|
||||||
bestdist = dist;
|
if (distance < best_distance) {
|
||||||
|
best_target = targets;
|
||||||
|
best_distance = distance;
|
||||||
}
|
}
|
||||||
player = find(player,classname,"player");
|
|
||||||
|
// Continue iterating
|
||||||
|
targets = find(targets, classname, "player");
|
||||||
}
|
}
|
||||||
return closest;
|
|
||||||
|
// Return a good player if we found one.
|
||||||
|
if (best_target != world)
|
||||||
|
return best_target;
|
||||||
|
|
||||||
|
// We couldn't find a good player. How about a horde point?
|
||||||
|
targets = find(world, classname, "zombie_horde_point");
|
||||||
|
|
||||||
|
while(targets != world) {
|
||||||
|
// Found one, let's see if it's closer than our last ideal target.
|
||||||
|
distance = vlen(blarg.origin - targets.origin);
|
||||||
|
|
||||||
|
if (distance < best_distance) {
|
||||||
|
best_target = targets;
|
||||||
|
best_distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue iterating
|
||||||
|
targets = find(targets, classname, "zombie_horde_point");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a horde point if we found one.
|
||||||
|
if (best_target != world)
|
||||||
|
return best_target;
|
||||||
}
|
}
|
||||||
if (self.classname != "wunder")
|
|
||||||
bprint(PRINT_HIGH, "Error: Find_New_Enemy returns world! \n");
|
// We didn't have much luck, just return the world.
|
||||||
return world;
|
return best_target;
|
||||||
};
|
};
|
||||||
|
|
||||||
float() avoid_zombies =
|
float() avoid_zombies =
|
||||||
|
@ -605,7 +632,7 @@ float(vector start, vector min, vector max, vector end, float nomonsters, entity
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void(float dist) Inside_Walk = {
|
void(float dist) Inside_Walk = {
|
||||||
if(self.enemy_timeout < time || self.enemy == world) {
|
if(self.enemy_timeout < time || self.enemy == world || self.enemy.downed == true) {
|
||||||
self.enemy_timeout = time + 5;
|
self.enemy_timeout = time + 5;
|
||||||
local entity oldEnemy;
|
local entity oldEnemy;
|
||||||
oldEnemy = self.enemy;
|
oldEnemy = self.enemy;
|
||||||
|
@ -613,13 +640,15 @@ void(float dist) Inside_Walk = {
|
||||||
}
|
}
|
||||||
//================Check for proximity to player ===========
|
//================Check for proximity to player ===========
|
||||||
if(vlen(self.enemy.origin - self.origin) < 60) {
|
if(vlen(self.enemy.origin - self.origin) < 60) {
|
||||||
if(self.enemy.classname == "monkey") {
|
if(self.enemy.classname == "monkey_bomb") {
|
||||||
self.th_idle();
|
self.th_idle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self.attack_delay < time) {
|
if(self.attack_delay < time) {
|
||||||
self.attack_delay = time + 1 + (1 * random());
|
self.attack_delay = time + 1 + (1 * random());
|
||||||
self.th_melee();
|
self.th_melee();
|
||||||
|
if (self.enemy.downed == true)
|
||||||
|
self.enemy = find_new_enemy(self);
|
||||||
self.goalentity = self.enemy;
|
self.goalentity = self.enemy;
|
||||||
self.chase_time = time + 5;
|
self.chase_time = time + 5;
|
||||||
}
|
}
|
||||||
|
@ -642,9 +671,9 @@ void(float dist) Inside_Walk = {
|
||||||
self.chase_time = 0;
|
self.chase_time = 0;
|
||||||
}
|
}
|
||||||
//============= No Target ====================
|
//============= No Target ====================
|
||||||
if(self.goalentity == world) {//not sure when this would ever occur... but whatever.
|
//if(self.goalentity == world) {//not sure when this would ever occur... but whatever.
|
||||||
self.goalentity = self.goaldummy;
|
// self.goalentity = self.goaldummy;
|
||||||
}
|
//}
|
||||||
//============ GoalDummy is Target ============
|
//============ GoalDummy is Target ============
|
||||||
if(self.goalentity == self.goaldummy) {
|
if(self.goalentity == self.goaldummy) {
|
||||||
if(nearby(self.goaldummy.origin)) {
|
if(nearby(self.goaldummy.origin)) {
|
||||||
|
|
|
@ -856,22 +856,22 @@ void() zombie_attack2;
|
||||||
|
|
||||||
$frame attack1 attack2 attack3 attack4 attack5
|
$frame attack1 attack2 attack3 attack4 attack5
|
||||||
|
|
||||||
void() zombie_attackA1 =[ $attack1, zombie_attackA2 ] {self.frame = 102;SetZombieHitBox(BASE_BBOX);Zombie_Think();self.solid = SOLID_BBOX;};
|
void() zombie_attackA1 =[ $attack1, zombie_attackA2 ] {self.frame = 102;SetZombieHitBox(BASE_BBOX);Zombie_Think();};
|
||||||
void() zombie_attackA2 =[ $attack2, zombie_attackA3 ] {self.frame = 103;Zombie_Think();};
|
void() zombie_attackA2 =[ $attack2, zombie_attackA3 ] {self.frame = 103;Zombie_Think();};
|
||||||
void() zombie_attackA3 =[ $attack3, zombie_attackA4 ] {self.frame = 104;Zombie_Think();};
|
void() zombie_attackA3 =[ $attack3, zombie_attackA4 ] {self.frame = 104;Zombie_Think();};
|
||||||
void() zombie_attackA4 =[ $attack4, zombie_attackA5 ] {zombie_attack2();self.frame = 105;Zombie_Think();};
|
void() zombie_attackA4 =[ $attack4, zombie_attackA5 ] {zombie_attack2();self.frame = 105;Zombie_Think();};
|
||||||
void() zombie_attackA5 =[ $attack5, zombie_decide ] {self.frame = 106;Zombie_Think();self.solid = SOLID_CORPSE;};
|
void() zombie_attackA5 =[ $attack5, zombie_decide ] {self.frame = 106;Zombie_Think();};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////// ZOMBIE ATTACK 2// Swipe with left arm
|
///////////////////////////////////////////////////////////////////////// ZOMBIE ATTACK 2// Swipe with left arm
|
||||||
//91-96
|
//91-96
|
||||||
$frame attackb1 attackb2 attackb3 attackb4 attackb5 attackb6
|
$frame attackb1 attackb2 attackb3 attackb4 attackb5 attackb6
|
||||||
|
|
||||||
void() zombie_attackB1 =[ $attackb1, zombie_attackB2 ] {self.frame = 107;SetZombieHitBox(BASE_BBOX);Zombie_Think();self.solid = SOLID_BBOX;};
|
void() zombie_attackB1 =[ $attackb1, zombie_attackB2 ] {self.frame = 107;SetZombieHitBox(BASE_BBOX);Zombie_Think();};
|
||||||
void() zombie_attackB2 =[ $attackb2, zombie_attackB3 ] {self.frame = 108;Zombie_Think();};
|
void() zombie_attackB2 =[ $attackb2, zombie_attackB3 ] {self.frame = 108;Zombie_Think();};
|
||||||
void() zombie_attackB3 =[ $attackb3, zombie_attackB4 ] {self.frame = 109;Zombie_Think();};
|
void() zombie_attackB3 =[ $attackb3, zombie_attackB4 ] {self.frame = 109;Zombie_Think();};
|
||||||
void() zombie_attackB4 =[ $attackb4, zombie_attackB5 ] {zombie_attack2(); self.frame = 110;Zombie_Think();};
|
void() zombie_attackB4 =[ $attackb4, zombie_attackB5 ] {zombie_attack2(); self.frame = 110;Zombie_Think();};
|
||||||
void() zombie_attackB5 =[ $attackb5, zombie_attackB6 ] {self.frame = 111;Zombie_Think();};
|
void() zombie_attackB5 =[ $attackb5, zombie_attackB6 ] {self.frame = 111;Zombie_Think();};
|
||||||
void() zombie_attackB6 =[ $attackb6, zombie_decide ] {self.frame = 112;Zombie_Think();self.solid = SOLID_CORPSE;};
|
void() zombie_attackB6 =[ $attackb6, zombie_decide ] {self.frame = 112;Zombie_Think();};
|
||||||
|
|
||||||
|
|
||||||
void() zombie_attack =
|
void() zombie_attack =
|
||||||
|
|
Loading…
Reference in New Issue