Scripts / Improved Zombie AI Script

Author
Message
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 31st Mar 2019 22:44
Hey guys,

I searched forum for improved zombie AI scripts but couldn't found, so I started to write one myself. I made it for a zombie (Office Zombie) that is lying on the floor, and when player get close he starts to get up and run toward player to kill him.

I'm not sure if this work with many zombies because I couldn't test yet, but it's working 100% on my game. Another bad thing is that every zombie will carry it's own variables, so gonna need to write a script per zombie.

My main idea was to use animation frames based script.

Here's the code:



Please guys let me know if anyone tried this way before because I could not find anything to improve Zombie AI on forum.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 31st Mar 2019 23:39 Edited at: 31st Mar 2019 23:40
This might help.


Edited to add :
This is your script edited a bit to allow it to work with multiple zombies.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 2nd Apr 2019 18:57
Quote: "I could not find anything to improve Zombie AI on forum."

https://forum.game-guru.com/thread/217686
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 2nd Apr 2019 19:14
Thanks 3com! its working with alot of zombies? did you test if they sometimes stop respoding?
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 2nd Apr 2019 19:24
Really not, I did it times ago and GG has changed a lot since then.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 2nd Apr 2019 19:35
The script I made don't work that well with some zombies, like the Clown one. In my first level 2 zombies did good, and then I needed to make another script for the clown otherwise it was Idle. Looks like an internal conflict.

Btw Defy is working on a zombie module: https://forum.game-guru.com/thread/220337
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 2nd Apr 2019 19:40
I did not delve into the matter since people did not seem interested as usual.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 5th Apr 2019 17:09
Here's another code, made for that Giant Classic Zombie, Elmongo:

Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 6th Apr 2019 00:35
@AmenMoses the script you made is not working here, zombie rises and runs, but dont attack.

everything seems to be fine, but aint working
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 6th Apr 2019 18:15 Edited at: 6th Apr 2019 18:17
Good News

I think aigotoentity was bugging script (seems ai related commands bug scripts), so I changed it to MoveForward(e,v) and few other calls. Made multiple animation-based scripts for the zombies and placed em in a map I have alot of trees and models, scripts running, audio and more, and all zombies worked 100%. I forgot to set Anim Speed and Speed of some, and player distance condition too, that why few zombies takes a lil to react in the video.

Video below:


Script below (mine + AmenMoses combined):



Guess that's the solution for now for gg zombie AI, lemme know guys if you could test it and confirm.

Attachments

Login to view attachments
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 6th Apr 2019 23:29
Working now to make AI find a new path when stuck on wall.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Apr 2019 07:54
if you don't use the AI commands it won't follow the pathfinding system - turn on the debug slider in tab tab and you will likely see your character doesn't follow the red path.
unfortunately GG handles the AI logic and character entity placement backwards and you can only place the AI capsule at the model's location rather than placing the character model at the AI logic's position but it can still be made to work - it's how the default AI works.

i feel that's not very well explained but AI is technically 2 systems happening at once; 1 is the hidden AI logic that follows it's own pathing logic - this can be seen in the debug slider visuals,
the other is the visual model you can see in your game - this simply moves as a script tells it but is not really locked to the AI logic and so you can easily get unexpected/poor results, this is because you have 2 systems at once and they aren't always aligned correctly.

to me it would make more sense to be able to position the character model at the location & angle of the AI logic but GG handles it in reverse and we must place the AI logic at the character model's location each frame to avoid a disconnect.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 8th Apr 2019 13:22
@smallg i'm not expert at AI, but to me seems too much calc makes the system crash. I can't understand yet why soldiers AI is working fine, maybe because they are ranged and don't walk too much?

btw, is there a command line to calc the path from the entity to player, or it's inside the AI code? If not, I'm going to turn collision off when player not seeing the mob, and turn on when it can be seem, so it can keep chasing the player no matter what.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Apr 2019 14:22 Edited at: 8th Apr 2019 14:49
the AIGotoPosition() calculates the pathing but you can't get any info from it - hence why i say GG does it backwards

with a few tweaks amen's edit of your script works fine (most notably it got stuck in the 'runtoplayer' state so i moved it further down the list and it now attacks correctly)


p.s. the stock AI is not really a good place for a tutorial as if you look at the code it actually uses way more logic than it needs to and some is broken... i.e.
Quote: "AIEntityGoToPosition(AIObjNo,ai_bot_targetx[e],ai_bot_targety[e],ai_bot_targetz[e])"

the above command only accepts 3 parameters not 4 (no Y) and actually does nothing because of this but it's used many times in the core AI scripts.
however it does hold the secret to using manual movement with pathing
Quote: "SetRotation(e,GetEntityAngleX(e),GetEntityAngleY(e),GetEntityAngleZ(e))
MoveForward(e,AIGetEntitySpeed(AIObjNo))
AISetEntityPosition(AIObjNo,GetEntityPositionX(e),GetEntityPositionY(e),GetEntityPositionZ(e))"
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 8th Apr 2019 14:47 Edited at: 8th Apr 2019 14:48
If you set the character up right the default zombie script works pretty well for pathing as far as i can see. It's mainly the fast zombies that have issues, all you need to do is go into properties and turn their speed down a bit, and they should work ok.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 8th Apr 2019 15:12
@smallg thanks for the script edit, I'm going to test it on my map tonight.

@Belidos I tested it many times in multiple levels, and got feedback from other players too, that a group of zombie just don't work right or become idle, or just point like it have a weapon and do nothing. It's not 100% granted that will work, thats the problem. Some will work fine, but the final boss, for example, that player expect to be a great fight may become iddle or do nothing at all. Zombies usually work fine on small maps, with not much entities, where the AI path is easily to calc (thats what I think, as I said i'm not expert)

With the script I showed, it's 100% chance to work, and zombie can be upgraded (move fast, attack fast, and more). After Smallg edit I'm going to test again in a map with many entities and see if AI commands won't stuck. But my guess is anything that use gg AI will crash one or more characters.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Apr 2019 15:33
Quote: "If you set the character up right the default zombie script works pretty well for pathing as far as i can see. It's mainly the fast zombies that have issues, all you need to do is go into properties and turn their speed down a bit, and they should work ok.
"

absolutely, they work really well, i'm just saying it's quite a mess to read and learn from but i guess that's expected when it's a 1 script fits all approach
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-04-25 15:32:13
Your offset time is: 2024-04-25 15:32:13