Bump Attack Toggle Button
Posted: Thu Oct 13, 2011 4:31 pm
I spoke about this with DarkGod and drquicksilver in IRC. It'd be pretty convenient to have a key binding that would allow the player to toggle bump attacking on and off. This would help prevent deaths that don't necessarily involve a lack of tactics or planning on the player's part. Even at full health, I've died multiple times because I happened to be holding down (or sometimes just tapping) a movement key before I could realize I was being attacked.
The following patch adds several new key bindings, the most important of which defaults to the 'b' key: This changes the player's movement mode from the "Default" state to the "Passive" state, preventing him from attacking enemies by bumping into them. The other new key bindings are similar to the regular movement keys, but they ignore the player's current movement mode, allowing him the convenience of being able to attack an enemy without the need to toggle between movement modes. Neutral creatures and allies will not be attacked as this is no different than the normal movement mode currently present in the game.
DarkGod: The below code is not the most up-to-date version. Consider it deprecated in favor of http://forums.te4.org/viewtopic.php?p=120933#p120933
The patch applies to the b34 release.
The following patch adds several new key bindings, the most important of which defaults to the 'b' key: This changes the player's movement mode from the "Default" state to the "Passive" state, preventing him from attacking enemies by bumping into them. The other new key bindings are similar to the regular movement keys, but they ignore the player's current movement mode, allowing him the convenience of being able to attack an enemy without the need to toggle between movement modes. Neutral creatures and allies will not be attacked as this is no different than the normal movement mode currently present in the game.
DarkGod: The below code is not the most up-to-date version. Consider it deprecated in favor of http://forums.te4.org/viewtopic.php?p=120933#p120933
Code: Select all
diff -crB original-tome-3.9.34/class/Game.lua tome-3.9.34/class/Game.lua
*** original-tome-3.9.34/class/Game.lua 2011-09-17 01:10:28.000000000 -0700
--- tome-3.9.34/class/Game.lua 2011-10-13 09:11:15.279700000 -0700
***************
*** 238,243 ****
--- 238,244 ----
self:updateCurrentChar()
end
+ self.bump_attack_disabled = false
self.always_target = true
local nb_unlocks, max_unlocks = self:countBirthUnlocks()
self.creating_player = true
***************
*** 469,475 ****
function _M:save()
self.total_playtime = (self.total_playtime or 0) + (os.time() - (self.last_update or self.real_starttime))
self.last_update = os.time()
! return class.save(self, self:defaultSavedFields{difficulty=true, permadeath=true, to_re_add_actors=true, party=true, _chronoworlds=true, total_playtime=true, on_level_load_fcts=true, visited_zones=true}, true)
end
function _M:updateCurrentChar()
--- 470,476 ----
function _M:save()
self.total_playtime = (self.total_playtime or 0) + (os.time() - (self.last_update or self.real_starttime))
self.last_update = os.time()
! return class.save(self, self:defaultSavedFields{difficulty=true, permadeath=true, to_re_add_actors=true, party=true, _chronoworlds=true, total_playtime=true, on_level_load_fcts=true, visited_zones=true, bump_attack_disabled=false}, true)
end
function _M:updateCurrentChar()
***************
*** 1129,1134 ****
--- 1130,1144 ----
RUN_RIGHT_UP = function() self.player:runInit(9) end,
RUN_RIGHT_DOWN = function() self.player:runInit(3) end,
+ ATTACK_OR_MOVE_LEFT = function() self.player:attackOrMoveDir(4) end,
+ ATTACK_OR_MOVE_RIGHT = function() self.player:attackOrMoveDir(6) end,
+ ATTACK_OR_MOVE_UP = function() self.player:attackOrMoveDir(8) end,
+ ATTACK_OR_MOVE_DOWN = function() self.player:attackOrMoveDir(2) end,
+ ATTACK_OR_MOVE_LEFT_UP = function() self.player:attackOrMoveDir(7) end,
+ ATTACK_OR_MOVE_LEFT_DOWN = function() self.player:attackOrMoveDir(1) end,
+ ATTACK_OR_MOVE_RIGHT_UP = function() self.player:attackOrMoveDir(9) end,
+ ATTACK_OR_MOVE_RIGHT_DOWN = function() self.player:attackOrMoveDir(3) end,
+
-- Hotkeys
HOTKEY_1 = not_wild(function() self.player:activateHotkey(1) end),
HOTKEY_2 = not_wild(function() self.player:activateHotkey(2) end),
***************
*** 1368,1374 ****
USERCHAT_SHOW_TALK = function()
self.show_userchat = not self.show_userchat
! end
}
self.key:setCurrent()
--- 1378,1394 ----
USERCHAT_SHOW_TALK = function()
self.show_userchat = not self.show_userchat
! end,
!
! TOGGLE_BUMP_ATTACK = function()
! if (self.bump_attack_disabled) then
! self.log("Movement Mode: #LIGHT_GREEN#Default#LAST#.")
! self.bump_attack_disabled = false
! else
! self.log("Movement Mode: #LIGHT_RED#Passive#LAST#.")
! self.bump_attack_disabled = true
! end
! end
}
self.key:setCurrent()
diff -crB original-tome-3.9.34/class/Player.lua tome-3.9.34/class/Player.lua
*** original-tome-3.9.34/class/Player.lua 2011-09-17 01:10:28.000000000 -0700
--- tome-3.9.34/class/Player.lua 2011-10-13 08:49:09.891100000 -0700
***************
*** 1025,1027 ****
--- 1025,1034 ----
end
end
+ function _M:attackOrMoveDir(dir)
+ local tmp = game.bump_attack_disabled
+
+ game.bump_attack_disabled = false
+ self:moveDir(dir)
+ game.bump_attack_disabled = tmp
+ end
diff -crB original-tome-3.9.34/class/interface/Combat.lua tome-3.9.34/class/interface/Combat.lua
*** original-tome-3.9.34/class/interface/Combat.lua 2011-09-17 01:10:28.000000000 -0700
--- tome-3.9.34/class/interface/Combat.lua 2011-10-13 06:17:25.085500000 -0700
***************
*** 33,38 ****
--- 33,39 ----
local reaction = self:reactionToward(target)
if reaction < 0 then
if target.encounterAttack and self.player then self:onWorldEncounter(target, x, y) return end
+ if game.player == self and game.bump_attack_disabled then return end
return self:useTalent(self.T_ATTACK, nil, nil, nil, target)
elseif reaction >= 0 then
-- Talk ?
diff -crB original-tome-3.9.34/data/keybinds/tome.lua tome-3.9.34/data/keybinds/tome.lua
*** original-tome-3.9.34/data/keybinds/tome.lua 2011-08-04 11:34:24.000000000 -0700
--- tome-3.9.34/data/keybinds/tome.lua 2011-10-13 08:52:14.592700000 -0700
***************
*** 135,137 ****
--- 135,200 ----
group = "party",
name = "Give order to character 8",
}
+
+ defineAction{
+ default = { "sym:_b:false:false:false:false" },
+ type = "TOGGLE_BUMP_ATTACK",
+ group = "movement",
+ name = "Toggle movement mode",
+ }
+
+ defineAction{
+ default = { "sym:_LEFT:true:false:false:false", "sym:_KP_4:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_LEFT",
+ group = "movement",
+ name = "Attack left",
+ }
+
+ defineAction{
+ default = { "sym:_RIGHT:true:false:false:false", "sym:_KP_6:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_RIGHT",
+ group = "movement",
+ name = "Attack right",
+ }
+
+ defineAction{
+ default = { "sym:_UP:true:false:false:false", "sym:_KP_8:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_UP",
+ group = "movement",
+ name = "Attack up",
+ }
+
+ defineAction{
+ default = { "sym:_DOWN:true:false:false:false", "sym:_KP_2:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_DOWN",
+ group = "movement",
+ name = "Attack down",
+ }
+
+ defineAction{
+ default = { "sym:_KP_7:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_LEFT_UP",
+ group = "movement",
+ name = "Attack diagonally left and up",
+ }
+
+ defineAction{
+ default = { "sym:_KP_9:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_RIGHT_UP",
+ group = "movement",
+ name = "Attack diagonally right and up",
+ }
+
+ defineAction{
+ default = { "sym:_KP_1:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_LEFT_DOWN",
+ group = "movement",
+ name = "Attack diagonally left and down",
+ }
+
+ defineAction{
+ default = { "sym:_KP_3:true:false:false:false" },
+ type = "ATTACK_OR_MOVE_RIGHT_DOWN",
+ group = "movement",
+ name = "Attack diagonally right and down",
+ }