Author Topic: Any tips on how to do monster/monster interaction?  (Read 22842 times)

magellan

  • Rogueliker
  • ***
  • Posts: 91
  • Karma: +0/-0
    • View Profile
    • Email
Any tips on how to do monster/monster interaction?
« on: May 05, 2009, 04:38:19 PM »
Thought i ask here, since there are a lot of people here who are smarter and more experienced than me.

If i want my monsters to have allies and foes amongst the other monsters, the only way i can think of doing that would be to use a table with monster_no rows and monster_no columns and store in it what each monster thinks of every other monster.

This seems a bit excessive and very clunky to me. Am I missing something? are there any other concepts for that? (there have to be)

PaulBlay

  • Rogueliker
  • ***
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Any tips on how to do monster/monster interaction?
« Reply #1 on: May 05, 2009, 06:56:09 PM »
Thought i ask here, since there are a lot of people here who are smarter and more experienced than me.

One concept is to have a number of 'factions' that many monster types can belong to and store relations between those factions.   Civilized, Creature, Unnatural, Divine, Demonic, Warlike, etc.

Civilized (Human, Dwarf, Elf, Gnome) could start off neutral to Creature, allied to Divine and hostile to the rest.

Creature (Bat, Deer, etc.) could start off neutral to Civilized and Divine and Fearful of the others.

and so on.

You can allow individual monsters to be pissed off (e.g. PC deliberately hits friendlies) and eventually cause relations to break down between factions.

Obviously implementation would take a bit of thought.

Vanguard

  • Rogueliker
  • ***
  • Posts: 1112
  • Karma: +0/-0
    • View Profile
Re: Any tips on how to do monster/monster interaction?
« Reply #2 on: May 06, 2009, 01:14:21 AM »
PaulBlay's is probably the best way to do it in most cases.

If you want it to be something that only occurs in a few instances you could also have your game assume all monsters are allied with each other against the player (or whatever you want as the default), and then only list the exceptions in the way you mentioned.

Personally I'm doing it Paul's way though.

magellan

  • Rogueliker
  • ***
  • Posts: 91
  • Karma: +0/-0
    • View Profile
    • Email
Re: Any tips on how to do monster/monster interaction?
« Reply #3 on: May 06, 2009, 07:59:36 AM »
What i would like would be of course food chains, with different critters fulfilling different roles with different tactics :)
That model lends itself actually pretty well to that.
Not really different from "store what you think of every other monster" though is it? Not that that's bad i was just certain there would be more elegant ways.

Thanks for the input of course!


Anvilfolk

  • Rogueliker
  • ***
  • Posts: 374
  • Karma: +0/-0
    • View Profile
Re: Any tips on how to do monster/monster interaction?
« Reply #4 on: May 06, 2009, 10:08:11 AM »
It's not the same in that you don't have to have a list of monster "relations" for every monster. If you have, say, 50 monsters, that makes 250 entries. Now, if you have, say, two factions for 50 monsters, and there are no "particular cases", then you don't need to store anything except the faction of each monster. The feeling of a monster towards another can be induced from the factions, so you don't need to explicitly have that connection :)

Something along these lines:

Code: [Select]
if (this.faction == other.faction || allied(this.faction, other.faction)
  ... do something to help this guy, or don't attack him ...
else if (not_friendly(this.faction, other.faction)
  ... go ahead and attack ...
"Get it hot! Hit it harder!!!"
 - The tutor warcry

One of They Who Are Too Busy

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Any tips on how to do monster/monster interaction?
« Reply #5 on: May 06, 2009, 11:25:01 AM »
It could be very simple like if the target (anything that monster sees) is smaller than itself, then attack. But you maybe need more sophisticated rules than that, like all sorts of decisions depending on how intelligent the monster is and what is the monster's condition.

purpleflayer

  • Newcomer
  • Posts: 13
  • Karma: +0/-0
    • View Profile
    • Email
Re: Any tips on how to do monster/monster interaction?
« Reply #6 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 ;)

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.
« Last Edit: May 06, 2009, 12:50:42 PM by purpleflayer »

magellan

  • Rogueliker
  • ***
  • Posts: 91
  • Karma: +0/-0
    • View Profile
    • Email
Re: Any tips on how to do monster/monster interaction?
« Reply #7 on: May 07, 2009, 06:49:27 PM »
... i just realized that my monsters carry an array around that consists of 128 bytes that only get used if they happen to be a player :)

Guess it boils down to two basic approaches:
Predefine and store, and act accordingly
Analyze the other critter, store, and act accordingly

Thanks for the input guys!

Retrodice

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Any tips on how to do monster/monster interaction?
« Reply #8 on: May 22, 2009, 11:06:57 PM »
At a risk of making things more complicated, you could always add priorities to factions and their hatred of other factions.  This might make an elf forced with the choice of attacking a goblin or a human always go for the goblin first.

Also, be careful with infighting.  You could have some pretty boring dungeons if the player gets there to find that the monsters have already had a huge royal rumble and killed each other first, leaving one badly injured minotaur in the middle of it all.  You may want to leave the AI silent until they notice the player (ala doom) and sit still until a noise awakens them, but this leaves yet another question to be answered; if they hate each other so much why did they leave it until the player showed up to kill each other?

A possible solution is to show a constant on-going battle between two factions and allow the player to battle amongst them all.  Many MMOs including World of Warcraft and Warhammer Online do this, but they often involve the respawning of monsters to give a feel of an almost infinite number of army members on both sides.  It's not the sort of thing I'd expect to see in a roguelike and I'm not so sure it'll sit so well with your target audience.

You could of course make it look like the player just happened upon a very short battle at the right time, but this would require a lot of atmosphere setting to pull off.  Using a RNG to create this effect would be extremely difficult.