diff --git a/code/item/class.lua b/code/item/class.lua index b32cd6f..55d6d56 100644 --- a/code/item/class.lua +++ b/code/item/class.lua @@ -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') @@ -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') @@ -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}, } @@ -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 @@ -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 @@ -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 @@ -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 \ No newline at end of file diff --git a/code/item/list/ammo.lua b/code/item/list/ammo.lua index d83d089..31dcea2 100644 --- a/code/item/list/ammo.lua +++ b/code/item/list/ammo.lua @@ -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 \ No newline at end of file diff --git a/code/item/list/equipment.lua b/code/item/list/equipment.lua index 016c35e..04d1ea9 100644 --- a/code/item/list/equipment.lua +++ b/code/item/list/equipment.lua @@ -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' @@ -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 \ No newline at end of file diff --git a/code/item/list/gadget.lua b/code/item/list/gadget.lua index f50acc9..847bd2f 100644 --- a/code/item/list/gadget.lua +++ b/code/item/list/gadget.lua @@ -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 diff --git a/code/item/list/junk.lua b/code/item/list/junk.lua index 15113f3..f5c13ab 100644 --- a/code/item/list/junk.lua +++ b/code/item/list/junk.lua @@ -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 \ No newline at end of file diff --git a/code/item/list/medical.lua b/code/item/list/medical.lua index 58b2266..26c35e2 100644 --- a/code/item/list/medical.lua +++ b/code/item/list/medical.lua @@ -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 = {} @@ -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 \ No newline at end of file diff --git a/code/item/list/weaponry.lua b/code/item/list/weaponry.lua index 4e1a1b3..6d6b489 100644 --- a/code/item/list/weaponry.lua +++ b/code/item/list/weaponry.lua @@ -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) --]] --[[ @@ -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 @@ -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 @@ -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 diff --git a/code/item/order.lua b/code/item/order.lua index 4c51eab..1c85cad 100644 --- a/code/item/order.lua +++ b/code/item/order.lua @@ -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 \ No newline at end of file diff --git a/code/item/use/activate.lua b/code/item/use/activate.lua index 3f23391..6bc52ed 100644 --- a/code/item/use/activate.lua +++ b/code/item/use/activate.lua @@ -8,7 +8,7 @@ local activate = {} --- MEDICAL --]] -function activate.FAK(player, target, condition) +function activate.FAK(player, condition, target) local FAK = lookupMedical('FAK') local FAK_dice = dice:new(FAK:getDice()) local tile = player:getTile() @@ -35,7 +35,7 @@ function activate.FAK(player, target, condition) print('You heal with '..FAK:getName()..' for '..hp_gained..' hp.') end -function activate.bandage(player, target, condition) +function activate.bandage(player, condition, target) local bandage = lookupMedical('bandage') local bandage_dice = dice:new(bandage:getDice()) @@ -57,7 +57,7 @@ function activate.bandage(player, target, condition) print('You heal with '..bandage:getName()..' for '..hp_gained..' hp.') end -function activate.antidote(player, target, condition) +function activate.antidote(player, condition, target) local antidote = lookupMedical('antidote') local cure_chance = antidote:getAccuracy() -- modify chance based on skills? @@ -72,7 +72,7 @@ function activate.antidote(player, target, condition) end end -function activate.syringe(player, target, condition) +function activate.syringe(player, condition, target) local syringe = lookupMedical('syringe') local inject_chance = syringe:getAccuracy() -- modify chance based on skills? @@ -95,7 +95,7 @@ end --- GADGETS --]] -function activate.radio(player, old_freq, new_freq, condition) +function activate.radio(player, condition, old_freq, new_freq) player.inventory:updateRadio(player, 'remove', old_freq, condition) player.inventory:updateRadio(player, 'insert', new_freq, condition) end @@ -104,7 +104,7 @@ function activate.cellphone(player, condition) end -function activate.sampler(player, target, condition) +function activate.sampler(player, condition, target) end @@ -129,7 +129,8 @@ end --]] function activate.barricade(player, condition) - + local building_tile = player:getTile() + building_tile.barricade:fortify(player, condition) end function activate.fuel(player, condition) diff --git a/code/item/use/check.lua b/code/item/use/check.lua index 0298c8b..09d613c 100644 --- a/code/item/use/check.lua +++ b/code/item/use/check.lua @@ -52,7 +52,10 @@ end --]] function check.barricade(player) - + local p_tile = player:getTile() + assert(playerInsideBuilding(player), 'Must be inside building to barricade') + assert(p_tile.barricade:roomForFortification(), 'There is no room available for fortifications') + assert(p_tile.barricade:canPlayerFortify(player), 'Unable to make stronger fortification without required skills') end function check.fuel(player) diff --git a/code/item/use/criteria.lua b/code/item/use/criteria.lua index 1b822d9..ab8b0f0 100644 --- a/code/item/use/criteria.lua +++ b/code/item/use/criteria.lua @@ -107,9 +107,16 @@ end --]] function criteria.barricade(player) - + local p_tile = player:getTile() + assert(playerInsideBuilding(player), 'Must be inside building to barricade') + assert(p_tile.barricade:roomForFortification(), 'There is no room available for fortifications') + assert(p_tile.barricade:canPlayerFortify(player), 'Unable to make stronger fortification without required skills') end +error_list[#error_list+1] = 'Must be inside building to barricade' +error_list[#error_list+1] = 'There is no room available for fortifications' +error_list[#error_list+1] = 'Unable to make stronger fortification without required skills' + function criteria.fuel(player) local p_tile = player:getTile() assert(playerInsideBuilding(player), 'Must be inside building to refuel') @@ -148,32 +155,4 @@ function criteria.newspaper(player) end -- need light? function criteria.bottle(player) end ---[[ ---- BARRICADES ---]] - -function criteria.small(player) - assert(playerInsideBuilding(player), 'Must be inside building to use barricade') -end - -error_list[#error_list+1] = 'Must be inside building to use barricade' - -function criteria.medium(player) - assert(playerInsideBuilding(player), 'Must be inside building to use barricade') -end - -error_list[#error_list+1] = 'Must be inside building to use barricade' - -function criteria.large(player) - assert(playerInsideBuilding(player), 'Must be inside building to use barricade') -end - -error_list[#error_list+1] = 'Must be inside building to use barricade' - -function criteria.heavy(player) - assert(playerInsideBuilding(player), 'Must be inside building to use barricade') -end - -error_list[#error_list+1] = 'Must be inside building to use barricade' - return criteria \ No newline at end of file diff --git a/code/item/weapon/class.lua b/code/item/weapon/class.lua index 5695da6..7669b88 100644 --- a/code/item/weapon/class.lua +++ b/code/item/weapon/class.lua @@ -19,6 +19,8 @@ function weapon:isSkillRequired() return (self.skill_required and true) or false function weapon:isCombustionSource() return self.combustion_source or false end +function weapon:isSingleUse() return self.one_use or false end + function weapon:hasConditionEffect(player) if self:getClassName() == 'claw' and not player.skills:check('grapple') then return false -- if attacking with claws and missing grapple skill then no condition effect diff --git a/code/location/building/barrier/barricade/class.lua b/code/location/building/barrier/barricade/class.lua index 5f600e6..1dd0179 100644 --- a/code/location/building/barrier/barricade/class.lua +++ b/code/location/building/barrier/barricade/class.lua @@ -4,20 +4,45 @@ local barrier = require('code.location.building.barrier.class') local barricade = class('barricade', barrier) local DEFAULT_HP, DEFAULT_POTENTIAL_HP = 0, 15 +local MIN_POTENTIAL_HP = 15 local MAX_HP = 63 +local fortification_status = { + {desc = 'secured', range = 0}, -- 0 + {desc = 'loose', range = 6}, -- 1-06 [6] + {desc = 'light', range = 13}, -- 7-13 [7] + {desc = 'regular', range = 21}, -- 14-21 [8] + {desc = 'strong', range = 30}, -- 22-30 [9] + {desc = 'very strong', range = 40}, -- 31-40 [10] + {desc = 'heavily', range = 51}, -- 41-51 [11] + {desc = 'extremely heavily', range = 63}, -- 52-63 [12] +} + +local room_available = { + {desc = 'no', range = 0}, -- 0 + {desc = 'little', range = 4}, -- 1-04 + {desc = 'some', range = 8}, -- 5-08 + {desc = 'plenty', range = 63}, -- 7-63 +} + function barricade:initialize(type) barrier.initialize(self) self.hp = DEFAULT_HP self.potential_hp = DEFAULT_POTENTIAL_HP + + self.hp_desc = fortification_status[1].desc + self.potential_hp_desc = room_available[4].desc end barricade.max_hp = MAX_HP +function barricade:getDesc() return self.hp_desc, self.potential_hp_desc end + function barricade:updateHP(num) self.hp = math.min( math.max(self.hp+num, 0), self.potential_hp) -- if damage done to barricade, need to subtract it from potential_hp as well (default_potential_hp is the lowest it can go) - if num < 0 then self.potential_hp = math.max(self.potential_hp - num, DEFAULT_POTENTIAL_HP) end + if num < 0 then self.potential_hp = math.max(self.potential_hp - num, MIN_POTENTIAL_HP) end + self:updateDesc() end function barricade:isDestroyed() return self.hp == 0 end @@ -31,7 +56,6 @@ local reinforce_potential_params = { {margin = 3, range = 63}, -- 53-63 [11] } -local MIN_POTENTIAL_HP = 15 local MIN_HP_TO_REINFORCE = 9 function barricade:canReinforce() @@ -83,34 +107,19 @@ function barricade:reinforce() end local reinforce_dice = dice:new(dice_str, 0) - self.potential_hp = math.min(self.potential_hp + reinforce_dice.roll(), MAX_HP) - -- we should probably return something to notify if the reinforce action failed (ie. rolled a 0) + local roll_result = reinforce_dice.roll() + if roll_result > 0 then + self.potential_hp = math.min(self.potential_hp + roll_result, MAX_HP) + self:updateDesc() + else -- reinforce action failed (roll == 0) + -- we should probably return something to notify if the reinforce action failed (ie. rolled a 0) + end end -local fortification_status = { - {desc = 'empty', range = 0}, -- 0 - {desc = 'loose', range = 6}, -- 1-06 [6] - {desc = 'light', range = 13}, -- 7-13 [7] - {desc = 'regular', range = 21}, -- 14-21 [8] - {desc = 'strong', range = 30}, -- 22-30 [9] - {desc = 'very strong', range = 40}, -- 31-40 [10] - {desc = 'heavily', range = 51}, -- 41-51 [11] - {desc = 'extremely heavily', range = 63}, -- 52-63 [12] -} - -local room_available = { - {desc = 'none', range = 0}, -- 0 - {desc = 'little', range = 3}, -- 1-03 - {desc = 'moderate', range = 6}, -- 4-06 - {desc = 'large', range = 63}, -- 7-63 -} - -function barricade:getDesc() - local fort_desc, fort_avail_desc - +function barricade:updateDesc() for i, fort in ipairs(fortification_status) do if fort.range >= self.hp then - fort_desc = fort.desc + self.hp_desc = fort.desc break end end @@ -119,12 +128,10 @@ function barricade:getDesc() for i, room in ipairs(room_available) do if room.range >= hp_gap then - fort_avail_desc = room.desc + self.potential_hp_desc = room.desc break end end - - return fort_desc, fort_avail_desc end function barricade:canPlayerFortify(player) @@ -134,13 +141,12 @@ function barricade:canPlayerFortify(player) if cade_past_v_strong then return player.skills:check('barricade_adv') -- can barricade all elseif cade_past_regular then return player.skills:check('barricade') -- can barricade up to very strong - else return true -- can barricade up to regular - end + else return true end -- can barricade up to regular end local bypass_skill_bonus, zombie_multiplier = 5, 20 -function barricade:fortifyAttempt(player, zombie_n, human_n) +function barricade:fortifyAttempt(player, zombie_n, human_n) -- this code will be implemented later, probably needs chance tweaks local zombie_blockade_value = (zombie_multiplier*zombie_n) - human_n local skill_bonus = (player.skills:check('barricade') and bypass_skill_bonus) or 0 local skill_bonus_adv = (player.skills:check('barricade_adv') and bypass_skill_bonus) or 0 @@ -149,7 +155,7 @@ function barricade:fortifyAttempt(player, zombie_n, human_n) return zombie_blockade_value <= dice.roll(zombie_blockade_value + bypass_chance) end -local cade_dice = {'1d3^+1', '1d3', '1d3^-1', '1d3-1^-1'} -- Averages [2.5, 2, 1.5, 1.1] +local cade_dice = {'1d3-1^-1', '1d3^-1', '1d3', '1d3^+1'} -- Averages [1.1, 1.5, 2, 2.5] function barricade:fortify(player, cade_condition) local dice_str = cade_dice[cade_condition] diff --git a/code/location/building/barrier/class.lua b/code/location/building/barrier/class.lua index 0ab7f90..f4a118e 100644 --- a/code/location/building/barrier/class.lua +++ b/code/location/building/barrier/class.lua @@ -2,21 +2,18 @@ local class = require('code.libs.middleclass') local barrier = class('barrier') ---[[ -self.barricade = {hp=0, desc=0} -- 1 bit {exist}, 6 bit {64hp}, 3 bit {desc} -self.door = {hp=4, state='closed'}-- 1 bit {exist}, 2 bit {04hp}, 1 bit {state} +--[[ +self.barricade = {hp=0, desc=0} -- 1 bit {exist}, 6 bit {63hp}, 3 bit {desc} +self.door = {hp=4, state='closed'}-- 1 bit {exist}, 2 bit {03hp}, 1 bit {state} --]] function barrier:initialize() end function barrier:getHP() return self.hp end -function barrier:updateHP(num) - for k,v in pairs(self) do print(k,v) end - print(self.static) - print(self.max_hp) - - self.hp = math.min( math.max(self.hp+num, 0), self.max_hp) +function barrier:updateHP(num) + self.hp = math.min( math.max(self.hp+num, 0), self.max_hp) + self:updateDesc() end return barrier \ No newline at end of file diff --git a/code/location/building/barrier/door/class.lua b/code/location/building/barrier/door/class.lua index e2693dc..e45920c 100644 --- a/code/location/building/barrier/door/class.lua +++ b/code/location/building/barrier/door/class.lua @@ -4,21 +4,26 @@ local barrier = require('code.location.building.barrier.class') local door = class('door', barrier) local default_hp, max_hp = 3, 3 +local door_desc = {[0] = 'destroyed', [1] = 'smashed', [2] = 'dented', [3] = 'undamaged'} + function door:initialize() barrier.initialize(self) self.hp = default_hp self.is_open = false + + self.hp_desc = door_desc[default_hp] end door.max_hp = max_hp --- DOOR LEVELS -local destroyed, broken, smashed, normal = 0, 1, 2, 3 +function door:updateDesc() self.hp_desc = door_desc[self.hp] end + +function door:getDesc() return self.hp_desc end function door:repair() self:updateHP(3) end -function door:toggle() self.is_closed = not self.is_open end +function door:toggle() self.is_open = not self.is_open end function door:isDestroyed() return self.hp == 0 end diff --git a/code/location/building/class.lua b/code/location/building/class.lua index 62d2b44..43cbd66 100644 --- a/code/location/building/class.lua +++ b/code/location/building/class.lua @@ -40,14 +40,30 @@ end function building:install(equipment_type, condition) self[equipment_type]:install(condition) end -function building:barricade(size) self.barricade:updateHP(size) end - function building:blackout() -- 3x3 area do blackout event on tile(s) end function building:getBarrier() return (self.barricade:getHP() > 0 and 'barricade') or (self.door:getHP() > 0 and 'door') end -- should this be a class? +function building:getBarrierDesc() + local cade_str, space_str = self.barricade:getDesc() + local door_str = self.door:getDesc() + + local no_cades_exist = (cade_str == 'secured') + local is_entrance_open = no_cades_exist and (door_str == 'destroyed' or self.door:isOpen()) + local is_door_damaged = door_str ~= 'undamaged' + + cade_str = (is_entrance_open and 'left wide open') or cade_str + door_str = (is_door_damaged and 'is '..door_str..' and ') or '' + + local door_desc = 'The building door '..door_str + local cade_desc = 'has been '..cade_str..'. ' + local space_desc = 'There is '..space_str..' room available for fortifications.' + + return door_desc..cade_desc..space_desc +end + function building:getEquipment() local machines = {} for machine in pairs(equipment.subclasses) do @@ -78,8 +94,9 @@ function building:isFortified() return self.barricade:getHP() > 0 and self.door: function building:isPowered() return self.generator:isActive() end -function building:isOpen() return self.barricade:isDestroyed() and (self.door:isOpen() or self.door:isDestroyed()) -end +function building:isOpen() return self.barricade:isDestroyed() and (self.door:isOpen() or self.door:isDestroyed()) end + +function building:isRuined() return false end --self.ruin:isActive() ruins haven't been implemented yet -- do we need this?! function building:isDescPresent(desc_type) return (self[desc_type] and #self[desc_type] > 0) or false end diff --git a/code/location/building/list.lua b/code/location/building/list.lua index 9307cec..59382c1 100644 --- a/code/location/building/list.lua +++ b/code/location/building/list.lua @@ -10,8 +10,6 @@ building.external_desc = { surroundings = {'surrounded by wrecked cars', 'surrounded by a metal fence', 'surrounded by trees', 'covered in vines', 'covered in moss', 'surrounded by a wooden fence'}, } -local OUTSIDE_SEARCH_ODDS, INSIDE_SEARCH_ODDS = .75, .15 - -- external desc works as follows -- You are standing outside the [building title], a [story] [adjective] [color] [material] [details] [surroundings]. @@ -36,11 +34,10 @@ factory = 30-40% library/school = 20% home = 10% -street/outside_building = 50-75% to find mostly barricades -wasteland/forest = 05% - --]]----------- SEARCH ODDS ------------ +local OUTSIDE_SEARCH_ODDS, INSIDE_SEARCH_ODDS = .50, .15 + --[[ --- GENERIC --]] @@ -48,8 +45,19 @@ wasteland/forest = 05% building.default = {} building.default.full_name = 'building' building.default.building_type = 'generic' -building.default.search_odds = {inside = 0.15, outside = 0.75} -building.default.item_chance = { +building.default.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = INSIDE_SEARCH_ODDS} +building.default.item_chance = {} +building.default.item_chance.outside = { + -- WEAPONS = 00.1% + knife = .001, + + -- MISC = 09.9% + newspaper = .099, + + -- EQUIPMENT = 90% + barricade = .90, +} +building.default.item_chance.inside = { -- MEDICAL = 15% FAK = .05, bandage = .10, @@ -78,8 +86,10 @@ building.default.item_chance = { building.apartment = {} building.apartment.full_name = 'apartment' building.apartment.building_type = 'residential' -building.apartment.search_odds = {inside = 0.10} -building.apartment.item_chance = { +building.apartment.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.10} +building.apartment.item_chance = {} +building.apartment.item_chance.outside = building.default.item_chance.outside +building.apartment.item_chance.inside = { -- MEDICAL = 15% FAK = .05, bandage = .10, @@ -104,8 +114,10 @@ building.apartment.item_chance = { building.hotel = {} building.hotel.full_name = 'hotel' building.hotel.building_type = 'residential' -building.hotel.search_odds = {inside = 0.20} -building.hotel.item_chance = { +building.hotel.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.20} +building.hotel.item_chance = {} +building.hotel.item_chance.outside = building.default.item_chance.outside +building.hotel.item_chance.inside = { -- MEDICAL = 15% FAK = .05, bandage = .10, @@ -134,8 +146,10 @@ building.hotel.item_chance = { building.PD = {} building.PD.full_name = 'police department' building.PD.building_type = 'government' -building.PD.search_odds = {inside = 0.50} -building.PD.item_chance = { +building.PD.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.50} +building.PD.item_chance = {} +building.PD.item_chance.outside = building.default.item_chance.outside +building.PD.item_chance.inside = { -- WEAPONS = 24% pistol = .16, shotgun = .08, @@ -155,15 +169,17 @@ shotgun_shell = .16, building.FD = {} building.FD.full_name = 'fire department' building.FD.building_type = 'government' -building.FD.search_odds = {inside = 0.50} -building.FD.item_chance = { +building.FD.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.50} +building.FD.item_chance = {} +building.FD.item_chance.outside = building.default.item_chance.outside +building.FD.item_chance.inside = { -- MEDICAL = 25% FAK = .05, bandage = .20, -- WEAPONS = 40% axe = .10, - flare = .20, + flare = .20, crowbar = .10, -- MISC = 10% @@ -177,8 +193,10 @@ building.FD.item_chance = { building.hospital = {} building.hospital.full_name = 'hospital' building.hospital.building_type = 'government' -building.hospital.search_odds = {inside = 0.50, outside = OUTSIDE_SEARCH_ODDS} -building.hospital.item_chance = { +building.hospital.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.50} +building.hospital.item_chance = {} +building.hospital.item_chance.outside = building.default.item_chance.outside +building.hospital.item_chance.inside = { -- MEDICAL = 75% -- FAK = .25, -- bandage = .50, @@ -193,8 +211,10 @@ building.hospital.item_chance = { building.courthouse = {} building.courthouse.full_name = 'courthouse' building.courthouse.building_type = 'government' -building.courthouse.search_odds = {inside = 0.30, outside = OUTSIDE_SEARCH_ODDS} -building.courthouse.item_chance = { +building.courthouse.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.30} +building.courthouse.item_chance = {} +building.courthouse.item_chance.outside = building.default.item_chance.outside +building.courthouse.item_chance.inside = { -- MEDICAL bandage = .10, @@ -209,8 +229,10 @@ building.courthouse.item_chance = { building.warehouse = {} building.warehouse.full_name = 'warehouse' building.warehouse.building_type = 'industrial' -building.warehouse.search_odds = {inside = 0.40} -building.warehouse.item_chance = { +building.warehouse.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.40} +building.warehouse.item_chance = {} +building.warehouse.item_chance.outside = building.default.item_chance.outside +building.warehouse.item_chance.inside = { -- WEAPONS = 70% crowbar = .20, sledge = .10, @@ -228,8 +250,10 @@ building.warehouse.item_chance = { building.factory = {} building.factory.full_name = 'factory' building.factory.building_type = 'industrial' -building.factory.search_odds = {inside = 0.40} -building.factory.item_chance = { +building.factory.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.40} +building.factory.item_chance = {} +building.factory.item_chance.outside = building.default.item_chance.outside +building.factory.item_chance.inside = { -- WEAPONS = 70% crowbar = .20, sledge = .10, @@ -251,16 +275,20 @@ building.factory.item_chance = { building.news = {} building.news.full_name = 'news' building.news.building_type = 'commercial' -building.news.search_odds = {inside = 0.30} -building.news.item_chance = { +building.news.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.30} +building.news.item_chance = {} +building.news.item_chance.outside = building.default.item_chance.outside +building.news.item_chance.inside = { newspaper = 1.00, } building.sport = {} building.sport.full_name = 'sporting goods' building.sport.building_type = 'commercial' -building.sport.search_odds = {inside = 0.30} -building.sport.item_chance = { +building.sport.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.30} +building.sport.item_chance = {} +building.sport.item_chance.outside = building.default.item_chance.outside +building.sport.item_chance.inside = { -- WEAPONS = 60% machate = .10, bat = .20, @@ -278,8 +306,10 @@ building.sport.item_chance = { building.bar = {} building.bar.full_name = 'bar' building.bar.building_type = 'commercial' -building.bar.search_odds = {inside = 0.20} -building.bar.item_chance = { +building.bar.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.20} +building.bar.item_chance = {} +building.bar.item_chance.outside = building.default.item_chance.outside +building.bar.item_chance.inside = { -- WEAPONS = 30% shotgun = .10, bat = .05, @@ -298,8 +328,10 @@ shotgun_shell = .25, building.mall = {} building.mall.full_name = 'shopping mall' building.mall.building_type = 'commercial' -building.mall.search_odds = {inside = 0.60} -building.mall.item_chance = { +building.mall.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.60} +building.mall.item_chance = {} +building.mall.item_chance.outside = building.default.item_chance.outside +building.mall.item_chance.inside = { -- WEAPONS = 60% machate = .10, bat = .20, @@ -321,8 +353,10 @@ building.mall.item_chance = { building.library = {} building.library.full_name = 'public library' building.library.building_type = 'public' -building.library.search_odds = {inside = 0.20} -building.library.item_chance = { +building.library.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.20} +building.library.item_chance = {} +building.library.item_chance.outside = building.default.item_chance.outside +building.library.item_chance.inside = { -- MISC = 95% newspaper = .20, book = .75, @@ -334,8 +368,10 @@ building.library.item_chance = { building.school = {} building.school.full_name = 'school' building.school.building_type = 'public' -building.school.search_odds = {inside = 0.20} -building.school.item_chance = { +building.school.search_odds = {outside = OUTSIDE_SEARCH_ODDS, inside = 0.20} +building.school.item_chance = {} +building.school.item_chance.outside = building.default.item_chance.outside +building.school.item_chance.inside = { -- WEAPONS = 02% bat = .02, diff --git a/code/location/tile/class.lua b/code/location/tile/class.lua index 6a21b09..faa3fc8 100644 --- a/code/location/tile/class.lua +++ b/code/location/tile/class.lua @@ -85,13 +85,10 @@ function tile:getMap() return self.map_zone end function tile:getPos() return self.y, self.x end function tile:getState() -- update later for ruins - local state - if self:isBuilding() and self:isPowered() then - state = 'powered' - else - state = 'unpowered' + if self:isBuilding() and self:isPowered() then return 'powered' + elseif self:isBuilding() and self:isRuined() then return 'ruined' + else return 'unpowered' end - return state end function tile:getDesc(setting) @@ -131,8 +128,6 @@ end --function tile:getTileType() return self.tile_type end -function tile:getSearchOdds(setting) return (setting and self.search_odds[setting]) or self.search_odds.outside end - function tile:getPlayers(setting) local players if setting == 'inside' then @@ -151,6 +146,17 @@ function tile:isBuilding() return self.inside_players and true or false end function tile:isClass(tile_class) return self:getClassName() == tile_class end +local modifier = { + building_condition = {unpowered = 0.00, powered = 0.20, ruined = -0.80}, + looting_skill = 0.05 +} + +function tile:getSearchOdds(player, setting, location_status) + local search_chance = (setting and self.search_odds[setting]) or self.search_odds.outside + local modifier_sum = modifier.building_condition[location_status] + (player.skills:check('looting') and modifier.looting_skill or 0) + return search_chance + (search_chance * modifier_sum) +end + local function select_item(list) local chance, total = math.random(), 0 @@ -160,19 +166,22 @@ local function select_item(list) end end -function tile:search(setting) - local odds = self:getSearchOdds(setting) -print('odds are:', odds) -print('setting is:', setting) +function tile:search(player, setting) + local location_state = self:getState() + + local odds = self:getSearchOdds(player, setting, location_state) local search_success = dice.chance(odds) if not search_success then return false end - - local items = self.item_chance + + local items = self.item_chance[setting] local item_type = select_item(items) - local location_state = self:getState() print('tile:search - ', item_type) print('location_state - ', location_state) + + -- junkyards yield better barricade conditions than other locations due to the amount of junk + if self:getClassName() == 'junkyard' then location_state = 'powered' end + local item_INST = item[item_type]:new(location_state) -- DO WE NEED THIS?! diff --git a/code/location/tile/list.lua b/code/location/tile/list.lua index fd4fc17..c1b174a 100644 --- a/code/location/tile/list.lua +++ b/code/location/tile/list.lua @@ -3,47 +3,36 @@ local tile = {} --[[ full_name = 'insert name' resources = 0, 1, 2, 3 - item_chance = {item = 0.00} + item_chance = {outside = {item = 0.00}, inside = {item = 0.00}} barricade = {size = 'desc'} --]] tile.street = {} tile.street.full_name = 'street' -tile.street.item_chance = { - -- WEAPONS = 00.1% - knife = .001, +tile.street.item_chance = {} +tile.street.item_chance.outside = { + -- WEAPONS = 00.1% + knife = .001, - -- MISC = 09.9% - newspaper = .099, + -- MISC = 09.9% + newspaper = .099, - -- BARRICADE = 90% - small = .20, - medium = .30, - large = .20, - heavy = .20, + -- EQUIPMENT = 90% + barricade = .90, } + +--[[ barricade descriptions inserted at a later time tile.street.barricades = { small = {'cinder blocks'}, medium = {'pieces of scrap metal',}, large = {'trash can',}, heavy = {'tire',}, } - --- small barricade, barricade, medium barricade, large barricade --- small [4], normal [2], medium [1], large [1] +--]] tile.cemetary = {} tile.cemetary.full_name = 'cemetary' -tile.cemetary.item_chance = { - -- MISC 20% - newspaper = .20, - - -- BARRICADE = 80% - medium = .80, -} -tile.cemetary.barricades = { - medium = {'tombstone',}, -} +tile.cemetary.item_chance = {} tile.monument = {} tile.monument.full_name = 'monument' diff --git a/code/player/action/catalog.lua b/code/player/action/catalog.lua index 88e2729..fd32ddf 100644 --- a/code/player/action/catalog.lua +++ b/code/player/action/catalog.lua @@ -13,7 +13,7 @@ local function determineAvailableActions(player, all_actions, check, available_a for action in pairs(all_actions) do local cost = player:getCost('ap', action) if ap >= cost then - local action_passed_requirements, fail_msg = pcall(check, player, action) --pcall(check[action], player) + local action_passed_requirements, fail_msg = pcall(check, player, action) --check(player, action) if action_passed_requirements then available_actions[#available_actions + 1] = action end end end diff --git a/code/player/action/check.lua b/code/player/action/check.lua index 154e2b1..e6ba989 100644 --- a/code/player/action/check.lua +++ b/code/player/action/check.lua @@ -84,7 +84,7 @@ function check.skill(player, skill) --, target) local cost, ep = player:getCost('ep', skill), player:getStat('ep') assert(ep >= cost, 'Not enough enzyme points to use skill') end - if skillCheck[skill] then skillCheck[skill](player) end + if skillCheck[skill] then skillCheck[skill](player) end end return check \ No newline at end of file diff --git a/code/player/action/criteria.lua b/code/player/action/criteria.lua index 56c6361..b23ab24 100644 --- a/code/player/action/criteria.lua +++ b/code/player/action/criteria.lua @@ -184,17 +184,14 @@ function criteria.default(action, player, ...) if criteria[action] then criteria[action](player, ...) end end -function criteria.item(item, player, target, inv_ID) ---print(player, item_name, target, inv_ID) +function criteria.item(item, player, inv_ID, ...) assert(inv_ID, 'Missing inventory ID for item') assert(player.inventory:check(inv_ID), 'Item not in inventory') - local item, inv_item = lookupItem(item), player.inventory:lookup(inv_ID) ---print(item, inv_item) - assert(inv_item:getID() == item:getID(), "Item in inventory doesn't match one being used") + local item_INST = player.inventory:lookup(inv_ID) + assert(item == item_INST:getClassName(), "Item in inventory doesn't match one being used") - local item_name = item:getName() - if itemCriteria[item_name] then itemCriteria[item_name](player, target) end + if itemCriteria[item] then itemCriteria[item](player, ...) end end error_list[#error_list+1] = 'Missing inventory ID for item' diff --git a/code/player/action/list.lua b/code/player/action/list.lua index d2418f0..4a05d13 100644 --- a/code/player/action/list.lua +++ b/code/player/action/list.lua @@ -27,15 +27,9 @@ local action_list = { basic = { respawn = {name='respawn', cost=10}, search = {name='search', cost= 1}, - --barricade = {name='barricade', cost= 1}, attack = {name='attack', cost= 1}, speak = {name='speak', cost= 1}, --close = {name='close door', cost= 1}, - --[[ Are these neccessary? - item = {cost=1}, - equipment = {cost=1}, - skill = {cost=1}, - --]] }, skill = { repair = { @@ -47,9 +41,10 @@ local action_list = { }, }, item = { - generator = {cost=4, modifier={tech=-1, power_tech=-2},}, - transmitter = {cost=4, modifier={tech=-1, radio_tech=-2},}, - terminal = {cost=4, modifier={tech=-1, computer_tech=-2},}, + barricade = {name='barricade', cost=1}, + generator = {name='generator', cost=4, modifier={tech=-1, power_tech=-2},}, + transmitter = {name='transmitter', cost=4, modifier={tech=-1, radio_tech=-2},}, + terminal = {name='terminal', cost=4, modifier={tech=-1, computer_tech=-2},}, --[[ **RELOADING** @@ -59,16 +54,16 @@ local action_list = { shotgun - ? ap (2 shots) [3 ap, 2ap, .5ap] bow - ? ap (8 shots [quiver]) [8 ap, 6ap, 3ap] --]] - shotgun_shell = {cost=2, modifier={guns = -1, shotguns = -1},}, - pistol_clip = {cost=3, modifier={guns = -2, handguns = -1},}, - speed_loader = {cost=3, modifier={guns = -2, handguns = -1},}, - rifle_magazine= {cost=4, modifier={guns = -3, rifles = -1},}, - quiver = {cost=4, modifier={archery= -3, bows = -1},}, - book = {cost=5, modifier={bookworm=-2},}, - FAK = {cost=1}, - bandage = {}, - antidote = {}, - syringe = {}, + shotgun_shell = {name='shotgun shell', cost=2, modifier={guns = -1, shotguns = -1},}, + pistol_clip = {name='pistol clip', cost=3, modifier={guns = -2, handguns = -1},}, + speed_loader = {name='speed loader', cost=3, modifier={guns = -2, handguns = -1},}, + rifle_magazine= {name='rifle magazine', cost=4, modifier={guns = -3, rifles = -1},}, + quiver = {name='quiver', cost=4, modifier={archery= -3, bows = -1},}, + book = {name='book', cost=5, modifier={bookworm=-2},}, + FAK = {name='first aid kit', cost=1}, + bandage = {name='bandage',}, + antidote = {name='antidote',}, + syringe = {name='syringe',}, }, equipment = { broadcast = {cost=3, modifier={tech = -1, radio_tech = -1},}, @@ -78,7 +73,7 @@ local action_list = { }, zombie = { default = { - move = {name='move', cost=2, modifier={sprint = -1},}, + move = {name='move', cost=2, modifier={sprint = -1},}, enter = {name='enter', cost= 1}, exit = {name='exit', cost= 1}, }, @@ -99,7 +94,7 @@ local action_list = { ruin = {name='ruin', cost=1}, -- hunter skills mark_prey = {name='mark prey', cost=1}, - tracking = {name='tracking', cost=1}, + track = {name='track', cost=1}, }, }, }, @@ -109,7 +104,11 @@ local function fillList(list) for mob_type in pairs(list.info) do list[mob_type] = {} for category in pairs(list.info[mob_type]) do - for action, data in pairs(list.info[mob_type][category]) do list[mob_type][action] = data end + for action, data in pairs(list.info[mob_type][category]) do + list[mob_type][action] = data + -- basic actions are classified as default for their category + list[mob_type][action].category = (category == 'basic' and 'default') or category + end end end return list diff --git a/code/player/action/outcome.lua b/code/player/action/outcome.lua index 50ca1ca..61ef7c0 100644 --- a/code/player/action/outcome.lua +++ b/code/player/action/outcome.lua @@ -58,7 +58,7 @@ end local ARMOR_DAMAGE_MOD = 2.5 -function Outcome.attack(player, target, weapon) +function Outcome.attack(player, target, weapon, inv_ID) local target_class = target:getClassName() local attack, damage, critical = combat(player, target, weapon) @@ -67,10 +67,7 @@ function Outcome.attack(player, target, weapon) if target.armor:isPresent() then -- what if weapon is harmless? local damage_type = weapon:getDamageType() local resistance = target.armor:getProtection(damage_type) - damage = damage - resistance - - local degrade_chance = math.floor(damage/ARMOR_DAMAGE_MOD) + 1 - local armor_is_damaged = target.armor:passDgygynkurabilityCheck(degrade_chance) + damage = damage - resistance -- do we need to add a desc if resistance is working? (ie absorbing damage in battle log?) local retailation_damage = target.armor:getProtection('damage_melee_attacker') @@ -80,6 +77,16 @@ function Outcome.attack(player, target, weapon) player:updateStat('hp', retailation_hp_loss) -- insert some type of event? end + + local degrade_chance = math.floor(damage/ARMOR_DAMAGE_MOD) + 1 -- might wanna change this later? Damage affects degrade chance? + if target.armor:failDurabilityCheck(degrade_chance) then target.armor:degrade(target) end + end + + local zombie = (player:isMobType('zombie') and player) or (target:isMobType('zombie') and player) + local human = (player:isMobType('human') and player) or (target:isMobType('human') and player) + + if zombie.skills:check('track') then + zombie.condition.tracking:addScent(human) end end @@ -95,24 +102,31 @@ function Outcome.attack(player, target, weapon) target.condition[effect]:add(duration, bonus_effect) end end + + if player:isMobType('human') and not weapon:isOrganic() then + local item_INST = player.inventory:lookup(inv_ID) + if item_INST:isSingleUse() then player.inventory:remove(inv_ID) -- no need to do a durability check + elseif item_INST:failDurabilityCheck(player) then item_INST:updateCondition(-1, player, inv_ID) + end + end else - if player:isMobType('zombie') and player.skills:check('grapple') then - player.condition.entangle:remove() + if player:isMobType('zombie') and player.skills:check('grapple') then + player.condition.entangle:remove() + elseif player:isMobType('human') and weapon:getStyle() == 'ranged' then + local item_INST = player.inventory:lookup(inv_ID) + if item_INST:isSingleUse() then player.inventory:remove(inv_ID) -- no need to do a durability check + elseif item_INST:failDurabilityCheck(player) then item_INST:updateCondition(-1, player, inv_ID) + end end - end + end + return {attack, damage, critical} end function Outcome.search(player) ---print('map_zone Outcome.search()', map_zone) local p_tile = player:getTile() - local item = p_tile:search(player:getStage()) -print('item:', item) - if item then - print('item found') - player.inventory:insert(item) - print('no item discovered') - end + local item = p_tile:search(player, player:getStage()) + if item then player.inventory:insert(item) end return {item} end @@ -122,16 +136,6 @@ function Outcome.discard(player, inv_ID) return {item} end -function Outcome.barricade(player) - local building = player:getBuilding() - local result = building:barricade() - if result then - print('barricaded building') - else - print('failed barricade') - end -end - function Outcome.speak(player, message) -- , target) local tile = player:getTile() tile:listen(player, message, player:getStage()) @@ -200,14 +204,13 @@ function Outcome.default(action, player, ...) return Outcome[action](player, ...) end -function Outcome.item(item, player, target, inv_ID) - local item = lookupItem(item) - local item_name = item:getName() ---print('item_name Outcome.item', item_name) - -- condition degrade on use? - -- CONVERT INV_ID INTO CONDITION!!! - return itemActivate[item_name](player, target, inv_ID) - -- degrade item +function Outcome.item(item, player, inv_ID, target) + local item_INST = player.inventory:lookup(inv_ID) + local item_condition = item_INST:getCondition() + local result = itemActivate[item](player, item_condition, target) + if item_INST:isSingleUse() then player.inventory:remove(inv_ID) -- no need to do a durability check + elseif item_INST:failDurabilityCheck(player) then item_INST:updateCondition(-1, player, inv_ID) end + return result end function Outcome.equipment(equipment, player, operation, ...) -- condition degrade on use? diff --git a/code/player/action/perform.lua b/code/player/action/perform.lua index bd6c0fb..97999ec 100644 --- a/code/player/action/perform.lua +++ b/code/player/action/perform.lua @@ -3,26 +3,8 @@ local serverCriteria = require('code.player.action.criteria') local broadcastEvent = require('code.server.event') local getZone = require('code.player.action.zone') local error_list = require('code.error.list') - -local action_category = { - fields = {'default', 'item', 'skill', 'equipment'}, - default = {'move', 'attack', 'search', 'speak', 'enter', 'exit', 'respawn', 'feed'}, - item = {}, - skill = {'drag_prey', 'groan', 'gesture', 'armor', 'ruin', 'mark_prey', 'tracking'}, - equipment = {}, -} - -local function fillActionCategories(list) - for _, action_type in ipairs(list.fields) do - for _, action in ipairs(list[action_type]) do - list[action] = action_type - end - end - return list -end - -action_category = fillActionCategories(action_category) - +local action_list = require('code.player.action.list') + local function basicCriteria(player, action) local ap, AP_cost = player:getStat('ap'), player:getCost('ap', action) assert(AP_cost, 'action has no ap_cost?') -- remove this assertion once all actions have been added (will be unneccsary) @@ -31,16 +13,17 @@ local function basicCriteria(player, action) end local function perform(action, player, ...) - local action_category_type = action_category[action] + local mob_type = player:getMobType() + local action_category = action_list[mob_type][action].category -- standard checks on ALL actions local basic_verification, error_msg = pcall(basicCriteria, player, action) -- checks to make sure action is valid - local verification, error_msg = pcall(serverCriteria[action_category_type], action, player, ...) + local verification, error_msg = pcall(serverCriteria[action_category], action, player, ...) if basic_verification and verification then local ap, AP_cost = player:getStat('ap'), player:getCost('ap', action) -- process the action and update stuff (returns a result dependent on action) - local result = serverOutcome[action_category_type](action, player, ...) + local result = serverOutcome[action_category](action, player, ...) local zone = getZone(action, player, ...) -- may need to change location of getZone (for server events?) local params = {player, ...} diff --git a/code/player/action/zone.lua b/code/player/action/zone.lua index acd0ab7..4eda057 100644 --- a/code/player/action/zone.lua +++ b/code/player/action/zone.lua @@ -112,6 +112,13 @@ function setupZone.armor(player) zone.type = 'self' end +function setupZone.track(player) + zone.player = player + zone.type = 'stage' + zone.stage = player:getStage() + zone.tile = player:getTile() +end + --------------------------------------- --------------------------------------- -- JUST A DIVIDER -- diff --git a/code/player/armor/class.lua b/code/player/armor/class.lua index 4cbf748..fa3f41d 100644 --- a/code/player/armor/class.lua +++ b/code/player/armor/class.lua @@ -7,7 +7,7 @@ function armor:initialize(player) self.player = player end -function armor:passDurabilityCheck(degrade_chance) return dice:rollAndTotal(self.durability) > degrade_chance end +function armor:failDurabilityCheck(degrade_chance) return dice.roll(self.durability) <= degrade_chance end function armor:getProtection(damage_type) return self.protection[damage_type] or 0 end diff --git a/code/player/armor/item_class.lua b/code/player/armor/item_class.lua index 5f17e71..40a5c9e 100644 --- a/code/player/armor/item_class.lua +++ b/code/player/armor/item_class.lua @@ -15,7 +15,10 @@ function item_armor:equip(name, condition, inv_ID) self.durability = item_armor_list[name].durability end -function item_armor:degrade() +function item_armor:degrade(player) + local item_INST = player.inventory:lookup(self.inv_ID) + item_INST:updateCondition(-1, player, self.inv_ID) + self.condition = self.condition - 1 if 0 > self.condition then -- armor is destroyed local player = self.player diff --git a/code/player/class.lua b/code/player/class.lua index c668fca..5f52d0d 100644 --- a/code/player/class.lua +++ b/code/player/class.lua @@ -21,7 +21,7 @@ local lookupItem = require('code.item.search') -- refactored? (delete) local player = class('player') -local default = {hp=1, ep=50, ip= 0, xp= 0, ap=50} +local default = {hp=50, ep=50, ip= 0, xp= 0, ap=50} local default_max = {hp=50, ep=50, ip=50, xp=1000, ap=50} local skill_bonus = {hp=10, ep=10, ip=10, xp= 0, ap=0} local bonus_flag_name = {hp='hp_bonus', ip='ip_bonus', ep='ep_bonus', ap=false, xp=false} @@ -187,13 +187,10 @@ end function player:getActions(category) return catalogAvailableActions[category](self) end function player:getWeapons() -print() -print('player:getWeapons') local list = {} if self:isMobType('human') then for inv_ID, item_INST in ipairs(self.inventory) do -print('player:getWeapons inv loop', inv_ID, item_INST) if item_INST:isWeapon() then local item_name, condition = item_INST:getClassName(), item_INST:getCondition() local weap_INST = weapon[item_name]:new(condition) diff --git a/code/player/condition/class.lua b/code/player/condition/class.lua index 65b9778..286d35d 100644 --- a/code/player/condition/class.lua +++ b/code/player/condition/class.lua @@ -22,7 +22,7 @@ function condition:initialize(player) end self.entangle = entangle:new() - self.tracking = tracking:new() + self.tracking = tracking:new(player) end function condition:isActive(effect) diff --git a/code/player/condition/tracking.lua b/code/player/condition/tracking.lua index c42912c..72839e7 100644 --- a/code/player/condition/tracking.lua +++ b/code/player/condition/tracking.lua @@ -30,7 +30,7 @@ function tracking:addScent(target) end self.list[#self.list+1] = {prey = target, ticks = dice.rollAndTotal(scent_time)} - target.tracking:isMarked(self.player) + target.condition.tracking:addTracker(self.player) local target_limit = has_advanced_tracking and TRACKING_ADV_TARGET_LIMIT or TRACKING_TARGET_LIMIT @@ -54,13 +54,13 @@ end local tracking_range = { advanced = {35, 25, 15, 10, 6, 3, 1, 0}, - basic = {25, 15, 6, 3}, + basic = {25, 15, 6, 0}, -- Include ticks_left feature for advanced? (ie. scent lingers, scent is faint, scent is strong) } -local function selectTrackingRangeIndex(distance, skill) - for i, range in ipairs(tracking_range[skill]) do - if distance >= range then return tracking_range[skill][i] end +local function selectTrackingRangeIndex(distance, skill_proficiency) + for tracking_index, range in ipairs(tracking_range[skill_proficiency]) do + if distance >= range then return tracking_index end end end @@ -75,29 +75,14 @@ function tracking:getPrey() prey, tracking_range_indexs = {}, {} for i, scent in ipairs(self.list) do local distance, has_advanced_tracking = getDistanceApart(self.player, scent.prey), self.player.skills:check('track_adv') - local skill = has_advanced_tracking and tracking_range.advanced or tracking_range.basic + local skill_proficiency = has_advanced_tracking and 'advanced' or 'basic' prey[#prey+1] = scent.prey - tracking_range_indexs[#tracking_range_indexs+1] = selectTrackingRangeIndex(distance, skill) + tracking_range_indexs[#tracking_range_indexs+1] = selectTrackingRangeIndex(distance, skill_proficiency) end end return prey, tracking_range_indexs end ---[[ -function tracking:getScentDesc() - local track_msgs = {'You sniff the air for prey.'} - if self.is_tracking then - for i, scent in ipairs(self.list) do - local distance, has_advanced_tracking = getDistanceApart(self.player, scent.prey), self.player.skills:check('track_adv') - local params = has_advanced_tracking and tracking_params.advanced or tracking_params.basic - track_msgs[#track_msgs+1] = scent.prey:getUserName()..' is '..selectTrackingMessage(distance, params)..'.' - end - else - track_msgs[#track_msgs+1] = 'There are no humans you are currently tracking.' - end -end ---]] - function tracking:elapse() if self.player.isMobType('zombie') and self.is_tracking then for i, scent in ipairs(self.list) do diff --git a/code/player/enzyme_list.lua b/code/player/enzyme_list.lua index b3c85ab..74bc54e 100644 --- a/code/player/enzyme_list.lua +++ b/code/player/enzyme_list.lua @@ -19,7 +19,7 @@ local enzyme_list = { sticky = {cost=2}, -- hunter skills mark_prey = {cost=1}, - tracking = {cost=3, modifier={tracking_adv = -1}}, + track = {cost=3, modifier={track_adv = -1}}, leap = {cost=2, modifier={leap_adv = -1},}, -- sentient skills open_door = {cost=1}, diff --git a/code/player/log/getMessage.lua b/code/player/log/getMessage.lua index 65a771d..6611cae 100644 --- a/code/player/log/getMessage.lua +++ b/code/player/log/getMessage.lua @@ -146,16 +146,16 @@ local tracking_description = { basic = {'far away', 'in the distance', 'in the area', 'close'}, } -function description.tracking(player, prey, prey_range_indexs) +function description.track(player, prey, prey_range_indexs) msg[1] = 'You sniff the air for prey.' msg[3] = 'A zombie smells the air for prey.' - + if prey then local has_advanced_tracking = player.skills:check('track_adv') for i, target in ipairs(prey) do local description = has_advanced_tracking and tracking_description.advanced or tracking_description.basic local index = prey_range_indexs[i] - msg[1] = msg[1]..'\n'..target:getUserName()..' is '..description[index]..'.' + msg[1] = msg[1]..'\n'..target:getUsername()..' is '..description[index]..'.' end else msg[1] = msg[1] .. 'There are no humans you are currently tracking.' diff --git a/code/player/skills/activate.lua b/code/player/skills/activate.lua index 7d263fb..6dd322e 100644 --- a/code/player/skills/activate.lua +++ b/code/player/skills/activate.lua @@ -32,7 +32,7 @@ end function activate.gesture(player, target) end -function activate.tracking(player) +function activate.track(player) local targets, targets_ranges = player.condition.tracking:getPrey() return {targets, targets_ranges} end diff --git a/code/player/skills/check.lua b/code/player/skills/check.lua index 7bdc11e..75f4b7d 100644 --- a/code/player/skills/check.lua +++ b/code/player/skills/check.lua @@ -41,7 +41,7 @@ function check.mark_prey(player) end -function check.tracking(player) +function check.track(player) end diff --git a/code/player/skills/criteria.lua b/code/player/skills/criteria.lua index 88f814c..ab45349 100644 --- a/code/player/skills/criteria.lua +++ b/code/player/skills/criteria.lua @@ -47,7 +47,7 @@ function criteria.mark_prey(player) end -function criteria.tracking(player) +function criteria.track(player) end diff --git a/code/player/skills/flags.lua b/code/player/skills/flags.lua index 0a70162..450c57f 100644 --- a/code/player/skills/flags.lua +++ b/code/player/skills/flags.lua @@ -63,6 +63,15 @@ local skill_flags = { -- Engineering repairs = 1, repairs_adv = 2, + barricade = 4, + barricade_adv = 8, + reinforce = 16, + renovate = 32, + tech = 64, + power_tech = 128, + radio_tech = 256, + computer_tech = 512, + -------------- diff --git a/code/player/skills/list.lua b/code/player/skills/list.lua index 68b9c59..568a57f 100644 --- a/code/player/skills/list.lua +++ b/code/player/skills/list.lua @@ -29,7 +29,7 @@ local skill_list = { military = {'ranged_adv', 'guns', 'light_guns', 'heavy_guns', 'archery', 'archery_adv', 'melee_adv', 'chopping', 'slicing', 'smashing', 'smacking', 'explosives'}, medical = {'healing', 'major_healing', 'major_healing_adv', 'minor_healing', 'minor_healing_adv', 'chemistry', 'serium', 'stimulants', 'antibodies', 'recovery', 'recovery_adv', 'diagnosis_adv'}, research = {'bookworm'}, - engineering = {'repairs', 'repairs_adv',}, --'construction', 'renovate', 'barricade', 'barricade_adv', 'reinforce', 'tech', 'power_tech', 'radio_tech', 'computer_tech', 'reserve'}, + engineering = {'repairs', 'repairs_adv', 'barricade', 'barricade_adv', 'reinforce', 'renovate', 'tech', 'power_tech', 'radio_tech', 'computer_tech'}, --'construction', 'reserve'}, }, }, info = { @@ -552,23 +552,61 @@ local skill_list = { research = { lab_tech = {name='lab tech', desc='Gain ability to use science equipment',}, researcher = {name='researcher', desc='Gain ability to tag zombies and track via terminals',}, - computer_tech = {}, -- terminals installed/repaired/use at less ap bookworm = {name='bookworm',}, }, engineering = { - --construction = {name = 'construction',}, - repairs = {name='basic repairs', desc='Gain ability to repair equipment',}, - repairs_adv= {name='advanced repairs',desc='Gain ability to repair ruined buildings',}, + repairs = { + name='basic repairs', + desc='Gain ability to repair equipment', + icon='spanner', + }, + repairs_adv= { + name='advanced repairs', + desc='Repair equipment at cheaper cost', + icon='auto-repair', + }, + barricade = { + name='barricade', + desc='Gain ability to barricade past regular and increased barricade strength', + icon='wooden-door', + }, + barricade_adv= { + name='barricade advanced', + desc='Gain ability to barricade past very strongly and a bonus reroll for barricade strength', + icon='closed-doors', + }, + reinforce = { + name='reinforce', + desc='Gain ability to reinforce barricades for more available space', + icon='push', + }, + renovate = { + name='renovate', + desc='Gain ability to repair ruins', + icon='hammer-nails' + }, + tech = { + name='tech', + desc='Gain ability to install equipment', + icon='processor', + }, + power_tech = { + name='power tech', + desc='Installing generators requires less ap', + icon='light-bulb', + }, + radio_tech = { + name='radio tech', + desc='Installing radio transmitters requires less ap', + icon='radar-dish', + }, + computer_tech = { + name='computer tech', + desc='Installing computer terminals requires less ap', + icon='keyboard', + }, --[[ - renovate = {name='renovate'}, -- repair ruins - barricade = {name='barricade',}, -- barricade past very strongly? - barricade_adv= {name='barricade +', desc='Build better barricades',}, -- +1 to all barricades - reinforce = {name='reinforce',}, -- extend max barricade limit more easier - tech = {name='tech',}, - power_tech = {name='power tech',}, -- generators installed/repaired at less ap - radio_tech = {name='radio tech',}, - computer_tech = {name='computer tech',}, - + construction = {name='construction'}, -- ??? reserve = {name='reserve',}, -- toolbox durability increased --]] }, diff --git a/graphics/icons/skills/human/engineering.tps b/graphics/icons/skills/human/engineering.tps new file mode 100644 index 0000000..e12f82c --- /dev/null +++ b/graphics/icons/skills/human/engineering.tps @@ -0,0 +1,255 @@ + + + + fileFormatVersion + 3 + texturePackerVersion + 3.4.0 + fileName + C:/Users/Tim/Documents/GitHub/ZomboTropolis-Roguelike/graphics/icons/skills/human/engineering.tps + autoSDSettings + + + scale + 1 + extension + @4x + spriteFilter + + acceptFractionalValues + + maxTextureSize + + width + -1 + height + -1 + + + + scale + 0.5 + extension + @2x + spriteFilter + + acceptFractionalValues + + maxTextureSize + + width + -1 + height + -1 + + + + scale + 0.25 + extension + @1x + spriteFilter + + acceptFractionalValues + + maxTextureSize + + width + -1 + height + -1 + + + + scale + 0.125 + extension + @0.5x + spriteFilter + + acceptFractionalValues + + maxTextureSize + + width + -1 + height + -1 + + + + allowRotation + + premultiplyAlpha + + shapeDebug + + dpi + 72 + dataFormat + corona-imagesheet + textureFileName + engineering{v}.png + flipPVR + + ditherType + NearestNeighbour + backgroundColor + 0 + libGdx + + filtering + + x + Linear + y + Linear + + + shapePadding + 0 + jpgQuality + 80 + pngOptimizationLevel + 0 + webpQualityLevel + 101 + textureSubPath + + textureFormat + png + borderPadding + 0 + maxTextureSize + + width + 2048 + height + 2048 + + fixedTextureSize + + width + -1 + height + -1 + + reduceBorderArtifacts + + algorithmSettings + + algorithm + MaxRects + freeSizeMode + Best + sizeConstraints + AnySize + forceSquared + + forceWordAligned + + maxRects + + heuristic + Best + + basic + + sortBy + Best + order + Ascending + + + andEngine + + minFilter + Linear + packageName + Texture + wrap + + s + Clamp + t + Clamp + + magFilter + MagLinear + + dataFileNames + + data + + name + + + lua + + name + engineering{v}.lua + + + multiPack + + forceIdenticalLayout + + outputFormat + RGBA8888 + contentProtection + + key + + + autoAliasEnabled + + trimSpriteNames + + prependSmartFolderName + + cleanTransparentPixels + + globalSpriteSettings + + scale + 1 + scaleMode + Smooth + innerPadding + 0 + extrude + 0 + trimThreshold + 1 + trimMode + Trim + heuristicMask + + pivotPoint + Center + + fileList + + engineering/auto-repair.png + engineering/closed-doors.png + engineering/hammer-nails.png + engineering/keyboard.png + engineering/light-bulb.png + engineering/processor.png + engineering/push.png + engineering/radar-dish.png + engineering/spanner.png + engineering/wooden-door.png + + ignoreFileList + + replaceList + + ignoredWarnings + + commonDivisorX + 1 + commonDivisorY + 1 + + diff --git a/graphics/icons/skills/human/engineering/auto-repair.png b/graphics/icons/skills/human/engineering/auto-repair.png new file mode 100644 index 0000000..206bc91 Binary files /dev/null and b/graphics/icons/skills/human/engineering/auto-repair.png differ diff --git a/graphics/icons/skills/human/engineering/closed-doors.png b/graphics/icons/skills/human/engineering/closed-doors.png new file mode 100644 index 0000000..141d532 Binary files /dev/null and b/graphics/icons/skills/human/engineering/closed-doors.png differ diff --git a/graphics/icons/skills/human/engineering/hammer-nails.png b/graphics/icons/skills/human/engineering/hammer-nails.png new file mode 100644 index 0000000..0c3764f Binary files /dev/null and b/graphics/icons/skills/human/engineering/hammer-nails.png differ diff --git a/graphics/icons/skills/human/engineering/keyboard.png b/graphics/icons/skills/human/engineering/keyboard.png new file mode 100644 index 0000000..4f2c1c7 Binary files /dev/null and b/graphics/icons/skills/human/engineering/keyboard.png differ diff --git a/graphics/icons/skills/human/engineering/light-bulb.png b/graphics/icons/skills/human/engineering/light-bulb.png new file mode 100644 index 0000000..04d443f Binary files /dev/null and b/graphics/icons/skills/human/engineering/light-bulb.png differ diff --git a/graphics/icons/skills/human/engineering/processor.png b/graphics/icons/skills/human/engineering/processor.png new file mode 100644 index 0000000..d4c9b59 Binary files /dev/null and b/graphics/icons/skills/human/engineering/processor.png differ diff --git a/graphics/icons/skills/human/engineering/push.png b/graphics/icons/skills/human/engineering/push.png new file mode 100644 index 0000000..6278383 Binary files /dev/null and b/graphics/icons/skills/human/engineering/push.png differ diff --git a/graphics/icons/skills/human/engineering/radar-dish.png b/graphics/icons/skills/human/engineering/radar-dish.png new file mode 100644 index 0000000..df215ad Binary files /dev/null and b/graphics/icons/skills/human/engineering/radar-dish.png differ diff --git a/graphics/icons/skills/human/engineering/spanner.png b/graphics/icons/skills/human/engineering/spanner.png new file mode 100644 index 0000000..a23a0b7 Binary files /dev/null and b/graphics/icons/skills/human/engineering/spanner.png differ diff --git a/graphics/icons/skills/human/engineering/wooden-door.png b/graphics/icons/skills/human/engineering/wooden-door.png new file mode 100644 index 0000000..a73ff48 Binary files /dev/null and b/graphics/icons/skills/human/engineering/wooden-door.png differ diff --git a/graphics/icons/skills/human/engineering@0.5x.lua b/graphics/icons/skills/human/engineering@0.5x.lua index 15369dd..92a836b 100644 --- a/graphics/icons/skills/human/engineering@0.5x.lua +++ b/graphics/icons/skills/human/engineering@0.5x.lua @@ -1,7 +1,7 @@ -- -- created with TexturePacker (http://www.codeandweb.com/texturepacker) -- --- $TexturePacker:SmartUpdate:5298dbad9e9f261cf9c1d7ec8a139b20:5bde6d16fda800c4d752b092767a32ad:31a49f9b64123c8184d8f9d9ca4b1789$ +-- $TexturePacker:SmartUpdate:ad36779889ba8f2b0f50f1c392072f67:6affa68a25f0e28cee65e5ea14100536:31a49f9b64123c8184d8f9d9ca4b1789$ -- -- local sheetInfo = require("mysheet") -- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() ) @@ -15,7 +15,7 @@ SheetInfo.sheet = frames = { { - -- aerosol + -- auto-repair x=0, y=0, width=64, @@ -23,7 +23,7 @@ SheetInfo.sheet = }, { - -- fulguro-punch + -- closed-doors x=64, y=0, width=64, @@ -31,7 +31,7 @@ SheetInfo.sheet = }, { - -- muscle-fat + -- hammer-nails x=128, y=0, width=64, @@ -39,7 +39,7 @@ SheetInfo.sheet = }, { - -- muscle-up + -- keyboard x=192, y=0, width=64, @@ -47,7 +47,7 @@ SheetInfo.sheet = }, { - -- pummeled + -- light-bulb x=256, y=0, width=64, @@ -55,7 +55,7 @@ SheetInfo.sheet = }, { - -- punch + -- processor x=320, y=0, width=64, @@ -63,7 +63,7 @@ SheetInfo.sheet = }, { - -- quick-slash + -- push x=384, y=0, width=64, @@ -71,7 +71,7 @@ SheetInfo.sheet = }, { - -- serrated-slash + -- radar-dish x=448, y=0, width=64, @@ -79,7 +79,7 @@ SheetInfo.sheet = }, { - -- slap + -- spanner x=512, y=0, width=64, @@ -87,50 +87,32 @@ SheetInfo.sheet = }, { - -- snatch + -- wooden-door x=576, y=0, width=64, height=64, }, - { - -- sprint - x=640, - y=0, - width=64, - height=64, - - }, - { - -- targeting - x=704, - y=0, - width=64, - height=64, - - }, }, - sheetContentWidth = 768, + sheetContentWidth = 640, sheetContentHeight = 64 } SheetInfo.frameIndex = { - ["aerosol"] = 1, - ["fulguro-punch"] = 2, - ["muscle-fat"] = 3, - ["muscle-up"] = 4, - ["pummeled"] = 5, - ["punch"] = 6, - ["quick-slash"] = 7, - ["serrated-slash"] = 8, - ["slap"] = 9, - ["snatch"] = 10, - ["sprint"] = 11, - ["targeting"] = 12, + ["auto-repair"] = 1, + ["closed-doors"] = 2, + ["hammer-nails"] = 3, + ["keyboard"] = 4, + ["light-bulb"] = 5, + ["processor"] = 6, + ["push"] = 7, + ["radar-dish"] = 8, + ["spanner"] = 9, + ["wooden-door"] = 10, } function SheetInfo:getSheet() diff --git a/graphics/icons/skills/human/engineering@0.5x.png b/graphics/icons/skills/human/engineering@0.5x.png index 2996b3d..aac9597 100644 Binary files a/graphics/icons/skills/human/engineering@0.5x.png and b/graphics/icons/skills/human/engineering@0.5x.png differ diff --git a/graphics/icons/skills/human/engineering@1x.lua b/graphics/icons/skills/human/engineering@1x.lua index 176abd1..570d9ba 100644 --- a/graphics/icons/skills/human/engineering@1x.lua +++ b/graphics/icons/skills/human/engineering@1x.lua @@ -1,7 +1,7 @@ -- -- created with TexturePacker (http://www.codeandweb.com/texturepacker) -- --- $TexturePacker:SmartUpdate:5298dbad9e9f261cf9c1d7ec8a139b20:5bde6d16fda800c4d752b092767a32ad:31a49f9b64123c8184d8f9d9ca4b1789$ +-- $TexturePacker:SmartUpdate:ad36779889ba8f2b0f50f1c392072f67:6affa68a25f0e28cee65e5ea14100536:31a49f9b64123c8184d8f9d9ca4b1789$ -- -- local sheetInfo = require("mysheet") -- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() ) @@ -15,7 +15,7 @@ SheetInfo.sheet = frames = { { - -- aerosol + -- auto-repair x=0, y=0, width=128, @@ -23,7 +23,7 @@ SheetInfo.sheet = }, { - -- fulguro-punch + -- closed-doors x=128, y=0, width=128, @@ -31,7 +31,7 @@ SheetInfo.sheet = }, { - -- muscle-fat + -- hammer-nails x=256, y=0, width=128, @@ -39,7 +39,7 @@ SheetInfo.sheet = }, { - -- muscle-up + -- keyboard x=384, y=0, width=128, @@ -47,7 +47,7 @@ SheetInfo.sheet = }, { - -- pummeled + -- light-bulb x=512, y=0, width=128, @@ -55,7 +55,7 @@ SheetInfo.sheet = }, { - -- punch + -- processor x=640, y=0, width=128, @@ -63,7 +63,7 @@ SheetInfo.sheet = }, { - -- quick-slash + -- push x=768, y=0, width=128, @@ -71,7 +71,7 @@ SheetInfo.sheet = }, { - -- serrated-slash + -- radar-dish x=896, y=0, width=128, @@ -79,7 +79,7 @@ SheetInfo.sheet = }, { - -- slap + -- spanner x=1024, y=0, width=128, @@ -87,50 +87,32 @@ SheetInfo.sheet = }, { - -- snatch + -- wooden-door x=1152, y=0, width=128, height=128, }, - { - -- sprint - x=1280, - y=0, - width=128, - height=128, - - }, - { - -- targeting - x=1408, - y=0, - width=128, - height=128, - - }, }, - sheetContentWidth = 1536, + sheetContentWidth = 1280, sheetContentHeight = 128 } SheetInfo.frameIndex = { - ["aerosol"] = 1, - ["fulguro-punch"] = 2, - ["muscle-fat"] = 3, - ["muscle-up"] = 4, - ["pummeled"] = 5, - ["punch"] = 6, - ["quick-slash"] = 7, - ["serrated-slash"] = 8, - ["slap"] = 9, - ["snatch"] = 10, - ["sprint"] = 11, - ["targeting"] = 12, + ["auto-repair"] = 1, + ["closed-doors"] = 2, + ["hammer-nails"] = 3, + ["keyboard"] = 4, + ["light-bulb"] = 5, + ["processor"] = 6, + ["push"] = 7, + ["radar-dish"] = 8, + ["spanner"] = 9, + ["wooden-door"] = 10, } function SheetInfo:getSheet() diff --git a/graphics/icons/skills/human/engineering@1x.png b/graphics/icons/skills/human/engineering@1x.png index 24c1d38..7458fc5 100644 Binary files a/graphics/icons/skills/human/engineering@1x.png and b/graphics/icons/skills/human/engineering@1x.png differ diff --git a/graphics/icons/skills/human/engineering@2x.lua b/graphics/icons/skills/human/engineering@2x.lua index b202041..4ea4f30 100644 --- a/graphics/icons/skills/human/engineering@2x.lua +++ b/graphics/icons/skills/human/engineering@2x.lua @@ -1,7 +1,7 @@ -- -- created with TexturePacker (http://www.codeandweb.com/texturepacker) -- --- $TexturePacker:SmartUpdate:5298dbad9e9f261cf9c1d7ec8a139b20:5bde6d16fda800c4d752b092767a32ad:31a49f9b64123c8184d8f9d9ca4b1789$ +-- $TexturePacker:SmartUpdate:ad36779889ba8f2b0f50f1c392072f67:6affa68a25f0e28cee65e5ea14100536:31a49f9b64123c8184d8f9d9ca4b1789$ -- -- local sheetInfo = require("mysheet") -- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() ) @@ -15,7 +15,7 @@ SheetInfo.sheet = frames = { { - -- aerosol + -- auto-repair x=0, y=0, width=256, @@ -23,7 +23,7 @@ SheetInfo.sheet = }, { - -- fulguro-punch + -- closed-doors x=0, y=256, width=256, @@ -31,7 +31,7 @@ SheetInfo.sheet = }, { - -- muscle-fat + -- hammer-nails x=256, y=0, width=256, @@ -39,7 +39,7 @@ SheetInfo.sheet = }, { - -- muscle-up + -- keyboard x=256, y=256, width=256, @@ -47,7 +47,7 @@ SheetInfo.sheet = }, { - -- pummeled + -- light-bulb x=512, y=0, width=256, @@ -55,7 +55,7 @@ SheetInfo.sheet = }, { - -- punch + -- processor x=512, y=256, width=256, @@ -63,7 +63,7 @@ SheetInfo.sheet = }, { - -- quick-slash + -- push x=768, y=0, width=256, @@ -71,7 +71,7 @@ SheetInfo.sheet = }, { - -- serrated-slash + -- radar-dish x=768, y=256, width=256, @@ -79,7 +79,7 @@ SheetInfo.sheet = }, { - -- slap + -- spanner x=1024, y=0, width=256, @@ -87,50 +87,32 @@ SheetInfo.sheet = }, { - -- snatch + -- wooden-door x=1024, y=256, width=256, height=256, }, - { - -- sprint - x=1280, - y=0, - width=256, - height=256, - - }, - { - -- targeting - x=1280, - y=256, - width=256, - height=256, - - }, }, - sheetContentWidth = 1536, + sheetContentWidth = 1280, sheetContentHeight = 512 } SheetInfo.frameIndex = { - ["aerosol"] = 1, - ["fulguro-punch"] = 2, - ["muscle-fat"] = 3, - ["muscle-up"] = 4, - ["pummeled"] = 5, - ["punch"] = 6, - ["quick-slash"] = 7, - ["serrated-slash"] = 8, - ["slap"] = 9, - ["snatch"] = 10, - ["sprint"] = 11, - ["targeting"] = 12, + ["auto-repair"] = 1, + ["closed-doors"] = 2, + ["hammer-nails"] = 3, + ["keyboard"] = 4, + ["light-bulb"] = 5, + ["processor"] = 6, + ["push"] = 7, + ["radar-dish"] = 8, + ["spanner"] = 9, + ["wooden-door"] = 10, } function SheetInfo:getSheet() diff --git a/graphics/icons/skills/human/engineering@2x.png b/graphics/icons/skills/human/engineering@2x.png index a28a0d2..e4a4ca1 100644 Binary files a/graphics/icons/skills/human/engineering@2x.png and b/graphics/icons/skills/human/engineering@2x.png differ diff --git a/graphics/icons/skills/human/engineering@4x.lua b/graphics/icons/skills/human/engineering@4x.lua index ee5c36e..728c2f7 100644 --- a/graphics/icons/skills/human/engineering@4x.lua +++ b/graphics/icons/skills/human/engineering@4x.lua @@ -1,7 +1,7 @@ -- -- created with TexturePacker (http://www.codeandweb.com/texturepacker) -- --- $TexturePacker:SmartUpdate:5298dbad9e9f261cf9c1d7ec8a139b20:5bde6d16fda800c4d752b092767a32ad:31a49f9b64123c8184d8f9d9ca4b1789$ +-- $TexturePacker:SmartUpdate:ad36779889ba8f2b0f50f1c392072f67:6affa68a25f0e28cee65e5ea14100536:31a49f9b64123c8184d8f9d9ca4b1789$ -- -- local sheetInfo = require("mysheet") -- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() ) @@ -15,7 +15,7 @@ SheetInfo.sheet = frames = { { - -- aerosol + -- auto-repair x=0, y=0, width=512, @@ -23,23 +23,7 @@ SheetInfo.sheet = }, { - -- fulguro-punch - x=512, - y=0, - width=512, - height=512, - - }, - { - -- muscle-fat - x=1024, - y=0, - width=512, - height=512, - - }, - { - -- muscle-up + -- closed-doors x=0, y=512, width=512, @@ -47,7 +31,7 @@ SheetInfo.sheet = }, { - -- pummeled + -- hammer-nails x=0, y=1024, width=512, @@ -55,15 +39,15 @@ SheetInfo.sheet = }, { - -- punch - x=0, - y=1536, + -- keyboard + x=512, + y=0, width=512, height=512, }, { - -- quick-slash + -- light-bulb x=512, y=512, width=512, @@ -71,66 +55,64 @@ SheetInfo.sheet = }, { - -- serrated-slash - x=1024, - y=512, + -- processor + x=512, + y=1024, width=512, height=512, }, { - -- slap - x=512, - y=1024, + -- push + x=1024, + y=0, width=512, height=512, }, { - -- snatch - x=512, - y=1536, + -- radar-dish + x=1536, + y=0, width=512, height=512, }, { - -- sprint + -- spanner x=1024, - y=1024, + y=512, width=512, height=512, }, { - -- targeting + -- wooden-door x=1024, - y=1536, + y=1024, width=512, height=512, }, }, - sheetContentWidth = 1536, - sheetContentHeight = 2048 + sheetContentWidth = 2048, + sheetContentHeight = 1536 } SheetInfo.frameIndex = { - ["aerosol"] = 1, - ["fulguro-punch"] = 2, - ["muscle-fat"] = 3, - ["muscle-up"] = 4, - ["pummeled"] = 5, - ["punch"] = 6, - ["quick-slash"] = 7, - ["serrated-slash"] = 8, - ["slap"] = 9, - ["snatch"] = 10, - ["sprint"] = 11, - ["targeting"] = 12, + ["auto-repair"] = 1, + ["closed-doors"] = 2, + ["hammer-nails"] = 3, + ["keyboard"] = 4, + ["light-bulb"] = 5, + ["processor"] = 6, + ["push"] = 7, + ["radar-dish"] = 8, + ["spanner"] = 9, + ["wooden-door"] = 10, } function SheetInfo:getSheet() diff --git a/graphics/icons/skills/human/engineering@4x.png b/graphics/icons/skills/human/engineering@4x.png index 586cb8b..da185fe 100644 Binary files a/graphics/icons/skills/human/engineering@4x.png and b/graphics/icons/skills/human/engineering@4x.png differ diff --git a/scenes/action.lua b/scenes/action.lua index 2a05bc5..5023f14 100644 --- a/scenes/action.lua +++ b/scenes/action.lua @@ -51,25 +51,9 @@ elseif main_player:isMobType('human') then item = main_player:getActions('item') end - - local menu_w = width - 20 local actionMenu, tabBar, selectedTab, itemListMenu, menu ---[[ -local function onCategoryTap(event) - local row = event.target - print("tapped Category", row.id) - - for k,v in pairs(rowTitles) do rowTitles[k]=nil end - - listItems[row.id].collapsed = not listItems[row.id].collapsed - list:deleteAllRows() - populateList() -end ---]] - - local function populateItemList() menu:insertRow{isCategory=true, params = {name = '[ITEM]', condition = '[CONDITION]', weight = '[SIZE]', canBeTapped=false}} @@ -77,9 +61,9 @@ local function populateItemList() local item = itemListMenu[i].item menu:insertRow{params = {name = item:getClassName(), condition = item:getConditionState(), weight = item:getWeight(), canBeTapped=true}} if itemListMenu[i].collapsed then - menu:insertRow{params = {discard=true, activate=item:canBeActivated(), canBeTapped=false, item_options=true}} + menu:insertRow{params = {name=item:getClassName(), inventory_index=i, discard=true, activate=item:canBeActivated(), canBeTapped=false, item_options=true}} end - end + end end local function onCategoryTap(event) @@ -102,18 +86,40 @@ local function onRowRender( event ) local rowWidth = row.contentWidth if row.params.item_options then - -- row.params.discard - --[[local rowTitle = display.newText( row, 'Discard='..tostring(row.params.discard)..' Activate='..tostring(row.params.activate), 10, 0, nil, 14 ) -- THIS LINE IS IMPORTANT - rowTitle:setFillColor(0) - rowTitle.anchorX = 0 - rowTitle.y = rowHeight * 0.5 - --]] + print('') + print('row.params are:') + for k,v in pairs(row.params) do print(k,v) end -- Function to handle button events local function handleButtonEvent( event ) if ( "ended" == event.phase ) then print( "Button was pressed and released" ) + local item_name = row.params.name + print(item_name, 'action cost is - ', main_player:getCost('ap', item_name)) + + local options = { + isModal = true, + effect = "fade", + time = 400, + params = {} + } + + local mob_type = main_player:getMobType() + local action_data, params = action_list[mob_type][item_name], options.params + params.id = action_data.name + params.inv_id = event.target.id + params.name = action_data.name + params.desc = action_data.desc + params.icon = action_data.icon + params.cost = main_player:getCost('ap', item_name) + + print('') + print('The params going into options are:') + for k,v in pairs(options.params) do print(k,v) end + + composer.showOverlay( "scenes.action_perform", options) + print( "Button was pressed and released" ) end end @@ -122,7 +128,7 @@ local function onRowRender( event ) { left = 20, top = 0, - id = "button1", + id = row.params.inventory_index, label = "Use", shape = 'roundedRect', height = 40, diff --git a/scenes/action_perform.lua b/scenes/action_perform.lua index 5c88f28..6653bb9 100644 --- a/scenes/action_perform.lua +++ b/scenes/action_perform.lua @@ -44,6 +44,7 @@ end local speak_msg local targets, weapons, wheel, armor_list +local action_params local function getActionText(action) local p_tile = main_player:getTile() @@ -74,7 +75,7 @@ local function getActionText(action) end --]] elseif action == 'barricade' then - + str = 'Barricade the '.. p_tile:getName() .. ' ' .. p_tile:getClassName() .. '?' elseif action == 'groan' then str = 'Emit groan?' elseif action == 'gesture' or action == 'drag_prey' then @@ -119,7 +120,8 @@ local function getActionParams(action) --]] params = {speak_msg} elseif action == 'barricade' then - + local inventory_ID = action_params.inv_id + params = {inventory_ID} end return params end @@ -236,6 +238,7 @@ function scene:create( event ) local sceneGroup = self.view --local parent = event.parent local params = event.params + action_params = event.params local action = event.params.id container_xtra_w = extra_widget_sizes[action] and extra_widget_sizes[action].width or 0 @@ -273,6 +276,11 @@ function scene:create( event ) local performButtonEvent = function(event) if ('ended' == event.phase) then if active_timer then timer.cancel(active_timer) end + + print('') + print('getting action params:') + for k,v in pairs(getActionParams(action)) do print(k,v) end + main_player:takeAction(action, unpack(getActionParams(action))) composer.hideOverlay('fade', 400) composer.gotoScene('scenes.action') diff --git a/scenes/map.lua b/scenes/map.lua index 22183a8..771f8b2 100644 --- a/scenes/map.lua +++ b/scenes/map.lua @@ -454,6 +454,10 @@ function scene:create( event ) if main_player:isStaged('outside') then desc_text = location:getDesc('external') elseif main_player:isStaged('inside') then desc_text = location:getDesc('internal') end + + if location:isBuilding() then + desc_text = desc_text..'\n\n'..location:getBarrierDesc() + end local text_object = display.newText(desc_text, 0, 0, 285, 0, native.systemFont, 12, "right") text_object:setTextColor(0) diff --git a/scenes/skill_purchase.lua b/scenes/skill_purchase.lua index deb12e7..2497b38 100644 --- a/scenes/skill_purchase.lua +++ b/scenes/skill_purchase.lua @@ -93,7 +93,7 @@ function scene:create( event ) local sceneGroup = self.view local parent = event.parent local params = event.params - + -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. local bar_h = 30 diff --git a/scenes/skills.lua b/scenes/skills.lua index 156b5b3..c661dfc 100644 --- a/scenes/skills.lua +++ b/scenes/skills.lua @@ -146,7 +146,7 @@ local skill_buttons, categoryText, scrollView = {}, {} local function handleButtonEvent( event ) skill_buttons[event.target.id]:setFillColor(unpack(getButtonColor(event.target.id))) - if ( "ended" == event.phase ) then + if ( "ended" == event.phase ) then local skill, params = skill_list[event.target.id], options.params params.id = event.target.id params.name = skill.name