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

add money

git-svn-id: http://svn.net-core.org/repos/t-engine4@371 51575b47-30f0-44d4-a5cc-537603b46e54
parent f0af9952
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,7 @@ end
function _M:pickupFloor(i, vocal)
local o = game.level.map:getObject(self.x, self.y, i)
if o then
if self:addObject(self.INVEN_INVEN, o) then
if not o:check("on_prepickup", self, i) and self:addObject(self.INVEN_INVEN, o) then
game.level.map:removeObject(self.x, self.y, i)
o:check("on_pickup", self)
......
......@@ -73,6 +73,8 @@ function _M:init(t, no_default)
t.max_equilibrium = t.max_equilibrium or 100000
t.equilibrium = t.equilibrium or 0
t.money = t.money or 0
-- Default melee barehanded damage
self.combat = { dam=1, atk=1, apr=0, dammod={str=1} }
......
......@@ -69,6 +69,8 @@ function _M:descAttribute(attr)
elseif attr == "COMBAT" then
local c = self.combat
return c.dam.."-"..(c.dam*(c.damrange or 1.1)).." dam, "..(c.apr or 0).." apr"
elseif attr == "MONEY" then
return ("worth %0.2f"):format(self.money_value / 10)
end
end
......
......@@ -32,6 +32,7 @@ function _M:display()
h = h + self.font_h
self.surface:drawColorString(self.font, "Level: #00ff00#"..game.player.level, 0, h, 255, 255, 255) h = h + self.font_h
self.surface:drawColorString(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), 0, h, 255, 255, 255) h = h + self.font_h
self.surface:drawColorString(self.font, ("Gold: #00ff00#%0.2f"):format(game.player.money), 0, h, 255, 255, 255) h = h + self.font_h
h = h + self.font_h
......
......@@ -46,8 +46,8 @@ newBirthDescriptor{
},
copy = {
equipment = resolvers.equip{ id=true,
{type="weapon", subtype="longbow", name="elm longbow"},
{type="ammo", subtype="arrow", name="elm arrow"},
{type="weapon", subtype="longbow", name="elm longbow", autoreq=true},
{type="ammo", subtype="arrow", name="elm arrow", autoreq=true},
},
},
}
......@@ -79,8 +79,8 @@ newBirthDescriptor{
},
copy = {
equipment = resolvers.equip{ id=true,
{type="weapon", subtype="sling", name="elm sling"},
{type="ammo", subtype="shot", name="iron shot"},
{type="weapon", subtype="sling", name="elm sling", autoreq=true},
{type="ammo", subtype="shot", name="iron shot", autoreq=true},
},
},
}
......@@ -8,6 +8,7 @@ newBirthDescriptor{
body = { INVEN = 1000, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
copy = {
money = 10,
resolvers.equip{ id=true,
{type="lite", subtype="lite", name="brass lantern"},
},
......
......@@ -55,8 +55,8 @@ newBirthDescriptor{
max_life = 80,
life_rating = 7,
resolvers.equip{ id=true,
{type="weapon", subtype="staff", name="elm staff"},
{type="armor", subtype="cloth", name="robe"}
{type="weapon", subtype="staff", name="elm staff", autoreq=true},
{type="armor", subtype="cloth", name="robe", autoreq=true}
},
resolvers.inventory{ id=true,
{type="potion", subtype="potion", name="potion of lesser mana"},
......@@ -103,9 +103,9 @@ newBirthDescriptor{
mana_rating = 8,
stamina_rating = 8,
resolvers.equip{ id=true,
{type="weapon", subtype="staff", name="elm staff"},
{type="armor", subtype="shield", name="iron shield"},
{type="armor", subtype="cloth", name="robe"},
{type="weapon", subtype="staff", name="elm staff", autoreq=true},
{type="armor", subtype="shield", name="iron shield", autoreq=true},
{type="armor", subtype="cloth", name="robe", autoreq=true},
},
resolvers.inventory{ id=true,
{type="potion", subtype="potion", name="potion of lesser mana"},
......@@ -146,8 +146,8 @@ newBirthDescriptor{
max_life = 80,
life_rating = 7,
resolvers.equip{ id=true,
{type="weapon", subtype="staff", name="elm staff"},
{type="armor", subtype="cloth", name="robe"}
{type="weapon", subtype="staff", name="elm staff", autoreq=true},
{type="armor", subtype="cloth", name="robe", autoreq=true}
},
resolvers.inventory{ id=true,
{type="potion", subtype="potion", name="potion of lesser mana"},
......
......@@ -18,9 +18,9 @@ newBirthDescriptor{
max_life = 100,
life_rating = 9,
equipment = resolvers.equip{ id=true,
{type="weapon", subtype="dagger", name="iron dagger"},
{type="weapon", subtype="dagger", name="iron dagger"},
{type="armor", subtype="light", name="rough leather armour"}
{type="weapon", subtype="dagger", name="iron dagger", autoreq=true},
{type="weapon", subtype="dagger", name="iron dagger", autoreq=true},
{type="armor", subtype="light", name="rough leather armour", autoreq=true}
},
},
}
......
......@@ -86,8 +86,8 @@ newBirthDescriptor{
},
copy = {
resolvers.equip{ id=true,
{type="weapon", subtype="greatsword", name="iron greatsword"},
{type="armor", subtype="heavy", name="iron mail armour"}
{type="weapon", subtype="greatsword", name="iron greatsword", autoreq=true},
{type="armor", subtype="heavy", name="iron mail armour", autoreq=true},
},
},
}
newEntity{
define_as = "BASE_MONEY",
type = "money", subtype="money",
display = "$", color=colors.YELLOW,
encumber = 0,
rarity = 5,
identified = true,
desc = [[All that glisters is not gold, all that is gold does not glitter.]],
on_prepickup = function(self, who, id)
who.money = who.money + self.money_value / 10
-- Remove from the map
game.level.map:removeObject(who.x, who.y, id)
return true
end,
}
newEntity{ base = "BASE_MONEY",
name = "gold pieces",
add_name = " (#MONEY#)",
level_range = {1, 50},
money_value = resolvers.rngavg(1, 20),
}
-- Misc
load("/data/general/objects/money.lua")
load("/data/general/objects/lites.lua")
-- Usable stuff
......
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