mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 19:22:56 +00:00
Zooming with an item is now done with a general proc zoom(). This applies to binoculars and sniper rifle.
This commit is contained in:
@@ -38,6 +38,8 @@
|
|||||||
var/armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0)
|
var/armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0)
|
||||||
var/list/allowed = null //suit storage stuff.
|
var/list/allowed = null //suit storage stuff.
|
||||||
var/obj/item/device/uplink/hidden/hidden_uplink = null // All items can have an uplink hidden inside, just remember to add the triggers.
|
var/obj/item/device/uplink/hidden/hidden_uplink = null // All items can have an uplink hidden inside, just remember to add the triggers.
|
||||||
|
var/zoomdevicename = null //name used for message when binoculars/scope is used
|
||||||
|
var/zoom = 0 //1 if item is actively being used to zoom. For scoped guns and binoculars.
|
||||||
|
|
||||||
/* Species-specific sprites, concept stolen from Paradise//vg/.
|
/* Species-specific sprites, concept stolen from Paradise//vg/.
|
||||||
ex:
|
ex:
|
||||||
@@ -218,6 +220,11 @@
|
|||||||
// apparently called whenever an item is removed from a slot, container, or anything else.
|
// apparently called whenever an item is removed from a slot, container, or anything else.
|
||||||
/obj/item/proc/dropped(mob/user as mob)
|
/obj/item/proc/dropped(mob/user as mob)
|
||||||
..()
|
..()
|
||||||
|
if(zoom) //binoculars, scope, etc
|
||||||
|
user.client.view = world.view
|
||||||
|
user.client.pixel_x = 0
|
||||||
|
user.client.pixel_y = 0
|
||||||
|
zoom = 0
|
||||||
|
|
||||||
// called just as an item is picked up (loc is not yet changed)
|
// called just as an item is picked up (loc is not yet changed)
|
||||||
/obj/item/proc/pickup(mob/user)
|
/obj/item/proc/pickup(mob/user)
|
||||||
@@ -619,3 +626,78 @@
|
|||||||
var/obj/item/I = get_active_hand()
|
var/obj/item/I = get_active_hand()
|
||||||
if(I && !I.abstract)
|
if(I && !I.abstract)
|
||||||
I.showoff(src)
|
I.showoff(src)
|
||||||
|
|
||||||
|
/*
|
||||||
|
For zooming with scope or binoculars. 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/proc/zoom(var/tileoffset = 11,var/viewsize = 12) //tileoffset is client view offset in the direction the user is facing. viewsize is how far out this thing zooms. 7 is normal view
|
||||||
|
|
||||||
|
var/devicename
|
||||||
|
|
||||||
|
if(zoomdevicename)
|
||||||
|
devicename = zoomdevicename
|
||||||
|
else
|
||||||
|
devicename = src.name
|
||||||
|
|
||||||
|
var/cannotzoom
|
||||||
|
|
||||||
|
if(usr.stat || !(istype(usr,/mob/living/carbon/human)))
|
||||||
|
usr << "You are unable to focus through the [devicename]"
|
||||||
|
cannotzoom = 1
|
||||||
|
else if(!zoom && global_hud.darkMask[1] in usr.client.screen)
|
||||||
|
usr << "Your welding equipment gets in the way of you looking through the [devicename]"
|
||||||
|
cannotzoom = 1
|
||||||
|
else if(!zoom && usr.get_active_hand() != src)
|
||||||
|
usr << "You are too distracted to look through the [devicename], perhaps if it was in your active hand this might work better"
|
||||||
|
cannotzoom = 1
|
||||||
|
|
||||||
|
if(!zoom && !cannotzoom)
|
||||||
|
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
|
||||||
|
|
||||||
|
usr.visible_message("[usr] peers through the [devicename].")
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(istype(usr,/mob/living/carbon/human/))
|
||||||
|
var/mob/living/carbon/human/H = usr
|
||||||
|
usr.visible_message("[usr] holds [devicename] up to [H.get_visible_gender() == MALE ? "his" : H.get_visible_gender() == FEMALE ? "her" : "their"] eyes.")
|
||||||
|
else
|
||||||
|
usr.visible_message("[usr] holds [devicename] 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
|
||||||
|
|
||||||
|
if(!cannotzoom)
|
||||||
|
usr.visible_message("[usr] lowers the [devicename].")
|
||||||
|
|
||||||
|
return
|
||||||
@@ -13,82 +13,6 @@
|
|||||||
|
|
||||||
//matter = list("metal" = 50,"glass" = 50)
|
//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 = 0
|
|
||||||
|
|
||||||
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)
|
/obj/item/device/binoculars/attack_self(mob/user)
|
||||||
zoom()
|
zoom()
|
||||||
@@ -1301,7 +1301,13 @@
|
|||||||
if(!druggy) see_invisible = SEE_INVISIBLE_LEVEL_TWO
|
if(!druggy) see_invisible = SEE_INVISIBLE_LEVEL_TWO
|
||||||
if(healths) healths.icon_state = "health7" //DEAD healthmeter
|
if(healths) healths.icon_state = "health7" //DEAD healthmeter
|
||||||
if(client)
|
if(client)
|
||||||
if(client.view != world.view)
|
if(client.view != world.view) // If mob moves while zoomed in with device, unzoom them.
|
||||||
|
for(var/obj/item/item in contents)
|
||||||
|
if(item.zoom)
|
||||||
|
item.zoom()
|
||||||
|
break
|
||||||
|
|
||||||
|
/*
|
||||||
if(locate(/obj/item/weapon/gun/energy/sniperrifle, contents))
|
if(locate(/obj/item/weapon/gun/energy/sniperrifle, contents))
|
||||||
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)
|
||||||
@@ -1310,6 +1316,7 @@
|
|||||||
var/obj/item/device/binoculars/b = locate() in src
|
var/obj/item/device/binoculars/b = locate() in src
|
||||||
if(b.zoom)
|
if(b.zoom)
|
||||||
b.zoom()
|
b.zoom()
|
||||||
|
*/
|
||||||
|
|
||||||
else
|
else
|
||||||
sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS)
|
sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS)
|
||||||
|
|||||||
@@ -189,7 +189,12 @@
|
|||||||
Process_Incorpmove(direct)
|
Process_Incorpmove(direct)
|
||||||
return
|
return
|
||||||
if(mob.client)
|
if(mob.client)
|
||||||
if(mob.client.view != world.view)
|
if(mob.client.view != world.view) // If mob moves while zoomed in with device, unzoom them.
|
||||||
|
for(var/obj/item/item in mob.contents)
|
||||||
|
if(item.zoom)
|
||||||
|
item.zoom()
|
||||||
|
break
|
||||||
|
/*
|
||||||
if(locate(/obj/item/weapon/gun/energy/sniperrifle, mob.contents)) // If mob moves while zoomed in with sniper rifle, unzoom them.
|
if(locate(/obj/item/weapon/gun/energy/sniperrifle, mob.contents)) // If mob moves while zoomed in with sniper rifle, unzoom them.
|
||||||
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)
|
||||||
@@ -198,6 +203,7 @@
|
|||||||
var/obj/item/device/binoculars/b = locate() in mob
|
var/obj/item/device/binoculars/b = locate() in mob
|
||||||
if(b.zoom)
|
if(b.zoom)
|
||||||
b.zoom()
|
b.zoom()
|
||||||
|
*/
|
||||||
|
|
||||||
if(Process_Grab()) return
|
if(Process_Grab()) return
|
||||||
|
|
||||||
|
|||||||
@@ -225,69 +225,11 @@ obj/item/weapon/gun/energy/staff/focus
|
|||||||
charge_cost = 250
|
charge_cost = 250
|
||||||
fire_delay = 35
|
fire_delay = 35
|
||||||
w_class = 4.0
|
w_class = 4.0
|
||||||
var/zoom = 0
|
zoomdevicename = "sniper scope"
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/sniperrifle/dropped(mob/user)
|
/obj/item/weapon/gun/energy/sniperrifle/verb/scope()
|
||||||
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/weapon/gun/energy/sniperrifle/verb/zoom()
|
|
||||||
set category = "Object"
|
set category = "Object"
|
||||||
set name = "Use Sniper Scope"
|
set name = "Use Scope"
|
||||||
set popup_menu = 1
|
set popup_menu = 1
|
||||||
|
|
||||||
if(usr.stat || !(istype(usr,/mob/living/carbon/human)))
|
zoom()
|
||||||
usr << "You are unable to focus down the scope of the rifle."
|
|
||||||
return
|
|
||||||
if(!zoom && global_hud.darkMask[1] in usr.client.screen)
|
|
||||||
usr << "Your welding equipment gets in the way of you looking down the scope"
|
|
||||||
return
|
|
||||||
if(!zoom && usr.get_active_hand() != src)
|
|
||||||
usr << "You are too distracted to look down the scope, 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 = 12
|
|
||||||
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
|
|
||||||
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 << "<font color='[zoom?"blue":"red"]'>Zoom mode [zoom?"en":"dis"]abled.</font>"
|
|
||||||
return
|
|
||||||
|
|||||||
Reference in New Issue
Block a user