more work

This commit is contained in:
Fox-McCloud
2017-01-22 01:46:48 -05:00
parent ea76990b7a
commit 10c0e734c3
19 changed files with 1046 additions and 524 deletions
+55 -74
View File
@@ -2,32 +2,37 @@
/obj/effect/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 = "glowshroomf"
icon_state = "glowshroom" //replaced in New
layer = 2.1
var/endurance = 30
var/potency = 30
var/delay = 1200
var/floor = 0
var/yield = 3
var/spreadChance = 40
var/generation = 1
var/spreadIntoAdjacentChance = 60
var/evolveChance = 2
var/lastTick = 0
var/spreaded = 1
obj/effect/glowshroom/glowcap
name = "glowcap"
icon_state = "glowcap"
/obj/effect/glowshroom/single
spreadChance = 0
yield = 0
/obj/effect/glowshroom/examine(mob/user)
. = ..()
to_chat(user, "This is a [generation]\th generation [name]!")
/obj/effect/glowshroom/New()
..()
set_light(round(potency/10))
dir = 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)
@@ -38,70 +43,52 @@
pixel_x = 32
if(WEST)
pixel_x = -32
icon_state = "glowshroom[rand(1,3)]"
icon_state = "[base_icon_state][rand(1,3)]"
else //if on the floor, glowshroom on-floor sprite
icon_state = "glowshroomf"
icon_state = "[base_icon_state]f"
processing_objects += src
addtimer(src, "Spread", delay)
/obj/effect/glowshroom/proc/Spread()
for(var/i = 1 to 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
set_light(round(potency/10))
lastTick = world.timeofday
if(prob(spreadIntoAdjacentChance))
spreadsIntoAdjacent = TRUE
for(var/turf/simulated/floor/earth in view(3,src))
if(spreadsIntoAdjacent || !locate(/obj/effect/glowshroom) in view(1,earth))
possibleLocs += earth
CHECK_TICK
/obj/effect/glowshroom/Destroy()
processing_objects -= src
return ..()
if(!possibleLocs.len)
break
/obj/effect/glowshroom/process()
if(!spreaded)
return
var/turf/newLoc = pick(possibleLocs)
if(((world.timeofday - lastTick) > delay) || ((world.timeofday - lastTick) < 0))
lastTick = world.timeofday
spreaded = 0
var/shroomCount = 0 //hacky
var/placeCount = 1
for(var/obj/effect/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
for(var/i=1,i<=yield,i++)
if(prob(spreadChance))
var/list/possibleLocs = list()
var/spreadsIntoAdjacent = 0
var/obj/effect/glowshroom/child = new type(newLoc)//The baby mushrooms have different stats :3
child.potency = max(potency + rand(-3,6), 0)
child.yield = max(yield + rand(-1,2), 0)
child.delay = max(delay + rand(-30,60), 0)
child.endurance = max(endurance + rand(-3,6), 1)
child.generation = generation + 1
if(prob(spreadIntoAdjacentChance))
spreadsIntoAdjacent = 1
for(var/turf/simulated/floor/plating/airless/asteroid/earth in view(3,src))
if(spreadsIntoAdjacent || !locate(/obj/effect/glowshroom) in view(1,earth))
possibleLocs += earth
if(!possibleLocs.len)
break
var/turf/newLoc = pick(possibleLocs)
var/shroomCount = 0 //hacky
var/placeCount = 1
for(var/obj/effect/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/effect/glowshroom/child = new /obj/effect/glowshroom(newLoc)
child.potency = potency
child.yield = yield
child.delay = delay
child.endurance = endurance
spreaded++
if(prob(evolveChance)) //very low chance to evolve on its own
potency += rand(4,6)
CHECK_TICK
/obj/effect/glowshroom/proc/CalcDir(turf/location = loc)
//set background = 1
var/direction = 16
for(var/wallDir in cardinal)
@@ -133,28 +120,22 @@
floor = 1
return 1
/obj/effect/glowshroom/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
/obj/effect/glowshroom/attackby(obj/item/I, mob/user)
..()
endurance -= W.force
CheckEndurance()
if(I.damtype != STAMINA)
endurance -= I.force
CheckEndurance()
/obj/effect/glowshroom/ex_act(severity)
switch(severity)
if(1.0)
if(1)
qdel(src)
return
if(2.0)
if(2)
if(prob(50))
qdel(src)
return
if(3.0)
if(3)
if(prob(5))
qdel(src)
return
else
return
/obj/effect/glowshroom/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(exposed_temperature > 300)