« get me outta code hell

Only make enemies heal 50% of the time - csb-game - Pixelly spin-off of the Command Synergy Battle system used in Final Fantasy XIII
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-08-19 15:30:34 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-19 15:30:34 -0300
commit75186624ce88e391afa629c7f2b6b8b6f217eb2b (patch)
treee60f85216d97cbb42768eb1b5b0fe91aeac94958
parentf8a1ea210f120bb0f7e9ddd8895aa1391650ee71 (diff)
Only make enemies heal 50% of the time
-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
+          }
         }
       }