Merge pull request #8639 from mwerezak/holocarp-fix

Holopad fix, makes holodeck objects slightly transparent
This commit is contained in:
Chinsky
2015-03-27 20:57:30 +03:00
2 changed files with 32 additions and 25 deletions

View File

@@ -38,6 +38,10 @@ var/const/HOLOPAD_MODE = RANGE_BASED
layer = TURF_LAYER+0.1 //Preventing mice and drones from sneaking under them.
var/power_per_hologram = 500 //per usage per hologram
idle_power_usage = 5
use_power = 1
var/list/mob/living/silicon/ai/masters = new() //List of AIs that use the holopad
var/last_request = 0 //to prevent request spam. ~Carn
var/holo_range = 5 // Change to change how far the AI can move away from the holopad before deactivating.
@@ -122,7 +126,6 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
SetLuminosity(2) //pad lighting
icon_state = "holopad1"
A.holo = src
use_power += HOLOGRAM_POWER_USAGE
return 1
/obj/machinery/hologram/holopad/proc/clear_holo(mob/living/silicon/ai/user)
@@ -130,29 +133,31 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
user.holo = null
del(masters[user])//Get rid of user's hologram //qdel
masters -= user //Discard AI from the list of those who use holopad
use_power = max(HOLOPAD_PASSIVE_POWER_USAGE, use_power - HOLOGRAM_POWER_USAGE)//Reduce power usage
if (!masters.len)//If no users left
SetLuminosity(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted)
icon_state = "holopad0"
use_power = HOLOPAD_PASSIVE_POWER_USAGE
return 1
/obj/machinery/hologram/holopad/process()
for (var/mob/living/silicon/ai/master in masters)
if(master && !master.stat && master.client && master.eyeobj)//If there is an AI attached, it's not incapacitated, it has a client, and the client eye is centered on the projector.
if(!(stat & NOPOWER))//If the machine has power.
if((HOLOPAD_MODE == RANGE_BASED && (get_dist(master.eyeobj, src) <= holo_range)))
return 1
var/active_ai = (master && !master.stat && master.client && master.eyeobj)//If there is an AI attached, it's not incapacitated, it has a client, and the client eye is centered on the projector.
if((stat & NOPOWER) || !active_ai)
clear_holo(master)
continue
else if (HOLOPAD_MODE == AREA_BASED)
if((HOLOPAD_MODE == RANGE_BASED && (get_dist(master.eyeobj, src) > holo_range)))
clear_holo(master)
continue
if(HOLOPAD_MODE == AREA_BASED)
var/area/holo_area = get_area(src)
var/area/eye_area = get_area(master.eyeobj)
if(eye_area in holo_area.master.related)
return 1
if(!(eye_area in holo_area.master.related))
clear_holo(master)
continue
clear_holo(master)//If not, we want to get rid of the hologram.
use_power(power_per_hologram)
return 1
/obj/machinery/hologram/holopad/proc/move_hologram(mob/living/silicon/ai/user)

View File

@@ -28,7 +28,7 @@ var/global/list/holodeck_programs = list(
var/area/linkedholodeck = null
var/area/target = null
var/active = 0
var/list/holographic_items = list()
var/list/holographic_objs = list()
var/list/holographic_mobs = list()
var/damaged = 0
var/safety_disabled = 0
@@ -208,7 +208,7 @@ var/global/list/holodeck_programs = list(
emergencyShutdown()
/obj/machinery/computer/HolodeckControl/process()
for(var/item in holographic_items) // do this first, to make sure people don't take items out when power is down.
for(var/item in holographic_objs) // do this first, to make sure people don't take items out when power is down.
if(!(get_turf(item) in linkedholodeck))
derez(item, 0)
@@ -221,7 +221,7 @@ var/global/list/holodeck_programs = list(
if(!..())
return
if(active)
use_power(item_power_usage * (holographic_items.len + holographic_mobs.len))
use_power(item_power_usage * (holographic_objs.len + holographic_mobs.len))
if(!checkInteg(linkedholodeck))
damaged = 1
@@ -243,7 +243,7 @@ var/global/list/holodeck_programs = list(
T.hotspot_expose(1000,500,1)
/obj/machinery/computer/HolodeckControl/proc/derez(var/obj/obj , var/silent = 1)
holographic_items.Remove(obj)
holographic_objs.Remove(obj)
if(obj == null)
return
@@ -271,7 +271,7 @@ var/global/list/holodeck_programs = list(
if(toggleOn)
var/area/targetsource = locate(/area/holodeck/source_emptycourt)
holographic_items = targetsource.copy_contents_to(linkedholodeck)
holographic_objs = targetsource.copy_contents_to(linkedholodeck)
spawn(30)
for(var/obj/effect/landmark/L in linkedholodeck)
@@ -288,7 +288,7 @@ var/global/list/holodeck_programs = list(
active = 1
use_power = 2
else
for(var/item in holographic_items)
for(var/item in holographic_objs)
derez(item)
if(!linkedholodeck.has_gravity)
linkedholodeck.gravitychange(1,linkedholodeck)
@@ -313,7 +313,7 @@ var/global/list/holodeck_programs = list(
active = 1
use_power = 2
for(var/item in holographic_items)
for(var/item in holographic_objs)
derez(item)
for(var/mob/living/simple_animal/hostile/carp/holodeck/C in holographic_mobs)
@@ -323,7 +323,9 @@ var/global/list/holodeck_programs = list(
for(var/obj/effect/decal/cleanable/blood/B in linkedholodeck)
del(B)
holographic_items = A.copy_contents_to(linkedholodeck , 1)
holographic_objs = A.copy_contents_to(linkedholodeck , 1)
for(var/obj/holo_obj in holographic_objs)
holo_obj.alpha *= 0.8 //give holodeck objs a slight transparency
spawn(30)
for(var/obj/effect/landmark/L in linkedholodeck)
@@ -366,7 +368,7 @@ var/global/list/holodeck_programs = list(
/obj/machinery/computer/HolodeckControl/proc/emergencyShutdown()
//Get rid of any items
for(var/item in holographic_items)
for(var/item in holographic_objs)
derez(item)
for(var/mob/living/simple_animal/hostile/carp/holodeck/C in holographic_mobs)
holographic_mobs -= C