From 454348759da1cbae87426ec51b8829d74116e7e0 Mon Sep 17 00:00:00 2001 From: Ikarrus Date: Sun, 28 Jun 2015 18:19:11 -0600 Subject: [PATCH 1/6] Workplace "Accidents" - Slipping while carrying items in your hand may cause ~accidents~ - 30% chance to attack yourself - 30% chance to attack the floor - 30% chance to throw the item towards the direction you're facing - Throwing reagent containers such as drinks or beakers may spill their contents onto whatever they hit --- code/game/objects/items.dm | 27 ++++++++++++++++--- code/game/turfs/turf.dm | 21 +++++++++++---- .../drinks/drinks/drinkingglass.dm | 4 +++ code/modules/mob/living/carbon/carbon.dm | 20 ++++++++++++++ .../reagents/reagent_containers/glass.dm | 14 +++++++--- html/changelogs/ikarrus-workplacesafety.yml | 6 +++++ 6 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 html/changelogs/ikarrus-workplacesafety.yml diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 9c166718063..df8ca78d321 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -82,8 +82,8 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s var/flags_cover = 0 //for flags such as GLASSESCOVERSEYES -/obj/item/proc/check_allowed_items(atom/target, not_inside) - if((src in target) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into)) +/obj/item/proc/check_allowed_items(atom/target, not_inside, hitting_themselves) + if(((src in target) && !hitting_themselves) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into)) return 0 else return 1 @@ -493,4 +493,25 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s var/obj/item/weapon/storage/S = loc S.remove_from_storage(src,newLoc) return 1 - return 0 \ No newline at end of file + return 0 + +/obj/item/proc/impact_reagent(atom/target) + if(!reagents.total_volume || prob(5)) //Small chance it doesn't spill! + return + + if(ismob(target) && target.reagents) + var/mob/M = target + var/R + target.visible_message("[M] has been splashed with something!", \ + "[M] has been splashed with something!") + if(reagents) + for(var/datum/reagent/A in reagents.reagent_list) + R += A.id + " (" + R += num2text(A.volume) + ")," + + var/mob/thrower = directory[ckey(src.fingerprintslast)] + add_logs(thrower, M, "splashed", object="[R]") + reagents.reaction(target, TOUCH) + else + reagents.reaction(target, TOUCH) + reagents.clear_reagents() \ No newline at end of file diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 71d40ca2dd4..75d97cf7122 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -228,6 +228,19 @@ if (M.m_intent=="walk" && (lube&NO_SLIP_WHEN_WALKING)) return 0 if(!M.lying && (M.status_flags & CANWEAKEN)) // we slip those who are standing and can fall. + if(O) + M << "You slipped on the [O.name]!" + else + M << "You slipped!" + playsound(M.loc, 'sound/misc/slip.ogg', 50, 1, -3) + + var/active_hand = M.hand + M.hand = 1 + M.accident(M.l_hand) + M.hand = 0 + M.accident(M.r_hand) + M.hand = active_hand + var/olddir = M.dir M.Stun(s_amount) M.Weaken(w_amount) @@ -239,11 +252,9 @@ M.spin(1,1) if(M.lying) //did I fall over? M.adjustBruteLoss(2) - if(O) - M << "You slipped on the [O.name]!" - else - M << "You slipped!" - playsound(M.loc, 'sound/misc/slip.ogg', 50, 1, -3) + + + return 1 return 0 // no success. Used in clown pda and wet floors diff --git a/code/modules/food&drinks/drinks/drinks/drinkingglass.dm b/code/modules/food&drinks/drinks/drinks/drinkingglass.dm index d145ef39fb3..1774d5b5d6a 100644 --- a/code/modules/food&drinks/drinks/drinks/drinkingglass.dm +++ b/code/modules/food&drinks/drinks/drinks/drinkingglass.dm @@ -9,6 +9,10 @@ burn_state = 0 //Burnable burntime = 5 +/obj/item/weapon/reagent_containers/food/drinks/drinkingglass/throw_impact(atom/target) + ..() + impact_reagent(target) + /obj/item/weapon/reagent_containers/food/drinks/drinkingglass/fire_act() if(!reagents.total_volume) return diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 937d13e4ec4..5e7c1dc495d 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -507,3 +507,23 @@ var/const/GALOSHES_DONT_HELP = 8 /mob/living/carbon/check_ear_prot() if(head && (head.flags & HEADBANGPROTECT)) return 1 + +/mob/living/carbon/proc/accident(var/obj/item/Item) + if(!Item) + return + + switch(rand(1,100)) //Nothing special happens 91-100 + if(1 to 30) //attack yourself + src.Click() + if(31 to 60) //attack your turf/loc + var/turf/target = get_turf(loc) + target.Click() + if(61 to 90) //Throw object in facing direction + var/turf/target = get_turf(loc) + var/range = rand(2,5) + for(var/i = 1; i < range; i++) + var/turf/new_turf = get_step(target, src.dir) + target = new_turf + if(new_turf.density) + break + throw_item(target) \ No newline at end of file diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index b8f188c3ba5..132bb37c2b3 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -31,16 +31,22 @@ /mob/living/simple_animal/hostile/retaliate/goat ) - +/obj/item/weapon/reagent_containers/glass/throw_impact(atom/target) + ..() + impact_reagent(target) /obj/item/weapon/reagent_containers/glass/afterattack(obj/target, mob/user, proximity) - if((!proximity) || !check_allowed_items(target)) return + if((!proximity) || !check_allowed_items(target,hitting_themselves=1)) return if(ismob(target) && target.reagents && reagents.total_volume) var/mob/M = target var/R - target.visible_message("[user] has splashed [target] with something!", \ - "[user] has splashed [target] with something!") + if(user==target) + target.visible_message("[user] splashes himself with something!", \ + "[user] splashes himself with something!") + else + target.visible_message("[user] has splashed [target] with something!", \ + "[user] has splashed [target] with something!") if(reagents) for(var/datum/reagent/A in reagents.reagent_list) R += A.id + " (" diff --git a/html/changelogs/ikarrus-workplacesafety.yml b/html/changelogs/ikarrus-workplacesafety.yml new file mode 100644 index 00000000000..bace06864d8 --- /dev/null +++ b/html/changelogs/ikarrus-workplacesafety.yml @@ -0,0 +1,6 @@ +author: Ikarrus +delete-after: True + +changes: + - rscadd: "Throwing reagent containers such as drinks or beakers may spill their contents onto whatever they hit" + - rscadd: "Slipping while carrying items in your hand may cause ~accidents~" \ No newline at end of file From 8c1fde7947351f81b19ac320327b1ee94769afc3 Mon Sep 17 00:00:00 2001 From: Ikarrus Date: Sun, 28 Jun 2015 18:21:08 -0600 Subject: [PATCH 2/6] Squashed Commits --- code/game/objects/items.dm | 27 ++---------------- code/game/turfs/turf.dm | 5 +--- .../drinks/drinks/drinkingglass.dm | 5 +--- code/modules/mob/living/carbon/carbon.dm | 28 ++++++++++++------- code/modules/reagents/reagent_containers.dm | 25 ++++++++++++++++- .../reagents/reagent_containers/glass.dm | 14 +++------- 6 files changed, 51 insertions(+), 53 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index df8ca78d321..9c166718063 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -82,8 +82,8 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s var/flags_cover = 0 //for flags such as GLASSESCOVERSEYES -/obj/item/proc/check_allowed_items(atom/target, not_inside, hitting_themselves) - if(((src in target) && !hitting_themselves) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into)) +/obj/item/proc/check_allowed_items(atom/target, not_inside) + if((src in target) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into)) return 0 else return 1 @@ -493,25 +493,4 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s var/obj/item/weapon/storage/S = loc S.remove_from_storage(src,newLoc) return 1 - return 0 - -/obj/item/proc/impact_reagent(atom/target) - if(!reagents.total_volume || prob(5)) //Small chance it doesn't spill! - return - - if(ismob(target) && target.reagents) - var/mob/M = target - var/R - target.visible_message("[M] has been splashed with something!", \ - "[M] has been splashed with something!") - if(reagents) - for(var/datum/reagent/A in reagents.reagent_list) - R += A.id + " (" - R += num2text(A.volume) + ")," - - var/mob/thrower = directory[ckey(src.fingerprintslast)] - add_logs(thrower, M, "splashed", object="[R]") - reagents.reaction(target, TOUCH) - else - reagents.reaction(target, TOUCH) - reagents.clear_reagents() \ No newline at end of file + return 0 \ No newline at end of file diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 75d97cf7122..79114808580 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -232,14 +232,11 @@ M << "You slipped on the [O.name]!" else M << "You slipped!" + M.attack_log += "\[[time_stamp()]\] Slipped[O ? " on the [O.name]" : ""][(lube&SLIDE)? " (LUBE)" : ""]!" playsound(M.loc, 'sound/misc/slip.ogg', 50, 1, -3) - var/active_hand = M.hand - M.hand = 1 M.accident(M.l_hand) - M.hand = 0 M.accident(M.r_hand) - M.hand = active_hand var/olddir = M.dir M.Stun(s_amount) diff --git a/code/modules/food&drinks/drinks/drinks/drinkingglass.dm b/code/modules/food&drinks/drinks/drinks/drinkingglass.dm index 1774d5b5d6a..33ae82d0310 100644 --- a/code/modules/food&drinks/drinks/drinks/drinkingglass.dm +++ b/code/modules/food&drinks/drinks/drinks/drinkingglass.dm @@ -8,10 +8,7 @@ volume = 50 burn_state = 0 //Burnable burntime = 5 - -/obj/item/weapon/reagent_containers/food/drinks/drinkingglass/throw_impact(atom/target) - ..() - impact_reagent(target) + flags = OPENCONTAINER /obj/item/weapon/reagent_containers/food/drinks/drinkingglass/fire_act() if(!reagents.total_volume) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 5e7c1dc495d..cc64b74b399 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -508,22 +508,30 @@ var/const/GALOSHES_DONT_HELP = 8 if(head && (head.flags & HEADBANGPROTECT)) return 1 -/mob/living/carbon/proc/accident(var/obj/item/Item) - if(!Item) +/mob/living/carbon/proc/accident(var/obj/item/I) + if(!I || (I.flags & NODROP)) return - switch(rand(1,100)) //Nothing special happens 91-100 - if(1 to 30) //attack yourself - src.Click() - if(31 to 60) //attack your turf/loc + unEquip(I) + + var/modifier = 0 + if(disabilities & CLUMSY) + modifier -= 30 //Clumsy people are more likely to hit themselves -Honk! + + switch(rand(1,100)+modifier) //91-100=Nothing special happens + if(-INFINITY to 0) //attack yourself + I.attack(src,src) + if(1 to 30) //throw it at yourself + I.throw_impact(src) + if(31 to 60) //throw it down to the floor var/turf/target = get_turf(loc) - target.Click() + I.throw_at(target,I.throw_range,I.throw_speed) if(61 to 90) //Throw object in facing direction var/turf/target = get_turf(loc) - var/range = rand(2,5) + var/range = rand(2,I.throw_range) for(var/i = 1; i < range; i++) - var/turf/new_turf = get_step(target, src.dir) + var/turf/new_turf = get_step(target, dir) target = new_turf if(new_turf.density) break - throw_item(target) \ No newline at end of file + I.throw_at(target,I.throw_range,I.throw_speed) \ No newline at end of file diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index c3108ddeb0c..d3717ae0c24 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -76,4 +76,27 @@ /obj/item/weapon/reagent_containers/fire_act() reagents.chem_temp += 30 reagents.handle_reactions() - ..() \ No newline at end of file + ..() + +/obj/item/weapon/reagent_containers/throw_impact(atom/target) + ..() + + if(!reagents.total_volume || !is_open_container()) + return + + if(ismob(target) && target.reagents) + var/mob/M = target + var/R + target.visible_message("[M] has been splashed with something!", \ + "[M] has been splashed with something!") + if(reagents) + for(var/datum/reagent/A in reagents.reagent_list) + R += A.id + " (" + R += num2text(A.volume) + ")," + + var/client/thrower = directory[ckey(src.fingerprintslast)] + add_logs(thrower.mob, M, "splashed", object="[R]") + reagents.reaction(target, TOUCH) + else + reagents.reaction(target, TOUCH) + reagents.clear_reagents() diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index 132bb37c2b3..b8f188c3ba5 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -31,22 +31,16 @@ /mob/living/simple_animal/hostile/retaliate/goat ) -/obj/item/weapon/reagent_containers/glass/throw_impact(atom/target) - ..() - impact_reagent(target) + /obj/item/weapon/reagent_containers/glass/afterattack(obj/target, mob/user, proximity) - if((!proximity) || !check_allowed_items(target,hitting_themselves=1)) return + if((!proximity) || !check_allowed_items(target)) return if(ismob(target) && target.reagents && reagents.total_volume) var/mob/M = target var/R - if(user==target) - target.visible_message("[user] splashes himself with something!", \ - "[user] splashes himself with something!") - else - target.visible_message("[user] has splashed [target] with something!", \ - "[user] has splashed [target] with something!") + target.visible_message("[user] has splashed [target] with something!", \ + "[user] has splashed [target] with something!") if(reagents) for(var/datum/reagent/A in reagents.reagent_list) R += A.id + " (" From 5792e7ccd9ba67050fa2d957a63fb147224e9bb9 Mon Sep 17 00:00:00 2001 From: Ikarrus Date: Mon, 29 Jun 2015 19:29:12 -0600 Subject: [PATCH 3/6] - Swaps floor throwing and distance throwing - Reagent containers thrown by bartenders will never spill if it doesn't collide into anything --- .../food&drinks/drinks/drinks/drinkingglass.dm | 1 - code/modules/mob/living/carbon/carbon.dm | 10 +++++----- code/modules/reagents/reagent_containers.dm | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/code/modules/food&drinks/drinks/drinks/drinkingglass.dm b/code/modules/food&drinks/drinks/drinks/drinkingglass.dm index 33ae82d0310..d145ef39fb3 100644 --- a/code/modules/food&drinks/drinks/drinks/drinkingglass.dm +++ b/code/modules/food&drinks/drinks/drinks/drinkingglass.dm @@ -8,7 +8,6 @@ volume = 50 burn_state = 0 //Burnable burntime = 5 - flags = OPENCONTAINER /obj/item/weapon/reagent_containers/food/drinks/drinkingglass/fire_act() if(!reagents.total_volume) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index cc64b74b399..5ff331cb104 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -516,17 +516,14 @@ var/const/GALOSHES_DONT_HELP = 8 var/modifier = 0 if(disabilities & CLUMSY) - modifier -= 30 //Clumsy people are more likely to hit themselves -Honk! + modifier -= 40 //Clumsy people are more likely to hit themselves -Honk! switch(rand(1,100)+modifier) //91-100=Nothing special happens if(-INFINITY to 0) //attack yourself I.attack(src,src) if(1 to 30) //throw it at yourself I.throw_impact(src) - if(31 to 60) //throw it down to the floor - var/turf/target = get_turf(loc) - I.throw_at(target,I.throw_range,I.throw_speed) - if(61 to 90) //Throw object in facing direction + if(31 to 60) //Throw object in facing direction var/turf/target = get_turf(loc) var/range = rand(2,I.throw_range) for(var/i = 1; i < range; i++) @@ -534,4 +531,7 @@ var/const/GALOSHES_DONT_HELP = 8 target = new_turf if(new_turf.density) break + I.throw_at(target,I.throw_range,I.throw_speed) + if(61 to 90) //throw it down to the floor + var/turf/target = get_turf(loc) I.throw_at(target,I.throw_range,I.throw_speed) \ No newline at end of file diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index d3717ae0c24..c79142c6a32 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -84,7 +84,10 @@ if(!reagents.total_volume || !is_open_container()) return + var/client/thrower = directory[ckey(src.fingerprintslast)] + if(ismob(target) && target.reagents) + reagents.total_volume *= rand(5,10) * 0.1 //Not all of it makes contact with the target var/mob/M = target var/R target.visible_message("[M] has been splashed with something!", \ @@ -94,9 +97,16 @@ R += A.id + " (" R += num2text(A.volume) + ")," - var/client/thrower = directory[ckey(src.fingerprintslast)] - add_logs(thrower.mob, M, "splashed", object="[R]") + if(thrower && thrower.mob) + add_logs(thrower.mob, M, "splashed", object="[R]") reagents.reaction(target, TOUCH) + + else if(!target.density || target.throwpass) + if(thrower && thrower.mob && thrower.mob.mind && thrower.mob.mind.assigned_role == "Bartender") + visible_message("[src] lands onto the [target.name] without spilling a single drop.") + return + else + visible_message("[src] spills its contents all over [target].") reagents.reaction(target, TOUCH) reagents.clear_reagents() From 07bf0fd953f9f1efc46cf555eb1dc55316a13821 Mon Sep 17 00:00:00 2001 From: Ikarrus Date: Wed, 1 Jul 2015 12:01:58 -0600 Subject: [PATCH 4/6] You can splash yourself with reagent glasses now --- code/game/objects/items.dm | 4 ++-- code/modules/reagents/reagent_containers/glass.dm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 9c166718063..503eed7bec8 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -82,8 +82,8 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s var/flags_cover = 0 //for flags such as GLASSESCOVERSEYES -/obj/item/proc/check_allowed_items(atom/target, not_inside) - if((src in target) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into)) +/obj/item/proc/check_allowed_items(atom/target, not_inside, target_self) + if(((src in target) && !target_self) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into)) return 0 else return 1 diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index b8f188c3ba5..3090f998c9e 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -34,7 +34,7 @@ /obj/item/weapon/reagent_containers/glass/afterattack(obj/target, mob/user, proximity) - if((!proximity) || !check_allowed_items(target)) return + if((!proximity) || !check_allowed_items(target,1)) return if(ismob(target) && target.reagents && reagents.total_volume) var/mob/M = target From 55bec2d24d4c87b033dcd720a43d3dc2d914c38a Mon Sep 17 00:00:00 2001 From: Ikarrus Date: Wed, 1 Jul 2015 13:00:12 -0600 Subject: [PATCH 5/6] Adds a thrownby var that's used by admin logging. --- code/_onclick/telekinesis.dm | 2 +- code/datums/martial.dm | 2 +- code/datums/spells/wizard.dm | 2 +- code/game/atoms_movable.dm | 8 +++++++- code/game/objects/items/weapons/pneumaticCannon.dm | 2 +- code/modules/admin/verbs/buildmode.dm | 8 ++++---- code/modules/games/cards.dm | 2 +- code/modules/mob/living/carbon/carbon.dm | 6 +++--- code/modules/mob/living/living_defense.dm | 9 +++------ .../ninja/suit/n_suit_verbs/ninja_sword_recall.dm | 2 +- code/modules/projectiles/guns/grenade_launcher.dm | 2 +- code/modules/reagents/reagent_containers.dm | 8 +++----- 12 files changed, 27 insertions(+), 26 deletions(-) diff --git a/code/_onclick/telekinesis.dm b/code/_onclick/telekinesis.dm index d86f0351d75..9cb3d4945e5 100644 --- a/code/_onclick/telekinesis.dm +++ b/code/_onclick/telekinesis.dm @@ -128,7 +128,7 @@ var/const/tk_maxrange = 15 else apply_focus_overlay() - focus.throw_at(target, 10, 1) + focus.throw_at(target, 10, 1,user) last_throw = world.time return diff --git a/code/datums/martial.dm b/code/datums/martial.dm index 8c5c136980e..a1c92bd97d0 100644 --- a/code/datums/martial.dm +++ b/code/datums/martial.dm @@ -225,7 +225,7 @@ "[A] has hit [D] with Plasma Punch!") playsound(D.loc, 'sound/weapons/punch1.ogg', 50, 1, -1) var/atom/throw_target = get_edge_target_turf(D, get_dir(D, get_step_away(D, A))) - D.throw_at(throw_target, 200, 4) + D.throw_at(throw_target, 200, 4,A) A.say("HYAH!") return diff --git a/code/datums/spells/wizard.dm b/code/datums/spells/wizard.dm index d6cdfe7c872..f7624463fe0 100644 --- a/code/datums/spells/wizard.dm +++ b/code/datums/spells/wizard.dm @@ -343,4 +343,4 @@ var/mob/living/M = AM M.Weaken(2) M << "You're thrown back by a mystical force!" - spawn(0) AM.throw_at(throwtarget, ((Clamp((maxthrow - (Clamp(distfromcaster - 2, 0, distfromcaster))), 3, maxthrow))), 1)//So stuff gets tossed around at the same time. \ No newline at end of file + spawn(0) AM.throw_at(throwtarget, ((Clamp((maxthrow - (Clamp(distfromcaster - 2, 0, distfromcaster))), 3, maxthrow))), 1,user)//So stuff gets tossed around at the same time. \ No newline at end of file diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 41ebb2b02b2..33b0400ac41 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -6,6 +6,7 @@ var/throw_speed = 2 var/throw_range = 7 var/mob/pulledby = null + var/mob/thrownby = null var/languages = 0 //For say() and Hear() var/verb_say = "says" var/verb_ask = "asks" @@ -168,10 +169,15 @@ src.throw_impact(A) src.throwing = 0 -/atom/movable/proc/throw_at(atom/target, range, speed) +/atom/movable/proc/throw_at(atom/target, range, speed, mob/user) if(!target || !src || (flags & NODROP)) return 0 //use a modified version of Bresenham's algorithm to get from the atom's current position to that of the target + if(user) + thrownby = user + else + thrownby = null + src.throwing = 1 if(target.allow_spin) // turns out 1000+ spinning objects being thrown at the singularity creates lag - Iamgoofball SpinAnimation(5, 1) diff --git a/code/game/objects/items/weapons/pneumaticCannon.dm b/code/game/objects/items/weapons/pneumaticCannon.dm index f4af87c3f10..e8d9be3948b 100644 --- a/code/game/objects/items/weapons/pneumaticCannon.dm +++ b/code/game/objects/items/weapons/pneumaticCannon.dm @@ -92,7 +92,7 @@ loadedWeightClass -= ITD.w_class ITD.throw_speed = pressureSetting * 2 ITD.loc = get_turf(src) - ITD.throw_at(target, pressureSetting * 5, pressureSetting * 2) + ITD.throw_at(target, pressureSetting * 5, pressureSetting * 2,user) if(pressureSetting >= 3) user << "\The [src]'s recoil knocks you down!" user.Weaken(2) diff --git a/code/modules/admin/verbs/buildmode.dm b/code/modules/admin/verbs/buildmode.dm index d06bd7e61c8..a3912ae24c0 100644 --- a/code/modules/admin/verbs/buildmode.dm +++ b/code/modules/admin/verbs/buildmode.dm @@ -189,10 +189,10 @@ var/type = input(usr,"Select Generator Type","Type") as null|anything in gen_paths if(!type) return - + master.generator_path = type master.cornerA = null - master.cornerB = null + master.cornerB = null return 1 @@ -292,7 +292,7 @@ holder.throw_atom = object if(pa.Find("right")) if(holder.throw_atom) - holder.throw_atom.throw_at(object, 10, 1) + holder.throw_atom.throw_at(object, 10, 1,user) log_admin("Build Mode: [key_name(usr)] threw [holder.throw_atom] at [object] ([object.x],[object.y],[object.z])") if(AREA_BUILDMODE) if(!holder.cornerA) @@ -300,7 +300,7 @@ return if(holder.cornerA && !holder.cornerB) holder.cornerB = get_turf(object) - + if(pa.Find("left")) //rectangular if(holder.cornerA && holder.cornerB) if(!holder.generator_path) diff --git a/code/modules/games/cards.dm b/code/modules/games/cards.dm index a39c6f54dc0..932c4f2a174 100644 --- a/code/modules/games/cards.dm +++ b/code/modules/games/cards.dm @@ -104,7 +104,7 @@ H.update_icon() source.visible_message("\The [source] deals a card to \the [target].") - H.throw_at(get_step(target, target.dir), 10, 1, H) + H.throw_at(get_step(target, target.dir), 10, 1, source) /* Hand */ diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 5ff331cb104..d43041dac13 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -278,7 +278,7 @@ newtonian_move(get_dir(target, src)) - item.throw_at(target, item.throw_range, item.throw_speed) + item.throw_at(target, item.throw_range, item.throw_speed, src) /mob/living/carbon/can_use_hands() if(handcuffed) @@ -531,7 +531,7 @@ var/const/GALOSHES_DONT_HELP = 8 target = new_turf if(new_turf.density) break - I.throw_at(target,I.throw_range,I.throw_speed) + I.throw_at(target,I.throw_range,I.throw_speed,src) if(61 to 90) //throw it down to the floor var/turf/target = get_turf(loc) - I.throw_at(target,I.throw_range,I.throw_speed) \ No newline at end of file + I.throw_at(target,I.throw_range,I.throw_speed,src) \ No newline at end of file diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index af8b231f78a..7533ad9df49 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -71,12 +71,9 @@ "[src] has been hit by [I].") var/armor = run_armor_check(zone, "melee", "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].",I.armour_penetration) apply_damage(I.throwforce, dtype, zone, armor, I) - if(!I.fingerprintslast) - return - var/client/assailant = directory[ckey(I.fingerprintslast)] - if(assailant && assailant.mob && istype(assailant.mob,/mob)) - var/mob/M = assailant.mob - add_logs(M, src, "hit", object="[I]") + + if(I.thrownby) + add_logs(I.thrownby, src, "hit", object="[I]") /mob/living/mech_melee_attack(obj/mecha/M) if(M.occupant.a_intent == "harm") diff --git a/code/modules/ninja/suit/n_suit_verbs/ninja_sword_recall.dm b/code/modules/ninja/suit/n_suit_verbs/ninja_sword_recall.dm index c117cd40d8e..fb38a3fbdd7 100644 --- a/code/modules/ninja/suit/n_suit_verbs/ninja_sword_recall.dm +++ b/code/modules/ninja/suit/n_suit_verbs/ninja_sword_recall.dm @@ -41,7 +41,7 @@ energyKatana.spark_system.start() playsound(H, "sparks", 50, 1) H.visible_message("\the [energyKatana] flies towards [H]!","You hold out your hand and \the [energyKatana] flies towards you!") - energyKatana.throw_at(H, distance+1, energyKatana.throw_speed) + energyKatana.throw_at(H, distance+1, energyKatana.throw_speed,H) else //Else just TP it to us. energyKatana.returnToOwner(H,1) diff --git a/code/modules/projectiles/guns/grenade_launcher.dm b/code/modules/projectiles/guns/grenade_launcher.dm index 2075ebeaa60..0c8cc54a66e 100644 --- a/code/modules/projectiles/guns/grenade_launcher.dm +++ b/code/modules/projectiles/guns/grenade_launcher.dm @@ -51,7 +51,7 @@ var/obj/item/weapon/grenade/chem_grenade/F = grenades[1] //Now with less copypasta! grenades -= F F.loc = user.loc - F.throw_at(target, 30, 2) + F.throw_at(target, 30, 2,user) message_admins("[key_name_admin(user)] fired a grenade ([F.name]) from a grenade launcher ([src.name]).") log_game("[key_name(user)] fired a grenade ([F.name]) from a grenade launcher ([src.name]).") F.active = 1 diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index c79142c6a32..bf6c53c0671 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -84,8 +84,6 @@ if(!reagents.total_volume || !is_open_container()) return - var/client/thrower = directory[ckey(src.fingerprintslast)] - if(ismob(target) && target.reagents) reagents.total_volume *= rand(5,10) * 0.1 //Not all of it makes contact with the target var/mob/M = target @@ -97,12 +95,12 @@ R += A.id + " (" R += num2text(A.volume) + ")," - if(thrower && thrower.mob) - add_logs(thrower.mob, M, "splashed", object="[R]") + if(thrownby) + add_logs(thrownby, M, "splashed", object="[R]") reagents.reaction(target, TOUCH) else if(!target.density || target.throwpass) - if(thrower && thrower.mob && thrower.mob.mind && thrower.mob.mind.assigned_role == "Bartender") + if(thrownby && thrownby.mind && thrownby.mind.assigned_role == "Bartender") visible_message("[src] lands onto the [target.name] without spilling a single drop.") return From 8f8164d8e802aaf6c9274a1a38920839f4e99d76 Mon Sep 17 00:00:00 2001 From: Ikarrus Date: Thu, 2 Jul 2015 19:57:51 -0600 Subject: [PATCH 6/6] Removed atom var and instead used paramaters to determine the thrower --- code/game/atoms.dm | 4 ++-- code/game/atoms_movable.dm | 14 ++++---------- code/modules/mob/living/living_defense.dm | 6 +++--- code/modules/reagents/reagent_containers.dm | 8 ++++---- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index f6a52f40e54..52ac867c334 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -55,10 +55,10 @@ return 0 -/atom/proc/throw_impact(atom/hit_atom) +/atom/proc/throw_impact(atom/hit_atom,mob/thrower) if(istype(hit_atom,/mob/living)) var/mob/living/M = hit_atom - M.hitby(src) + M.hitby(src,thrower) else if(isobj(hit_atom)) var/obj/O = hit_atom diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 33b0400ac41..f0083db4d8b 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -6,7 +6,6 @@ var/throw_speed = 2 var/throw_range = 7 var/mob/pulledby = null - var/mob/thrownby = null var/languages = 0 //For say() and Hear() var/verb_say = "says" var/verb_ask = "asks" @@ -155,13 +154,13 @@ /atom/movable/proc/checkpass(passflag) return pass_flags&passflag -/atom/movable/proc/hit_check() // todo: this is partly obsolete due to passflags already, add throwing stuff to mob CanPass and finish it +/atom/movable/proc/hit_check(mob/thrower) // todo: this is partly obsolete due to passflags already, add throwing stuff to mob CanPass and finish it if(src.throwing) for(var/atom/A in get_turf(src)) if(A == src) continue if(istype(A,/mob/living)) if(A:lying) continue - src.throw_impact(A) + src.throw_impact(A,thrower) if(src.throwing == 1) src.throwing = 0 if(isobj(A)) @@ -169,15 +168,10 @@ src.throw_impact(A) src.throwing = 0 -/atom/movable/proc/throw_at(atom/target, range, speed, mob/user) +/atom/movable/proc/throw_at(atom/target, range, speed, mob/thrower) if(!target || !src || (flags & NODROP)) return 0 //use a modified version of Bresenham's algorithm to get from the atom's current position to that of the target - if(user) - thrownby = user - else - thrownby = null - src.throwing = 1 if(target.allow_spin) // turns out 1000+ spinning objects being thrown at the singularity creates lag - Iamgoofball SpinAnimation(5, 1) @@ -209,7 +203,7 @@ if(!step) // going off the edge of the map makes get_step return null, don't let things go off the edge break src.Move(step, get_dir(loc, step)) - hit_check() + hit_check(thrower) error += (error < 0) ? tdist_x : -tdist_y; dist_travelled++ dist_since_sleep++ diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 7533ad9df49..d050141cd8d 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -44,7 +44,7 @@ else return 0 -/mob/living/hitby(atom/movable/AM)//Standardization and logging -Sieve +/mob/living/hitby(atom/movable/AM,mob/thrower)//Standardization and logging -Sieve if(istype(AM, /obj/item)) var/obj/item/I = AM var/zone = ran_zone("chest", 65)//Hits a random part of the body, geared towards the chest @@ -72,8 +72,8 @@ var/armor = run_armor_check(zone, "melee", "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].",I.armour_penetration) apply_damage(I.throwforce, dtype, zone, armor, I) - if(I.thrownby) - add_logs(I.thrownby, src, "hit", object="[I]") + if(thrower) + add_logs(thrower, src, "hit", object="[I]") /mob/living/mech_melee_attack(obj/mecha/M) if(M.occupant.a_intent == "harm") diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index bf6c53c0671..76c234716ca 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -78,7 +78,7 @@ reagents.handle_reactions() ..() -/obj/item/weapon/reagent_containers/throw_impact(atom/target) +/obj/item/weapon/reagent_containers/throw_impact(atom/target,mob/thrower) ..() if(!reagents.total_volume || !is_open_container()) @@ -95,12 +95,12 @@ R += A.id + " (" R += num2text(A.volume) + ")," - if(thrownby) - add_logs(thrownby, M, "splashed", object="[R]") + if(thrower) + add_logs(thrower, M, "splashed", object="[R]") reagents.reaction(target, TOUCH) else if(!target.density || target.throwpass) - if(thrownby && thrownby.mind && thrownby.mind.assigned_role == "Bartender") + if(thrower && thrower.mind && thrower.mind.assigned_role == "Bartender") visible_message("[src] lands onto the [target.name] without spilling a single drop.") return