Refactoring APTFT altclick/verb options into flags

This commit is contained in:
Ghommie
2020-01-26 18:53:16 +01:00
parent 45ad9bc77d
commit 41ee00b7df
6 changed files with 25 additions and 43 deletions
+6 -1
View File
@@ -8,7 +8,7 @@
#define REAGENT_PURITY_ACCURACY 0.001
#define DEFAULT_SPECIFIC_HEAT 200
// container_type defines
//reagents_holder_flags defines
#define INJECTABLE (1<<0) // Makes it possible to add reagents through droppers and syringes.
#define DRAWABLE (1<<1) // Makes it possible to remove reagents through syringes.
@@ -29,6 +29,11 @@
#define PATCH 4 // patches
#define INJECT 5 // injection
//container_flags
#define PH_WEAK (1 << 0)
#define TEMP_WEAK (1 << 1)
#define APTFT_VERB (1 << 2) //APTFT stands for "amount per transfer from this"
#define APTFT_ALTCLICK (1 << 3)
//defines passed through to the on_reagent_change proc
#define DEL_REAGENT 1 // reagent deleted (fully cleared)
+10 -14
View File
@@ -1,6 +1,3 @@
#define PH_WEAK (1 << 0)
#define TEMP_WEAK (1 << 1)
/obj/item/reagent_containers
name = "Container"
desc = "..."
@@ -9,14 +6,13 @@
w_class = WEIGHT_CLASS_TINY
var/amount_per_transfer_from_this = 5
var/list/possible_transfer_amounts = list(5,10,15,20,25,30)
var/APTFT_altclick = TRUE //will the set amount_per_transfer_from_this proc be called on AltClick() ?
var/volume = 30
var/reagent_flags
var/reagent_flags //used to determine the reagent holder flags on add_initial_reagents()
var/list/list_reagents = null
var/spawned_disease = null
var/disease_amount = 20
var/spillable = FALSE
var/beaker_weakness_bitflag = NONE//Bitflag!
var/container_flags = APTFT_ALTCLICK|APTFT_VERB //the container item flags
var/container_HP = 2
var/cached_icon
@@ -24,7 +20,7 @@
. = ..()
if(isnum(vol) && vol > 0)
volume = vol
if(length(possible_transfer_amounts))
if(container_flags & APTFT_VERB && length(possible_transfer_amounts))
verbs += /obj/item/reagent_containers/proc/set_APTFT
create_reagents(volume, reagent_flags)
if(spawned_disease)
@@ -37,12 +33,12 @@
. = ..()
if(length(possible_transfer_amounts) > 1)
. += "Currently transferring [amount_per_transfer_from_this] units per use."
if(APTFT_altclick && user.Adjacent(src))
if(container_flags & APTFT_ALTCLICK && user.Adjacent(src))
. += "<span class='notice'>Alt-click it to set its transfer amount.</span>"
/obj/item/reagent_containers/AltClick(mob/user)
. = ..()
if(APTFT_altclick && length(possible_transfer_amounts) > 1 && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY))
if(container_flags & APTFT_ALTCLICK && length(possible_transfer_amounts) > 1 && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY))
set_APTFT()
return TRUE
@@ -157,7 +153,7 @@
//melts plastic beakers
/obj/item/reagent_containers/microwave_act(obj/machinery/microwave/M)
reagents.expose_temperature(1000)
if(beaker_weakness_bitflag & TEMP_WEAK)
if(container_flags & TEMP_WEAK)
var/list/seen = viewers(5, get_turf(src))
var/iconhtml = icon2html(src, seen)
for(var/mob/H in seen)
@@ -172,13 +168,13 @@
temp_check()
/obj/item/reagent_containers/proc/temp_check()
if(beaker_weakness_bitflag & TEMP_WEAK)
if(container_flags & TEMP_WEAK)
if(reagents.chem_temp >= 444)//assuming polypropylene
START_PROCESSING(SSobj, src)
//melts glass beakers
/obj/item/reagent_containers/proc/pH_check()
if(beaker_weakness_bitflag & PH_WEAK)
if(container_flags & PH_WEAK)
if((reagents.pH < 1.5) || (reagents.pH > 12.5))
START_PROCESSING(SSobj, src)
else if((reagents.pH < -3) || (reagents.pH > 17))
@@ -192,7 +188,7 @@
cached_icon = icon_state
var/damage
var/cause
if(beaker_weakness_bitflag & PH_WEAK)
if(container_flags & PH_WEAK)
if(reagents.pH < 2)
damage = (2 - reagents.pH)/20
cause = "from the extreme pH"
@@ -203,7 +199,7 @@
cause = "from the extreme pH"
playsound(get_turf(src), 'sound/FermiChem/bufferadd.ogg', 50, 1)
if(beaker_weakness_bitflag & TEMP_WEAK)
if(container_flags & TEMP_WEAK)
if(reagents.chem_temp >= 444)
if(damage)
damage += (reagents.chem_temp/444)/5
@@ -110,7 +110,7 @@
item_state = "beaker"
materials = list(MAT_GLASS=500)
possible_transfer_amounts = list(5,10,15,20,25,30,50,60)
beaker_weakness_bitflag = PH_WEAK
container_flags = PH_WEAK|APTFT_ALTCLICK|APTFT_VERB
/obj/item/reagent_containers/glass/beaker/Initialize()
. = ..()
@@ -203,11 +203,7 @@
volume = 180
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,20,25,30,40,50,60,120,180)
/obj/item/reagent_containers/glass/beaker/plastic/Initialize()
beaker_weakness_bitflag &= ~PH_WEAK
beaker_weakness_bitflag |= TEMP_WEAK
. = ..()
container_flags = TEMP_WEAK|APTFT_ALTCLICK|APTFT_VERB
/obj/item/reagent_containers/glass/beaker/plastic/update_icon()
icon_state = "beakerlarge" // hack to lets us reuse the large beaker reagent fill states
@@ -222,10 +218,7 @@
volume = 240
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,20,25,30,40,50,60,120,200,240)
/obj/item/reagent_containers/glass/beaker/meta/Initialize() // why the fuck can't you just set the beaker weakness bitflags to nothing? fuck you
beaker_weakness_bitflag &= ~PH_WEAK
. = ..()
container_flags = APTFT_ALTCLICK|APTFT_VERB
/obj/item/reagent_containers/glass/beaker/noreact
name = "cryostasis beaker"
@@ -236,13 +229,9 @@
reagent_flags = OPENCONTAINER | NO_REACT
volume = 50
amount_per_transfer_from_this = 10
container_flags = APTFT_ALTCLICK|APTFT_VERB
container_HP = 10//shouldn't be needed
/obj/item/reagent_containers/glass/beaker/noreact/Initialize()
beaker_weakness_bitflag &= ~PH_WEAK
. = ..()
//reagents.set_reacting(FALSE) was this removed in a recent pr?
/obj/item/reagent_containers/glass/beaker/bluespace
name = "bluespace beaker"
desc = "A bluespace beaker, powered by experimental bluespace technology \
@@ -310,12 +299,9 @@
SLOT_L_STORE, SLOT_R_STORE,\
SLOT_GENERC_DEXTROUS_STORAGE
)
container_flags = APTFT_ALTCLICK|APTFT_VERB
container_HP = 1
/obj/item/reagent_containers/glass/bucket/Initialize()
beaker_weakness_bitflag |= TEMP_WEAK
. = ..()
/obj/item/reagent_containers/glass/bucket/attackby(obj/O, mob/user, params)
if(istype(O, /obj/item/mop))
if(reagents.total_volume < 1)
@@ -365,12 +351,9 @@
volume = 50
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,20,25,30,50)
container_flags = TEMP_WEAK|APTFT_ALTCLICK|APTFT_VERB
container_HP = 1
/obj/item/reagent_containers/glass/beaker/waterbottle/Initialize()
beaker_weakness_bitflag |= TEMP_WEAK
. = ..()
/obj/item/reagent_containers/glass/beaker/waterbottle/empty
list_reagents = list()
@@ -7,7 +7,7 @@
spillable = FALSE
volume = 10
possible_transfer_amounts = list(1,2,5,10)
APTFT_altclick = FALSE
container_flags = APTFT_VERB
obj_flags = UNIQUE_RENAME
unique_reskin = list("hypovial" = "hypovial",
"red hypovial" = "hypovial-b",
@@ -25,9 +25,6 @@
if(!icon_state)
icon_state = "hypovial"
update_icon()
// beaker_weakness_bitflag |= PH_WEAK // fuck you if you're using these like beakers
// beaker_weakness_bitflag |= TEMP_WEAK
/obj/item/reagent_containers/glass/bottle/vial/on_reagent_change()
update_icon()
@@ -8,7 +8,7 @@
reagent_flags = REFILLABLE | DRAINABLE
amount_per_transfer_from_this = 5
possible_transfer_amounts = list()
APTFT_altclick = FALSE
container_flags = APTFT_VERB
volume = 5
spillable = FALSE
var/wipe_sound
@@ -23,6 +23,7 @@
amount_per_transfer_from_this = 5
volume = 250
possible_transfer_amounts = list(5,10,15,20,25,30,50,100)
container_flags = NONE //APTFT is alternated between the initial value and stream_amount and shouldn't be exploited.
/obj/item/reagent_containers/spray/afterattack(atom/A, mob/user)
. = ..()