Polishes up the reset_view proc, which is basically

`reset_perspective` from tgstation.

Also adds various support for remote viewing lenses - like cameras not
transmitting xray vision, among other things

Recommit because we're using different compiler versions
This commit is contained in:
Crazylemon64
2016-12-21 17:56:57 -08:00
parent 94a6caa4b5
commit 6d3e66f41c
57 changed files with 506 additions and 411 deletions
@@ -1,6 +0,0 @@
/mob/living/carbon/alien/humanoid/Login()
..()
if(!isturf(loc))
client.eye = loc
client.perspective = EYE_PERSPECTIVE
return
+26 -16
View File
@@ -31,21 +31,31 @@
return 1
/mob/living/carbon/alien/update_sight()
if(stat == DEAD || (XRAY in mutations))
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
if(!client)
return
if(stat == DEAD)
grant_death_vision()
return
sight = SEE_MOBS
if(nightvision)
see_in_dark = 8
see_invisible = SEE_INVISIBLE_MINIMUM
else
see_in_dark = 4
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else if(stat != DEAD)
sight |= SEE_MOBS
sight &= ~SEE_TURFS
sight &= ~SEE_OBJS
if(nightvision)
see_in_dark = 8
see_invisible = SEE_INVISIBLE_MINIMUM
else if(!nightvision)
see_in_dark = 4
see_invisible = 45
if(see_override)
see_invisible = see_override
if(client.eye != src)
var/atom/A = client.eye
if(A.update_remote_sight(src)) //returns 1 if we override all other sight updates.
return
for(var/obj/item/organ/internal/cyberimp/eyes/E in internal_organs)
sight |= E.vision_flags
if(E.dark_view)
see_in_dark = max(see_in_dark, E.dark_view)
if(E.see_invisible)
see_invisible = min(see_invisible, E.see_invisible)
if(see_override)
see_invisible = see_override
@@ -62,22 +62,5 @@
. = 1
/mob/living/carbon/brain/handle_vision()
..()
if(stat == 2 || (XRAY in src.mutations))
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else if(stat != 2)
sight &= ~SEE_TURFS
sight &= ~SEE_MOBS
sight &= ~SEE_OBJS
see_in_dark = 2
see_invisible = SEE_INVISIBLE_LIVING
handle_hud_icons_health()
/mob/living/carbon/brain/breathe()
return
+46
View File
@@ -1039,3 +1039,49 @@ so that different stomachs can handle things in different ways VB*/
/mob/living/carbon/proc/update_internals_hud_icon(internal_state = 0)
if(hud_used && hud_used.internals)
hud_used.internals.icon_state = "internal[internal_state]"
//to recalculate and update the mob's total tint from tinted equipment it's wearing.
/mob/living/carbon/proc/update_tint()
if(!tinted_weldhelh)
return
var/tinttotal = get_total_tint()
if(tinttotal >= TINT_BLIND)
overlay_fullscreen("tint", /obj/screen/fullscreen/blind)
else if(tinttotal >= TINT_IMPAIR)
overlay_fullscreen("tint", /obj/screen/fullscreen/impaired, 2)
else
clear_fullscreen("tint", 0)
/mob/living/carbon/proc/get_total_tint()
. = 0
if(istype(head, /obj/item/clothing/head))
var/obj/item/clothing/head/HT = head
. += HT.tint
if(wear_mask)
. += wear_mask.tint
/mob/living/carbon/human/get_total_tint()
. = ..()
if(glasses)
var/obj/item/clothing/glasses/G = glasses
. += G.tint
//handle stuff to update when a mob equips/unequips a mask.
/mob/living/proc/wear_mask_update(obj/item/clothing/C, toggle_off = 1)
update_inv_wear_mask()
/mob/living/carbon/wear_mask_update(obj/item/clothing/C, toggle_off = 1)
if(C.tint || initial(C.tint))
update_tint()
update_inv_wear_mask()
//handle stuff to update when a mob equips/unequips a headgear.
/mob/living/carbon/proc/head_update(obj/item/I, forced)
if(istype(I, /obj/item/clothing))
var/obj/item/clothing/C = I
if(C.tint || initial(C.tint))
update_tint()
if(I.flags_inv & HIDEMASK || forced)
update_inv_wear_mask()
update_inv_head()
@@ -724,6 +724,17 @@
if(istype(id))
return id
/mob/living/carbon/human/update_sight()
if(!client)
return
if(stat == DEAD)
grant_death_vision()
return
species.update_sight(src)
//Removed the horrible safety parameter. It was only being used by ninja code anyways.
//Now checks siemens_coefficient of the affected area by default
/mob/living/carbon/human/electrocute_act(shock_damage, obj/source, siemens_coeff = 1, safety = 0, override = 0, tesla_shock = 0)
@@ -111,6 +111,13 @@
update_inv_gloves()
else if(I == glasses)
glasses = null
var/obj/item/clothing/glasses/G = I
if(G.tint)
update_tint()
if(G.prescription)
clear_fullscreen("nearsighted")
if(G.vision_flags || G.darkness_view || G.invis_override || G.invis_view)
update_sight()
update_inv_glasses()
else if(I == head)
head = null
@@ -118,6 +125,7 @@
update_hair() //rebuild hair
update_fhair()
update_head_accessory()
head_update(I)
update_inv_head()
else if(I == r_ear)
r_ear = null
@@ -140,6 +148,7 @@
if(internal)
internal = null
update_internals_hud_icon(0)
wear_mask_update(I, toggle_off = FALSE)
sec_hud_set_ID()
update_inv_wear_mask()
else if(I == wear_id)
@@ -203,6 +212,7 @@
update_head_accessory(redraw_mob)
if(hud_list.len)
sec_hud_set_ID()
wear_mask_update(W, toggle_off = TRUE)
update_inv_wear_mask(redraw_mob)
if(slot_handcuffed)
handcuffed = W
@@ -247,6 +257,14 @@
update_inv_ears(redraw_mob)
if(slot_glasses)
glasses = W
var/obj/item/clothing/glasses/G = W
if(G.tint)
update_tint()
if(G.prescription)
if(disabilities & NEARSIGHTED)
overlay_fullscreen("nearsighted", /obj/screen/fullscreen/impaired, 1)
if(G.vision_flags || G.darkness_view || G.invis_override || G.invis_view)
update_sight()
update_inv_glasses(redraw_mob)
if(slot_gloves)
gloves = W
@@ -257,6 +275,7 @@
update_hair(redraw_mob) //rebuild hair
update_fhair(redraw_mob)
update_head_accessory(redraw_mob)
head_update(W)
update_inv_head(redraw_mob)
if(slot_shoes)
shoes = W
@@ -1,8 +1,5 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32
#define TINT_IMPAIR 2 //Threshold of tint level to apply weld mask overlay
#define TINT_BLIND 3 //Threshold of tint level to obscure vision fully
/mob/living/carbon/human
var/pressure_alert = 0
@@ -12,11 +9,9 @@
var/exposedtimenow = 0
var/firstexposed = 0
var/heartbeat = 0
var/tinttotal = 0 // Total level of visually impairing items
/mob/living/carbon/human/Life()
fire_alert = 0 //Reset this here, because both breathe() and handle_environment() have a chance to set it.
tinttotal = tintcheck() //here as both hud updates and status updates call it
life_tick++
in_stasis = 0
@@ -46,6 +46,7 @@
var/siemens_coeff = 1 //base electrocution coefficient
var/invis_sight = SEE_INVISIBLE_LIVING
var/darksight = 2
var/hazard_high_pressure = HAZARD_HIGH_PRESSURE // Dangerously high pressure.
var/warning_high_pressure = WARNING_HIGH_PRESSURE // High pressure warning.
@@ -506,15 +507,6 @@
H.see_invisible = SEE_INVISIBLE_LIVING
H.seer = 0
//This checks how much the mob's eyewear impairs their vision
if(H.tinttotal >= TINT_IMPAIR)
if(tinted_weldhelh)
H.overlay_fullscreen("tint", /obj/screen/fullscreen/impaired, 2)
if(H.tinttotal >= TINT_BLIND)
H.EyeBlind(1)
else
H.clear_fullscreen("tint")
var/minimum_darkness_view = INFINITY
if(H.glasses)
if(istype(H.glasses, /obj/item/clothing/glasses))
@@ -684,3 +676,37 @@ It'll return null if the organ doesn't correspond, so include null checks when u
if(!(organ_slot in has_organ))
return null
return has_organ[organ_slot]
/datum/species/proc/update_sight(mob/living/carbon/human/H)
H.sight = initial(H.sight)
H.see_in_dark = darksight
H.see_invisible = invis_sight
if(H.client.eye != H)
var/atom/A = H.client.eye
if(A.update_remote_sight(H)) //returns 1 if we override all other sight updates.
return
for(var/obj/item/organ/internal/cyberimp/eyes/E in H.internal_organs)
H.sight |= E.vision_flags
if(E.dark_view)
H.see_in_dark = E.dark_view
if(E.see_invisible)
H.see_invisible = min(H.see_invisible, E.see_invisible)
if(H.glasses)
var/obj/item/clothing/glasses/G = H.glasses
H.sight |= G.vision_flags
H.see_in_dark = max(G.darkness_view, H.see_in_dark)
if(G.invis_override)
H.see_invisible = G.invis_override
else
H.see_invisible = min(G.invis_view, H.see_invisible)
if(XRAY in H.mutations)
H.sight |= (SEE_TURFS|SEE_MOBS|SEE_OBJS)
H.see_in_dark = max(H.see_in_dark, 8)
if(H.see_override) //Override all
H.see_invisible = H.see_override
+24 -18
View File
@@ -409,27 +409,33 @@
return 1
/mob/living/carbon/update_sight()
if(!client)
return
if(stat == DEAD)
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else
sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS)
if(XRAY in mutations)
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
grant_death_vision()
return
else
see_in_dark = 2
see_invisible = SEE_INVISIBLE_LIVING
see_invisible = initial(see_invisible)
see_in_dark = initial(see_in_dark)
sight = initial(sight)
if(see_override)
see_invisible = see_override
if(XRAY in mutations)
grant_xray_vision()
if(client.eye != src)
var/atom/A = client.eye
if(A.update_remote_sight(src)) //returns 1 if we override all other sight updates.
return
for(var/obj/item/organ/internal/cyberimp/eyes/E in internal_organs)
sight |= E.vision_flags
if(E.dark_view)
see_in_dark = max(see_in_dark,E.dark_view)
if(E.see_invisible)
see_invisible = min(see_invisible, E.see_invisible)
if(see_override)
see_invisible = see_override
/mob/living/carbon/handle_hud_icons()
+18
View File
@@ -238,6 +238,24 @@
/mob/living/proc/update_sight()
return
// Gives a mob the vision of being dead
/mob/living/proc/grant_death_vision()
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_OBSERVER
// See through walls, dark, etc.
// basically the same as death vision except you can't
// see ghosts
/mob/living/proc/grant_xray_vision()
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
/mob/living/proc/handle_hud_icons()
handle_hud_icons_health()
return
+8 -1
View File
@@ -1163,4 +1163,11 @@ var/list/ai_verbs_default = list(
to_chat(src, "You are also capable of hacking APCs, which grants you more points to spend on your Malfunction powers. The drawback is that a hacked APC will give you away if spotted by the crew. Hacking an APC takes 60 seconds.")
view_core() //A BYOND bug requires you to be viewing your core before your verbs update
verbs += /mob/living/silicon/ai/proc/choose_modules
malf_picker = new /datum/module_picker
malf_picker = new /datum/module_picker
/mob/living/silicon/ai/reset_view(atom/A)
if(camera_light_on)
light_cameras()
if(istype(A, /obj/machinery/camera))
current = A
. = ..()
+38 -35
View File
@@ -1,3 +1,8 @@
#define POWER_RESTORATION_OFF 0
#define POWER_RESTORATION_START 1
#define POWER_RESTORATION_SEARCH_APC 2
#define POWER_RESTORATION_APC_FOUND 3
/mob/living/silicon/ai/Life()
//doesn't call parent because it's a horrible mess
if(stat == DEAD)
@@ -16,11 +21,16 @@
death()
return 0
if(malfhack)
if(malfhack.aidisabled)
to_chat(src, "<span class='danger'>ERROR: APC access disabled, hack attempt canceled.</span>")
malfhacking = 0
malfhack = null
if(!eyeobj || qdeleted(eyeobj) || !eyeobj.loc)
view_core()
if(machine)
machine.check_eye(src)
if(malfhack && malfhack.aidisabled)
to_chat(src, "<span class='danger'>ERROR: APC access disabled, hack attempt canceled.</span>")
malfhacking = 0
malfhack = null
if(aiRestorePowerRoutine)
adjustOxyLoss(1)
@@ -29,22 +39,9 @@
handle_stunned()
var/is_blind = 0 //THIS WAS JUST FUCKING 'blind' WHICH CONFLICTED WITH A NORMAL VARIABLE
var/area/my_area = get_area(src)
if(istype(my_area))
if(!my_area.power_equip && !is_type_in_list(loc, list(/obj/item, /obj/mecha)))
is_blind = 1 //HOW THE FUCK DID THAT EVEN COMPILE JESUS CHRIST
if(!is_blind)
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
if(see_override)
see_invisible = see_override
if(!lacks_power())
if(aiRestorePowerRoutine == 2)
to_chat(src, "Alert cancelled. Power has been restored without our assistance.")
@@ -57,18 +54,12 @@
else
sight &= ~SEE_TURFS
sight &= ~SEE_MOBS
sight &= ~SEE_OBJS
overlay_fullscreen("blind", /obj/screen/fullscreen/blind)
see_in_dark = 0
see_invisible = SEE_INVISIBLE_LIVING
if(((!my_area.power_equip) || istype(T, /turf/space)) && !is_type_in_list(loc, list(/obj/item, /obj/mecha)))
if(lacks_power())
if(!aiRestorePowerRoutine)
aiRestorePowerRoutine = 1
update_sight()
to_chat(src, "<span class='danger'>You have lost power!</span>")
if(!is_special_character(src))
set_zeroth_law("")
@@ -78,7 +69,7 @@
sleep(50)
my_area = get_area(src)
T = get_turf(src)
if(my_area && my_area.power_equip && !istype(T, /turf/space))
if(!lacks_power())
to_chat(src, "Alert cancelled. Power has been restored without our assistance.")
aiRestorePowerRoutine = 0
return
@@ -115,12 +106,11 @@
aiRestorePowerRoutine = 2
return
if(my_area.power_equip)
if(!istype(T, /turf/space))
to_chat(src, "Alert cancelled. Power has been restored without our assistance.")
aiRestorePowerRoutine = 0
clear_fullscreen("blind")
return
if(!lacks_power())
to_chat(src, "Alert cancelled. Power has been restored without our assistance.")
aiRestorePowerRoutine = 0
clear_fullscreen("blind")
return
switch(PRP)
if(1)
@@ -170,4 +160,17 @@
if(client)
var/client/C = client
for(var/mob/living/carbon/human/H in view(eyeobj, 14))
C.images += H.hud_list[NATIONS_HUD]
C.images += H.hud_list[NATIONS_HUD]
/mob/living/silicon/ai/update_sight()
see_invisible = initial(see_invisible)
see_in_dark = initial(see_in_dark)
sight = initial(sight)
if(aiRestorePowerRoutine)
sight = sight&~SEE_TURFS
sight = sight&~SEE_MOBS
sight = sight&~SEE_OBJS
see_in_dark = 0
if(see_override)
see_invisible = see_override
+1 -5
View File
@@ -2,9 +2,5 @@
..()
for(var/obj/machinery/ai_status_display/O in world) //change status
O.mode = 0
if(!isturf(loc))
if(client)
client.eye = loc
client.perspective = EYE_PERSPECTIVE
src.view_core()
return
return
+1 -6
View File
@@ -363,9 +363,6 @@
var/obj/item/device/pda/holder = card.loc
holder.pai = null
if(client)
client.perspective = EYE_PERSPECTIVE
client.eye = src
forceMove(get_turf(card))
card.forceMove(src)
@@ -487,9 +484,7 @@
visible_message("<span class=notice>[src] neatly folds inwards, compacting down to a rectangular card.</span>", "<span class=notice>You neatly fold inwards, compacting down to a rectangular card.</span>")
stop_pulling()
if(client)
client.perspective = EYE_PERSPECTIVE
client.eye = card
reset_view(card)
// If we are being held, handle removing our holder from their inv.
var/obj/item/weapon/holder/H = loc
@@ -17,6 +17,7 @@
if(istype(O,/obj/item/borg/sight))
var/obj/item/borg/sight/S = O
sight_mode &= ~S.sight_mode
update_sight()
if(client)
client.screen -= O
@@ -52,6 +53,7 @@
if((cell.charge * 100 / cell.maxcharge) < B.powerneeded)
to_chat(src, "Not enough power to activate [B.name]!")
return
var/activated_thingy = null
if(!module_state_1)
O.mouse_opacity = initial(O.mouse_opacity)
module_state_1 = O
@@ -59,8 +61,7 @@
O.plane = HUD_PLANE
O.screen_loc = inv1.screen_loc
contents += O
if(istype(module_state_1,/obj/item/borg/sight))
sight_mode |= module_state_1:sight_mode
activated_thingy = O
else if(!module_state_2)
O.mouse_opacity = initial(O.mouse_opacity)
module_state_2 = O
@@ -68,8 +69,7 @@
O.plane = HUD_PLANE
O.screen_loc = inv2.screen_loc
contents += O
if(istype(module_state_2,/obj/item/borg/sight))
sight_mode |= module_state_2:sight_mode
activated_thingy = O
else if(!module_state_3)
O.mouse_opacity = initial(O.mouse_opacity)
module_state_3 = O
@@ -77,11 +77,12 @@
O.plane = HUD_PLANE
O.screen_loc = inv3.screen_loc
contents += O
if(istype(module_state_3,/obj/item/borg/sight))
sight_mode |= module_state_3:sight_mode
activated_thingy = O
else
to_chat(src, "You need to disable a module first!")
src.update_icons()
if(istype(activated_thingy,/obj/item/borg/sight))
update_sight()
update_icons()
/mob/living/silicon/robot/proc/uneq_active()
uneq_module(module_active)
+29 -23
View File
@@ -120,32 +120,38 @@
return 1
/mob/living/silicon/robot/update_sight()
if(stat == DEAD || sight_mode & BORGXRAY)
if(!client)
return
if(stat == DEAD)
grant_death_vision()
return
see_invisible = initial(see_invisible)
see_in_dark = initial(see_in_dark)
sight = initial(sight)
if(client.eye != src)
var/atom/A = client.eye
if(A.update_remote_sight(src)) //returns 1 if we override all other sight updates.
return
if(sight_mode & BORGMESON)
sight |= SEE_TURFS
see_invisible = min(see_invisible, SEE_INVISIBLE_MINIMUM)
see_in_dark = 1
if(sight_mode & BORGXRAY)
sight |= (SEE_TURFS|SEE_MOBS|SEE_OBJS)
see_invisible = SEE_INVISIBLE_LIVING
see_in_dark = 8
if(sight_mode & BORGTHERM)
sight |= SEE_MOBS
sight |= SEE_OBJS
see_invisible = min(see_invisible, SEE_INVISIBLE_LIVING)
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else
see_in_dark = 8
if(sight_mode & BORGMESON && sight_mode & BORGTHERM)
sight |= SEE_TURFS
sight |= SEE_MOBS
see_invisible = SEE_INVISIBLE_MINIMUM
else if(sight_mode & BORGMESON)
sight |= SEE_TURFS
see_invisible = SEE_INVISIBLE_MINIMUM
see_in_dark = 1
else if(sight_mode & BORGTHERM)
sight |= SEE_MOBS
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else if(stat != DEAD)
sight &= ~SEE_MOBS
sight &= ~SEE_TURFS
sight &= ~SEE_OBJS
see_invisible = SEE_INVISIBLE_LEVEL_TWO
if(see_override)
see_invisible = see_override
if(see_override)
see_invisible = see_override
/mob/living/silicon/robot/handle_hud_icons()
update_items()
@@ -393,9 +393,8 @@
passenger = M
load = M
can_buckle = FALSE
if(M.client)
M.client.perspective = EYE_PERSPECTIVE
M.client.eye = src
// Not sure why this is done
reset_view(src)
return TRUE
return FALSE
@@ -423,9 +422,7 @@
if(ismob(load))
var/mob/M = load
if(M.client)
M.client.perspective = MOB_PERSPECTIVE
M.client.eye = M
M.reset_view(null)
unbuckle_mob()
if(load)
@@ -452,9 +449,7 @@
AM.pixel_y = initial(AM.pixel_y)
if(ismob(AM))
var/mob/M = AM
if(M.client)
M.client.perspective = MOB_PERSPECTIVE
M.client.eye = M
M.reset_view(null)
/mob/living/simple_animal/bot/mulebot/call_bot()
..()
@@ -706,6 +706,22 @@
/mob/living/simple_animal/proc/sentience_act() //Called when a simple animal gains sentience via gold slime potion
return
/mob/living/simple_animal/update_sight()
if(!client)
return
if(stat == DEAD)
grant_death_vision()
return
see_invisible = initial(see_invisible)
see_in_dark = initial(see_in_dark)
sight = initial(sight)
if(client.eye != src)
var/atom/A = client.eye
if(A.update_remote_sight(src)) //returns 1 if we override all other sight updates.
return
/mob/living/simple_animal/SetEarDamage()
return
+1 -6
View File
@@ -43,12 +43,7 @@
sight |= SEE_SELF
..()
if(loc && !isturf(loc))
client.eye = loc
client.perspective = EYE_PERSPECTIVE
else
client.eye = src
client.perspective = MOB_PERSPECTIVE
reset_view(loc)
if(ckey in deadmins)
+27 -1
View File
@@ -487,6 +487,7 @@ var/list/slot_equipment_priority = list( \
return 0 //Unsupported slot
//END HUMAN
// If you're looking for `reset_perspective`, that's a synonym for this proc.
/mob/proc/reset_view(atom/A)
if(client)
if(istype(A, /atom/movable))
@@ -499,8 +500,33 @@ var/list/slot_equipment_priority = list( \
else
client.perspective = EYE_PERSPECTIVE
client.eye = loc
return
return 1
/mob/living/reset_view(atom/A)
. = ..()
if(.)
// Above check means the mob has a client
update_sight()
if(client.eye != src)
var/atom/AT = client.eye
AT.get_remote_view_fullscreens(src)
else
clear_fullscreen("remote_view", 0)
update_pipe_vision()
/mob/dead/reset_view(atom/A)
if(client)
if(ismob(client.eye) && (client.eye != src))
// Note to self: Use `client.eye` for ghost following in place
// of periodic ghost updates
var/mob/target = client.eye
target.following_mobs -= src
. = ..()
if(.)
// Allows sharing HUDs with ghosts
if(hud_used)
client.screen = list()
hud_used.show_hud(hud_used.hud_version)
/mob/proc/show_inv(mob/user)
user.set_machine(src)