6
6
7
7
std::vector<art_effect_passive> fill_good_passive ();
8
8
std::vector<art_effect_passive> fill_bad_passive ();
9
- std::vector<art_effect_active> fill_good_active ();
10
- std::vector<art_effect_active> fill_bad_active ();
9
+ std::vector<art_effect_active> fill_good_active ();
10
+ std::vector<art_effect_active> fill_bad_active ();
11
11
12
12
std::string artifact_name (std::string type);
13
13
@@ -108,24 +108,27 @@ It may have unknown powers; use 'a' to activate them.";
108
108
// Finally, activated effects; not necessarily good or bad
109
109
num_good = 0 ;
110
110
num_bad = 0 ;
111
+ value = 0 ;
111
112
art->def_charges = 0 ;
112
113
art->max_charges = 0 ;
113
114
std::vector<art_effect_active> good_a_effects = fill_good_active ();
114
115
std::vector<art_effect_active> bad_a_effects = fill_bad_active ();
115
116
while (!good_a_effects.empty () && !bad_a_effects.empty () &&
116
- num_good < 3 && num_bad < 3 &&
117
- ((num_bad > 0 && num_good == 0 ) || ! one_in ( 3 - num_good ) ||
118
- !one_in (3 - num_bad))) {
119
- if (!one_in (3 )) { // Good effect
117
+ num_good < 3 && num_bad < 3 &&
118
+ (value > 3 || (num_bad > 0 && num_good == 0 ) ||
119
+ !one_in (3 - num_good) || ! one_in ( 3 - num_bad))) {
120
+ if (!one_in (3 ) && value <= 1 ) { // Good effect
120
121
int index = rng (0 , good_a_effects.size () - 1 );
121
122
active_tmp = good_a_effects[index ];
122
123
good_a_effects.erase (good_a_effects.begin () + index );
123
124
num_good++;
125
+ value += active_effect_cost[active_tmp];
124
126
} else { // Bad effect
125
127
int index = rng (0 , bad_a_effects.size () - 1 );
126
128
active_tmp = bad_a_effects[index ];
127
129
bad_a_effects.erase (bad_a_effects.begin () + index );
128
130
num_bad++;
131
+ value += active_effect_cost[active_tmp];
129
132
}
130
133
art->effects_activated .push_back (active_tmp);
131
134
art->max_charges += rng (1 , 3 );
@@ -134,6 +137,8 @@ It may have unknown powers; use 'a' to activate them.";
134
137
// If we have charges, pick a recharge mechanism
135
138
if (art->max_charges > 0 )
136
139
art->charge_type = art_charge ( rng (ARTC_NULL + 1 , NUM_ARTCS - 1 ) );
140
+ if (one_in (8 ) && num_bad + num_good >= 4 )
141
+ art->charge_type = ARTC_NULL; // 1 in 8 chance that it can't recharge!
137
142
138
143
art->id = itypes.size ();
139
144
itypes.push_back (art);
@@ -245,6 +250,119 @@ It may have unknown powers; use 'a' to activate them.";
245
250
}
246
251
}
247
252
253
+ itype* game::new_natural_artifact (artifact_natural_property prop)
254
+ {
255
+ // Natural artifacts are always tools.
256
+ it_artifact_tool *art = new it_artifact_tool ();
257
+ // Pick a form
258
+ artifact_natural_shape shape =
259
+ artifact_natural_shape (rng (ARTSHAPE_NULL + 1 , ARTSHAPE_MAX - 1 ));
260
+ artifact_shape_datum *shape_data = &(artifact_shape_data[shape]);
261
+ // Pick a property
262
+ artifact_natural_property property = (prop > ARTPROP_NULL ? prop :
263
+ artifact_natural_property (rng (ARTPROP_NULL + 1 , ARTPROP_MAX - 1 )));
264
+ artifact_property_datum *property_data = &(artifact_property_data[property]);
265
+
266
+ art->sym = ' :' ;
267
+ art->color = c_yellow;
268
+ art->m1 = STONE;
269
+ art->m2 = MNULL;
270
+ art->volume = rng (shape_data->volume_min , shape_data->volume_max );
271
+ art->weight = rng (shape_data->weight_min , shape_data->weight_max );
272
+ art->melee_dam = 0 ;
273
+ art->melee_cut = 0 ;
274
+ art->m_to_hit = 0 ;
275
+ art->item_flags = 0 ;
276
+
277
+ art->name = property_data->name + " " + shape_data->name ;
278
+ std::stringstream desc;
279
+ desc << " This " << shape_data->desc << " " << property_data->desc << " ." ;
280
+ art->description = desc.str ();
281
+ // Add line breaks to the description as necessary
282
+ size_t pos = 76 ;
283
+ while (art->description .length () - pos >= 76 ) {
284
+ pos = art->description .find_last_of (' ' , pos);
285
+ if (pos == std::string::npos)
286
+ pos = art->description .length ();
287
+ else {
288
+ art->description [pos] = ' \n ' ;
289
+ pos += 76 ;
290
+ }
291
+ }
292
+
293
+ // Three possibilities: good passive + bad passive, good active + bad active,
294
+ // and bad passive + good active
295
+ bool good_passive = false , bad_passive = false ,
296
+ good_active = false , bad_active = false ;
297
+ switch (rng (1 , 3 )) {
298
+ case 1 :
299
+ good_passive = true ;
300
+ bad_passive = true ;
301
+ break ;
302
+ case 2 :
303
+ good_active = true ;
304
+ bad_active = true ;
305
+ break ;
306
+ case 3 :
307
+ bad_passive = true ;
308
+ good_active = true ;
309
+ break ;
310
+ }
311
+
312
+ int value_to_reach = 0 ; // This is slowly incremented, allowing for better arts
313
+ int value = 0 ;
314
+ art_effect_passive aep_good = AEP_NULL, aep_bad = AEP_NULL;
315
+ art_effect_active aea_good = AEA_NULL, aea_bad = AEA_NULL;
316
+
317
+ do {
318
+ if (good_passive) {
319
+ aep_good = property_data->passive_good [ rng (0 , 3 ) ];
320
+ if (aep_good == AEP_NULL || one_in (4 ))
321
+ aep_good = art_effect_passive (rng (AEP_NULL + 1 , AEP_SPLIT - 1 ));
322
+ }
323
+ if (bad_passive) {
324
+ aep_bad = property_data->passive_bad [ rng (0 , 3 ) ];
325
+ if (aep_bad == AEP_NULL || one_in (4 ))
326
+ aep_bad = art_effect_passive (rng (AEP_SPLIT + 1 , NUM_AEAS - 1 ));
327
+ }
328
+ if (good_active) {
329
+ aea_good = property_data->active_good [ rng (0 , 3 ) ];
330
+ if (aea_good == AEA_NULL || one_in (4 ))
331
+ aea_good = art_effect_active (rng (AEA_NULL + 1 , AEA_SPLIT - 1 ));
332
+ }
333
+ if (bad_active) {
334
+ aea_bad = property_data->active_bad [ rng (0 , 3 ) ];
335
+ if (aea_bad == AEA_NULL || one_in (4 ))
336
+ aea_bad = art_effect_active (rng (AEA_SPLIT + 1 , NUM_AEAS - 1 ));
337
+ }
338
+
339
+ value = passive_effect_cost[aep_good] + passive_effect_cost[aep_bad] +
340
+ active_effect_cost[aea_good] + active_effect_cost[aea_bad];
341
+ value_to_reach++; // Yes, it is intentional that this is 1 the first check
342
+ } while (value > value_to_reach);
343
+
344
+ if (aep_good != AEP_NULL)
345
+ art->effects_carried .push_back (aep_good);
346
+ if (aep_bad != AEP_NULL)
347
+ art->effects_carried .push_back (aep_bad);
348
+ if (aea_good != AEA_NULL)
349
+ art->effects_activated .push_back (aea_good);
350
+ if (aea_bad != AEA_NULL)
351
+ art->effects_activated .push_back (aea_bad);
352
+
353
+ // Natural artifacts ALWAYS can recharge
354
+ // (When "implanting" them in a mundane item, this ability may be lost
355
+ if (!art->effects_activated .empty ()) {
356
+ art->max_charges = rng (1 , 4 );
357
+ art->def_charges = art->max_charges ;
358
+ art->charge_type = art_charge ( rng (ARTC_NULL + 1 , NUM_ARTCS - 1 ) );
359
+ }
360
+
361
+ art->id = itypes.size ();
362
+ itypes.push_back (art);
363
+ return art;
364
+ }
365
+
248
366
std::vector<art_effect_passive> fill_good_passive ()
249
367
{
250
368
std::vector<art_effect_passive> ret;
@@ -494,6 +612,14 @@ void game::add_artifact_messages(std::vector<art_effect_passive> effects)
494
612
add_msg (" Your mental state feels protected." );
495
613
break ;
496
614
615
+ case AEP_RESIST_ELECTRICITY:
616
+ add_msg (" You feel insulated." );
617
+ break ;
618
+
619
+ case AEP_CARRY_MORE:
620
+ add_msg (" Your back feels strengthened." );
621
+ break ;
622
+
497
623
case AEP_HUNGER:
498
624
add_msg (" You feel hungry." );
499
625
break ;
@@ -521,6 +647,18 @@ void game::add_artifact_messages(std::vector<art_effect_passive> effects)
521
647
case AEP_ATTENTION:
522
648
add_msg (" You feel an otherworldly attention upon you..." );
523
649
break ;
650
+
651
+ case AEP_FORCE_TELEPORT:
652
+ add_msg (" You feel a force pulling you inwards." );
653
+ break ;
654
+
655
+ case AEP_MOVEMENT_NOISE:
656
+ add_msg (" You hear a rattling noise coming from inside yourself." );
657
+ break ;
658
+
659
+ case AEP_BAD_WEATHER:
660
+ add_msg (" You feel storms coming." );
661
+ break ;
524
662
}
525
663
}
526
664
0 commit comments