Skip to content

Commit 65a9b6f

Browse files
Maleclypsegithub-actions[bot]
authored andcommitted
[ Xedra Evolved ] Fix Gracken trait improving items (CleverRaven#82716)
* Update monster_drops.json * Quick and dirty craft failure explosions code changes * Update crafting.cpp * Update mutation.cpp * Update src/mutation.cpp * Update src/mutation.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update mutation.cpp * Update mutation.cpp * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/mutation.cpp * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * items work again * Fix EOC not respecting mutation type * Test * Update src/npctalk.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update npctalk.cpp * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/npctalk.cpp * Update src/npctalk.cpp * Update src/npctalk.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update iuse_test.cpp * Apply suggestions from code review * Update iuse_test.cpp * Update src/mutation.cpp * Update tests/iuse_test.cpp * Apply suggestions from code review * Update npctalk.cpp --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e096759 commit 65a9b6f

File tree

2 files changed

+113
-27
lines changed

2 files changed

+113
-27
lines changed

data/mods/Xedra_Evolved/items/gracken_trait_improvements.json

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
{
33
"abstract": "gracken_improvement_general",
44
"type": "ITEM",
5-
"subtypes": [ "COMESTIBLE" ],
6-
"comestible_type": "INVALID",
5+
"subtypes": [ "TOOL" ],
76
"category": "MED",
87
"name": { "str": "abstract gracken improvement", "//~": "NO_I18N" },
98
"weight": "2041 g",
@@ -12,17 +11,22 @@
1211
"symbol": "!",
1312
"color": "light_gray",
1413
"price_postapoc": "10 USD",
15-
"flags": [ "NO_INGEST", "EDIBLE_FROZEN" ]
14+
"flags": [ "SINGLE_USE" ]
1615
},
1716
{
1817
"id": "gracken_shade_arms",
1918
"copy-from": "gracken_improvement_general",
2019
"type": "ITEM",
21-
"subtypes": [ "COMESTIBLE" ],
20+
"subtypes": [ "TOOL" ],
2221
"name": { "str_sp": "Gracken Shade Arms" },
2322
"looks_like": "offal",
2423
"description": "An organ that allows a mature Gracken to convert their arms back to a base state.",
25-
"consumption_effect_on_conditions": [ "shade_arms" ]
24+
"use_action": {
25+
"type": "effect_on_conditions",
26+
"consume": true,
27+
"description": "You graft this organ onto your body replacing whatever was there before.",
28+
"effect_on_conditions": [ "shade_arms" ]
29+
}
2630
},
2731
{
2832
"type": "effect_on_condition",
@@ -35,11 +39,16 @@
3539
"id": "gracken_strong_arms",
3640
"copy-from": "gracken_improvement_general",
3741
"type": "ITEM",
38-
"subtypes": [ "COMESTIBLE" ],
42+
"subtypes": [ "TOOL" ],
3943
"name": { "str_sp": "Gracken Strong Arms" },
4044
"looks_like": "offal",
4145
"description": "An organ that allows a mature Gracken to convert their arms to a stronger form.",
42-
"consumption_effect_on_conditions": [ "strong_arms" ]
46+
"use_action": {
47+
"type": "effect_on_conditions",
48+
"consume": true,
49+
"description": "You graft this organ onto your body replacing whatever was there before.",
50+
"effect_on_conditions": [ "strong_arms" ]
51+
}
4352
},
4453
{
4554
"type": "effect_on_condition",
@@ -52,11 +61,16 @@
5261
"id": "gracken_long_arms",
5362
"copy-from": "gracken_improvement_general",
5463
"type": "ITEM",
55-
"subtypes": [ "COMESTIBLE" ],
64+
"subtypes": [ "TOOL" ],
5665
"name": { "str_sp": "Gracken Long Arms" },
5766
"looks_like": "offal",
5867
"description": "An organ that allows a mature Gracken to convert their arms to a longer form.",
59-
"consumption_effect_on_conditions": [ "long_arms" ]
68+
"use_action": {
69+
"type": "effect_on_conditions",
70+
"consume": true,
71+
"description": "You graft this organ onto your body replacing whatever was there before.",
72+
"effect_on_conditions": [ "long_arms" ]
73+
}
6074
},
6175
{
6276
"type": "effect_on_condition",
@@ -69,11 +83,16 @@
6983
"id": "gracken_shade_hands",
7084
"copy-from": "gracken_improvement_general",
7185
"type": "ITEM",
72-
"subtypes": [ "COMESTIBLE" ],
86+
"subtypes": [ "TOOL" ],
7387
"name": { "str_sp": "Gracken Shade Hands" },
7488
"looks_like": "offal",
7589
"description": "An organ that allows a mature Gracken to convert their hands back to a base state.",
76-
"consumption_effect_on_conditions": [ "shade_hands" ]
90+
"use_action": {
91+
"type": "effect_on_conditions",
92+
"consume": true,
93+
"description": "You graft this organ onto your body replacing whatever was there before.",
94+
"effect_on_conditions": [ "shade_hands" ]
95+
}
7796
},
7897
{
7998
"type": "effect_on_condition",
@@ -86,11 +105,16 @@
86105
"id": "gracken_sharp_nails",
87106
"copy-from": "gracken_improvement_general",
88107
"type": "ITEM",
89-
"subtypes": [ "COMESTIBLE" ],
108+
"subtypes": [ "TOOL" ],
90109
"name": { "str_sp": "Gracken Sharp Nails" },
91110
"looks_like": "offal",
92111
"description": "An organ that allows a mature Gracken to convert their hands to a sharper form.",
93-
"consumption_effect_on_conditions": [ "sharp_nails" ]
112+
"use_action": {
113+
"type": "effect_on_conditions",
114+
"consume": true,
115+
"description": "You graft this organ onto your body replacing whatever was there before.",
116+
"effect_on_conditions": [ "sharp_nails" ]
117+
}
94118
},
95119
{
96120
"type": "effect_on_condition",
@@ -103,11 +127,16 @@
103127
"id": "gracken_dextrous_hands",
104128
"copy-from": "gracken_improvement_general",
105129
"type": "ITEM",
106-
"subtypes": [ "COMESTIBLE" ],
130+
"subtypes": [ "TOOL" ],
107131
"name": { "str_sp": "Gracken Dextrous Hands" },
108132
"looks_like": "offal",
109133
"description": "An organ that allows a mature Gracken to convert their hands to a more agile form.",
110-
"consumption_effect_on_conditions": [ "dextrous_hands" ]
134+
"use_action": {
135+
"type": "effect_on_conditions",
136+
"consume": true,
137+
"description": "You graft this organ onto your body replacing whatever was there before.",
138+
"effect_on_conditions": [ "dextrous_hands" ]
139+
}
111140
},
112141
{
113142
"type": "effect_on_condition",
@@ -120,11 +149,16 @@
120149
"id": "gracken_herbivorous_stomach",
121150
"copy-from": "gracken_improvement_general",
122151
"type": "ITEM",
123-
"subtypes": [ "COMESTIBLE" ],
152+
"subtypes": [ "TOOL" ],
124153
"name": { "str_sp": "Gracken Herbivorous Stomach" },
125154
"looks_like": "offal",
126155
"description": "An organ that allows a mature Gracken to convert their diet to an herbivorous one.",
127-
"consumption_effect_on_conditions": [ "herbivorous_stomach" ]
156+
"use_action": {
157+
"type": "effect_on_conditions",
158+
"consume": true,
159+
"description": "You graft this organ onto your body replacing whatever was there before.",
160+
"effect_on_conditions": [ "herbivorous_stomach" ]
161+
}
128162
},
129163
{
130164
"type": "effect_on_condition",
@@ -137,11 +171,16 @@
137171
"id": "gracken_omnivorous_stomach",
138172
"copy-from": "gracken_improvement_general",
139173
"type": "ITEM",
140-
"subtypes": [ "COMESTIBLE" ],
174+
"subtypes": [ "TOOL" ],
141175
"name": { "str_sp": "Gracken Dextrous Hands" },
142176
"looks_like": "offal",
143177
"description": "An organ that allows a mature Gracken to convert their diet to an omnivorous one.",
144-
"consumption_effect_on_conditions": [ "omnivorous_stomach" ]
178+
"use_action": {
179+
"type": "effect_on_conditions",
180+
"consume": true,
181+
"description": "You graft this organ onto your body replacing whatever was there before.",
182+
"effect_on_conditions": [ "omnivorous_stomach" ]
183+
}
145184
},
146185
{
147186
"type": "effect_on_condition",
@@ -154,11 +193,16 @@
154193
"id": "gracken_carnivorous_stomach",
155194
"copy-from": "gracken_improvement_general",
156195
"type": "ITEM",
157-
"subtypes": [ "COMESTIBLE" ],
196+
"subtypes": [ "TOOL" ],
158197
"name": { "str_sp": "Gracken Dextrous Hands" },
159198
"looks_like": "offal",
160199
"description": "An organ that allows a mature Gracken to convert their diet to an carnivorous one.",
161-
"consumption_effect_on_conditions": [ "carnivorous_stomach" ]
200+
"use_action": {
201+
"type": "effect_on_conditions",
202+
"consume": true,
203+
"description": "You graft this organ onto your body replacing whatever was there before.",
204+
"effect_on_conditions": [ "carnivorous_stomach" ]
205+
}
162206
},
163207
{
164208
"type": "effect_on_condition",
@@ -171,11 +215,16 @@
171215
"id": "gracken_shade_legs",
172216
"copy-from": "gracken_improvement_general",
173217
"type": "ITEM",
174-
"subtypes": [ "COMESTIBLE" ],
218+
"subtypes": [ "TOOL" ],
175219
"name": { "str_sp": "Gracken Shade Legs" },
176220
"looks_like": "offal",
177221
"description": "An organ that allows a mature Gracken to convert their legs back to a base state.",
178-
"consumption_effect_on_conditions": [ "shade_legs" ]
222+
"use_action": {
223+
"type": "effect_on_conditions",
224+
"consume": true,
225+
"description": "You graft this organ onto your body replacing whatever was there before.",
226+
"effect_on_conditions": [ "shade_legs" ]
227+
}
179228
},
180229
{
181230
"type": "effect_on_condition",
@@ -188,11 +237,16 @@
188237
"id": "gracken_short_legs",
189238
"copy-from": "gracken_improvement_general",
190239
"type": "ITEM",
191-
"subtypes": [ "COMESTIBLE" ],
240+
"subtypes": [ "TOOL" ],
192241
"name": { "str_sp": "Gracken Short Legs" },
193242
"looks_like": "offal",
194243
"description": "An organ that allows a mature Gracken to convert their legs to a shorter form.",
195-
"consumption_effect_on_conditions": [ "short_legs" ]
244+
"use_action": {
245+
"type": "effect_on_conditions",
246+
"consume": true,
247+
"description": "You graft this organ onto your body replacing whatever was there before.",
248+
"effect_on_conditions": [ "short_legs" ]
249+
}
196250
},
197251
{
198252
"type": "effect_on_condition",
@@ -205,11 +259,16 @@
205259
"id": "gracken_long_legs",
206260
"copy-from": "gracken_improvement_general",
207261
"type": "ITEM",
208-
"subtypes": [ "COMESTIBLE" ],
262+
"subtypes": [ "TOOL" ],
209263
"name": { "str_sp": "Gracken Long Legs" },
210264
"looks_like": "offal",
211265
"description": "An organ that allows a mature Gracken to convert their legs to a longer form.",
212-
"consumption_effect_on_conditions": [ "long_legs" ]
266+
"use_action": {
267+
"type": "effect_on_conditions",
268+
"consume": true,
269+
"description": "You graft this organ onto your body replacing whatever was there before.",
270+
"effect_on_conditions": [ "long_legs" ]
271+
}
213272
},
214273
{
215274
"type": "effect_on_condition",

src/npctalk.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,33 @@ talk_effect_fun_t::func f_add_trait( const JsonObject &jo, std::string_view memb
34973497
const trait_id trait = trait_id( new_trait.evaluate( d ) );
34983498
const mutation_variant *variant = trait->variant( new_variant.evaluate( d ) );
34993499

3500+
Character *guy = d.actor( is_npc )->get_character();
3501+
if( !guy ) {
3502+
debugmsg( "f_add_trait: No valid character." );
3503+
return;
3504+
}
3505+
3506+
const auto &new_types = trait->types;
3507+
3508+
for( const trait_id &existing : guy->get_mutations() ) {
3509+
if( existing == trait ) {
3510+
continue;
3511+
}
3512+
const auto &existing_types = existing->types;
3513+
for( const std::string &t : existing_types ) {
3514+
bool match = false;
3515+
if constexpr( std::is_same_v<decltype( new_types ), const std::set<std::string> &> ) {
3516+
match = new_types.count( t ) > 0;
3517+
} else {
3518+
match = new_types.find( t ) != new_types.end();
3519+
}
3520+
if( match ) {
3521+
guy->unset_mutation( existing );
3522+
break;
3523+
}
3524+
}
3525+
}
3526+
35003527
d.actor( is_npc )->set_mutation( trait, variant );
35013528
};
35023529
}

0 commit comments

Comments
 (0)