Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing "COOLDOWN_LIST", and some botany changes #9324

Closed
wants to merge 12 commits into from
20 changes: 20 additions & 0 deletions code/__DEFINES/cooldowns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,23 @@
#define COOLDOWN_RESET(cd_source, cd_index) cd_source.cd_index = 0

#define COOLDOWN_TIMELEFT(cd_source, cd_index) (max(0, cd_source.cd_index - world.time))



// when a timer should track targets individually
// this is useful when an item should individually trigger cooldown time per mob
#define COOLDOWN_LIST_DECLARE(cd_index) var/list/##cd_index = list()

#define COOLDOWN_STATIC_LIST_DECLARE(cd_index) var/static/list/##cd_index = list()

/// IMPORTANT: "cd_target" should be individual because it's assoc key
#define COOLDOWN_LIST_START(cd_target, cd_source, cd_index, cd_time) (cd_source.cd_index[cd_target] = world.time + (cd_time))

#define COOLDOWN_LIST_FINISHED(cd_target, cd_source, cd_index) (cd_source.cd_index[cd_target] < world.time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These macro param names are confusing considering the index is actually the name of the cooldown and the target is the index.
The order of arguments should be:
object, cooldown name, index (cd_target), value (time/length)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed macro param names. would that work?


#define COOLDOWN_LIST_RESET(cd_target, cd_source, cd_index) cd_source.cd_index[cd_target] = 0

#define COOLDOWN_LIST_TIMELEFT(cd_target, cd_source, cd_index) (max(0, cd_source.cd_index[cd_target] - world.time))

/// use to change existing cooldown
#define COOLDOWN_LIST_ADJUST_TIME(cd_target, cd_source, cd_index, cd_time) (cd_source.cd_index[cd_target] = cd_source.cd_index[cd_target] - (cd_time))
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
/obj/item/reagent_containers/food/snacks/grown/proc/add_juice()
if(reagents)
if(bitesize_mod)
bitesize = 1 + round(reagents.total_volume / bitesize_mod)
bitesize = max(1, round(reagents.total_volume / bitesize_mod))
return 1
return 0

Expand Down
1 change: 1 addition & 0 deletions code/modules/hydroponics/grown/cannabis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,6 @@
desc = "You feel dizzy looking at it. What the fuck?"
icon_state = "ocannabis"
volume = 420
bitesize = 1
wine_power = 90
discovery_points = 300
24 changes: 22 additions & 2 deletions code/modules/hydroponics/plant_genes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,28 @@
// Also affects plant batteries see capatative cell production datum
name = "Electrical Activity"
rate = 0.2
COOLDOWN_STATIC_LIST_DECLARE(recent_victims)

/datum/plant_gene/trait/cell_charge/on_slip(obj/item/reagent_containers/food/snacks/grown/G, mob/living/carbon/C)
if(!COOLDOWN_LIST_FINISHED(C, src, recent_victims)) // if you were a victim recently, you won't get it again
return
var/power = round(G.seed.potency*rate)
if(prob(power))
COOLDOWN_LIST_START(C, src, recent_victims, 2 SECONDS)
C.electrocute_act(power, G, 1, 1)
var/turf/T = get_turf(C)
if(C.ckey != G.fingerprintslast)
C.investigate_log("[C] has slipped on an electric plant at [AREACOORD(T)]. Last fingerprint: [G.fingerprintslast].", INVESTIGATE_BOTANY)
log_combat(C, G, "slipped on and got electrocuted by", null, "with the power of 10. Last fingerprint: [G.fingerprintslast]")

/datum/plant_gene/trait/cell_charge/on_squash(obj/item/reagent_containers/food/snacks/grown/G, atom/target)
if(!COOLDOWN_LIST_FINISHED(target, src, recent_victims)) // if you were a victim recently, you won't get it again
return
if(iscarbon(target))
var/mob/living/carbon/C = target
var/power = G.seed.potency*rate
if(prob(power))
COOLDOWN_LIST_START(C, src, recent_victims, 2 SECONDS)
C.electrocute_act(round(power), G, 1, 1)
if(C.ckey != G.fingerprintslast)
log_combat(G.thrownby, C, "hit and electrocuted", G, "at [AREACOORD(G)] with power of [power]")
Expand Down Expand Up @@ -439,6 +446,7 @@

/datum/plant_gene/trait/stinging
name = "Hypodermic Prickles"
COOLDOWN_STATIC_LIST_DECLARE(recent_victims)

/datum/plant_gene/trait/stinging/on_slip(obj/item/reagent_containers/food/snacks/grown/G, atom/target)
if(!isliving(target) || !G.reagents || !G.reagents.total_volume)
Expand All @@ -464,11 +472,23 @@
if(!L.reagents && !L.can_inject(null, 0))
return FALSE

var/injecting_amount = max(1, G.seed.potency*0.2) // Minimum of 1, max of 20
var/fraction = min(injecting_amount/G.reagents.total_volume, 1)
// Mechanism: It will always inject the amount as "injecting_amount" variable no matter the total size is
var/prick_efficiency = 0.1 // default (maximum: 10u)
if(locate(/datum/plant_gene/trait/squash) in G.seed.genes)
prick_efficiency = 0.05 // how can a smooth plant be deadly? (maximum: 5u)
else if(istype(G, /obj/item/seeds/nettle/death)) // as long as it has not Liquid Content
prick_efficiency = 0.2 // bonus to "death" nettle (maximum: 20u)
else if(G.force)
prick_efficiency = 0.15 // bonus to blunt plants (miaxmum: 15u)
if(!COOLDOWN_LIST_FINISHED(L, src, recent_victims)) // until 10s cooldown time from a victim is finished, the effective becomes half
prick_efficiency = round(prick_efficiency/2, 0.01) // i.e) 15u to 7.5u

var/injecting_amount = round(max(1, G.seed.potency * prick_efficiency), 0.1) // mimumum 1u to maximum 5/10/15/20u
var/fraction = min(injecting_amount/G.reagents.total_volume, 1) // Let's say you have 90u + 10u. Injecting 5u will be "4.5u + 0.5u" by the fraction
G.reagents.reaction(L, INJECT, fraction)
G.reagents.trans_to(L, injecting_amount)
to_chat(L, "<span class='danger'>You are pricked by [G]!</span>")
COOLDOWN_LIST_START(L, src, recent_victims, 10 SECONDS) // this refreshes 10s cooldown time. repeated attack will not be effective
return TRUE

/datum/plant_gene/trait/smoke
Expand Down
4 changes: 2 additions & 2 deletions code/modules/hydroponics/seeds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@
renamedByPlayer = TRUE

if(penchoice == "Plant Description")
var/input = stripped_input(user,"What do you want to change the description of the plant to?", default=plantdesc, max_length=MAX_NAME_LEN)
var/input = stripped_input(user,"What do you want to change the description of the plant to?", default=plantdesc, max_length=MAX_MESSAGE_LEN)
if(QDELETED(src) || !user.canUseTopic(src, BE_CLOSE))
return
plantdesc = input

if(penchoice == "Seed Description")
var/input = stripped_input(user,"What do you want to change the description of the seeds to?", default=desc, max_length=MAX_NAME_LEN)
var/input = stripped_input(user,"What do you want to change the description of the seeds to?", default=desc, max_length=MAX_MESSAGE_LEN)
if(QDELETED(src) || !user.canUseTopic(src, BE_CLOSE))
return
desc = input
Expand Down