From 2bff23f1f1d1fe7d7dfd5ca33bb390ce070966a5 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 17:23:08 -0500 Subject: [PATCH 1/9] Bumped version number to v0.4.1 --- settings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.lua b/settings.lua index 1b6d4fa..2a72fbc 100644 --- a/settings.lua +++ b/settings.lua @@ -1,5 +1,5 @@ local settings = { - _VERSION = 'ZomboTropolis v0.4.0', + _VERSION = 'ZomboTropolis v0.4.1', _AUTHOR = 'Timothy Torres', _URL = 'https://github.com/timothymtorres/ZomboTropolis-Roguelike', _DESCRIPTION = 'A zombie survival roguelike MMORPG.', From ed09e13f242ce8b0b2c161c57bdc86cc6a68768f Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 17:47:26 -0500 Subject: [PATCH 2/9] Changed item:initialize argument and removed print statements item:initialize arg now accepts a string or number and converts it into the instance condition. If the arg is malformed an error will result. --- code/item/class.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/code/item/class.lua b/code/item/class.lua index 0f1a906..d665c87 100644 --- a/code/item/class.lua +++ b/code/item/class.lua @@ -29,11 +29,10 @@ local condition_spawn_odds = { -- used when spawning new item powered = {[1] = 0.10, [2] = 0.25, [3] = 0.40, [4] = 0.25}, } -function item:initialize(location_status) ---print(condition_spawn_odds, location_status) ---print(condition_spawn_odds[location_status]) - self.condition = selectFrom(condition_spawn_odds[location_status]) ---print('self.condition - ', self.condition) +function item:initialize(condition_setting) + if type(condition_setting) == 'string' then self.condition = selectFrom(condition_spawn_odds[condition_setting]) + elseif type(condition_setting) == 'number' and condition_setting > 0 and condition_setting <= 4 then self.condition = condition_setting + else error('Item initialization has a malformed condition setting') end --[[ THESE ARE SERVER/DATABASE FUNCTIONS From 7fe441e2a7141abf0e378c1ca45173ad46a44bcd Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 17:49:22 -0500 Subject: [PATCH 3/9] Changed index values for resistance Index values were from [0]-[3] when item.conditions are from [1]-[4]? Not sure if I have this problem with other items, but if I do they need to be converted to [1]-[4]. Lua indexs start from 1, not 0 so keeping in line with that. --- code/item/list/armor.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/item/list/armor.lua b/code/item/list/armor.lua index b2c342e..4c4fe6e 100644 --- a/code/item/list/armor.lua +++ b/code/item/list/armor.lua @@ -14,20 +14,20 @@ armor.leather = {} armor.leather.full_name = 'leather jacket' armor.leather.durability = 32 armor.leather.resistance = { - [0] = {blunt=1}, [1] = {blunt=1}, [2] = {blunt=1}, [3] = {blunt=1}, + [4] = {blunt=1}, } armor.firesuit = {} armor.firesuit.full_name = 'firesuit' armor.firesuit.durability = 4 armor.firesuit.resistance = { - [0] = {acid=1}, - [1] = {acid=2}, - [2] = {acid=3}, - [3] = {acid=4}, + [1] = {acid=1}, + [2] = {acid=2}, + [3] = {acid=3}, + [4] = {acid=4}, } return armor \ No newline at end of file From 4ef119d7d27ecd9337d18d0fc87fe4a900d1c7bd Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 22:23:23 -0500 Subject: [PATCH 4/9] Bugfix/Typo - Forgot to end an if loop --- code/item/class.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/code/item/class.lua b/code/item/class.lua index d665c87..f03b274 100644 --- a/code/item/class.lua +++ b/code/item/class.lua @@ -33,6 +33,7 @@ function item:initialize(condition_setting) if type(condition_setting) == 'string' then self.condition = selectFrom(condition_spawn_odds[condition_setting]) elseif type(condition_setting) == 'number' and condition_setting > 0 and condition_setting <= 4 then self.condition = condition_setting else error('Item initialization has a malformed condition setting') + end end --[[ THESE ARE SERVER/DATABASE FUNCTIONS From 5082acbf69aaf9a683a1395c4f95ba6ccff19c81 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 22:27:43 -0500 Subject: [PATCH 5/9] Refactored armor for humans Removed inv_ID tracking for item armor class, instead it now copies the condition and name of the armor in the armor_INST and removes the item from inventory. Lot easier to manage this way, but in the superclass armor it has to be split via human/zombie. Possibly change zombie armor to be more similiar to human armor? Unsure. --- code/player/armor/class.lua | 26 +++++++++++++++++++++++--- code/player/armor/item_class.lua | 27 +++++++++++++++------------ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/code/player/armor/class.lua b/code/player/armor/class.lua index d50a800..2f03b5a 100644 --- a/code/player/armor/class.lua +++ b/code/player/armor/class.lua @@ -1,4 +1,5 @@ local dice = require('code.libs.dice') +local item_armor_list = require('code.player.armor.item_list') local class = require('code.libs.middleclass') local armor = class('armor') @@ -7,10 +8,29 @@ function armor:initialize(player) self.player = player end -function armor:failDurabilityCheck(degrade_chance) return dice.roll(self.durability) <= degrade_chance end +-- Possibly consider redoing armor for the zombies? Make it similiar to human armor or less complex... if it's made to be similiar to human armor, it will shrink +-- down the code in this file quite a bit, no need to differenate between human/zombie mobtypes -function armor:getProtection(damage_type) return self.protection[damage_type] or 0 end +function armor:failDurabilityCheck(degrade_chance) + local player, protection = self.player + + if player:isMobType('human') then return dice.roll(item_armor_list[self.name].durability) <= degrade_chance + elseif player:isMobType('zombie') then return dice.roll(self.durability) <= degrade_chance + end +end -function armor:isPresent() return self.protection and true or false end +function armor:getProtection(damage_type) + local player, protection = self.player + + if player:isMobType('human') then return item_armor_list[self.name].resistance[self.condition][damage_type] or 0 + elseif player:isMobType('zombie') then return self.protection[damage_type] or 0 + end +end + +function armor:isPresent() + if player:isMobType('human') then return self.name and true or false + elseif player:isMobType('zombie') then return self.protection and true or false + end +end return armor \ No newline at end of file diff --git a/code/player/armor/item_class.lua b/code/player/armor/item_class.lua index 42a8126..8e74737 100644 --- a/code/player/armor/item_class.lua +++ b/code/player/armor/item_class.lua @@ -1,6 +1,7 @@ -local class = require('code.libs.middleclass') +local class = require('code.libs.middleclass') local item_armor_list = require('code.item.list.armor') -local armor = require('code.player.armor.class') +local item = require('code.item.class') +local armor = require('code.player.armor.class') local item_armor = class('item_armor', armor) @@ -8,23 +9,25 @@ function item_armor:initialize(player) armor.initialize(self, player) end -function item_armor:equip(name, condition, inv_ID) - self.protection = item_armor_list[name].resistance[condition] - self.name, self.inv_ID, self.condition = name, inv_ID, condition - self.durability = item_armor_list[name].durability +function item_armor:equip(name, condition) + if self:isPresent() then self:remove() end -- unequips the old armor and puts it back into the inventory + self.name, self.condition = name, condition end -function item_armor:degrade(player) - local item_INST = player.inventory:lookup(self.inv_ID) - item_INST:updateCondition(-1, player, self.inv_ID) +function item_armor:remove() + local player, armor_type, condition = self.player, self.name, self.condition + local armor_INST = item[armor_type]:new(condition) + player.inventory:insert(armor_INST) + self.name, self.condition = nil, nil +end + +function item_armor:degrade(player) self.condition = self.condition - 1 if 0 > self.condition then -- armor is destroyed - local player = self.player - player.armor = item_armor:new(player) + self.name, self.condition = nil, nil return -- something to tell that armor is destroyed? end - self.protection = item_armor_list[self.name].resistance[self.condition] end return item_armor \ No newline at end of file From 6a1882d5281449e6f1d77b706484b38eac7e5d55 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 22:30:14 -0500 Subject: [PATCH 6/9] Make armor items one use, and relocate durability values to a different file Item list now has armor durability to 0, and the prior values are transferred to code/player/armor/item_list.lua --- code/item/list/armor.lua | 23 +++-------------------- code/player/armor/item_list.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 code/player/armor/item_list.lua diff --git a/code/item/list/armor.lua b/code/item/list/armor.lua index 4c4fe6e..c0b18ca 100644 --- a/code/item/list/armor.lua +++ b/code/item/list/armor.lua @@ -2,32 +2,15 @@ local armor = {} --[[ full_name = 'insert name' - durability = num (average # of attacks it takes to wear armor out) - resistance = { - condition = {protection=num}, - } - - ** As condition becomes worse armor starts to lose resistance (with the exception of a few armors) + durability = 0 (all armor is one_use) --]] armor.leather = {} armor.leather.full_name = 'leather jacket' -armor.leather.durability = 32 -armor.leather.resistance = { - [1] = {blunt=1}, - [2] = {blunt=1}, - [3] = {blunt=1}, - [4] = {blunt=1}, -} +armor.leather.durability = 0 armor.firesuit = {} armor.firesuit.full_name = 'firesuit' -armor.firesuit.durability = 4 -armor.firesuit.resistance = { - [1] = {acid=1}, - [2] = {acid=2}, - [3] = {acid=3}, - [4] = {acid=4}, -} +armor.firesuit.durability = 0 return armor \ No newline at end of file diff --git a/code/player/armor/item_list.lua b/code/player/armor/item_list.lua new file mode 100644 index 0000000..40c3fbe --- /dev/null +++ b/code/player/armor/item_list.lua @@ -0,0 +1,31 @@ +local armor = {} + +--[[ + full_name = 'insert name' + durability = num (average # of attacks it takes to wear armor out) + resistance = { + condition = {protection=num}, + } + + ** As condition becomes worse armor starts to lose resistance (with the exception of a few armors) +--]] + +armor.leather = {} +armor.leather.durability = 32 +armor.leather.resistance = { + [1] = {blunt=1}, + [2] = {blunt=1}, + [3] = {blunt=1}, + [4] = {blunt=1}, +} + +armor.firesuit = {} +armor.firesuit.durability = 4 +armor.firesuit.resistance = { + [1] = {acid=1}, + [2] = {acid=2}, + [3] = {acid=3}, + [4] = {acid=4}, +} + +return armor \ No newline at end of file From 9ec64e483ffda3baebec0f79be2c5b7cb19c4747 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 22:30:50 -0500 Subject: [PATCH 7/9] Added criteria, check, and activate functions for armor --- code/item/use/activate.lua | 12 ++++++++++++ code/item/use/check.lua | 8 ++++++++ code/item/use/criteria.lua | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/code/item/use/activate.lua b/code/item/use/activate.lua index 6b198b9..dcb970f 100644 --- a/code/item/use/activate.lua +++ b/code/item/use/activate.lua @@ -205,4 +205,16 @@ function activate.bottle(player, condition) player:updateHP(1) end +--[[ +--- ARMOR +--]] + +function activate.leather(player, condition) + player.armor:equip('leather', condition) +end + +function activate.firesuit(player, condition) + player.armor:equip('firesuit', condition) +end + return activate \ No newline at end of file diff --git a/code/item/use/check.lua b/code/item/use/check.lua index abf4151..24c4647 100644 --- a/code/item/use/check.lua +++ b/code/item/use/check.lua @@ -103,4 +103,12 @@ function check.barricade(player) assert(playerInsideBuilding(player), 'Must be inside building to use barricade') end +--[[ +--- ARMOR +--]] + +function check.leather(player) end + +function check.firesuit(player) end + return check \ No newline at end of file diff --git a/code/item/use/criteria.lua b/code/item/use/criteria.lua index a63b116..1897553 100644 --- a/code/item/use/criteria.lua +++ b/code/item/use/criteria.lua @@ -170,4 +170,12 @@ function criteria.newspaper(player) end -- need light? function criteria.bottle(player) end +--[[ +--- ARMOR +--]] + +function criteria.leather(player) end -- make sure there is inventory room when unequiping armor? + +function criteria.firesuit(player) end + return criteria \ No newline at end of file From f6f83d6bbb253f3acfed3d61161c06f51ae524e2 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 22:31:21 -0500 Subject: [PATCH 8/9] Added msg, zone, and AP cost to item armor --- code/player/action/list.lua | 2 ++ code/player/action/zone.lua | 4 ++++ code/player/log/getMessage.lua | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/code/player/action/list.lua b/code/player/action/list.lua index aa3853a..ba0082d 100644 --- a/code/player/action/list.lua +++ b/code/player/action/list.lua @@ -65,6 +65,8 @@ local action_list = { antidote = {name='antidote', cost=1}, antibodies= {name='antibodies', cost=1}, syringe = {name='syringe', cost=1}, + leather = {name='leather', cost=1}, + firesuit = {name='firesuit', cost=1}, }, equipment = { broadcast = {cost=3, modifier={tech = -1, radio_tech = -1},}, diff --git a/code/player/action/zone.lua b/code/player/action/zone.lua index dfb1029..73ca550 100644 --- a/code/player/action/zone.lua +++ b/code/player/action/zone.lua @@ -79,6 +79,10 @@ function setupZone.syringe(player, inv_ID, target) zone.target = target end +function setupZone.leather(player, inv_ID) + zone.type = 'self' +end + --------------------------------------- --------------------------------------- -- ZOMBIE -- diff --git a/code/player/log/getMessage.lua b/code/player/log/getMessage.lua index 1d267cd..7f45922 100644 --- a/code/player/log/getMessage.lua +++ b/code/player/log/getMessage.lua @@ -88,6 +88,16 @@ function description.syringe(player, inv_ID, target, inject_success, target_weak end end +function description.leather(player, inv_ID) + local armor_INST = player.inventory:lookup(inv_ID) + msg[1] = 'You equip '..armor_INST:getClassName()..' armor.' +end + +function description.firesuit() + local armor_INST = player.inventory:lookup(inv_ID) + msg[1] = 'You equip '..armor_INST:getClassName()..' armor.' +end + --------------------------------------- --------------------------------------- -- ZOMBIE -- From 3685a3beac89d36f4f11c3f38220bdfac043a523 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 12 Aug 2017 22:38:43 -0500 Subject: [PATCH 9/9] Remove arg from armor:equip --- main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.lua b/main.lua index eec2895..7f5df64 100644 --- a/main.lua +++ b/main.lua @@ -51,7 +51,7 @@ end local firesuit_INST = item.firesuit:new('ruined') alt_player.inventory:insert(firesuit_INST) -alt_player.armor:equip('firesuit', firesuit_INST:getCondition(), #alt_player.inventory) +alt_player.armor:equip('firesuit', firesuit_INST:getCondition()) --[[ print('---------')