Getting monsters unstuck!
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
Getting monsters unstuck!
As some of you know (if you've played Nazi Zombies Portable), the zombies sometimes get stuck when 2 or more hop over the barricade, and then they can't move.
I have been' trying to fix this problem by making a function to see if there is a zombie inside of another zombie, if so, push the other one out, I have had VERY mixed success, I tweak one thing, it works in one scenario, but messes it up in another, and vice versa, and it's rather frustrating.
Here is my function., this function is called every .5 seconds (changed from a previous 2 seconds)
as you can see, i'm basically trying to find the angle between 2 zombies, and push them in the opposite direction of each other (just imagine them pushing each other away)
I've tried using velocity (which worked a bit more), but I would have problems of where to take off the FL_ONGROUND flag (which also interferes with other stuff :\ _)
well, this is one way to do it.
I could try telefragging, but that wouldn't look too cool xD
Anyone have any ideas on how to make zombies not get stuck inside of each other? :\
Thanks ;D
I have been' trying to fix this problem by making a function to see if there is a zombie inside of another zombie, if so, push the other one out, I have had VERY mixed success, I tweak one thing, it works in one scenario, but messes it up in another, and vice versa, and it's rather frustrating.
Here is my function., this function is called every .5 seconds (changed from a previous 2 seconds)
- Code: Select all
void() check_stuck
{
local entity thing;
thing = findradius(self.origin, 10);
while (thing.classname == "monster_knight")
{
if(thing != self)
{
if(thing.classname == "monster_knight")
{
bprint("zombie is stuck! \n");
self.other_angle_y = vectoyaw(thing.origin - self.origin);
makevectors(self.other_angle);
thing.origin = thing.origin + ((v_right) * 5);
thing.origin = thing.origin + ((v_forward) * 5);
bprint(vtos(self.other_angle));
bprint("\n");
bprint(vtos(thing.velocity));
bprint("\n");
{
}
}
}
thing = thing.chain;
}
};
as you can see, i'm basically trying to find the angle between 2 zombies, and push them in the opposite direction of each other (just imagine them pushing each other away)
I've tried using velocity (which worked a bit more), but I would have problems of where to take off the FL_ONGROUND flag (which also interferes with other stuff :\ _)
well, this is one way to do it.
I could try telefragging, but that wouldn't look too cool xD
Anyone have any ideas on how to make zombies not get stuck inside of each other? :\
Thanks ;D
A truly rewarding experience for an AI coder: watching your ai navigate the map... makes all the time invested in the code worth it 
-

blubswillrule - Posts: 68
- Joined: Mon Oct 04, 2010 9:08 pm
- Location: Lincoln, California
firstly: any direct assignments of origin is a bug, potentially resulting in both invisible entities and non-solid entities.
secondly: any assignments of origin which do not consider the bsp state of the map and any pushers is a bug.
thirdly: knights are generally not zombies.
fourthly: findradius is generally not viable for an actual non-radius bbox-based collision.
fifthly: what happens if one is standing directly on the other's head.
consider using walkmove. it will take care of geometry, step up steps, and will report if the entity is completely stuck.
secondly: any assignments of origin which do not consider the bsp state of the map and any pushers is a bug.
thirdly: knights are generally not zombies.
fourthly: findradius is generally not viable for an actual non-radius bbox-based collision.
fifthly: what happens if one is standing directly on the other's head.
consider using walkmove. it will take care of geometry, step up steps, and will report if the entity is completely stuck.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:firstly: any direct assignments of origin is a bug, potentially resulting in both invisible entities and non-solid entities.
secondly: any assignments of origin which do not consider the bsp state of the map and any pushers is a bug.
thirdly: knights are generally not zombies.
fourthly: findradius is generally not viable for an actual non-radius bbox-based collision.
fifthly: what happens if one is standing directly on the other's head.
consider using walkmove. it will take care of geometry, step up steps, and will report if the entity is completely stuck.
yes, I can see how the direct assignment of the origin is a bug, but is removing the monster's on_ground (or whatever it may be, forgot at the moment) the only way to have velocity affect it?
and I know knights are not zombies, but they were the closest monster to the zombies we were trying to make, thus we based it on them. (ironically we just ended up redoing the whole monster code, yet I kept the monster_knight, too many dependancies I believe.)
and @ceriux, i'm currently experimenting with solid_not
A truly rewarding experience for an AI coder: watching your ai navigate the map... makes all the time invested in the code worth it 
-

blubswillrule - Posts: 68
- Joined: Mon Oct 04, 2010 9:08 pm
- Location: Lincoln, California
I've gotten' this mostly figured out (and functional), but I have one question that I need answered.
Is there any way to make velocity affect monsters WITHOUT removing their FL_ONGROUND flag?(I really need this)
Is there any way to make velocity affect monsters WITHOUT removing their FL_ONGROUND flag?(I really need this)
A truly rewarding experience for an AI coder: watching your ai navigate the map... makes all the time invested in the code worth it 
-

blubswillrule - Posts: 68
- Joined: Mon Oct 04, 2010 9:08 pm
- Location: Lincoln, California
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
