|
@@ -11,60 +11,56 @@ module AIRules {
|
|
export var resultRetaliate = new ContentMarker("I'll hit you once so you can see how you like 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 var resultHostile = new ContentMarker("I'll hit you until you drop dead.", true);
|
|
|
|
|
|
- export function printGrudgeResult (aggressor : Thing, victim : Person, ...markers : Array<ContentMarker>) {
|
|
|
|
- if (victim.isVisibleTo(WorldState.player)) {
|
|
|
|
- let group = new ContentGroup();
|
|
|
|
- let unit = new CombatPokeUnit();
|
|
|
|
- group.addUnit(unit);
|
|
|
|
- unit.setTarget(victim);
|
|
|
|
- unit.setAggressor(aggressor);
|
|
|
|
- unit.addMarker(...markers);
|
|
|
|
|
|
+ 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++;
|
|
|
|
- }
|
|
|
|
- Elements.CurrentTurnHandler.printAsContent(new Say(...CombatPokeDescription.getDescription(group)));
|
|
|
|
|
|
+ if (aggressor == WorldState.player) {
|
|
|
|
+ victim.AI.warnedTimes++;
|
|
}
|
|
}
|
|
|
|
+ return 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<Person>) => {
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
|
|
+ // TODO: Make a rulebook called "ReactionTo", this is a rule that should be there with a condition of Action = ActingAggressively.
|
|
|
|
+ export function getPoked (person : Person, action : Action) {
|
|
|
|
+ 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 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;
|
|
|
|
- }
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
- printGrudgeResult(action.actor, person, actionLevel, result);
|
|
|
|
- if (result == resultRetaliate) {
|
|
|
|
- return new ActionAttack(person, action.actor);
|
|
|
|
- }
|
|
|
|
- return new ActionWait(person); // we talked so we shouldn't move further
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
}
|
|
}
|