1
Programming / Re: Any tips on how to do monster/monster interaction?
« on: May 06, 2009, 12:48:28 PM »
Perhaps you have simply a "default attitude" for a species, and then a map from species id to an attitude. And if he sees somebody not in his map, he uses his default. This way you only need to hold data, when he has something specific grudge or likes some species. Let me use a pseudocode to show what I mean better
So the orcs and goblins form an alliance, and they are scared of dragons, and the elves do not like them. You could even extend this so you may store a "personal" attitude as well as a specific one. So if an orc acquires a grudge against some particular dragon, he may do
And of course you can define groups of species called factions and then includes PaulBlay's saying earlier.
Code: [Select]
-- create species ids
orcs = new Species()
goblins = new Species()
elves = new Species()
dragons = new Species()
-- default attitudes
orcs.set_default_attitude(Attitude.HOSTILE)
goblins.set_default_attitude(Attitude.HOSTILE)
elves.set_default_attitude(Attitude.NEUTRAL)
dragons.set_default_attitude(Attitude.HOSTILE)
-- specific attitudes
elves.set_attitude(orcs, Attitude.HOSTILE)
elves.set_attitude(goblins, Attitude.HOSTILE)
orcs.set_attitude(goblins, Attitude.FRIENDLY)
goblins.set_attitude(orcs, Attitude.FRIENDLY)
orcs.set_attitude(dragons, Attitude.SCARED)
goblins.set_attitude(dragons, Attitude.SCARED)
So the orcs and goblins form an alliance, and they are scared of dragons, and the elves do not like them. You could even extend this so you may store a "personal" attitude as well as a specific one. So if an orc acquires a grudge against some particular dragon, he may do
Code: [Select]
Blork_the_orc.set_personal_attitude(Prog_the_dragon, Attitude.HOSTILE)
And of course you can define groups of species called factions and then includes PaulBlay's saying earlier.