« get me outta code hell

csb-game - Pixelly spin-off of the Command Synergy Battle system used in Final Fantasy XIII
summary refs log tree commit diff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/index.js b/index.js
index 5138e92..ca01536 100644
--- a/index.js
+++ b/index.js
@@ -1312,9 +1312,14 @@ const basicAI = function() {
       if (mostHurtAlly.hp / mostHurtAlly.maxHP <= 0.5) {
         // We can only heal them if we have healing actions available!
         if (this.getValidActions('ally').find(a => isHealingAction(a))) {
-          this.targetType = 'ally'
-          this.targetCharacter = mostHurtAlly
-          break determineTarget
+          // If we're an enemy, be nice: only heal 50% of the time.
+          // This also lets the enemy be "tough", more focused towards fighting
+          // than defending.
+          if (this.team === this.battle.playerCharacter.team || Math.random() <= 0.5) {
+            this.targetType = 'ally'
+            this.targetCharacter = mostHurtAlly
+            break determineTarget
+          }
         }
       }