Companion_ai

Posted By: 3run

Companion_ai - 06/25/09 18:02

Half year earlyer, in User Contributions I found a very good script in C-Script, it was called companion_ai. In the demo there is dude, he always follows player, and he even jumped over obstacles. That was a very good pathfinding code. But my PC had some problems, & my HDD was formated. Please if any one has that perfect code, share it!!!
Posted By: Damocles_

Re: Companion_ai - 06/25/09 18:39

Yup, that was from me.

I will reactivate the link:


www.wasteland.at/companion.zip

Its c-script for A6, but should be easy adoptable to A7

Its a very good way to realize a following companion, or even
a certain type of "chasing" enemy, that finds his way without
having you to implement pathfinding.

---

It also contains a decent ego-shooter WASD movement routine.
Posted By: 3run

Re: Companion_ai - 06/25/09 19:05

Man! You are the best!!! THANK U A LOT!!! I'll use it in my free zombie shooter game! =)
Posted By: Damocles_

Re: Companion_ai - 06/25/09 19:08

Looking forward to see it wink
Posted By: the_clown

Re: Companion_ai - 06/26/09 11:45

Another zombie shooter???
Posted By: 3run

Re: Companion_ai - 06/26/09 17:23

It will be like "left 4 dead", even zombie models will be from it.
Posted By: the_clown

Re: Companion_ai - 06/26/09 17:26

Multiplayer?
Posted By: 3run

Re: Companion_ai - 06/26/09 18:24

Not for now... may be later I'll add multiplayer. All I whant to do 4 now, is create zombies and friendly dude, he will help as to get throuh the zombies. Movement code, weapons, models, sounds & textures are finished! =) now I have to work with AI code, Physics (I have some problems with ragdolls), Shaders & main menu code;
Posted By: MegaMarioDeluxe

Re: Companion_ai - 06/27/09 03:23

That's what I need for my project. Have another character has a helper. Thanks a lot, Damocles_! smile
Posted By: Erick_Castro

Re: Companion_ai - 07/02/09 15:58

Excellent!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I was looking for that code a long time ago!

That code really adds AI to my FPS Game!

Thank you!
Posted By: Damocles_

Re: Companion_ai - 07/02/09 22:45

Apart from the code, wich you can look though of course, here the mechanics of that guy:

---

This AI is based on finding a movement path without
the need for creating a node-based pathfinding grid.

The nodes are created "on the fly" by the player when he moves.

The player continiusly "drops" nodes when walking.
As the nodes are in a linked list, they somehow form a
"chain", wich is the path for the AI to move.

The AI guy looks for the most recent node, that he can directly reach.
Once he is there, he will go to an even more recent node.
Similar to a Dog, sniffing his way.

This way the AI follows the player.

I dont remember exactly, but I think, when the AI gets stuck,
he walks back his way, until he can find a suitable node again
to follow.

---

The other part is the movement script, wich uses
several traces, that makes the AI avoid to get to close to walls.
So before colliding directly with something, the AI usually pushed itself away from the obstacle or turned a bit.

The same with jumping. The Players actually hover over the ground up to the hips.
Similar to humans, the legs are basically
fully flexible to adapt to narrow obstacles on the floor.

If the trace dow finds a distance lower than the leg-hight, the
AI pushes itself up. If it is higher than the hip-hight, it
stops pushing, and starts to fall.
Posted By: 3run

Re: Companion_ai - 07/03/09 07:46

Thank you Damocles! =) This is very usefull!!!
Posted By: awstar

Re: Companion_ai - 07/15/09 23:00

when player jumps , companion moves under him keeping player on top......
Posted By: 3run

Re: Companion_ai - 07/18/09 09:28

I think thats becouse of player.x, "companion" is trying to get in to player.x position
Posted By: Damocles_

Re: Companion_ai - 07/18/09 14:28

The companion tries to get to the player as close as possible,
and both player and bot automatically step onto obstacles to move over them.

Here the bot sees the player as objstacle and steps onto him, or
the other way around.

you can avoid that by letting the bot stop earlier or let the bot not step onto the player (ignoring him in the trace)
Posted By: 3run

Re: Companion_ai - 07/18/09 16:37

I'll make if comparison, with distanse to player, if closer then 400 quants, follow player, if closer 50 quants stop & attack... I think that way this AI is the best for my zombie shooter game! smile
Posted By: Muhsin

Re: Companion_ai - 08/25/09 15:32

Does the companion attack enemies, if they attack the player?
Posted By: Damocles_

Re: Companion_ai - 08/25/09 17:00

No thats not implemented in that code.

Its basically just a demonstration to get
an active entity to follow you.

To extend it to an attacking companion,
you need to let the companion switch from
following the player to chasing the enemy.

(using a statemachine or something similar)
Posted By: Muhsin

Re: Companion_ai - 08/26/09 14:38

OK, thanks for the help
© 2024 lite-C Forums