Skip to content

Commit b5924a2

Browse files
committed
Rewrote map saving; entire map is stored in memory
1 parent cf18cea commit b5924a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2078
-592
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# DEBUG is best turned on if you plan to debug in gdb -- please do!
44
# PROFILE is for use with gprof or a similar program -- don't bother generally
55
#WARNINGS = -Wall -Wextra -Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -Wno-char-subscripts
6-
#DEBUG = -g
6+
DEBUG = -g
77
#PROFILE = -pg
8-
OTHERS = -O3
8+
#OTHERS = -O3
99

1010
ODIR = obj
1111
DDIR = .deps

artifact.cpp

+144-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
std::vector<art_effect_passive> fill_good_passive();
88
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();
1111

1212
std::string artifact_name(std::string type);
1313

@@ -108,24 +108,27 @@ It may have unknown powers; use 'a' to activate them.";
108108
// Finally, activated effects; not necessarily good or bad
109109
num_good = 0;
110110
num_bad = 0;
111+
value = 0;
111112
art->def_charges = 0;
112113
art->max_charges = 0;
113114
std::vector<art_effect_active> good_a_effects = fill_good_active();
114115
std::vector<art_effect_active> bad_a_effects = fill_bad_active();
115116
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
120121
int index = rng(0, good_a_effects.size() - 1);
121122
active_tmp = good_a_effects[index];
122123
good_a_effects.erase(good_a_effects.begin() + index);
123124
num_good++;
125+
value += active_effect_cost[active_tmp];
124126
} else { // Bad effect
125127
int index = rng(0, bad_a_effects.size() - 1);
126128
active_tmp = bad_a_effects[index];
127129
bad_a_effects.erase(bad_a_effects.begin() + index);
128130
num_bad++;
131+
value += active_effect_cost[active_tmp];
129132
}
130133
art->effects_activated.push_back(active_tmp);
131134
art->max_charges += rng(1, 3);
@@ -134,6 +137,8 @@ It may have unknown powers; use 'a' to activate them.";
134137
// If we have charges, pick a recharge mechanism
135138
if (art->max_charges > 0)
136139
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!
137142

138143
art->id = itypes.size();
139144
itypes.push_back(art);
@@ -245,6 +250,119 @@ It may have unknown powers; use 'a' to activate them.";
245250
}
246251
}
247252

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+
248366
std::vector<art_effect_passive> fill_good_passive()
249367
{
250368
std::vector<art_effect_passive> ret;
@@ -494,6 +612,14 @@ void game::add_artifact_messages(std::vector<art_effect_passive> effects)
494612
add_msg("Your mental state feels protected.");
495613
break;
496614

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+
497623
case AEP_HUNGER:
498624
add_msg("You feel hungry.");
499625
break;
@@ -521,6 +647,18 @@ void game::add_artifact_messages(std::vector<art_effect_passive> effects)
521647
case AEP_ATTENTION:
522648
add_msg("You feel an otherworldly attention upon you...");
523649
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;
524662
}
525663
}
526664

artifact.h

+66
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ enum art_effect_passive {
2121
AEP_EXTINGUISH, // May extinguish nearby flames
2222
AEP_GLOW, // Four-tile light source
2323
AEP_PSYSHIELD, // Protection from stare attacks
24+
AEP_RESIST_ELECTRICITY, // Protection from electricity
25+
AEP_CARRY_MORE, // Increases carrying capacity by 200
26+
AEP_SAP_LIFE, // Killing non-zombie monsters may heal you
2427
// Splits good from bad
2528
AEP_SPLIT,
2629
// Bad
@@ -38,12 +41,17 @@ enum art_effect_passive {
3841
AEP_INT_DOWN, // Int - 3
3942
AEP_ALL_DOWN, // All stats - 2
4043
AEP_SPEED_DOWN, // -20 speed
44+
AEP_FORCE_TELEPORT, // Occasionally force a teleport
45+
AEP_MOVEMENT_NOISE, // Makes noise when you move
46+
AEP_BAD_WEATHER, // More likely to experience bad weather
47+
AEP_SICK, // Decreases health
4148

4249
NUM_AEPS
4350
};
4451

4552
enum art_effect_active {
4653
AEA_NULL = 0,
54+
4755
AEA_STORM, // Emits shock fields
4856
AEA_FIREBALL, // Targeted
4957
AEA_ADRENALINE, // Adrenaline rush
@@ -56,6 +64,10 @@ enum art_effect_active {
5664
AEA_CONFUSED, // Confuses all monsters in view
5765
AEA_ENTRANCE, // Chance to make nearby monsters friendly
5866
AEA_BUGS, // Chance to summon friendly insects
67+
AEA_TELEPORT, // Teleports you
68+
AEA_LIGHT, // Temporary light source
69+
AEA_GROWTH, // Grow plants, a la triffid queen
70+
AEA_HURTALL, // Hurts all monsters!
5971

6072
AEA_SPLIT, // Split between good and bad
6173

@@ -66,6 +78,13 @@ enum art_effect_active {
6678
AEA_FIRESTORM, // Spreads minor fire all around you
6779
AEA_ATTENTION, // Attention from sub-prime denizens
6880
AEA_TELEGLOW, // Teleglow disease
81+
AEA_NOISE, // Loud noise
82+
AEA_SCREAM, // Noise & morale penalty
83+
AEA_DIM, // Darkens the sky slowly
84+
AEA_FLASH, // Flashbang
85+
AEA_VOMIT, // User vomits
86+
AEA_SHADOWS, // Summon shadow creatures
87+
6988
NUM_AEAS
7089
};
7190

@@ -78,4 +97,51 @@ enum art_charge
7897
ARTC_HP, // Drains HP to recharge
7998
NUM_ARTCS
8099
};
100+
101+
enum artifact_natural_shape
102+
{
103+
ARTSHAPE_NULL,
104+
ARTSHAPE_SPHERE,
105+
ARTSHAPE_ROD,
106+
ARTSHAPE_TEARDROP,
107+
ARTSHAPE_LAMP,
108+
ARTSHAPE_SNAKE,
109+
ARTSHAPE_DISC,
110+
ARTSHAPE_BEADS,
111+
ARTSHAPE_NAPKIN,
112+
ARTSHAPE_URCHIN,
113+
ARTSHAPE_JELLY,
114+
ARTSHAPE_SPIRAL,
115+
ARTSHAPE_PIN,
116+
ARTSHAPE_TUBE,
117+
ARTSHAPE_PYRAMID,
118+
ARTSHAPE_CRYSTAL,
119+
ARTSHAPE_KNOT,
120+
ARTSHAPE_CRESCENT,
121+
ARTSHAPE_MAX
122+
};
123+
124+
enum artifact_natural_property
125+
{
126+
ARTPROP_NULL,
127+
ARTPROP_WRIGGLING, //
128+
ARTPROP_GLOWING, //
129+
ARTPROP_HUMMING, //
130+
ARTPROP_MOVING, //
131+
ARTPROP_WHISPERING, //
132+
ARTPROP_BREATHING, //
133+
ARTPROP_DEAD, //
134+
ARTPROP_ITCHY, //
135+
ARTPROP_GLITTERING, //
136+
ARTPROP_ELECTRIC, //
137+
ARTPROP_SLIMY, //
138+
ARTPROP_ENGRAVED, //
139+
ARTPROP_CRACKLING, //
140+
ARTPROP_WARM, //
141+
ARTPROP_RATTLING, //
142+
ARTPROP_SCALED,
143+
ARTPROP_FRACTAL,
144+
ARTPROP_MAX
145+
};
146+
81147
#endif

0 commit comments

Comments
 (0)