|
@@ -0,0 +1,77 @@
|
|
|
+/// <reference path="../../AI.ts" />
|
|
|
+///<reference path="../../ContentPicker/ContentMarker.ts"/>
|
|
|
+module AIRules {
|
|
|
+// Only one at a time
|
|
|
+ export var actionMin = new ContentMarker("That pissed me off a little", true);
|
|
|
+ export var actionMed = new ContentMarker("That pissed me off", true);
|
|
|
+ export var actionMax = new ContentMarker("That pissed me off HARD", true);
|
|
|
+
|
|
|
+ // Only one at a time
|
|
|
+ export var resultNotHostile = new ContentMarker("I'm not gonna do anything about it", true);
|
|
|
+ export var resultRetaliate = new ContentMarker("I'll hit you once so you can see how you like it", true);
|
|
|
+ export var resultHostile = new ContentMarker("I'll hit you until you drop dead.", true);
|
|
|
+
|
|
|
+ export function printGrudgeResult (aggressor : Thing, victim : Person, ...markers : Array<ContentMarker>) : Say {
|
|
|
+ let group = new ContentGroup();
|
|
|
+ let unit = new CombatPokeUnit();
|
|
|
+ group.addUnit(unit);
|
|
|
+ unit.setTarget(victim);
|
|
|
+ unit.setAggressor(aggressor);
|
|
|
+ unit.addMarker(...markers);
|
|
|
+
|
|
|
+ if (aggressor == WorldState.player) {
|
|
|
+ victim.AI.warnedTimes++;
|
|
|
+ }
|
|
|
+ return new Say(...CombatPokeDescription.getDescription(group));
|
|
|
+ }
|
|
|
+
|
|
|
+ export var actedUponAggressively = AI.reacttoRules.createAndAddRule({
|
|
|
+ name : "Reacting to Aggressive action",
|
|
|
+ code : (runner : RulebookRunner<Person>) => {
|
|
|
+ let person = runner.noun;
|
|
|
+ let pai = runner.noun.AI;
|
|
|
+ let action = pai.reactingTo;
|
|
|
+
|
|
|
+ if (person.AI.hostileTargets.includes(action.actor)) {
|
|
|
+ return; // Already hostile
|
|
|
+ }
|
|
|
+ person.AI.addHostility(action.actor, action.aggressivenessRating);
|
|
|
+ if (action.actor == WorldState.player) {
|
|
|
+ person.reputation -= action.aggressivenessRating;
|
|
|
+ }
|
|
|
+
|
|
|
+ let ai = person.AI;
|
|
|
+ let response : Say;
|
|
|
+ let gain = ai.grudgeRate * action.aggressivenessRating;
|
|
|
+ let actionLevel = actionMin;
|
|
|
+ let result = resultNotHostile;
|
|
|
+ if (ai.getHostilityTo(action.actor) > 100) {
|
|
|
+ result = resultHostile;
|
|
|
+ } else if (ai.retaliates && ai.getHostilityTo(action.actor) >= (ai.hostileThreshold / 2)) {
|
|
|
+ result = resultRetaliate;
|
|
|
+ }
|
|
|
+ if (gain >= (ai.hostileThreshold / 2)) {
|
|
|
+ actionLevel = actionMax;
|
|
|
+ } else if (gain >= (ai.hostileThreshold / 4)) {
|
|
|
+ actionLevel = actionMed;
|
|
|
+ }
|
|
|
+ response = printGrudgeResult(action.actor, person, actionLevel, result);
|
|
|
+
|
|
|
+ let nAct : Action;
|
|
|
+ if (result == resultRetaliate) {
|
|
|
+ nAct = new ActionAttack(person, action.actor);
|
|
|
+ nAct.finalSay = response.add(Say.PARAGRAPH_BREAK);
|
|
|
+ nAct.finalSayOnEnd = false;
|
|
|
+ } else {
|
|
|
+ nAct = new ActionWait(person);
|
|
|
+ nAct.finalSay = response.add(Say.PARAGRAPH_BREAK);
|
|
|
+ }
|
|
|
+ person.AI.storedReaction = nAct;
|
|
|
+ },
|
|
|
+ conditions : (runner : RulebookRunner<Person>) => {
|
|
|
+ let pai = runner.noun.AI;
|
|
|
+ let action = pai.reactingTo;
|
|
|
+ return action.actingAgressively;
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|