From d545eb7f9fbac09d198af313c41c6a092fae5107 Mon Sep 17 00:00:00 2001 From: phil235 Date: Thu, 4 Dec 2014 01:08:04 +0100 Subject: [PATCH] Visible_message() now uses recursive_hear_check so mob inside something can see those messages. Fixes being able to see visible_message w/o seeing the src of it (happened when the src could see us but not the other way around), you no longer see visible_message from mobs inside closets for example. Fixes pAI being deaf. Removing some no longer needed occupant_message() in mecha code. Fixed some typos and span class here and there. --- code/ATMOSPHERICS/pipes/simple.dm | 2 +- code/game/machinery/doors/windowdoor.dm | 1 - code/game/mecha/mecha.dm | 18 +----------------- code/game/objects/items/toys.dm | 4 ++-- code/game/objects/structures.dm | 1 - code/game/turfs/simulated/walls.dm | 2 -- .../mob/living/carbon/human/human_defense.dm | 1 - code/modules/mob/living/living_defense.dm | 2 -- code/modules/mob/living/silicon/pai/life.dm | 6 ------ code/modules/mob/living/silicon/pai/pai.dm | 4 +--- code/modules/mob/mob.dm | 18 +++++++++++++----- code/modules/reagents/Chemistry-Holder.dm | 2 +- 12 files changed, 19 insertions(+), 42 deletions(-) diff --git a/code/ATMOSPHERICS/pipes/simple.dm b/code/ATMOSPHERICS/pipes/simple.dm index da6fce0c263..eabf5a2badb 100644 --- a/code/ATMOSPHERICS/pipes/simple.dm +++ b/code/ATMOSPHERICS/pipes/simple.dm @@ -102,7 +102,7 @@ The regular pipe you see everywhere, including bent ones. else return 1 /obj/machinery/atmospherics/pipe/simple/proc/burst() - src.visible_message("[src] bursts!"); + visible_message("[src] bursts!"); playsound(src.loc, 'sound/effects/bang.ogg', 25, 1) var/datum/effect/effect/system/harmless_smoke_spread/smoke = new smoke.set_up(1,0, src.loc, 0) diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm index 05caa8ff585..5a7558b60d9 100644 --- a/code/game/machinery/doors/windowdoor.dm +++ b/code/game/machinery/doors/windowdoor.dm @@ -200,7 +200,6 @@ /obj/machinery/door/window/mech_melee_attack(obj/mecha/M) if(M.damtype == "brute") playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1) - M.occupant_message("You hit [src].") visible_message("[src] has been hit by [M.name].") take_damage(M.force) return diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 02fe27be028..225bf65a69b 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -320,7 +320,6 @@ obj/mecha/proc/can_use(mob/user) playsound(src, 'sound/items/Welder.ogg', 50, 1) else return - M.occupant_message("You hit [src].") visible_message("[src] has been hit by [M.name].") take_damage(M.force, damtype) add_logs(M.occupant, src, "attacked", object=M, addition="(INTENT: [uppertext(M.occupant.a_intent)]) (DAMTYPE: [uppertext(M.damtype)])") @@ -475,6 +474,7 @@ obj/mecha/proc/can_use(mob/user) var/damage = absorbDamage(amount,type) health -= damage update_health() + occupant_message("Taking damage!") log_append_to_last("Took [damage] points of damage. Damage type: \"[type]\".",1) /obj/mecha/proc/absorbDamage(damage,damage_type) @@ -499,7 +499,6 @@ obj/mecha/proc/can_use(mob/user) src.take_damage(15) src.check_for_internal_damage(list(MECHA_INT_TEMP_CONTROL,MECHA_INT_TANK_BREACH,MECHA_INT_CONTROL_LOST)) user.visible_message("[user] hits [src.name], doing some damage.", "You hit [src.name] with all your might. The metal creaks and bends.") - src.occupant_message("[user] hits [src.name], doing some damage.") else user.visible_message("[user] hits [src.name]. Nothing happens","You hit [src.name] with no visible effect.") src.log_append_to_last("Armor saved.") @@ -517,14 +516,11 @@ obj/mecha/proc/can_use(mob/user) src.take_damage(15) src.check_for_internal_damage(list(MECHA_INT_TEMP_CONTROL,MECHA_INT_TANK_BREACH,MECHA_INT_CONTROL_LOST)) playsound(src.loc, 'sound/weapons/slash.ogg', 50, 1, -1) - user << "You slash at the armored suit!" visible_message("The [user] slashes at [src.name]'s armor!") - src.occupant_message("The [user] slashes at [src.name]'s armor!") else src.log_append_to_last("Armor saved.") playsound(src.loc, 'sound/weapons/slash.ogg', 50, 1, -1) user << "\green Your claws had no effect!" - src.occupant_message("The [user]'s claws are stopped by the armor.") visible_message("The [user] rebounds off [src.name]'s armor!") return @@ -541,12 +537,10 @@ obj/mecha/proc/can_use(mob/user) src.take_damage(damage) src.check_for_internal_damage(list(MECHA_INT_TEMP_CONTROL,MECHA_INT_TANK_BREACH,MECHA_INT_CONTROL_LOST)) visible_message("[user] [user.attacktext] [src]!") - src.occupant_message("[user] [user.attacktext] [src]!") add_logs(user, src, "attacked", admin=0) else src.log_append_to_last("Armor saved.") playsound(src.loc, 'sound/weapons/slash.ogg', 50, 1, -1) - src.occupant_message("[user]'s attack is stopped by the armor.") visible_message("The [user] rebounds off [src.name]'s armor!") add_logs(user, src, "attacked", admin=0) return @@ -565,7 +559,6 @@ obj/mecha/proc/can_use(mob/user) src.visible_message("The [A] fastens firmly to [src].") return if(prob(src.deflect_chance) || istype(A, /mob)) - src.occupant_message("[A] bounces off the armor.") src.visible_message("[A] bounces off the [src.name] armor") src.log_append_to_last("Armor saved.") if(istype(A, /mob/living)) @@ -574,7 +567,6 @@ obj/mecha/proc/can_use(mob/user) else if(istype(A, /obj)) var/obj/O = A if(O.throwforce) - src.occupant_message("[src.name] is hit by [A].") src.visible_message("[src.name] is hit by [A].") src.take_damage(O.throwforce) src.check_for_internal_damage(list(MECHA_INT_TEMP_CONTROL,MECHA_INT_TANK_BREACH,MECHA_INT_CONTROL_LOST)) @@ -589,7 +581,6 @@ obj/mecha/proc/can_use(mob/user) /obj/mecha/proc/dynbulletdamage(var/obj/item/projectile/Proj) if(prob(src.deflect_chance)) - src.occupant_message("The armor deflects incoming projectile.") src.visible_message("The [src.name] armor deflects the projectile") src.log_append_to_last("Armor saved.") return @@ -601,7 +592,6 @@ obj/mecha/proc/can_use(mob/user) ignore_threshold = 1 if((Proj.damage_type == BRUTE || Proj.damage_type == BURN)) src.take_damage(Proj.damage,Proj.flag) - src.occupant_message("[src.name] is hit by [Proj]!") src.visible_message("[src.name] is hit by [Proj].") src.check_for_internal_damage(list(MECHA_INT_FIRE,MECHA_INT_TEMP_CONTROL,MECHA_INT_TANK_BREACH,MECHA_INT_CONTROL_LOST,MECHA_INT_SHORT_CIRCUIT),ignore_threshold) Proj.on_hit(src) @@ -677,14 +667,8 @@ obj/mecha/proc/can_use(mob/user) if(prob(src.deflect_chance)) user << "The [W] bounces off [src.name] armor." src.log_append_to_last("Armor saved.") -/* - for (var/mob/V in viewers(src)) - if(V.client && !(V.blinded)) - V.show_message("The [W] bounces off [src.name] armor.", 1) -*/ return 0 else - src.occupant_message("[user] hits [src] with [W].") user.visible_message("[user] hits [src] with [W].", "You hit [src] with [W].") src.take_damage(W.force,W.damtype) src.check_for_internal_damage(list(MECHA_INT_TEMP_CONTROL,MECHA_INT_TANK_BREACH,MECHA_INT_CONTROL_LOST)) diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm index 9b91799d00e..30f01ef2e6a 100644 --- a/code/game/objects/items/toys.dm +++ b/code/game/objects/items/toys.dm @@ -67,7 +67,7 @@ /obj/item/toy/balloon/throw_impact(atom/hit_atom) if(src.reagents.total_volume >= 1) - src.visible_message("The [src] bursts!","You hear a pop and a splash.") + src.visible_message("\The [src] bursts!","You hear a pop and a splash.") src.reagents.reaction(get_turf(hit_atom)) for(var/atom/A in get_turf(hit_atom)) src.reagents.reaction(A) @@ -735,7 +735,7 @@ obj/item/toy/cards/deck/attack_hand(mob/user as mob) src.cards -= choice H.pickup(user) user.put_in_active_hand(H) - src.visible_message("[user] draws a card from the deck.", "You draw a card from the deck.") + user.visible_message("[user] draws a card from the deck.", "You draw a card from the deck.") if(cards.len > 26) src.icon_state = "deck_[deckstyle]_full" else if(cards.len > 10) diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index 9d6b1269e9f..aaea66cb517 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -12,7 +12,6 @@ /obj/structure/mech_melee_attack(obj/mecha/M) if(M.damtype == "brute") - M.occupant_message("You hit [src].") visible_message("[src] has been hit by [M.name].") return 1 return 0 diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index 0ea09fc2316..e6ae9a49027 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -77,11 +77,9 @@ /turf/simulated/wall/mech_melee_attack(obj/mecha/M) if(M.damtype == "brute") playsound(src, 'sound/weapons/punch4.ogg', 50, 1) - M.occupant_message("You hit [src].") visible_message("[src] has been hit by [M.name].") if(prob(5) && M.force > 20) dismantle_wall(1) - M.occupant_message("You smash through the wall.") visible_message("[src.name] smashes through the wall!") playsound(src, 'sound/effects/meteorimpact.ogg', 100, 1) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 7b9b0749916..32035a955cc 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -398,7 +398,6 @@ emp_act update_damage_overlays(0) updatehealth() - M.occupant_message("You hit [src].") visible_message("[src] has been hit by [M.name].", \ "[src] has been hit by [M.name].") add_logs(M.occupant, src, "attacked", object=M, addition="(INTENT: [uppertext(M.occupant.a_intent)]) (DAMTYPE: [uppertext(M.damtype)])") diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 87e9a0741c4..4d7e77f370e 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -86,14 +86,12 @@ proc/vol_by_throwforce_and_or_w_class(var/obj/item/I) else return updatehealth() - M.occupant_message("You hit [src].") visible_message("[src] has been hit by [M.name].", \ "[src] has been hit by [M.name].") add_logs(M.occupant, src, "attacked", object=M, addition="(INTENT: [uppertext(M.occupant.a_intent)]) (DAMTYPE: [uppertext(M.damtype)])") else step_away(src,M) add_logs(M.occupant, src, "pushed", object=M, admin=0) - M.occupant_message("You push [src] out of the way.") visible_message("[M] pushes [src] out of the way.") return diff --git a/code/modules/mob/living/silicon/pai/life.dm b/code/modules/mob/living/silicon/pai/life.dm index 874828a6f69..cfcf71eeffb 100644 --- a/code/modules/mob/living/silicon/pai/life.dm +++ b/code/modules/mob/living/silicon/pai/life.dm @@ -19,9 +19,3 @@ stat = CONSCIOUS return health = maxHealth - getBruteLoss() - getFireLoss() - -/mob/living/silicon/pai/proc/follow_pai() - while(card) - loc = get_turf(card) - sleep(5) - qdel(src) //if there's no pAI we shouldn't exist diff --git a/code/modules/mob/living/silicon/pai/pai.dm b/code/modules/mob/living/silicon/pai/pai.dm index 53d4fec79f6..58f7478a67e 100644 --- a/code/modules/mob/living/silicon/pai/pai.dm +++ b/code/modules/mob/living/silicon/pai/pai.dm @@ -4,7 +4,6 @@ mouse_opacity = 0 density = 0 mob_size = 0 - invisibility = 101 var/network = "SS13" var/obj/machinery/camera/current = null @@ -51,7 +50,7 @@ /mob/living/silicon/pai/New(var/obj/item/device/paicard) make_laws() canmove = 0 - src.loc = get_turf(paicard) + src.loc = paicard card = paicard sradio = new(src) if(card) @@ -66,7 +65,6 @@ pda.owner = text("[]", src) pda.name = pda.owner + " (" + pda.ownjob + ")" - follow_pai() ..() /mob/living/silicon/pai/make_laws() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 918437895bb..5424d83628d 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -75,14 +75,18 @@ var/next_mob_id = 0 src << msg return -// Show a message to all mobs in sight of this one +// Show a message to all mobs who sees the src mob and the src mob itself // This would be for visible actions by the src mob // message is the message output to anyone who can see e.g. "[src] does something!" // self_message (optional) is what the src mob sees e.g. "You do something!" // blind_message (optional) is what blind people will hear e.g. "You hear something!" /mob/visible_message(var/message, var/self_message, var/blind_message) - for(var/mob/M in viewers(src)) + var/list/atom_viewers = list() + for(var/atom/movable/A in view(src)) + atom_viewers |= recursive_hear_check(A) + atom_viewers |= src + for(var/mob/M in atom_viewers) if(M.see_invisible < invisibility) continue //can't view the invisible var/msg = message @@ -90,12 +94,16 @@ var/next_mob_id = 0 msg = self_message M.show_message( msg, 1, blind_message, 2) -// Show a message to all mobs in sight of this atom +// Show a message to all mobs who sees this atom // Use for objects performing visible actions // message is output to anyone who can see, e.g. "The [src] does something!" // blind_message (optional) is what blind people will hear e.g. "You hear something!" + /atom/proc/visible_message(var/message, var/blind_message) - for(var/mob/M in viewers(src)) + var/list/atom_viewers = list() + for(var/atom/movable/A in view(src)) + atom_viewers |= recursive_hear_check(A) + for(var/mob/M in atom_viewers) M.show_message( message, 1, blind_message, 2) // Show a message to all mobs in earshot of this one @@ -882,7 +890,7 @@ var/list/slot_equipment_priority = list( \ /mob/proc/get_ghost(even_if_they_cant_reenter = 0) if(mind) - for(var/mob/dead/observer/G in player_list) + for(var/mob/dead/observer/G in dead_mob_list) if(G.mind == mind) if(G.can_reenter_corpse || even_if_they_cant_reenter) return G diff --git a/code/modules/reagents/Chemistry-Holder.dm b/code/modules/reagents/Chemistry-Holder.dm index 9e4da4d8a40..6001a9c0fa1 100644 --- a/code/modules/reagents/Chemistry-Holder.dm +++ b/code/modules/reagents/Chemistry-Holder.dm @@ -282,7 +282,7 @@ datum/reagents/proc/handle_reactions() ME2.Uses-- if(ME2.Uses <= 0) // give the notification that the slime core is dead for(var/mob/M in seen) - M << "\icon[my_atom] The [my_atom]'s power is consumed in the reaction." + M << "\icon[my_atom] \The [my_atom]'s power is consumed in the reaction." ME2.name = "\improper used slime extract" ME2.desc = "This extract has been used up."