Refactors how armor works. It's now less of a dice roll, but still retains some randomness. This makes weaker armor worth using, and stronger armor not godlike.

Also fixes a bug with the auto shotgun causing runtimes.
This commit is contained in:
Neerti
2015-12-01 03:45:47 -05:00
parent dacc1c85be
commit 062a092cfe
7 changed files with 114 additions and 52 deletions

View File

@@ -78,20 +78,19 @@
//armour
var/blocked = L.run_armor_check(target_zone, "melee")
if(blocked >= 2)
if(blocked >= 100)
return
if(!L.apply_damage(30, BRUTE, target_zone, blocked, used_weapon=src))
return 0
//trap the victim in place
if(!blocked)
set_dir(L.dir)
can_buckle = 1
buckle_mob(L)
L << "<span class='danger'>The steel jaws of \the [src] bite into you, trapping you in place!</span>"
deployed = 0
can_buckle = initial(can_buckle)
set_dir(L.dir)
can_buckle = 1
buckle_mob(L)
L << "<span class='danger'>The steel jaws of \the [src] bite into you, trapping you in place!</span>"
deployed = 0
can_buckle = initial(can_buckle)
/obj/item/weapon/beartrap/Crossed(AM as mob|obj)
if(deployed && isliving(AM))

View File

@@ -351,6 +351,8 @@ This function restores all organs.
return organs_by_name[zone]
/mob/living/carbon/human/apply_damage(var/damage = 0, var/damagetype = BRUTE, var/def_zone = null, var/blocked = 0, var/sharp = 0, var/edge = 0, var/obj/used_weapon = null)
if(Debug2)
world.log << "## DEBUG: human/apply_damage() was called on [src], with [damage] damage, and an armor value of [blocked]."
//visible_message("Hit debug. [damage] | [damagetype] | [def_zone] | [blocked] | [sharp] | [used_weapon]")
@@ -366,7 +368,8 @@ This function restores all organs.
//Handle BRUTE and BURN damage
handle_suit_punctures(damagetype, damage, def_zone)
if(blocked >= 2) return 0
if(blocked >= 100)
return 0
var/obj/item/organ/external/organ = null
if(isorgan(def_zone))
@@ -377,7 +380,10 @@ This function restores all organs.
if(!organ) return 0
if(blocked)
damage = (damage/(blocked+1))
blocked = (100-blocked)/100
damage = (damage * blocked)
if(Debug2)
world.log << "## DEBUG: [src] was hit for [damage]."
switch(damagetype)
if(BRUTE)

View File

@@ -9,28 +9,34 @@
standard 0 if fail
*/
/mob/living/proc/apply_damage(var/damage = 0,var/damagetype = BRUTE, var/def_zone = null, var/blocked = 0, var/used_weapon = null, var/sharp = 0, var/edge = 0)
if(!damage || (blocked >= 2)) return 0
if(Debug2)
world.log << "## DEBUG: apply_damage() was called on [src], with [damage] damage, and an armor value of [blocked]."
if(!damage || (blocked >= 100))
return 0
blocked = (100-blocked)/100
switch(damagetype)
if(BRUTE)
adjustBruteLoss(damage/(blocked+1))
adjustBruteLoss(damage * blocked)
if(BURN)
if(COLD_RESISTANCE in mutations) damage = 0
adjustFireLoss(damage/(blocked+1))
if(COLD_RESISTANCE in mutations)
damage = 0
adjustFireLoss(damage * blocked)
if(TOX)
adjustToxLoss(damage/(blocked+1))
adjustToxLoss(damage * blocked)
if(OXY)
adjustOxyLoss(damage/(blocked+1))
adjustOxyLoss(damage * blocked)
if(CLONE)
adjustCloneLoss(damage/(blocked+1))
adjustCloneLoss(damage * blocked)
if(HALLOSS)
adjustHalLoss(damage/(blocked+1))
adjustHalLoss(damage * blocked)
flash_weak_pain()
updatehealth()
return 1
/mob/living/proc/apply_damages(var/brute = 0, var/burn = 0, var/tox = 0, var/oxy = 0, var/clone = 0, var/halloss = 0, var/def_zone = null, var/blocked = 0)
if(blocked >= 2) return 0
if(blocked >= 100)
return 0
if(brute) apply_damage(brute, BRUTE, def_zone, blocked)
if(burn) apply_damage(burn, BURN, def_zone, blocked)
if(tox) apply_damage(tox, TOX, def_zone, blocked)
@@ -42,32 +48,43 @@
/mob/living/proc/apply_effect(var/effect = 0,var/effecttype = STUN, var/blocked = 0, var/check_protection = 1)
if(!effect || (blocked >= 2)) return 0
if(Debug2)
world.log << "## DEBUG: apply_effect() was called. The type of effect is [effecttype]. Blocked by [blocked]."
if(!effect || (blocked >= 100))
return 0
blocked = (100-blocked)/100
switch(effecttype)
if(STUN)
Stun(effect/(blocked+1))
Stun(effect * blocked)
if(WEAKEN)
Weaken(effect/(blocked+1))
Weaken(effect * blocked)
if(PARALYZE)
Paralyse(effect/(blocked+1))
Paralyse(effect * blocked)
if(AGONY)
halloss += effect // Useful for objects that cause "subdual" damage. PAIN!
halloss += max((effect * blocked), 0) // Useful for objects that cause "subdual" damage. PAIN!
if(IRRADIATE)
/*
var/rad_protection = check_protection ? getarmor(null, "rad")/100 : 0
radiation += max((1-rad_protection)*effect/(blocked+1),0)//Rads auto check armor
*/
var/rad_protection = getarmor(null, "rad")
rad_protection = (100-rad_protection)/100
radiation += max((effect * rad_protection), 0)
if(STUTTER)
if(status_flags & CANSTUN) // stun is usually associated with stutter
stuttering = max(stuttering,(effect/(blocked+1)))
stuttering = max(stuttering,(effect * blocked))
if(EYE_BLUR)
eye_blurry = max(eye_blurry,(effect/(blocked+1)))
eye_blurry = max(eye_blurry,(effect * blocked))
if(DROWSY)
drowsyness = max(drowsyness,(effect/(blocked+1)))
drowsyness = max(drowsyness,(effect * blocked))
updatehealth()
return 1
/mob/living/proc/apply_effects(var/stun = 0, var/weaken = 0, var/paralyze = 0, var/irradiate = 0, var/stutter = 0, var/eyeblur = 0, var/drowsy = 0, var/agony = 0, var/blocked = 0)
if(blocked >= 2) return 0
if(blocked >= 100)
return 0
if(stun) apply_effect(stun, STUN, blocked)
if(weaken) apply_effect(weaken, WEAKEN, blocked)
if(paralyze) apply_effect(paralyze, PARALYZE, blocked)

View File

@@ -2,33 +2,66 @@
/*
run_armor_check(a,b)
args
a:def_zone - What part is getting hit, if null will check entire body
b:attack_flag - What type of attack, bullet, laser, energy, melee
a:def_zone - What part is getting hit, if null will check entire body
b:attack_flag - What type of attack, bullet, laser, energy, melee
c:armour_pen - How much armor to ignore.
d:absorb_text - Custom text to send to the player when the armor fully absorbs an attack.
e:soften_text - Similar to absorb_text, custom text to send to the player when some damage is reduced.
Returns
0 - no block
1 - halfblock
2 - fullblock
A number between 0 and 100, with higher numbers resulting in less damage taken.
*/
/mob/living/proc/run_armor_check(var/def_zone = null, var/attack_flag = "melee", var/armour_pen = 0, var/absorb_text = null, var/soften_text = null)
if(Debug2)
world.log << "## DEBUG: getarmor() was called."
if(armour_pen >= 100)
return 0 //might as well just skip the processing
var/armor = getarmor(def_zone, attack_flag)
if(armor)
var/armor_variance_range = round(armor * 0.25) //Armor's effectiveness has a +25%/-25% variance.
var/armor_variance = rand(-armor_variance_range, armor_variance_range) //Get a random number between -25% and +25% of the armor's base value
if(Debug2)
world.log << "## DEBUG: The range of armor variance is [armor_variance_range]. The variance picked by RNG is [armor_variance]."
armor = min(armor + armor_variance, 100) //Now we calcuate damage using the new armor percentage.
armor = max(armor - armour_pen, 0) //Armor pen makes armor less effective.
if(armor >= 100)
if(absorb_text)
src << "<span class='danger'>[absorb_text]</span>"
else
src << "<span class='danger'>Your armor absorbs the blow!</span>"
else if(armor > 0)
if(soften_text)
src << "<span class='danger'>[soften_text]</span>"
else
src << "<span class='danger'>Your armor softens the blow!</span>"
if(Debug2)
world.log << "## DEBUG: Armor when [src] was attacked was [armor]."
return armor
/*
//Old armor code here.
if(armour_pen >= 100)
return 0 //might as well just skip the processing
var/armor = getarmor(def_zone, attack_flag)
var/absorb = 0
//Roll armour
if(prob(armor))
absorb += 1
if(prob(armor))
absorb += 1
//Roll penetration
if(prob(armour_pen))
absorb -= 1
if(prob(armour_pen))
absorb -= 1
if(absorb >= 2)
if(absorb_text)
show_message("[absorb_text]")
@@ -42,7 +75,7 @@
show_message("<span class='warning'>Your armor softens the blow!</span>")
return 1
return 0
*/
//if null is passed for def_zone, then this should return something appropriate for all zones (e.g. area effect damage)
/mob/living/proc/getarmor(var/def_zone, var/type)
@@ -85,7 +118,15 @@
if(!P.nodamage)
apply_damage(P.damage, P.damage_type, def_zone, absorb, 0, P, sharp=proj_sharp, edge=proj_edge)
P.on_hit(src, absorb, def_zone)
return absorb
if(absorb == 100)
return 2
else if (absorb >= 0)
return 1
else
return 0
// return absorb
//Handles the effects of "stun" weapons
/mob/living/proc/stun_effect_act(var/stun_amount, var/agony_amount, var/def_zone, var/used_weapon=null)
@@ -130,8 +171,7 @@
src.visible_message("\red [src] has been hit by [O].")
var/armor = run_armor_check(null, "melee")
if(armor < 2)
apply_damage(throw_damage, dtype, null, armor, is_sharp(O), has_edge(O), O)
apply_damage(throw_damage, dtype, null, armor, is_sharp(O), has_edge(O), O)
O.throwing = 0 //it hit, so stop moving
@@ -262,7 +302,7 @@
return 0
//Scale quadratically so that single digit numbers of fire stacks don't burn ridiculously hot.
//lower limit of 700 K, same as matches and roughly the temperature of a cool flame.
//lower limit of 700 K, same as matches and roughly the temperature of a cool flame.
return max(2.25*round(FIRESUIT_MAX_HEAT_PROTECTION_TEMPERATURE*(fire_stacks/FIRE_MAX_FIRESUIT_STACKS)**2), 700)
/mob/living/proc/reagent_permeability()

View File

@@ -52,7 +52,7 @@
attacker.visible_message("<span class='danger'>[attacker] [pick("bent", "twisted")] [target]'s [organ.name] into a jointlock!</span>")
var/armor = target.run_armor_check(target, "melee")
if(armor < 2)
if(armor < 60)
target << "<span class='danger'>You feel extreme pain!</span>"
affecting.adjustHalLoss(Clamp(0, 60-affecting.halloss, 30)) //up to 60 halloss

View File

@@ -242,8 +242,8 @@
firemodes = list(
list(mode_name="semiauto", burst=1, fire_delay=0),
list(mode_name="3-round bursts", burst=3, move_delay=6, accuracy = list(0,-1,-1,-2,-2), dispersion = list(0.0, 0.6, 0.6)),
// list(mode_name="6-round bursts", burst=6, move_delay=6, accuracy = list(0,-1,-1,-2,-2), dispersion = list(0.6, 1.0, 1.0, 1.0, 1.2, 1.2)),
list(mode_name="3-round bursts", burst=3, move_delay=6, burst_accuracy = list(0,-1,-1,-2,-2), dispersion = list(0.0, 0.6, 0.6)),
// list(mode_name="6-round bursts", burst=6, move_delay=6, burst_accuracy = list(0,-1,-1,-2,-2), dispersion = list(0.6, 1.0, 1.0, 1.0, 1.2, 1.2)),
)
/obj/item/weapon/gun/projectile/automatic/as24/update_icon()

View File

@@ -70,7 +70,7 @@
//TODO: make it so this is called more reliably, instead of sometimes by bullet_act() and sometimes not
/obj/item/projectile/proc/on_hit(var/atom/target, var/blocked = 0, var/def_zone = null)
if(blocked >= 2) return 0//Full block
if(blocked >= 100) return 0//Full block
if(!isliving(target)) return 0
if(isanimal(target)) return 0
var/mob/living/L = target
@@ -144,19 +144,19 @@
on_impact(user)
qdel(src)
return 0
loc = get_turf(user) //move the projectile out into the world
firer = user
shot_from = launcher.name
silenced = launcher.silenced
return launch(target, target_zone, x_offset, y_offset)
//Used to change the direction of the projectile in flight.
/obj/item/projectile/proc/redirect(var/new_x, var/new_y, var/atom/starting_loc, var/mob/new_firer=null)
var/turf/new_target = locate(new_x, new_y, src.z)
original = new_target
if(new_firer)
firer = src
@@ -402,9 +402,9 @@
var/turf/targloc = get_turf(target)
if(!curloc || !targloc)
return 0
original = target
//plot the initial trajectory
setup_trajectory(curloc, targloc)
return process(targloc)
@@ -438,7 +438,7 @@
//Set the flags and pass flags to that of the real projectile...
if(!isnull(flags))
trace.flags = flags
trace.flags = flags
trace.pass_flags = pass_flags
var/output = trace.launch(target) //Test it!