Skip to content
Snippets Groups Projects
Commit c15951a5 authored by dg's avatar dg
Browse files

Qucik Weapon Set SWitch key (x by default)

git-svn-id: http://svn.net-core.org/repos/t-engine4@826 51575b47-30f0-44d4-a5cc-537603b46e54
parent 77d0550b
No related branches found
No related tags found
No related merge requests found
......@@ -62,3 +62,10 @@ defineAction{
group = "inventory",
name = "Use items",
}
defineAction{
default = { "uni:x", },
type = "QUICK_SWITCH_WEAPON",
group = "inventory",
name = "Quick switch weapons set",
}
......@@ -44,6 +44,7 @@ function _M:defineInventory(short_name, name, is_worn, desc)
self.inven_def[#self.inven_def].id = #self.inven_def
self.inven_def[short_name] = self.inven_def[#self.inven_def]
self["INVEN_"..short_name:upper()] = #self.inven_def
print("[INVENTORY] define slot", #self.inven_def, self.inven_def[#self.inven_def].name)
end
-- Auto define the inventory
......@@ -268,6 +269,7 @@ function _M:wearObject(o, replace, vocal)
if vocal then game.logSeen(self, "%s is not wearable.", o:getName{do_color=true}) end
return false
end
print("wear slot", inven)
local ok, err = self:canWearObject(o)
if not ok then
if vocal then game.logSeen(self, "%s can not wear: %s (%s).", self.name:capitalize(), o:getName{do_color=true}, err) end
......
......@@ -655,6 +655,10 @@ function _M:setupCommands()
self.player:playerUseItem()
end),
QUICK_SWITCH_WEAPON = function()
self.player:quickSwitchWeapons()
end,
USE_TALENTS = not_wild(function()
self.player:useTalents()
end),
......
......@@ -44,19 +44,6 @@ module(..., package.seeall, class.inherit(
))
function _M:init(t, no_default)
t.body = {
INVEN = 1000,
MAINHAND = 1,
OFFHAND = 1,
FINGER = 2,
NECK = 1,
LITE = 1,
BODY = 1,
HEAD = 1,
HANDS = 1,
FEET = 1,
TOOL = 1,
}
t.display=t.display or '@'
t.color_r=t.color_r or 230
t.color_g=t.color_g or 230
......@@ -490,6 +477,28 @@ function _M:playerUseItem(object, item, inven)
)
end
function _M:quickSwitchWeapons()
local mh1, mh2 = self.inven[self.INVEN_MAINHAND], self.inven[self.INVEN_QS_MAINHAND]
local oh1, oh2 = self.inven[self.INVEN_OFFHAND], self.inven[self.INVEN_QS_OFFHAND]
local mhset1, mhset2 = {}, {}
local ohset1, ohset2 = {}, {}
-- Remove them all
for i = #mh1, 1, -1 do mhset1[#mhset1+1] = self:removeObject(mh1, i, true) end
for i = #mh2, 1, -1 do mhset2[#mhset2+1] = self:removeObject(mh2, i, true) end
for i = #oh1, 1, -1 do ohset1[#ohset1+1] = self:removeObject(oh1, i, true) end
for i = #oh2, 1, -1 do ohset2[#ohset2+1] = self:removeObject(oh2, i, true) end
-- Put them all back
for i = 1, #mhset1 do self:addObject(mh2, mhset1[i]) end
for i = 1, #mhset2 do self:addObject(mh1, mhset2[i]) end
for i = 1, #ohset1 do self:addObject(oh2, ohset1[i]) end
for i = 1, #ohset2 do self:addObject(oh1, ohset2[i]) end
self:useEnergy()
game.logPlayer(self, "You switch your weapons.")
end
function _M:playerLevelup(on_finish)
if self.unused_stats > 0 then
local ds = LevelupStatsDialog.new(self, on_finish)
......
......@@ -40,7 +40,7 @@ newBirthDescriptor{
},
talents = {},
experience = 1.0,
body = { INVEN = 1000, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
body = { INVEN = 1000, QS_MAINHAND = 1, QS_OFFHAND = 1, MAINHAND = 1, OFFHAND = 1, FINGER = 2, NECK = 1, LITE = 1, BODY = 1, HEAD = 1, HANDS = 1, FEET = 1, TOOL = 1, QUIVER = 1 },
copy = {
-- Mages are unheard of at first, nobody but them regenerates mana
......
......@@ -54,6 +54,8 @@ dofile("/mod/resolvers.lua")
-- Body parts
ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.")
ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use shields or a second weapon in your off-hand, if you have the talents for it.")
ActorInventory:defineInventory("QS_MAINHAND", "In main hand (2)", false, "Weapon Set 2: Most weapons are wielded in the main hand.")
ActorInventory:defineInventory("QS_OFFHAND", "In off hand (2)", false, "Weapon Set 2: You can use shields or a second weapon in your off-hand, if you have the talents for it.")
ActorInventory:defineInventory("FINGER", "On fingers", true, "Rings are worn on fingers.")
ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets are worn around the neck.")
ActorInventory:defineInventory("LITE", "Light source", true, "A light source allows you to see in the dark places of the world.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment