ACF2: Cyborg decision: Wait for 2 seconds when close to cyborg, to allow close attack
authorWuzzy <Wuzzy2@mail.ru>
Sat, 04 May 2019 21:03:26 +0200
changeset 14882 421eed52a8e1
parent 14881 543729d313f5
child 14883 4e3d81af71bf
ACF2: Cyborg decision: Wait for 2 seconds when close to cyborg, to allow close attack
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Sat May 04 19:07:58 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Sat May 04 21:03:26 2019 +0200
@@ -127,6 +127,7 @@
 lastEnemyHog = 0
 stage = 0
 choice = 0
+checkAcceptTimer = 0
 
 brainiacDead = false
 cyborgHidden = false
@@ -800,7 +801,17 @@
 end
 
 function CheckAccept()
-  return GetX(dense) < 1300 and StoppedGear(dense)
+  if GetX(dense) < 1300 then
+    -- When close to cyborg, wait for a short time before accepting,
+    -- to allow player to attack with melee weapons.
+    checkAcceptTimer = checkAcceptTimer + 1
+    if checkAcceptTimer > 2000 and StoppedGear(dense) then
+      return true
+    end
+  else
+    checkAcceptTimer = 0
+  end
+  return false
 end
 
 function DoAccept()