mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-29 19:52:12 +00:00
191 lines
5.5 KiB
Plaintext
191 lines
5.5 KiB
Plaintext
//separate dm since hydro is getting bloated already
|
|
|
|
/obj/structure/glowshroom
|
|
name = "glowshroom"
|
|
desc = "Mycena Bregprox, a species of mushroom that glows in the dark."
|
|
anchored = 1
|
|
opacity = 0
|
|
density = 0
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "glowshroom" //replaced in New
|
|
layer = 2.1
|
|
var/endurance = 30
|
|
var/delay = 1200
|
|
var/floor = 0
|
|
var/generation = 1
|
|
var/spreadIntoAdjacentChance = 60
|
|
var/obj/item/seeds/myseed = /obj/item/seeds/glowshroom
|
|
|
|
/obj/structure/glowshroom/glowcap
|
|
name = "glowcap"
|
|
desc = "Mycena Ruthenia, a species of mushroom that, while it does glow in the dark, is not actually bioluminescent."
|
|
icon_state = "glowcap"
|
|
myseed = /obj/item/seeds/glowshroom/glowcap
|
|
|
|
/obj/structure/glowshroom/shadowshroom
|
|
name = "shadowshroom"
|
|
desc = "Mycena Umbra, a species of mushroom that emits shadow instead of light."
|
|
icon_state = "shadowshroom"
|
|
myseed = /obj/item/seeds/glowshroom/shadowshroom
|
|
|
|
/obj/structure/glowshroom/single/Spread()
|
|
return
|
|
|
|
/obj/structure/glowshroom/examine(mob/user)
|
|
. = ..()
|
|
to_chat(user, "This is a [generation]\th generation [name]!")
|
|
|
|
/obj/structure/glowshroom/Destroy()
|
|
QDEL_NULL(myseed)
|
|
return ..()
|
|
|
|
/obj/structure/glowshroom/New(loc, obj/item/seeds/newseed, mutate_stats)
|
|
..()
|
|
if(newseed)
|
|
myseed = newseed.Copy()
|
|
myseed.forceMove(src)
|
|
else
|
|
myseed = new myseed(src)
|
|
if(mutate_stats) //baby mushrooms have different stats :3
|
|
myseed.adjust_potency(rand(-3,6))
|
|
myseed.adjust_yield(rand(-1,2))
|
|
myseed.adjust_production(rand(-3,6))
|
|
myseed.adjust_endurance(rand(-3,6))
|
|
delay = delay - myseed.production * 100 //So the delay goes DOWN with better stats instead of up. :I
|
|
endurance = myseed.endurance
|
|
if(myseed.get_gene(/datum/plant_gene/trait/glow))
|
|
var/datum/plant_gene/trait/glow/G = myseed.get_gene(/datum/plant_gene/trait/glow)
|
|
set_light(G.glow_range(myseed), G.glow_power(myseed), G.glow_color)
|
|
setDir(CalcDir())
|
|
var/base_icon_state = initial(icon_state)
|
|
if(!floor)
|
|
switch(dir) //offset to make it be on the wall rather than on the floor
|
|
if(NORTH)
|
|
pixel_y = 32
|
|
if(SOUTH)
|
|
pixel_y = -32
|
|
if(EAST)
|
|
pixel_x = 32
|
|
if(WEST)
|
|
pixel_x = -32
|
|
icon_state = "[base_icon_state][rand(1,3)]"
|
|
else //if on the floor, glowshroom on-floor sprite
|
|
icon_state = "[base_icon_state]f"
|
|
|
|
addtimer(CALLBACK(src, .proc/Spread), delay)
|
|
|
|
/obj/structure/glowshroom/proc/Spread()
|
|
var/turf/ownturf = get_turf(src)
|
|
var/shrooms_planted = 0
|
|
for(var/i in 1 to myseed.yield)
|
|
if(prob(1/(generation * generation) * 100))//This formula gives you diminishing returns based on generation. 100% with 1st gen, decreasing to 25%, 11%, 6, 4, 2...
|
|
var/list/possibleLocs = list()
|
|
var/spreadsIntoAdjacent = FALSE
|
|
|
|
if(prob(spreadIntoAdjacentChance))
|
|
spreadsIntoAdjacent = TRUE
|
|
|
|
for(var/turf/simulated/floor/earth in view(3,src))
|
|
if(!ownturf.CanAtmosPass(earth))
|
|
continue
|
|
if(spreadsIntoAdjacent || !locate(/obj/structure/glowshroom) in view(1,earth))
|
|
possibleLocs += earth
|
|
CHECK_TICK
|
|
|
|
if(!possibleLocs.len)
|
|
break
|
|
|
|
var/turf/newLoc = pick(possibleLocs)
|
|
|
|
var/shroomCount = 0 //hacky
|
|
var/placeCount = 1
|
|
for(var/obj/structure/glowshroom/shroom in newLoc)
|
|
shroomCount++
|
|
for(var/wallDir in cardinal)
|
|
var/turf/isWall = get_step(newLoc,wallDir)
|
|
if(isWall.density)
|
|
placeCount++
|
|
if(shroomCount >= placeCount)
|
|
continue
|
|
|
|
var/obj/structure/glowshroom/child = new type(newLoc, myseed, TRUE)
|
|
child.generation = generation + 1
|
|
shrooms_planted++
|
|
|
|
CHECK_TICK
|
|
else
|
|
shrooms_planted++ //if we failed due to generation, don't try to plant one later
|
|
if(shrooms_planted < myseed.yield) //if we didn't get all possible shrooms planted, try again later
|
|
myseed.yield -= shrooms_planted
|
|
addtimer(CALLBACK(src, .proc/Spread), delay)
|
|
|
|
/obj/structure/glowshroom/proc/CalcDir(turf/location = loc)
|
|
var/direction = 16
|
|
|
|
for(var/wallDir in cardinal)
|
|
var/turf/newTurf = get_step(location,wallDir)
|
|
if(newTurf.density)
|
|
direction |= wallDir
|
|
|
|
for(var/obj/structure/glowshroom/shroom in location)
|
|
if(shroom == src)
|
|
continue
|
|
if(shroom.floor) //special
|
|
direction &= ~16
|
|
else
|
|
direction &= ~shroom.dir
|
|
|
|
var/list/dirList = list()
|
|
|
|
for(var/i=1,i<=16,i <<= 1)
|
|
if(direction & i)
|
|
dirList += i
|
|
|
|
if(dirList.len)
|
|
var/newDir = pick(dirList)
|
|
if(newDir == 16)
|
|
floor = 1
|
|
newDir = 1
|
|
return newDir
|
|
|
|
floor = 1
|
|
return 1
|
|
|
|
/obj/structure/glowshroom/attackby(obj/item/I, mob/user)
|
|
..()
|
|
var/damage_to_do = I.force
|
|
if(istype(I, /obj/item/scythe))
|
|
var/obj/item/scythe/S = I
|
|
if(S.extend) //so folded telescythes won't get damage boosts / insta-clears (they instead will instead be treated like non-scythes)
|
|
damage_to_do *= 4
|
|
for(var/obj/structure/glowshroom/G in range(1,src))
|
|
G.endurance -= damage_to_do
|
|
G.CheckEndurance()
|
|
return
|
|
else if(I.sharp)
|
|
damage_to_do = I.force * 3 // wirecutter: 6->18, knife 10->30, hatchet 12->36
|
|
if(I.damtype != STAMINA)
|
|
endurance -= damage_to_do
|
|
CheckEndurance()
|
|
|
|
/obj/structure/glowshroom/ex_act(severity)
|
|
switch(severity)
|
|
if(1)
|
|
qdel(src)
|
|
if(2)
|
|
if(prob(50))
|
|
qdel(src)
|
|
if(3)
|
|
if(prob(5))
|
|
qdel(src)
|
|
|
|
/obj/structure/glowshroom/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
|
..()
|
|
if(exposed_temperature > 300)
|
|
endurance -= 5
|
|
CheckEndurance()
|
|
|
|
/obj/structure/glowshroom/proc/CheckEndurance()
|
|
if(endurance <= 0)
|
|
qdel(src)
|