From 41c1d71bc40518c1daf01ec404c8d46a9d8b6c3f Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 22 Jun 2022 23:02:44 -0500 Subject: [PATCH] Add magic reactions to hydroponics plants (#67724) * Add magic reactions to hydroponics plants * Refactor magic bolts for plants * Add polymorph proc to hydroponics plants * Fix mob and plant_tray variable names --- code/modules/hydroponics/hydroponics.dm | 18 +++- code/modules/projectiles/projectile/magic.dm | 88 +++++++++++++------- 2 files changed, 77 insertions(+), 29 deletions(-) diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index 82008d72e20..127c45b2d25 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -627,7 +627,6 @@ /obj/machinery/hydroponics/proc/hardmutate() mutate(4, 10, 2, 4, 50, 4, 10, 0, 4) - /obj/machinery/hydroponics/proc/mutatespecie() // Mutagent produced a new plant! if(!myseed || plant_status == HYDROTRAY_PLANT_DEAD || !LAZYLEN(myseed.mutatelist)) return @@ -645,6 +644,23 @@ var/message = span_warning("[oldPlantName] suddenly mutates into [myseed.plantname]!") addtimer(CALLBACK(src, .proc/after_mutation, message), 0.5 SECONDS) +/obj/machinery/hydroponics/proc/polymorph() // Polymorph a plant into another plant + if(!myseed || plant_status == HYDROTRAY_PLANT_DEAD) + return + + var/oldPlantName = myseed.plantname + var/polymorph_seed = pick(subtypesof(/obj/item/seeds)) + set_seed(new polymorph_seed(src)) + + hardmutate() + age = 0 + set_plant_health(myseed.endurance, update_icon = FALSE) + lastcycle = world.time + set_weedlevel(0, update_icon = FALSE) + + var/message = span_warning("[oldPlantName] suddenly polymorphs into [myseed.plantname]!") + addtimer(CALLBACK(src, .proc/after_mutation, message), 0.5 SECONDS) + /obj/machinery/hydroponics/proc/mutateweed() // If the weeds gets the mutagent instead. Mind you, this pretty much destroys the old plant if( weedlevel > 5 ) set_seed(null) diff --git a/code/modules/projectiles/projectile/magic.dm b/code/modules/projectiles/projectile/magic.dm index 6f3926ebb1b..83f3ae8224d 100644 --- a/code/modules/projectiles/projectile/magic.dm +++ b/code/modules/projectiles/projectile/magic.dm @@ -11,30 +11,47 @@ /// determines the drain cost on the antimagic item var/antimagic_charge_cost = 1 -/obj/projectile/magic/prehit_pierce(mob/living/target) +/obj/projectile/magic/prehit_pierce(atom/target) . = ..() - if(istype(target) && target.can_block_magic(antimagic_flags, antimagic_charge_cost)) - visible_message(span_warning("[src] fizzles on contact with [target]!")) - return PROJECTILE_DELETE_WITHOUT_HITTING + + if(isliving(target)) + var/mob/living/victim = target + if(victim.can_block_magic(antimagic_flags, antimagic_charge_cost)) + visible_message(span_warning("[src] fizzles on contact with [victim]!")) + return PROJECTILE_DELETE_WITHOUT_HITTING + + if(istype(target, /obj/machinery/hydroponics)) // even plants can block antimagic + var/obj/machinery/hydroponics/plant_tray = target + if(!plant_tray.myseed) + return + if(plant_tray.myseed.get_gene(/datum/plant_gene/trait/anti_magic)) + visible_message(span_warning("[src] fizzles on contact with [plant_tray]!")) + return PROJECTILE_DELETE_WITHOUT_HITTING /obj/projectile/magic/death name = "bolt of death" icon_state = "pulse1_bl" -/obj/projectile/magic/death/on_hit(mob/living/target) +/obj/projectile/magic/death/on_hit(atom/target) . = ..() - if(!isliving(target)) - return - if(target.mob_biotypes & MOB_UNDEAD) //negative energy heals the undead - if(target.revive(full_heal = TRUE, admin_revive = TRUE)) - target.grab_ghost(force = TRUE) // even suicides - to_chat(target, span_notice("You rise with a start, you're undead!!!")) - else if(target.stat != DEAD) - to_chat(target, span_notice("You feel great!")) - return + if(isliving(target)) + var/mob/living/victim = target + if(victim.mob_biotypes & MOB_UNDEAD) //negative energy heals the undead + if(victim.revive(full_heal = TRUE, admin_revive = TRUE)) + victim.grab_ghost(force = TRUE) // even suicides + to_chat(victim, span_notice("You rise with a start, you're undead!!!")) + else if(victim.stat != DEAD) + to_chat(victim, span_notice("You feel great!")) + return + victim.death() - target.death() + if(istype(target, /obj/machinery/hydroponics)) + var/obj/machinery/hydroponics/plant_tray = target + if(!plant_tray.myseed) + return + plant_tray.set_weedlevel(0) // even the weeds perish + plant_tray.plantdies() /obj/projectile/magic/resurrection name = "bolt of resurrection" @@ -43,20 +60,27 @@ damage_type = OXY nodamage = TRUE -/obj/projectile/magic/resurrection/on_hit(mob/living/target) +/obj/projectile/magic/resurrection/on_hit(atom/target) . = ..() - if(!isliving(target)) - return - if(target.mob_biotypes & MOB_UNDEAD) //positive energy harms the undead - target.death() - return + if(isliving(target)) + var/mob/living/victim = target - if(target.revive(full_heal = TRUE, admin_revive = TRUE)) - target.grab_ghost(force = TRUE) // even suicides - to_chat(target, span_notice("You rise with a start, you're alive!!!")) - else if(target.stat != DEAD) - to_chat(target, span_notice("You feel great!")) + if(victim.mob_biotypes & MOB_UNDEAD) //positive energy harms the undead + victim.death() + return + + if(victim.revive(full_heal = TRUE, admin_revive = TRUE)) + victim.grab_ghost(force = TRUE) // even suicides + to_chat(victim, span_notice("You rise with a start, you're alive!!!")) + else if(victim.stat != DEAD) + to_chat(victim, span_notice("You feel great!")) + + if(istype(target, /obj/machinery/hydroponics)) + var/obj/machinery/hydroponics/plant_tray = target + if(!plant_tray.myseed) + return + plant_tray.set_plant_health(plant_tray.myseed.endurance, forced = TRUE) /obj/projectile/magic/teleport name = "bolt of teleportation" @@ -139,10 +163,18 @@ damage_type = BURN nodamage = TRUE -/obj/projectile/magic/change/on_hit(mob/living/target) +/obj/projectile/magic/change/on_hit(atom/target) . = ..() + if(isliving(target)) - target.wabbajack() + var/mob/living/victim = target + victim.wabbajack() + + if(istype(target, /obj/machinery/hydroponics)) + var/obj/machinery/hydroponics/plant_tray = target + if(!plant_tray.myseed) + return + plant_tray.polymorph() /obj/projectile/magic/animate name = "bolt of animation"