Skip to content

Commit

Permalink
Merge pull request #2 from timothymtorres/Barricades-&-Tracking
Browse files Browse the repository at this point in the history
New Barricades, Tracking, and Item Durability features
  • Loading branch information
timothymtorres committed Nov 7, 2016
2 parents da79f3e + d7deb15 commit f3c4cc8
Show file tree
Hide file tree
Showing 62 changed files with 855 additions and 551 deletions.
31 changes: 21 additions & 10 deletions code/item/class.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local class = require('code.libs.middleclass')
local b_list = require('code.item.list.barricade')
local e_list = require('code.item.list.equipment')
local g_list = require('code.item.list.gadget')
local j_list = require('code.item.list.junk')
Expand All @@ -10,6 +9,7 @@ local order = require('code.item.order')
local bit = require('plugin.bit')
local lshift, rshift, bor = bit.lshift, bit.rshift, bit.bor
local check = require('code.item.use.check')
local dice = require('code.libs.rl-dice.dice')

local item = class('item')

Expand All @@ -23,7 +23,7 @@ local function selectFrom(spawn_list)
end

local condition_spawn_odds = { -- used when spawning new item
--ruined = {[1] = 0.60, [2] = 0.25, [3] = 0.10, [4] = 0.05},
ruined = {[1] = 0.60, [2] = 0.25, [3] = 0.10, [4] = 0.05},
unpowered = {[1] = 0.25, [2] = 0.40, [3] = 0.25, [4] = 0.10},
powered = {[1] = 0.10, [2] = 0.25, [3] = 0.40, [4] = 0.25},
}
Expand Down Expand Up @@ -54,6 +54,22 @@ function item:hasUses() return self.designated_uses and true or false end

function item:isWeapon() return self.designated_weapon or false end

function item:isSingleUse() return self.one_use or false end

function item:failDurabilityCheck(player)
-- skill mastery provides +20% durability bonus to items
local durability = (player.skills:check(self.master_skill) and math.floor(self.durability*1.2 + 0.5)) or self.durability
return dice.roll(durability) <= 1
end

function item:updateCondition(num, player, inv_ID)
self.condition = self.condition + num -- is condition 1-4 or 0-3?! Might need to fix this... Also add math.max(whatever the limit is...)
if self.condition < 0 then -- item is destroyed
player.inventory:remove(inv_ID)
-- include announcement msg?
end
end

function item:isConditionVisible(player) end

function item:getName() return self.name end
Expand All @@ -77,13 +93,6 @@ print('getFlag()', ID, 2)
return flag
end

--[[
function item:getID()
print(item, self:getClassName())
print(item[self:getClassName()], item[self:getClassName()].ID)
return item[self:getClassName()].ID end
--]]

function item:getUses() return self.uses end

function item:getCondition() return self.condition end
Expand All @@ -96,6 +105,8 @@ function item:getClassCategory() return self.class_category end

function item:getWeight() return self.weight end

function item:getMasterSkill() return self.master_skill end

function item:dataToClass(...) -- this should be a middleclass function (fix later)
local combined_lists = {...}
for _, list in ipairs(combined_lists) do
Expand All @@ -118,6 +129,6 @@ function item:dataToClass(...) -- this should be a middleclass function (fix lat
end

-- turn our list of objs into item class
item:dataToClass(b_list, e_list, g_list, j_list, m_list, w_list, a_list)
item:dataToClass(e_list, g_list, j_list, m_list, w_list, a_list)

return item
12 changes: 5 additions & 7 deletions code/item/list/ammo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@ local ammo = {}
full_name = 'insert name'
weight = num
class_category = 'military'
condition_omitted = nil/true (if omitted, item has no condition levels)
special = nil/4/16 (bit_flags for special) [ammo, color, battery_life, etc.]
one_use = true
--]]

ammo.pistol_mag = {}
ammo.pistol_mag.full_name = 'pistol magazine'
ammo.pistol_mag.weight = 3
ammo.pistol_mag.condition_omitted = true

ammo.shotgun_shell = {}
ammo.shotgun_shell.full_name = 'shotgun shell'
ammo.shotgun_shell.weight = 2
ammo.shotgun_shell.condition_omitted = true

ammo.rifle_clip = {}
ammo.rifle_clip.full_name = 'rifle clip'
ammo.rifle_clip.weight = 5
ammo.rifle_clip.condition_omitted = true

ammo.quiver = {}
ammo.quiver.full_name = 'quiver'
ammo.quiver.weight = 4
ammo.quiver.condition_omitted = true

for item in pairs(ammo) do ammo[item].class_category = 'military' end
for item in pairs(ammo) do
ammo[item].class_category = 'military'
ammo[item].one_use = true -- all ammo is single use
end

return ammo
12 changes: 9 additions & 3 deletions code/item/list/equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ local equipment = {}
size = 1/2/3/4
weight = num
class_category = 'engineering'
condition_omitted = nil/true (if omitted, item has no condition levels)
special = nil/4/16 (bit_flags for special) [radio_freq, ammo, color, battery_life, etc.]
one_use = true
durability = num (average # of uses when equipment installed before it wears out)
--]]

equipment.generator = {}
equipment.generator.full_name = 'generator'
equipment.generator.weight = 25
equipment.generator.durability = 100

equipment.transmitter = {}
equipment.transmitter.full_name = 'transmitter'
equipment.transmitter.weight = 25
equipment.transmitter.durability = 100

equipment.terminal = {}
equipment.terminal.full_name = 'terminal'
equipment.terminal.weight = 25
equipment.terminal.durability = 100

equipment.fuel = {}
equipment.fuel.full_name = 'fuel tank'
Expand All @@ -29,6 +32,9 @@ equipment.barricade = {}
equipment.barricade.full_name = 'barricade'
equipment.barricade.weight = 7

for item in pairs(equipment) do equipment[item].class_category = 'equipment' end
for item in pairs(equipment) do
equipment[item].class_category = 'engineering'
equipment[item].one_use = true
end

return equipment
12 changes: 8 additions & 4 deletions code/item/list/gadget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,35 @@ local gadget = {}
size = 1/2/3/4
weight = num
class_category = 'research'
condition_omitted = nil/true (if omitted, item has no condition levels)
special = nil/4/16 (bit_flags for special) [radio_freq, ammo, color, battery_life, etc.]
durability = num (average # of uses before the item wears out)
--]]

gadget.radio = {}
gadget.radio.full_name = 'portable radio'
gadget.radio.weight = 3
gadget.radio.durability = 100

gadget.GPS = {}
gadget.GPS = {} -- GPS for humans should have a small chance to grant a free AP for movement
gadget.GPS.full_name = 'global position system'
gadget.GPS.weight = 2
gadget.GPS.durability = 300

--[[
gadget.cellphone = {}
gadget.cellphone.full_name = 'cellphone'
gadget.cellphone.weight = 2
gadget.cellphone.durability = 200
gadget.sampler = {}
gadget.sampler.full_name = 'lab sampler'
gadget.sampler.weight = 4
gadget.loudspeaker = {}
gadget.loudspeaker.full_name = 'loudspeaker'
gadget.loudspeaker.weight = 1
--[[ used for searching? give search bonus?!
--used for searching? give search bonus?!
gadget.flashlight = {}
gadget.flashlight.full_name = 'flashlight'
gadget.flashlight.weight = 4
Expand Down
7 changes: 4 additions & 3 deletions code/item/list/junk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ local junk = {}
size = 1/2/3/4
weight = num
class_category = 'research'
condition_omitted = nil/true (if omitted, item has no condition levels)
special = nil/4/16 (bit_flags for special) [radio_freq, ammo, color, battery_life, etc.]
one_use = true/nil
--]]

junk.book = {}
junk.book.full_name = 'book'
junk.book.weight = 2
junk.book.class_category = 'research'
junk.book.one_use = true

junk.bottle = {}
junk.bottle.full_name = 'bottle'
junk.bottle.weight = 1
junk.bottle.class_category = 'junk'
junk.bottle.one_use = true

junk.newspaper = {}
junk.newspaper.full_name = 'newspaper'
junk.newspaper.weight = 1
junk.newspaper.class_category = 'junk'
junk.newspaper.condition_omitted = true
junk.newspaper.one_use = true

return junk
7 changes: 5 additions & 2 deletions code/item/list/medical.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ local medical = {}
weight = num
designated_weapon = true/nil
class_category = 'medical'/'research'
condition_omitted = nil/true (if omitted, item has no condition levels)
special = nil/4/16 (bit_flags for special) [radio_freq, ammo, color, battery_life, etc.]
one_use = true
--]]

medical.FAK = {}
Expand All @@ -31,4 +30,8 @@ medical.syringe.weight = 5
medical.syringe.designated_weapon = true
medical.syringe.class_category = 'research'

for item in pairs(medical) do
medical[item].one_use = true
end

return medical
55 changes: 36 additions & 19 deletions code/item/list/weaponry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ local weaponry = {}

--[[
full_name = 'insert name'
size = 1/2/3/4
weight = num
designated_weapon = true/nil
class_category = military/research/engineering/medical
==(not sure about these bottom ones? code rewrite)==
condition_omitted = nil/true (if omitted, item has no condition levels)
special = nil/4/8/16 (bit_flags for special) [radio_freq, ammo, color, battery_life, etc.]
one_use = true/nil
durability = num (average # of attacks to wear out weapon)
--]]

--[[
Expand All @@ -20,18 +16,26 @@ local weaponry = {}
weaponry.crowbar = {}
weaponry.crowbar.full_name = 'crowbar'
weaponry.crowbar.weight = 8

weaponry.toolbox = {}
weaponry.toolbox.full_name = 'toolbox'
weaponry.toolbox.weight = 15
weaponry.crowbar.master_skill = 'smacking'
weaponry.crowbar.durability = 25

weaponry.bat = {}
weaponry.bat.full_name = 'baseball bat'
weaponry.bat.weight = 9
weaponry.bat.master_skill = 'smacking'
weaponry.bat.durability = 15

weaponry.toolbox = {}
weaponry.toolbox.full_name = 'toolbox'
weaponry.toolbox.weight = 15
weaponry.toolbox.master_skill = 'smashing'
weaponry.toolbox.durability = 10

weaponry.sledge = {}
weaponry.sledge.full_name = 'sledgehammer'
weaponry.sledge.weight = 25
weaponry.sledge.master_skill = 'smashing'
weaponry.sledge.durability = 20

--[[
--- BLADE
Expand All @@ -40,10 +44,14 @@ weaponry.sledge.weight = 25
weaponry.knife = {}
weaponry.knife.full_name = 'knife'
weaponry.knife.weight = 3
weaponry.knife.master_skill = 'slicing'
weaponry.knife.durability = 10

weaponry.katanna = {}
weaponry.katanna.full_name = 'katanna'
weaponry.katanna.weight = 7
weaponry.katanna.master_skill = 'chopping'
weaponry.katanna.durability = 15

--[[
--- PROJECTILE
Expand All @@ -52,39 +60,48 @@ weaponry.katanna.weight = 7
weaponry.pistol = {}
weaponry.pistol.full_name = 'pistol'
weaponry.pistol.weight = 6
weaponry.pistol.special = 16
weaponry.pistol.master_skill = 'light_guns'
weaponry.pistol.durability = 40

weaponry.magnum = {}
weaponry.magnum.full_name = 'magnum'
weaponry.magnum.weight = 6
weaponry.magnum.special = 8
weaponry.magnum.master_skill = 'light_guns'
weaponry.magnum.durability = 50

weaponry.shotgun = {}
weaponry.shotgun.full_name = 'shotgun'
weaponry.shotgun.weight = 10
weaponry.shotgun.special = 4

weaponry.flare = {}
weaponry.flare.full_name = 'flare'
weaponry.flare.weight = 5
weaponry.shotgun.master_skill = 'heavy_guns'
weaponry.shotgun.durability = 40

weaponry.rifle = {}
weaponry.rifle.full_name = 'assualt rifle'
weaponry.rifle.weight = 15
weaponry.rifle.special = 8
weaponry.rifle.master_skill = 'heavy_guns'
weaponry.rifle.durability = 40

--[[
weaponry.bow = {}
weaponry.bow.full_name = 'bow'
weaponry.bow.weight = 9
weaponry.bow.special = 8
weaponry.missle = {}
weaponry.missle.full_name = 'missle launcher'
weaponry.missle.weight = 25
--]]

weaponry.flare = {}
weaponry.flare.full_name = 'flare'
weaponry.flare.weight = 5
weaponry.flare.one_use = true
weaponry.flare.master_skill = 'explosives'

weaponry.molotov = {}
weaponry.molotov.full_name = 'molotov cocktail'
weaponry.molotov.weight = 5
weaponry.molotov.one_use = true
weaponry.molotov.master_skill = 'explosives'

for item in pairs(weaponry) do
weaponry[item].designated_weapon = true
Expand Down
6 changes: 2 additions & 4 deletions code/item/order.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ local order = {
-- MEDICAL
'FAK', 'bandage', 'antidote', 'syringe',
-- EQUIPMENT
'transmitter', 'generator', 'terminal', 'fuel',
'barricade', 'transmitter', 'generator', 'terminal', 'fuel',
-- GADGET
'radio', 'cellphone', 'sampler', 'GPS',
'radio', 'GPS', --'cellphone', 'sampler'
-- JUNK
'book', 'bottle', 'newspaper',
-- AMMO
'pistol_mag', 'shotgun_shell', 'rifle_clip', 'quiver',
-- BARRICADE
'small', 'medium', 'large', 'heavy',
}

return order
Loading

0 comments on commit f3c4cc8

Please sign in to comment.