/// /// 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) { let group = new ContentGroup(); let unit = new CombatPokeUnit(); group.addUnit(unit); unit.setTarget(victim); unit.setAggressor(aggressor); unit.addMarker(...markers); victim.AI.warnedTimes++; Elements.CurrentTurnHandler.printAsContent(new Say(...CombatPokeDescription.getDescription(group))); } export var Grudge = AI.rules.createAndAddRule({ name : "Grudge", firstPriority : AIRules.PRIORITY_ACTING_ON_SITUATION, priority : AIRules.PRIORITY_ACTING_ON_SITUATION - 3, code : (runner : RulebookRunner) => { let person = runner.noun; for (let i = 0; i < TurnSequence.currentTurnActionsTargets.length; i++) { if (TurnSequence.currentTurnActionsTargets[i] == person) { let action = TurnSequence.currentTurnActions[i]; if (action.actingAgressively) { person.AI.addHostility(action.actor, action.aggressivenessRating); if (action.actor == WorldState.player) { person.reputation -= action.aggressivenessRating; } let ai = person.AI; 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; } printGrudgeResult(action.actor, person, actionLevel, result); if (result == resultRetaliate) { return new ActionAttack(person, action.actor); } } } } } }); }