Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

2 years ago

December 10, 2018, 10:51:39 pm

Author Topic: [Release] Networked Pedestrian / Vehicle Traffic / Heat System  (Read 13796 times)

jaxm

  • Developer
  • Jr. Member
  • *****
  • Posts: 89
    • View Profile
[Release] Networked Pedestrian / Vehicle Traffic / Heat System
« on: November 22, 2015, 12:53:00 pm »

Core Features
  • Pedestrians now spawn around the cities of Panau, walking along the sides of the streets going about their life.
  • Vehicle Traffic now spawn on almost every road in Panau, the traffic is randomized and dynamic.
  • The Heat System is a very basic attempt at creating enemies for the players to deal with. By default a player can trigger the heat system by attacking any civilians.

Download From GitHub Here
The Nav files required can be downloaded here.

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
  • server/main.lua - You can tweak the 'time_left' variable to specify how long the server will spend each frame processing AI related tasks. Lowering this number will improve server performance, but slow the rate at which cells are loaded and paths are generated. Do not make this number higher than the default value of 16.7
  • server/Cell.lua - If you’d like to configure the dynamic Pedestrian / Traffic the values CellPedTrafficLimit and CellVehicleTrafficLimit

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’ 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.
« Last Edit: February 15, 2016, 07:09:12 am by jaxm »

Trix

  • Developer
  • Full Member
  • *****
  • Posts: 216
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #1 on: November 22, 2015, 01:04:55 pm »
« Last Edit: November 22, 2015, 01:07:10 pm by Trix »

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #2 on: November 22, 2015, 02:46:29 pm »

Gaveroid

  • Donator
  • Jr. Member
  • *****
  • Posts: 56
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #3 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

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #4 on: November 22, 2015, 05:37:45 pm »
Very nice work. I'm happy you released it.

Dev_34

  • Full Member
  • ***
  • Posts: 158
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #5 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

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #6 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.

Jman100

  • Sr. Member
  • ****
  • Posts: 325
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #7 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!
« Last Edit: November 23, 2015, 10:09:59 am by Jman100 »

jaxm

  • Developer
  • Jr. Member
  • *****
  • Posts: 89
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #8 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.
« Last Edit: November 23, 2015, 12:15:46 pm by jaxm »

SneakBug8

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #9 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.
« Last Edit: November 23, 2015, 07:58:46 pm by SneakBug8 »

BoboWon

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #10 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)
« Last Edit: November 25, 2015, 07:00:14 pm by BoboWon »

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #11 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.



techandtrains101

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #12 on: November 28, 2015, 11:41:43 pm »
Cool!
« Last Edit: November 29, 2015, 03:00:54 pm by techandtrains101 »

eluvian

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #13 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" ?

thetruestarr

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: [Release] Networked Pedestrian / Vehicle Traffic / Heat System
« Reply #14 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
« Last Edit: January 11, 2016, 03:18:55 pm by thetruestarr »