Skip to content

Commit 378dc8b

Browse files
dynamic foliage generation
1 parent 1b28902 commit 378dc8b

File tree

5 files changed

+1129
-995
lines changed

5 files changed

+1129
-995
lines changed

code/game/objects/structures/flora/flora.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
..()
1111
update_icon()
1212

13+
/obj/structure/flora/Destroy()
14+
..()
15+
if(istype(loc,/turf/unsimulated/floor/jungle/grass))
16+
var/turf/unsimulated/floor/jungle/grass/G=loc
17+
G.turf_speed_multiplier=1.1
18+
1319
/obj/structure/flora/update_icon()
1420
clicked = new/icon(src.icon, src.icon_state, src.dir)
1521

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//subtype used in junglestation for tunnels. do NOT spawn it normally.
2+
3+
/obj/structure/ladder/jungle_tunnel
4+
5+
6+
/obj/structure/ladder/jungle_tunnel/ex_act()
7+
return
8+
/obj/structure/ladder/jungle_tunnel/singularity_act()
9+
return 0
10+
11+
12+
/obj/structure/ladder/jungle_tunnel/Destroy()
13+
..()
14+
if(up)
15+
qdel(up)
16+
if(down)
17+
qdel(down)
18+
var/turf/T = loc
19+
if(T.type==/turf/unsimulated/floor/jungle/bedrock)
20+
var/turf/unsimulated/floor/jungle/bedrock/TT=T
21+
TT.hashole=null
22+
TT.icon_state="mariahive_noanimation"
23+
if(T.type==/turf/unsimulated/floor/jungle/dirt)
24+
var/turf/unsimulated/floor/jungle/dirt/TT=T
25+
TT.hashole=null
26+
27+

code/game/turfs/unsimulated/jungle.dm

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,62 @@
3333
return 0.0
3434

3535

36+
37+
var/list/foliage_choices=list(
38+
/obj/structure/flora/ausbushes,
39+
/obj/structure/flora/ausbushes/brflowers,
40+
/obj/structure/flora/ausbushes/fernybush,
41+
/obj/structure/flora/ausbushes/fullgrass,
42+
/obj/structure/flora/ausbushes/genericbush,
43+
/obj/structure/flora/ausbushes/grassybush,
44+
/obj/structure/flora/ausbushes/lavendergrass,
45+
/obj/structure/flora/ausbushes/leafybush,
46+
/obj/structure/flora/ausbushes/palebush,
47+
/obj/structure/flora/ausbushes/pointybush,
48+
/obj/structure/flora/ausbushes/ppflowers,
49+
/obj/structure/flora/ausbushes/reedbush,
50+
/obj/structure/flora/ausbushes/sparsegrass,
51+
/obj/structure/flora/ausbushes/stalkybush,
52+
/obj/structure/flora/ausbushes/sunnybush,
53+
)
54+
3655
/turf/unsimulated/floor/jungle/grass
3756
name="Jungle Grass"
3857
desc="A thick and lush carpet of various plant species, sustained by a regular supply to water."
3958
icon = 'icons/turf/floors.dmi'
4059
icon_state = "grass_alt1"
4160
turf_speed_multiplier=1.1 // tall grass.
4261

62+
/turf/unsimulated/floor/jungle/grass/New(var/loc,var/NO_GROW=FALSE)
63+
..()
64+
if(NO_GROW)
65+
return
66+
67+
if (prob(50))
68+
var/plantseed = abs(( sin((x+rand(-2,2))*5.01+213.998) + sin((y+rand(-2,2))*4.56+71.294) )%%1.0)
69+
plantseed = 1+floor(plantseed*(foliage_choices.len-0.01))//mmm, dumb float math
70+
71+
var/create=foliage_choices[plantseed]
72+
if(create)
73+
new create(src)
74+
turf_speed_multiplier+=0.6
75+
else if(prob(20)) //10% overall
76+
if( !(locate(/obj/structure/flora/tree) in view(1,src)) )
77+
new/obj/structure/flora/tree/shitty(src)
78+
79+
80+
/turf/unsimulated/floor/jungle/grass/Destroy()
81+
..()
82+
for(var/obj/structure/flora/F in contents)
83+
qdel(F)
84+
4385
/turf/unsimulated/floor/jungle/grass/attackby(obj/item/C as obj, mob/user as mob)
86+
..()
4487
if(!C || !user)
4588
return 0
4689
var/s=0.0
4790
s=item_terraforming_ispickaxe(C)
48-
if(s>0.0)
91+
if(s>0.0 && !(locate(/obj/structure/flora) in contents))
4992
to_chat(user, "<span class='notice'>You start breaking up the soil</span>")
5093
if(do_after(user, src, 20/s ))
5194
ChangeTurf(/turf/unsimulated/floor/jungle/dirt)
@@ -67,6 +110,10 @@
67110
..()
68111
icon_state="grass_alt[rand(1,4)]"
69112

113+
/turf/unsimulated/floor/jungle/grass/no_flora //BYOND...
114+
/turf/unsimulated/floor/jungle/grass/no_flora/New(var/loc)
115+
..(loc,TRUE)
116+
70117

71118
/turf/unsimulated/floor/jungle/mud
72119
name="Mud"
@@ -103,7 +150,7 @@
103150
name="Soil"
104151
desc="A mixture of sediments, clays, and decomposed matter."
105152
icon_state = "ironsand1"
106-
var/obj/structure/ladder/hashole=null
153+
var/obj/structure/ladder/jungle_tunnel/hashole=null
107154

108155
/turf/unsimulated/floor/jungle/dirt/examine()
109156
..()
@@ -116,7 +163,7 @@
116163
if(C.type== /obj/item/stack/tile/grass && !hashole)
117164
var/obj/item/stack/tile/T = C
118165
if(T.use(1))
119-
ChangeTurf(/turf/unsimulated/floor/jungle/grass)
166+
ChangeTurf(/turf/unsimulated/floor/jungle/grass/no_flora)
120167
var/s=0.0
121168
s=item_terraforming_isshovel(C)
122169
if(s>0.0 && !hashole)
@@ -129,8 +176,8 @@
129176
if(do_after(user, src, 80/s ))
130177
if(!hashole)
131178
to_chat(usr,"you finish making a hole.")
132-
var/obj/structure/ladder/l_surf=new(src)
133-
var/obj/structure/ladder/l_tunnel=new(locate(x,y,2))
179+
var/obj/structure/ladder/jungle_tunnel/l_surf=new(src)
180+
var/obj/structure/ladder/jungle_tunnel/l_tunnel=new(locate(x,y,2))
134181
l_tunnel.up=l_surf
135182
l_surf.down=l_tunnel
136183
hashole=l_surf
@@ -321,15 +368,14 @@
321368
desc="A very dense rock. Nothing seems to be able to dig through it."
322369
icon='icons/turf/walls.dmi'
323370
icon_state = "mariahive_noanimation"
324-
var/obj/structure/ladder/hashole=null
371+
var/obj/structure/ladder/jungle_tunnel/hashole=null
325372

326373

327374
/turf/unsimulated/floor/jungle/bedrock/New(var/loc)
328-
if(locate(/obj/structure/ladder) in contents)
375+
if(locate(/obj/structure/ladder/jungle_tunnel) in contents)
329376
icon_state="mariahive_noanimation_l"
330377

331-
var/turf/T=locate(x,y,1)
332-
if(T && (!istype(T,/turf/unsimulated/floor/jungle) || T.type==/turf/unsimulated/floor/jungle/path_plated || T.type==/turf/unsimulated/floor/jungle/water || T.type==/turf/unsimulated/floor/jungle/water_deep))
378+
if(!cannot_dig_up())
333379
icon_state="mariahive_noanimation_d"
334380

335381
/turf/unsimulated/floor/jungle/bedrock/attackby(obj/item/C as obj, mob/user as mob)
@@ -338,17 +384,15 @@
338384
var/s=0.0
339385
s=item_terraforming_ispickaxe(C)
340386
if(s>0.0 && !hashole)
341-
var/turf/T=locate(x,y,1) //if there's no blockers above us
342-
if(T && istype(T,/turf/unsimulated/floor/jungle) && T.type!=/turf/unsimulated/floor/jungle/path_plated && T.type!=/turf/unsimulated/floor/jungle/water && T.type!=/turf/unsimulated/floor/jungle/water_deep && T.type!=/turf/unsimulated/floor/jungle/concrete )
387+
if(!cannot_dig_up() )
343388
to_chat(usr,"you start digging upwards...")
344389
if(do_after(user, src, 80/s ))
345-
T=locate(x,y,1)
346-
if(!hashole && T && istype(T,/turf/unsimulated/floor/jungle) && T.type!=/turf/unsimulated/floor/jungle/path_plated && T.type!=/turf/unsimulated/floor/jungle/water && T.type!=/turf/unsimulated/floor/jungle/water_deep && T.type!=/turf/unsimulated/floor/jungle/concrete )
390+
if(!hashole && !cannot_dig_up() )
347391
to_chat(usr,"you finish making a hole.")
348392
icon_state="mariahive_noanimation_l"
349393

350-
var/obj/structure/ladder/l_tunnel=new(src)
351-
var/obj/structure/ladder/l_surf=new(locate(x,y,1))
394+
var/obj/structure/ladder/jungle_tunnel/l_tunnel=new(src)
395+
var/obj/structure/ladder/jungle_tunnel/l_surf=new(locate(x,y,1))
352396

353397
l_tunnel.up=l_surf
354398
l_surf.down=l_tunnel
@@ -362,13 +406,13 @@
362406
to_chat(usr,"something gets in your way.")
363407
return
364408
else
365-
to_chat(usr,"something solid prevents you from tunneling upwards.")
409+
to_chat(usr,cannot_dig_up() || "something solid prevents you from tunneling upwards.")
366410

367411

368412
/turf/unsimulated/floor/jungle/bedrock/examine()
369413
..()
370414
if(icon_state=="mariahive_noanimation_d")
371-
to_chat(usr,"it seems that there's something solid above you that you won't be able to dig through.")
415+
to_chat(usr,cannot_dig_up() || "it seems that there's something solid above you that you won't be able to dig through.")
372416
return
373417
if(icon_state=="mariahive_noanimation_l")
374418
to_chat(usr,"there's a hole leading to the surface.")
@@ -381,11 +425,10 @@
381425
..()
382426
icon_state="mariahive_noanimation"
383427

384-
if(locate(/obj/structure/ladder) in contents)
428+
if(locate(/obj/structure/ladder/jungle_tunnel) in contents)
385429
icon_state="mariahive_noanimation_l"
386430

387-
var/turf/T=locate(x,y,1)
388-
if(T && (!istype(T,/turf/unsimulated/floor/jungle) || T.type==/turf/unsimulated/floor/jungle/path_plated || T.type==/turf/unsimulated/floor/jungle/water || T.type==/turf/unsimulated/floor/jungle/water_deep || T.type==/turf/unsimulated/floor/jungle/concrete))
431+
if(cannot_dig_up())
389432
icon_state="mariahive_noanimation_d"
390433

391434
if(recursive) //we reveal the state of surrounding bedrock. there's probably a better way to do this.
@@ -414,6 +457,22 @@
414457
if(T2 && T2.type==/turf/unsimulated/floor/jungle/bedrock)
415458
T2.Entered(Obj,FALSE)
416459

460+
/turf/unsimulated/floor/jungle/bedrock/proc/cannot_dig_up()
461+
var/turf/T=locate(x,y,1)
462+
var/T_T=T.type
463+
if(!istype(T,/turf/unsimulated/floor/jungle))
464+
return "something hard blocks the way."
465+
if(T_T==/turf/unsimulated/floor/jungle/path_plated)
466+
return "something hard blocks the way."
467+
if(T_T==/turf/unsimulated/floor/jungle/water)
468+
return "something tells you that this is a really bad idea."
469+
if(T_T==/turf/unsimulated/floor/jungle/water_deep)
470+
return "something tells you that this is a really bad idea."
471+
if(T_T==/turf/unsimulated/floor/jungle/concrete)
472+
return "something hard blocks the way."
473+
if(locate(/obj/structure/flora/tree) in T.contents)
474+
return "there's too many roots in the way."
475+
return null
417476

418477
/turf/unsimulated/floor/jungle/bedrock/ex_act(severity)
419478
return

0 commit comments

Comments
 (0)