mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 20:45:28 +01:00
Implant chair refactor (#19272)
Removes some copypasta Refactors implant chairs. Adds some fun variations.
This commit is contained in:
@@ -7,141 +7,186 @@
|
||||
icon_state = "implantchair"
|
||||
density = 1
|
||||
opacity = 0
|
||||
anchored = 1
|
||||
anchored = TRUE
|
||||
|
||||
var/ready = 1
|
||||
var/malfunction = 0
|
||||
var/list/obj/item/weapon/implant/mindshield/implant_list = list()
|
||||
var/ready = TRUE
|
||||
var/replenishing = FALSE
|
||||
|
||||
var/ready_implants = 5
|
||||
var/max_implants = 5
|
||||
var/injection_cooldown = 600
|
||||
var/replenish_cooldown = 6000
|
||||
var/replenishing = 0
|
||||
var/injecting = 0
|
||||
|
||||
/obj/machinery/implantchair/proc
|
||||
go_out()
|
||||
put_mob(mob/living/carbon/M)
|
||||
implant(var/mob/M)
|
||||
add_implants()
|
||||
|
||||
var/implant_type = /obj/item/weapon/implant/mindshield
|
||||
var/auto_inject = FALSE
|
||||
var/auto_replenish = TRUE
|
||||
var/special = FALSE
|
||||
var/special_name = "special function"
|
||||
|
||||
/obj/machinery/implantchair/New()
|
||||
..()
|
||||
add_implants()
|
||||
open_machine()
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/implantchair/attack_hand(mob/user)
|
||||
user.set_machine(src)
|
||||
var/health_text = ""
|
||||
if(src.occupant)
|
||||
if(src.occupant.health <= -100)
|
||||
health_text = "<FONT color=red>Dead</FONT>"
|
||||
else if(src.occupant.health < 0)
|
||||
health_text = "<FONT color=red>[round(src.occupant.health,0.1)]</FONT>"
|
||||
else
|
||||
health_text = "[round(src.occupant.health,0.1)]"
|
||||
/obj/machinery/implantchair/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = notcontained_state)
|
||||
|
||||
var/dat ="<B>Implanter Status</B><BR>"
|
||||
|
||||
dat +="<B>Current occupant:</B> [src.occupant ? "<BR>Name: [src.occupant]<BR>Health: [health_text]<BR>" : "<FONT color=red>None</FONT>"]<BR>"
|
||||
dat += "<B>Implants:</B> [src.implant_list.len ? "[implant_list.len]" : "<A href='?src=\ref[src];replenish=1'>Replenish</A>"]<BR>"
|
||||
if(src.occupant)
|
||||
dat += "[src.ready ? "<A href='?src=\ref[src];implant=1'>Implant</A>" : "Recharging"]<BR>"
|
||||
user.set_machine(src)
|
||||
user << browse(dat, "window=implant")
|
||||
onclose(user, "implant")
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "implantchair", name, 375, 280, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
|
||||
/obj/machinery/implantchair/Topic(href, href_list)
|
||||
/obj/machinery/implantchair/ui_data()
|
||||
var/list/data = list()
|
||||
data["occupied"] = occupant ? 1 : 0
|
||||
data["open"] = state_open
|
||||
|
||||
data["occupant"] = list()
|
||||
if(occupant)
|
||||
data["occupant"]["name"] = occupant.name
|
||||
data["occupant"]["stat"] = occupant.stat
|
||||
|
||||
data["special_name"] = special ? special_name : null
|
||||
data["ready_implants"] = ready_implants
|
||||
data["ready"] = ready
|
||||
data["replenishing"] = replenishing
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/implantchair/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
if(href_list["implant"])
|
||||
if(src.occupant)
|
||||
injecting = 1
|
||||
go_out()
|
||||
ready = 0
|
||||
spawn(injection_cooldown)
|
||||
ready = 1
|
||||
switch(action)
|
||||
if("door")
|
||||
if(state_open)
|
||||
close_machine()
|
||||
else
|
||||
open_machine()
|
||||
. = TRUE
|
||||
if("implant")
|
||||
implant(occupant,usr)
|
||||
. = TRUE
|
||||
|
||||
if(href_list["replenish"])
|
||||
ready = 0
|
||||
spawn(replenish_cooldown)
|
||||
add_implants()
|
||||
ready = 1
|
||||
|
||||
updateUsrDialog()
|
||||
|
||||
|
||||
/obj/machinery/implantchair/go_out(mob/M)
|
||||
if(!occupant)
|
||||
/obj/machinery/implantchair/proc/implant(mob/living/carbon/M,mob/user)
|
||||
if (!istype(M))
|
||||
return
|
||||
if(M == occupant) // so that the guy inside can't eject himself -Agouri
|
||||
if(!ready_implants || !ready)
|
||||
return
|
||||
occupant.loc = loc
|
||||
occupant.reset_perspective(null)
|
||||
if(injecting)
|
||||
implant(src.occupant)
|
||||
injecting = 0
|
||||
occupant = null
|
||||
icon_state = "implantchair"
|
||||
return
|
||||
if(implant_action(M,user))
|
||||
ready_implants--
|
||||
if(!replenishing && auto_replenish)
|
||||
replenishing = TRUE
|
||||
addtimer(src,"replenish",replenish_cooldown)
|
||||
if(injection_cooldown > 0)
|
||||
ready = FALSE
|
||||
addtimer(src,"set_ready",injection_cooldown)
|
||||
else
|
||||
playsound(get_turf(src), 'sound/machines/buzz-sigh.ogg', 25, 1)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/implantchair/proc/implant_action(mob/living/carbon/M)
|
||||
var/obj/item/weapon/implant/I = new implant_type
|
||||
if(I.implant(M))
|
||||
visible_message("<span class='warning'>[M] has been implanted by the [name].</span>")
|
||||
return 1
|
||||
|
||||
/obj/machinery/implantchair/put_mob(mob/living/carbon/M)
|
||||
if(!iscarbon(M))
|
||||
usr << "<span class='warning'>The [src.name] cannot hold this!</span>"
|
||||
/obj/machinery/implantchair/update_icon()
|
||||
icon_state = initial(icon_state)
|
||||
if(state_open)
|
||||
icon_state += "_open"
|
||||
if(occupant)
|
||||
icon_state += "_occupied"
|
||||
if(ready)
|
||||
add_overlay("ready")
|
||||
else
|
||||
cut_overlays()
|
||||
|
||||
/obj/machinery/implantchair/proc/replenish()
|
||||
if(ready_implants < max_implants)
|
||||
ready_implants++
|
||||
if(ready_implants < max_implants)
|
||||
addtimer(src,"replenish",replenish_cooldown)
|
||||
else
|
||||
replenishing = FALSE
|
||||
|
||||
/obj/machinery/implantchair/proc/set_ready()
|
||||
ready = TRUE
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/implantchair/container_resist()
|
||||
var/mob/living/user = usr
|
||||
if(state_open)
|
||||
return
|
||||
if(src.occupant)
|
||||
usr << "<span class='warning'>The [src.name] is already occupied!</span>"
|
||||
user.changeNext_move(CLICK_CD_BREAKOUT)
|
||||
user.last_special = world.time + CLICK_CD_BREAKOUT
|
||||
user << "<span class='notice'>You lean on the back of [src] and start pushing the door open... (this will take about about a minute.)</span>"
|
||||
audible_message("<span class='italics'>You hear a metallic creaking from [src]!</span>",hearing_distance = 2)
|
||||
|
||||
if(do_after(user, 600, target = src))
|
||||
if(!user || user.stat != CONSCIOUS || user.loc != src || state_open)
|
||||
return
|
||||
visible_message("<span class='warning'>[user] successfully broke out of [src]!</span>")
|
||||
user << "<span class='notice'>You successfully break out of [src]!</span>"
|
||||
open_machine()
|
||||
|
||||
/obj/machinery/implantchair/relaymove(mob/user)
|
||||
container_resist()
|
||||
|
||||
/obj/machinery/implantchair/MouseDrop_T(mob/target, mob/user)
|
||||
if(user.stat || user.lying || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
|
||||
return
|
||||
M.stop_pulling()
|
||||
M.loc = src
|
||||
M.reset_perspective(src)
|
||||
src.occupant = M
|
||||
src.add_fingerprint(usr)
|
||||
icon_state = "implantchair_on"
|
||||
close_machine(target)
|
||||
|
||||
/obj/machinery/implantchair/close_machine(mob/user)
|
||||
if((isnull(user) || istype(user)) && state_open)
|
||||
..(user)
|
||||
if(auto_inject && ready && ready_implants > 0)
|
||||
implant(user,null)
|
||||
|
||||
/obj/machinery/implantchair/genepurge
|
||||
name = "Genetic purifier"
|
||||
desc = "Used to purge human genome of foreign influences"
|
||||
special = TRUE
|
||||
special_name = "Purge genome"
|
||||
injection_cooldown = 0
|
||||
replenish_cooldown = 300
|
||||
|
||||
/obj/machinery/implantchair/genepurge/implant_action(mob/living/carbon/human/H,mob/user)
|
||||
if(!istype(H))
|
||||
return 0
|
||||
H.set_species(/datum/species/human, 1)//lizards go home
|
||||
purrbation_remove(H)//remove cats
|
||||
H.dna.remove_all_mutations()//hulks out
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/implantchair/implant(mob/M)
|
||||
if (!istype(M, /mob/living/carbon))
|
||||
return
|
||||
if(!implant_list.len)
|
||||
return
|
||||
for(var/obj/item/weapon/implant/mindshield/imp in implant_list)
|
||||
if(!imp)
|
||||
continue
|
||||
if(istype(imp, /obj/item/weapon/implant/mindshield))
|
||||
M.visible_message("<span class='warning'>[M] has been implanted by the [src.name].</span>")
|
||||
/obj/machinery/implantchair/brainwash
|
||||
name = "Neural Imprinter"
|
||||
desc = "Used to <s>indoctrinate</s> rehabilitate hardened recidivists."
|
||||
special_name = "Imprint"
|
||||
injection_cooldown = 3000
|
||||
auto_inject = FALSE
|
||||
auto_replenish = FALSE
|
||||
special = TRUE
|
||||
var/objective = "Obey the law. Praise Nanotrasen."
|
||||
var/custom = FALSE
|
||||
|
||||
if(imp.implant(M))
|
||||
implant_list -= imp
|
||||
break
|
||||
return
|
||||
/obj/machinery/implantchair/brainwash/implant_action(mob/living/carbon/C,mob/user)
|
||||
if(!istype(C) || !C.mind)
|
||||
return 0
|
||||
if(custom)
|
||||
if(!user || !user.Adjacent(src))
|
||||
return 0
|
||||
objective = stripped_input(usr,"What order do you want to imprint on [C]?","Enter the order","",120)
|
||||
message_admins("[key_name_admin(user)] set brainwash machine objective to '[objective]'.")
|
||||
log_game("[key_name_admin(user)] set brainwash machine objective to '[objective]'.")
|
||||
var/datum/objective/custom_objective = new/datum/objective(objective)
|
||||
custom_objective.owner = C.mind
|
||||
C.mind.objectives += custom_objective
|
||||
C.mind.announce_objectives()
|
||||
message_admins("[key_name_admin(user)] brainwashed [key_name_admin(C)] with objective '[objective]'.")
|
||||
log_game("[key_name_admin(user)] brainwashed [key_name_admin(C)] with objective '[objective]'.")
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/implantchair/add_implants()
|
||||
for(var/i=0, i<src.max_implants, i++)
|
||||
var/obj/item/weapon/implant/mindshield/I = new /obj/item/weapon/implant/mindshield(src)
|
||||
implant_list += I
|
||||
return
|
||||
|
||||
/obj/machinery/implantchair/verb/get_out()
|
||||
set name = "Eject occupant"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
if(usr.stat != 0)
|
||||
return
|
||||
src.go_out(usr)
|
||||
add_fingerprint(usr)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/implantchair/verb/move_inside()
|
||||
set name = "Move Inside"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
if(usr.stat != 0 || stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
put_mob(usr)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user