Each npc has a predefined personality (in a script file), and many modifiers.
Waypoints : places he likes to visit depending on world time, as well as action he wants to do there.
action modifiers : angry, in love, sad, happy, depressed, hungry, needs water, needs funs, is Taking Damage,
Actions cause modifiers to others (with your scripting language).
float variables like in sims : hapiness, fun, sleepiness, needs to pee, that can cause modifiers.
Now with this system npcs would do the same predefined things each day.
You want them to alter the world based on a Random quest/event generator, e.g
the blacksmithās son dies ā he is depressed ā he stops producing equipment ā the villagers have no weapons to defend ā the goblin scouts detect the village weakness ā the goblins attack.
[unexpected-to avoid predictability in events]
It turns out it was a fake death gambit produced by the son staging his death in order to force the goblins to attack the village. He didnt notify the others to make it more believable. blablabla
Possible scenarios:
a) the son was in a goblin alliance.
b) the son waits for everyone to die to keep the loot.
c) the son ninja loots everything from goblin village since goblins have left it undefended (they went to war).
d) The son wanted to make war with the goblins but the elders disagreed saying that they have to be peacefull. He worked hard overproducing weapons secretly as well as gathering forces from other villages to defeat the goblins once and for all, if they ever attacked the village. His alliance to the goblins was a double crossing fake betrayal in order to spy on them and gather information.
Letās consider the complicate code line I typed above:
robber.find(an expensive props) will return a prop
the prop.ofWho() return its owner (victim)
the victim.distance(robber,10) return true or false when the distance between victim and robber > 10.
in robber object which save the last expensive prop he has found, then the system tell him rob the prop.
Itās how power of scripting isā¦
One line - One rule!
My thought: But when your world is too complex, when the rule condition is āconflictā and āconfusingā with each other, you have to make a system to decide the right things by pattern matching.
Take a look at :
http://en.wikipedia.org/wiki/Rete_algorithm <= I think you 've already known it. But as I see you are āsuper goodā at this area, hope that you make it work in java and JME somehow!
@tralala Iām not going that complex with the personalities myself.
Consider a population of 200 people. I dont need them to calculate whether to be happy or sad by some advance calculation, they will all die by the giant godzilla thatās entering town
This game is made to be an engine, foundation, for people to build games of. So creating complex aiās will be fully supported tho.
@atomix Iām trying to make it easy to write a person without having to script it.
For example, the robbers Soul txt file is here:
Walking:100
Sleeping:50
Running:10
Scout:25
Handgun
HotSpot:Panic
RobberChat
Skin:Robber.png
Then I still had to special write a couple of Ears for him. But that was sort of like your design:
[java]public void recive(Person speaker, String msg, boolean shout) {
System.out.println("Recived: "+speaker.getTitle()+" ("+shout+"): " + msg);
if (speaker.getTitle().equals("Cop")){
if (msg.equals("Hey!")){
Then I have a bounch of Activities that you do. So the mode RobberRunAwayFrom will create a new instance of the activity RobberRunAwayFrom and there is the complex instructions on what to do to avoid cops :P
Finding and Driving a car is also just a set of actions executed in a wished order. FindVehicle, EnterVehicle, DriveCar, LeaveVehicle.
Trying to keep it all very simple to make it easy to modd. When I'm done, to create a high complex character, all you got to do is write a simple soul file of maybe 50 lines. Then extends a Brain and script in there the rest. And that would not be a too big script either as the Activities would do moste of the script job for you. Brains only handles conditions, inputs etc.
Ah, itās quite a simulation of the real world ⦠Since everyone must ālistenā to everything others say! Itās annoying of course but in the term of programming, itās not just annoying, if we didnāt take good care of it, it will become a bad design IMO.
In still surprise that you manage your code too good. As those code can easily break and out of track sometimes iām afraid. Please donāt consider this is an offensive argument, I just try to tell something and hope that help:
Assume that 2 things happen : An explosion and one man got killed.
An explosion :
System tell everyone , there is an explosion. Everyone run by their instinct. The police and the robber have special skill : the police come near to the crime scene, and the robber try to leave the place where he made the explosion.
One man got killed:
System tell the police that someone killed a normal man. The police come and try to determine who is he?
As you see in my example, āthe policeā which are a ānormal manā in the āeveryday lifeā (normal situation), extends ānormal manā but has an opposite decision when it come to āspecial situationā.
May be you know this is the basic concept of an agent system or entity systemā¦
System has an āevent busā which decide to send what event to whoā¦
And āthe policeā is a service, which can be call if needā¦
May be when your game grow big, you should consider make one, to keep your code clean and easy to tweakā¦
Hey Addez, your game/city sim looks awesome :), really love the humour in it
Since I“m doing some research for my own future project on topics that seams related to your game, I thought I“ld mention a few things that have cought my attention:
b) In xml files containing the data use inheritance. [avoids data duplication].
Guard
{
extends = civilian
onExplotion(){ investigate();}
}
[ we avoided copy pasting civilian ]
would using multiple inheritance help in data files ? [dupplicate variables are resolved depending on declaration order]
i read about dugeon siedge game objects but i didnt understand it when it suggested that the objectās data be āinterpretedā based on a schema, how would that help ? (apart from automatic handling from the game editor).