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

ammo creation

git-svn-id: http://svn.net-core.org/repos/t-engine4@362 51575b47-30f0-44d4-a5cc-537603b46e54
parent dc1d57d0
No related branches found
No related tags found
No related merge requests found
......@@ -108,6 +108,14 @@ function _M:unstack()
return o, false
end
--- Applies a function to all items of the stack
function _M:forAllStack(fct)
fct(self)
for i, so in ipairs(self.stacked) do
fct(so)
end
end
--- Returns the number of objects available
-- Always one for non stacking objects
function _M:getNumber()
......
......@@ -136,7 +136,7 @@ function _M:makeEntity(level, type, filter)
local list = level:getEntitiesList(type)
local e
local tries = 200
local tries = 500
-- CRUDE ! Brute force ! Make me smarter !
while tries > 0 do
e = self:pickEntity(list)
......
......@@ -37,7 +37,8 @@ local function tryDestroy(who, inven, destroy_prop, proof_prop, msg)
print(who, inven, destroy_prop, proof_prop, msg, "::", i)
if o[destroy_prop] and rng.percent(o[destroy_prop]) and not o[proof_prop] then
game.logPlayer(who, msg, o:getName())
who:removeObject(inven, i)
local obj = who:removeObject(inven, i)
obj:removed()
end
end
end
......
......@@ -135,10 +135,29 @@ newTalent{
type = {"technique/archery-utility", 1},
no_energy = true,
points = 5,
cooldown = 500,
cooldown = 1000,
stamina = 30,
require = techs_dex_req1,
action = function(self, t)
if not self:getInven("MAINHAND") then return nil end
local weapon = self:getInven("MAINHAND")[1]
if not weapon or not weapon.archery then
game.logPlayer("You must wield your archery weapon to forage.")
return nil
end
local st = "arrow"
if weapon.archery == "sling" then st = "shot" end
local o = game.zone:makeEntity(game.level, "object", {type="ammo", subtype=st})
if o and rng.percent(10 + self:getTalentLevel(t) * 10) then
o:identify(true)
o:forAllStack(function(so) so.cost = 0 end)
self:addObject(self.INVEN_INVEN, o)
game.logPlayer(self, "You create some ammo: %d %s", o:getNumber(), o:getName())
else
game.logPlayer(self, "You found nothing!")
end
return true
end,
info = function(self, t)
......
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