diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm
index 2a0fbfe920..3377baf8f2 100644
--- a/code/modules/projectiles/gun.dm
+++ b/code/modules/projectiles/gun.dm
@@ -34,18 +34,6 @@
proc/load_into_chamber()
return 0
- //Removing the lock and the buttons.
- dropped(mob/user as mob)
- if(target)
- for(var/mob/living/M in target)
- if(M)
- M.NotTargeted(src) //Untargeting people.
- del(target)
- del(user.item_use_icon) //Removing the control icons.
- del(user.gun_move_icon)
- del(user.gun_run_icon)
- return ..()
-
proc/special_check(var/mob/M) //Placeholder for any special checks, like detective's revolver.
return 1
@@ -100,9 +88,7 @@
return
if(!load_into_chamber()) //CHECK
- user.visible_message("*click click*", "\red *click*")
- playsound(user, 'sound/weapons/empty.ogg', 100, 1)
- return
+ return click_empty(user)
if(!in_chamber)
return
@@ -123,7 +109,7 @@
playsound(user, fire_sound, 10, 1)
else
playsound(user, fire_sound, 50, 1)
- user.visible_message("[user] fires [src][reflex ? "by reflex":""]!", \
+ user.visible_message("[user] fires [src][reflex ? " by reflex":""]!", \
"You fire [src][reflex ? "by reflex":""]!", \
"You hear a [istype(in_chamber, /obj/item/projectile/beam) ? "laser blast" : "gunshot"]!")
@@ -157,6 +143,13 @@
else
user.update_inv_r_hand()
+/obj/item/weapon/gun/proc/click_empty(mob/user = null)
+ if (user)
+ user.visible_message("*click click*", "\red *click*")
+ playsound(user, 'sound/weapons/empty.ogg', 100, 1)
+ else
+ src.visible_message("*click click*")
+ playsound(src.loc, 'sound/weapons/empty.ogg', 100, 1)
/obj/item/weapon/gun/attack(mob/living/M as mob, mob/living/user as mob, def_zone)
//Suicide handling.
@@ -182,8 +175,7 @@
mouthshoot = 0
return
else
- user.visible_message("*click click*", "\red *click*")
- playsound(user, 'sound/weapons/empty.ogg', 100, 1)
+ click_empty(user)
mouthshoot = 0
return
@@ -195,8 +187,7 @@
Fire(M,user)
return
else if(target && M in target)
- world << "\red PREFIRE IS CALLED TO SHOOT AT [M] BY [user]"
- PreFire(M,user) ///Otherwise, shoot!
+ Fire(M,user) ///Otherwise, shoot!
return
else
return ..() //Pistolwhippin'
\ No newline at end of file
diff --git a/code/modules/projectiles/targeting.dm b/code/modules/projectiles/targeting.dm
index ea52bc5bdf..5480b83d84 100644
--- a/code/modules/projectiles/targeting.dm
+++ b/code/modules/projectiles/targeting.dm
@@ -11,16 +11,28 @@
set name = "Lower Aim"
set category = "Object"
if(target)
- for(var/mob/living/M in target)
- if(M)
- M.NotTargeted(src)
- del(target)
+ stop_aim()
usr.visible_message("\blue \The [usr] lowers \the [src]...")
//Clicking gun will still lower aim for guns that don't overwrite this
/obj/item/weapon/gun/attack_self()
lower_aim()
+//Removing the lock and the buttons.
+/obj/item/weapon/gun/dropped(mob/user as mob)
+ stop_aim()
+ if (user.client)
+ user.client.remove_gun_icons()
+ return ..()
+
+//Removes lock fro mall targets
+/obj/item/weapon/gun/proc/stop_aim()
+ if(target)
+ for(var/mob/living/M in target)
+ if(M)
+ M.NotTargeted(src) //Untargeting people.
+ del(target)
+
//Compute how to fire.....
/obj/item/weapon/gun/proc/PreFire(atom/A as mob|obj|turf|area, mob/living/user as mob|obj, params)
//Lets not spam it.
@@ -34,11 +46,6 @@
Aim(M) //Aha! Aim at them!
else if(!ismob(M) || (ismob(M) && !(M in view(user)))) //Nope! They weren't there!
Fire(A,user,params) //Fire like normal, then.
-/*
- else if(!target)
- world << "\red DIDN'T HAVE A TARGET, FIRED"
- Fire(A,user,params) //Boom!
- */
usr.dir = get_cardinal_dir(src, A)
//Aiming at the target mob.
@@ -61,11 +68,7 @@
if(M == T) return
if(!istype(M)) return
if(src != M.equipped())
- for(var/mob/living/N in target)
- if(N)
- N.NotTargeted(src)
- del(target)
- return
+ stop_aim()
M.last_move_intent = world.time
if(load_into_chamber())
var/firing_check = in_chamber.check_fire(T,usr) //0 if it cannot hit them, 1 if it is capable of hitting, and 2 if a special check is preventing it from firing.
@@ -78,9 +81,7 @@
spawn(30)
told_cant_shoot = 0
else
- usr.visible_message("*click click*", "\red *click*")
- for(var/mob/living/K in viewers(usr))
- K << 'empty.ogg'
+ click_empty(M)
usr.dir = get_cardinal_dir(src, T)
@@ -171,11 +172,8 @@ mob/living/proc/Targeted(var/obj/item/weapon/gun/I) //Self explanitory.
//Adding the buttons to the controler person
var/mob/living/T = I.loc
if(T)
- T.item_use_icon = new /obj/screen/gun/item(null)
- T.gun_move_icon = new /obj/screen/gun/move(null)
if(T.client)
- T.client.screen += T.item_use_icon
- T.client.screen += T.gun_move_icon
+ T.client.add_gun_icons()
else
I.lower_aim()
return
@@ -215,9 +213,7 @@ mob/living/proc/NotTargeted(var/obj/item/weapon/gun/I)
del(I.target)
var/mob/living/T = I.loc //Remove the targeting icons
if(T && ismob(T) && !I.target)
- del(T.item_use_icon)
- del(T.gun_move_icon)
- del(T.gun_run_icon)
+ T.client.remove_gun_icons()
if(!targeted_by.len)
del target_locked //Remove the overlay
del targeted_by
@@ -243,17 +239,51 @@ client/var
gun_mode = 0
//These are called by the on-screen buttons, adjusting what the victim can and cannot do.
+client/proc/add_gun_icons()
+ if (!usr.item_use_icon)
+ usr.item_use_icon = new /obj/screen/gun/item(null)
+ usr.item_use_icon.icon_state = "no_item[target_can_click]"
+ usr.item_use_icon.name = "[target_can_click ? "Disallow" : "Allow"] Item Use"
+
+ if (!usr.gun_move_icon)
+ usr.gun_move_icon = new /obj/screen/gun/move(null)
+ usr.gun_move_icon.icon_state = "no_walk[target_can_move]"
+ usr.gun_move_icon.name = "[target_can_move ? "Disallow" : "Allow"] Walking"
+
+ if (target_can_move && !usr.gun_run_icon)
+ usr.gun_run_icon = new /obj/screen/gun/run(null)
+ usr.gun_run_icon.icon_state = "no_run[target_can_run]"
+ usr.gun_run_icon.name = "[target_can_run ? "Disallow" : "Allow"] Running"
+
+ screen += usr.item_use_icon
+ screen += usr.gun_move_icon
+ if (target_can_move)
+ screen += usr.gun_run_icon
+
+client/proc/remove_gun_icons()
+ screen -= usr.item_use_icon
+ screen -= usr.gun_move_icon
+ if (target_can_move)
+ screen -= usr.gun_run_icon
+ del usr.gun_move_icon
+ del usr.item_use_icon
+ del usr.gun_run_icon
client/verb/ToggleGunMode()
set hidden = 1
gun_mode = !gun_mode
if(gun_mode)
usr << "You will now take people captive."
+ add_gun_icons()
else
usr << "You will now shoot where you target."
+ for(var/obj/item/weapon/gun/G in usr)
+ G.stop_aim()
+ remove_gun_icons()
if(usr.gun_setting_icon)
usr.gun_setting_icon.icon_state = "gun[gun_mode]"
+
client/verb/AllowTargetMove()
set hidden=1