-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathhydroponics.dm
992 lines (846 loc) · 38.2 KB
/
hydroponics.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
/obj/machinery/hydroponics
name = "hydroponics tray"
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "hydrotray"
density = TRUE
pixel_z = 8
obj_flags = CAN_BE_HIT | UNIQUE_RENAME | UNIQUE_REDESC
circuit = /obj/item/circuitboard/machine/hydroponics
var/waterlevel = 100 //The amount of water in the tray (max 100)
var/maxwater = 100 //The maximum amount of water in the tray
var/nutrilevel = 10 //The amount of nutrient in the tray (max 10)
var/maxnutri = 10 //The maximum nutrient of water in the tray
var/pestlevel = 0 //The amount of pests in the tray (max 10)
var/weedlevel = 0 //The amount of weeds in the tray (max 10)
var/yieldmod = 1 //Nutriment's effect on yield
var/mutmod = 1 //Nutriment's effect on mutations
var/toxic = 0 //Toxicity in the tray?
var/age = 0 //Current age
var/dead = 0 //Is it dead?
var/plant_health //Its health
var/lastproduce = 0 //Last time it was harvested
var/lastcycle = 0 //Used for timing of cycles.
var/cycledelay = 200 //About 10 seconds / cycle
var/harvest = 0 //Ready to harvest?
var/obj/item/seeds/myseed = null //The currently planted seed
var/rating = 1
var/unwrenchable = 1
var/recent_bee_visit = FALSE //Have we been visited by a bee recently, so bees dont overpollinate one plant
var/using_irrigation = FALSE //If the tray is connected to other trays via irrigation hoses
var/self_sufficiency_req = 20 //Required total dose to make a self-sufficient hydro tray. 1:1 with earthsblood.
var/self_sufficiency_progress = 0
var/self_sustaining = FALSE //If the tray generates nutrients and water on its own
/obj/machinery/hydroponics/constructable
name = "hydroponics tray"
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "hydrotray3"
/obj/machinery/hydroponics/constructable/RefreshParts()
var/tmp_capacity = 0
for (var/obj/item/stock_parts/matter_bin/M in component_parts)
tmp_capacity += M.rating
for (var/obj/item/stock_parts/manipulator/M in component_parts)
rating = M.rating
maxwater = tmp_capacity * 50 // Up to 300
maxnutri = tmp_capacity * 5 // Up to 30
/obj/machinery/hydroponics/constructable/examine(mob/user)
. = ..()
if(in_range(user, src) || isobserver(user))
. += "<span class='notice'>The status display reads: Tray efficiency at <b>[rating*100]%</b>.<span>"
/obj/machinery/hydroponics/Destroy()
if(myseed)
qdel(myseed)
myseed = null
return ..()
/obj/machinery/hydroponics/constructable/attackby(obj/item/I, mob/living/user, params)
if (!user.combat_mode)
// handle opening the panel
if(default_deconstruction_screwdriver(user, icon_state, icon_state, I))
return
// handle deconstructing the machine, if permissible
if(I.tool_behaviour == TOOL_CROWBAR && using_irrigation)
to_chat(user, span_warning("Disconnect the hoses first!"))
return
else if(default_deconstruction_crowbar(I))
return
return ..()
/obj/machinery/hydroponics/proc/FindConnected()
var/list/connected = list()
var/list/processing_atoms = list(src)
while(processing_atoms.len)
var/atom/a = processing_atoms[1]
for(var/step_dir in GLOB.cardinals)
var/obj/machinery/hydroponics/h = locate() in get_step(a, step_dir)
// Soil plots aren't dense
if(h && h.using_irrigation && h.density && !(h in connected) && !(h in processing_atoms))
processing_atoms += h
processing_atoms -= a
connected += a
return connected
/obj/machinery/hydroponics/bullet_act(obj/projectile/Proj) //Works with the Somatoray to modify plant variables.
if(!myseed)
return ..()
if(istype(Proj , /obj/projectile/energy/floramut))
mutate()
else if(istype(Proj , /obj/projectile/energy/florayield))
return myseed.bullet_act(Proj)
else
return ..()
/obj/machinery/hydroponics/process(delta_time)
var/needs_update = 0 // Checks if the icon needs updating so we don't redraw empty trays every time
if(myseed && (myseed.loc != src))
myseed.forceMove(src)
if(self_sustaining)
adjustNutri(1)
adjustWater(rand(1,2) * delta_time * 0.5)
adjustWeeds(-0.5 * delta_time)
adjustPests(-0.5 * delta_time)
adjustToxic(-2)
needs_update = TRUE
if(world.time > (lastcycle + cycledelay))
lastcycle = world.time
if(myseed && !dead)
// Advance age
age++
if(age < myseed.maturation)
lastproduce = age
needs_update = 1
//Nutrients//////////////////////////////////////////////////////////////
// Nutrients deplete slowly
if(prob(50))
adjustNutri(-1 / rating)
// Lack of nutrients hurts non-weeds
if(nutrilevel <= 0 && !myseed.get_gene(/datum/plant_gene/trait/plant_type/weed_hardy))
adjustHealth(-rand(1,3))
//Photosynthesis/////////////////////////////////////////////////////////
// Lack of light hurts non-mushrooms
if(isturf(loc))
var/turf/currentTurf = loc
var/lightAmt = currentTurf.get_lumcount()
if(myseed.get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism))
if(lightAmt < 0.2)
adjustHealth(-1 / rating)
else // Non-mushroom
if(lightAmt < 0.4)
adjustHealth(-2 / rating)
//Water//////////////////////////////////////////////////////////////////
// Drink random amount of water
adjustWater(-rand(1,6) / rating)
// If the plant is dry, it loses health pretty fast, unless mushroom
if(waterlevel <= 10 && !myseed.get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism))
adjustHealth(-rand(0,1) / rating)
if(waterlevel <= 0)
adjustHealth(-rand(0,2) / rating)
// Sufficient water level and nutrient level = plant healthy but also spawns weeds
else if(waterlevel > 10 && nutrilevel > 0)
adjustHealth(rand(1,2) / rating)
if(myseed && prob(myseed.weed_chance))
adjustWeeds(myseed.weed_rate)
else if(prob(5)) //5 percent chance the weed population will increase
adjustWeeds(1 / rating)
//Toxins/////////////////////////////////////////////////////////////////
// Too much toxins cause harm, but when the plant drinks the contaiminated water, the toxins disappear slowly
if(toxic >= 40 && toxic < 80)
adjustHealth(-1 / rating)
adjustToxic(-rand(1,10) / rating)
else if(toxic >= 80) // I don't think it ever gets here tbh unless above is commented out
adjustHealth(-3)
adjustToxic(-rand(1,10) / rating)
//Pests & Weeds//////////////////////////////////////////////////////////
else if(pestlevel >= 5)
adjustHealth(-1 / rating)
// If it's a weed, it doesn't stunt the growth
if(weedlevel >= 5 && !myseed.get_gene(/datum/plant_gene/trait/plant_type/weed_hardy))
adjustHealth(-1 / rating)
//Health & Age///////////////////////////////////////////////////////////
// Plant dies if plant_health <= 0
if(plant_health <= 0)
plantdies()
adjustWeeds(1 / rating) // Weeds flourish
// If the plant is too old, lose health fast
if(age > myseed.lifespan)
adjustHealth(-rand(1,5) / rating)
// Harvest code
if(age > myseed.production && (age - lastproduce) > myseed.production && (!harvest && !dead))
nutrimentMutation()
if(myseed && myseed.yield != -1) // Unharvestable shouldn't be harvested
harvest = 1
else
lastproduce = age
if(prob(5)) // On each tick, there's a 5 percent chance the pest population will increase
adjustPests(1 / rating)
else
if(waterlevel > 10 && nutrilevel > 0 && prob(10)) // If there's no plant, the percentage chance is 10%
adjustWeeds(1 / rating)
// Weeeeeeeeeeeeeeedddssss
if(weedlevel >= 10 && prob(50)) // At this point the plant is kind of fucked. Weeds can overtake the plant spot.
if(myseed)
if(!myseed.get_gene(/datum/plant_gene/trait/plant_type/weed_hardy) && !myseed.get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) // If a normal plant
weedinvasion()
else
weedinvasion() // Weed invasion into empty tray
needs_update = 1
if(needs_update)
update_appearance(UPDATE_ICON)
return
/obj/machinery/hydroponics/proc/nutrimentMutation()
if (mutmod == 0)
return
if (mutmod == 1)
if(prob(80)) //80%
mutate()
else if(prob(75)) //15%
hardmutate()
return
if (mutmod == 2)
if(prob(50)) //50%
mutate()
else if(prob(50)) //25%
hardmutate()
else if(prob(50)) //12.5%
mutatespecie()
return
return
/obj/machinery/hydroponics/update_icon(updates=ALL)
. = ..()
//Refreshes the icon and sets the luminosity
cut_overlays()
if(self_sustaining)
if(istype(src, /obj/machinery/hydroponics/soil))
add_atom_colour(rgb(255, 175, 0), FIXED_COLOUR_PRIORITY)
else
add_overlay(mutable_appearance('icons/obj/hydroponics/equipment.dmi', "gaia_blessing"))
set_light(3)
update_icon_hoses()
if(myseed)
update_icon_plant()
update_icon_lights()
if(!self_sustaining)
if(myseed && 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)
else
set_light(0)
return
/obj/machinery/hydroponics/proc/update_icon_hoses()
var/n = 0
for(var/Dir in GLOB.cardinals)
var/obj/machinery/hydroponics/t = locate() in get_step(src,Dir)
if(t && t.using_irrigation && using_irrigation)
n += Dir
icon_state = "hoses-[n]"
/obj/machinery/hydroponics/proc/update_icon_plant()
var/mutable_appearance/plant_overlay = mutable_appearance(myseed.growing_icon, layer = OBJ_LAYER + 0.01)
if(dead)
plant_overlay.icon_state = myseed.icon_dead
else if(harvest)
if(!myseed.icon_harvest)
plant_overlay.icon_state = "[myseed.icon_grow][myseed.growthstages]"
else
plant_overlay.icon_state = myseed.icon_harvest
else
var/t_growthstate = clamp(round((age / myseed.maturation) * myseed.growthstages), 1, myseed.growthstages)
plant_overlay.icon_state = "[myseed.icon_grow][t_growthstate]"
add_overlay(plant_overlay)
/obj/machinery/hydroponics/proc/update_icon_lights()
if(waterlevel <= 10)
add_overlay(mutable_appearance('icons/obj/hydroponics/equipment.dmi', "over_lowwater3"))
if(nutrilevel <= 2)
add_overlay(mutable_appearance('icons/obj/hydroponics/equipment.dmi', "over_lownutri3"))
if(plant_health <= (myseed.endurance / 2))
add_overlay(mutable_appearance('icons/obj/hydroponics/equipment.dmi', "over_lowhealth3"))
if(weedlevel >= 5 || pestlevel >= 5 || toxic >= 40)
add_overlay(mutable_appearance('icons/obj/hydroponics/equipment.dmi', "over_alert3"))
if(harvest)
add_overlay(mutable_appearance('icons/obj/hydroponics/equipment.dmi', "over_harvest3"))
/obj/machinery/hydroponics/examine(mob/user)
. = ..()
if(myseed)
. += span_info("It has [span_name("[myseed.plantname]")] planted.")
if (dead)
. += span_warning("It's dead!")
else if (harvest)
. += span_info("It's ready to harvest.")
else if (plant_health <= (myseed.endurance / 2))
. += span_warning("It looks unhealthy.")
if(user.skill_check(SKILL_SCIENCE, EXP_LOW))
. += myseed.get_analyzer_text(user, TRUE)
else
. += span_info("It's empty.")
if(!self_sustaining)
. += "[span_info("Water: [waterlevel]/[maxwater].")]\n"+\
span_info("Nutrient: [nutrilevel]/[maxnutri].")
if(self_sufficiency_progress > 0)
var/percent_progress = round(self_sufficiency_progress * 100 / self_sufficiency_req)
. += span_info("Treatment for self-sustenance are [percent_progress]% complete.")
else
. += span_info("It doesn't require any water or nutrients.")
if(weedlevel >= 5)
to_chat(user, span_warning("It's filled with weeds!"))
if(pestlevel >= 5)
to_chat(user, span_warning("It's filled with tiny worms!"))
/obj/machinery/hydroponics/proc/weedinvasion() // If a weed growth is sufficient, this happens.
dead = 0
var/oldPlantName
if(myseed) // In case there's nothing in the tray beforehand
oldPlantName = myseed.plantname
qdel(myseed)
myseed = null
else
oldPlantName = "empty tray"
switch(rand(1,18)) // randomly pick predominative weed
if(16 to 18)
myseed = new /obj/item/seeds/reishi(src)
if(14 to 15)
myseed = new /obj/item/seeds/nettle(src)
if(12 to 13)
myseed = new /obj/item/seeds/harebell(src)
if(10 to 11)
myseed = new /obj/item/seeds/amanita(src)
if(8 to 9)
myseed = new /obj/item/seeds/chanter(src)
if(6 to 7)
myseed = new /obj/item/seeds/tower(src)
if(4 to 5)
myseed = new /obj/item/seeds/plump(src)
else
myseed = new /obj/item/seeds/starthistle(src)
age = 0
plant_health = myseed.endurance
lastcycle = world.time
harvest = 0
weedlevel = 0 // Reset
pestlevel = 0 // Reset
visible_message(span_warning("The [oldPlantName] is overtaken by some [myseed.plantname]!"))
update_appearance()
/obj/machinery/hydroponics/proc/mutate(lifemut = 2, endmut = 5, productmut = 1, yieldmut = 2, potmut = 25, wrmut = 2, wcmut = 5, traitmut = 0) // Mutates the current seed
if(!myseed)
return
myseed.mutate(lifemut, endmut, productmut, yieldmut, potmut, wrmut, wcmut, traitmut)
/obj/machinery/hydroponics/proc/hardmutate()
mutate(4, 10, 2, 4, 50, 4, 10, 3)
/obj/machinery/hydroponics/proc/mutatespecie() // Mutagent produced a new plant!
if(!myseed || dead)
return
var/oldPlantName = myseed.plantname
if(myseed.mutatelist.len > 0)
var/mutantseed = pick(myseed.mutatelist)
qdel(myseed)
myseed = null
myseed = new mutantseed
else
return
hardmutate()
age = 0
plant_health = myseed.endurance
lastcycle = world.time
harvest = 0
weedlevel = 0 // Reset
sleep(0.5 SECONDS) // Wait a while
visible_message(span_warning("[oldPlantName] suddenly mutates into [myseed.plantname]!"))
update_appearance()
/obj/machinery/hydroponics/proc/mutateweed() // If the weeds gets the mutagent instead. Mind you, this pretty much destroys the old plant
if( weedlevel > 5 )
if(myseed)
qdel(myseed)
myseed = null
var/newWeed = pick(/obj/item/seeds/liberty, /obj/item/seeds/angel, /obj/item/seeds/nettle/death)
myseed = new newWeed
dead = 0
hardmutate()
age = 0
plant_health = myseed.endurance
lastcycle = world.time
harvest = 0
weedlevel = 0 // Reset
sleep(0.5 SECONDS) // Wait a while
visible_message(span_warning("The mutated weeds in [src] spawn some [myseed.plantname]!"))
update_appearance()
else
to_chat(usr, span_warning("The few weeds in [src] seem to react, but only for a moment..."))
/obj/machinery/hydroponics/proc/plantdies() // OH NOES!!!!! I put this all in one function to make things easier
plant_health = 0
harvest = 0
pestlevel = 0 // Pests die
lastproduce = 0
if(!dead)
dead = TRUE
update_appearance(UPDATE_ICON)
/obj/machinery/hydroponics/proc/mutatepest(mob/user)
if(pestlevel > 5)
message_admins("[ADMIN_LOOKUPFLW(user)] caused spiderling pests to spawn in a hydro tray")
log_game("[key_name(user)] caused spiderling pests to spawn in a hydro tray")
visible_message(span_warning("The pests seem to behave oddly..."))
spawn_atom_to_turf(/obj/structure/spider/spiderling/hunter, src, 3, FALSE)
else
to_chat(user, span_warning("The pests seem to behave oddly, but quickly settle down..."))
/obj/machinery/hydroponics/proc/applyChemicals(datum/reagents/S, mob/user)
if(myseed)
myseed.on_chem_reaction(S) //In case seeds have some special interactions with special chems, currently only used by vines
// Requires 5 mutagen to possibly change species.// Poor man's mutagen.
if(S.has_reagent(/datum/reagent/toxin/mutagen, 5) || S.has_reagent(/datum/reagent/uranium/radium, 10) || S.has_reagent(/datum/reagent/uranium, 10))
switch(rand(100))
if(91 to 100)
adjustHealth(-10)
to_chat(user, span_warning("The plant shrivels and burns."))
if(81 to 90)
mutatespecie()
if(66 to 80)
hardmutate()
if(41 to 65)
mutate()
if(21 to 41)
to_chat(user, span_notice("The plants don't seem to react..."))
if(11 to 20)
mutateweed()
if(1 to 10)
mutatepest(user)
else
to_chat(user, span_notice("Nothing happens..."))
// 2 or 1 units is enough to change the yield and other stats.// Can change the yield and other stats, but requires more than mutagen
else if(S.has_reagent(/datum/reagent/toxin/mutagen, 2) || S.has_reagent(/datum/reagent/uranium/radium, 5) || S.has_reagent(/datum/reagent/uranium, 5))
hardmutate()
else if(S.has_reagent(/datum/reagent/toxin/mutagen, 1) || S.has_reagent(/datum/reagent/uranium/radium, 2) || S.has_reagent(/datum/reagent/uranium, 2))
mutate()
// After handling the mutating, we now handle the damage from adding crude radioactives...
if(S.has_reagent(/datum/reagent/uranium, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/uranium) * 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/uranium) * 2))
if(S.has_reagent(/datum/reagent/uranium/radium, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/uranium/radium) * 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/uranium/radium) * 3)) // Radium is harsher (OOC: also easier to produce)
// Nutriments
if(S.has_reagent(/datum/reagent/plantnutriment/eznutriment, 1))
yieldmod = 1
mutmod = 1
adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/eznutriment) * 1))
if(S.has_reagent(/datum/reagent/plantnutriment/left4zednutriment, 1))
yieldmod = 0
mutmod = 2
adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/left4zednutriment) * 1))
if(S.has_reagent(/datum/reagent/plantnutriment/robustharvestnutriment, 1))
yieldmod = 1.3
mutmod = 0
adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/robustharvestnutriment) *1 ))
if(S.has_reagent(/datum/reagent/plantnutriment/tribalnutriment, 1))
mutmod = 0
adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/tribalnutriment) *1 ))
// Ambrosia Gaia produces earthsblood.
if(S.has_reagent(/datum/reagent/medicine/earthsblood))
self_sufficiency_progress += S.get_reagent_amount(/datum/reagent/medicine/earthsblood)
if(self_sufficiency_progress >= self_sufficiency_req)
become_self_sufficient()
else if(!self_sustaining)
to_chat(user, span_notice("[src] warms as it might on a spring day under a genuine Sun."))
// Antitoxin binds shit pretty well. So the tox goes significantly down
if(S.has_reagent(/datum/reagent/medicine/charcoal, 1))
adjustToxic(-round(S.get_reagent_amount(/datum/reagent/medicine/charcoal) * 2))
if(S.has_reagent(/datum/reagent/toxin, 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin) * 2))
// Milk is good for humans, but bad for plants. The sugars canot be used by plants, and the milk fat fucks up growth. Not shrooms though. I can't deal with this now...
if(S.has_reagent(/datum/reagent/consumable/milk, 1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/milk) * 0.1))
adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/milk) * 0.9))
// Beer is a chemical composition of alcohol and various other things. It's a shitty nutrient but hey, it's still one. Also alcohol is bad, mmmkay?
if(S.has_reagent(/datum/reagent/consumable/ethanol/beer, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.05))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.25))
adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.7))
// You're an idiot for thinking that one of the most corrosive and deadly gasses would be beneficial
if(S.has_reagent(/datum/reagent/fluorine, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/fluorine) * 2))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/fluorine) * 2.5))
adjustWater(-round(S.get_reagent_amount(/datum/reagent/fluorine) * 0.5))
adjustWeeds(-rand(1,4))
// You're an idiot for thinking that one of the most corrosive and deadly gasses would be beneficial
if(S.has_reagent(/datum/reagent/chlorine, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/chlorine) * 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/chlorine) * 1.5))
adjustWater(-round(S.get_reagent_amount(/datum/reagent/chlorine) * 0.5))
adjustWeeds(-rand(1,3))
// White Phosphorous + water -> phosphoric acid. That's not a good thing really.
// Phosphoric salts are beneficial though. And even if the plant suffers, in the long run the tray gets some nutrients. The benefit isn't worth that much.
if(S.has_reagent(/datum/reagent/phosphorus, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.75))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.1))
adjustWater(-round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.5))
adjustWeeds(-rand(1,2))
// Plants should not have sugar, they can't use it and it prevents them getting water/ nutients, it is good for mold though...
if(S.has_reagent(/datum/reagent/consumable/sugar, 1))
adjustWeeds(rand(1,2))
adjustPests(rand(1,2))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/sugar) * 0.1))
// It is water!
if(S.has_reagent(/datum/reagent/water, 1))
adjustWater(round(S.get_reagent_amount(/datum/reagent/water) * 1))
// Holy water. Mostly the same as water, it also heals the plant a little with the power of the spirits~
if(S.has_reagent(/datum/reagent/water/holywater, 1))
adjustWater(round(S.get_reagent_amount(/datum/reagent/water/holywater) * 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/water/holywater) * 0.1))
// A variety of nutrients are dissolved in club soda, without sugar.
// These nutrients include carbon, oxygen, hydrogen, phosphorous, potassium, sulphur and sodium, all of which are needed for healthy plant growth.
if(S.has_reagent(/datum/reagent/consumable/sodawater, 1))
adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 0.1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 0.1))
// Man, you guys are ridiculous haha that's what it said before..
if(S.has_reagent(/datum/reagent/toxin/acid, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/acid) * 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/acid) * 1.5))
adjustWeeds(-rand(1,2))
// SERIOUSLY
if(S.has_reagent(/datum/reagent/toxin/acid/fluacid, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/acid/fluacid) * 2))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/acid/fluacid) * 3))
adjustWeeds(-rand(1,4))
// Plant-B-Gone is just as bad
if(S.has_reagent(/datum/reagent/toxin/plantbgone, 1))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone) * 5))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone) * 6))
adjustWeeds(-rand(4,8))
// why, just why
if(S.has_reagent(/datum/reagent/napalm, 1))
if(!(myseed.resistance_flags & FIRE_PROOF))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/napalm) * 6))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/napalm) * 7))
adjustWeeds(-rand(5,9)) //At least give them a small reward if they bother.
//Weed Spray
if(S.has_reagent(/datum/reagent/toxin/plantbgone/weedkiller, 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone/weedkiller) * 0.5))
//old toxicity was 4, each spray is default 10 (minimal of 5) so 5 and 2.5 are the new ammounts
adjustWeeds(-rand(1,2))
//Pest Spray
if(S.has_reagent(/datum/reagent/toxin/pestkiller, 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/pestkiller) * 0.5))
adjustPests(-rand(1,2))
//Nicotine is used as a pesticide IRL.
if(S.has_reagent(/datum/reagent/drug/nicotine, 1))
adjustToxic(round(S.get_reagent_amount(/datum/reagent/drug/nicotine)))
adjustPests(-rand(1,2))
// Healing
if(S.has_reagent(/datum/reagent/medicine/cryoxadone, 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/medicine/cryoxadone) * 3))
adjustToxic(-round(S.get_reagent_amount(/datum/reagent/medicine/cryoxadone) * 3))
// Ammonia is bad ass.
if(S.has_reagent(/datum/reagent/ammonia, 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/ammonia) * 0.5))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/ammonia) * 1))
if(myseed)
myseed.adjust_yield(round(S.get_reagent_amount(/datum/reagent/ammonia) * 0.01))
// Saltpetre is used for gardening IRL, to simplify highly, it speeds up growth and strengthens plants
if(S.has_reagent(/datum/reagent/saltpetre, 1))
var/salt = S.get_reagent_amount(/datum/reagent/saltpetre)
adjustHealth(round(salt * 0.25))
if (myseed)
myseed.adjust_production(-round(salt/100)-prob(salt%100))
myseed.adjust_potency(round(salt*0.5))
// Ash is also used IRL in gardening, as a fertilizer enhancer and weed killer
if(S.has_reagent(/datum/reagent/ash, 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/ash) * 0.25))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/ash) * 0.5))
adjustWeeds(-1)
// This is more bad ass, and pests get hurt by the corrosive nature of it, not the plant.
if(S.has_reagent(/datum/reagent/diethylamine, 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 2))
if(myseed)
myseed.adjust_yield(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 0.02))
adjustPests(-rand(1,2))
// Compost, effectively
if(S.has_reagent(/datum/reagent/consumable/nutriment, 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/nutriment) * 0.5))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/nutriment) * 1))
// Compost for EVERYTHING
if(S.has_reagent(/datum/reagent/consumable/virus_food, 1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/virus_food) * 0.5))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/consumable/virus_food) * 0.5))
// FEED ME
if(S.has_reagent(/datum/reagent/blood, 1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/blood) * 1))
adjustPests(rand(2,4))
// FEED ME SEYMOUR
if(S.has_reagent(/datum/reagent/medicine/strange_reagent, 1))
spawnplant()
// Honey, Pests are dieing of sugar, so is the plant
if(S.has_reagent(/datum/reagent/consumable/honey, 1))
adjustPests(-rand(2,5))
adjustHealth(-round(S.get_reagent_amount(/datum/reagent/consumable/honey) * 1))
// Buzz Fuzz, a drink seemingly made for plants...
if(S.has_reagent(/datum/reagent/consumable/buzz_fuzz, 1))
adjustPests(-rand(2,5))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/buzz_fuzz) * 0.1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/buzz_fuzz) * 0.5))
// The best stuff there is. For testing/debugging.
if(S.has_reagent(/datum/reagent/medicine/adminordrazine, 1))
adjustWater(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1))
adjustHealth(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1))
adjustNutri(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1))
adjustPests(-rand(1,5))
adjustWeeds(-rand(1,5))
if(S.has_reagent(/datum/reagent/medicine/adminordrazine, 5))
switch(rand(100))
if(66 to 100)
mutatespecie()
if(33 to 65)
mutateweed()
if(1 to 32)
mutatepest(user)
else
to_chat(user, span_warning("Nothing happens..."))
/obj/machinery/hydroponics/attack_ghost(mob/user)
if(myseed)
to_chat(user, "*** <B>[myseed.plantname]</B> ***" )
to_chat(user, "- Plant Age: [span_notice("[age]")]")
var/list/text_string = myseed.get_analyzer_text()
if(text_string)
to_chat(user, text_string)
else
to_chat(user, "<B>No plant found.</B>")
to_chat(user, "- Weed level: [span_notice("[weedlevel] / 10")]")
to_chat(user, "- Pest level: [span_notice("[pestlevel] / 10")]")
to_chat(user, "- Toxicity level: [span_notice("[toxic] / 100")]")
to_chat(user, "- Water level: [span_notice("[waterlevel] / [maxwater]")]")
to_chat(user, "- Nutrition level: [span_notice("[nutrilevel] / [maxnutri]")]")
to_chat(user, "")
/obj/machinery/hydroponics/attackby(obj/item/O, mob/user, params)
//Called when mob user "attacks" it with object O
if(istype(O, /obj/item/reagent_containers) ) // Syringe stuff (and other reagent containers now too)
var/obj/item/reagent_containers/reagent_source = O
if(!reagent_source.reagents.total_volume)
to_chat(user, span_notice("[reagent_source] is empty."))
return 1
var/list/trays = list(src)//makes the list just this in cases of syringes and compost etc
var/target = myseed ? myseed.plantname : src
var/visi_msg = ""
var/irrigate = 0 //How am I supposed to irrigate pill contents?
var/transfer_amount
if(istype(reagent_source, /obj/item/reagent_containers/food/snacks) || istype(reagent_source, /obj/item/reagent_containers/pill))
if(istype(reagent_source, /obj/item/reagent_containers/food/snacks))
var/obj/item/reagent_containers/food/snacks/R = reagent_source
if (R.trash)
R.generate_trash(get_turf(user))
visi_msg="[user] composts [reagent_source], spreading it through [target]"
transfer_amount = reagent_source.reagents.total_volume
else
transfer_amount = reagent_source.amount_per_transfer_from_this
if(istype(reagent_source, /obj/item/reagent_containers/syringe/))
var/obj/item/reagent_containers/syringe/syr = reagent_source
visi_msg="[user] injects [target] with [syr]"
else if(istype(reagent_source, /obj/item/reagent_containers/spray/))
visi_msg="[user] sprays [target] with [reagent_source]"
playsound(loc, 'sound/effects/spray3.ogg', 50, 1, -6)
irrigate = 1
else if(transfer_amount) // Droppers, cans, beakers, what have you.
visi_msg="[user] uses [reagent_source] on [target]"
irrigate = 1
// Beakers, bottles, buckets, etc.
if(reagent_source.is_drainable())
playsound(loc, 'sound/effects/slosh.ogg', 25, 1)
if(irrigate && transfer_amount > 30 && reagent_source.reagents.total_volume >= 30 && using_irrigation)
trays = FindConnected()
if (trays.len > 1)
visi_msg += ", setting off the irrigation system"
if(visi_msg)
visible_message(span_notice("[visi_msg]."))
var/split = round(transfer_amount/trays.len)
for(var/obj/machinery/hydroponics/H in trays)
//cause I don't want to feel like im juggling 15 tamagotchis and I can get to my real work of ripping flooring apart in hopes of validating my life choices of becoming a space-gardener
var/datum/reagents/S = new /datum/reagents() //This is a strange way, but I don't know of a better one so I can't fix it at the moment...
S.my_atom = H
reagent_source.reagents.trans_to(S,split, transfered_by = user)
if(istype(reagent_source, /obj/item/reagent_containers/food/snacks) || istype(reagent_source, /obj/item/reagent_containers/pill))
qdel(reagent_source)
H.applyChemicals(S, user)
S.clear_reagents()
qdel(S)
H.update_appearance(UPDATE_ICON)
if(reagent_source) // If the source wasn't composted and destroyed
reagent_source.update_appearance(UPDATE_ICON)
return 1
else if(istype(O, /obj/item/seeds) && !istype(O, /obj/item/seeds/sample))
if(!myseed)
if(istype(O, /obj/item/seeds/kudzu))
investigate_log("had Kudzu planted in it by [key_name(user)] at [AREACOORD(src)]","kudzu")
if(!user.transferItemToLoc(O, src))
return
to_chat(user, span_notice("You plant [O]."))
dead = 0
myseed = O
age = 1
plant_health = myseed.endurance
lastcycle = world.time
update_appearance()
else
to_chat(user, span_warning("[src] already has seeds in it!"))
else if(istype(O, /obj/item/plant_analyzer))
var/list/combined_msg = list()
playsound(src, 'sound/effects/fastbeep.ogg', 30)
if(myseed)
combined_msg += "*** <B>[myseed.plantname]</B> ***"
combined_msg += "- Plant Age: [span_notice("[age]")]"
var/list/text_string = myseed.get_analyzer_text()
if(text_string)
combined_msg += "[text_string]"
else
combined_msg += "<B>No plant found.</B>"
combined_msg += "- Weed level: <span class='notice'>[weedlevel] / 10</span>"
combined_msg += "- Pest level: <span class='notice'>[pestlevel] / 10</span>"
combined_msg += "- Toxicity level: <span class='notice'>[toxic] / 100</span>"
combined_msg += "- Water level: <span class='notice'>[waterlevel] / [maxwater]</span>"
combined_msg += "- Nutrition level: <span class='notice'>[nutrilevel] / [maxnutri]</span>"
combined_msg += ""
to_chat(user, examine_block(combined_msg.Join("\n")))
else if(istype(O, /obj/item/cultivator))
if(weedlevel > 0)
user.visible_message("[user] uproots the weeds.", span_notice("You remove the weeds from [src]."))
weedlevel = 0
update_appearance(UPDATE_ICON)
else
to_chat(user, span_warning("This plot is completely devoid of weeds! It doesn't need uprooting."))
else if(istype(O, /obj/item/storage/bag/plants))
attack_hand(user)
for(var/obj/item/reagent_containers/food/snacks/grown/G in locate(user.x,user.y,user.z))
SEND_SIGNAL(O, COMSIG_TRY_STORAGE_INSERT, G, user, TRUE)
else if(default_unfasten_wrench(user, O))
return
else if((O.tool_behaviour == TOOL_WIRECUTTER) && unwrenchable)
if (!anchored)
to_chat(user, span_warning("Anchor the tray first!"))
return
using_irrigation = !using_irrigation
O.play_tool_sound(src)
user.visible_message(span_notice("[user] [using_irrigation ? "" : "dis"]connects [src]'s irrigation hoses."), \
span_notice("You [using_irrigation ? "" : "dis"]connect [src]'s irrigation hoses."))
for(var/obj/machinery/hydroponics/h in range(1,src))
h.update_appearance(UPDATE_ICON)
else if(istype(O, /obj/item/shovel/spade))
if(!myseed && !weedlevel)
to_chat(user, span_warning("[src] doesn't have any plants or weeds!"))
return
user.visible_message(span_notice("[user] starts digging out [src]'s plants..."),
span_notice("You start digging out [src]'s plants..."))
if(O.use_tool(src, user, 50, volume=50) || (!myseed && !weedlevel))
user.visible_message(span_notice("[user] digs out the plants in [src]!"), span_notice("You dig out all of [src]'s plants!"))
if(myseed) //Could be that they're just using it as a de-weeder
age = 0
plant_health = 0
lastproduce = 0
if(harvest)
harvest = FALSE //To make sure they can't just put in another seed and insta-harvest it
qdel(myseed)
myseed = null
weedlevel = 0 //Has a side effect of cleaning up those nasty weeds
update_appearance()
else
return ..()
/obj/machinery/hydroponics/attackby_secondary(obj/item/weapon, mob/user, params)
if (istype(weapon, /obj/item/reagent_containers/syringe))
to_chat(user, span_warning("You can't get any extract out of this plant."))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
return SECONDARY_ATTACK_CALL_NORMAL
/obj/machinery/hydroponics/can_be_unfasten_wrench(mob/user, silent)
if (!unwrenchable) // case also covered by NODECONSTRUCT checks in default_unfasten_wrench
return CANT_UNFASTEN
if (using_irrigation)
if (!silent)
to_chat(user, span_warning("Disconnect the hoses first!"))
return FAILED_UNFASTEN
return ..()
/obj/machinery/hydroponics/attack_hand(mob/user)
. = ..()
if(.)
return
if(issilicon(user)) //How does AI know what plant is?
return
if(harvest)
return myseed.harvest(user)
else if(dead)
dead = 0
to_chat(user, span_notice("You remove the dead plant from [src]."))
qdel(myseed)
myseed = null
update_appearance()
else
if(user)
examine(user)
/obj/machinery/hydroponics/AltClick(mob/user)
. = ..()
if(!anchored)
update_appearance(UPDATE_ICON)
return FALSE
var/warning = tgui_alert(user, "Are you sure you wish to empty the tray's nutrient beaker?","Empty Tray Nutrients?", list("Yes", "No"))
if(warning == "Yes" && user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
reagents.clear_reagents()
to_chat(user, "<span class='warning'>You empty [src]'s nutrient tank.</span>")
/**
* Update Tray Proc
* Handles plant harvesting on the tray side, by clearing the sead, names, description, and dead stat.
* Shuts off autogrow if enabled.
* Sends messages to the cleaer about plants harvested, or if nothing was harvested at all.
* * User - The mob who clears the tray.
*/
/obj/machinery/hydroponics/proc/update_tray(mob/user)
harvest = 0
lastproduce = age
if(istype(myseed, /obj/item/seeds/replicapod))
to_chat(user, span_notice("You harvest from the [myseed.plantname]."))
else if(myseed.getYield() <= 0)
to_chat(user, span_warning("You fail to harvest anything useful!"))
else
to_chat(user, span_notice("You harvest [myseed.getYield()] items from the [myseed.plantname]."))
if(!myseed.get_gene(/datum/plant_gene/trait/repeated_harvest))
qdel(myseed)
myseed = null
dead = 0
update_appearance()
/// Tray Setters - The following procs adjust the tray or plants variables, and make sure that the stat doesn't go out of bounds.///
/obj/machinery/hydroponics/proc/adjustNutri(adjustamt)
nutrilevel = clamp(nutrilevel + adjustamt, 0, maxnutri)
/obj/machinery/hydroponics/proc/adjustWater(adjustamt)
waterlevel = clamp(waterlevel + adjustamt, 0, maxwater)
if(adjustamt>0)
adjustToxic(-round(adjustamt/4))//Toxicity dilutation code. The more water you put in, the lesser the toxin concentration.
/obj/machinery/hydroponics/proc/adjustHealth(adjustamt)
if(myseed && !dead)
plant_health = clamp(plant_health + adjustamt, 0, myseed.endurance)
/obj/machinery/hydroponics/proc/adjustToxic(adjustamt)
toxic = clamp(toxic + adjustamt, 0, 100)
/obj/machinery/hydroponics/proc/adjustPests(adjustamt)
pestlevel = clamp(pestlevel + adjustamt, 0, 10)
/obj/machinery/hydroponics/proc/adjustWeeds(adjustamt)
weedlevel = clamp(weedlevel + adjustamt, 0, 10)
/obj/machinery/hydroponics/proc/spawnplant() // why would you put strange reagent in a hydro tray you monster I bet you also feed them blood
var/list/livingplants = list(/mob/living/simple_animal/hostile/tree, /mob/living/simple_animal/hostile/killertomato)
var/chosen = pick(livingplants)
var/mob/living/simple_animal/hostile/C = new chosen
C.faction = list("plants")
/obj/machinery/hydroponics/proc/become_self_sufficient() // Ambrosia Gaia effect
visible_message(span_boldnotice("[src] begins to glow with a beautiful light!"))
self_sustaining = TRUE
update_appearance(UPDATE_ICON)
/obj/machinery/hydroponics/update_name(updates=ALL)
. = ..()
if(myseed)
name = "[initial(name)] ([myseed.plantname])"
else
name = initial(name)
///////////////////////////////////////////////////////////////////////////////
/obj/machinery/hydroponics/soil //Not actually hydroponics at all! Honk!
name = "soil"
desc = "A patch of dirt."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "soil"
circuit = null
density = FALSE
use_power = NO_POWER_USE
flags_1 = NODECONSTRUCT_1
unwrenchable = FALSE
/obj/machinery/hydroponics/soil/update_icon_hoses()
return // Has no hoses
/obj/machinery/hydroponics/soil/update_icon_lights()
return // Has no lights
/obj/machinery/hydroponics/soil/attackby_secondary(obj/item/weapon, mob/user, params)
if(weapon.tool_behaviour == TOOL_SHOVEL)
to_chat(user, span_notice("You clear up [src]!"))
qdel(src)
return SECONDARY_ATTACK_CONTINUE_CHAIN
return ..()