Merge pull request #4581 from Ccomp5950/ai_apc_fix

APC-Rewrite AI fix.
This commit is contained in:
Chinsky
2014-03-14 18:24:43 +04:00
2 changed files with 47 additions and 2 deletions

View File

@@ -94,7 +94,7 @@ var/list/ai_list = list()
/mob/living/silicon/ai/proc/ai_camera_list, /mob/living/silicon/ai/proc/ai_network_change, \ /mob/living/silicon/ai/proc/ai_camera_list, /mob/living/silicon/ai/proc/ai_network_change, \
/mob/living/silicon/ai/proc/ai_statuschange, /mob/living/silicon/ai/proc/ai_hologram_change, \ /mob/living/silicon/ai/proc/ai_statuschange, /mob/living/silicon/ai/proc/ai_hologram_change, \
/mob/living/silicon/ai/proc/toggle_camera_light) /mob/living/silicon/ai/proc/toggle_camera_light)
if(!safety)//Only used by AIize() to successfully spawn an AI. if(!safety)//Only used by AIize() to successfully spawn an AI.
if (!B)//If there is no player/brain inside. if (!B)//If there is no player/brain inside.
@@ -116,6 +116,10 @@ var/list/ai_list = list()
job = "AI" job = "AI"
spawn(5)
new /obj/machinery/ai_powersupply(src)
hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudblank") hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudblank")
hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudblank") hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudblank")
hud_list[ID_HUD] = image('icons/mob/hud.dmi', src, "hudblank") hud_list[ID_HUD] = image('icons/mob/hud.dmi', src, "hudblank")
@@ -135,6 +139,37 @@ var/list/ai_list = list()
..() ..()
/*
The AI Power supply is a dummy object used for powering the AI since only machinery should be using power.
The alternative was to rewrite a bunch of AI code instead here we are.
*/
/obj/machinery/ai_powersupply
name="Power Supply"
active_power_usage=1000
use_power = 2
power_channel = EQUIP
var/mob/living/silicon/ai/powered_ai = null
invisibility = 100
/obj/machinery/ai_powersupply/New(var/mob/living/silicon/ai/ai=null)
powered_ai = ai
if(isnull(powered_ai))
Del()
loc = powered_ai.loc
use_power(1) // Just incase we need to wake up the power system.
..()
/obj/machinery/ai_powersupply/process()
if(!powered_ai || powered_ai.stat & DEAD)
Del()
if(!powered_ai.anchored)
loc = powered_ai.loc
use_power = 0
if(powered_ai.anchored)
use_power = 2
/mob/living/silicon/ai/verb/pick_icon() /mob/living/silicon/ai/verb/pick_icon()
set category = "AI Commands" set category = "AI Commands"
set name = "Set AI Core Display" set name = "Set AI Core Display"

View File

@@ -58,10 +58,20 @@
src.see_in_dark = 8 src.see_in_dark = 8
src.see_invisible = SEE_INVISIBLE_LEVEL_TWO src.see_invisible = SEE_INVISIBLE_LEVEL_TWO
//Congratulations! You've found a way for AI's to run without using power!
//Todo: Without snowflaking up master_controller procs find a way to make AI use_power but only when APC's clear the area usage the tick prior
// since mobs are in master_controller before machinery. We also have to do it in a manner where we don't reset the entire area's need to update
// the power usage.
//
// We can probably create a new machine that resides inside of the AI contents that uses power using the idle_usage of 1000 and nothing else and
// be fine.
/*
var/area/home = get_area(src) var/area/home = get_area(src)
if(!home) return//something to do with malf fucking things up I guess. <-- aisat is gone. is this still necessary? ~Carn if(!home) return//something to do with malf fucking things up I guess. <-- aisat is gone. is this still necessary? ~Carn
if(home.powered(EQUIP)) if(home.powered(EQUIP))
home.use_power(1000, EQUIP) home.use_power(1000, EQUIP)
*/
if (src:aiRestorePowerRoutine==2) if (src:aiRestorePowerRoutine==2)
src << "Alert cancelled. Power has been restored without our assistance." src << "Alert cancelled. Power has been restored without our assistance."
@@ -168,4 +178,4 @@
if(fire_res_on_core) if(fire_res_on_core)
health = 100 - getOxyLoss() - getToxLoss() - getBruteLoss() health = 100 - getOxyLoss() - getToxLoss() - getBruteLoss()
else else
health = 100 - getOxyLoss() - getToxLoss() - getFireLoss() - getBruteLoss() health = 100 - getOxyLoss() - getToxLoss() - getFireLoss() - getBruteLoss()