Files
Yogstation/code/game/machinery/ai_slipper.dm
phil235 c4c447a8dc Fixes hotspot having two New() procs.
Fixes many machines and a few structure not having a cooldown when attacked with an item.
Fixes not being able to eat or be facehugged when wearing riot helmet with visor up.
Fixes not being able to use child of the tool type for craft recipes requiring tools.
Tablecrafting failure message now tells you what caused the failure (missing tool, missing component)
Fixes fuego plasma burrito recipe.
Fixes being able to grab cups from water cooler with telekinesis, putting the cup directly in your hand.
Fixes golem appearing with their old human name for a split second.
Some changes to make code more OOP (take_damage() proc for barricade, shieldgen, etc)
Some tweaks to light tube building code.
2015-10-08 19:50:01 +02:00

123 lines
3.2 KiB
Plaintext

/obj/machinery/ai_slipper
name = "\improper AI liquid dispenser"
icon = 'icons/obj/device.dmi'
icon_state = "motion3"
layer = 3
anchored = 1
var/uses = 20
var/disabled = 1
var/lethal = 0
var/locked = 1
var/cooldown_time = 0
var/cooldown_timeleft = 0
var/cooldown_on = 0
req_access = list(access_ai_upload)
/obj/machinery/ai_slipper/power_change()
if(stat & BROKEN)
return
else
if( powered() )
stat &= ~NOPOWER
else
icon_state = "motion0"
stat |= NOPOWER
/obj/machinery/ai_slipper/proc/setState(enabled, uses)
src.disabled = disabled
src.uses = uses
src.power_change()
/obj/machinery/ai_slipper/attackby(obj/item/weapon/W, mob/user, params)
if(stat & (NOPOWER|BROKEN))
return
if (istype(user, /mob/living/silicon))
return src.attack_hand(user)
else // trying to unlock the interface
if (src.allowed(usr))
locked = !locked
user << "<span class='notice'>You [ locked ? "lock" : "unlock"] the device.</span>"
if (locked)
if (user.machine==src)
user.unset_machine()
user << browse(null, "window=ai_slipper")
else
if (user.machine==src)
src.attack_hand(usr)
else
user << "<span class='danger'>Access denied.</span>"
/obj/machinery/ai_slipper/attack_ai(mob/user)
return attack_hand(user)
/obj/machinery/ai_slipper/attack_hand(mob/user)
if(stat & (NOPOWER|BROKEN))
return
if ( (get_dist(src, user) > 1 ))
if (!istype(user, /mob/living/silicon))
user << text("Too far away.")
user.unset_machine()
user << browse(null, "window=ai_slipper")
return
user.set_machine(src)
var/loc = src.loc
if (istype(loc, /turf))
loc = loc:loc
if (!istype(loc, /area))
user << text("Turret badly positioned - loc.loc is [].", loc)
return
var/area/area = loc
var/t = "<TT><B>AI Liquid Dispenser</B> ([format_text(area.name)])<HR>"
if(src.locked && (!istype(user, /mob/living/silicon)))
t += "<I>(Swipe ID card to unlock control panel.)</I><BR>"
else
t += text("Dispenser [] - <A href='?src=\ref[];toggleOn=1'>[]?</a><br>\n", src.disabled?"deactivated":"activated", src, src.disabled?"Enable":"Disable")
t += text("Uses Left: [uses]. <A href='?src=\ref[src];toggleUse=1'>Activate the dispenser?</A><br>\n")
user << browse(t, "window=computer;size=575x450")
onclose(user, "computer")
return
/obj/machinery/ai_slipper/Topic(href, href_list)
if(..())
return
if (src.locked)
if (!istype(usr, /mob/living/silicon))
usr << "Control panel is locked!"
return
if (href_list["toggleOn"])
src.disabled = !src.disabled
icon_state = src.disabled? "motion0":"motion3"
if (href_list["toggleUse"])
if(cooldown_on || disabled)
return
else
PoolOrNew(/obj/effect/effect/foam, loc)
src.uses--
cooldown_on = 1
cooldown_time = world.timeofday + 100
slip_process()
return
src.attack_hand(usr)
return
/obj/machinery/ai_slipper/proc/slip_process()
while(cooldown_time - world.timeofday > 0)
var/ticksleft = cooldown_time - world.timeofday
if(ticksleft > 1e5)
cooldown_time = world.timeofday + 10 // midnight rollover
cooldown_timeleft = (ticksleft / 10)
sleep(5)
if (uses <= 0)
return
if (uses >= 0)
cooldown_on = 0
src.power_change()
return