-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
grown.dm
196 lines (167 loc) · 6.83 KB
/
grown.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
// ***********************************************************
// Foods that are produced from hydroponics ~~~~~~~~~~
// Data from the seeds carry over to these grown foods
// ***********************************************************
// Base type. Subtypes are found in /grown dir. Lavaland-based subtypes can be found in mining/ash_flora.dm
/obj/item/reagent_containers/food/snacks/grown
icon = 'icons/obj/hydroponics/harvest.dmi'
var/obj/item/seeds/seed = null // type path, gets converted to item on New(). It's safe to assume it's always a seed item.
var/plantname = ""
var/bitesize_mod = 0
var/splat_type = /obj/effect/decal/cleanable/food/plant_smudge
// If set, bitesize = 1 + round(reagents.total_volume / bitesize_mod)
dried_type = -1
// Saves us from having to define each stupid grown's dried_type as itself.
// If you don't want a plant to be driable (watermelons) set this to null in the time definition.
resistance_flags = FLAMMABLE
var/dry_grind = FALSE //If TRUE, this object needs to be dry to be ground up
var/can_distill = TRUE //If FALSE, this object cannot be distilled into an alcohol.
var/distill_reagent //If NULL and this object can be distilled, it uses a generic fruit_wine reagent and adjusts its variables.
var/wine_flavor //If NULL, this is automatically set to the fruit's flavor. Determines the flavor of the wine if distill_reagent is NULL.
var/wine_power = 10 //Determines the boozepwr of the wine if distill_reagent is NULL.
/obj/item/reagent_containers/food/snacks/grown/Initialize(mapload, obj/item/seeds/new_seed)
. = ..()
if(!tastes)
tastes = list("[name]" = 1)
if(new_seed)
seed = new_seed.Copy()
else if(ispath(seed))
// This is for adminspawn or map-placed growns. They get the default stats of their seed type.
seed = new seed()
seed.adjust_potency(50-seed.potency)
pixel_x = rand(-5, 5)
pixel_y = rand(-5, 5)
if(dried_type == -1)
dried_type = src.type
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_new(src, loc)
seed.prepare_result(src)
transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5 //Makes the resulting produce's sprite larger or smaller based on potency!
w_class = round((seed.potency / 100) * 2, 1) + 1 //more potent plants are larger
add_juice()
/obj/item/reagent_containers/food/snacks/grown/proc/add_juice()
if(reagents)
if(bitesize_mod)
bitesize = 1 + round(reagents.total_volume / bitesize_mod)
return 1
return 0
/obj/item/reagent_containers/food/snacks/grown/examine(user)
. = ..()
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
if(T.examine_line)
. += T.examine_line
/// Ghost attack proc
/obj/item/reagent_containers/food/snacks/grown/attack_ghost(mob/user)
..()
var/msg = "<span class='info'>This is \a [span_name("[src]")].\n"
if(seed)
msg += seed.get_analyzer_text()
var/reag_txt = ""
if(seed)
for(var/reagent_id in seed.reagents_add)
var/datum/reagent/R = GLOB.chemical_reagents_list[reagent_id]
var/amt = reagents.get_reagent_amount(reagent_id)
reag_txt += "\n[span_info("- [R.name]: [amt]")]"
if(reag_txt)
msg += reag_txt
msg += "<br>[span_info("")]"
to_chat(user, examine_block(msg))
/obj/item/reagent_containers/food/snacks/grown/attackby(obj/item/O, mob/user, params)
..()
if (istype(O, /obj/item/plant_analyzer))
playsound(src, 'sound/effects/fastbeep.ogg', 30)
var/msg = "<span class='info'>This is \a [span_name("[src]")].\n"
if(seed)
msg += seed.get_analyzer_text()
var/reag_txt = ""
if(seed)
for(var/reagent_id in seed.reagents_add)
var/datum/reagent/R = GLOB.chemical_reagents_list[reagent_id]
var/amt = reagents.get_reagent_amount(reagent_id)
reag_txt += "\n[span_info("- [R.name]: [amt]")]"
if(reag_txt)
msg += reag_txt
msg += "<br>[span_info("")]"
to_chat(user, examine_block(msg))
else
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_attackby(src, O, user)
// Various gene procs
/obj/item/reagent_containers/food/snacks/grown/attack_self(mob/user)
if(seed && seed.get_gene(/datum/plant_gene/trait/squash))
squash(user)
..()
/obj/item/reagent_containers/food/snacks/grown/attack(mob/living/M, mob/living/user, def_zone)
if(!..()) // didn't get overridden
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_attack(src, M, user, def_zone)
/obj/item/reagent_containers/food/snacks/grown/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
if(!..()) //was it caught by a mob?
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_throw_impact(src, hit_atom)
if(seed.get_gene(/datum/plant_gene/trait/squash))
squash(hit_atom)
/obj/item/reagent_containers/food/snacks/grown/proc/squash(atom/target)
var/turf/T = get_turf(target)
forceMove(T)
if(ispath(splat_type, /obj/effect/decal/cleanable/food/plant_smudge))
if(filling_color)
var/obj/O = new splat_type(T)
O.color = filling_color
O.name = "[name] smudge"
else if(splat_type)
new splat_type(T)
if(trash)
generate_trash(T)
visible_message(span_warning("[src] has been squashed."),span_italics("You hear a smack."))
if(seed)
for(var/datum/plant_gene/trait/trait in seed.genes)
trait.on_squash(src, target)
reagents.reaction(T)
for(var/A in T)
reagents.reaction(A)
qdel(src)
/obj/item/reagent_containers/food/snacks/grown/On_Consume()
if(iscarbon(usr))
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_consume(src, usr)
..()
/obj/item/reagent_containers/food/snacks/grown/generate_trash(atom/location)
if(trash && ispath(trash, /obj/item/grown))
. = new trash(location, seed)
trash = null
return
return ..()
/obj/item/reagent_containers/food/snacks/grown/grind_requirements()
if(dry_grind && !dry)
to_chat(usr, span_warning("[src] needs to be dry before it can be ground up!"))
return
return TRUE
/obj/item/reagent_containers/food/snacks/grown/on_grind()
var/nutriment = reagents.get_reagent_amount(/datum/reagent/consumable/nutriment)
if(grind_results&&grind_results.len)
for(var/i in 1 to grind_results.len)
grind_results[grind_results[i]] = nutriment
reagents.del_reagent(/datum/reagent/consumable/nutriment)
reagents.del_reagent(/datum/reagent/consumable/nutriment/vitamin)
/obj/item/reagent_containers/food/snacks/grown/on_juice()
var/nutriment = reagents.get_reagent_amount(/datum/reagent/consumable/nutriment)
if(juice_results&&juice_results.len)
for(var/i in 1 to juice_results.len)
juice_results[juice_results[i]] = nutriment
reagents.del_reagent(/datum/reagent/consumable/nutriment)
reagents.del_reagent(/datum/reagent/consumable/nutriment/vitamin)
// For item-containing growns such as eggy
/obj/item/reagent_containers/food/snacks/grown/shell/attack_self(mob/user)
var/obj/item/T
if(trash)
T = generate_trash()
qdel(src)
user.putItemFromInventoryInHandIfPossible(T, user.active_hand_index, TRUE)
to_chat(user, span_notice("You open [src]\'s shell, revealing \a [T]."))