SERVER: Fix AI getting stuck inside player

This commit is contained in:
cypress 2023-11-07 12:56:56 -05:00
parent c14e2345bd
commit 619980e88c
4 changed files with 31 additions and 6 deletions

View file

@ -125,6 +125,22 @@ entity(entity blarg) find_new_enemy =
targets = find(targets, classname, "zombie_horde_point");
}
// Last chance -- try a player spawn point.
targets = find(world, classname, "info_player_1_spawn");
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, "info_player_1_spawn");
}
// Return a horde point if we found one.
if (best_target != world)
return best_target;
@ -655,7 +671,10 @@ void(float dist) Inside_Walk = {
if(self.attack_delay < time) {
self.attack_delay = time + 1 + (1 * random());
self.th_melee();
if (self.enemy.health)
self.th_melee();
if (self.enemy.downed == true)
self.enemy = find_new_enemy(self);
self.goalentity = self.enemy;

View file

@ -706,15 +706,15 @@ void() zombie_hop2_5 =[ $hop2, zombie_hop3 ] {self.frame = self.head.frame = 114
void() zombie_hop3 =[ $hop3, zombie_hop3_5 ] {self.frame = self.head.frame = 115;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};
void() zombie_hop3_5 =[ $hop3, zombie_hop4 ] {self.frame = self.head.frame = 115;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop4 =[ $hop4, zombie_hop4_5 ] {self.frame = self.head.frame = 116;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};
void() zombie_hop4_5 =[ $hop4, zombie_hop5 ] {self.frame = self.head.frame = 116;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop4_5 =[ $hop4, zombie_hop5 ] {self.frame = self.head.frame = 116;self.nextthink = time+0.05;moveforwardalittle(1);};
void() zombie_hop5 =[ $hop5, zombie_hop5_5 ] {self.frame = self.head.frame = 117;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};
void() zombie_hop5_5 =[ $hop5, zombie_hop6 ] {self.frame = self.head.frame = 117;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop5_5 =[ $hop5, zombie_hop6 ] {self.frame = self.head.frame = 117;self.nextthink = time+0.05;moveforwardalittle(1);};
void() zombie_hop6 =[ $hop6, zombie_hop6_5 ] {self.frame = self.head.frame = 118;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};
void() zombie_hop6_5 =[ $hop6, zombie_hop7 ] {self.frame = self.head.frame = 118;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop6_5 =[ $hop6, zombie_hop7 ] {self.frame = self.head.frame = 118;self.nextthink = time+0.05;moveforwardalittle(1);};
void() zombie_hop7 =[ $hop7, zombie_hop7_5 ] {self.frame = self.head.frame = 119;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};
void() zombie_hop7_5 =[ $hop7, zombie_hop8 ] {self.frame = self.head.frame = 119;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop7_5 =[ $hop7, zombie_hop8 ] {self.frame = self.head.frame = 119;self.nextthink = time+0.05;moveforwardalittle(1);};
void() zombie_hop8 =[ $hop8, zombie_hop8_5 ] {self.frame = self.head.frame = 120;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();zombie_footstep();};
void() zombie_hop8_5 =[ $hop8, zombie_hop9 ] {self.frame = self.head.frame = 120;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop8_5 =[ $hop8, zombie_hop9 ] {self.frame = self.head.frame = 120;self.nextthink = time+0.05;moveforwardalittle(1);};
void() zombie_hop9 =[ $hop9, zombie_hop9_5 ] {self.frame = self.head.frame = 121;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};
void() zombie_hop9_5 =[ $hop9, zombie_hop10 ] {self.frame = self.head.frame = 121;self.nextthink = time+0.05;moveforwardalittle(0);};
void() zombie_hop10 =[ $hop10, zombie_hop10_5 ] {self.frame = self.head.frame = 122;self.nextthink = time+0.05;moveforwardalittle(1);Zombie_Think();};

View file

@ -181,6 +181,7 @@ void() rec_downed =
self.nextthink = time + 0.1;
}
float() push_away_zombies;
void() GetDown =
{
// 'Pro Gamer Move' achievement.
@ -191,6 +192,9 @@ void() GetDown =
GiveAchievement(9, self);
}
// Make any zombies inside of the player's bounding box leave
push_away_zombies();
// Play Last Stand Animation
PAnim_GetDown1();

View file

@ -49,6 +49,8 @@ void() info_player_2_spawn = {};
void() info_player_3_spawn = {};
void() info_player_4_spawn = {};
void() zombie_horde_point = {};
void() zapper1 = {remove(self);};
void() zapper2 = {remove(self);};
void() item_switch = {remove(self);};