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

pop


git-svn-id: http://svn.net-core.org/repos/t-engine4@1277 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1c856b09
No related branches found
No related tags found
No related merge requests found
......@@ -34,21 +34,27 @@ end
-- This requires the ActorTalents interface to use talents and a method player:playerUseItem(o, item, inven) to use inventory objects
function _M:activateHotkey(id)
if self.hotkey[id] then
if self.hotkey[id][1] == "talent" then
self:useTalent(self.hotkey[id][2])
elseif self.hotkey[id][1] == "inventory" then
local o, item, inven = self:findInAllInventories(self.hotkey[id][2])
if not o then
Dialog:simplePopup("Item not found", "You do not have any "..self.hotkey[id][2]..".")
else
self:playerUseItem(o, item, inven)
end
end
self["hotkey"..self.hotkey[id][1]:capitalize()](self, self.hotkey[id][2])
else
Dialog:simplePopup("Hotkey not defined", "You may define a hotkey by pressing 'm' and following the inscructions there.")
end
end
--- Activates a hotkey with a type "talent"
function _M:hotkeyTalent(tid)
self:useTalent(tid)
end
--- Activates a hotkey with a type "inventory"
function _M:hotkeyInventory(name)
local o, item, inven = self:findInAllInventories(name)
if not o then
Dialog:simplePopup("Item not found", "You do not have any "..name..".")
else
self:playerUseItem(o, item, inven)
end
end
--- Switch to previous hotkey page
function _M:prevHotkeyPage()
self.hotkey_page = util.boundWrap(self.hotkey_page - 1, 1, 3)
......
......@@ -59,7 +59,9 @@ function _M:act()
end
--- Use the object (quaff, read, ...)
function _M:use(who, typ)
function _M:use(who, typ, inven, item)
inven = who:getInven(inven)
if self.use_no_blind and who:attr("blind") then
game.logPlayer(who, "You cannot see!")
return
......@@ -79,7 +81,7 @@ function _M:use(who, typ)
if not typ and #types == 1 then typ = types[1] end
if typ == "use" then
who:useEnergy()
who:useEnergy(game.energy_to_act * (inven.use_speed or 1))
if self.use_sound then game:playSoundNear(who, self.use_sound) end
return self:useObject(who)
end
......
......@@ -445,6 +445,27 @@ function _M:runMoved()
self:playerFOV()
end
--- Activates a hotkey with a type "inventory"
function _M:hotkeyInventory(name)
local find = function(name)
local os = {}
for inven_id, inven in pairs(self.inven) do
local o, item = self:findInInventory(inven, name, getname)
if o and item then os[#os+1] = {o, item, inven_id, inven} end
end
if #os == 0 then return end
table.sort(os, function(a, b) return (a[4].use_speed or 1) < (b[4].use_speed or 1) end)
return os[1][1], os[1][2], os[1][3]
end
local o, item, inven = find(name)
if not o then
Dialog:simplePopup("Item not found", "You do not have any "..name..".")
else
self:playerUseItem(o, item, inven)
end
end
function _M:doDrop(inven, item)
if game.zone.wilderness then
Dialog:yesnoLongPopup("Warning", "You cannot drop items on the world map.\nIf you drop it, it will be lost forever.", 300, function(ret)
......@@ -523,7 +544,7 @@ function _M:playerWear()
local inven = self:getInven(self.INVEN_INVEN)
local titleupdator = self:getEncumberTitleUpdator("Wield/wear object")
self:showInventory(titleupdator(), inven, function(o)
return o:wornInven() and true or false
return o:wornInven() and self:getInven(o:wornInven()) and true or false
end, function(o, item)
self:doWear(inven, item, o)
end)
......@@ -542,7 +563,7 @@ function _M:playerUseItem(object, item, inven)
local use_fct = function(o, inven, item)
local co = coroutine.create(function()
self.changed = true
local ret, no_id = o:use(self)
local ret, no_id = o:use(self, nil, inven, item)
if not no_id then
o:identify(true)
end
......
......@@ -54,12 +54,12 @@ newEntity{
cost = 6,
belt_slots = resolvers.mbonus_material(6, 3, function(e, v) return v * 1 end),
on_wear = function(self, who)
who.inven[who.INVEN_INBELT] = {max=self.belt_slots, worn=false, id=who.INVEN_INBELT}
who.inven[who.INVEN_INBELT] = {max=self.belt_slots, worn=false, use_speed=0.6, id=who.INVEN_INBELT}
end,
on_cantakeoff = function(self, who)
if #who:getInven(who.INVEN_INBELT) > 0 then
game.logPlayer(who, "You can not remove %s while it still carries items.", self:getName{do_color=true})
return false
return true
end
end,
on_takeoff = function(self, who)
......
......@@ -19,7 +19,7 @@
newEntity{
define_as = "BASE_POTION",
slot = "INBELT",
slot = "INBELT", use_no_wear=true,
type = "potion", subtype="potion",
unided_name = "potion", id_by_type = true,
display = "!", color=colors.WHITE, image="object/potion-0x0.png",
......
......@@ -19,7 +19,7 @@
newEntity{
define_as = "BASE_SCROLL",
slot = "INBELT",
slot = "INBELT", use_no_wear=true,
type = "scroll", subtype="scroll",
unided_name = "scroll", id_by_type = true,
display = "?", color=colors.WHITE, image="object/scroll.png",
......
......@@ -78,7 +78,7 @@ function _M:generateList()
local list = {}
if self.object:canUseObject() then list[#list+1] = {name="Use", action="use"} end
if self.inven == self.actor.INVEN_INVEN and self.object:wornInven() then list[#list+1] = {name="Wield/Wear", action="wear"} end
if self.inven == self.actor.INVEN_INVEN and self.object:wornInven() and self.actor:getInven(self.object:wornInven()) then list[#list+1] = {name="Wield/Wear", action="wear"} end
if self.inven ~= self.actor.INVEN_INVEN and self.object:wornInven() then list[#list+1] = {name="Take off", action="takeoff"} end
if self.inven == self.actor.INVEN_INVEN then list[#list+1] = {name="Drop", action="drop"} end
......
......@@ -70,10 +70,10 @@ ActorInventory:defineInventory("BODY", "Main armor", true, "Armor protects you f
ActorInventory:defineInventory("CLOAK", "Cloak", true, "A cloak can simply keep you warm or grant you wonderous powers should you find a magical one.")
ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head")
ActorInventory:defineInventory("BELT", "Around waist", true, "Belts are worn around your waist.")
ActorInventory:defineInventory("INBELT", "In your belt", true, "Put small objects in your belt, using them from the belt only uses 60% of the normal time.")
ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.")
ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.")
ActorInventory:defineInventory("TOOL", "Tool", true, "This is your readied tool, always available immediately.")
ActorInventory:defineInventory("INBELT", "In your belt", true, "Put small objects in your belt.")
ActorInventory:defineInventory("QUIVER", "Quiver", true, "Your readied ammo.")
ActorInventory:defineInventory("MOUNT", "Mount", false, "Your mount.")
......
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