Okay, I'm hoping to start poking at some code for this in the next few days (no promises on how long before it's even a remotely usable demo). I know I need to build up a library of causes and effects. The question is how to enumerate them.
Let's say there's some event that we're using to explain why the humans are at war with the goblins. "Poisoned the Water Supply" sounds good. What do we need to know about this event? Let's call it...
ePoisonedWaterSupply
- It's an action that a faction takes on a location.
- It's some kind of offensive action, which means the acting faction should have a reason to attack the location.
- It's perpetrated against a settlement. The target must have people living there.
- It must be performed locally. The acting faction must have physical access to the targeted location.
- It's "subtle"; the actors must have some intrinsic ability to be subtle (some factions are too stupid to do this...trolls or giants might be too dumb)
- It requires the target location to have an "externally accessible water supply". This is not very important though. Unless some plot point specifically says "they don't drink water" or something, assume this is OK.
- It's "sneaky"; it can be performed by a small force against a larger defending force.
- It leads to some condition, let's call it "cWaterSupplyPoisoned", which lasts from days to months, and which kills or weakens the location's population while in effect.
- It is an "evil" action (largely because it attacks civilians), so it's generally only performed by a faction whose morals allow it.
- As an offensive action and as an evil action, it inspires hate for the actors within the target location. It can inspire a declaration of war.
- It opens up a slot for a "mastermind"--some character within the acting faction who takes the blame, and who can later be killed in revenge (or used as a quest). This is not mandatory.
- It requires that the acting faction have access to something toxic...which isn't difficult, since even a dead body would work.
I'm running out of ideas for the basic characteristics of this event. We also need some strings when people refer to the event...
"%s poisoned %s's water supply"
"%s poisoned our water supply"
"%s poisoned our water supply with %s"
"the evil %s of the %s poisoned our water supply"
These can get built into other strings, presumably, generating something like "Five months ago, the goblins poisoned our water supply with dead human bodies, causing us to declare war on them. The evil Blacktooth poisoned our water supply; I command that you kill him! Blacktooth is hiding in a cave to the west."
Now the tricky part is still HOW DO YOU REPRESENT ALL THIS DATA. What I'm noticing though, is that nearly all of the characteristics of events like this can be represented purely in text files with no event-specific code! Same basic strategy as a DF tokens file, though I'd probably use (urk) XML. Or maybe something more like
STRIPS.
To put it more code-like... And yes, this is total bull, and a lot of it doesn't make much sense, and a lot of it would have to be totally reworked, but I *HAVE* seen planning languages that can handle code remotely like this:
ePoisonedWaterSupply {
requires actor is faction
requires target is location
optional mastermind is character
include eOffensiveAction(actor, target)
if mastermind {
assert mastermind has faction actor
}
assert target has flag "occupied"
assert actor has flag "subtle"
assert actor can access physically target
if target.watersupply {
assert target.watersupply has flag "external"
}
assert actor.morality has "evil"
assert cHasReasonToAttack(target, actor)
causes cWaterSupplyPoisoned(target, timeRange(7 days, 3 months))
has morality "evil"
has inspireHate intRange(3, 20)
where victim is faction
{
assert victim has location target
can provide causeWarDeclaration(victim, actor)
if mastermind {
can provide cHasReasonToKill(victim, mastermind)
}
}
}
Does this sound...Remotely workable? You'd have to work some more strings in there too. Also, some events WOULD need custom code, and you'd need a way to state that in this text file so it would know to look for the custom stuff.
I just don't think this is possible to do if every single event, condition, cause, effect is hard-coded.
Seriously...Does this look alright, or does this look really insane? The more I'm looking at this, the more I realize that it NEEDS an automated planner and some really insane planning algorithms that can handle multiple highly imperfect heuristic-based paths...but the important question is, *can* you represent all the important facts about every event and condition in this format?
Edit: Dammit. I knew this wasn't going to be easy, but I thought I'd be doing a whole lot of randomized-with-hints guessing and checking, instead of writing my own damn automated planner with free-variable support from freaking scratch. >.<
I hadn't even considered the difficulty of handling free variables in a scripting type of language. This may have just slipped past the realm of possibility.