Skip to content

Commit 9676ba6

Browse files
Merge pull request #4 from timothymtorres/condense-skills-and-classes
Remove medical and sentient classes
2 parents 5be401b + 275f9dc commit 9676ba6

File tree

11 files changed

+181
-238
lines changed

11 files changed

+181
-238
lines changed

code/item/list/gadget.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ gadget.radio.durability = 100
1616
gadget.GPS = {} -- GPS for humans should have a small chance to grant a free AP for movement
1717
gadget.GPS.full_name = 'global position system'
1818
gadget.GPS.weight = 2
19-
gadget.GPS.durability = 300
19+
gadget.GPS.durability = 50
2020

2121
--[[
2222
gadget.cellphone = {}
@@ -33,11 +33,13 @@ gadget.loudspeaker = {}
3333
gadget.loudspeaker.full_name = 'loudspeaker'
3434
gadget.loudspeaker.weight = 1
3535
36-
--used for searching? give search bonus?!
36+
--]]
37+
3738
gadget.flashlight = {}
3839
gadget.flashlight.full_name = 'flashlight'
3940
gadget.flashlight.weight = 4
40-
--]]
41+
gadget.flashlight.durability = 100
42+
4143

4244
for item in pairs(gadget) do gadget[item].class_category = 'research' end
4345

code/item/list/medical.lua

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@ local medical = {}
1212
medical.FAK = {}
1313
medical.FAK.full_name = 'first aid kit'
1414
medical.FAK.weight = 8
15-
medical.FAK.class_category = 'medical'
1615

1716
medical.bandage = {}
1817
medical.bandage.full_name = 'bandage'
1918
medical.bandage.weight = 3
20-
medical.bandage.class_category = 'medical'
21-
22-
medical.antidote = {}
23-
medical.antidote.full_name = 'vial of antidote'
24-
medical.antidote.weight = 1
25-
medical.antidote.class_category = 'medical'
2619

2720
medical.syringe = {}
28-
medical.syringe.full_name = 'revival syringe'
21+
medical.syringe.full_name = 'syringe'
2922
medical.syringe.weight = 5
30-
medical.syringe.designated_weapon = true
31-
medical.syringe.class_category = 'research'
3223

3324
for item in pairs(medical) do
3425
medical[item].one_use = true
26+
medical[item].class_category = 'research'
3527
end
3628

3729
return medical

code/item/use/activate.lua

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local dice = require('code.libs.dice')
2-
local flags = require('code.player.skills.flags')
32
local medical = require('code.item.medical.class')
43

54
local activate = {}
@@ -12,38 +11,38 @@ function activate.FAK(player, condition, target)
1211
local FAK_dice = dice:new(medical.FAK:getDice())
1312
local tile = player:getTile()
1413

15-
if player.skills:check(flags.recovery) and tile:isBuilding() and tile:isPowered() and player:isStaged('inside') then
14+
if player.skills:check('healing') and tile:isBuilding() and tile:isPowered() and player:isStaged('inside') then
1615
FAK_dice = FAK_dice*1
1716
--print('powered confirmed')
1817
--print(tile:getClassName(), tile:getName(), tile:getTileType() )
19-
if player.skills:check(flags.major_healing) and tile:isClass('hospital') then
18+
if player.skills:check('major_healing') and tile:isClass('hospital') then
2019
FAK_dice = FAK_dice*1
2120
--print('hosptial confirmed')
2221
end
2322
end
2423

25-
if player.skills:check(flags.major_healing_adv) then
24+
if player.skills:check('major_healing') then
2625
FAK_dice = FAK_dice^1
2726
FAK_dice = FAK_dice..'^^'
28-
end
27+
end
2928

3029
local hp_gained = FAK_dice:roll()
3130
target:updateHP(hp_gained)
3231
-- target:event trigger
33-
print('You heal with '..FAK:getName()..' for '..hp_gained..' hp.')
32+
print('You heal with the first aid kit for '..hp_gained..' hp.')
3433
end
3534

3635
function activate.bandage(player, condition, target)
3736
local bandage_dice = dice:new(medical.bandage:getDice())
37+
local tile = player:getTile()
38+
39+
if tile:isBuilding() and tile:isPowered() and player:isStaged('inside') then bandage_dice = bandage_dice+1 end
3840

39-
if player.skills:check(flags.recovery) then
41+
if player.skills:check('healing') then
4042
bandage_dice = bandage_dice+1
41-
if player.skills:check(flags.minor_healing) then
42-
bandage_dice = bandage_dice+1
43-
if player.skills:check(flags.major_healing_adv) then
44-
bandage_dice = bandage_dice^1
45-
bandage_dice = bandage_dice+1
46-
end
43+
if player.skills:check('minor_healing') then
44+
bandage_dice = bandage_dice+1
45+
bandage_dice = bandage_dice^1
4746
end
4847
end
4948

@@ -53,29 +52,25 @@ function activate.bandage(player, condition, target)
5352
print('You heal with '..bandage:getName()..' for '..hp_gained..' hp.')
5453
end
5554

56-
function activate.antidote(player, condition, target)
57-
local antidote = medical.antidote
58-
local cure_chance = antidote:getAccuracy()
59-
-- modify chance based on skills?
60-
61-
local cure_success = cure_chance >= math.random()
62-
-- target:updateStatusEffects?
63-
-- target:event trigger
64-
if cure_success then
65-
print('You cure with the '..antidote:getName()..'.')
66-
else
67-
print('You fail to cure with the '..antidote:getName()..'.')
68-
end
69-
end
55+
local syringe_hp_ranges = {3, 6, 9, 12}
7056

7157
function activate.syringe(player, condition, target)
7258
local syringe = medical.syringe
7359
local inject_chance = syringe:getAccuracy()
74-
-- modify chance based on skills?
60+
if player.skills:check('syringe') then
61+
inject_chance = inject_chance + 0.05
62+
if player.skills:check("syringe_adv") then
63+
inject_chance = inject_chance + 0.05
64+
end
65+
end
7566

7667
local inject_success = inject_chance >= math.random()
77-
target:killed('syringe')
68+
local target_weak_enough = syringe_hp_ranges[condition] >= target:getStat('hp')
69+
70+
if inject_success and target_weak_enough then target:killed() end
7871
-- target:event trigger
72+
73+
return {inject_success, target_weak_enough}
7974
end
8075

8176
--[[
@@ -104,8 +99,15 @@ function activate.sampler(player, condition, target)
10499

105100
end
106101

107-
function activate.GPS(player, condition)
102+
local GPS_basic_chance, GPS_advanced_chance = 0.15, 0.20
108103

104+
function activate.GPS(player, condition)
105+
local GPS_chance = (player.skils:check('gadgets') and GPS_advanced_chance) or GPS_basic_chance
106+
local free_movement_success = GPS_chance >= math.random()
107+
if free_movement_success then -- the GPS has a chance to avoid wasting ap on movement
108+
player:updateStat('ap', 1) -- this is pretty much a hack (if a player's ap is 50 then they will NOT receive the ap)
109+
end
110+
return {free_movement_success}
109111
end
110112

111113
function activate.loudspeaker(player, condition, message)
@@ -158,8 +160,7 @@ local book_xp_dice = {'1d3', '1d5', '1d7', '1d10'}
158160
function activate.book(player, condition)
159161
local xp_dice_str = book_xp_dice[condition-1]
160162
local book_dice = dice:new(xp_dice_str)
161-
if player.skills:check(flags.bookworm) then book_dice = book_dice^1 end
162-
if player:isStaged('inside') and player:getSpotCondition() == 'powered' then book_dice = book_dice/2 end
163+
if player:isStaged('inside') and player:getSpotCondition() == 'powered' then book_dice = book_dice^1 end
163164
local gained_xp = book_dice:roll()
164165
player:updateXP(gained_xp)
165166
end

code/player/action/list.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ local action_list = {
7474
zombie = {
7575
default = {
7676
move = {name='move', cost=2, modifier={sprint = -1},},
77-
enter = {name='enter', cost= 1},
78-
exit = {name='exit', cost= 1},
77+
enter = {name='enter', cost=1},
78+
exit = {name='exit', cost=1},
7979
},
8080
basic = {
81-
respawn = {cost=10, modifier={resurrection = -5},},
82-
attack = {cost=1},
83-
speak = {cost=1},
84-
feed = {cost=1},
81+
respawn = {cost= 10, modifier={resurrection = -5},},
82+
attack = {cost= 1},
83+
speak = {cost= 1},
84+
feed = {cost= 1},
8585
},
8686
skill = {
8787
-- generic skills

code/player/action/outcome.lua

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
--[[
2-
local lookupItem = require('code.item.search')
3-
local lookupWeapon= require('code.item.weapon.search')
4-
--]]
51
local map = require('code.location.map.class')
62
local combat = require('code.player.combat')
73
local entangle = require('code.player.condition.entangle')
@@ -10,6 +6,8 @@ local equipmentActivate = require('code.location.building.equipment.operation.ac
106
local skillActivate = require('code.player.skills.activate')
117
local enzyme_list = require('code.player.enzyme_list')
128
local dice = require('code.libs.dice')
9+
local item = require('code.item.class')
10+
1311

1412
Outcome = {}
1513

@@ -39,6 +37,7 @@ function Outcome.move(player, dir)
3937
local y, x = player:getPos()
4038
local map = player:getMap()
4139
local dir_y, dir_x = getNewPos(y, x, dir)
40+
local GPS_usage
4241

4342
if player:isStaged('inside') then
4443
map[y][x]:remove(player, 'inside')
@@ -47,13 +46,20 @@ function Outcome.move(player, dir)
4746
else
4847
map[dir_y][dir_x]:insert(player, 'outside')
4948
end
50-
else
49+
else -- player is outside
50+
if player:isMobType('human') then
51+
local inventory_has_GPS, inv_ID = player.inventory:search('GPS')
52+
if inventory_has_GPS then
53+
GPS_usage = Outcome.item('GPS', player, inv_ID)
54+
end
55+
end
56+
5157
map[y][x]:remove(player)
5258
map[dir_y][dir_x]:insert(player)
5359
end
5460

5561
player:updatePos(dir_y, dir_x)
56-
return {dir}
62+
return {dir, GPS_usage}
5763
end
5864

5965
local ARMOR_DAMAGE_MOD = 2.5
@@ -63,8 +69,8 @@ function Outcome.attack(player, target, weapon, inv_ID)
6369
local attack, damage, critical = combat(player, target, weapon)
6470

6571
if attack then
66-
if target_class == 'player' then -- what about barricades? buildings? equipment?
67-
if target.armor:isPresent() then -- what if weapon is harmless?
72+
if target_class == 'player' then
73+
if target.armor:isPresent() and not weapon:isHarmless() then
6874
local damage_type = weapon:getDamageType()
6975
local resistance = target.armor:getProtection(damage_type)
7076
damage = damage - resistance
@@ -88,6 +94,9 @@ function Outcome.attack(player, target, weapon, inv_ID)
8894
if zombie.skills:check('track') then
8995
zombie.condition.tracking:addScent(human)
9096
end
97+
--elseif target_class == 'building' then
98+
--elseif target_class == 'barricade' then
99+
--elseif target_class == equipment?
91100
end
92101

93102
local hp_loss = -1*damage
@@ -208,8 +217,24 @@ function Outcome.item(item, player, inv_ID, target)
208217
local item_INST = player.inventory:lookup(inv_ID)
209218
local item_condition = item_INST:getCondition()
210219
local result = itemActivate[item](player, item_condition, target)
211-
if item_INST:isSingleUse() then player.inventory:remove(inv_ID) -- no need to do a durability check
212-
elseif item_INST:failDurabilityCheck(player) then item_INST:updateCondition(-1, player, inv_ID) end
220+
221+
if item_INST:isSingleUse() then -- no need for durability check
222+
if item_INST:getClassName() == 'syringe' then
223+
local inject_success, target_weak_enough = result[1], result[2]
224+
if inject_success then
225+
if target_weak_enough then -- the syringe will be discarded without creating a vaccine if the target is too strong
226+
local vaccine = item.vaccine:new('unpowered') -- should probably make unpowered/powered condition dependent on syringe skills
227+
player.inventory:insert(vaccine)
228+
end
229+
player.inventory:remove(inv_ID)
230+
--else the syringe is not removed from inventory since it didn't hit
231+
end
232+
else -- all other single use items get discarded
233+
player.inventory:remove(inv_ID)
234+
end
235+
elseif item_INST:failDurabilityCheck(player) then
236+
item_INST:updateCondition(-1, player, inv_ID)
237+
end
213238
return result
214239
end
215240

code/player/class.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ local condition = require('code.player.condition.class')
1212
local carcass = require('code.player.carcass')
1313
local organic_armor = require('code.player.armor.organic_class')
1414
local item_armor = require('code.player.armor.item_class')
15-
local flags = require('code.player.skills.flags')
1615
local weapon = require('code.item.weapon.class')
17-
--[[
18-
local lookupWeapon = require('code.item.weapon.search') -- refactored? (delete)
19-
local lookupItem = require('code.item.search') -- refactored? (delete)
20-
--]]
2116

2217
local player = class('player')
2318

@@ -54,7 +49,10 @@ function player:killed(cause_of_death)
5449
#1 - human killed (turns into zombie) [reset skills, xp, sp]
5550
#2 - zombie killed (decay) [delete]
5651
#3 - zombie killed (regular death) [nothing]
57-
--]]
52+
--]]
53+
54+
self.hp, self.health_state = 0, {basic=4, advanced=8} -- reset our hp stats to zero
55+
5856
if self:isMobType('human') then
5957
self.hp, self.health_state = 0, {basic=4, advanced=8}
6058
self:updateMobType('zombie')

code/player/inventory.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local item = require('code.item.class')
21
local class = require('code.libs.middleclass')
32

43
local inventory = class('code.player.inventory')
@@ -16,7 +15,7 @@ function inventory:initialize()
1615
self.radio_receivers = {}
1716
end
1817

19-
function inventory:insert(obj_INST) self[#self+1] = obj_INST end
18+
function inventory:insert(item_INST) self[#self+1] = item_INST end
2019

2120
function inventory:remove(inv_ID) table.remove(self, inv_ID) end
2221

@@ -29,6 +28,15 @@ function inventory:lookup(inv_ID) -- get itemClass_INST
2928
return self[inv_ID]
3029
end
3130

31+
function inventory:search(item_name)
32+
for inv_ID, item_INST in ipairs(self) do
33+
if item_INST:getClassName() == item_name then
34+
return true, inv_ID
35+
end
36+
end
37+
return false
38+
end
39+
3240
function inventory:catalog()
3341
local contents = {}
3442
for inv_ID=1, #self do contents[#contents + 1] = self[inv_ID] end

code/player/log/getMessage.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ end
2828
--]]--DIR/COMPASS LAYOUT
2929
local compass = {'North', 'NorthEast', 'East', 'SouthEast', 'South', 'SouthWest', 'West', 'NorthWest'}
3030

31-
function description.move(player, dir)
32-
msg[1] = 'You travel '..compass[dir]..'.'
31+
function description.move(player, dir, GPS_usage)
32+
if GPS_usage then
33+
msg[1] = 'You travel '..compass[dir]..' using a GPS.'
34+
else
35+
msg[1] = 'You travel '..compass[dir]..'.'
36+
end
3337
end
3438

3539
function description.search(player, item)

0 commit comments

Comments
 (0)