mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 03:33:21 +00:00
Bit of refactoring.
Moved gun icons adding/deletion in separate procs. Moved dropping aim in separate procs. Moved gun empty clicking in separate proc because all the copypaste. Fixed issues with aim mode HUD icons not being updated in some cases. Now toggling mode cancels aim properly. Fixed type in firing message.
This commit is contained in:
@@ -34,18 +34,6 @@
|
|||||||
proc/load_into_chamber()
|
proc/load_into_chamber()
|
||||||
return 0
|
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.
|
proc/special_check(var/mob/M) //Placeholder for any special checks, like detective's revolver.
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -100,9 +88,7 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
if(!load_into_chamber()) //CHECK
|
if(!load_into_chamber()) //CHECK
|
||||||
user.visible_message("*click click*", "\red <b>*click*</b>")
|
return click_empty(user)
|
||||||
playsound(user, 'sound/weapons/empty.ogg', 100, 1)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(!in_chamber)
|
if(!in_chamber)
|
||||||
return
|
return
|
||||||
@@ -123,7 +109,7 @@
|
|||||||
playsound(user, fire_sound, 10, 1)
|
playsound(user, fire_sound, 10, 1)
|
||||||
else
|
else
|
||||||
playsound(user, fire_sound, 50, 1)
|
playsound(user, fire_sound, 50, 1)
|
||||||
user.visible_message("<span class='warning'>[user] fires [src][reflex ? "by reflex":""]!</span>", \
|
user.visible_message("<span class='warning'>[user] fires [src][reflex ? " by reflex":""]!</span>", \
|
||||||
"<span class='warning'>You fire [src][reflex ? "by reflex":""]!</span>", \
|
"<span class='warning'>You fire [src][reflex ? "by reflex":""]!</span>", \
|
||||||
"You hear a [istype(in_chamber, /obj/item/projectile/beam) ? "laser blast" : "gunshot"]!")
|
"You hear a [istype(in_chamber, /obj/item/projectile/beam) ? "laser blast" : "gunshot"]!")
|
||||||
|
|
||||||
@@ -157,6 +143,13 @@
|
|||||||
else
|
else
|
||||||
user.update_inv_r_hand()
|
user.update_inv_r_hand()
|
||||||
|
|
||||||
|
/obj/item/weapon/gun/proc/click_empty(mob/user = null)
|
||||||
|
if (user)
|
||||||
|
user.visible_message("*click click*", "\red <b>*click*</b>")
|
||||||
|
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)
|
/obj/item/weapon/gun/attack(mob/living/M as mob, mob/living/user as mob, def_zone)
|
||||||
//Suicide handling.
|
//Suicide handling.
|
||||||
@@ -182,8 +175,7 @@
|
|||||||
mouthshoot = 0
|
mouthshoot = 0
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
user.visible_message("*click click*", "\red <b>*click*</b>")
|
click_empty(user)
|
||||||
playsound(user, 'sound/weapons/empty.ogg', 100, 1)
|
|
||||||
mouthshoot = 0
|
mouthshoot = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -195,8 +187,7 @@
|
|||||||
Fire(M,user)
|
Fire(M,user)
|
||||||
return
|
return
|
||||||
else if(target && M in target)
|
else if(target && M in target)
|
||||||
world << "\red PREFIRE IS CALLED TO SHOOT AT [M] BY [user]"
|
Fire(M,user) ///Otherwise, shoot!
|
||||||
PreFire(M,user) ///Otherwise, shoot!
|
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
return ..() //Pistolwhippin'
|
return ..() //Pistolwhippin'
|
||||||
@@ -11,16 +11,28 @@
|
|||||||
set name = "Lower Aim"
|
set name = "Lower Aim"
|
||||||
set category = "Object"
|
set category = "Object"
|
||||||
if(target)
|
if(target)
|
||||||
for(var/mob/living/M in target)
|
stop_aim()
|
||||||
if(M)
|
|
||||||
M.NotTargeted(src)
|
|
||||||
del(target)
|
|
||||||
usr.visible_message("\blue \The [usr] lowers \the [src]...")
|
usr.visible_message("\blue \The [usr] lowers \the [src]...")
|
||||||
|
|
||||||
//Clicking gun will still lower aim for guns that don't overwrite this
|
//Clicking gun will still lower aim for guns that don't overwrite this
|
||||||
/obj/item/weapon/gun/attack_self()
|
/obj/item/weapon/gun/attack_self()
|
||||||
lower_aim()
|
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.....
|
//Compute how to fire.....
|
||||||
/obj/item/weapon/gun/proc/PreFire(atom/A as mob|obj|turf|area, mob/living/user as mob|obj, params)
|
/obj/item/weapon/gun/proc/PreFire(atom/A as mob|obj|turf|area, mob/living/user as mob|obj, params)
|
||||||
//Lets not spam it.
|
//Lets not spam it.
|
||||||
@@ -34,11 +46,6 @@
|
|||||||
Aim(M) //Aha! Aim at them!
|
Aim(M) //Aha! Aim at them!
|
||||||
else if(!ismob(M) || (ismob(M) && !(M in view(user)))) //Nope! They weren't there!
|
else if(!ismob(M) || (ismob(M) && !(M in view(user)))) //Nope! They weren't there!
|
||||||
Fire(A,user,params) //Fire like normal, then.
|
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)
|
usr.dir = get_cardinal_dir(src, A)
|
||||||
|
|
||||||
//Aiming at the target mob.
|
//Aiming at the target mob.
|
||||||
@@ -61,11 +68,7 @@
|
|||||||
if(M == T) return
|
if(M == T) return
|
||||||
if(!istype(M)) return
|
if(!istype(M)) return
|
||||||
if(src != M.equipped())
|
if(src != M.equipped())
|
||||||
for(var/mob/living/N in target)
|
stop_aim()
|
||||||
if(N)
|
|
||||||
N.NotTargeted(src)
|
|
||||||
del(target)
|
|
||||||
return
|
|
||||||
M.last_move_intent = world.time
|
M.last_move_intent = world.time
|
||||||
if(load_into_chamber())
|
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.
|
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)
|
spawn(30)
|
||||||
told_cant_shoot = 0
|
told_cant_shoot = 0
|
||||||
else
|
else
|
||||||
usr.visible_message("*click click*", "\red <b>*click*</b>")
|
click_empty(M)
|
||||||
for(var/mob/living/K in viewers(usr))
|
|
||||||
K << 'empty.ogg'
|
|
||||||
|
|
||||||
usr.dir = get_cardinal_dir(src, T)
|
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
|
//Adding the buttons to the controler person
|
||||||
var/mob/living/T = I.loc
|
var/mob/living/T = I.loc
|
||||||
if(T)
|
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)
|
if(T.client)
|
||||||
T.client.screen += T.item_use_icon
|
T.client.add_gun_icons()
|
||||||
T.client.screen += T.gun_move_icon
|
|
||||||
else
|
else
|
||||||
I.lower_aim()
|
I.lower_aim()
|
||||||
return
|
return
|
||||||
@@ -215,9 +213,7 @@ mob/living/proc/NotTargeted(var/obj/item/weapon/gun/I)
|
|||||||
del(I.target)
|
del(I.target)
|
||||||
var/mob/living/T = I.loc //Remove the targeting icons
|
var/mob/living/T = I.loc //Remove the targeting icons
|
||||||
if(T && ismob(T) && !I.target)
|
if(T && ismob(T) && !I.target)
|
||||||
del(T.item_use_icon)
|
T.client.remove_gun_icons()
|
||||||
del(T.gun_move_icon)
|
|
||||||
del(T.gun_run_icon)
|
|
||||||
if(!targeted_by.len)
|
if(!targeted_by.len)
|
||||||
del target_locked //Remove the overlay
|
del target_locked //Remove the overlay
|
||||||
del targeted_by
|
del targeted_by
|
||||||
@@ -243,17 +239,51 @@ client/var
|
|||||||
gun_mode = 0
|
gun_mode = 0
|
||||||
|
|
||||||
//These are called by the on-screen buttons, adjusting what the victim can and cannot do.
|
//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()
|
client/verb/ToggleGunMode()
|
||||||
set hidden = 1
|
set hidden = 1
|
||||||
gun_mode = !gun_mode
|
gun_mode = !gun_mode
|
||||||
if(gun_mode)
|
if(gun_mode)
|
||||||
usr << "You will now take people captive."
|
usr << "You will now take people captive."
|
||||||
|
add_gun_icons()
|
||||||
else
|
else
|
||||||
usr << "You will now shoot where you target."
|
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)
|
if(usr.gun_setting_icon)
|
||||||
usr.gun_setting_icon.icon_state = "gun[gun_mode]"
|
usr.gun_setting_icon.icon_state = "gun[gun_mode]"
|
||||||
|
|
||||||
|
|
||||||
client/verb/AllowTargetMove()
|
client/verb/AllowTargetMove()
|
||||||
set hidden=1
|
set hidden=1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user