Zooming is now a /gun level ability, enable-able at gun creation via a "zoomable" var, Zooming can be properly enabled externally by calling the build_zooming() proc on any gun.

This commit is contained in:
Remie Richards
2015-12-12 15:26:17 +00:00
parent a49fdc0cc7
commit 36d2f54c69
2 changed files with 84 additions and 67 deletions
+81 -1
View File
@@ -55,11 +55,21 @@
var/flight_x_offset = 0
var/flight_y_offset = 0
//Zooming
var/zoomable = FALSE //whether the gun generates a Zoom action on creation
var/zoomed = FALSE //Zoom toggle
var/zoom_amt = 3 //Distance in TURFs to move the user's screen forward (the "zoom" effect)
var/datum/action/toggle_scope_zoom/azoom
/obj/item/weapon/gun/New()
..()
if(pin)
pin = new pin(src)
build_zooming()
/obj/item/weapon/gun/CheckParts()
var/obj/item/weapon/gun/G = locate(/obj/item/weapon/gun) in contents
if(G)
@@ -334,13 +344,17 @@
if(F.on)
user.AddLuminosity(F.brightness_on)
SetLuminosity(0)
if(azoom)
azoom.Grant(user)
/obj/item/weapon/gun/dropped(mob/user)
if(F)
if(F.on)
user.AddLuminosity(-F.brightness_on)
SetLuminosity(F.brightness_on)
zoom(user,FALSE)
if(azoom)
azoom.Remove(user)
/obj/item/weapon/gun/attack_hand(mob/user)
if(unique_reskin && !reskinned && loc == user)
@@ -407,3 +421,69 @@
chambered.BB.damage *= 5
process_fire(target, user, 1, params)
/////////////
// ZOOMING //
/////////////
/datum/action/toggle_scope_zoom
name = "Toggle Scope"
check_flags = AB_CHECK_ALIVE|AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING
button_icon_state = "sniper_zoom"
var/obj/item/weapon/gun/gun = null
/datum/action/toggle_scope_zoom/Trigger()
gun.zoom(owner)
/datum/action/toggle_scope_zoom/IsAvailable()
. = ..()
if(!. && gun)
gun.zoom(owner, FALSE)
/datum/action/toggle_scope_zoom/Remove(mob/living/L)
gun.zoom(L, FALSE)
..()
/obj/item/weapon/gun/proc/zoom(mob/living/user, forced_zoom)
if(!user || !user.client)
return
switch(forced_zoom)
if(FALSE)
zoomed = FALSE
if(TRUE)
zoomed = TRUE
else
zoomed = !zoomed
if(zoomed)
var/_x = 0
var/_y = 0
switch(user.dir)
if(NORTH)
_y = zoom_amt
if(EAST)
_x = zoom_amt
if(SOUTH)
_y = -zoom_amt
if(WEST)
_x = -zoom_amt
user.client.pixel_x = world.icon_size*_x
user.client.pixel_y = world.icon_size*_y
else
user.client.pixel_x = 0
user.client.pixel_y = 0
//Proc, so that gun accessories/scopes/etc. can easily add zooming.
/obj/item/weapon/gun/proc/build_zooming()
if(azoom)
return
if(zoomable)
azoom = new()
azoom.gun = src
@@ -12,9 +12,9 @@
can_unsuppress = 1
can_suppress = 1
w_class = 3
var/zoomed = FALSE
var/zoom_amt = 7
var/datum/action/sniper_zoom/azoom
zoomable = TRUE
zoom_amt = 7 //Long range, enough to see in front of you, but no tiles behind you.
/obj/item/weapon/gun/projectile/sniper_rifle/syndicate
name = "syndicate sniper rifle"
@@ -22,69 +22,6 @@
pin = /obj/item/device/firing_pin/implant/pindicate
origin_tech = "combat=8;syndicate=4"
/obj/item/weapon/gun/projectile/sniper_rifle/New()
..()
azoom = new()
azoom.rifle = src
/obj/item/weapon/gun/projectile/sniper_rifle/dropped(mob/living/user)
zoom(user,FALSE)
azoom.Remove(user)
/obj/item/weapon/gun/projectile/sniper_rifle/pickup(mob/living/user)
azoom.Grant(user)
/obj/item/weapon/gun/projectile/sniper_rifle/proc/zoom(mob/living/user, forced_zoom)
if(!user || !user.client)
return
switch(forced_zoom)
if(FALSE)
zoomed = FALSE
if(TRUE)
zoomed = TRUE
else
zoomed = !zoomed
if(zoomed)
var/_x = 0
var/_y = 0
switch(user.dir)
if(NORTH)
_y = zoom_amt
if(EAST)
_x = zoom_amt
if(SOUTH)
_y = -zoom_amt
if(WEST)
_x = -zoom_amt
user.client.pixel_x = world.icon_size*_x
user.client.pixel_y = world.icon_size*_y
else
user.client.pixel_x = 0
user.client.pixel_y = 0
/datum/action/sniper_zoom
name = "Zoom Sniper Rifle"
check_flags = AB_CHECK_ALIVE|AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING
button_icon_state = "sniper_zoom"
var/obj/item/weapon/gun/projectile/sniper_rifle/rifle = null
/datum/action/sniper_zoom/Trigger()
rifle.zoom(owner)
/datum/action/sniper_zoom/IsAvailable()
. = ..()
if(!. && rifle)
rifle.zoom(owner, FALSE)
/datum/action/sniper_zoom/Remove(mob/living/L)
rifle.zoom(L, FALSE)
..()