JC-MP

Scripting => Releases => Topic started by: jaxm on November 22, 2015, 12:53:00 pm

Title: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: jaxm on November 22, 2015, 12:53:00 pm

Core Features

Download From GitHub Here (https://github.com/jaxm/jcmp_ai)
The Nav files required can be downloaded here (http://static.jc-mp.com/Nav.zip).

Nav folder should be extracted into the ai module folder on the server. Example: scripts/jcmp_ai/Nav

Server Owners
This module in its current state is very expensive / demanding on the server, it’s largely untested with higher numbers of players. It’s likely to run into issues on freeroam servers with lots of players spread out across Panau. The reason for this is every time an on foot agent requests a path, the server has to load that area into its memory to be able to build a path for the agent. The current default CellsLoadedLimit is 80. In the event you had agents in spread throughout more cells than this number, they would stand on the spot until another cell can be unloaded to load their cell and generate a path. If you would like to tweak this value you can find it in server/PathFinding/MeshSearch.lua

Server Performance Tips

Additional Information
I have committed a fairly extensive amount of time to this project throughout this year. Bringing AI enemies back into the game has been one of my major goals since our initial release. If you’re interested in learning more about what was involved with creating this module, read on!

Pathfinding
Just Cause 2 uses PathEngine for its AI movement and pathing requirements. Our attempts to reverse engineer PathEngine, or at least JC2’s interface with PathEngine all ended in failure. This put adding AI back into JC2 on the shelf for quite some time. So I wrote my own pathfinding solution.

Based on tutorials found on various game development websites and code snippets on forums,  I created my own monstrosity which can generate paths from one side of Panau to the other (within reason). So I had my pathfinding solution, but needed to at any point be able to get information about the world, regardless of whether or not a player was there at the time. So I wrote an algorithm to map out Panau and save it in my own connected node format.


Map Data
In the interests of saving space, I opted to only save data about land that was a) pathable by an NPC walking around and b) relevant to the player. From my singleplayer experience, I remember most combat taking place around bases and on roads, so I felt that those were the relevant areas to save data. I had my algorithm generate a cell based node system for all the roads in Panau, along with the areas inside and around each military base. This came in at 1.3GB, which zip compresses down to 242MB, I felt those were acceptable all things considered. So now I had my pathfinding solution and the resources it required to generate paths, next I needed to write my own AI, have it networked, responsive and move convincingly through the world.

Artificial Intelligence
Previously I made the JC-MP gamemode ‘Invasion (https://www.jc-mp.com/forums/index.php/topic,5443.0.html)’ which featured very simple AI enemies in the form of invading aliens. In both cases, the logic for the agents run on the server. The similarities between the two stop there. With my current AI, I had the idea that I wanted to be able to write say a ‘Guard’ behaviour, but have the same code work regardless of whether the NPC was in a vehicle or on foot, without the code size sprawling out of control. So I opted for a modular approach for my agent logic. Currently the agents use two types of logic controllers, a movement controller and a role controller. The idea is that the role controller handles how the agent handles situations, like a player shooting at it, whether it needs to return fire or run away. The movement controller purely handles how to navigate any paths it receives from the role controller. The current profiles are largely incomplete, the best example to follow would be the Pursue role, which is currently hard coded for the Heat system.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Trix on November 22, 2015, 01:04:55 pm
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Darwood37 on November 22, 2015, 02:46:29 pm
(http://www.fallingbread.com/uploads/4/7/5/4/4754194/6731018_orig.jpg)
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Gaveroid on November 22, 2015, 02:55:44 pm
Hello by Gaveroid Richie
---------------------------------------------
I've been without you
Inside my mind
And in my dreams I've jacked your cars
A thousand times
I sometimes see you
In my solo game

Hello!
It's you I've been looking for
I can see it in your walk
I can see it in your cars
You're all I've ever wanted
And my bullet spray is flying wide
Because you know just what to say
And I know just what to do
And I want to tell you so much
I'll shoot you

I long to see the bullets in your body
And tell you time and time again
How much fun I'll have
Sometimes I feel my mind will overflow

Hello!
I've just got to let you know
Because I wonder where you are
And I wonder what you do
Are you somewhere feeling lonely?
Or is someone shooting you?
Tell me how to win your game
For I haven't got a clue
But let me start by saying I'll shoot you

Hello!
It's you I've been looking for
I can see it in your paths
I can see it in your cars
You're all I've ever wanted
And my bullet spray is flying wide
Because you know just what to say
And I know just what to do
And I want to tell you so much
AI, I'll shoot you
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: SinisterRectus on November 22, 2015, 05:37:45 pm
Very nice work. I'm happy you released it.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Dev_34 on November 22, 2015, 06:18:25 pm
This is really cool, I was awestruck from the minute I saw these on your public test server  :D
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: JasonMRC on November 23, 2015, 03:27:14 am
Impressive as always.

I'll try it out sometime, but I fear it may be too intensive for practical use when combined with the other scripts I run.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Jman100 on November 23, 2015, 07:06:57 am
Impressive as always.

I'll try it out sometime, but I fear it may be too intensive for practical use when combined with the other scripts I run.

I can say with certainty that running it on a freeroam server is intense. My server locked up at about 9-10 players.

That being said, it's incredible and jaxm did an amazing job as always. Very impressive.

Edit: Seems a fix for the lockup issue has been committed by jaxm. Nice!
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: jaxm on November 23, 2015, 11:51:28 am
Pushed an update today resolving a few issues / code bugs.
Code: [Select]
Fixed an error on ModuleLoad that could cause the module to fail.
Fixed infinite loop error on Traffic init.
Fixed issue where vehicle traffic were spawning on water vehicle paths.
Fixed issue where Heat enemies were spawning on water vehicle paths.
Increased CellsLoadedLimit to be more friendly to freeroam servers.

Updated OP with server performance tips for server owners.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: SneakBug8 on November 23, 2015, 05:56:54 pm
It is crashing the game, when max bounty is ahead.
NPCs are silently stupid on roads :)
On dirty roads NPCs are going crazy.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: BoboWon on November 25, 2015, 05:54:24 pm
Got regular npc to spawn but hostile npc wont spawn, if i get a heat rating it drops to nothing almost immediately and never comes back(ok so police will spawn if i kill civilians but military are no where to be found)
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Darwood37 on November 26, 2015, 12:53:13 am
Just have to say how impressed i am with this. I load it up on our server every once in a while Just for some added fun. I find it a little unstable to leave loaded all the time especially when the server gets more players joining. I have tweaked the values in the cell.lua to CellVehicleTrafficLimit = 1 and CellPedTrafficLimit = 3 and in the main.lua time_left = 12.


Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: techandtrains101 on November 28, 2015, 11:41:43 pm
Cool!
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: eluvian on December 27, 2015, 10:19:33 am
The pedestrians just sit, not walking at all. I think it might be because of this :
"Nav folder should be extracted into the ai module folder on the server. Example: scripts/jcmp_ai/Nav"

But, where can I find the "ai module folder" ?
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: thetruestarr on January 10, 2016, 10:44:13 pm
Should i be worried?

Code: [Select]
22:40:47 | [info ] | Server started up successfully
22:40:47 | [info ] | Loading module jcmp_ai
22:40:47 | [info ] | Loading script "shared/CombatDefinitions/Weapon/_init.lua"
22:40:47 | [info ] | Loading script "shared/_init.lua"
22:40:47 | [info ] | Loading script "shared/CombatDefinitions/Factions.lua"
22:40:47 | [info ] | Loading script "shared/CombatDefinitions/Vehicle.lua"
22:40:47 | [info ] | Loading script "server/_init.lua"
22:40:47 | [info ] | Loading script "server/GameMode/HeatSystem/_init.lua"
22:40:47 | [info ] | Loading script "server/PathFinding/_init.lua"
22:40:47 | [info ] | Loading script "server/Actor/_init.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Movement/OnFoot.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Movement/OnFootPanic.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Movement/VehicleDriver.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/AgentTraffic.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/Guard.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/Panic.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/Pursue.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/RescueObjective.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/TaxiDriver.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/Wander.lua"
22:40:47 | [info ] | Loading script "server/Actor/Controller/Role/Zombie.lua"
22:40:47 | [info ] | Loading script "server/ActorManager.lua"
22:40:47 | [info ] | Loading script "server/Cell.lua"
22:40:47 | [info ] | Loading script "server/Events/EventManager.lua"
22:40:47 | [info ] | Loading script "server/Events/HeatEvent.lua"
22:40:47 | [info ] | Loading script "server/Events/PopulateEvent.lua"
22:40:47 | [info ] | Loading script "server/Faction.lua"
22:40:47 | [info ] | Loading script "server/Overseer.lua"
22:40:47 | [info ] | Loading script "server/PathFinding/AStar.lua"
22:40:47 | [info ] | Loading script "server/PathFinding/MapLoad.lua"
22:40:47 | [info ] | Loading script "server/PathFinding/MeshSearch.lua"
22:40:48 | [info ] | Loading script "server/PathFinding/PriorityQueue.lua"
22:40:48 | [info ] | Loading script "server/Player/Damage/Actor.lua"
22:40:48 | [info ] | Loading script "server/Player/Damage/Object.lua"
22:40:48 | [info ] | Loading script "server/Player/Damage/Vehicle.lua"
22:40:48 | [info ] | Loading script "server/Player/FoV.lua"
22:40:48 | [info ] | Loading script "server/Player/Vehicle.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/CombatGrunt.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/HeatMilitaryBasic.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/HeatMilitaryFinal.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/HeatMilitaryHeavy.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/HeatMilitaryMedium.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/MilitaryAPC_Cannon.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/Pedestrian.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/PoliceGuard.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/RescueObjective.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/Taxi.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/Traffic.lua"
22:40:48 | [info ] | Loading script "server/Spawnset/Zombie.lua"
22:40:48 | [info ] | Loading script "server/Triangle.lua"
22:40:48 | [info ] | Loading script "server/VehicleObjectManager.lua"
22:40:48 | [info ] | Loading script "server/main.lua"
22:40:52 | [error] | Lua error in module jcmp_ai when running event ModuleLoad:
22:40:52 | [error] |   /home/gs/JC2/scripts/jcmp_ai/server/PathFinding/MapLoad.lua:64: ...e/gs/JC2/scripts/jcmp_ai/server/packages/MessagePack.lua:1071: extra bytes
22:40:52 | [error] |   Callstack:
22:40:52 | [error] |     API function: in global error
22:40:52 | [error] |     server/PathFinding/MapLoad.lua:64: in global LoadMap
22:40:52 | [error] |     server/PathFinding/MapLoad.lua:8: in function <server/PathFinding/MapLoad.lua:2>
22:40:52 | [info ] | Module jcmp_ai loaded successfully

and also module doesnt work, nothing ingame

Im using following sripts:

http://puu.sh/mrK0d.png
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Cole89 on February 05, 2016, 04:29:30 pm
YESSSSSS I Was waiting for this !! Thanks !!
gonna try a LAN party now !
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Cole89 on February 08, 2016, 11:20:50 am
btw, is this script still updated ? is it stable ? i'm reinstalling JC2 right now ..

edit: tried and working ! is not perfect but it assumes an entirely different involvement !!! THANK YOU !
are you planning to update this script ? maybe making npc cars breaking while you are crossing the road ?
is the heat system editable?
very good job !
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Over9K on May 09, 2016, 04:30:50 pm
Hi!

Sorry for necroing a bit...

First of all, great release. Im using it to play with friends and works great. Just a question:

Is there any way to be able to spawn hostile soldiers (like police when you shoot a civilian) but wich are hostile to ANY nearby player, even if they didn´t nothing?

The idea is admin to be able to spawn enemies around players for event. I´ts feasible somehow?

Thxx-
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: FiberGamingEU on August 27, 2016, 11:26:31 am
11:14:24 | [error] |   ..._Files/36/scripts/jcmp_ai/server/PathFinding/MapLoad.lua:64: ...Files/36/scripts/jcmp_ai/server/packages/MessagePack.lua:1071: extra bytes

11:14:24 | [error] |   Callstack:

11:14:24 | [error] |     API function: in global error

11:14:24 | [error] |     server/PathFinding/MapLoad.lua:64: in global LoadMap

11:14:24 | [error] |     server/PathFinding/MapLoad.lua:8: in function <server/PathFinding/MapLoad.lua:2>

need help
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Darwood37 on August 30, 2016, 05:37:43 am
Did you download the NAV files and put them n the correct place?
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: BleachDealer on June 30, 2017, 02:50:02 am
Hi! This isn't working for my server, do you know anything that will help? The problem seems to root at MeshLoadTick in main.lua.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Swagxy on December 30, 2017, 09:23:31 am
Hi! This isn't working for my server, do you know anything that will help? The problem seems to root at MeshLoadTick in main.lua.
where do we put the Nav File?
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: SuperBoom2 on July 01, 2018, 09:40:50 pm
it unloads it everytime i try to use it. because it has alot of errors
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: FairTrade on July 08, 2018, 02:25:27 am
I need help!
Where is everyone! i am trying to find them but they are not here.
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: SPECTOR_ on November 26, 2018, 12:22:56 am
Hey,

I know its been 4 years since the script has came out but does anyone have the Nav files for it (the link just 404's), Me and a friend of mine are trying to make a server for some people to hang out on and the AI keeps freaking out within 5 minutes of gameplay (Eg, Ai wont render, Ai stands still in the running animation, Ai cars flying though streets and sometimes come and hit us)

Thanks in advance
Title: Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
Post by: Woet on November 26, 2018, 04:23:33 am
Hey,

I know its been 4 years since the script has came out but does anyone have the Nav files for it (the link just 404's), Me and a friend of mine are trying to make a server for some people to hang out on and the AI keeps freaking out within 5 minutes of gameplay (Eg, Ai wont render, Ai stands still in the running animation, Ai cars flying though streets and sometimes come and hit us)

Thanks in advance

Fixed! http://static.jc-mp.com/Nav.zip (http://static.jc-mp.com/Nav.zip)