I'm trying to create a faction system of sorts for my roguelike and I'm not quite sure how to go about making it work the way I envisioned it. Here is a scenario:
Skeletons and rats would be their own group. They would not attack each other. Skeletons and rats will attack goblins though.
Guards will attack any sort of monster. Guards will not attack players, unless players attack guards.
Turtles do their own thing. No one would really bother to attack turtles.
Basically I'd need to be able to easily define different groups and add/remove allegiances so groups will attack/ignore each other.
ID:154753
Dec 30 2011, 6:06 pm
|
|
In response to Jp
|
|
I see. Thank you. I've never really used associative lists before. Would this example be the right way based on what you posted?
var/list/faction_list = list(/faction/player = "the_player", /faction/undead_vermin = "skeletons_and_rats") |
In response to LordAndrew
|
|
Not quite. You're associating types with strings, not instances of the datum, and you've got them the wrong way around.
More something like this: faction Obviously doesn't solve the AI problem, but part of the solution. Also, untested. I'd recommend reading the reference entry on associative lists and playing around with them a bit - they're /very/ useful. |
In response to Jp
|
|
OH. Wow, haha. Thank you again Jp, and I will make sure to have a look at the reference.
|
The second, more complicated question is about how to model AI that uses this information. That depends entirely on how complex your game is and how you want to run things. This DreamMakers article contains a discussion about a state-machine based approach to AI that might be worth considering.