Skip to content

Commit fc155d9

Browse files
Merge branch 'hotfix-v0.4.1'
2 parents 68a749e + 3685a3b commit fc155d9

File tree

13 files changed

+123
-42
lines changed

13 files changed

+123
-42
lines changed

code/item/class.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ local condition_spawn_odds = { -- used when spawning new item
2929
powered = {[1] = 0.10, [2] = 0.25, [3] = 0.40, [4] = 0.25},
3030
}
3131

32-
function item:initialize(location_status)
33-
--print(condition_spawn_odds, location_status)
34-
--print(condition_spawn_odds[location_status])
35-
self.condition = selectFrom(condition_spawn_odds[location_status])
36-
--print('self.condition - ', self.condition)
32+
function item:initialize(condition_setting)
33+
if type(condition_setting) == 'string' then self.condition = selectFrom(condition_spawn_odds[condition_setting])
34+
elseif type(condition_setting) == 'number' and condition_setting > 0 and condition_setting <= 4 then self.condition = condition_setting
35+
else error('Item initialization has a malformed condition setting')
36+
end
3737
end
3838

3939
--[[ THESE ARE SERVER/DATABASE FUNCTIONS

code/item/list/armor.lua

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,15 @@ local armor = {}
22

33
--[[
44
full_name = 'insert name'
5-
durability = num (average # of attacks it takes to wear armor out)
6-
resistance = {
7-
condition = {protection=num},
8-
}
9-
10-
** As condition becomes worse armor starts to lose resistance (with the exception of a few armors)
5+
durability = 0 (all armor is one_use)
116
--]]
127

138
armor.leather = {}
149
armor.leather.full_name = 'leather jacket'
15-
armor.leather.durability = 32
16-
armor.leather.resistance = {
17-
[0] = {blunt=1},
18-
[1] = {blunt=1},
19-
[2] = {blunt=1},
20-
[3] = {blunt=1},
21-
}
10+
armor.leather.durability = 0
2211

2312
armor.firesuit = {}
2413
armor.firesuit.full_name = 'firesuit'
25-
armor.firesuit.durability = 4
26-
armor.firesuit.resistance = {
27-
[0] = {acid=1},
28-
[1] = {acid=2},
29-
[2] = {acid=3},
30-
[3] = {acid=4},
31-
}
14+
armor.firesuit.durability = 0
3215

3316
return armor

code/item/use/activate.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,16 @@ function activate.bottle(player, condition)
205205
player:updateHP(1)
206206
end
207207

208+
--[[
209+
--- ARMOR
210+
--]]
211+
212+
function activate.leather(player, condition)
213+
player.armor:equip('leather', condition)
214+
end
215+
216+
function activate.firesuit(player, condition)
217+
player.armor:equip('firesuit', condition)
218+
end
219+
208220
return activate

code/item/use/check.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,12 @@ function check.barricade(player)
103103
assert(playerInsideBuilding(player), 'Must be inside building to use barricade')
104104
end
105105

106+
--[[
107+
--- ARMOR
108+
--]]
109+
110+
function check.leather(player) end
111+
112+
function check.firesuit(player) end
113+
106114
return check

code/item/use/criteria.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,12 @@ function criteria.newspaper(player) end -- need light?
170170

171171
function criteria.bottle(player) end
172172

173+
--[[
174+
--- ARMOR
175+
--]]
176+
177+
function criteria.leather(player) end -- make sure there is inventory room when unequiping armor?
178+
179+
function criteria.firesuit(player) end
180+
173181
return criteria

code/player/action/list.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ local action_list = {
6565
antidote = {name='antidote', cost=1},
6666
antibodies= {name='antibodies', cost=1},
6767
syringe = {name='syringe', cost=1},
68+
leather = {name='leather', cost=1},
69+
firesuit = {name='firesuit', cost=1},
6870
},
6971
equipment = {
7072
broadcast = {cost=3, modifier={tech = -1, radio_tech = -1},},

code/player/action/zone.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ function setupZone.syringe(player, inv_ID, target)
7979
zone.target = target
8080
end
8181

82+
function setupZone.leather(player, inv_ID)
83+
zone.type = 'self'
84+
end
85+
8286
---------------------------------------
8387
---------------------------------------
8488
-- ZOMBIE --

code/player/armor/class.lua

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local dice = require('code.libs.dice')
2+
local item_armor_list = require('code.player.armor.item_list')
23
local class = require('code.libs.middleclass')
34

45
local armor = class('armor')
@@ -7,10 +8,29 @@ function armor:initialize(player)
78
self.player = player
89
end
910

10-
function armor:failDurabilityCheck(degrade_chance) return dice.roll(self.durability) <= degrade_chance end
11+
-- 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
12+
-- down the code in this file quite a bit, no need to differenate between human/zombie mobtypes
1113

12-
function armor:getProtection(damage_type) return self.protection[damage_type] or 0 end
14+
function armor:failDurabilityCheck(degrade_chance)
15+
local player, protection = self.player
16+
17+
if player:isMobType('human') then return dice.roll(item_armor_list[self.name].durability) <= degrade_chance
18+
elseif player:isMobType('zombie') then return dice.roll(self.durability) <= degrade_chance
19+
end
20+
end
1321

14-
function armor:isPresent() return self.protection and true or false end
22+
function armor:getProtection(damage_type)
23+
local player, protection = self.player
24+
25+
if player:isMobType('human') then return item_armor_list[self.name].resistance[self.condition][damage_type] or 0
26+
elseif player:isMobType('zombie') then return self.protection[damage_type] or 0
27+
end
28+
end
29+
30+
function armor:isPresent()
31+
if player:isMobType('human') then return self.name and true or false
32+
elseif player:isMobType('zombie') then return self.protection and true or false
33+
end
34+
end
1535

1636
return armor

code/player/armor/item_class.lua

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
local class = require('code.libs.middleclass')
1+
local class = require('code.libs.middleclass')
22
local item_armor_list = require('code.item.list.armor')
3-
local armor = require('code.player.armor.class')
3+
local item = require('code.item.class')
4+
local armor = require('code.player.armor.class')
45

56
local item_armor = class('item_armor', armor)
67

78
function item_armor:initialize(player)
89
armor.initialize(self, player)
910
end
1011

11-
function item_armor:equip(name, condition, inv_ID)
12-
self.protection = item_armor_list[name].resistance[condition]
13-
self.name, self.inv_ID, self.condition = name, inv_ID, condition
14-
self.durability = item_armor_list[name].durability
12+
function item_armor:equip(name, condition)
13+
if self:isPresent() then self:remove() end -- unequips the old armor and puts it back into the inventory
14+
self.name, self.condition = name, condition
1515
end
1616

17-
function item_armor:degrade(player)
18-
local item_INST = player.inventory:lookup(self.inv_ID)
19-
item_INST:updateCondition(-1, player, self.inv_ID)
17+
function item_armor:remove()
18+
local player, armor_type, condition = self.player, self.name, self.condition
19+
local armor_INST = item[armor_type]:new(condition)
2020

21+
player.inventory:insert(armor_INST)
22+
self.name, self.condition = nil, nil
23+
end
24+
25+
function item_armor:degrade(player)
2126
self.condition = self.condition - 1
2227
if 0 > self.condition then -- armor is destroyed
23-
local player = self.player
24-
player.armor = item_armor:new(player)
28+
self.name, self.condition = nil, nil
2529
return -- something to tell that armor is destroyed?
2630
end
27-
self.protection = item_armor_list[self.name].resistance[self.condition]
2831
end
2932

3033
return item_armor

code/player/armor/item_list.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
local armor = {}
2+
3+
--[[
4+
full_name = 'insert name'
5+
durability = num (average # of attacks it takes to wear armor out)
6+
resistance = {
7+
condition = {protection=num},
8+
}
9+
10+
** As condition becomes worse armor starts to lose resistance (with the exception of a few armors)
11+
--]]
12+
13+
armor.leather = {}
14+
armor.leather.durability = 32
15+
armor.leather.resistance = {
16+
[1] = {blunt=1},
17+
[2] = {blunt=1},
18+
[3] = {blunt=1},
19+
[4] = {blunt=1},
20+
}
21+
22+
armor.firesuit = {}
23+
armor.firesuit.durability = 4
24+
armor.firesuit.resistance = {
25+
[1] = {acid=1},
26+
[2] = {acid=2},
27+
[3] = {acid=3},
28+
[4] = {acid=4},
29+
}
30+
31+
return armor

code/player/log/getMessage.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ function description.syringe(player, inv_ID, target, inject_success, target_weak
8888
end
8989
end
9090

91+
function description.leather(player, inv_ID)
92+
local armor_INST = player.inventory:lookup(inv_ID)
93+
msg[1] = 'You equip '..armor_INST:getClassName()..' armor.'
94+
end
95+
96+
function description.firesuit()
97+
local armor_INST = player.inventory:lookup(inv_ID)
98+
msg[1] = 'You equip '..armor_INST:getClassName()..' armor.'
99+
end
100+
91101
---------------------------------------
92102
---------------------------------------
93103
-- ZOMBIE --

main.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151

5252
local firesuit_INST = item.firesuit:new('ruined')
5353
alt_player.inventory:insert(firesuit_INST)
54-
alt_player.armor:equip('firesuit', firesuit_INST:getCondition(), #alt_player.inventory)
54+
alt_player.armor:equip('firesuit', firesuit_INST:getCondition())
5555

5656
--[[
5757
print('---------')

settings.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local settings = {
2-
_VERSION = 'ZomboTropolis v0.4.0',
2+
_VERSION = 'ZomboTropolis v0.4.1',
33
_AUTHOR = 'Timothy Torres',
44
_URL = 'https://github.com/timothymtorres/ZomboTropolis-Roguelike',
55
_DESCRIPTION = 'A zombie survival roguelike MMORPG.',

0 commit comments

Comments
 (0)