Skip to content

Commit

Permalink
Merged infection/poison features into one
Browse files Browse the repository at this point in the history
-Removed poison condition
-Changed infection to work differently.  Whenever a hive zombie bites
with infection skills, a human will be infected, causing the condition
to be dormant for a period of time and then once active deal continous
damage
  • Loading branch information
timothymtorres committed Jul 11, 2017
1 parent 561ed0b commit a18c73b
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 221 deletions.
35 changes: 7 additions & 28 deletions code/item/weapon/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ 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
elseif self:getClassName() == 'bite' and not player.skills:check('infection') then
return false -- if attacking with bite and missing infection skill then no condition effect
end

return (self.condition_effect and true) or false
end

Expand Down Expand Up @@ -96,7 +99,7 @@ local organic_modifier = {
},
bite = {
dice={'1d5+1', '1d5+2'},
included_skills={'bite', 'power_bite'},
included_skills={'bite', 'bite_adv'},
},
fist = {
dice={'1d2'},
Expand All @@ -123,9 +126,9 @@ function weapon:getDice(player, condition)
if skill_count > 0 then
local dice_str = organic_modifier.dice[skill_count]
weapon_dice = dice:new(dice_str)
end
end
end
-- else organic weapon has no modifier or player lacks all included skills then use weapons default dice
end
end

local mastered_skill = self:getMasterSkill()
Expand All @@ -139,18 +142,6 @@ function weapon:getDice(player, condition)
return tostring(weapon_dice)
end

local skill_effects = {
poison = {
order = {'venom_adv', 'venom', 'stinger'},
stinger = {duration = '1d2+2', amount='1d5+10'},
venom = {duration = '1d3+2', amount='1d7+15'},
venom_adv = {duration = '1d4+3', amount='1d10+20'},
},
entangle = {

}
}

function weapon:getConditionEffect(player) --, condition) maybe for later...?
local effect = self.condition_effect
local duration, bonus_effect
Expand All @@ -159,21 +150,9 @@ function weapon:getConditionEffect(player) --, condition) maybe for later...?
if effect == 'burn' then
duration = weapon:getFuelAmount()
bonus_effect = weapon:isCombustionSource()
elseif effect == 'decay' then

end
elseif player:isMobType('zombie') then
if effect == 'poison' then
for _, skill in ipairs(skill_effects.poison.order) do
if player.skills:check(skill) then
duration = skill_effects.poison[skill].duration
bonus_effect = skill_effects.poison[skill].amount
break
end
end
elseif effect == 'infection' then

elseif effect == 'entangle' then
if effect == 'entangle' then
if player.skills:check('impale') then bonus_effect = true end -- possible to impale on crit hit
end
end
Expand Down
19 changes: 3 additions & 16 deletions code/item/weapon/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ weapon.claw.critical = 0.05
weapon.claw.organic = 'zombie'
weapon.claw.object_damage = {barricade=1, door=1, equipment=1}
weapon.claw.condition_effect = 'entangle'
weapon.claw.master_skill = 'claw_adv'

weapon.bite = {}
weapon.bite.full_name = 'bite'
Expand All @@ -277,22 +278,8 @@ weapon.bite.dice = '1d4+1'
weapon.bite.accuracy = 0.20
weapon.bite.critical = 0.05
weapon.bite.organic = 'zombie'

--[[
--- PROJECTILE
--]]

weapon.sting = {}
weapon.sting.full_name = 'sting'
weapon.sting.attack_style = 'ranged'
weapon.sting.damage_type = 'bullet'
weapon.sting.group = {'stinger'}
weapon.sting.dice = '1d2'
weapon.sting.accuracy = 0.15
weapon.sting.critical = 0.05
weapon.sting.organic = 'zombie'
weapon.sting.condition_effect = 'poison'
weapon.sting.skill_required = 'stinger'
weapon.bite.condition_effect = 'infection'
weapon.bite.master_skill = 'bite_adv'

--[[
--- BURN
Expand Down
10 changes: 10 additions & 0 deletions code/player/action/outcome.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ function Outcome.attack(player, target, weapon, inv_ID)
if effect == 'entangle' then
local impale_bonus = bonus_effect and critical
entangle.add(player, target, impale_bonus)
elseif effect == 'infection' then
-- infection_adv skill makes bites auto infect, infection skill requires a zombie to be entagled with the target to infect with bite
if player.skills:check('infection_adv') or (player.skills:check('infection') and entangle.isTangledTogether(player, target)) then
if not target.condition.infection:isImmune() or target.condition.infection:isActive() then --target cannot be immune or infection already active
target.condition.infection:add()
--print('A zombie has infected the target')
-- should probably add an infection message to the ZOMBIE only! A human shouldn't be notfied immediately until damage is taken
-- also should probably look at refactoring the msg system for player.log to make this easier
end
end
else -- normal effect process
target.condition[effect]:add(duration, bonus_effect)
end
Expand Down
4 changes: 1 addition & 3 deletions code/player/condition/class.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local class = require('code.libs.middleclass')
local poison = require('code.player.condition.poison')
local infection = require('code.player.condition.infection')
local burn = require('code.player.condition.burn')
local decay = require('code.player.condition.decay')
Expand All @@ -14,7 +13,6 @@ local condition = class('condition')
function condition:initialize(player)
if player:isMobType('human') then
-- insert status conditions?
self.poison = poison:new()
self.infection = infection:new()
elseif player:isMobType('zombie') then
self.burn = burn:new()
Expand All @@ -30,7 +28,7 @@ function condition:isActive(effect)
end

local condition_list = {
human = {'poison', 'infection'},
human = {'infection'},
zombie = {'burn', 'decay'},
-- tracking:elapse() is used ONLY during server ticks, not during players actions
}
Expand Down
50 changes: 29 additions & 21 deletions code/player/condition/infection.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
local class = require('code.libs.middleclass')
local dice = require('code.libs.dice')

local infection = class('infection')

local MAX_TIME = 1023
local MAX_TIME = 511
local INCUBATION_DEFAULT = '1d1' --'1d80+20'
local INFECTION_DAMAGE_PER_TICK = -1

function infection:initialize()
self.time = 0
self.incubation_timer = 0
self.is_infected = false
end

function infection:add(amount, player)
self.time = math.max(self.time + amount, 0)
if self.time >= MAX_TIME then
player:killed('infection')
end
function infection:add()
print('Player has just been infected!')
self.incubation_timer = dice.roll(INCUBATION_DEFAULT)
self.is_infected = true
end

function infection:elapse(player, time)
self:add(time, player)
function infection:remove(player)
print('Player has been cured of infection!')
self.incubation_timer = 0
self.is_infected = false
end

function infection:getTime() return self.time end
function infection:addImmunity(time) self.incubation_timer = math.min(MAX_TIME, self.incubation_timer + time) end

function infection:isActive() return self.is_infected end

return infection
function infection:isImmune() return (self.is_infected and self.incubation_timer > 0) end

--[[
you have 0 infection = aka 21 days to live
you get attacked lose about 30 hp from bites
ie... make infection 1d2, 1d3, 1d4 from bites?
function infection:elapse(player, time)
if not self.is_infected then return end

if self.incubation_timer > 0 then
self.incubation_timer = math.max(self.incubation_timer - time, 0)
else -- infection is no longer dormant
player:updateStat('hp', INFECTION_DAMAGE_PER_TICK)
print('Player takes damage for infection!')
end
end

21 days
knockoff @ 60 hp (ie. 59 damage) should remove 5/7 days?
7x50 = 350
5x50 = 250
3x50 = 150
--]]
return infection
126 changes: 0 additions & 126 deletions code/player/condition/poison.lua

This file was deleted.

6 changes: 2 additions & 4 deletions code/player/skills/flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ local skill_flags = {
acid_adv = 32,
ruin = 64,
ransack = 128,
homewrecker = 256,
stinger = 512,
venom = 1024,
venom_adv = 2048,
infection = 256,
infection_adv = 512,
}

return skill_flags
Loading

0 comments on commit a18c73b

Please sign in to comment.