diff --git a/game/engine/interface/ActorInventory.lua b/game/engine/interface/ActorInventory.lua index 9884d67efa4d7d304a94ece23cd72e06d06e8dba..47f83ac4bb883b2481fc9e33469cf604523905c2 100644 --- a/game/engine/interface/ActorInventory.lua +++ b/game/engine/interface/ActorInventory.lua @@ -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) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 7932ae27164d82750e743ec4ede934b49073958d..1bb70afa668d832d9b8e2b726eebe8bd29e8dc35 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -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} } diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua index 1064159cabd8592764faea7ee84111742860f4d1..d6a5bc06e61b39d1873998119bedaff4129a2cf5 100644 --- a/game/modules/tome/class/Object.lua +++ b/game/modules/tome/class/Object.lua @@ -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 diff --git a/game/modules/tome/class/PlayerDisplay.lua b/game/modules/tome/class/PlayerDisplay.lua index c465cd154ee257be1fbd8508ae7e80506758d1d1..e056b03150adea83473e111198b9e1b0c58a3762 100644 --- a/game/modules/tome/class/PlayerDisplay.lua +++ b/game/modules/tome/class/PlayerDisplay.lua @@ -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 diff --git a/game/modules/tome/data/birth/archer.lua b/game/modules/tome/data/birth/archer.lua index 0162945c1998d0b4ec385db2152eae20beabe904..d6fb48b869e0d15a668b30549251bb37cd939607 100644 --- a/game/modules/tome/data/birth/archer.lua +++ b/game/modules/tome/data/birth/archer.lua @@ -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}, }, }, } diff --git a/game/modules/tome/data/birth/descriptors.lua b/game/modules/tome/data/birth/descriptors.lua index 47ffbcb15c47b0a01305f157b3f27bd257704c2f..70682e5ef1b0b6056952343ff57a5b252f879ace 100644 --- a/game/modules/tome/data/birth/descriptors.lua +++ b/game/modules/tome/data/birth/descriptors.lua @@ -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"}, }, diff --git a/game/modules/tome/data/birth/mage.lua b/game/modules/tome/data/birth/mage.lua index 23c55cd849d1bb3ece9d9ea92a0df2cc0d948903..ed14d425cb9f4f6a2a6acaed09e39017a498ad9b 100644 --- a/game/modules/tome/data/birth/mage.lua +++ b/game/modules/tome/data/birth/mage.lua @@ -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"}, diff --git a/game/modules/tome/data/birth/rogue.lua b/game/modules/tome/data/birth/rogue.lua index 9cfde4877493aafb9ec492d7f9224ec25b755383..9076cf9d378ac4936af25327e165948d9286b220 100644 --- a/game/modules/tome/data/birth/rogue.lua +++ b/game/modules/tome/data/birth/rogue.lua @@ -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} }, }, } diff --git a/game/modules/tome/data/birth/warrior.lua b/game/modules/tome/data/birth/warrior.lua index 7d05df482b8cedf9aba458f33c05c479098d52dc..652cb6a785ac13f2c6197dc90944d21030c04f84 100644 --- a/game/modules/tome/data/birth/warrior.lua +++ b/game/modules/tome/data/birth/warrior.lua @@ -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}, }, }, } diff --git a/game/modules/tome/data/general/objects/money.lua b/game/modules/tome/data/general/objects/money.lua new file mode 100644 index 0000000000000000000000000000000000000000..26f658b3cab8ae22c7008889b3282b0af4ae77f1 --- /dev/null +++ b/game/modules/tome/data/general/objects/money.lua @@ -0,0 +1,22 @@ +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), +} diff --git a/game/modules/tome/data/general/objects/objects.lua b/game/modules/tome/data/general/objects/objects.lua index f164d38faff21637b6f02614fa885fe141c6c106..e8c603b110c1898762620ca24f2ff2e14f2810fc 100644 --- a/game/modules/tome/data/general/objects/objects.lua +++ b/game/modules/tome/data/general/objects/objects.lua @@ -1,4 +1,5 @@ -- Misc +load("/data/general/objects/money.lua") load("/data/general/objects/lites.lua") -- Usable stuff