Skip to content

Commit

Permalink
Moves most duplicate alt refinery checks to the parent and some clean…
Browse files Browse the repository at this point in the history
…up (vlggms#2045)

* initial commit

* removes forced parent calls, machines talk about items

* minor qol
  • Loading branch information
Gboster-0 authored and vampirebat74 committed May 10, 2024
1 parent c0ac2e5 commit e35599a
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 61 deletions.
57 changes: 55 additions & 2 deletions ModularTegustation/tegu_items/refinery/alt_refinery/_refiner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,64 @@
anchored = TRUE
density = TRUE
resistance_flags = INDESTRUCTIBLE
/// Toggles if only extraction officers can use the alt refinery
var/officer_only = TRUE
/// the PE cost that the refinery consumes upon use
var/extraction_cost = 0
/// toggles if attack_hand should tell the person to use an item instead of just clicking the refinery
var/requires_item = FALSE

/obj/structure/altrefiner/Initialize()
/obj/structure/altrefiner/Initialize(mapload)
. = ..()
GLOB.lobotomy_devices += src

/obj/structure/altrefiner/examine(mob/user)
. = ..()
if(requires_item)
. += span_notice("Use an object on this machine to start the extraction process[officer_only ? " if you are an extraction officer" : ""].")
else
. += span_notice("Click on this machine to start the extraction process[officer_only ? " if you are an extraction officer" : ""].")

/obj/structure/altrefiner/attack_hand(mob/living/carbon/M)
. = ..()
if(requires_item)
to_chat(M, span_warning("This machine needs an object for proper operation."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return FALSE

if(officer_only && M?.mind?.assigned_role != "Extraction Officer")
to_chat(M, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return FALSE

if(SSlobotomy_corp.available_box < extraction_cost)
to_chat(M, span_warning("Not enough PE boxes stored for this operation. [extraction_cost] PE is necessary for this operation. Current PE: [SSlobotomy_corp.available_box]."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return FALSE

SSlobotomy_corp.AdjustAvailableBoxes(-1 * extraction_cost)
return TRUE

/obj/structure/altrefiner/attackby(obj/item/I, mob/living/user, params)
. = ..()
if(!requires_item)
to_chat(user, span_notice("This machine does not accept objects, so instead you touched it"))
attack_hand(user)
return FALSE

if(officer_only && user?.mind?.assigned_role != "Extraction Officer")
to_chat(user, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return FALSE

if(SSlobotomy_corp.available_box < extraction_cost)
to_chat(user, span_warning("Not enough PE boxes stored for this operation. \n[extraction_cost] PE is necessary for this operation. Current PE: [SSlobotomy_corp.available_box]."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return FALSE

SSlobotomy_corp.AdjustAvailableBoxes(-1 * extraction_cost)
return TRUE

/obj/structure/altrefiner/Destroy()
GLOB.lobotomy_devices -= src
return ..()
Expand All @@ -28,7 +81,7 @@ GLOBAL_LIST_INIT(unspawned_refiners, list(
icon = 'icons/effects/landmarks_static.dmi'
icon_state = "x4"

/obj/effect/landmark/refinerspawn/Initialize()
/obj/effect/landmark/refinerspawn/Initialize(mapload)
..()
if(!LAZYLEN(GLOB.unspawned_refiners))
return INITIALIZE_HINT_QDEL
Expand Down
17 changes: 3 additions & 14 deletions ModularTegustation/tegu_items/refinery/alt_refinery/blood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@
name = "Blood Refinery"
desc = "A machine used by the Extraction Officer to give all but 1 of their HP for a chance at a PE box."
icon_state = "dominator-red"
var/pecost = 100
extraction_cost = 100

/obj/structure/altrefiner/blood/attack_hand(mob/living/carbon/M)
..()
//Only the EO may use it
if(M?.mind?.assigned_role != "Extraction Officer")
to_chat(M, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return

if(M.health <= 20)
to_chat(M, span_warning("You have no more blood to give."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return

//This is more expensive than regular refining still
if(SSlobotomy_corp.available_box < pecost)
to_chat(M, span_warning("Not enough PE boxes stored for this operation. 100 PE is necessary for this operation. Current PE: [SSlobotomy_corp.available_box]."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
. = ..()
if(!.)
return

//Gamble it
Expand All @@ -35,5 +26,3 @@
else
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
to_chat(M, span_warning("Refining failure. Please try again."))
SSlobotomy_corp.AdjustAvailableBoxes(-1 * pecost)

17 changes: 3 additions & 14 deletions ModularTegustation/tegu_items/refinery/alt_refinery/chance.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@
name = "Chance Refinery"
desc = "A machine used by the Extraction Officer to coinflip for a PE box. Costs 25 cargo PE."
icon_state = "dominator-purple"
var/pecost = 25
extraction_cost = 25

/obj/structure/altrefiner/chance/attack_hand(mob/living/carbon/M)
..()
//Only the EO may use it
if(M?.mind?.assigned_role != "Extraction Officer")
to_chat(M, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return

//This is more expensive than regular refining still
if(SSlobotomy_corp.available_box < pecost)
to_chat(M, span_warning("Not enough PE boxes stored for this operation. 25 PE is necessary for this operation. Current PE: [SSlobotomy_corp.available_box]."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
. = ..()
if(!.)
return

if(prob(50))
Expand All @@ -25,5 +16,3 @@
else
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
to_chat(M, span_warning("Refining failure. Please try again."))
SSlobotomy_corp.AdjustAvailableBoxes(-1 * pecost)

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
name = "Quick Refinery"
desc = "A machine used by the Extraction Officer to ship PE to command to refine."
icon_state = "dominator-yellow"
requires_item = TRUE

/obj/structure/altrefiner/quick/attackby(obj/item/I, mob/living/user, params)
if(user?.mind?.assigned_role != "Extraction Officer")
to_chat(user, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
. = ..()
if(!.)
return

if(I.type != /obj/item/rawpe)
Expand Down
28 changes: 8 additions & 20 deletions ModularTegustation/tegu_items/refinery/alt_refinery/timed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,26 @@
name = "Timed Auto-Refinery"
desc = "A machine used by the Extraction Officer to automatically refine PE at the rate of 5 boxes every 5 minutes."
icon_state = "dominator-blue"
var/pecost = 500
extraction_cost = 500
var/ready = TRUE

/obj/structure/altrefiner/timed/proc/reset()
playsound(get_turf(src), 'sound/machines/terminal_prompt_confirm.ogg', 50, TRUE)
ready = TRUE

/obj/structure/altrefiner/timed/attack_hand(mob/living/carbon/M)
..()
//Only the EO may use it
if(M?.mind?.assigned_role != "Extraction Officer")
to_chat(M, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return

//and you actually need the boxes
if(SSlobotomy_corp.available_box < pecost)
to_chat(M, span_warning("Not enough PE boxes stored for this operation. 500 PE is necessary for this operation. Current PE: [SSlobotomy_corp.available_box]."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return

if(!ready)
to_chat(M, span_warning("This machine is not yet ready."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return

. = ..()
if(!.)
return

playsound(get_turf(src), 'sound/machines/terminal_prompt_confirm.ogg', 50, TRUE)
SSlobotomy_corp.AdjustAvailableBoxes(-1 * pecost)
new /obj/item/refinedpe(get_turf(src))
new /obj/item/refinedpe(get_turf(src))
new /obj/item/refinedpe(get_turf(src))
new /obj/item/refinedpe(get_turf(src))
new /obj/item/refinedpe(get_turf(src))
for(var/i in 1 to 5)
new /obj/item/refinedpe(get_turf(src))

ready = FALSE
addtimer(CALLBACK(src, PROC_REF(reset)), 5 MINUTES)
13 changes: 5 additions & 8 deletions ModularTegustation/tegu_items/refinery/alt_refinery/weapon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@
name = "EGO Refinery"
desc = "A machine used by the Extraction Officer to automatically melt EGO and potentially spit out a refined PE."
icon_state = "dominator-green"
requires_item = TRUE
var/list/meltable

/obj/structure/altrefiner/weapon/Initialize()
/obj/structure/altrefiner/weapon/Initialize(mapload)
var/list/processing = list(/obj/item/ego_weapon, /obj/item/gun/ego_gun, /obj/item/clothing/suit/armor/ego_gear)
var/list/banned = list(/obj/item/ego_weapon/city/ncorp_mark)
for(var/Y in processing)
meltable += subtypesof(Y)
for(var/X in banned)
meltable -= subtypesof(X)
..()
return ..()

/obj/structure/altrefiner/weapon/attackby(obj/item/I, mob/living/user, params)
if(user?.mind?.assigned_role != "Extraction Officer")
to_chat(user, span_warning("Only the Extraction Officer can use this machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
. = ..()
if(!.)
return

if(!(I.type in meltable))
to_chat(user, span_warning("Only EGO is accepted by the machine."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
return


qdel(I)
if(prob(50))
playsound(get_turf(src), 'sound/machines/terminal_prompt_deny.ogg', 50, TRUE)
Expand All @@ -34,5 +33,3 @@
to_chat(user, span_notice("Refining success."))
playsound(get_turf(src), 'sound/machines/terminal_prompt_confirm.ogg', 50, TRUE)
new /obj/item/refinedpe(get_turf(src))


0 comments on commit e35599a

Please sign in to comment.