mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-30 19:41:56 +00:00
* organizing flora file and icon states, & flags Changes the typepath for a lot of flora, and adds new paths depending on the amount of icon states the flora had, for better modularization on mappers. Also adds flags to the flora depending on what type it was, instead of 3 bools * Getting ready to attempt to modularize flora Moving most vars and procs from ash flora into the normal flora type path, as a general preparation to add more here * Weighted products & Region Messages Rewrites flora code so a flora's produced items can be initialized with a weighted list. Also has some improvements, relating to item stacks. Adds an option via variables to separate 3 messages into 3 possible regions, or the old method where the message changes when the value is exactly the same as the low or high harvest value * organizing + documentation on procs * Documentation, Organization & Modularization (DOMing) yeah, I dom Gives variables for tools that can harvest flora, a blacklist of them, and modularizes variables a bit. Retypes the stump to be a subtype of a tree, which just deletes after being harvested * Adds the ability to uproot flora with a shovel * added eswords to the list of things that can cut * ausbush junk * code review appreciation + changing drag_slowdown * more code review appreciation * kirbyplants ComponentInitialize() -> Initialize() * forgot glob.
246 lines
7.1 KiB
Plaintext
246 lines
7.1 KiB
Plaintext
/obj/structure/trap
|
|
name = "IT'S A TRAP"
|
|
desc = "Stepping on me is a guaranteed bad day."
|
|
icon = 'icons/obj/hand_of_god_structures.dmi'
|
|
icon_state = "trap"
|
|
density = FALSE
|
|
anchored = TRUE
|
|
alpha = 30 //initially quite hidden when not "recharging"
|
|
var/flare_message = "<span class='warning'>the trap flares brightly!</span>"
|
|
var/last_trigger = 0
|
|
var/time_between_triggers = 600 //takes a minute to recharge
|
|
var/charges = INFINITY
|
|
var/antimagic_flags = MAGIC_RESISTANCE
|
|
|
|
var/list/static/ignore_typecache
|
|
var/list/mob/immune_minds = list()
|
|
|
|
var/sparks = TRUE
|
|
var/datum/effect_system/spark_spread/spark_system
|
|
|
|
/obj/structure/trap/Initialize(mapload)
|
|
. = ..()
|
|
flare_message = "<span class='warning'>[src] flares brightly!</span>"
|
|
spark_system = new
|
|
spark_system.set_up(4,1,src)
|
|
spark_system.attach(src)
|
|
|
|
var/static/list/loc_connections = list(
|
|
COMSIG_ATOM_ENTERED = .proc/on_entered
|
|
)
|
|
AddElement(/datum/element/connect_loc, loc_connections)
|
|
|
|
if(!ignore_typecache)
|
|
ignore_typecache = typecacheof(list(
|
|
/obj/effect,
|
|
/mob/dead,
|
|
))
|
|
|
|
/obj/structure/trap/Destroy()
|
|
qdel(spark_system)
|
|
spark_system = null
|
|
. = ..()
|
|
|
|
/obj/structure/trap/examine(mob/user)
|
|
. = ..()
|
|
if(!isliving(user))
|
|
return
|
|
if(user.mind && (user.mind in immune_minds))
|
|
return
|
|
if(get_dist(user, src) <= 1)
|
|
. += span_notice("You reveal [src]!")
|
|
flare()
|
|
|
|
/obj/structure/trap/proc/flare()
|
|
// Makes the trap visible, and starts the cooldown until it's
|
|
// able to be triggered again.
|
|
visible_message(flare_message)
|
|
if(sparks)
|
|
spark_system.start()
|
|
alpha = 200
|
|
last_trigger = world.time
|
|
charges--
|
|
if(charges <= 0)
|
|
animate(src, alpha = 0, time = 10)
|
|
QDEL_IN(src, 10)
|
|
else
|
|
animate(src, alpha = initial(alpha), time = time_between_triggers)
|
|
|
|
/obj/structure/trap/proc/on_entered(datum/source, atom/movable/AM)
|
|
SIGNAL_HANDLER
|
|
if(last_trigger + time_between_triggers > world.time)
|
|
return
|
|
// Don't want the traps triggered by sparks, ghosts or projectiles.
|
|
if(is_type_in_typecache(AM, ignore_typecache))
|
|
return
|
|
if(ismob(AM))
|
|
var/mob/M = AM
|
|
if(M.mind in immune_minds)
|
|
return
|
|
if(M.can_block_magic(antimagic_flags))
|
|
flare()
|
|
return
|
|
if(charges <= 0)
|
|
return
|
|
flare()
|
|
if(isliving(AM))
|
|
trap_effect(AM)
|
|
|
|
/obj/structure/trap/proc/trap_effect(mob/living/L)
|
|
return
|
|
|
|
/obj/structure/trap/stun
|
|
name = "shock trap"
|
|
desc = "A trap that will shock and render you immobile. You'd better avoid it."
|
|
icon_state = "trap-shock"
|
|
var/stun_time = 100
|
|
|
|
/obj/structure/trap/stun/trap_effect(mob/living/L)
|
|
L.electrocute_act(30, src, flags = SHOCK_NOGLOVES) // electrocute act does a message.
|
|
L.Paralyze(stun_time)
|
|
|
|
/obj/structure/trap/stun/hunter
|
|
name = "bounty trap"
|
|
desc = "A trap that only goes off when a fugitive steps on it, announcing the location and stunning the target. You'd better avoid it."
|
|
icon = 'icons/obj/objects.dmi'
|
|
icon_state = "bounty_trap_on"
|
|
stun_time = 200
|
|
sparks = FALSE //the item version gives them off to prevent runtimes (see Destroy())
|
|
antimagic_flags = NONE
|
|
var/obj/item/bountytrap/stored_item
|
|
var/caught = FALSE
|
|
|
|
/obj/structure/trap/stun/hunter/Initialize(mapload)
|
|
. = ..()
|
|
time_between_triggers = 10
|
|
flare_message = "<span class='warning'>[src] snaps shut!</span>"
|
|
|
|
/obj/structure/trap/stun/hunter/Destroy()
|
|
if(!QDELETED(stored_item))
|
|
qdel(stored_item)
|
|
stored_item = null
|
|
return ..()
|
|
|
|
/obj/structure/trap/stun/hunter/on_entered(datum/source, atom/movable/AM)
|
|
if(isliving(AM))
|
|
var/mob/living/L = AM
|
|
if(!L.mind?.has_antag_datum(/datum/antagonist/fugitive))
|
|
return
|
|
caught = TRUE
|
|
. = ..()
|
|
|
|
/obj/structure/trap/stun/hunter/flare()
|
|
..()
|
|
var/turf/our_turf = get_turf(src)
|
|
if(!our_turf)
|
|
return
|
|
stored_item.forceMove(get_turf(src))
|
|
forceMove(stored_item)
|
|
if(caught)
|
|
stored_item.announce_fugitive()
|
|
caught = FALSE
|
|
|
|
/obj/item/bountytrap
|
|
name = "bounty trap"
|
|
desc = "A trap that only goes off when a fugitive steps on it, announcing the location and stunning the target. It's currently inactive."
|
|
icon = 'icons/obj/objects.dmi'
|
|
icon_state = "bounty_trap_off"
|
|
var/obj/structure/trap/stun/hunter/stored_trap
|
|
var/obj/item/radio/radio
|
|
var/datum/effect_system/spark_spread/spark_system
|
|
|
|
/obj/item/bountytrap/Initialize(mapload)
|
|
. = ..()
|
|
radio = new(src)
|
|
radio.subspace_transmission = TRUE
|
|
radio.canhear_range = 0
|
|
radio.recalculateChannels()
|
|
spark_system = new
|
|
spark_system.set_up(4,1,src)
|
|
spark_system.attach(src)
|
|
name = "[name] #[rand(1, 999)]"
|
|
stored_trap = new(src)
|
|
stored_trap.name = name
|
|
stored_trap.stored_item = src
|
|
|
|
/obj/item/bountytrap/proc/announce_fugitive()
|
|
spark_system.start()
|
|
playsound(src, 'sound/machines/ding.ogg', 50, TRUE)
|
|
radio.talk_into(src, "Fugitive has triggered this trap in the [get_area_name(src)]!", RADIO_CHANNEL_COMMON)
|
|
|
|
/obj/item/bountytrap/attack_self(mob/living/user)
|
|
var/turf/T = get_turf(src)
|
|
if(!user || !user.transferItemToLoc(src, T))//visibly unequips
|
|
return
|
|
to_chat(user, span_notice("You set up [src]. Examine while close to disarm it."))
|
|
stored_trap.forceMove(T)//moves trap to ground
|
|
forceMove(stored_trap)//moves item into trap
|
|
|
|
/obj/item/bountytrap/Destroy()
|
|
if(!QDELETED(stored_trap))
|
|
qdel(stored_trap)
|
|
stored_trap = null
|
|
QDEL_NULL(radio)
|
|
QDEL_NULL(spark_system)
|
|
. = ..()
|
|
|
|
/obj/structure/trap/fire
|
|
name = "flame trap"
|
|
desc = "A trap that will set you ablaze. You'd better avoid it."
|
|
icon_state = "trap-fire"
|
|
|
|
/obj/structure/trap/fire/trap_effect(mob/living/L)
|
|
to_chat(L, span_danger("<B>Spontaneous combustion!</B>"))
|
|
L.Paralyze(20)
|
|
new /obj/effect/hotspot(get_turf(src))
|
|
|
|
/obj/structure/trap/chill
|
|
name = "frost trap"
|
|
desc = "A trap that will chill you to the bone. You'd better avoid it."
|
|
icon_state = "trap-frost"
|
|
|
|
/obj/structure/trap/chill/trap_effect(mob/living/L)
|
|
to_chat(L, span_danger("<B>You're frozen solid!</B>"))
|
|
L.Paralyze(20)
|
|
L.adjust_bodytemperature(-300)
|
|
L.apply_status_effect(/datum/status_effect/freon)
|
|
|
|
|
|
/obj/structure/trap/damage
|
|
name = "earth trap"
|
|
desc = "A trap that will summon a small earthquake, just for you. You'd better avoid it."
|
|
icon_state = "trap-earth"
|
|
|
|
|
|
/obj/structure/trap/damage/trap_effect(mob/living/L)
|
|
to_chat(L, span_danger("<B>The ground quakes beneath your feet!</B>"))
|
|
L.Paralyze(100)
|
|
L.adjustBruteLoss(35)
|
|
var/obj/structure/flora/rock/style_random/giant_rock = new(get_turf(src))
|
|
QDEL_IN(giant_rock, 200)
|
|
|
|
|
|
/obj/structure/trap/ward
|
|
name = "divine ward"
|
|
desc = "A divine barrier, It looks like you could destroy it with enough effort, or wait for it to dissipate..."
|
|
icon_state = "ward"
|
|
density = TRUE
|
|
time_between_triggers = 1200 //Exists for 2 minutes
|
|
|
|
/obj/structure/trap/ward/Initialize(mapload)
|
|
. = ..()
|
|
QDEL_IN(src, time_between_triggers)
|
|
|
|
/obj/structure/trap/cult
|
|
name = "unholy trap"
|
|
desc = "A trap that rings with unholy energy. You think you hear... chittering?"
|
|
icon_state = "trap-cult"
|
|
|
|
/obj/structure/trap/cult/trap_effect(mob/living/L)
|
|
to_chat(L, span_danger("<B>With a crack, the hostile constructs come out of hiding, stunning you!</B>"))
|
|
L.electrocute_act(10, src, flags = SHOCK_NOGLOVES) // electrocute act does a message.
|
|
L.Paralyze(20)
|
|
new /mob/living/simple_animal/hostile/construct/proteon/hostile(loc)
|
|
new /mob/living/simple_animal/hostile/construct/proteon/hostile(loc)
|
|
QDEL_IN(src, 30)
|