mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
202 lines
5.7 KiB
Plaintext
202 lines
5.7 KiB
Plaintext
/mob/living/bot/cleanbot
|
|
name = "Cleanbot"
|
|
desc = "A little cleaning robot, he looks so excited!"
|
|
icon_state = "cleanbot0"
|
|
req_one_access = list(access_robotics, access_janitor)
|
|
botcard_access = list(access_janitor, access_maint_tunnels)
|
|
|
|
locked = 0 // Start unlocked so roboticist can set them to patrol.
|
|
wait_if_pulled = 1
|
|
min_target_dist = 0
|
|
|
|
var/cleaning = 0
|
|
var/screwloose = 0
|
|
var/oddbutton = 0
|
|
var/should_patrol = 0
|
|
var/blood = 1
|
|
var/list/target_types = list()
|
|
|
|
/mob/living/bot/cleanbot/New()
|
|
..()
|
|
get_targets()
|
|
|
|
/mob/living/bot/cleanbot/handleIdle()
|
|
if(!screwloose && !oddbutton && prob(5))
|
|
custom_emote(2, "makes an excited beeping booping sound!")
|
|
|
|
if(screwloose && prob(5)) // Make a mess
|
|
if(istype(loc, /turf/simulated))
|
|
var/turf/simulated/T = loc
|
|
T.wet_floor()
|
|
|
|
if(oddbutton && prob(5)) // Make a big mess
|
|
visible_message("Something flies out of [src]. He seems to be acting oddly.")
|
|
var/obj/effect/decal/cleanable/blood/gibs/gib = new /obj/effect/decal/cleanable/blood/gibs(loc)
|
|
ignore_list += gib
|
|
spawn(600)
|
|
ignore_list -= gib
|
|
|
|
/mob/living/bot/cleanbot/lookForTargets()
|
|
for(var/obj/effect/decal/cleanable/D in view(world.view, src)) // There was some odd code to make it start with nearest decals, it's unnecessary, this works
|
|
if(confirmTarget(D))
|
|
target = D
|
|
return
|
|
|
|
/mob/living/bot/cleanbot/confirmTarget(var/obj/effect/decal/cleanable/D)
|
|
if(!..())
|
|
return 0
|
|
for(var/T in target_types)
|
|
if(istype(D, T))
|
|
return 1
|
|
return 0
|
|
|
|
/mob/living/bot/cleanbot/handleAdjacentTarget()
|
|
if(get_turf(target) == src.loc)
|
|
UnarmedAttack(target)
|
|
|
|
/mob/living/bot/cleanbot/UnarmedAttack(var/obj/effect/decal/cleanable/D, var/proximity)
|
|
if(!..())
|
|
return
|
|
|
|
if(!istype(D))
|
|
return
|
|
|
|
if(D.loc != loc)
|
|
return
|
|
|
|
busy = 1
|
|
custom_emote(2, "begins to clean up \the [D]")
|
|
update_icons()
|
|
var/cleantime = istype(D, /obj/effect/decal/cleanable/dirt) ? 10 : 50
|
|
if(do_after(src, cleantime))
|
|
if(istype(loc, /turf/simulated))
|
|
var/turf/simulated/f = loc
|
|
f.dirt = 0
|
|
if(!D)
|
|
return
|
|
qdel(D)
|
|
if(D == target)
|
|
target = null
|
|
busy = 0
|
|
update_icons()
|
|
|
|
/mob/living/bot/cleanbot/explode()
|
|
on = 0
|
|
visible_message("<span class='danger'>[src] blows apart!</span>")
|
|
var/turf/Tsec = get_turf(src)
|
|
|
|
new /obj/item/weapon/reagent_containers/glass/bucket(Tsec)
|
|
new /obj/item/device/assembly/prox_sensor(Tsec)
|
|
if(prob(50))
|
|
new /obj/item/robot_parts/l_arm(Tsec)
|
|
|
|
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
|
s.set_up(3, 1, src)
|
|
s.start()
|
|
qdel(src)
|
|
return
|
|
|
|
/mob/living/bot/cleanbot/update_icons()
|
|
if(busy)
|
|
icon_state = "cleanbot-c"
|
|
else
|
|
icon_state = "cleanbot[on]"
|
|
|
|
/mob/living/bot/cleanbot/attack_hand(var/mob/user)
|
|
var/dat
|
|
dat += "<TT><B>Automatic Station Cleaner v1.0</B></TT><BR><BR>"
|
|
dat += "Status: <A href='?src=\ref[src];operation=start'>[on ? "On" : "Off"]</A><BR>"
|
|
dat += "Behaviour controls are [locked ? "locked" : "unlocked"]<BR>"
|
|
dat += "Maintenance panel is [open ? "opened" : "closed"]"
|
|
if(!locked || issilicon(user))
|
|
dat += "<BR>Cleans Blood: <A href='?src=\ref[src];operation=blood'>[blood ? "Yes" : "No"]</A><BR>"
|
|
dat += "<BR>Patrol station: <A href='?src=\ref[src];operation=patrol'>[should_patrol ? "Yes" : "No"]</A><BR>"
|
|
if(open && !locked)
|
|
dat += "Odd looking screw twiddled: <A href='?src=\ref[src];operation=screw'>[screwloose ? "Yes" : "No"]</A><BR>"
|
|
dat += "Weird button pressed: <A href='?src=\ref[src];operation=oddbutton'>[oddbutton ? "Yes" : "No"]</A>"
|
|
|
|
user << browse("<HEAD><TITLE>Cleaner v1.0 controls</TITLE></HEAD>[dat]", "window=autocleaner")
|
|
onclose(user, "autocleaner")
|
|
return
|
|
|
|
/mob/living/bot/cleanbot/Topic(href, href_list)
|
|
if(..())
|
|
return
|
|
usr.set_machine(src)
|
|
add_fingerprint(usr)
|
|
switch(href_list["operation"])
|
|
if("start")
|
|
if(on)
|
|
turn_off()
|
|
else
|
|
turn_on()
|
|
if("blood")
|
|
blood = !blood
|
|
get_targets()
|
|
if("patrol")
|
|
should_patrol = !should_patrol
|
|
patrol_path = null
|
|
if("screw")
|
|
screwloose = !screwloose
|
|
usr << "<span class='notice'>You twiddle the screw.</span>"
|
|
if("oddbutton")
|
|
oddbutton = !oddbutton
|
|
usr << "<span class='notice'>You press the weird button.</span>"
|
|
attack_hand(usr)
|
|
|
|
/mob/living/bot/cleanbot/emag_act(var/remaining_uses, var/mob/user)
|
|
. = ..()
|
|
if(!screwloose || !oddbutton)
|
|
if(user)
|
|
user << "<span class='notice'>The [src] buzzes and beeps.</span>"
|
|
oddbutton = 1
|
|
screwloose = 1
|
|
return 1
|
|
|
|
/mob/living/bot/cleanbot/proc/get_targets()
|
|
target_types = list()
|
|
|
|
target_types += /obj/effect/decal/cleanable/blood/oil
|
|
target_types += /obj/effect/decal/cleanable/vomit
|
|
target_types += /obj/effect/decal/cleanable/crayon
|
|
target_types += /obj/effect/decal/cleanable/liquid_fuel
|
|
target_types += /obj/effect/decal/cleanable/mucus
|
|
target_types += /obj/effect/decal/cleanable/dirt
|
|
|
|
if(blood)
|
|
target_types += /obj/effect/decal/cleanable/blood
|
|
|
|
/* Assembly */
|
|
|
|
/obj/item/weapon/bucket_sensor
|
|
desc = "It's a bucket. With a sensor attached."
|
|
name = "proxy bucket"
|
|
icon = 'icons/obj/aibots.dmi'
|
|
icon_state = "bucket_proxy"
|
|
force = 3.0
|
|
throwforce = 10.0
|
|
throw_speed = 2
|
|
throw_range = 5
|
|
w_class = 3.0
|
|
var/created_name = "Cleanbot"
|
|
|
|
/obj/item/weapon/bucket_sensor/attackby(var/obj/item/O, var/mob/user)
|
|
..()
|
|
if(istype(O, /obj/item/robot_parts/l_arm) || istype(O, /obj/item/robot_parts/r_arm))
|
|
user.drop_item()
|
|
qdel(O)
|
|
var/turf/T = get_turf(loc)
|
|
var/mob/living/bot/cleanbot/A = new /mob/living/bot/cleanbot(T)
|
|
A.name = created_name
|
|
user << "<span class='notice'>You add the robot arm to the bucket and sensor assembly. Beep boop!</span>"
|
|
user.drop_from_inventory(src)
|
|
qdel(src)
|
|
|
|
else if(istype(O, /obj/item/weapon/pen))
|
|
var/t = sanitizeSafe(input(user, "Enter new robot name", name, created_name), MAX_NAME_LEN)
|
|
if(!t)
|
|
return
|
|
if(!in_range(src, usr) && src.loc != usr)
|
|
return
|
|
created_name = t
|