Sniper rifle zoom now adds a client.pixel_x/y offset in addition to zoom. Currently 11 tiles in the direction the user is facing. Zooming can now be done through the right-click menu.

Binoculars added. Functionally similar to sniper scope. Adminspawn-only as of this commit.
This commit is contained in:
RavingManiac
2014-10-04 04:01:56 +08:00
parent 91d576e05a
commit f0da0380a5
6 changed files with 130 additions and 1 deletions

View File

@@ -486,6 +486,7 @@
#include "code\game\objects\items\toys.dm" #include "code\game\objects\items\toys.dm"
#include "code\game\objects\items\trash.dm" #include "code\game\objects\items\trash.dm"
#include "code\game\objects\items\devices\aicard.dm" #include "code\game\objects\items\devices\aicard.dm"
#include "code\game\objects\items\devices\binoculars.dm"
#include "code\game\objects\items\devices\chameleonproj.dm" #include "code\game\objects\items\devices\chameleonproj.dm"
#include "code\game\objects\items\devices\debugger.dm" #include "code\game\objects\items\devices\debugger.dm"
#include "code\game\objects\items\devices\flash.dm" #include "code\game\objects\items\devices\flash.dm"

View File

@@ -0,0 +1,94 @@
/obj/item/device/binoculars
name = "binoculars"
desc = "A pair of binoculars."
icon_state = "binoculars"
flags = FPRINT | TABLEPASS| CONDUCT
force = 5.0
w_class = 2.0
throwforce = 5.0
throw_range = 15
throw_speed = 3
//matter = list("metal" = 50,"glass" = 50)
var/tileoffset = 11 //client view offset in the direction the user is facing
var/viewsize = 12 //how far out this thing zooms. 7 is normal view
var/zoom = 0
/obj/item/device/binoculars/dropped(mob/user)
user.client.view = world.view
user.client.pixel_x = 0
user.client.pixel_y = 0
/*
This is called from
modules/mob/mob_movement.dm if you move you will be zoomed out
modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
*/
/obj/item/device/binoculars/verb/zoom()
set category = "Object"
set name = "Use"
set popup_menu = 1
if(usr.stat || !(istype(usr,/mob/living/carbon/human)))
usr << "You are unable to focus through the binoculars."
return
if(!zoom && global_hud.darkMask[1] in usr.client.screen)
usr << "Your welding equipment gets in the way of you looking through the binoculars"
return
if(!zoom && usr.get_active_hand() != src)
usr << "You are too distracted to look through the binoculars, perhaps if it was in your active hand this might work better"
return
if(usr.client.view == world.view)
if(!usr.hud_used.hud_shown)
usr.button_pressed_F12(1) // If the user has already limited their HUD this avoids them having a HUD when they zoom in
usr.button_pressed_F12(1)
usr.client.view = viewsize
zoom = 1
var/tilesize = 32
var/viewoffset = tilesize * tileoffset
switch(usr.dir)
if (NORTH)
usr.client.pixel_x = 0
usr.client.pixel_y = viewoffset
if (SOUTH)
usr.client.pixel_x = 0
usr.client.pixel_y = -viewoffset
if (EAST)
usr.client.pixel_x = viewoffset
usr.client.pixel_y = 0
if (WEST)
usr.client.pixel_x = -viewoffset
usr.client.pixel_y = 0
if(istype(usr,/mob/living/carbon/human/))
var/mob/living/carbon/human/H = usr
usr.visible_message("[usr] holds [src] up to [H.get_visible_gender() == MALE ? "his" : H.get_visible_gender() == FEMALE ? "her" : "their"] eyes.")
else
usr.visible_message("[usr] holds [src] up to its eyes.")
else
usr.client.view = world.view
if(!usr.hud_used.hud_shown)
usr.button_pressed_F12(1)
zoom = 0
usr.client.pixel_x = 0
usr.client.pixel_y = 0
usr.visible_message("[usr] lowers [src].")
return
/obj/item/device/binoculars/attack_self(mob/user)
zoom()

View File

@@ -1306,6 +1306,10 @@
var/obj/item/weapon/gun/energy/sniperrifle/s = locate() in src var/obj/item/weapon/gun/energy/sniperrifle/s = locate() in src
if(s.zoom) if(s.zoom)
s.zoom() s.zoom()
if(locate(/obj/item/device/binoculars, contents))
var/obj/item/device/binoculars/b = locate() in src
if(b.zoom)
b.zoom()
else else
sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS) sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS)

View File

@@ -194,6 +194,10 @@
var/obj/item/weapon/gun/energy/sniperrifle/s = locate() in mob var/obj/item/weapon/gun/energy/sniperrifle/s = locate() in mob
if(s.zoom) if(s.zoom)
s.zoom() s.zoom()
if(locate(/obj/item/device/binoculars, mob.contents)) // If mob moves while zoomed in with binoculars, unzoom them.
var/obj/item/device/binoculars/b = locate() in mob
if(b.zoom)
b.zoom()
if(Process_Grab()) return if(Process_Grab()) return

View File

@@ -229,6 +229,8 @@ obj/item/weapon/gun/energy/staff/focus
/obj/item/weapon/gun/energy/sniperrifle/dropped(mob/user) /obj/item/weapon/gun/energy/sniperrifle/dropped(mob/user)
user.client.view = world.view user.client.view = world.view
user.client.pixel_x = 0
user.client.pixel_y = 0
@@ -241,7 +243,8 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
/obj/item/weapon/gun/energy/sniperrifle/verb/zoom() /obj/item/weapon/gun/energy/sniperrifle/verb/zoom()
set category = "Object" set category = "Object"
set name = "Use Sniper Scope" set name = "Use Sniper Scope"
set popup_menu = 0 set popup_menu = 1
if(usr.stat || !(istype(usr,/mob/living/carbon/human))) if(usr.stat || !(istype(usr,/mob/living/carbon/human)))
usr << "You are unable to focus down the scope of the rifle." usr << "You are unable to focus down the scope of the rifle."
return return
@@ -258,10 +261,33 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
usr.button_pressed_F12(1) usr.button_pressed_F12(1)
usr.client.view = 12 usr.client.view = 12
zoom = 1 zoom = 1
var/tileoffset = 11 //client view offset in the direction the user is facing
var/tilesize = 32
var/viewoffset = tilesize * tileoffset
switch(usr.dir)
if (NORTH)
usr.client.pixel_x = 0
usr.client.pixel_y = viewoffset
if (SOUTH)
usr.client.pixel_x = 0
usr.client.pixel_y = -viewoffset
if (EAST)
usr.client.pixel_x = viewoffset
usr.client.pixel_y = 0
if (WEST)
usr.client.pixel_x = -viewoffset
usr.client.pixel_y = 0
else else
usr.client.view = world.view usr.client.view = world.view
if(!usr.hud_used.hud_shown) if(!usr.hud_used.hud_shown)
usr.button_pressed_F12(1) usr.button_pressed_F12(1)
zoom = 0 zoom = 0
usr.client.pixel_x = 0
usr.client.pixel_y = 0
usr << "<font color='[zoom?"blue":"red"]'>Zoom mode [zoom?"en":"dis"]abled.</font>" usr << "<font color='[zoom?"blue":"red"]'>Zoom mode [zoom?"en":"dis"]abled.</font>"
return return

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB