Files
CHOMPStation2/code/modules/mob/living/bot/cleanbot.dm
Leshana eb65ff2ed2 Ports the new parts of https://github.com/Baystation12/Baystation12/pull/15298 back to Polaris
* Changes navbeacons to no longer use radios (Doing so was slower and didn't really help anything) Note: var/freq remains for mapping compatibility until all maps are updated.
  * Fixes navbeacons to actually hide under flooring if you put plating over them.
  * Changed how navbeacons are mapped in.  Don't use the picky "code_txt" variable, instead use appropriate subtype.
  * Made useful reusable subtypes so you don't have to code in a type for every. single. one.
* Updated mulebot to use new navbeacon codes.
* Re-activate patrolling!  With the new navbeacons, bots with will_patrol can follow the patrol navbeacons.
  * Note: various "should_patrol" variables on each bot type unified under /mob/living/bot/var/will_patrol
* Securitrons (beepsky) got an overhaul to the new patrol routing.
  * Note: BayStation replaced the snowflake handcuffs code with acutal handcuffs.  Polaris handcuffs requiere a grab to work, so are more complicated.  Kept our existing attack code.
  * Behavior procs reorganized to use better movement detection and just be more flexible.
* Floorbot fixes & removal of bridgemode
  * Floorbot will now remove & replace broken floor tiles.
  * Floorbot will no longer decide its okay to pave over all of SPACE.
  * For the moment patching hull breaches is disabled, it is too laggy.
* Sundry bugfixes to all bots
  * Use forceMove() instead of setting loc
  * Use "\The [X]" message strings.
  * Pass target to do_after() when doing something to a target.
* Fixed events that were supposed to emag bots to now do so again.
2017-03-14 16:29:29 -04:00

202 lines
5.9 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/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)
// TODO - I have a feeling weakrefs will not work in ignore_list, verify this ~Leshana
var/weakref/g = weakref(gib)
ignore_list += g
spawn(600)
ignore_list -= g
/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'>[will_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")
will_patrol = !will_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 = ITEMSIZE_NORMAL
var/created_name = "Cleanbot"
/obj/item/weapon/bucket_sensor/attackby(var/obj/item/W, var/mob/user)
..()
if(istype(W, /obj/item/robot_parts/l_arm) || istype(W, /obj/item/robot_parts/r_arm) || (istype(W, /obj/item/organ/external/arm) && ((W.name == "robotic left arm") || (W.name == "robotic right arm"))))
user.drop_item()
qdel(W)
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(W, /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