mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-28 14:37:27 +01:00
Refactors bottle smashing, apply_hit_effect() now returns the blocked status.
This commit is contained in:
@@ -235,7 +235,7 @@
|
||||
..()
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/snacks/grown/apply_hit_effect(mob/living/target, mob/living/user, var/hit_zone)
|
||||
..()
|
||||
. = ..()
|
||||
|
||||
if(seed && seed.get_trait(TRAIT_STINGS))
|
||||
if(!reagents || reagents.total_volume <= 0)
|
||||
|
||||
@@ -178,7 +178,7 @@ emp_act
|
||||
var/blocked = run_armor_check(hit_zone, "melee", I.armor_penetration, "Your armor has protected your [affecting.name].", "Your armor has softened the blow to your [affecting.name].")
|
||||
standard_weapon_hit_effects(I, user, effective_force, blocked, hit_zone)
|
||||
|
||||
return 1
|
||||
return blocked
|
||||
|
||||
/mob/living/carbon/human/standard_weapon_hit_effects(obj/item/I, mob/living/user, var/effective_force, var/blocked, var/hit_zone)
|
||||
var/obj/item/organ/external/affecting = get_organ(hit_zone)
|
||||
|
||||
@@ -33,7 +33,7 @@ var/const/MAX_ACTIVE_TIME = 400
|
||||
..()
|
||||
|
||||
/obj/item/clothing/mask/facehugger/apply_hit_effect(mob/living/target, mob/living/user, var/hit_zone)
|
||||
..()
|
||||
. = ..()
|
||||
user.drop_from_inventory(src)
|
||||
if(hit_zone == "head")
|
||||
Attach(target)
|
||||
|
||||
@@ -111,35 +111,10 @@
|
||||
O.emp_act(severity)
|
||||
..()
|
||||
|
||||
/*
|
||||
//Whereas attackby() handles the general case of using items on mobs, this handles the specific case of attacking a mob with an item as a weapon.
|
||||
/mob/living/proc/attacked_with_item(obj/item/I, mob/living/user, var/target_zone)
|
||||
if(!istype(user))
|
||||
return 0
|
||||
|
||||
/////////////////////////
|
||||
user.lastattacked = M
|
||||
M.lastattacker = user
|
||||
|
||||
if(!no_attack_log)
|
||||
user.attack_log += "\[[time_stamp()]\]<font color='red'> Attacked [M.name] ([M.ckey]) with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])</font>"
|
||||
M.attack_log += "\[[time_stamp()]\]<font color='orange'> Attacked by [user.name] ([user.ckey]) with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])</font>"
|
||||
msg_admin_attack("[key_name(user)] attacked [key_name(M)] with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])" )
|
||||
/////////////////////////
|
||||
|
||||
user.do_attack_animation(M)
|
||||
|
||||
var/hit_zone = resolve_hit_zone(I, user, target_zone)
|
||||
if(hit_zone)
|
||||
I.apply_hit_effect(src, user, hit_zone)
|
||||
|
||||
return 1
|
||||
*/
|
||||
|
||||
/mob/living/proc/resolve_item_attack(obj/item/I, mob/living/user, var/target_zone)
|
||||
return target_zone
|
||||
|
||||
//Called when the mob is hit with an item in combat.
|
||||
//Called when the mob is hit with an item in combat. Returns the blocked result
|
||||
/mob/living/proc/hit_with_weapon(obj/item/I, mob/living/user, var/effective_force, var/hit_zone)
|
||||
visible_message("<span class='danger'>[src] has been [I.attack_verb.len? pick(I.attack_verb) : "attacked"] with [I.name] by [user]!</span>")
|
||||
|
||||
@@ -150,6 +125,8 @@
|
||||
var/turf/simulated/location = get_turf(src)
|
||||
if(istype(location)) location.add_blood_floor(src)
|
||||
|
||||
return blocked
|
||||
|
||||
//returns 0 if the effects failed to apply for some reason, 1 otherwise.
|
||||
/mob/living/proc/standard_weapon_hit_effects(obj/item/I, mob/living/user, var/effective_force, var/blocked, var/hit_zone)
|
||||
if(!effective_force || blocked >= 2)
|
||||
|
||||
@@ -293,18 +293,21 @@
|
||||
|
||||
/mob/living/simple_animal/hit_with_weapon(obj/item/O, mob/living/user, var/effective_force, var/hit_zone)
|
||||
|
||||
if(O.force > resistance)
|
||||
var/damage = O.force
|
||||
if (O.damtype == HALLOSS)
|
||||
damage = 0
|
||||
if(supernatural && istype(O,/obj/item/weapon/nullrod))
|
||||
damage *= 2
|
||||
purge = 3
|
||||
adjustBruteLoss(damage)
|
||||
else
|
||||
user << "<span class='danger'>This weapon is ineffective, it does no damage.</span>"
|
||||
visible_message("<span class='danger'>\The [src] has been attacked with \the [O] by [user].</span>")
|
||||
|
||||
visible_message("<span class='danger'>\The [src] has been attacked with \the [O] by [user].</span>")
|
||||
if(O.force <= resistance)
|
||||
user << "<span class='danger'>This weapon is ineffective, it does no damage.</span>"
|
||||
return 2
|
||||
|
||||
var/damage = O.force
|
||||
if (O.damtype == HALLOSS)
|
||||
damage = 0
|
||||
if(supernatural && istype(O,/obj/item/weapon/nullrod))
|
||||
damage *= 2
|
||||
purge = 3
|
||||
adjustBruteLoss(damage)
|
||||
|
||||
return 0
|
||||
|
||||
/mob/living/simple_animal/movement_delay()
|
||||
var/tally = 0 //Incase I need to add stuff other than "speed" later
|
||||
|
||||
@@ -117,60 +117,34 @@
|
||||
else
|
||||
set_light(0)
|
||||
|
||||
/obj/item/weapon/reagent_containers/food/drinks/bottle/attack(mob/living/target as mob, mob/living/user as mob)
|
||||
if(!target)
|
||||
/obj/item/weapon/reagent_containers/food/drinks/bottle/apply_hit_effect(mob/living/target, mob/living/user, var/hit_zone)
|
||||
var/blocked = ..()
|
||||
|
||||
if(user.a_intent != I_HURT)
|
||||
return
|
||||
|
||||
if(user.a_intent != I_HURT || !isGlass)
|
||||
return ..()
|
||||
|
||||
var/obj/item/organ/external/affecting = user.zone_sel.selecting //Find what the player is aiming at
|
||||
|
||||
var/armor_block = 0 //Get the target's armour values for normal attack damage.
|
||||
var/armor_duration = 0 //The more force the bottle has, the longer the duration.
|
||||
|
||||
//Calculating duration and calculating damage.
|
||||
armor_block = target.run_armor_check(affecting, "melee")
|
||||
|
||||
//force will counteract armour, but will never increase duration
|
||||
armor_duration = smash_duration + min(0, force - target.getarmor(affecting, "melee") + 10)
|
||||
|
||||
//Apply the damage!
|
||||
target.apply_damage(force, BRUTE, affecting, armor_block, sharp=0)
|
||||
|
||||
if(!smash_check(1))
|
||||
return //won't always break on the first hit
|
||||
|
||||
// You are going to knock someone out for longer if they are not wearing a helmet.
|
||||
var/do_smash = smash_check(1) //won't always break on the first hit
|
||||
if(affecting == "head" && istype(target, /mob/living/carbon/) && do_smash)
|
||||
|
||||
//Display an attack message.
|
||||
for(var/mob/O in viewers(user, null))
|
||||
if(target != user) O.show_message(text("\red <B>[target] has been hit over the head with a bottle of [src.name], by [user]!</B>"), 1)
|
||||
else O.show_message(text("\red <B>[target] hit \himself with a bottle of [src.name] on the head!</B>"), 1)
|
||||
//Weaken the target for the duration that we calculated and divide it by 5.
|
||||
if(armor_duration)
|
||||
target.apply_effect(min(armor_duration, 5) , WEAKEN, armor_block) // Never weaken more than a flash!
|
||||
var/weaken_duration = 0
|
||||
if(blocked < 2)
|
||||
weaken_duration = smash_duration + min(0, force - target.getarmor(hit_zone, "melee") + 10)
|
||||
|
||||
if(hit_zone == "head" && istype(target, /mob/living/carbon/))
|
||||
user.visible_message("<span class='danger'>\The [user] smashes [src] over [target]'s head!</span>")
|
||||
if(weaken_duration)
|
||||
target.apply_effect(min(weaken_duration, 5), WEAKEN, blocked) // Never weaken more than a flash!
|
||||
else
|
||||
//Default attack message and don't weaken the target.
|
||||
for(var/mob/O in viewers(user, null))
|
||||
if(target != user) O.show_message(text("\red <B>[target] has been attacked with a bottle of [src.name], by [user]!</B>"), 1)
|
||||
else O.show_message(text("\red <B>[target] has attacked \himself with a bottle of [src.name]!</B>"), 1)
|
||||
user.visible_message("<span class='danger'>\The [user] smashes [src] into [target]!</span>")
|
||||
|
||||
//Attack logs
|
||||
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Has attacked [target.name] ([target.ckey]) with a bottle!</font>")
|
||||
target.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been smashed with a bottle by [user.name] ([user.ckey])</font>")
|
||||
msg_admin_attack("[user.name] ([user.ckey]) attacked [target.name] ([target.ckey]) with a bottle. (INTENT: [uppertext(user.a_intent)]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
|
||||
//The reagents in the bottle splash all over the target, thanks for the idea Nodrak
|
||||
if(reagents)
|
||||
user.visible_message("<span class='notice'>The contents of the [src] splash all over [target]!</span>")
|
||||
reagents.splash(target, reagents.total_volume)
|
||||
|
||||
if(do_smash)
|
||||
//The reagents in the bottle splash all over the target, thanks for the idea Nodrak
|
||||
if(reagents)
|
||||
user.visible_message("<span class='notice'>The contents of the [src] splash all over [target]!</span>")
|
||||
reagents.splash(target, reagents.total_volume)
|
||||
|
||||
//Finally, smash the bottle. This kills (qdel) the bottle.
|
||||
var/obj/item/weapon/broken_bottle/B = src.smash(target.loc, target)
|
||||
user.put_in_active_hand(B)
|
||||
|
||||
return
|
||||
//Finally, smash the bottle. This kills (qdel) the bottle.
|
||||
var/obj/item/weapon/broken_bottle/B = smash(target.loc, target)
|
||||
user.put_in_active_hand(B)
|
||||
|
||||
//Keeping this here for now, I'll ask if I should keep it here.
|
||||
/obj/item/weapon/broken_bottle
|
||||
|
||||
Reference in New Issue
Block a user