├── LICENSE ├── Makefile ├── Makefile.Windows ├── README ├── action.cpp ├── action.h ├── addiction.h ├── artifact.cpp ├── artifact.h ├── artifactdata.h ├── bionics.cpp ├── bionics.h ├── bodypart.cpp ├── bodypart.h ├── calendar.cpp ├── calendar.h ├── catacurse.cpp ├── catacurse.h ├── code_doc ├── EDITING ├── ENUMS ├── GAMEMODES ├── TODO ├── TODO_SHORT └── release_2012.2 ├── color.cpp ├── color.h ├── computer.cpp ├── computer.h ├── construction.cpp ├── construction.h ├── crafting.cpp ├── crafting.h ├── data ├── FONTDATA ├── LAB_NOTES ├── NAMES_FEMALE ├── NAMES_LAST ├── NAMES_MALE ├── NPC_HINTS ├── motd └── termfont ├── defense.cpp ├── dialogue.h ├── disease.h ├── enums.h ├── event.cpp ├── event.h ├── facdata.h ├── faction.cpp ├── faction.h ├── field.cpp ├── game.cpp ├── game.h ├── gamemode.cpp ├── gamemode.h ├── help.cpp ├── inventory.cpp ├── inventory.h ├── inventory_ui.cpp ├── item.cpp ├── item.h ├── itype.h ├── itypedef.cpp ├── iuse.cpp ├── iuse.h ├── keypress.cpp ├── keypress.h ├── line.cpp ├── line.h ├── main.cpp ├── map.cpp ├── map.h ├── mapbuffer.cpp ├── mapbuffer.h ├── mapdata.h ├── mapgen.cpp ├── mapitems.h ├── mapitemsdef.cpp ├── melee.cpp ├── mission.cpp ├── mission.h ├── mission_end.cpp ├── mission_fail.cpp ├── mission_place.cpp ├── mission_start.cpp ├── missiondef.cpp ├── monattack.cpp ├── monattack.h ├── mondeath.cpp ├── mondeath.h ├── mongroup.h ├── mongroupdef.cpp ├── monitemsdef.cpp ├── monmove.cpp ├── monster.cpp ├── monster.h ├── morale.h ├── moraledata.h ├── mtype.h ├── mtypedef.cpp ├── mutation.cpp ├── mutation.h ├── mutation_data.cpp ├── newcharacter.cpp ├── npc.cpp ├── npc.h ├── npcmove.cpp ├── npctalk.cpp ├── omdata.h ├── options.cpp ├── options.h ├── output.cpp ├── output.h ├── overmap.cpp ├── overmap.h ├── player.cpp ├── player.h ├── pldata.h ├── posix_time.cpp ├── posix_time.h ├── ranged.cpp ├── rng.cpp ├── rng.h ├── settlement.cpp ├── settlement.h ├── setvector.cpp ├── setvector.h ├── skill.cpp ├── skill.h ├── texthash.cpp ├── texthash.h ├── tileray.cpp ├── tileray.h ├── trap.h ├── trapdef.cpp ├── trapfunc.cpp ├── tutorial.cpp ├── tutorial.h ├── veh_interact.cpp ├── veh_interact.h ├── veh_type.h ├── veh_typedef.cpp ├── vehicle.cpp ├── vehicle.h ├── weather.cpp ├── weather.h ├── weather_data.h └── wish.cpp /LICENSE: -------------------------------------------------------------------------------- 1 | Cataclysm is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # comment these to toggle them as one sees fit. 2 | # WARNINGS will spam hundreds of warnings, mostly safe, if turned on 3 | # DEBUG is best turned on if you plan to debug in gdb -- please do! 4 | # PROFILE is for use with gprof or a similar program -- don't bother generally 5 | #WARNINGS = -Wall -Wextra -Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -Wno-char-subscripts 6 | #DEBUG = -g 7 | #PROFILE = -pg 8 | OTHERS = -O3 9 | 10 | ODIR = obj 11 | DDIR = .deps 12 | 13 | TARGET = cataclysm 14 | 15 | OS = $(shell uname -o) 16 | CXX = g++ 17 | 18 | CFLAGS = $(WARNINGS) $(DEBUG) $(PROFILE) $(OTHERS) 19 | 20 | ifeq ($(OS), Msys) 21 | LDFLAGS = -static -lpdcurses 22 | else 23 | LDFLAGS = -lncurses 24 | endif 25 | 26 | SOURCES = $(wildcard *.cpp) 27 | _OBJS = $(SOURCES:.cpp=.o) 28 | OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS)) 29 | 30 | all: $(TARGET) 31 | @ 32 | 33 | $(TARGET): $(ODIR) $(DDIR) $(OBJS) 34 | $(CXX) -o $(TARGET) $(CFLAGS) $(OBJS) $(LDFLAGS) 35 | 36 | $(ODIR): 37 | mkdir $(ODIR) 38 | 39 | $(DDIR): 40 | @mkdir $(DDIR) 41 | 42 | $(ODIR)/%.o: %.cpp 43 | $(CXX) $(CFLAGS) -c $< -o $@ 44 | 45 | clean: 46 | rm -f $(TARGET) $(ODIR)/*.o 47 | 48 | -include $(SOURCES:%.cpp=$(DEPDIR)/%.P) 49 | -------------------------------------------------------------------------------- /Makefile.Windows: -------------------------------------------------------------------------------- 1 | # comment these to toggle them as one sees fit. 2 | # WARNINGS will spam hundreds of warnings, mostly safe, if turned on 3 | # DEBUG is best turned on if you plan to debug in gdb -- please do! 4 | # PROFILE is for use with gprof or a similar program -- don't bother generally 5 | #WARNINGS = -Wall -Wextra -Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -Wno-char-subscripts 6 | #DEBUG = -g 7 | #PROFILE = -pg 8 | OTHERS = -O3 9 | 10 | ODIR = objwin 11 | DDIR = .deps 12 | 13 | TARGET = cataclysm.exe 14 | 15 | CXX = i486-mingw32-g++ 16 | 17 | LINKER = i486-mingw32-ld 18 | LINKERFLAGS = -Wl,-stack,12000000,-subsystem,windows 19 | 20 | CFLAGS = $(WARNINGS) $(DEBUG) $(PROFILE) $(OTHERS) 21 | 22 | LDFLAGS = -static -lgdi32 23 | 24 | #ifeq ($(OS), Msys) 25 | #LDFLAGS = -static -lpdcurses 26 | #else 27 | #LDFLAGS = -lncurses 28 | #endif 29 | 30 | SOURCES = $(wildcard *.cpp) 31 | _OBJS = $(SOURCES:.cpp=.o) 32 | OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS)) 33 | 34 | all: $(TARGET) 35 | @ 36 | 37 | $(TARGET): $(ODIR) $(DDIR) $(OBJS) 38 | $(CXX) $(LINKERFLAGS) -o $(TARGET) $(CFLAGS) $(OBJS) $(LDFLAGS) 39 | 40 | $(ODIR): 41 | mkdir $(ODIR) 42 | 43 | $(DDIR): 44 | @mkdir $(DDIR) 45 | 46 | $(ODIR)/%.o: %.cpp 47 | $(CXX) $(CFLAGS) -c $< -o $@ 48 | 49 | clean: 50 | rm -f $(TARGET) $(ODIR)/*.o 51 | 52 | -include $(SOURCES:%.cpp=$(DEPDIR)/%.P) 53 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Hi ManualDetonation! 2 | 3 | Cataclysm is a post-apocalyptic roguelike, set in the countryside of New England 4 | after a devastating plague of monsters and zombies. 5 | 6 | At present time, Cataclysm is still in early alpha, and is being developed very 7 | rapidly. As such, there are no formal version numbers, as a new version is 8 | released every day, often several a day. 9 | 10 | Source is available at the github repository, http://github.com/Whales/Cataclysm 11 | There is also a tarball available at http://squidnet.ath.cx/cataclysm.tar.gz 12 | Squidnet maintains a public SSH server. If you cannot play Cataclysm locally, 13 | or if you prefer to play it in a world shared with others, connect to 14 | cataclysm@squidnet.ath.cx (there is no password). 15 | 16 | Compiling Cataclysm under linux is straightforward, and only requires the 17 | ncurses development libraries. Under Ubuntu, these libraries can be found in 18 | the libncurses5-dev package ("sudo apt-get install libncurses5-dev" will install 19 | this package). 20 | 21 | Cataclysm is very different from most roguelikes in many ways. Rather than 22 | being set in a vertical, linear dungeon, it is set in an unbounded, 3D world. 23 | This means that exploration plays a much bigger role than in most roguelikes, 24 | and the game is much less linear. 25 | Because the map is so huge, it is actually completely persistant between games. 26 | If you die, and start a new character, your new game will be set in the same 27 | game world as your last. Like in many roguelikes, you will be able to loot the 28 | dead bodies of previous characters; unlike most roguelikes, you will also be 29 | able to retrace their steps completely, and any dramatic changes made to the 30 | world will persist into your next game. 31 | While this makes for interesting depth of play, and the ability to "save" game 32 | progress even after death, some prefer to start each game with a freshly 33 | generated world. This can be achieved by erasing the contents of the save 34 | directory, found in the same folder as the executable. "rm save/*" will erase 35 | these files for you. 36 | 37 | Cataclysm's gameplay also includes many unique quirks, and the learning curve is 38 | somewhat steep, even for those experienced with roguelikes. Included with the 39 | game is a tutorial which runs the player through most of the key features. The 40 | game also has extensive documentation via the ? command. Pressing ?1 will list 41 | all the key commands, which is a good place to start. 42 | 43 | To submit a bug, complaint, feature request, or praise, please send them via 44 | email to fivedozenwhales@gmail.com. You can also submit problem reports and 45 | patches at the github repository at http://github.com/Whales/Cataclysm . 46 | 47 | I strive to include as many feature requests as possible, and if you submit one 48 | there is a good chance that it will appear in the game within a few days. Of 49 | course, it is inevitable that I will reject some feature requests, either 50 | because they do not fit my conception of the game, or because they require more 51 | code than I think they're worth. Feature requests supplied in the form of a 52 | patch stand a better chance of inclusion, of course ;) For instructions on 53 | making changes to item types, monster types, etc., please see the EDITING file. 54 | Most changes of this variety require no training in C++, or programming in 55 | general. 56 | 57 | If you want to take Cataclysm in a new direction, please feel free to create a 58 | branch project--just let me know about it! 59 | -------------------------------------------------------------------------------- /action.h: -------------------------------------------------------------------------------- 1 | #ifndef _ACTION_H_ 2 | #define _ACTION_H_ 3 | 4 | enum action_id { 5 | ACTION_NULL = 0, 6 | // Movement 7 | ACTION_PAUSE, 8 | ACTION_MOVE_N, 9 | ACTION_MOVE_NE, 10 | ACTION_MOVE_E, 11 | ACTION_MOVE_SE, 12 | ACTION_MOVE_S, 13 | ACTION_MOVE_SW, 14 | ACTION_MOVE_W, 15 | ACTION_MOVE_NW, 16 | ACTION_MOVE_DOWN, 17 | ACTION_MOVE_UP, 18 | // Environment Interaction 19 | ACTION_OPEN, 20 | ACTION_CLOSE, 21 | ACTION_SMASH, 22 | ACTION_EXAMINE, 23 | ACTION_PICKUP, 24 | ACTION_BUTCHER, 25 | ACTION_CHAT, 26 | ACTION_LOOK, 27 | // Inventory Interaction (including quasi-inventories like bionics) 28 | ACTION_INVENTORY, 29 | ACTION_ORGANIZE, 30 | ACTION_USE, 31 | ACTION_WEAR, 32 | ACTION_TAKE_OFF, 33 | ACTION_EAT, 34 | ACTION_READ, 35 | ACTION_WIELD, 36 | ACTION_PICK_STYLE, 37 | ACTION_RELOAD, 38 | ACTION_UNLOAD, 39 | ACTION_THROW, 40 | ACTION_FIRE, 41 | ACTION_FIRE_BURST, 42 | ACTION_DROP, 43 | ACTION_DIR_DROP, 44 | ACTION_BIONICS, 45 | // Long-term / special actions 46 | ACTION_WAIT, 47 | ACTION_CRAFT, 48 | ACTION_CONSTRUCT, 49 | ACTION_SLEEP, 50 | ACTION_TOGGLE_SAFEMODE, 51 | ACTION_TOGGLE_AUTOSAFE, 52 | ACTION_IGNORE_ENEMY, 53 | ACTION_SAVE, 54 | ACTION_QUIT, 55 | // Info Screens 56 | ACTION_PL_INFO, 57 | ACTION_MAP, 58 | ACTION_MISSIONS, 59 | ACTION_FACTIONS, 60 | ACTION_MORALE, 61 | ACTION_MESSAGES, 62 | ACTION_HELP, 63 | // Debug Functions 64 | ACTION_DEBUG, 65 | ACTION_DISPLAY_SCENT, 66 | ACTION_TOGGLE_DEBUGMON, 67 | NUM_ACTIONS 68 | }; 69 | 70 | action_id look_up_action(std::string ident); 71 | std::string action_ident(action_id); 72 | std::string action_name(action_id); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /addiction.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADDICTION_H_ 2 | #define _ADDICTION_H_ 3 | 4 | #include "rng.h" 5 | #include "game.h" 6 | #include "morale.h" 7 | #include 8 | 9 | #define MIN_ADDICTION_LEVEL 3 // Minimum intensity before effects are seen 10 | 11 | void addict_effect(game *g, addiction &add) 12 | { 13 | int in = add.intensity; 14 | 15 | switch (add.type) { 16 | case ADD_CIG: 17 | if (in > 20 || one_in((500 - 20 * in))) { 18 | g->add_msg("You %s a cigarette.", 19 | rng(0, 6) < in ? "need" : "could use"); 20 | g->cancel_activity_query("You have a nicotine craving."); 21 | g->u.add_morale(MORALE_CRAVING_NICOTINE, -15, -50); 22 | if (one_in(800 - 50 * in)) 23 | g->u.fatigue++; 24 | if (one_in(400 - 20 * in)) 25 | g->u.stim--; 26 | } 27 | break; 28 | 29 | case ADD_CAFFEINE: 30 | g->u.moves -= 2; 31 | if (in > 20 || one_in((500 - 20 * in))) { 32 | g->add_msg("You want some caffeine."); 33 | g->cancel_activity_query("You have a caffeine craving."); 34 | g->u.add_morale(MORALE_CRAVING_CAFFEINE, -5, -30); 35 | if (rng(0, 10) < in) 36 | g->u.stim--; 37 | if (rng(8, 400) < in) { 38 | g->add_msg("Your hands start shaking... you need it bad!"); 39 | g->u.add_disease(DI_SHAKES, 20, g); 40 | } 41 | } 42 | break; 43 | 44 | case ADD_ALCOHOL: 45 | g->u.per_cur--; 46 | g->u.int_cur--; 47 | if (rng(40, 1200) <= in * 10) 48 | g->u.health--; 49 | if (one_in(20) && rng(0, 20) < in) { 50 | g->add_msg("You could use a drink."); 51 | g->cancel_activity_query("You have an alcohol craving."); 52 | g->u.add_morale(MORALE_CRAVING_ALCOHOL, -35, -120); 53 | } else if (rng(8, 300) < in) { 54 | g->add_msg("Your hands start shaking... you need a drink bad!"); 55 | g->cancel_activity_query("You have an alcohol craving."); 56 | g->u.add_morale(MORALE_CRAVING_ALCOHOL, -35, -120); 57 | g->u.add_disease(DI_SHAKES, 50, g); 58 | } else if (!g->u.has_disease(DI_HALLU) && rng(10, 1600) < in) 59 | g->u.add_disease(DI_HALLU, 3600, g); 60 | break; 61 | 62 | case ADD_SLEEP: 63 | // No effects here--just in player::can_sleep() 64 | // EXCEPT! Prolong this addiction longer than usual. 65 | if (one_in(2) && add.sated < 0) 66 | add.sated++; 67 | break; 68 | 69 | case ADD_PKILLER: 70 | if ((in >= 25 || int(g->turn) % (100 - in * 4) == 0) && g->u.pkill > 0) 71 | g->u.pkill--; // Tolerance increases! 72 | if (g->u.pkill >= 35) // No further effects if we're doped up. 73 | add.sated = 0; 74 | else { 75 | g->u.str_cur -= 1 + int(in / 7); 76 | g->u.per_cur--; 77 | g->u.dex_cur--; 78 | if (g->u.pain < in * 3) 79 | g->u.pain++; 80 | if (in >= 40 || one_in((1200 - 30 * in))) 81 | g->u.health--; 82 | if (one_in(20) && dice(2, 20) < in) { 83 | g->add_msg("Your hands start shaking... you need some painkillers."); 84 | g->cancel_activity_query("You have an opiate craving."); 85 | g->u.add_morale(MORALE_CRAVING_OPIATE, -40, -200); 86 | g->u.add_disease(DI_SHAKES, 20 + in * 5, g); 87 | } else if (one_in(20) && dice(2, 30) < in) { 88 | g->add_msg("You feel anxious. You need your painkillers!"); 89 | g->u.add_morale(MORALE_CRAVING_OPIATE, -30, -200); 90 | g->cancel_activity_query("You have a craving."); 91 | } else if (one_in(50) && dice(3, 50) < in) { 92 | g->add_msg("You throw up heavily!"); 93 | g->cancel_activity_query("Throwing up."); 94 | g->u.vomit(g); 95 | } 96 | } 97 | break; 98 | 99 | case ADD_SPEED: { 100 | int move_pen = in * 5; 101 | if (move_pen > 30) 102 | move_pen = 30; 103 | g->u.moves -= move_pen; 104 | g->u.int_cur--; 105 | g->u.str_cur--; 106 | if (g->u.stim > -100 && (in >= 20 || int(g->turn) % (100 - in * 5) == 0)) 107 | g->u.stim--; 108 | if (rng(0, 150) <= in) 109 | g->u.health--; 110 | if (dice(2, 100) < in) { 111 | g->add_msg("You feel depressed. Speed would help."); 112 | g->cancel_activity_query("You have a speed craving."); 113 | g->u.add_morale(MORALE_CRAVING_SPEED, -25, -200); 114 | } else if (one_in(10) && dice(2, 80) < in) { 115 | g->add_msg("Your hands start shaking... you need a pick-me-up."); 116 | g->cancel_activity_query("You have a speed craving."); 117 | g->u.add_morale(MORALE_CRAVING_SPEED, -25, -200); 118 | g->u.add_disease(DI_SHAKES, in * 20, g); 119 | } else if (one_in(50) && dice(2, 100) < in) { 120 | g->add_msg("You stop suddenly, feeling bewildered."); 121 | g->cancel_activity(); 122 | g->u.moves -= 300; 123 | } else if (!g->u.has_disease(DI_HALLU) && one_in(20) && 124 | 8 + dice(2, 80) < in) 125 | g->u.add_disease(DI_HALLU, 3600, g); 126 | } break; 127 | 128 | case ADD_COKE: 129 | g->u.int_cur--; 130 | g->u.per_cur--; 131 | if (in >= 30 || one_in((900 - 30 * in))) { 132 | g->add_msg("You feel like you need a bump."); 133 | g->cancel_activity_query("You have a craving for cocaine."); 134 | g->u.add_morale(MORALE_CRAVING_COCAINE, -20, -250); 135 | } 136 | if (dice(2, 80) <= in) { 137 | g->add_msg("You feel like you need a bump."); 138 | g->cancel_activity_query("You have a craving for cocaine."); 139 | g->u.add_morale(MORALE_CRAVING_COCAINE, -20, -250); 140 | g->u.stim -= 3; 141 | } 142 | break; 143 | } 144 | } 145 | 146 | std::string addiction_name(addiction cur) 147 | { 148 | switch (cur.type) { 149 | case ADD_CIG: return "Nicotine Withdrawal"; 150 | case ADD_CAFFEINE: return "Caffeine Withdrawal"; 151 | case ADD_ALCOHOL: return "Alcohol Withdrawal"; 152 | case ADD_SLEEP: return "Sleeping Pill Dependance"; 153 | case ADD_PKILLER: return "Opiate Withdrawal"; 154 | case ADD_SPEED: return "Amphetamine Withdrawal"; 155 | case ADD_COKE: return "Cocaine Withdrawal"; 156 | default: return "Erroneous addiction"; 157 | } 158 | } 159 | 160 | std::string addiction_text(addiction cur) 161 | { 162 | std::stringstream dump; 163 | int strpen = 1 + int(cur.intensity / 7); 164 | switch (cur.type) { 165 | case ADD_CIG: 166 | return "Intelligence - 1; Occasional cravings"; 167 | 168 | case ADD_CAFFEINE: 169 | return "Strength - 1; Slight sluggishness; Occasional cravings"; 170 | 171 | case ADD_ALCOHOL: 172 | return "\ 173 | Perception - 1; Intelligence - 1; Occasional Cravings;\n\ 174 | Risk of delirium tremens"; 175 | 176 | case ADD_SLEEP: 177 | return "You may find it difficult to sleep without medication."; 178 | 179 | case ADD_PKILLER: 180 | dump << "Strength -" << strpen << "; Perception - 1; Dexterity - 1;" << 181 | std::endl << 182 | "Depression and physical pain to some degree. Frequent cravings. Vomiting."; 183 | return dump.str(); 184 | 185 | case ADD_SPEED: 186 | return "Strength - 1; Intelligence - 1;\n\ 187 | Movement rate reduction. Depression. Weak immune system. Frequent cravings."; 188 | 189 | case ADD_COKE: 190 | return "Perception - 1; Intelligence - 1; Frequent cravings."; 191 | 192 | default: 193 | return ""; 194 | } 195 | } 196 | 197 | #endif 198 | -------------------------------------------------------------------------------- /artifact.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARTIFACT_H_ 2 | #define _ARTIFACT_H_ 3 | 4 | #include 5 | #include 6 | 7 | enum art_effect_passive { 8 | AEP_NULL = 0, 9 | // Good 10 | AEP_STR_UP, // Strength + 4 11 | AEP_DEX_UP, // Dexterity + 4 12 | AEP_PER_UP, // Perception + 4 13 | AEP_INT_UP, // Intelligence + 4 14 | AEP_ALL_UP, // All stats + 2 15 | AEP_SPEED_UP, // +20 speed 16 | AEP_IODINE, // Reduces radiation 17 | AEP_SNAKES, // Summons friendly snakes when you're hit 18 | AEP_INVISIBLE, // Makes you invisible 19 | AEP_CLAIRVOYANCE, // See through walls 20 | AEP_STEALTH, // Your steps are quieted 21 | AEP_EXTINGUISH, // May extinguish nearby flames 22 | AEP_GLOW, // Four-tile light source 23 | 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 27 | // Splits good from bad 28 | AEP_SPLIT, 29 | // Bad 30 | AEP_HUNGER, // Increases hunger 31 | AEP_THIRST, // Increases thirst 32 | AEP_SMOKE, // Emits smoke occasionally 33 | AEP_EVIL, // Addiction to the power 34 | AEP_SCHIZO, // Mimicks schizophrenia 35 | AEP_RADIOACTIVE, // Increases your radiation 36 | AEP_MUTAGENIC, // Mutates you slowly 37 | AEP_ATTENTION, // Draws netherworld attention slowly 38 | AEP_STR_DOWN, // Strength - 3 39 | AEP_DEX_DOWN, // Dex - 3 40 | AEP_PER_DOWN, // Per - 3 41 | AEP_INT_DOWN, // Int - 3 42 | AEP_ALL_DOWN, // All stats - 2 43 | 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 48 | 49 | NUM_AEPS 50 | }; 51 | 52 | enum art_effect_active { 53 | AEA_NULL = 0, 54 | 55 | AEA_STORM, // Emits shock fields 56 | AEA_FIREBALL, // Targeted 57 | AEA_ADRENALINE, // Adrenaline rush 58 | AEA_MAP, // Maps the area around you 59 | AEA_BLOOD, // Shoots blood all over 60 | AEA_FATIGUE, // Creates interdimensional fatigue 61 | AEA_ACIDBALL, // Targeted acid 62 | AEA_PULSE, // Destroys adjacent terrain 63 | AEA_HEAL, // Heals minor damage 64 | AEA_CONFUSED, // Confuses all monsters in view 65 | AEA_ENTRANCE, // Chance to make nearby monsters friendly 66 | 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! 71 | 72 | AEA_SPLIT, // Split between good and bad 73 | 74 | AEA_RADIATION, // Spew radioactive gas 75 | AEA_PAIN, // Increases player pain 76 | AEA_MUTATE, // Chance of mutation 77 | AEA_PARALYZE, // You lose several turns 78 | AEA_FIRESTORM, // Spreads minor fire all around you 79 | AEA_ATTENTION, // Attention from sub-prime denizens 80 | 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 | 88 | NUM_AEAS 89 | }; 90 | 91 | enum art_charge 92 | { 93 | ARTC_NULL, // Never recharges! 94 | ARTC_TIME, // Very slowly recharges with time 95 | ARTC_SOLAR, // Recharges in sunlight 96 | ARTC_PAIN, // Creates pain to recharge 97 | ARTC_HP, // Drains HP to recharge 98 | NUM_ARTCS 99 | }; 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 | 147 | #endif 148 | -------------------------------------------------------------------------------- /bodypart.cpp: -------------------------------------------------------------------------------- 1 | #include "bodypart.h" 2 | #include "rng.h" 3 | 4 | std::string body_part_name (body_part bp, int side) 5 | { 6 | switch (bp) { 7 | case bp_head: 8 | return "head"; 9 | case bp_eyes: 10 | return "eyes"; 11 | case bp_mouth: 12 | return "mouth"; 13 | case bp_torso: 14 | return "torso"; 15 | case bp_arms: 16 | if (side == 0) 17 | return "left arm"; 18 | if (side == 1) 19 | return "right arm"; 20 | return "arms"; 21 | case bp_hands: 22 | if (side == 0) 23 | return "left hand"; 24 | if (side == 1) 25 | return "right hand"; 26 | return "hands"; 27 | case bp_legs: 28 | if (side == 0) 29 | return "left leg"; 30 | if (side == 1) 31 | return "right leg"; 32 | return "legs"; 33 | case bp_feet: 34 | if (side == 0) 35 | return "left foot"; 36 | if (side == 1) 37 | return "right foot"; 38 | return "feet"; 39 | default: 40 | return "appendix"; 41 | } 42 | } 43 | 44 | std::string encumb_text(body_part bp) 45 | { 46 | switch (bp) { 47 | case bp_head: return ""; 48 | case bp_eyes: return "Ranged combat is hampered."; 49 | case bp_mouth: return "Running is slowed."; 50 | case bp_torso: return "Dodging and melee is hampered."; 51 | case bp_arms: return "Melee and ranged combat is hampered."; 52 | case bp_hands: return "Manual tasks are slowed."; 53 | case bp_legs: return "Running and swimming are slowed."; 54 | case bp_feet: return "Running is slowed."; 55 | default: return "It's inflammed."; 56 | } 57 | } 58 | 59 | body_part random_body_part() 60 | { 61 | int rn = rng(0, 30); 62 | if (rn == 0) 63 | return bp_eyes; 64 | if (rn <= 2) 65 | return bp_mouth; 66 | if (rn <= 6) 67 | return bp_head; 68 | if (rn <= 12) 69 | return bp_legs; 70 | if (rn <= 20) 71 | return bp_arms; 72 | return bp_torso; 73 | } 74 | -------------------------------------------------------------------------------- /bodypart.h: -------------------------------------------------------------------------------- 1 | #ifndef _BODYPART_H_ 2 | #define _BODYPART_H_ 3 | 4 | #include 5 | 6 | enum body_part { 7 | bp_head = 0, 8 | bp_eyes, 9 | bp_mouth, 10 | bp_torso, 11 | bp_arms, 12 | bp_hands, 13 | bp_legs, 14 | bp_feet, 15 | num_bp 16 | }; 17 | 18 | std::string body_part_name(body_part bp, int side); 19 | std::string encumb_text(body_part bp); 20 | 21 | body_part random_body_part(); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /calendar.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "weather.h" 3 | 4 | // How many minutes exist when the game starts - 8:00 AM 5 | #define STARTING_MINUTES 480 6 | // The number of days in a season - this also defines moon cycles 7 | #define DAYS_IN_SEASON 14 8 | 9 | // Convert minutes, hours, days to turns 10 | #define MINUTES(x) ((x) * 10) 11 | #define HOURS(x) ((x) * 600) 12 | #define DAYS(x) ((x) * 14400) 13 | 14 | // Times for sunrise, sunset at equinoxes 15 | #define SUNRISE_WINTER 7 16 | #define SUNRISE_SOLSTICE 6 17 | #define SUNRISE_SUMMER 5 18 | 19 | #define SUNSET_WINTER 17 20 | #define SUNSET_SOLSTICE 19 21 | #define SUNSET_SUMMER 21 22 | 23 | // How long, in minutes, does sunrise/sunset last? 24 | #define TWILIGHT_MINUTES 60 25 | 26 | // How much light moon provides--double for full moon 27 | #define MOONLIGHT_LEVEL 4 28 | // How much light is provided in full daylight 29 | #define DAYLIGHT_LEVEL 60 30 | 31 | enum moon_phase { 32 | MOON_NEW = 0, 33 | MOON_HALF, 34 | MOON_FULL 35 | }; 36 | 37 | class calendar 38 | { 39 | public: 40 | // The basic data; note that "second" should always be a multiple of 6 41 | int second; 42 | int minute; 43 | int hour; 44 | int day; 45 | season_type season; 46 | int year; 47 | // End data 48 | 49 | calendar(); 50 | calendar(const calendar ©); 51 | calendar(int Minute, int Hour, int Day, season_type Season, int Year); 52 | calendar(int turn); 53 | int get_turn(); 54 | operator int() const; // Returns get_turn() for backwards compatibility 55 | calendar& operator = (calendar &rhs); 56 | calendar& operator = (int rhs); 57 | calendar& operator -=(calendar &rhs); 58 | calendar& operator -=(int rhs); 59 | calendar& operator +=(calendar &rhs); 60 | calendar& operator +=(int rhs); 61 | calendar operator - (calendar &rhs); 62 | calendar operator - (int rhs); 63 | calendar operator + (calendar &rhs); 64 | calendar operator + (int rhs); 65 | 66 | void increment(); // Add one turn / 6 seconds 67 | 68 | void standardize(); // Ensure minutes <= 59, hour <= 23, etc. 69 | 70 | // Sunlight and day/night calcuations 71 | int minutes_past_midnight(); // Useful for sunrise/set calculations 72 | moon_phase moon(); // Find phase of moon 73 | calendar sunrise(); // Current time of sunrise 74 | calendar sunset(); // Current time of sunset 75 | bool is_night(); // After sunset + TWILIGHT_MINUTES, before sunrise 76 | int sunlight(); // Current amount of sun/moonlight; uses preceding funcs 77 | 78 | // Print-friendly stuff 79 | std::string print_time(bool twentyfour = false); 80 | std::string textify_period(); // "1 second" "2 hours" "two days" 81 | }; 82 | -------------------------------------------------------------------------------- /catacurse.h: -------------------------------------------------------------------------------- 1 | #ifndef __CATACURSE__ 2 | #define __CATACURSE__ 3 | #define _WIN32_WINNT 0x0500 4 | #define WIN32_LEAN_AND_MEAN 5 | //#define VC_EXTRALEAN 6 | #include 7 | #include 8 | typedef int chtype; 9 | typedef unsigned short attr_t; 10 | typedef unsigned int u_int32_t; 11 | 12 | #define __CHARTEXT 0x000000ff /* bits for 8-bit characters */ //<---------not used 13 | #define __NORMAL 0x00000000 /* Added characters are normal. */ //<---------not used 14 | #define __STANDOUT 0x00000100 /* Added characters are standout. */ //<---------not used 15 | #define __UNDERSCORE 0x00000200 /* Added characters are underscored. */ //<---------not used 16 | #define __REVERSE 0x00000400 /* Added characters are reverse //<---------not used 17 | video. */ 18 | #define __BLINK 0x00000800 /* Added characters are blinking. */ 19 | #define __DIM 0x00001000 /* Added characters are dim. */ //<---------not used 20 | #define __BOLD 0x00002000 /* Added characters are bold. */ 21 | #define __BLANK 0x00004000 /* Added characters are blanked. */ //<---------not used 22 | #define __PROTECT 0x00008000 /* Added characters are protected. */ //<---------not used 23 | #define __ALTCHARSET 0x00010000 /* Added characters are ACS */ //<---------not used 24 | #define __COLOR 0x03fe0000 /* Color bits */ 25 | #define __ATTRIBUTES 0x03ffff00 /* All 8-bit attribute bits */ //<---------not used 26 | 27 | //a pair of colors[] indexes, foreground and background 28 | typedef struct 29 | { 30 | int FG;//foreground index in colors[] 31 | int BG;//foreground index in colors[] 32 | } pairs; 33 | 34 | //The curse character struct, just a char, attribute, and color pair 35 | //typedef struct 36 | //{ 37 | // char character;//the ascii actual character 38 | // int attrib;//attributes, mostly for A_BLINK and A_BOLD 39 | // pairs color;//pair of foreground/background, indexed into colors[] 40 | //} cursechar; 41 | 42 | //Individual lines, so that we can track changed lines 43 | typedef struct{ 44 | bool touched; 45 | char *chars; 46 | char *FG; 47 | char *BG; 48 | //cursechar chars [80]; 49 | } curseline; 50 | //The curses window struct 51 | typedef struct { 52 | int x;//left side of window 53 | int y;//top side of window 54 | int width;//width of the curses window 55 | int height;//height of the curses window 56 | int FG;//current foreground color from attron 57 | int BG;//current background color from attron 58 | bool inuse;// Does this window actually exist? 59 | bool draw;//Tracks if the window text has been changed 60 | int cursorx;//x location of the cursor 61 | int cursory;//y location of the cursor 62 | curseline *line; 63 | } WINDOW; 64 | 65 | #define A_NORMAL __NORMAL 66 | #define A_STANDOUT __STANDOUT 67 | #define A_UNDERLINE __UNDERSCORE 68 | #define A_REVERSE __REVERSE 69 | #define A_BLINK __BLINK 70 | #define A_DIM __DIM 71 | #define A_BOLD __BOLD 72 | #define A_BLANK __BLANK 73 | #define A_PROTECT __PROTECT 74 | #define A_ALTCHARSET __ALTCHARSET 75 | #define A_ATTRIBUTES __ATTRIBUTES 76 | #define A_CHARTEXT __CHARTEXT 77 | #define A_COLOR __COLOR 78 | 79 | #define COLOR_BLACK 0x00 //RGB{0,0,0} 80 | #define COLOR_RED 0x01 //RGB{196, 0, 0} 81 | #define COLOR_GREEN 0x02 //RGB{0,196,0} 82 | #define COLOR_YELLOW 0x03 //RGB{196,180,30} 83 | #define COLOR_BLUE 0x04 //RGB{0, 0, 196} 84 | #define COLOR_MAGENTA 0x05 //RGB{196, 0, 180} 85 | #define COLOR_CYAN 0x06 //RGB{0, 170, 200} 86 | #define COLOR_WHITE 0x07 //RGB{196, 196, 196} 87 | 88 | #define COLOR_PAIR(n) ((((u_int32_t)n) << 17) & A_COLOR) 89 | //#define PAIR_NUMBER(n) ((((u_int32_t)n) & A_COLOR) >> 17) 90 | 91 | #define KEY_MIN 0x101 /* minimum extended key value */ //<---------not used 92 | #define KEY_BREAK 0x101 /* break key */ //<---------not used 93 | #define KEY_DOWN 0x102 /* down arrow */ 94 | #define KEY_UP 0x103 /* up arrow */ 95 | #define KEY_LEFT 0x104 /* left arrow */ 96 | #define KEY_RIGHT 0x105 /* right arrow*/ 97 | #define KEY_HOME 0x106 /* home key */ //<---------not used 98 | #define KEY_BACKSPACE 0x107 /* Backspace */ //<---------not used 99 | 100 | /* Curses external declarations. */ 101 | 102 | #define stdscr 0 103 | //WINDOW *stdscr; //Define this for portability, strscr will basically be window[0] anyways 104 | 105 | #define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) 106 | 107 | //Curses Functions 108 | #define ERR (-1) /* Error return. */ 109 | #define OK (0) /* Success return. */ 110 | WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x); 111 | int delwin(WINDOW *win); 112 | int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br); 113 | int wrefresh(WINDOW *win); 114 | int refresh(void); 115 | int getch(void); 116 | int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...); 117 | int mvprintw(int y, int x, const char *fmt, ...); 118 | int werase(WINDOW *win); 119 | int start_color(void); 120 | int init_pair(short pair, short f, short b); 121 | int wmove(WINDOW *win, int y, int x); 122 | 123 | int clear(void); 124 | int erase(void); 125 | int endwin(void); 126 | int mvwaddch(WINDOW *win, int y, int x, const chtype ch); 127 | int wclear(WINDOW *win); 128 | int wprintw(WINDOW *win, const char *fmt, ...); 129 | WINDOW *initscr(void); 130 | int noecho(void);//PORTABILITY, DUMMY FUNCTION 131 | int cbreak(void);//PORTABILITY, DUMMY FUNCTION 132 | int keypad(WINDOW *faux, bool bf);//PORTABILITY, DUMMY FUNCTION 133 | int curs_set(int visibility);//PORTABILITY, DUMMY FUNCTION 134 | int mvaddch(int y, int x, const chtype ch); 135 | int wattron(WINDOW *win, int attrs); 136 | int wattroff(WINDOW *win, int attrs); 137 | int attron(int attrs); 138 | int attroff(int attrs); 139 | int waddch(WINDOW *win, const chtype ch); 140 | int printw(const char *fmt,...); 141 | int getmaxx(WINDOW *win); 142 | int getmaxy(WINDOW *win); 143 | int move(int y, int x); 144 | void timeout(int delay);//PORTABILITY, DUMMY FUNCTION 145 | 146 | //Window Functions, Do not call these outside of catacurse.cpp 147 | void WinDestroy(); 148 | bool WinCreate(bool initgl); 149 | void CheckMessages(); 150 | int FindWin(WINDOW *wnd); 151 | LRESULT CALLBACK ProcessMessages(HWND__ *hWnd,u_int32_t Msg,WPARAM wParam, LPARAM lParam); 152 | #endif 153 | -------------------------------------------------------------------------------- /code_doc/EDITING: -------------------------------------------------------------------------------- 1 | ADDITIONS 2 | 3 | 1.1 Adding an item 4 | 1) Edit itype.h. Change the enum item_id and insert a unique identifier for 5 | your new item type. Be sure to put it among similar items. 6 | 2) Edit itypedef.cpp. Macros are used for all item types, and they are pretty 7 | self-explanatory. Be ABSOLUTELY sure that you insert the macro at the same 8 | point in the list as you inserted the identifier in item_id! 9 | 3) Your item type is now valid, but won't be spawned. If you want it to be 10 | spawned among similar items, edit mapitemsdef.cpp. Find the appropriate 11 | array(s), and insert the identifier for your item (e.g. itm_aspirin). Make 12 | sure it comes in before the NULL at the end of the list. 13 | 5) Some items, like tools or food, also take an iuse::function reference. 14 | Edit iuse.h and include the function in the class declaration; then edit 15 | iuse.cpp and define your function. Functions may be shared among different 16 | item types. 17 | 18 | 1.2 Adding a monster 19 | 1) Edit mtype.h. Change the enum mon_id and insert a unique identifier for 20 | your new monster type. Be sure to put it among similar monsters. 21 | 2) Edit montypedef.cpp. A macro is used for monsters and it is pretty 22 | straightforward (Any of this ring a bell?). Be ABSOLUTELY sure that you 23 | insert the macro at the same point in the list as your inserted the 24 | identifier in mon_id! 25 | 3) Your monster type is now valid, but won't be spawned. If you want it to be 26 | spawned among similar monsters, edit mongroupdef.cpp. Find the appropriate 27 | array, and insert the identifier for your monster (e.g, mon_zombie). Make 28 | sure it comes in before the NULL at the end of the list. 29 | 4) If you want your monster to drop items, edit monitemsdef.cpp. Make a new 30 | array for your monster type with all the map item groups it may carry, and a 31 | chance value for each. 32 | 5) Your monster may have a special attack, a monattack::function reference. 33 | Edit monattack.h and include the function in the class definition; then 34 | edit monattack.cpp and define your function. Functions may be shared among 35 | different monster types. Be aware that the function should contain a 36 | statement that the monster uses to decide whether or not to use the attack, 37 | and if they do, should reset the monster's attack timer. 38 | 7) Just like attacks, some monsters may have a special function called when 39 | they die. This works the same as attacks, but the relevent files are 40 | mondeath.h and mondeath.cpp. 41 | 42 | -------------------------------------------------------------------------------- /code_doc/ENUMS: -------------------------------------------------------------------------------- 1 | ENUMS 2 | 3 | This is a guide to all the enumerations in the game. If you encounter a flag 4 | you don't understand, grep it here. Likewise if a function accepts an m_flags 5 | tag, grep this document for 'm_flags'. Enums are also labeled with the file in 6 | which they are defined. 7 | 8 | Format: 9 | 10 | : 11 | 12 | 13 | 14 | ---------------------------------------- 15 | 16 | bionics.h : bionic_id 17 | bio_null, bio_batteries, bio_metabolics, bio_solar, bio_furnace, bio_ethanol, 18 | bio_memory, bio_ears, bio_eye_enhancer, bio_membrane, bio_targeting, bio_gills, 19 | bio_purifier, bio_climate, bio_storage, bio_recycler, bio_digestion, bio_tools, 20 | bio_shock, bio_heat_absorb, bio_carbon, bio_armor_head, bio_armor_torso, 21 | bio_armor_arms, bio_armor_legs, bio_flashlight, bio_night_vision, bio_infrared, 22 | bio_face_mask, bio_ads, bio_ods, bio_scent_mask, bio_cloak, bio_painkiller, 23 | bio_nanobots, bio_heatsink, bio_resonator, bio_time_freeze, bio_teleport, 24 | bio_blood_anal, bio_blood_filter, bio_alarm, bio_evap, bio_lighter, bio_claws, 25 | bio_blaster, bio_laser, bio_emp, bio_hydraulics, bio_water_extractor, 26 | bio_magnet, bio_fingerhack, bio_lockpick, bio_ground_sonar, max_bio_start, 27 | bio_banish, bio_gate_out, bio_gate_in, bio_nightfall, bio_drilldown, 28 | bio_heatwave, bio_lightning, bio_tremor, bio_flashflood, max_bio_good, 29 | bio_dis_shock, bio_dis_acid, bio_drain, bio_noise, bio_power_weakness, 30 | bio_stiff, max_bio 31 | 32 | bodypart.h : body_part 33 | color.h : col_attribute 34 | color.h : nc_color 35 | crafting.h : craft_cat 36 | dialogue.h : talk_topic 37 | enums.h : material 38 | event.h : event_type 39 | faction.h : faction_goal 40 | faction.h : faction_job 41 | faction.h : faction_value 42 | game.h : tut_type 43 | itype.h : itype_id 44 | itype.h : item_cat 45 | itype.h : ammotype 46 | itype.h : weapon_flag 47 | itype.h : container_flags 48 | line.h : direction 49 | map.cpp : astar_list 50 | mapdata.h : t_flag 51 | mapdata.h : ter_id 52 | mapdata.h : map_extra 53 | mapdata.h : field_id 54 | mapgen.cpp : room_type 55 | mapitems.h : items_location 56 | mission.h : mission_id 57 | mission.h : mission_origin 58 | mission.h : mission_goal 59 | mongroup.h : moncat_id 60 | monster.h : monster_effect_type 61 | morale.h:enum morale_type 62 | mtype.h : mon_id 63 | mtype.h : m_size 64 | mtype.h : m_flags 65 | npc.h : npc_attitude 66 | npc.h : npc_mission 67 | npc.h : npc_class 68 | npc.h : npc_action 69 | npc.h : npc_need 70 | npc.h : npc_flag 71 | omdata.h : oter_id 72 | omdata.h:// Order MUST match enum oter_id above! 73 | overmap.h:#include "enums.h" 74 | pldata.h : character_type 75 | pldata.h : dis_type 76 | pldata.h : add_type 77 | pldata.h : activity_type 78 | pldata.h : pl_flag 79 | pldata.h : hp_part 80 | skill.h : skill 81 | trap.h : trap_id 82 | tutorial.h : tut_lesson 83 | weather.h : season_type 84 | weather.h : weather_type 85 | -------------------------------------------------------------------------------- /code_doc/GAMEMODES: -------------------------------------------------------------------------------- 1 | #0 Table of Contents 2 | 3 | #0 Table of Contents 4 | #1 Files 5 | #2 special_game class 6 | #3 Functions 7 | #3.0 id() 8 | #3.1 init() 9 | #3.2 per_turn() 10 | #3.3 pre_action() 11 | #3.4 post_action() 12 | #3.5 game_over() 13 | 14 | #1 Files 15 | 16 | The main file to be concerned with is gamemode.h. 17 | 18 | This is where you can insert the class definition for your game mode, and any 19 | enums it might use. 20 | 21 | gamemode.cpp is also important, if short. It contains two functions: 22 | special_game_name() returns the name of each special game. 23 | get_special_game() returns a pointer to a special game of the proper 24 | type. 25 | 26 | Also of note are tutorial.h (houses text snippets for tutorials), and 27 | tutorial.cpp and defense.cpp, which house code for tutorials and defense games 28 | respectively. 29 | 30 | If you add a new game mode, use .cpp for its code and .h 31 | for any static data associated with it. 32 | 33 | 34 | 35 | #2 special_game class 36 | 37 | Every new game mode is a child class of special_game. It may house any private 38 | functions and variables it needs, as well as a constructor, but otherwise the 39 | only public members should be the five functions described below. 40 | 41 | The game class holds a pointer to a special_game. The five functions are 42 | called as is appropriate, and thus are cast to the proper function in a child 43 | class. 44 | 45 | There is an enum, special_game_id, at the top of gamemode.h. There should be 46 | one entry for every game mode in existance. Add one for yours. 47 | 48 | 49 | 50 | #3 Functions 51 | 52 | 53 | #3.0 id() 54 | 55 | virtual special_game_id id(); 56 | 57 | Returns the special_game_id assigned to your game mode. 58 | 59 | 60 | #3.1 init() 61 | 62 | virtual void init(game *g); 63 | 64 | This is run when your game mode begins. 65 | 66 | Some ideas: 67 | >>Change the itype and mtype definitions--remove certain monsters from 68 | the game, make certain items weightless, make baseballs bats uber-powerful 69 | >>Change the recipes. Add new ones, reduce the time crafting takes. 70 | >>Start the game in a special area. Edit the world to be entirely swamp. 71 | 72 | 73 | #3.2 per_turn() 74 | 75 | virtual void per_turn(game *g); 76 | 77 | This is run every turn, before anything else is done, including player actions. 78 | 79 | Some ideas: 80 | >>Reset the player's thirst, hunger, or fatigue to 0, eliminating these needs 81 | >>Spawn some monsters every 50 turns 82 | >>Make fire burn off faster 83 | >>Add a chance for a space debris to fall 84 | 85 | 86 | #3.3 pre_action() 87 | 88 | virtual void pre_action(game *g, action_id &act); 89 | 90 | This is run after a keypress, but before the action is performed. The action 91 | is passed by reference, so you can modify it if you like. 92 | 93 | Some ideas: 94 | >>Rewrite the functionality of actions entirely; change the long wait menu, 95 | for example 96 | >>Disallow certain actions by setting act to ACTION_NULL 97 | >>Add a confirmation request to certain actions 98 | >>Make the availability of certain actions dependant on game state 99 | 100 | 101 | #3.4 post_action() 102 | 103 | virtual void post_action(game *g, action_id act); 104 | 105 | This is run after an action is performed. 106 | 107 | Some ideas: 108 | >>Make certain actions perform faster by rebating movement points 109 | >>Add extra effects to certain actions 110 | >>Display a message upon execution of certain actions 111 | 112 | 113 | #3.5 game_over() 114 | 115 | virtual void game_over(game *g); 116 | 117 | This is run when the game is over (player quit or died). 118 | 119 | Some ideas: 120 | >>Add a special achievement message, e.g. number of rounds survived 121 | >>Delete any special files created during play 122 | -------------------------------------------------------------------------------- /code_doc/TODO_SHORT: -------------------------------------------------------------------------------- 1 | Drag furniture / objects 2 | Balance high skill levels of melee 3 | Balance cutting/bashing 4 | -------------------------------------------------------------------------------- /code_doc/release_2012.2: -------------------------------------------------------------------------------- 1 | Save NPCs: 2 hours 2 | Save Missions: 2 hours 3 | Save Factions: 1.5 hours 4 | 5 | Wild NPCs: 9.5 hr 6 | Pick when to place them & do so: 1.5 hr 7 | Fortify their location (if necessary): 2.5 hr 8 | Set their goal / destination: 1.5 hr 9 | Give them missions to assign to the player: 2 hr 10 | Associate them with a faction: 2 hr 11 | 12 | Interruptable Crafting: 4 hrs 13 | Save items with "used in crafting" flag: 30 min 14 | Display such items colored in inventory: 30 min 15 | Warn when "used in crafting" items are used elsewhere: 1 hr 16 | Add "craft in progress" to crafting menu: 1 hr 17 | Add "crafting in progress" to player class: 1 hr 18 | 19 | Improved Melee & Unarmed: 6 hr 20 | Add special effect flags to combat system: 1.5 hr 21 | Add flags to itypedef.cpp: 1.5 hr 22 | Add itype::it_style to itype.h: .5 hr 23 | Add itype::it_style to itypedef.cpp: .5 hr 24 | Add 'wield style' dialog: 1 hr 25 | Starting Trait: 1 hr 26 | 27 | Unload from inventory: .5 hr 28 | 29 | Action keys in inventory view: 1.5 hr 30 | 31 | Move items to data files: 4 hr 32 | Write a function to save the data: 2 hr 33 | Write a function to load the data: 1.5 hr 34 | Cleanly delete data from source: .5 hr 35 | 36 | Move monsters to data files: 3 hr 37 | Write a function to save the data: 1.5 hr 38 | Write a function to load the data: 1 hr 39 | Cleanly delete data from source: .5 hr 40 | 41 | Move tiles to data files: 3 hr 42 | Write a function to save the data: 1.5 hr 43 | Write a function to load the data: 1 hr 44 | Cleanly delete data from source: .5 hr 45 | -------------------------------------------------------------------------------- /color.cpp: -------------------------------------------------------------------------------- 1 | #include "color.h" 2 | 3 | #define HILIGHT COLOR_BLUE 4 | void init_colors() 5 | { 6 | start_color(); 7 | 8 | init_pair( 1, COLOR_WHITE, COLOR_BLACK ); 9 | init_pair( 2, COLOR_RED, COLOR_BLACK ); 10 | init_pair( 3, COLOR_GREEN, COLOR_BLACK ); 11 | init_pair( 4, COLOR_BLUE, COLOR_BLACK ); 12 | init_pair( 5, COLOR_CYAN, COLOR_BLACK ); 13 | init_pair( 6, COLOR_MAGENTA, COLOR_BLACK ); 14 | init_pair( 7, COLOR_YELLOW, COLOR_BLACK ); 15 | 16 | // Inverted Colors 17 | init_pair( 8, COLOR_BLACK, COLOR_WHITE ); 18 | init_pair( 9, COLOR_BLACK, COLOR_RED ); 19 | init_pair(10, COLOR_BLACK, COLOR_GREEN ); 20 | init_pair(11, COLOR_BLACK, COLOR_BLUE ); 21 | init_pair(12, COLOR_BLACK, COLOR_CYAN ); 22 | init_pair(13, COLOR_BLACK, COLOR_MAGENTA); 23 | init_pair(14, COLOR_BLACK, COLOR_YELLOW ); 24 | 25 | // Highlighted - blue background 26 | init_pair(15, COLOR_WHITE, HILIGHT); 27 | init_pair(16, COLOR_RED, HILIGHT); 28 | init_pair(17, COLOR_GREEN, HILIGHT); 29 | init_pair(18, COLOR_BLUE, HILIGHT); 30 | init_pair(19, COLOR_CYAN, HILIGHT); 31 | init_pair(20, COLOR_BLACK, HILIGHT); 32 | init_pair(21, COLOR_MAGENTA, HILIGHT); 33 | init_pair(22, COLOR_YELLOW, HILIGHT); 34 | 35 | // Red background - for monsters on fire 36 | init_pair(23, COLOR_WHITE, COLOR_RED); 37 | init_pair(24, COLOR_RED, COLOR_RED); 38 | init_pair(25, COLOR_GREEN, COLOR_RED); 39 | init_pair(26, COLOR_BLUE, COLOR_RED); 40 | init_pair(27, COLOR_CYAN, COLOR_RED); 41 | init_pair(28, COLOR_MAGENTA, COLOR_RED); 42 | init_pair(29, COLOR_YELLOW, COLOR_RED); 43 | 44 | init_pair(30, COLOR_BLACK, COLOR_BLACK ); 45 | } 46 | 47 | int color_to_int(nc_color col) 48 | { 49 | switch (col) { 50 | case c_black : return 0; 51 | case c_white : return 1; 52 | case c_ltgray : return 2; 53 | case c_dkgray : return 3; 54 | case c_red : return 4; 55 | case c_green : return 5; 56 | case c_blue : return 6; 57 | case c_cyan : return 7; 58 | case c_magenta: return 8; 59 | case c_brown : return 9; 60 | case c_ltred : return 10; 61 | case c_ltgreen: return 11; 62 | case c_ltblue : return 12; 63 | case c_ltcyan : return 13; 64 | case c_pink : return 14; 65 | case c_yellow : return 15; 66 | 67 | case h_black : return 16; 68 | case h_white : return 17; 69 | case h_ltgray : return 18; 70 | case h_dkgray : return 19; 71 | case h_red : return 20; 72 | case h_green : return 21; 73 | case h_cyan : return 23; 74 | case h_magenta: return 24; 75 | case h_brown : return 25; 76 | case h_ltred : return 26; 77 | case h_ltgreen: return 27; 78 | case h_ltblue : return 28; 79 | case h_ltcyan : return 29; 80 | case h_pink : return 30; 81 | case h_yellow : return 31; 82 | 83 | case i_white : return 33; 84 | case i_ltgray : return 34; 85 | case i_dkgray : return 35; 86 | case i_red : return 36; 87 | case i_green : return 37; 88 | case i_blue : return 38; 89 | case i_cyan : return 39; 90 | case i_magenta: return 40; 91 | case i_brown : return 41; 92 | case i_ltred : return 42; 93 | case i_ltgreen: return 43; 94 | case i_ltblue : return 44; 95 | case i_ltcyan : return 45; 96 | case i_pink : return 46; 97 | case i_yellow : return 47; 98 | 99 | case c_white_red : return 48; 100 | case c_ltgray_red : return 49; 101 | case c_green_red : return 52; 102 | case c_blue_red : return 53; 103 | case c_cyan_red : return 54; 104 | case c_magenta_red: return 55; 105 | case c_brown_red : return 56; 106 | case c_ltred_red : return 57; 107 | case c_ltgreen_red: return 58; 108 | case c_ltblue_red : return 59; 109 | case c_ltcyan_red : return 60; 110 | case c_pink_red : return 61; 111 | case c_yellow_red : return 62; 112 | 113 | } 114 | return 0; 115 | } 116 | 117 | nc_color int_to_color(int key) 118 | { 119 | switch (key) { 120 | case 0: return c_black ; 121 | case 1: return c_white ; 122 | case 2: return c_ltgray ; 123 | case 3: return c_dkgray ; 124 | case 4: return c_red ; 125 | case 5: return c_green ; 126 | case 6: return c_blue ; 127 | case 7: return c_cyan ; 128 | case 8: return c_magenta; 129 | case 9: return c_brown ; 130 | case 10: return c_ltred ; 131 | case 11: return c_ltgreen; 132 | case 12: return c_ltblue ; 133 | case 13: return c_ltcyan ; 134 | case 14: return c_pink ; 135 | case 15: return c_yellow ; 136 | 137 | case 16: return h_black ; 138 | case 17: return h_white ; 139 | case 18: return h_ltgray ; 140 | case 19: return h_dkgray ; 141 | case 20: return h_red ; 142 | case 21: return h_green ; 143 | case 22: return h_blue ; 144 | case 23: return h_cyan ; 145 | case 24: return h_magenta; 146 | case 25: return h_brown ; 147 | case 26: return h_ltred ; 148 | case 27: return h_ltgreen; 149 | case 28: return h_ltblue ; 150 | case 29: return h_ltcyan ; 151 | case 30: return h_pink ; 152 | case 31: return h_yellow ; 153 | 154 | case 32: return i_black ; 155 | case 33: return i_white ; 156 | case 34: return i_ltgray ; 157 | case 35: return i_dkgray ; 158 | case 36: return i_red ; 159 | case 37: return i_green ; 160 | case 38: return i_blue ; 161 | case 39: return i_cyan ; 162 | case 40: return i_magenta; 163 | case 41: return i_brown ; 164 | case 42: return i_ltred ; 165 | case 43: return i_ltgreen; 166 | case 44: return i_ltblue ; 167 | case 45: return i_ltcyan ; 168 | case 46: return i_pink ; 169 | case 47: return i_yellow ; 170 | 171 | case 48: return c_white_red ; 172 | case 49: return c_ltgray_red ; 173 | case 50: return c_dkgray_red ; 174 | case 51: return c_red_red ; 175 | case 52: return c_green_red ; 176 | case 53: return c_blue_red ; 177 | case 54: return c_cyan_red ; 178 | case 55: return c_magenta_red; 179 | case 56: return c_brown_red ; 180 | case 57: return c_ltred_red ; 181 | case 58: return c_ltgreen_red; 182 | case 59: return c_ltblue_red ; 183 | case 60: return c_ltcyan_red ; 184 | case 61: return c_pink_red ; 185 | case 62: return c_yellow_red ; 186 | } 187 | return c_black; 188 | } 189 | -------------------------------------------------------------------------------- /color.h: -------------------------------------------------------------------------------- 1 | #ifndef _COLOR_H_ 2 | #define _COLOR_H 3 | 4 | #if (defined _WIN32 || defined WINDOWS) 5 | #include "catacurse.h" 6 | #else 7 | #include 8 | #endif 9 | 10 | #ifndef _COLOR_LIST_ 11 | #define _COLOR_LIST_ 12 | 13 | void init_colors(); 14 | 15 | enum col_attribute { 16 | WA_NULL = 0, 17 | HI = 1, 18 | INV = 2 19 | }; 20 | 21 | enum nc_color { 22 | c_black = COLOR_PAIR(30), 23 | c_white = COLOR_PAIR(1) | A_BOLD, 24 | c_ltgray = COLOR_PAIR(1), 25 | c_dkgray = COLOR_PAIR(30) | A_BOLD, 26 | c_red = COLOR_PAIR(2), 27 | c_green = COLOR_PAIR(3), 28 | c_blue = COLOR_PAIR(4), 29 | c_cyan = COLOR_PAIR(5), 30 | c_magenta = COLOR_PAIR(6), 31 | c_brown = COLOR_PAIR(7), 32 | c_ltred = COLOR_PAIR(2) | A_BOLD, 33 | c_ltgreen = COLOR_PAIR(3) | A_BOLD, 34 | c_ltblue = COLOR_PAIR(4) | A_BOLD, 35 | c_ltcyan = COLOR_PAIR(5) | A_BOLD, 36 | c_pink = COLOR_PAIR(6) | A_BOLD, 37 | c_yellow = COLOR_PAIR(7) | A_BOLD, 38 | 39 | h_black = COLOR_PAIR(20), 40 | h_white = COLOR_PAIR(15) | A_BOLD, 41 | h_ltgray = COLOR_PAIR(15), 42 | h_dkgray = COLOR_PAIR(20) | A_BOLD, 43 | h_red = COLOR_PAIR(16), 44 | h_green = COLOR_PAIR(17), 45 | h_blue = COLOR_PAIR(20), 46 | h_cyan = COLOR_PAIR(19), 47 | h_magenta = COLOR_PAIR(21), 48 | h_brown = COLOR_PAIR(22), 49 | h_ltred = COLOR_PAIR(16) | A_BOLD, 50 | h_ltgreen = COLOR_PAIR(17) | A_BOLD, 51 | h_ltblue = COLOR_PAIR(18) | A_BOLD, 52 | h_ltcyan = COLOR_PAIR(19) | A_BOLD, 53 | h_pink = COLOR_PAIR(21) | A_BOLD, 54 | h_yellow = COLOR_PAIR(22) | A_BOLD, 55 | 56 | i_black = COLOR_PAIR(30), 57 | i_white = COLOR_PAIR(8) | A_BLINK, 58 | i_ltgray = COLOR_PAIR(8), 59 | i_dkgray = COLOR_PAIR(30) | A_BLINK, 60 | i_red = COLOR_PAIR(9), 61 | i_green = COLOR_PAIR(10), 62 | i_blue = COLOR_PAIR(11), 63 | i_cyan = COLOR_PAIR(12), 64 | i_magenta = COLOR_PAIR(13), 65 | i_brown = COLOR_PAIR(14), 66 | i_ltred = COLOR_PAIR(9) | A_BLINK, 67 | i_ltgreen = COLOR_PAIR(10) | A_BLINK, 68 | i_ltblue = COLOR_PAIR(11) | A_BLINK, 69 | i_ltcyan = COLOR_PAIR(12) | A_BLINK, 70 | i_pink = COLOR_PAIR(13) | A_BLINK, 71 | i_yellow = COLOR_PAIR(14) | A_BLINK, 72 | 73 | c_white_red = COLOR_PAIR(23) | A_BOLD, 74 | c_ltgray_red = COLOR_PAIR(23), 75 | c_dkgray_red = COLOR_PAIR(9), 76 | c_red_red = COLOR_PAIR(9), 77 | c_green_red = COLOR_PAIR(25), 78 | c_blue_red = COLOR_PAIR(26), 79 | c_cyan_red = COLOR_PAIR(27), 80 | c_magenta_red = COLOR_PAIR(28), 81 | c_brown_red = COLOR_PAIR(29), 82 | c_ltred_red = COLOR_PAIR(24) | A_BOLD, 83 | c_ltgreen_red = COLOR_PAIR(25) | A_BOLD, 84 | c_ltblue_red = COLOR_PAIR(26) | A_BOLD, 85 | c_ltcyan_red = COLOR_PAIR(27) | A_BOLD, 86 | c_pink_red = COLOR_PAIR(28) | A_BOLD, 87 | c_yellow_red = COLOR_PAIR(29) | A_BOLD 88 | 89 | }; 90 | 91 | int color_to_int(nc_color col); 92 | nc_color int_to_color(int key); 93 | 94 | void setattr(nc_color &col, col_attribute attr); 95 | 96 | #endif 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /computer.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMPUTER_H_ 2 | #define _COMPUTER_H_ 3 | 4 | //#include "texthash.h" 5 | #include "output.h" 6 | #include 7 | #include 8 | 9 | #define DEFAULT_COMPUTER_NAME "" 10 | 11 | class game; 12 | class player; 13 | 14 | enum computer_action 15 | { 16 | COMPACT_NULL = 0, 17 | COMPACT_OPEN, 18 | COMPACT_SAMPLE, 19 | COMPACT_RELEASE, 20 | COMPACT_TERMINATE, 21 | COMPACT_PORTAL, 22 | COMPACT_CASCADE, 23 | COMPACT_RESEARCH, 24 | COMPACT_MAPS, 25 | COMPACT_MAP_SEWER, 26 | COMPACT_MISS_LAUNCH, 27 | COMPACT_MISS_DISARM, 28 | COMPACT_LIST_BIONICS, 29 | COMPACT_ELEVATOR_ON, 30 | COMPACT_AMIGARA_LOG, 31 | COMPACT_AMIGARA_START, 32 | COMPACT_DOWNLOAD_SOFTWARE, 33 | COMPACT_BLOOD_ANAL, 34 | NUM_COMPUTER_ACTIONS 35 | }; 36 | 37 | enum computer_failure 38 | { 39 | COMPFAIL_NULL = 0, 40 | COMPFAIL_SHUTDOWN, 41 | COMPFAIL_ALARM, 42 | COMPFAIL_MANHACKS, 43 | COMPFAIL_SECUBOTS, 44 | COMPFAIL_DAMAGE, 45 | COMPFAIL_PUMP_EXPLODE, 46 | COMPFAIL_PUMP_LEAK, 47 | COMPFAIL_AMIGARA, 48 | COMPFAIL_DESTROY_BLOOD, 49 | NUM_COMPUTER_FAILURES 50 | }; 51 | 52 | struct computer_option 53 | { 54 | std::string name; 55 | computer_action action; 56 | int security; 57 | 58 | computer_option() { name = "Unknown", action = COMPACT_NULL, security = 0; }; 59 | computer_option(std::string N, computer_action A, int S) : 60 | name (N), action (A), security (S) {}; 61 | }; 62 | 63 | class computer 64 | { 65 | public: 66 | computer(); 67 | computer(std::string Name, int Security); 68 | ~computer(); 69 | 70 | computer & operator=(const computer &rhs); 71 | // Initialization 72 | void set_security(int Security); 73 | void add_option(std::string opt_name, computer_action action, int Security); 74 | void add_failure(computer_failure failure); 75 | // Basic usage 76 | void shutdown_terminal(); // Shutdown (free w_terminal, etc) 77 | void use(game *g); 78 | bool hack_attempt(player *p, int Security = -1);// -1 defaults to main security 79 | // Save/load 80 | std::string save_data(); 81 | void load_data(std::string data); 82 | 83 | std::string name; // "Jon's Computer", "Lab 6E77-B Terminal Omega" 84 | int mission_id; // Linked to a mission? 85 | 86 | private: 87 | int security; // Difficulty of simply logging in 88 | std::vector options; // Things we can do 89 | std::vector failures; // Things that happen if we fail a hack 90 | WINDOW *w_terminal; // Output window 91 | 92 | // Called by use() 93 | void activate_function (game *g, computer_action action); 94 | // Generally called when we fail a hack attempt 95 | void activate_random_failure(game *g); 96 | // ...but we can also choose a specific failure. 97 | void activate_failure (game *g, computer_failure fail); 98 | 99 | // OUTPUT/INPUT 100 | // Reset to a blank terminal (e.g. at start of usage loop) 101 | void reset_terminal(); 102 | // Prints a line to the terminal (with printf flags) 103 | void print_line(const char *text, ...); 104 | // For now, the same as print_line but in red (TODO: change this?) 105 | void print_error(const char *text, ...); 106 | // Prints code-looking gibberish 107 | void print_gibberish_line(); 108 | // Prints a line and waits for Y/N/Q 109 | char query_ynq(const char *text, ...); 110 | // Same as query_ynq, but returns true for y or Y 111 | bool query_bool(const char *text, ...); 112 | }; 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /construction.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "crafting.h" 4 | 5 | struct construct; 6 | 7 | struct construction_stage 8 | { 9 | ter_id terrain; 10 | int time; // In minutes, i.e. 10 turns 11 | std::vector tools[3]; 12 | std::vector components[3]; 13 | 14 | construction_stage(ter_id Terrain, int Time) : 15 | terrain (Terrain), time (Time) { }; 16 | }; 17 | 18 | struct constructable 19 | { 20 | int id; 21 | std::string name; // Name as displayed 22 | int difficulty; // Carpentry skill level required 23 | std::vector stages; 24 | bool (construct::*able) (game *, point); 25 | void (construct::*done) (game *, point); 26 | 27 | constructable(int Id, std::string Name, int Diff, 28 | bool (construct::*Able) (game *, point), 29 | void (construct::*Done) (game *, point)) : 30 | id (Id), name (Name), difficulty (Diff), able (Able), done (Done) {}; 31 | }; 32 | 33 | struct construct // Construction functions. 34 | { 35 | // Bools - able to build at the given point? 36 | bool able_always(game *, point) { return true; } 37 | bool able_never (game *, point) { return false; } 38 | 39 | bool able_empty (game *, point); // Able if tile is empty 40 | 41 | bool able_window(game *, point); // Any window tile 42 | bool able_window_pane(game *, point); // Only intact windows 43 | bool able_broken_window(game *, point); // Able if tile is broken window 44 | 45 | bool able_door(game *, point); // Any door tile 46 | bool able_door_broken(game *, point); // Broken door 47 | 48 | bool able_wall (game *, point); // Able if tile is wall 49 | bool able_wall_wood(game *g, point); // Only player-built walls 50 | 51 | bool able_between_walls(game *, point); // Flood-fill contained by walls 52 | 53 | bool able_dig(game *, point); // Able if diggable terrain 54 | bool able_pit(game *, point); // Able only on pits 55 | 56 | bool able_tree(game *, point); // Able on trees 57 | bool able_log(game *, point); // Able on logs 58 | 59 | // Does anything special happen when we're finished? 60 | void done_nothing(game *, point) { } 61 | void done_window_pane(game *, point); 62 | void done_vehicle(game *, point); 63 | void done_tree(game *, point); 64 | void done_log(game *, point); 65 | 66 | }; 67 | -------------------------------------------------------------------------------- /crafting.h: -------------------------------------------------------------------------------- 1 | #ifndef _CRAFTING_H_ 2 | #define _CRAFTING_H_ 3 | 4 | #include 5 | #include 6 | #include "itype.h" 7 | #include "skill.h" 8 | #include "rng.h" 9 | 10 | enum craft_cat { 11 | CC_NULL = 0, 12 | CC_WEAPON, 13 | CC_FOOD, 14 | CC_ELECTRONIC, 15 | CC_ARMOR, 16 | CC_MISC, 17 | NUM_CC 18 | }; 19 | 20 | struct component 21 | { 22 | itype_id type; 23 | int count; 24 | component() { type = itm_null; count = 0; } 25 | component(itype_id TYPE, int COUNT) : type (TYPE), count (COUNT) {} 26 | }; 27 | 28 | struct recipe 29 | { 30 | int id; 31 | itype_id result; 32 | craft_cat category; 33 | skill sk_primary; 34 | skill sk_secondary; 35 | int difficulty; 36 | int time; 37 | 38 | std::vector tools[5]; 39 | std::vector components[5]; 40 | 41 | recipe() { id = 0; result = itm_null; category = CC_NULL; sk_primary = sk_null; 42 | sk_secondary = sk_null; difficulty = 0; time = 0; } 43 | recipe(int pid, itype_id pres, craft_cat cat, skill p1, skill p2, int pdiff, 44 | int ptime) : 45 | id (pid), result (pres), category (cat), sk_primary (p1), sk_secondary (p2), 46 | difficulty (pdiff), time (ptime) {} 47 | }; 48 | 49 | void consume_items(game *g, std::vector components); 50 | void consume_tools(game *g, std::vector tools); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /data/FONTDATA: -------------------------------------------------------------------------------- 1 | Terminus 2 | 8 3 | 16 -------------------------------------------------------------------------------- /data/NAMES_FEMALE: -------------------------------------------------------------------------------- 1 | Emma 2 | Isabella 3 | Emily 4 | Madison 5 | Ava 6 | Olivia 7 | Sophie 8 | Abigail 9 | Elizabeth 10 | Chloe 11 | Samantha 12 | Addison 13 | Natalie 14 | Mia 15 | Alexis 16 | Alyssa 17 | Hannah 18 | Ashley 19 | Ella 20 | Sarah 21 | Grace 22 | Brianna 23 | Lily 24 | Hailey 25 | Anna 26 | Victoria 27 | Kayla 28 | Lillian 29 | Lauren 30 | Kaylee 31 | Allison 32 | Savannah 33 | Nevaeh 34 | Gabriella 35 | Sofia 36 | Makayla 37 | Avery 38 | Riley 39 | Julia 40 | Leah 41 | Aubrey 42 | Jasmine 43 | Audrey 44 | Katie 45 | Morgan 46 | Brooklyn 47 | Destiny 48 | Sydney 49 | Alexa 50 | Kylie 51 | Brooke 52 | Kaitlin 53 | Evelyn 54 | Layla 55 | Madeline 56 | Kimberly 57 | Kim 58 | Zoe 59 | Jessica 60 | Jessie 61 | Alexandra 62 | Claire 63 | Madelyn 64 | Maria 65 | Arianna 66 | Jocelyn 67 | Amelia 68 | Angelina 69 | Trinity 70 | Andrea 71 | Maya 72 | Valeria 73 | Sophie 74 | Rachel 75 | Vanessa 76 | Aaliyah 77 | Mariah 78 | Gabrielle 79 | Katelyn 80 | Ariana 81 | Bailey 82 | Camilla 83 | Jennifer 84 | Jen 85 | Melanie 86 | Gianna 87 | Charlotte 88 | Paige 89 | Autumn 90 | Payton 91 | Faith 92 | Sara 93 | Isabelle 94 | Caroline 95 | Genesis 96 | Isabel 97 | Mary 98 | Zoey 99 | Gracie 100 | Megan 101 | -------------------------------------------------------------------------------- /data/NAMES_LAST: -------------------------------------------------------------------------------- 1 | Smith 2 | Johnson 3 | Williams 4 | Jones 5 | Brown 6 | Davis 7 | Miller 8 | Wilson 9 | Moore 10 | Taylor 11 | Anderson 12 | Thomas 13 | Jackson 14 | White 15 | Harris 16 | Martin 17 | Thompson 18 | Garcia 19 | Martinez 20 | Robinson 21 | Clark 22 | Rodriguez 23 | Lewis 24 | Lee 25 | Walker 26 | Hall 27 | Allen 28 | Young 29 | Hernandez 30 | King 31 | Wright 32 | Lopez 33 | Hill 34 | Scott 35 | Green 36 | Adams 37 | Baker 38 | Gonzalez 39 | Nelson 40 | Carter 41 | Mitchell 42 | Perez 43 | Roberts 44 | Turner 45 | Phillips 46 | Campbell 47 | Parker 48 | Evans 49 | Edwards 50 | Collins 51 | Stewart 52 | Sanchez 53 | Morris 54 | Rogers 55 | Reed 56 | Cook 57 | Morgan 58 | Bell 59 | Murphy 60 | Bailey 61 | Rivera 62 | Cooper 63 | Richardson 64 | Cox 65 | Howard 66 | Ward 67 | Torres 68 | Peterson 69 | Gray 70 | Ramirez 71 | James 72 | Watson 73 | Brooks 74 | Kelly 75 | Sanders 76 | Price 77 | Bennett 78 | Wood 79 | Barnes 80 | Ross 81 | Henderson 82 | Coleman 83 | Jenkins 84 | Perry 85 | Powell 86 | Long 87 | Patterson 88 | Hughes 89 | Flores 90 | Washington 91 | Butler 92 | Simmons 93 | Foster 94 | Gonzales 95 | Bryant 96 | Alexander 97 | Russell 98 | Griffin 99 | Diaz 100 | Hayes 101 | -------------------------------------------------------------------------------- /data/NAMES_MALE: -------------------------------------------------------------------------------- 1 | Jacob 2 | Michael 3 | Ethan 4 | Joshua 5 | Daniel 6 | Alexander 7 | Anthony 8 | William 9 | Christopher 10 | Matthew 11 | Jayden 12 | Andrew 13 | Joseph 14 | David 15 | Noah 16 | Aiden 17 | James 18 | Ryan 19 | Logan 20 | John 21 | Nathan 22 | Elijah 23 | Christian 24 | Gabriel 25 | Benjamin 26 | Jonathan 27 | Tyler 28 | Samuel 29 | Nicholas 30 | Gavin 31 | Dylan 32 | Jackson 33 | Brandon 34 | Caleb 35 | Mason 36 | Angel 37 | Isaac 38 | Evan 39 | Jack 40 | Kevin 41 | Jose 42 | Isaiah 43 | Luke 44 | Landon 45 | Justin 46 | Lucas 47 | Zachary 48 | Jordan 49 | Robert 50 | Aaron 51 | Brayden 52 | Thomas 53 | Cameron 54 | Hunter 55 | Austin 56 | Adrian 57 | Connor 58 | Owen 59 | Aidan 60 | Jason 61 | Julian 62 | Wyatt 63 | Charles 64 | Luis 65 | Carter 66 | Juan 67 | Chase 68 | Diego 69 | Jeremiah 70 | Brody 71 | Xavier 72 | Adam 73 | Carlos 74 | Sabastian 75 | Liam 76 | Hayden 77 | Nathaniel 78 | Henry 79 | Jesus 80 | Ian 81 | Tristan 82 | Bryan 83 | Sean 84 | Cole 85 | Alex 86 | Eric 87 | Brian 88 | Jaden 89 | Carson 90 | Blake 91 | Ayden 92 | Cooper 93 | Dominic 94 | Brady 95 | Caden 96 | Josiah 97 | Kyle 98 | Colton 99 | Kaden 100 | Eli 101 | -------------------------------------------------------------------------------- /data/motd: -------------------------------------------------------------------------------- 1 | # This message may be 16 lines long at maximum. 2 | # Max length of a line is 64 characters; the following line is for reference 3 | ################################################################ 4 | The game now has configurable options. 5 | You can directly edit options.txt in the data directory, or you 6 | can edit the options via the help menu. 7 | 8 | If options.txt is missing, the game will create it for you. 9 | 10 | Check out the options listing by pressing ?2 11 | 12 | As always, please visit the forums at: 13 | http://whalesdev.com/forums/index.php 14 | -------------------------------------------------------------------------------- /data/termfont: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Whales/Cataclysm/f9b2b248ddef348090aef5a4743c00b2a44281b5/data/termfont -------------------------------------------------------------------------------- /enums.h: -------------------------------------------------------------------------------- 1 | #ifndef _ENUMS_H_ 2 | #define _ENUMS_H_ 3 | 4 | #ifndef sgn 5 | #define sgn(x) (((x) < 0) ? -1 : 1) 6 | #endif 7 | 8 | enum material { 9 | MNULL = 0, 10 | //Food Materials 11 | LIQUID, VEGGY, FLESH, POWDER, 12 | //Clothing 13 | COTTON, WOOL, LEATHER, KEVLAR, 14 | //Other 15 | STONE, PAPER, WOOD, PLASTIC, GLASS, IRON, STEEL, SILVER 16 | }; 17 | 18 | struct point { 19 | int x; 20 | int y; 21 | point(int X = 0, int Y = 0) : x (X), y (Y) {} 22 | point(const point &p) : x (p.x), y (p.y) {} 23 | ~point(){} 24 | }; 25 | 26 | struct tripoint { 27 | int x; 28 | int y; 29 | int z; 30 | tripoint(int X = 0, int Y = 0, int Z = 0) : x (X), y (Y), z (Z) {} 31 | tripoint(const tripoint &p) : x (p.x), y (p.y), z (p.z) {} 32 | ~tripoint(){} 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /event.h: -------------------------------------------------------------------------------- 1 | #ifndef _EVENT_H_ 2 | #define _EVENT_H_ 3 | 4 | #include "faction.h" 5 | #include "line.h" 6 | 7 | class game; 8 | 9 | enum event_type { 10 | EVENT_NULL, 11 | EVENT_HELP, 12 | EVENT_WANTED, 13 | EVENT_ROBOT_ATTACK, 14 | EVENT_SPAWN_WYRMS, 15 | EVENT_AMIGARA, 16 | EVENT_ROOTS_DIE, 17 | EVENT_TEMPLE_OPEN, 18 | EVENT_TEMPLE_FLOOD, 19 | EVENT_TEMPLE_SPAWN, 20 | EVENT_DIM, 21 | EVENT_ARTIFACT_LIGHT, 22 | NUM_EVENT_TYPES 23 | }; 24 | 25 | struct event { 26 | event_type type; 27 | int turn; 28 | int faction_id; 29 | point map_point; 30 | 31 | event() { 32 | type = EVENT_NULL; 33 | turn = 0; 34 | faction_id = -1; 35 | map_point.x = -1; 36 | map_point.y = -1; 37 | } 38 | 39 | event(event_type e_t, int t, int f_id, int x, int y) { 40 | type = e_t; 41 | turn = t; 42 | faction_id = f_id; 43 | map_point.x = x; 44 | map_point.y = y; 45 | } 46 | 47 | void actualize(game *g); // When the time runs out 48 | void per_turn(game *g); // Every turn 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /facdata.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string faction_adj_pos[15] = { 4 | "Shining", "Sacred", "Golden", "Holy", "Righteous", "Devoted", "Virtuous", 5 | "Splendid", "Divine", "Radiant", "Noble", "Venerable", "Immaculate" 6 | "Heroic", "Bright"}; 7 | 8 | std::string faction_adj_neu[15] = { 9 | "Original", "Crystal", "Metal", "Mighty", "Powerful", "Solid", "Stone", 10 | "Firey", "Colossal", "Famous", "Supreme", "Invincible", "Unlimited", 11 | "Great", "Electric"}; 12 | 13 | std::string faction_adj_bad[15] = { 14 | "Poisonous", "Deadly", "Foul", "Nefarious", "Wicked", "Vile", "Ruinous", 15 | "Horror", "Devastating", "Vicious", "Sinister", "Baleful", "Pestilent", 16 | "Pernicious", "Dread"}; 17 | 18 | std::string faction_noun_strong[15] = { 19 | "Fists", "Slayers", "Furies", "Dervishes", "Tigers", "Destroyers", 20 | "Berserkers", "Samurai", "Valkyries", "Army", "Killers", "Paladins", 21 | "Knights", "Warriors", "Huntsmen"}; 22 | 23 | std::string faction_noun_sneak[15] = { 24 | "Snakes", "Rats", "Assassins", "Ninja", "Agents", "Shadows", "Guerillas", 25 | "Eliminators", "Snipers", "Smoke", "Arachnids", "Creepers", "Shade", 26 | "Stalkers", "Eels"}; 27 | 28 | std::string faction_noun_crime[15] = { 29 | "Bandits", "Punks", "Family", "Mafia", "Mob", "Gang", "Vandals", "Sharks", 30 | "Muggers", "Cutthroats", "Guild", "Faction", "Thugs", "Racket", "Crooks"}; 31 | 32 | std::string faction_noun_cult[15] = { 33 | "Brotherhood", "Church", "Ones", "Crucible", "Sect", "Creed", "Doctrine", 34 | "Priests", "Tenet", "Monks", "Clerics", "Pastors", "Gnostics", "Elders", 35 | "Inquisitors"}; 36 | 37 | std::string faction_noun_none[15] = { 38 | "Settlers", "People", "Men", "Faction", "Tribe", "Clan", "Society", "Folk", 39 | "Nation", "Republic", "Colony", "State", "Kingdom", "Party", "Company"}; 40 | 41 | 42 | struct faction_value_datum { 43 | std::string name; 44 | int good; // A measure of how "good" the value is (naming purposes &c) 45 | int strength; 46 | int sneak; 47 | int crime; 48 | int cult; 49 | }; 50 | 51 | faction_value_datum facgoal_data[NUM_FACGOALS] = { 52 | // "Their ultimate goal is " 53 | //Name Good Str Sneak Crime Cult 54 | {"Null", 0, 0, 0, 0, 0}, 55 | {"basic survival", 0, 0, 0, 0, 0}, 56 | {"financial wealth", 0, -1, 0, 2, -1}, 57 | {"dominance of the region", -1, 1, -1, 1, -1}, 58 | {"the extermination of monsters",1, 3, -1, -1, -1}, 59 | {"contact with unseen powers", -1, 0, 1, 0, 4}, 60 | {"bringing the apocalypse", -5, 1, 2, 0, 7}, 61 | {"general chaos and anarchy", -3, 2, -3, 2, -1}, 62 | {"the cultivation of knowledge", 2, -3, 2, -1, 0}, 63 | {"harmony with nature", 2, -2, 0, -1, 2}, 64 | {"rebuilding civilization", 2, 1, -2, -2, -4}, 65 | {"spreading the fungus", -2, 1, 1, 0, 4} 66 | }; 67 | // TOTAL: -5 3 -2 0 7 68 | 69 | faction_value_datum facjob_data[NUM_FACJOBS] = { 70 | // "They earn money via " 71 | //Name Good Str Sneak Crime Cult 72 | {"Null", 0, 0, 0, 0, 0}, 73 | {"protection rackets", -3, 2, -1, 4, 0}, 74 | {"the sale of information", -1, -1, 4, 1, 0}, 75 | {"their bustling trade centers", 1, -1, -2, -4, -4}, 76 | {"trade caravans", 2, -1, -1, -3, -2}, 77 | {"scavenging supplies", 0, -1, 0, -1, -1}, 78 | {"mercenary work", 0, 3, -1, 1, -1}, 79 | {"assassinations", -1, 2, 2, 1, 1}, 80 | {"raiding settlements", -4, 4, -3, 3, -2}, 81 | {"the theft of property", -3, -1, 4, 4, 1}, 82 | {"gambling parlors", -1, -2, -1, 1, -1}, 83 | {"medical aid", 4, -3, -2, -3, 0}, 84 | {"farming & selling food", 3, -4, -2, -4, 1}, 85 | {"drug dealing", -2, 0, -1, 2, 0}, 86 | {"selling manufactured goods", 1, 0, -1, -2, 0} 87 | }; 88 | // TOTAL: -5 -3 -5 0 -6 89 | 90 | faction_value_datum facval_data[NUM_FACVALS] = { 91 | // "They are known for " 92 | //Name Good Str Sneak Crime Cult 93 | {"Null", 0, 0, 0, 0, 0}, 94 | {"their charitable nature", 5, -1, -1, -2, -2}, 95 | {"their isolationism", 0, -2, 1, 0, 2}, 96 | {"exploring extensively", 1, 0, 0, -1, -1}, 97 | {"collecting rare artifacts", 0, 1, 1, 0, 3}, 98 | {"their knowledge of bionics", 1, 2, 0, 0, 0}, 99 | {"their libraries", 1, -3, 0, -2, 1}, 100 | {"their elite training", 0, 4, 2, 0, 2}, 101 | {"their robotics factories", 0, 3, -1, 0, -2}, 102 | {"treachery", -3, 0, 1, 3, 0}, 103 | {"the avoidance of drugs", 1, 0, 0, -1, 1}, 104 | {"their adherance to the law", 2, -1, -1, -4, -1}, 105 | {"their cruelty", -3, 1, -1, 4, 1} 106 | }; 107 | // TOTALS: 5 4 1 -3 4 108 | /* Note: It's nice to keep the totals around 0 for Good, and about even for the 109 | * other four. It's okay if Good is slightly negative (after all, in a post- 110 | * apocalyptic world people might be a LITTLE less virtuous), and to keep 111 | * strength valued a bit higher than the others. 112 | */ 113 | 114 | -------------------------------------------------------------------------------- /faction.h: -------------------------------------------------------------------------------- 1 | #ifndef _FACTION_H_ 2 | #define _FACTION_H_ 3 | 4 | #include 5 | #include 6 | 7 | // TODO: Redefine? 8 | #define MAX_FAC_NAME_SIZE 40 9 | 10 | #ifndef mfb 11 | #define mfb(n) long(1 << (n)) 12 | #endif 13 | 14 | std::string fac_ranking_text(int val); 15 | std::string fac_respect_text(int val); 16 | 17 | class game; 18 | 19 | enum faction_goal { 20 | FACGOAL_NULL = 0, 21 | FACGOAL_NONE, 22 | FACGOAL_WEALTH, 23 | FACGOAL_DOMINANCE, 24 | FACGOAL_CLEANSE, 25 | FACGOAL_SHADOW, 26 | FACGOAL_APOCALYPSE, 27 | FACGOAL_ANARCHY, 28 | FACGOAL_KNOWLEDGE, 29 | FACGOAL_NATURE, 30 | FACGOAL_CIVILIZATION, 31 | FACGOAL_FUNGUS, 32 | NUM_FACGOALS 33 | }; 34 | 35 | enum faction_job { 36 | FACJOB_NULL = 0, 37 | FACJOB_EXTORTION, // Protection rackets, etc 38 | FACJOB_INFORMATION, // Gathering & sale of information 39 | FACJOB_TRADE, // Bazaars, etc. 40 | FACJOB_CARAVANS, // Transportation of goods 41 | FACJOB_SCAVENGE, // Scavenging & sale of general supplies 42 | FACJOB_MERCENARIES, // General fighters-for-hire 43 | FACJOB_ASSASSINS, // Targeted discreet killing 44 | FACJOB_RAIDERS, // Raiding settlements, trade routes, &c 45 | FACJOB_THIEVES, // Less violent; theft of property without killing 46 | FACJOB_GAMBLING, // Maitenance of gambling parlors 47 | FACJOB_DOCTORS, // Doctors for hire 48 | FACJOB_FARMERS, // Farming & sale of food 49 | FACJOB_DRUGS, // Drug dealing 50 | FACJOB_MANUFACTURE, // Manufacturing & selling goods 51 | NUM_FACJOBS 52 | }; 53 | 54 | enum faction_value { 55 | FACVAL_NULL = 0, 56 | FACVAL_CHARITABLE, // Give their job for free (often) 57 | FACVAL_LONERS, // Avoid associating with outsiders 58 | FACVAL_EXPLORATION, // Like to explore new territory 59 | FACVAL_ARTIFACTS, // Seek out unique items 60 | FACVAL_BIONICS, // Collection & installation of bionic parts 61 | FACVAL_BOOKS, // Collection of books 62 | FACVAL_TRAINING, // Training among themselves and others 63 | FACVAL_ROBOTS, // Creation / use of robots 64 | FACVAL_TREACHERY, // Untrustworthy 65 | FACVAL_STRAIGHTEDGE, // No drugs, alcohol, etc. 66 | FACVAL_LAWFUL, // Abide by the old laws 67 | FACVAL_CRUELTY, // Torture, murder, etc. 68 | NUM_FACVALS 69 | }; 70 | 71 | 72 | struct faction { 73 | faction(); 74 | faction(int uid); 75 | ~faction(); 76 | 77 | std::string save_info(); 78 | void load_info(std::string data); 79 | 80 | void randomize(); 81 | void make_army(); 82 | bool has_job(faction_job j); 83 | bool has_value(faction_value v); 84 | bool matches_us(faction_value v); 85 | std::string describe(); 86 | 87 | int response_time(game *g); // Time it takes for them to get to u 88 | 89 | std::string name; 90 | unsigned values : NUM_FACVALS; // Bitfield of values 91 | faction_goal goal; 92 | faction_job job1, job2; 93 | std::vector opinion_of; 94 | int likes_u; 95 | int respects_u; 96 | bool known_by_u; 97 | int id; 98 | int strength, sneak, crime, cult, good; // Defining values 99 | int omx, omy; // Which overmap are we based in? 100 | int mapx, mapy;// Where in that overmap are we? 101 | int size; // How big is our sphere of influence? 102 | int power; // General measure of our power 103 | }; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /gamemode.cpp: -------------------------------------------------------------------------------- 1 | #include "gamemode.h" 2 | #include "output.h" 3 | 4 | std::string special_game_name(special_game_id id) 5 | { 6 | switch (id) { 7 | case SGAME_NULL: 8 | case NUM_SPECIAL_GAMES: return "nethack (this is a bug)"; 9 | case SGAME_TUTORIAL: return "Tutorial"; 10 | case SGAME_DEFENSE: return "Defense"; 11 | default: return "Uncoded (this is a bug)"; 12 | } 13 | } 14 | 15 | special_game* get_special_game(special_game_id id) 16 | { 17 | special_game* ret; 18 | switch (id) { 19 | case SGAME_NULL: 20 | ret = new special_game; 21 | break; 22 | case SGAME_TUTORIAL: 23 | ret = new tutorial_game; 24 | break; 25 | case SGAME_DEFENSE: 26 | ret = new defense_game; 27 | break; 28 | default: 29 | debugmsg("Missing something in get_special_game()?"); 30 | ret = new special_game; 31 | break; 32 | } 33 | 34 | return ret; 35 | } 36 | -------------------------------------------------------------------------------- /gamemode.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAMEMODE_H_ 2 | #define _GAMEMODE_H_ 3 | 4 | #include 5 | #include 6 | #include "action.h" 7 | #include "itype.h" 8 | #include "mtype.h" 9 | 10 | class game; 11 | struct special_game; 12 | 13 | enum special_game_id { 14 | SGAME_NULL = 0, 15 | SGAME_TUTORIAL, 16 | SGAME_DEFENSE, 17 | NUM_SPECIAL_GAMES 18 | }; 19 | 20 | std::string special_game_name(special_game_id id); 21 | special_game* get_special_game(special_game_id id); 22 | 23 | struct special_game 24 | { 25 | virtual special_game_id id() { return SGAME_NULL; }; 26 | // init is run when the game begins 27 | virtual bool init(game *g) { return true; }; 28 | // per_turn is run every turn--before any player actions 29 | virtual void per_turn(game *g) { }; 30 | // pre_action is run after a keypress, but before the game handles the action 31 | // It may modify the action, e.g. to cancel it 32 | virtual void pre_action(game *g, action_id &act) { }; 33 | // post_action is run after the game handles the action 34 | virtual void post_action(game *g, action_id act) { }; 35 | // game_over is run when the player dies (or the game otherwise ends) 36 | virtual void game_over(game *g) { }; 37 | 38 | }; 39 | 40 | // TUTORIAL: 41 | 42 | enum tut_lesson { 43 | LESSON_INTRO, 44 | LESSON_MOVE, LESSON_LOOK, LESSON_OPEN, LESSON_CLOSE, LESSON_SMASH, 45 | LESSON_WINDOW, LESSON_PICKUP, LESSON_EXAMINE, LESSON_INTERACT, 46 | 47 | LESSON_FULL_INV, LESSON_WIELD_NO_SPACE, LESSON_AUTOWIELD, LESSON_ITEM_INTO_INV, 48 | LESSON_GOT_ARMOR, LESSON_GOT_WEAPON, LESSON_GOT_FOOD, LESSON_GOT_TOOL, 49 | LESSON_GOT_GUN, LESSON_GOT_AMMO, LESSON_WORE_ARMOR, LESSON_WORE_STORAGE, 50 | LESSON_WORE_MASK, 51 | 52 | LESSON_WEAPON_INFO, LESSON_HIT_MONSTER, LESSON_PAIN, LESSON_BUTCHER, 53 | 54 | LESSON_TOOK_PAINKILLER, LESSON_TOOK_CIG, LESSON_DRANK_WATER, 55 | 56 | LESSON_ACT_GRENADE, LESSON_ACT_BUBBLEWRAP, 57 | 58 | LESSON_OVERLOADED, 59 | 60 | LESSON_GUN_LOAD, LESSON_GUN_FIRE, LESSON_RECOIL, 61 | 62 | LESSON_STAIRS, LESSON_DARK_NO_FLASH, LESSON_DARK, LESSON_PICKUP_WATER, 63 | 64 | NUM_LESSONS 65 | }; 66 | 67 | struct tutorial_game : public special_game 68 | { 69 | virtual special_game_id id() { return SGAME_TUTORIAL; }; 70 | virtual bool init(game *g); 71 | virtual void per_turn(game *g); 72 | virtual void pre_action(game *g, action_id &act); 73 | virtual void post_action(game *g, action_id act); 74 | virtual void game_over(game *g) { }; 75 | 76 | private: 77 | void add_message(game *g, tut_lesson lesson); 78 | 79 | bool tutorials_seen[NUM_LESSONS]; 80 | }; 81 | 82 | 83 | // DEFENSE 84 | 85 | enum defense_style { 86 | DEFENSE_CUSTOM = 0, 87 | DEFENSE_EASY, 88 | DEFENSE_MEDIUM, 89 | DEFENSE_HARD, 90 | DEFENSE_SHAUN, 91 | DEFENSE_DAWN, 92 | DEFENSE_SPIDERS, 93 | DEFENSE_TRIFFIDS, 94 | DEFENSE_SKYNET, 95 | DEFENSE_LOVECRAFT, 96 | NUM_DEFENSE_STYLES 97 | }; 98 | 99 | enum defense_location { 100 | DEFLOC_NULL = 0, 101 | DEFLOC_HOSPITAL, 102 | DEFLOC_MALL, 103 | DEFLOC_BAR, 104 | DEFLOC_MANSION, 105 | NUM_DEFENSE_LOCATIONS 106 | }; 107 | 108 | enum caravan_category { 109 | CARAVAN_CART = 0, 110 | CARAVAN_MELEE, 111 | CARAVAN_GUNS, 112 | CARAVAN_COMPONENTS, 113 | CARAVAN_FOOD, 114 | CARAVAN_CLOTHES, 115 | CARAVAN_TOOLS, 116 | NUM_CARAVAN_CATEGORIES 117 | }; 118 | 119 | struct defense_game : public special_game 120 | { 121 | defense_game(); 122 | 123 | virtual special_game_id id() { return SGAME_DEFENSE; }; 124 | virtual bool init(game *g); 125 | virtual void per_turn(game *g); 126 | virtual void pre_action(game *g, action_id &act); 127 | virtual void post_action(game *g, action_id act); 128 | virtual void game_over(game *g); 129 | 130 | private: 131 | void init_to_style(defense_style new_style); 132 | void load_style(std::string style_name); 133 | 134 | void setup(); 135 | void refresh_setup(WINDOW *w, int selection); 136 | void init_itypes(game *g); 137 | void init_mtypes(game *g); 138 | void init_constructions(game *g); 139 | void init_recipes(game *g); 140 | void init_map(game *g); 141 | std::vector carvan_items(caravan_category cat); 142 | 143 | void spawn_wave(game *g); 144 | void caravan(game *g); 145 | std::vector pick_monster_wave(game *g); 146 | void spawn_wave_monster(game *g, mtype *type); 147 | 148 | std::string special_wave_message(std::string name); 149 | 150 | 151 | // DATA 152 | int current_wave; 153 | 154 | defense_style style; // What type of game is it? 155 | defense_location location; // Where are we? 156 | 157 | int initial_difficulty; // Total "level" of monsters in first wave 158 | int wave_difficulty; // Increased "level" of monsters per wave 159 | 160 | int time_between_waves; // Cooldown / building / healing time 161 | int waves_between_caravans; // How many waves until we get to trade? 162 | 163 | int initial_cash; // How much cash do we start with? 164 | int cash_per_wave; // How much cash do we get per wave? 165 | int cash_increase; // How much does the above increase per wave? 166 | 167 | bool zombies; 168 | bool specials; 169 | bool spiders; 170 | bool triffids; 171 | bool robots; 172 | bool subspace; 173 | 174 | bool hunger; // Do we hunger? 175 | bool thirst; // Do we thirst? 176 | bool sleep; // Do we need to sleep? 177 | 178 | bool mercenaries; // Do caravans offer the option of hiring a mercenary? 179 | 180 | }; 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /inventory.h: -------------------------------------------------------------------------------- 1 | #ifndef _INVENTORY_H_ 2 | #define _INVENTORY_H_ 3 | 4 | #include "item.h" 5 | #include 6 | #include 7 | 8 | class game; 9 | class map; 10 | 11 | class inventory 12 | { 13 | public: 14 | item& operator[] (int i); 15 | std::vector& stack_at(int i); 16 | std::vector const_stack(int i) const; 17 | std::vector as_vector(); 18 | item& front(); 19 | item& back(); 20 | int size() const; 21 | int num_items() const; 22 | 23 | inventory& operator= (inventory &rhs); 24 | inventory& operator= (const inventory &rhs); 25 | inventory& operator+= (const inventory &rhs); 26 | inventory& operator+= (const item &rhs); 27 | inventory& operator+= (const std::vector &rhs); 28 | inventory operator+ (const inventory &rhs); 29 | inventory operator+ (const item &rhs); 30 | inventory operator+ (const std::vector &rhs); 31 | 32 | void clear(); 33 | void add_stack(std::vector newits); 34 | void push_back(std::vector newits); 35 | void add_item (item newit, bool keep_invlet = false); 36 | void add_item_keep_invlet(item newit); 37 | void push_back(item newit); 38 | 39 | /* Check all items for proper stacking, rearranging as needed 40 | * game pointer is not necessary, but if supplied, will ensure no overlap with 41 | * the player's worn items / weapon 42 | */ 43 | void restack(player *p = NULL); 44 | 45 | void form_from_map(game *g, point origin, int distance); 46 | 47 | std::vector remove_stack(int index); 48 | item remove_item(int index); 49 | item remove_item(int stack, int index); 50 | item remove_item_by_letter(char ch); 51 | item& item_by_letter(char ch); 52 | int index_by_letter(char ch); 53 | 54 | // Below, "amount" refers to quantity 55 | // "charges" refers to charges 56 | int amount_of (itype_id it); 57 | int charges_of(itype_id it); 58 | 59 | void use_amount (itype_id it, int quantity, bool use_container = false); 60 | void use_charges(itype_id it, int quantity); 61 | 62 | bool has_amount (itype_id it, int quantity); 63 | bool has_charges(itype_id it, int quantity); 64 | bool has_item(item *it); // Looks for a specific item 65 | 66 | /* TODO: This stuff, I guess? 67 | std::string save(); 68 | void load(std::string data); 69 | */ 70 | 71 | item nullitem; 72 | std::vector nullstack; 73 | private: 74 | void assign_empty_invlet(item &it, player *p = NULL); 75 | std::vector< std::vector > items; 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /item.h: -------------------------------------------------------------------------------- 1 | #ifndef _ITEM_H_ 2 | #define _ITEM_H_ 3 | 4 | #include 5 | #include 6 | #include "itype.h" 7 | #include "mtype.h" 8 | //#include "npc.h" 9 | 10 | class player; 11 | class npc; 12 | 13 | class item 14 | { 15 | public: 16 | item(); 17 | item(itype* it, unsigned int turn); 18 | item(itype* it, unsigned int turn, char let); 19 | void make_corpse(itype* it, mtype* mt, unsigned int turn); // Corpse 20 | item(std::string itemdata, game *g); 21 | ~item(); 22 | void make(itype* it); 23 | 24 | // returns the default container of this item, with this item in it 25 | item in_its_container(std::vector *itypes); 26 | 27 | nc_color color(player *u); 28 | nc_color color_in_inventory(player *u); 29 | std::string tname(game *g = NULL); // g needed for rotten-test 30 | void use(player &u); 31 | bool burn(int amount = 1); // Returns true if destroyed 32 | 33 | // Firearm specifics 34 | int reload_time(player &u); 35 | int clip_size(); 36 | int accuracy(); 37 | int gun_damage(bool with_ammo = true); 38 | int noise(); 39 | int burst_size(); 40 | int recoil(bool with_ammo = true); 41 | int range(player *p = NULL); 42 | ammotype ammo_type(); 43 | int pick_reload_ammo(player &u, bool interactive); 44 | bool reload(player &u, int index); 45 | 46 | std::string save_info(); // Formatted for save files 47 | void load_info(std::string data, game *g); 48 | std::string info(bool showtext = false); // Formatted for human viewing 49 | char symbol(); 50 | nc_color color(); 51 | int price(); 52 | 53 | bool invlet_is_okay(); 54 | bool stacks_with(item rhs); 55 | void put_in(item payload); 56 | 57 | int weight(); 58 | int volume(); 59 | int volume_contained(); 60 | int attack_time(); 61 | int damage_bash(); 62 | int damage_cut(); 63 | bool has_flag(item_flag f); 64 | bool has_technique(technique_id t, player *p = NULL); 65 | std::vector techniques(); 66 | bool goes_bad(); 67 | bool count_by_charges(); 68 | bool craft_has_charges(); 69 | bool rotten(game *g); 70 | 71 | // Our value as a weapon, given particular skills 72 | int weapon_value(int skills[num_skill_types]); 73 | // As above, but discounts its use as a ranged weapon 74 | int melee_value (int skills[num_skill_types]); 75 | // Returns the data associated with tech, if we are an it_style 76 | style_move style_data(technique_id tech); 77 | bool is_two_handed(player *u); 78 | bool made_of(material mat); 79 | bool conductive(); // Electricity 80 | bool destroyed_at_zero_charges(); 81 | // Most of the is_whatever() functions call the same function in our itype 82 | bool is_null(); // True if type is NULL, or points to the null item (id == 0) 83 | bool is_food(player *u);// Some non-food items are food to certain players 84 | bool is_food_container(player *u); // Ditto 85 | bool is_food(); // Ignoring the ability to eat batteries, etc. 86 | bool is_food_container(); // Ignoring the ability to eat batteries, etc. 87 | bool is_drink(); 88 | bool is_weap(); 89 | bool is_bashing_weapon(); 90 | bool is_cutting_weapon(); 91 | bool is_gun(); 92 | bool is_gunmod(); 93 | bool is_bionic(); 94 | bool is_ammo(); 95 | bool is_armor(); 96 | bool is_book(); 97 | bool is_container(); 98 | bool is_tool(); 99 | bool is_software(); 100 | bool is_macguffin(); 101 | bool is_style(); 102 | bool is_other(); // Doesn't belong in other categories 103 | bool is_artifact(); 104 | 105 | itype* type; 106 | mtype* corpse; 107 | it_ammo* curammo; 108 | 109 | std::vector contents; 110 | 111 | std::string name; 112 | char invlet; // Inventory letter 113 | int charges; 114 | bool active; // If true, it has active effects to be processed 115 | signed char damage; // How much damage it's sustained; generally, max is 5 116 | char burnt; // How badly we're burnt 117 | unsigned int bday; // The turn on which it was created 118 | int owned; // UID of NPC owner; 0 = player, -1 = unowned 119 | int poison; // How badly poisoned is it? 120 | 121 | int mission_id;// Refers to a mission in game's master list 122 | int player_id; // Only give a mission to the right player! 123 | 124 | }; 125 | 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /iuse.h: -------------------------------------------------------------------------------- 1 | #ifndef _IUSE_H_ 2 | #define _IUSE_H_ 3 | 4 | class game; 5 | class item; 6 | class player; 7 | 8 | class iuse 9 | { 10 | public: 11 | void none (game *g, player *p, item *it, bool t) { }; 12 | // FOOD AND DRUGS (ADMINISTRATION) 13 | void sewage (game *g, player *p, item *it, bool t); 14 | void royal_jelly (game *g, player *p, item *it, bool t); 15 | void bandage (game *g, player *p, item *it, bool t); 16 | void firstaid (game *g, player *p, item *it, bool t); 17 | void vitamins (game *g, player *p, item *it, bool t); 18 | void caff (game *g, player *p, item *it, bool t); 19 | void alcohol (game *g, player *p, item *it, bool t); 20 | void pkill_1 (game *g, player *p, item *it, bool t); 21 | void pkill_2 (game *g, player *p, item *it, bool t); 22 | void pkill_3 (game *g, player *p, item *it, bool t); 23 | void pkill_4 (game *g, player *p, item *it, bool t); 24 | void pkill_l (game *g, player *p, item *it, bool t); 25 | void xanax (game *g, player *p, item *it, bool t); 26 | void cig (game *g, player *p, item *it, bool t); 27 | void weed (game *g, player *p, item *it, bool t); 28 | void coke (game *g, player *p, item *it, bool t); 29 | void meth (game *g, player *p, item *it, bool t); 30 | void poison (game *g, player *p, item *it, bool t); 31 | void hallu (game *g, player *p, item *it, bool t); 32 | void thorazine (game *g, player *p, item *it, bool t); 33 | void prozac (game *g, player *p, item *it, bool t); 34 | void sleep (game *g, player *p, item *it, bool t); 35 | void iodine (game *g, player *p, item *it, bool t); 36 | void flumed (game *g, player *p, item *it, bool t); 37 | void flusleep (game *g, player *p, item *it, bool t); 38 | void inhaler (game *g, player *p, item *it, bool t); 39 | void blech (game *g, player *p, item *it, bool t); 40 | void mutagen (game *g, player *p, item *it, bool t); 41 | void mutagen_3 (game *g, player *p, item *it, bool t); 42 | void purifier (game *g, player *p, item *it, bool t); 43 | void marloss (game *g, player *p, item *it, bool t); 44 | void dogfood (game *g, player *p, item *it, bool t); 45 | 46 | // TOOLS 47 | void lighter (game *g, player *p, item *it, bool t); 48 | void sew (game *g, player *p, item *it, bool t); 49 | void scissors (game *g, player *p, item *it, bool t); 50 | void extinguisher (game *g, player *p, item *it, bool t); 51 | void hammer (game *g, player *p, item *it, bool t); 52 | void light_off (game *g, player *p, item *it, bool t); 53 | void light_on (game *g, player *p, item *it, bool t); 54 | void water_purifier (game *g, player *p, item *it, bool t); 55 | void two_way_radio (game *g, player *p, item *it, bool t); 56 | void radio_off (game *g, player *p, item *it, bool t); 57 | void radio_on (game *g, player *p, item *it, bool t); 58 | void crowbar (game *g, player *p, item *it, bool t); 59 | void makemound (game *g, player *p, item *it, bool t); 60 | void dig (game *g, player *p, item *it, bool t); 61 | void chainsaw_off (game *g, player *p, item *it, bool t); 62 | void chainsaw_on (game *g, player *p, item *it, bool t); 63 | void jackhammer (game *g, player *p, item *it, bool t); 64 | void set_trap (game *g, player *p, item *it, bool t); 65 | void geiger (game *g, player *p, item *it, bool t); 66 | void teleport (game *g, player *p, item *it, bool t); 67 | void can_goo (game *g, player *p, item *it, bool t); 68 | void pipebomb (game *g, player *p, item *it, bool t); 69 | void pipebomb_act (game *g, player *p, item *it, bool t); 70 | void grenade (game *g, player *p, item *it, bool t); 71 | void grenade_act (game *g, player *p, item *it, bool t); 72 | void flashbang (game *g, player *p, item *it, bool t); 73 | void flashbang_act (game *g, player *p, item *it, bool t); 74 | void c4 (game *g, player *p, item *it, bool t); 75 | void c4armed (game *g, player *p, item *it, bool t); 76 | void EMPbomb (game *g, player *p, item *it, bool t); 77 | void EMPbomb_act (game *g, player *p, item *it, bool t); 78 | void gasbomb (game *g, player *p, item *it, bool t); 79 | void gasbomb_act (game *g, player *p, item *it, bool t); 80 | void smokebomb (game *g, player *p, item *it, bool t); 81 | void smokebomb_act (game *g, player *p, item *it, bool t); 82 | void acidbomb (game *g, player *p, item *it, bool t); 83 | void acidbomb_act (game *g, player *p, item *it, bool t); 84 | void molotov (game *g, player *p, item *it, bool t); 85 | void molotov_lit (game *g, player *p, item *it, bool t); 86 | void dynamite (game *g, player *p, item *it, bool t); 87 | void dynamite_act (game *g, player *p, item *it, bool t); 88 | void mininuke (game *g, player *p, item *it, bool t); 89 | void mininuke_act (game *g, player *p, item *it, bool t); 90 | void pheromone (game *g, player *p, item *it, bool t); 91 | void portal (game *g, player *p, item *it, bool t); 92 | void manhack (game *g, player *p, item *it, bool t); 93 | void turret (game *g, player *p, item *it, bool t); 94 | void UPS_off (game *g, player *p, item *it, bool t); 95 | void UPS_on (game *g, player *p, item *it, bool t); 96 | void tazer (game *g, player *p, item *it, bool t); 97 | void mp3 (game *g, player *p, item *it, bool t); 98 | void mp3_on (game *g, player *p, item *it, bool t); 99 | void vortex (game *g, player *p, item *it, bool t); 100 | void dog_whistle (game *g, player *p, item *it, bool t); 101 | void vacutainer (game *g, player *p, item *it, bool t); 102 | // MACGUFFINS 103 | void mcg_note (game *g, player *p, item *it, bool t); 104 | // ARTIFACTS 105 | // This function is used when an artifact is activated 106 | // It examines the item's artifact-specific properties 107 | // See artifact.h for a list 108 | void artifact (game *g, player *p, item *it, bool t); 109 | void heal (game *g, player *p, item *it, bool t); 110 | void twist_space (game *g, player *p, item *it, bool t); 111 | void mass_vampire (game *g, player *p, item *it, bool t); 112 | void growth (game *g, player *p, item *it, bool t); 113 | void water (game *g, player *p, item *it, bool t); 114 | void lava (game *g, player *p, item *it, bool t); 115 | 116 | }; 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /keypress.cpp: -------------------------------------------------------------------------------- 1 | #include "keypress.h" 2 | #include "action.h" 3 | #include "game.h" 4 | 5 | long input() 6 | { 7 | long ch = getch(); 8 | switch (ch) { 9 | case KEY_UP: return 'k'; 10 | case KEY_LEFT: return 'h'; 11 | case KEY_RIGHT: return 'l'; 12 | case KEY_DOWN: return 'j'; 13 | case 459: return '\n'; 14 | default: return ch; 15 | } 16 | } 17 | 18 | void get_direction(int &x, int &y, char ch) 19 | { 20 | x = 0; 21 | y = 0; 22 | switch (ch) { 23 | case 'y': 24 | x = -1; 25 | y = -1; 26 | return; 27 | case 'u': 28 | x = 1; 29 | y = -1; 30 | return; 31 | case 'h': 32 | x = -1; 33 | return; 34 | case 'j': 35 | y = 1; 36 | return; 37 | case 'k': 38 | y = -1; 39 | return; 40 | case 'l': 41 | x = 1; 42 | return; 43 | case 'b': 44 | x = -1; 45 | y = 1; 46 | return; 47 | case 'n': 48 | x = 1; 49 | y = 1; 50 | return; 51 | case '.': 52 | case ',': 53 | case 'g': 54 | x = 0; 55 | y = 0; 56 | return; 57 | default: 58 | x = -2; 59 | y = -2; 60 | } 61 | } 62 | 63 | void get_direction(game *g, int &x, int &y, char ch) 64 | { 65 | x = 0; 66 | y = 0; 67 | action_id act; 68 | if (g->keymap.find(ch) == g->keymap.end()) 69 | act = ACTION_NULL; 70 | else 71 | act = g->keymap[ch]; 72 | 73 | switch (act) { 74 | case ACTION_MOVE_NW: 75 | x = -1; 76 | y = -1; 77 | return; 78 | case ACTION_MOVE_NE: 79 | x = 1; 80 | y = -1; 81 | return; 82 | case ACTION_MOVE_W: 83 | x = -1; 84 | return; 85 | case ACTION_MOVE_S: 86 | y = 1; 87 | return; 88 | case ACTION_MOVE_N: 89 | y = -1; 90 | return; 91 | case ACTION_MOVE_E: 92 | x = 1; 93 | return; 94 | case ACTION_MOVE_SW: 95 | x = -1; 96 | y = 1; 97 | return; 98 | case ACTION_MOVE_SE: 99 | x = 1; 100 | y = 1; 101 | return; 102 | case ACTION_PAUSE: 103 | case ACTION_PICKUP: 104 | x = 0; 105 | y = 0; 106 | return; 107 | default: 108 | x = -2; 109 | y = -2; 110 | } 111 | } 112 | 113 | std::string default_keymap_txt() 114 | { 115 | return "\ 116 | # This is the keymapping for Cataclysm.\n\ 117 | # You can start a line with # to make it a comment--it will be ignored.\n\ 118 | # Blank lines are ignored too.\n\ 119 | # Extra whitespace, including tab, is ignored, so format things how you like.\n\ 120 | # If you wish to restore defaults, simply remove this file.\n\ 121 | \n\ 122 | # The format for each line is an action identifier, followed by several\n\ 123 | # keys. Any action may have an unlimited number of keys bound to it.\n\ 124 | # If you bind the same key to multiple actions, the second and subsequent\n\ 125 | # bindings will be ignored--and you'll get a warning when the game starts.\n\ 126 | # Keys are case-sensitive, of course; c and C are different.\n\ 127 | \n\ 128 | # WARNING: If you skip an action identifier, there will be no key bound to\n\ 129 | # that action! You will be NOT be warned of this when the game starts.\n\ 130 | # If you're going to mess with stuff, maybe you should back this file up?\n\ 131 | \n\ 132 | # It is okay to split commands across lines.\n\ 133 | # pause . 5 is equivalent to:\n\ 134 | # pause .\n\ 135 | # pause 5\n\ 136 | \n\ 137 | # Note that movement keybindings ONLY apply to movement (for now).\n\ 138 | # That is, binding w to move_n will let you use w to move north, but you\n\ 139 | # cannot use w to smash north, examine to the north, etc.\n\ 140 | # For now, you must use vikeys, the numpad, or arrow keys for those actions.\n\ 141 | # This is planned to change in the future.\n\ 142 | \n\ 143 | # Finally, there is no support for special keys, like spacebar, Home, and\n\ 144 | # so on. This is not a planned feature, but if it's important to you, please\n\ 145 | # let me know.\n\ 146 | \n\ 147 | # MOVEMENT:\n\ 148 | pause . 5\n\ 149 | move_n k 8\n\ 150 | move_ne u 9\n\ 151 | move_e l 6\n\ 152 | move_se n 3\n\ 153 | move_s j 2\n\ 154 | move_sw b 1\n\ 155 | move_w h 4\n\ 156 | move_nw y 7\n\ 157 | move_down >\n\ 158 | move_up <\n\ 159 | \n\ 160 | # ENVIRONMENT INTERACTION\n\ 161 | open o\n\ 162 | close c\n\ 163 | smash s\n\ 164 | examine e\n\ 165 | pickup , g\n\ 166 | butcher B\n\ 167 | chat C\n\ 168 | look ; x\n\ 169 | \n\ 170 | # INVENTORY & QUASI-INVENTORY INTERACTION\n\ 171 | inventory i\n\ 172 | organize =\n\ 173 | apply a\n\ 174 | wear W\n\ 175 | take_off T\n\ 176 | eat E\n\ 177 | read R\n\ 178 | wield w\n\ 179 | pick_style _\n\ 180 | reload r\n\ 181 | unload U\n\ 182 | throw t\n\ 183 | fire f\n\ 184 | fire_burst F\n\ 185 | drop d\n\ 186 | drop_adj D\n\ 187 | bionics p\n\ 188 | \n\ 189 | # LONG TERM & SPECIAL ACTIONS\n\ 190 | wait ^\n\ 191 | craft &\n\ 192 | construct *\n\ 193 | sleep $\n\ 194 | safemode !\n\ 195 | autosafe \"\n\ 196 | ignore_enemy '\n\ 197 | save S\n\ 198 | quit Q\n\ 199 | \n\ 200 | # INFO SCREENS\n\ 201 | player_data @\n\ 202 | map m :\n\ 203 | missions M\n\ 204 | factions #\n\ 205 | morale %\n\ 206 | messages P\n\ 207 | help ?\n\ 208 | \n\ 209 | # DEBUG FUNCTIONS\n\ 210 | debug_mode ~\n\ 211 | # debug Z\n\ 212 | # debug_scent -\n\ 213 | "; 214 | } 215 | -------------------------------------------------------------------------------- /keypress.h: -------------------------------------------------------------------------------- 1 | #ifndef _KEYPRESS_H_ 2 | #define _KEYPRESS_H_ 3 | #if (defined _WIN32 || defined WINDOWS) 4 | #include "catacurse.h" 5 | #else 6 | #include 7 | #endif 8 | 9 | #include 10 | 11 | class game; 12 | 13 | // Simple text input--translates numpad to vikeys 14 | long input(); 15 | // If ch is vikey, x & y are set to corresponding direction; ch=='y'->x=-1,y=-1 16 | void get_direction(int &x, int &y, char ch); 17 | // Uses the keymap to figure out direction properly 18 | void get_direction(game *g, int &x, int &y, char ch); 19 | std::string default_keymap_txt(); 20 | 21 | #define CTRL(n) (n - 'A' + 1 < 1 ? n - 'a' + 1 : n - 'A' + 1) 22 | #define KEY_ESCAPE 27 23 | #endif 24 | -------------------------------------------------------------------------------- /line.cpp: -------------------------------------------------------------------------------- 1 | #include "line.h" 2 | #include "map.h" 3 | 4 | #define SGN(a) (((a)<0) ? -1 : 1) 5 | 6 | std::vector line_to(int x1, int y1, int x2, int y2, int t) 7 | { 8 | std::vector ret; 9 | int dx = x2 - x1; 10 | int dy = y2 - y1; 11 | int ax = abs(dx)<<1; 12 | int ay = abs(dy)<<1; 13 | int sx = SGN(dx); 14 | int sy = SGN(dy); 15 | if (dy == 0) sy = 0; 16 | if (dx == 0) sx = 0; 17 | point cur; 18 | cur.x = x1; 19 | cur.y = y1; 20 | 21 | int xmin = (x1 < x2 ? x1 : x2), ymin = (y1 < y2 ? y1 : y2), 22 | xmax = (x1 > x2 ? x1 : x2), ymax = (y1 > y2 ? y1 : y2); 23 | 24 | xmin -= abs(dx); 25 | ymin -= abs(dy); 26 | xmax += abs(dx); 27 | ymax += abs(dy); 28 | 29 | if (ax == ay) { 30 | do { 31 | cur.y += sy; 32 | cur.x += sx; 33 | ret.push_back(cur); 34 | } while ((cur.x != x2 || cur.y != y2) && 35 | (cur.x >= xmin && cur.x <= xmax && cur.y >= ymin && cur.y <= ymax)); 36 | } else if (ax > ay) { 37 | do { 38 | if (t > 0) { 39 | cur.y += sy; 40 | t -= ax; 41 | } 42 | cur.x += sx; 43 | t += ay; 44 | ret.push_back(cur); 45 | } while ((cur.x != x2 || cur.y != y2) && 46 | (cur.x >= xmin && cur.x <= xmax && cur.y >= ymin && cur.y <= ymax)); 47 | } else { 48 | do { 49 | if (t > 0) { 50 | cur.x += sx; 51 | t -= ay; 52 | } 53 | cur.y += sy; 54 | t += ax; 55 | ret.push_back(cur); 56 | } while ((cur.x != x2 || cur.y != y2) && 57 | (cur.x >= xmin && cur.x <= xmax && cur.y >= ymin && cur.y <= ymax)); 58 | } 59 | return ret; 60 | } 61 | 62 | int trig_dist(int x1, int y1, int x2, int y2) 63 | { 64 | return int(sqrt(double(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0)))); 65 | } 66 | 67 | int rl_dist(int x1, int y1, int x2, int y2) 68 | { 69 | int dx = abs(x1 - x2), dy = abs(y1 - y2); 70 | if (dx > dy) 71 | return dx; 72 | return dy; 73 | } 74 | 75 | int rl_dist(point a, point b) 76 | { 77 | int dx = abs(a.x - b.x), dy = abs(a.y - b.y); 78 | if (dx > dy) 79 | return dx; 80 | return dy; 81 | } 82 | 83 | double slope_of(std::vector line) 84 | { 85 | double dX = line.back().x - line.front().x, dY = line.back().y - line.front().y; 86 | if (dX == 0) 87 | return SLOPE_VERTICAL; 88 | return (dY / dX); 89 | } 90 | 91 | std::vector continue_line(std::vector line, int distance) 92 | { 93 | point start = line.back(), end = line.back(); 94 | double slope = slope_of(line); 95 | int sX = (line.front().x < line.back().x ? 1 : -1), 96 | sY = (line.front().y < line.back().y ? 1 : -1); 97 | if (abs(slope) == 1) { 98 | end.x += distance * sX; 99 | end.y += distance * sY; 100 | } else if (abs(slope) < 1) { 101 | end.x += distance * sX; 102 | end.y += int(distance * abs(slope) * sY); 103 | } else { 104 | end.y += distance * sY; 105 | if (slope != SLOPE_VERTICAL) 106 | end.x += int(distance / abs(slope)) * sX; 107 | } 108 | return line_to(start.x, start.y, end.x, end.y, 0); 109 | } 110 | 111 | direction direction_from(int x1, int y1, int x2, int y2) 112 | { 113 | int dx = x2 - x1; 114 | int dy = y2 - y1; 115 | if (dx < 0) { 116 | if (abs(dx) / 2 > abs(dy) || dy == 0) { 117 | return WEST; 118 | } else if (abs(dy) / 2 > abs(dx)) { 119 | if (dy < 0) 120 | return NORTH; 121 | else 122 | return SOUTH; 123 | } else { 124 | if (dy < 0) 125 | return NORTHWEST; 126 | else 127 | return SOUTHWEST; 128 | } 129 | } else { 130 | if (dx / 2 > abs(dy) || dy == 0) { 131 | return EAST; 132 | } else if (abs(dy) / 2 > dx || dx == 0) { 133 | if (dy < 0) 134 | return NORTH; 135 | else 136 | return SOUTH; 137 | } else { 138 | if (dy < 0) 139 | return NORTHEAST; 140 | else 141 | return SOUTHEAST; 142 | } 143 | } 144 | } 145 | 146 | std::string direction_name(direction dir) 147 | { 148 | switch (dir) { 149 | case NORTH: return "north"; 150 | case NORTHEAST: return "northeast"; 151 | case EAST: return "east"; 152 | case SOUTHEAST: return "southeast"; 153 | case SOUTH: return "south"; 154 | case SOUTHWEST: return "southwest"; 155 | case WEST: return "west"; 156 | case NORTHWEST: return "northwest"; 157 | } 158 | return "WEIRD DIRECTION_NAME() BUG"; 159 | } 160 | -------------------------------------------------------------------------------- /line.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINE_H_ 2 | #define _LINE_H_ 3 | 4 | #include 5 | #include 6 | #include "enums.h" 7 | 8 | #define SLOPE_VERTICAL 999999 9 | 10 | enum direction { 11 | NORTH = 0, 12 | NORTHEAST, 13 | EAST, 14 | SOUTHEAST, 15 | SOUTH, 16 | SOUTHWEST, 17 | WEST, 18 | NORTHWEST 19 | }; 20 | 21 | // The "t" value decides WHICH Bresenham line is used. 22 | std::vector line_to(int x1, int y1, int x2, int y2, int t); 23 | // sqrt(dX^2 + dY^2) 24 | int trig_dist(int x1, int y1, int x2, int y2); 25 | // Roguelike distance; minimum of dX and dY 26 | int rl_dist(int x1, int y1, int x2, int y2); 27 | int rl_dist(point a, point b); 28 | double slope_of(std::vector line); 29 | std::vector continue_line(std::vector line, int distance); 30 | direction direction_from(int x1, int y1, int x2, int y2); 31 | std::string direction_name(direction dir); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /* Main Loop for cataclysm 2 | * Linux only I guess 3 | * But maybe not 4 | * Who knows 5 | */ 6 | 7 | #if (defined _WIN32 || defined WINDOWS) 8 | #include "catacurse.h" 9 | #else 10 | #include 11 | #endif 12 | 13 | #include 14 | #include "game.h" 15 | #include "color.h" 16 | #include "options.h" 17 | #include "mapbuffer.h" 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | srand(time(NULL)); 22 | 23 | // ncurses stuff 24 | initscr(); // Initialize ncurses 25 | noecho(); // Don't echo keypresses 26 | cbreak(); // C-style breaks (e.g. ^C to SIGINT) 27 | keypad(stdscr, true); // Numpad is numbers 28 | init_colors(); // See color.cpp 29 | curs_set(0); // Invisible cursor 30 | 31 | rand(); // For some reason a call to rand() seems to be necessary to avoid 32 | // repetion. 33 | bool quit_game = false; 34 | game *g = new game; 35 | MAPBUFFER = mapbuffer(g); 36 | MAPBUFFER.load(); 37 | load_options(); 38 | do { 39 | g->setup(); 40 | while (!g->do_turn()); 41 | if (g->game_quit()) 42 | quit_game = true; 43 | } while (!quit_game); 44 | MAPBUFFER.save(); 45 | erase(); // Clear screen 46 | endwin(); // End ncurses 47 | system("clear"); // Tell the terminal to clear itself 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /mapbuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "mapbuffer.h" 2 | #include "game.h" 3 | #include "output.h" 4 | #include 5 | 6 | mapbuffer MAPBUFFER; 7 | 8 | bool pcomp(point lhs, point rhs) 9 | { 10 | }; 11 | 12 | 13 | // g defaults to NULL 14 | mapbuffer::mapbuffer(game *g) 15 | { 16 | master_game = g; 17 | } 18 | 19 | mapbuffer::~mapbuffer() 20 | { 21 | std::list::iterator it; 22 | 23 | for (it = submap_list.begin(); it != submap_list.end(); it++) 24 | delete *it; 25 | } 26 | 27 | void mapbuffer::set_game(game *g) 28 | { 29 | master_game = g; 30 | } 31 | 32 | bool mapbuffer::add_submap(int x, int y, int z, submap *sm) 33 | { 34 | tripoint p(x, y, z); 35 | if (submaps.count(p) != 0) 36 | return false; 37 | 38 | if (master_game) 39 | sm->turn_last_touched = int(master_game->turn); 40 | submap_list.push_back(sm); 41 | submaps[p] = sm; 42 | } 43 | 44 | submap* mapbuffer::lookup_submap(int x, int y, int z) 45 | { 46 | tripoint p(x, y, z); 47 | 48 | if (submaps.count(p) == 0) 49 | return NULL; 50 | 51 | return submaps[p]; 52 | } 53 | 54 | void mapbuffer::save() 55 | { 56 | std::map::iterator it; 57 | std::ofstream fout; 58 | fout.open("save/maps.txt"); 59 | 60 | fout << submap_list.size() << std::endl; 61 | int percent = 0; 62 | 63 | for (it = submaps.begin(); it != submaps.end(); it++) { 64 | percent++; 65 | if (percent % 100 == 0) 66 | popup_nowait("Please wait as the map saves [%s%d/%d]", 67 | (percent < 100 ? percent < 10 ? " " : " " : ""), percent, 68 | submap_list.size()); 69 | fout << it->first.x << " " << it->first.y << " " << it->first.z << std::endl; 70 | submap *sm = it->second; 71 | fout << sm->turn_last_touched << std::endl; 72 | // Dump the terrain. 73 | for (int j = 0; j < SEEY; j++) { 74 | for (int i = 0; i < SEEX; i++) 75 | fout << int(sm->ter[i][j]) << " "; 76 | fout << std::endl; 77 | } 78 | // Dump the radiation 79 | for (int j = 0; j < SEEY; j++) { 80 | for (int i = 0; i < SEEX; i++) 81 | fout << sm->rad[i][j] << " "; 82 | } 83 | fout << std::endl; 84 | 85 | // Items section; designate it with an I. Then check itm[][] for each square 86 | // in the grid and print the coords and the item's details. 87 | // Designate it with a C if it's contained in the prior item. 88 | // Also, this wastes space since we print the coords for each item, when we 89 | // could be printing a list of items for each coord (except the empty ones) 90 | item tmp; 91 | for (int j = 0; j < SEEY; j++) { 92 | for (int i = 0; i < SEEX; i++) { 93 | for (int k = 0; k < sm->itm[i][j].size(); k++) { 94 | tmp = sm->itm[i][j][k]; 95 | fout << "I " << i << " " << j << std::endl; 96 | fout << tmp.save_info() << std::endl; 97 | for (int l = 0; l < tmp.contents.size(); l++) 98 | fout << "C " << std::endl << tmp.contents[l].save_info() << std::endl; 99 | } 100 | } 101 | } 102 | // Output the traps 103 | for (int j = 0; j < SEEY; j++) { 104 | for (int i = 0; i < SEEX; i++) { 105 | if (sm->trp[i][j] != tr_null) 106 | fout << "T " << i << " " << j << " " << sm->trp[i][j] << 107 | std::endl; 108 | } 109 | } 110 | 111 | // Output the fields 112 | field tmpf; 113 | for (int j = 0; j < SEEY; j++) { 114 | for (int i = 0; i < SEEX; i++) { 115 | tmpf = sm->fld[i][j]; 116 | if (tmpf.type != fd_null) 117 | fout << "F " << i << " " << j << " " << int(tmpf.type) << " " << 118 | int(tmpf.density) << " " << tmpf.age << std::endl; 119 | } 120 | } 121 | // Output the spawn points 122 | spawn_point tmpsp; 123 | for (int i = 0; i < sm->spawns.size(); i++) { 124 | tmpsp = sm->spawns[i]; 125 | fout << "S " << int(tmpsp.type) << " " << tmpsp.count << " " << tmpsp.posx << 126 | " " << tmpsp.posy << " " << tmpsp.faction_id << " " << 127 | tmpsp.mission_id << (tmpsp.friendly ? " 1 " : " 0 ") << 128 | tmpsp.name << std::endl; 129 | } 130 | // Output the vehicles 131 | for (int i = 0; i < sm->vehicles.size(); i++) { 132 | fout << "V "; 133 | sm->vehicles[i].save (fout); 134 | } 135 | // Output the computer 136 | if (sm->comp.name != "") 137 | fout << "c " << sm->comp.save_data() << std::endl; 138 | fout << "----" << std::endl; 139 | } 140 | // Close the file; that's all we need. 141 | fout.close(); 142 | } 143 | 144 | void mapbuffer::load() 145 | { 146 | if (!master_game) { 147 | debugmsg("Can't load mapbuffer without a master_game"); 148 | return; 149 | } 150 | std::map::iterator it; 151 | std::ifstream fin; 152 | fin.open("save/maps.txt"); 153 | if (!fin.is_open()) 154 | return; 155 | 156 | char line[SEEX]; 157 | char ch = 0; 158 | int itx, ity, t, d, a, num_submaps; 159 | bool fields_here = false; 160 | item it_tmp; 161 | std::string databuff; 162 | fin >> num_submaps; 163 | 164 | while (!fin.eof()) { 165 | int percent = submap_list.size(); 166 | if (percent % 100 == 0) 167 | popup_nowait("Please wait as the map loads [%s%d/%d]", 168 | (percent < 100 ? percent < 10 ? " " : " " : ""), percent, 169 | num_submaps); 170 | int locx, locy, locz, turn; 171 | submap* sm = new submap; 172 | fin >> locx >> locy >> locz >> turn; 173 | sm->turn_last_touched = turn; 174 | int turndif = (master_game ? int(master_game->turn) - turn : 0); 175 | if (turndif < 0) 176 | turndif = 0; 177 | // Load terrain 178 | for (int j = 0; j < SEEY; j++) { 179 | for (int i = 0; i < SEEX; i++) { 180 | int tmpter; 181 | fin >> tmpter; 182 | sm->ter[i][j] = ter_id(tmpter); 183 | sm->itm[i][j].clear(); 184 | sm->trp[i][j] = tr_null; 185 | sm->fld[i][j] = field(); 186 | } 187 | } 188 | // Load irradiation 189 | for (int j = 0; j < SEEY; j++) { 190 | for (int i = 0; i < SEEX; i++) { 191 | int radtmp; 192 | fin >> radtmp; 193 | radtmp -= int(turndif / 100); // Radiation slowly decays 194 | if (radtmp < 0) 195 | radtmp = 0; 196 | sm->rad[i][j] = radtmp; 197 | } 198 | } 199 | // Load items and traps and fields and spawn points and vehicles 200 | std::string string_identifier; 201 | do { 202 | fin >> string_identifier; // "----" indicates end of this submap 203 | t = 0; 204 | if (string_identifier == "I") { 205 | fin >> itx >> ity; 206 | getline(fin, databuff); // Clear out the endline 207 | getline(fin, databuff); 208 | it_tmp.load_info(databuff, master_game); 209 | sm->itm[itx][ity].push_back(it_tmp); 210 | if (it_tmp.active) 211 | sm->active_item_count++; 212 | } else if (string_identifier == "C") { 213 | getline(fin, databuff); // Clear out the endline 214 | getline(fin, databuff); 215 | int index = sm->itm[itx][ity].size() - 1; 216 | it_tmp.load_info(databuff, master_game); 217 | sm->itm[itx][ity][index].put_in(it_tmp); 218 | if (it_tmp.active) 219 | sm->active_item_count++; 220 | } else if (string_identifier == "T") { 221 | fin >> itx >> ity >> t; 222 | sm->trp[itx][ity] = trap_id(t); 223 | } else if (string_identifier == "F") { 224 | fields_here = true; 225 | fin >> itx >> ity >> t >> d >> a; 226 | sm->fld[itx][ity] = field(field_id(t), d, a); 227 | sm->field_count++; 228 | } else if (string_identifier == "S") { 229 | char tmpfriend; 230 | int tmpfac = -1, tmpmis = -1; 231 | std::string spawnname; 232 | fin >> t >> a >> itx >> ity >> tmpfac >> tmpmis >> tmpfriend >> spawnname; 233 | spawn_point tmp(mon_id(t), a, itx, ity, tmpfac, tmpmis, (tmpfriend == '1'), 234 | spawnname); 235 | sm->spawns.push_back(tmp); 236 | } else if (string_identifier == "V") { 237 | vehicle veh(master_game); 238 | veh.load (fin); 239 | //veh.smx = gridx; 240 | //veh.smy = gridy; 241 | sm->vehicles.push_back(veh); 242 | } else if (string_identifier == "c") { 243 | getline(fin, databuff); 244 | sm->comp.load_data(databuff); 245 | } 246 | } while (string_identifier != "----" && !fin.eof()); 247 | 248 | submap_list.push_back(sm); 249 | submaps[ tripoint(locx, locy, locz) ] = sm; 250 | } 251 | fin.close(); 252 | } 253 | 254 | int mapbuffer::size() 255 | { 256 | return submap_list.size(); 257 | } 258 | -------------------------------------------------------------------------------- /mapbuffer.h: -------------------------------------------------------------------------------- 1 | #include "map.h" 2 | #include "line.h" 3 | #include 4 | #include 5 | 6 | class game; 7 | 8 | struct pointcomp 9 | { 10 | bool operator() (const tripoint &lhs, const tripoint &rhs) const 11 | { 12 | if (lhs.x < rhs.x) return true; 13 | if (lhs.x > rhs.x) return false; 14 | if (lhs.y < rhs.y) return true; 15 | if (lhs.y > rhs.y) return false; 16 | if (lhs.z < rhs.z) return true; 17 | if (lhs.z > rhs.z) return false; 18 | return false; 19 | }; 20 | }; 21 | 22 | class mapbuffer 23 | { 24 | public: 25 | mapbuffer(game *g = NULL); 26 | ~mapbuffer(); 27 | 28 | void set_game(game *g); 29 | 30 | void load(); 31 | void save(); 32 | 33 | bool add_submap(int x, int y, int z, submap *sm); 34 | submap* lookup_submap(int x, int y, int z); 35 | 36 | int size(); 37 | 38 | private: 39 | std::map submaps; 40 | std::list submap_list; 41 | game *master_game; 42 | }; 43 | 44 | extern mapbuffer MAPBUFFER; 45 | -------------------------------------------------------------------------------- /mapitems.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAPITEMS_H_ 2 | #define _MAPITEMS_H_ 3 | enum items_location { 4 | mi_none, 5 | mi_field, mi_forest, mi_hive, mi_hive_center, 6 | mi_road, 7 | mi_livingroom, mi_kitchen, mi_fridge, mi_home_hw, mi_bedroom, mi_homeguns, 8 | mi_dresser, mi_dining, 9 | mi_snacks, mi_fridgesnacks, mi_behindcounter, mi_magazines, 10 | mi_softdrugs, mi_harddrugs, 11 | mi_cannedfood, mi_pasta, mi_produce, 12 | mi_cleaning, 13 | mi_hardware, mi_tools, mi_bigtools, mi_mischw, 14 | mi_consumer_electronics, 15 | mi_sports, mi_camping, mi_allsporting, 16 | mi_alcohol, 17 | mi_pool_table, 18 | mi_trash, 19 | mi_ammo, mi_pistols, mi_shotguns, mi_rifles, mi_smg, mi_assault, mi_allguns, 20 | mi_gunxtras, 21 | mi_shoes, mi_pants, mi_shirts, mi_jackets, mi_winter, mi_bags, mi_allclothes, 22 | mi_novels, mi_manuals, mi_textbooks, 23 | mi_cop_weapons, mi_cop_evidence, 24 | mi_hospital_lab, mi_hospital_samples, mi_surgery, 25 | mi_office, mi_vault, 26 | mi_art, mi_pawn, mi_mil_surplus, 27 | mi_shelter, 28 | mi_chemistry, mi_teleport, mi_goo, mi_cloning_vat, mi_dissection, 29 | mi_hydro, mi_electronics, mi_monparts, mi_bionics, mi_bionics_common, 30 | mi_bots, mi_launchers, mi_mil_rifles, mi_grenades, mi_mil_armor, mi_mil_food, 31 | mi_mil_food_nodrugs, mi_bionics_mil, 32 | mi_weapons, mi_survival_armor, mi_survival_tools, 33 | mi_sewage_plant, 34 | mi_mine_storage, mi_mine_equipment, 35 | mi_spiral, 36 | mi_radio, 37 | mi_toxic_dump_equipment, 38 | mi_subway, mi_sewer, 39 | mi_cavern, 40 | mi_spider, 41 | mi_ant_food, mi_ant_egg, 42 | // Monster drops 43 | mi_biollante, mi_bugs, mi_bees, mi_wasps, mi_robots, 44 | // Map Extras 45 | mi_helicopter, mi_military, mi_science, mi_rare, mi_stash_food, mi_stash_ammo, 46 | mi_stash_wood, mi_stash_drugs, mi_drugdealer, mi_wreckage, 47 | // Shopkeeps &c 48 | mi_npc_hacker, 49 | mi_trader_avoid, 50 | num_itloc 51 | }; 52 | 53 | // This is used only for monsters; they get a list of items_locations, and 54 | // a chance that each one will be used. 55 | struct items_location_and_chance 56 | { 57 | items_location loc; 58 | int chance; 59 | items_location_and_chance (items_location l, int c) { 60 | loc = l; 61 | chance = c; 62 | }; 63 | }; 64 | #endif 65 | -------------------------------------------------------------------------------- /mission.h: -------------------------------------------------------------------------------- 1 | #ifndef _MISSION_H_ 2 | #define _MISSION_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "itype.h" 8 | #include "texthash.h" 9 | #include "npc.h" 10 | 11 | struct mission; 12 | class game; 13 | enum talk_topic; 14 | 15 | enum mission_id { 16 | MISSION_NULL, 17 | MISSION_GET_ANTIBIOTICS, 18 | MISSION_GET_SOFTWARE, 19 | MISSION_GET_ZOMBIE_BLOOD_ANAL, 20 | MISSION_RESCUE_DOG, 21 | MISSION_KILL_ZOMBIE_MOM, 22 | MISSION_REACH_SAFETY, 23 | NUM_MISSION_IDS 24 | }; 25 | 26 | std::string mission_dialogue(mission_id id, talk_topic state); 27 | 28 | enum mission_origin { 29 | ORIGIN_NULL = 0, 30 | ORIGIN_GAME_START, // Given when the game starts 31 | ORIGIN_OPENER_NPC, // NPC comes up to you when the game starts 32 | ORIGIN_ANY_NPC, // Any NPC 33 | ORIGIN_SECONDARY, // Given at the end of another mission 34 | NUM_ORIGIN 35 | }; 36 | 37 | enum mission_goal { 38 | MGOAL_NULL = 0, 39 | MGOAL_GO_TO, // Reach a certain overmap tile 40 | MGOAL_FIND_ITEM, // Find an item of a given type 41 | MGOAL_FIND_ANY_ITEM, // Find an item tagged with this mission 42 | MGOAL_FIND_MONSTER, // Find and retrieve a friendly monster 43 | MGOAL_FIND_NPC, // Find a given NPC 44 | MGOAL_ASSASSINATE, // Kill a given NPC 45 | MGOAL_KILL_MONSTER, // Kill a particular hostile monster 46 | NUM_MGOAL 47 | }; 48 | 49 | struct mission_place { // Return true if [posx,posy] is valid in overmap 50 | bool never (game *g, int posx, int posy) { return false; } 51 | bool always (game *g, int posx, int posy) { return true; } 52 | bool near_town (game *g, int posx, int posy); 53 | }; 54 | 55 | /* mission_start functions are first run when a mission is accepted; this 56 | * initializes the mission's key values, like the target and description. 57 | * These functions are also run once a turn for each active mission, to check 58 | * if the current goal has been reached. At that point they either start the 59 | * goal, or run the appropriate mission_end function. 60 | */ 61 | struct mission_start { 62 | void standard (game *, mission *); // Standard for its goal type 63 | void infect_npc (game *, mission *); // DI_INFECTION, remove antibiotics 64 | void place_dog (game *, mission *); // Put a dog in a house! 65 | void place_zombie_mom (game *, mission *); // Put a zombie mom in a house! 66 | void place_npc_software(game *, mission *); // Put NPC-type-dependent software 67 | void reveal_hospital (game *, mission *); // Reveal the nearest hospital 68 | void find_safety (game *, mission *); // Goal is set to non-spawn area 69 | void place_book (game *, mission *); // Place a book to retrieve 70 | }; 71 | 72 | struct mission_end { // These functions are run when a mission ends 73 | void standard (game *, mission *){}; // Nothing special happens 74 | void heal_infection (game *, mission *); 75 | }; 76 | 77 | struct mission_fail { 78 | void standard (game *, mission *){}; // Nothing special happens 79 | void kill_npc (game *, mission *); // Kill the NPC who assigned it! 80 | }; 81 | 82 | struct mission_type { 83 | int id; // Matches it to a mission_id above 84 | std::string name; // The name the mission is given in menus 85 | mission_goal goal; // The basic goal type 86 | int difficulty; // Difficulty; TODO: come up with a scale 87 | int value; // Value; determines rewards and such 88 | npc_favor special_reward; // If we have a special gift, not cash value 89 | int deadline_low, deadline_high; // Low and high deadlines (turn numbers) 90 | bool urgent; // If true, the NPC will press this mission! 91 | 92 | std::vector origins; // Points of origin 93 | itype_id item_id; 94 | mission_id follow_up; 95 | 96 | bool (mission_place::*place)(game *g, int x, int y); 97 | void (mission_start::*start)(game *g, mission *); 98 | void (mission_end ::*end )(game *g, mission *); 99 | void (mission_fail ::*fail )(game *g, mission *); 100 | 101 | mission_type(int ID, std::string NAME, mission_goal GOAL, int DIF, int VAL, 102 | bool URGENT, 103 | bool (mission_place::*PLACE)(game *, int x, int y), 104 | void (mission_start::*START)(game *, mission *), 105 | void (mission_end ::*END )(game *, mission *), 106 | void (mission_fail ::*FAIL )(game *, mission *)) : 107 | id (ID), name (NAME), goal (GOAL), difficulty (DIF), value (VAL), 108 | urgent(URGENT), place (PLACE), start (START), end (END), fail (FAIL) 109 | { 110 | deadline_low = 0; 111 | deadline_high = 0; 112 | item_id = itm_null; 113 | follow_up = MISSION_NULL; 114 | }; 115 | 116 | mission create(game *g, int npc_id = -1); // Create a mission 117 | }; 118 | 119 | struct mission { 120 | mission_type *type; 121 | std::string description; // Basic descriptive text 122 | bool failed; // True if we've failed it! 123 | int value; // Cash/Favor value of completing this 124 | npc_favor reward; // If there's a special reward for completing it 125 | int uid; // Unique ID number, used for referencing elsewhere 126 | point target; // Marked on the player's map. (-1,-1) for none 127 | itype_id item_id; // Item that needs to be found (or whatever) 128 | int count; // How many of that item 129 | int deadline; // Turn number 130 | int npc_id; // ID of a related npc 131 | int good_fac_id, bad_fac_id; // IDs of the protagonist/antagonist factions 132 | int step; // How much have we completed? 133 | mission_id follow_up; // What mission do we get after this succeeds? 134 | text_hash text; 135 | 136 | std::string name(); 137 | std::string save_info(); 138 | void load_info(game *g, std::ifstream &info); 139 | 140 | mission() 141 | { 142 | type = NULL; 143 | description = ""; 144 | failed = false; 145 | value = 0; 146 | uid = -1; 147 | target = point(-1, -1); 148 | item_id = itm_null; 149 | count = 0; 150 | deadline = 0; 151 | npc_id = -1; 152 | good_fac_id = -1; 153 | bad_fac_id = -1; 154 | step = 0; 155 | } 156 | }; 157 | 158 | #endif 159 | -------------------------------------------------------------------------------- /mission_end.cpp: -------------------------------------------------------------------------------- 1 | #include "mission.h" 2 | #include "game.h" 3 | 4 | void mission_end::heal_infection(game *g, mission *miss) 5 | { 6 | bool found_npc = false; 7 | for (int i = 0; i < g->active_npc.size() && !found_npc; i++) { 8 | if (g->active_npc[i].id == miss->npc_id) { 9 | g->active_npc[i].rem_disease(DI_INFECTION); 10 | found_npc = true; 11 | } 12 | } 13 | 14 | for (int i = 0; !found_npc && i < g->cur_om.npcs.size(); i++) { 15 | if (g->cur_om.npcs[i].id == miss->npc_id) { 16 | g->cur_om.npcs[i].rem_disease(DI_INFECTION); 17 | found_npc = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mission_fail.cpp: -------------------------------------------------------------------------------- 1 | #include "mission.h" 2 | #include "game.h" 3 | 4 | void mission_fail::kill_npc(game *g, mission *miss) 5 | { 6 | for (int i = 0; i < g->active_npc.size(); i++) { 7 | if (g->active_npc[i].id == miss->npc_id) { 8 | g->active_npc[i].die(g, false); 9 | g->active_npc.erase(g->active_npc.begin() + i); 10 | return; 11 | } 12 | } 13 | for (int i = 0; i < g->cur_om.npcs.size(); i++) { 14 | if (g->cur_om.npcs[i].id == miss->npc_id) { 15 | g->cur_om.npcs[i].marked_for_death = true; 16 | return; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mission_place.cpp: -------------------------------------------------------------------------------- 1 | #include "mission.h" 2 | #include "game.h" 3 | 4 | bool mission_place::near_town(game *g, int posx, int posy) 5 | { 6 | return (g->cur_om.dist_from_city( point(posx, posy) ) <= 40); 7 | } 8 | -------------------------------------------------------------------------------- /missiondef.cpp: -------------------------------------------------------------------------------- 1 | #include "mission.h" 2 | #include "setvector.h" 3 | #include "game.h" 4 | 5 | void game::init_missions() 6 | { 7 | #define MISSION(name, goal, diff, val, urgent, place, start, end, fail) \ 8 | id++; mission_types.push_back( \ 9 | mission_type(id, name, goal, diff, val, urgent, place, start, end, fail) ) 10 | 11 | #define ORIGINS(...) setvector(mission_types[id].origins, __VA_ARGS__, NULL) 12 | #define ITEM(itid) mission_types[id].item_id = itid 13 | 14 | // DEADLINE defines the low and high end time limits, in hours 15 | // Omitting DEADLINE means the mission never times out 16 | #define DEADLINE(low, high) mission_types[id].deadline_low = low * 600;\ 17 | mission_types[id].deadline_high = high * 600 18 | //#define NPCS (...) setvector(missions[id].npc 19 | 20 | 21 | // The order of missions should match enum mission_id in mission.h 22 | int id = -1; 23 | 24 | MISSION("Null mission", MGOAL_NULL, 0, 0, false, 25 | &mission_place::never, &mission_start::standard, 26 | &mission_end::standard, &mission_fail::standard); 27 | 28 | MISSION("Find Antibiotics", MGOAL_FIND_ITEM, 2, 1500, true, 29 | &mission_place::always, &mission_start::infect_npc, 30 | &mission_end::heal_infection, &mission_fail::kill_npc); 31 | ORIGINS(ORIGIN_OPENER_NPC); 32 | ITEM(itm_antibiotics); 33 | DEADLINE(24, 48); // 1 - 2 days 34 | 35 | MISSION("Retrieve Software", MGOAL_FIND_ANY_ITEM, 2, 800, false, 36 | &mission_place::near_town, &mission_start::place_npc_software, 37 | &mission_end::standard, &mission_fail::standard); 38 | ORIGINS(ORIGIN_OPENER_NPC, ORIGIN_ANY_NPC); 39 | 40 | MISSION("Analyze Zombie Blood", MGOAL_FIND_ITEM, 8, 2500, false, 41 | &mission_place::always, &mission_start::reveal_hospital, 42 | &mission_end::standard, &mission_fail::standard); 43 | ORIGINS(ORIGIN_SECONDARY); 44 | ITEM(itm_software_blood_data); 45 | 46 | MISSION("Find Lost Dog", MGOAL_FIND_MONSTER, 3, 1000, false, 47 | &mission_place::near_town, &mission_start::place_dog, 48 | &mission_end::standard, &mission_fail::standard); 49 | ORIGINS(ORIGIN_OPENER_NPC); 50 | 51 | MISSION("Kill Zombie Mom", MGOAL_KILL_MONSTER, 5, 1200, true, 52 | &mission_place::near_town, &mission_start::place_zombie_mom, 53 | &mission_end::standard, &mission_fail::standard); 54 | ORIGINS(ORIGIN_OPENER_NPC, ORIGIN_ANY_NPC); 55 | 56 | MISSION("Reach Safety", MGOAL_GO_TO, 1, 0, false, 57 | &mission_place::always, &mission_start::find_safety, 58 | &mission_end::standard, &mission_fail::standard); 59 | ORIGINS(ORIGIN_NULL); 60 | 61 | MISSION("Find a Book", MGOAL_FIND_ANY_ITEM, 2, 800, false, 62 | &mission_place::always, &mission_start::place_book, 63 | &mission_end::standard, &mission_fail::standard); 64 | ORIGINS(ORIGIN_ANY_NPC); 65 | } 66 | -------------------------------------------------------------------------------- /monattack.h: -------------------------------------------------------------------------------- 1 | #ifndef _MONATTACK_H_ 2 | #define _MONATTACK_H_ 3 | 4 | //#include "game.h" 5 | 6 | class game; 7 | 8 | class mattack 9 | { 10 | public: 11 | void none (game *g, monster *z) { }; 12 | void antqueen (game *g, monster *z); 13 | void shriek (game *g, monster *z); 14 | void acid (game *g, monster *z); 15 | void shockstorm (game *g, monster *z); 16 | void boomer (game *g, monster *z); 17 | void resurrect (game *g, monster *z); 18 | void science (game *g, monster *z); 19 | void growplants (game *g, monster *z); 20 | void grow_vine (game *g, monster *z); 21 | void vine (game *g, monster *z); 22 | void spit_sap (game *g, monster *z); 23 | void triffid_heartbeat(game *g, monster *z); 24 | void fungus (game *g, monster *z); 25 | void fungus_sprout (game *g, monster *z); 26 | void leap (game *g, monster *z); 27 | void dermatik (game *g, monster *z); 28 | void plant (game *g, monster *z); 29 | void disappear (game *g, monster *z); 30 | void formblob (game *g, monster *z); 31 | void dogthing (game *g, monster *z); 32 | void tentacle (game *g, monster *z); 33 | void vortex (game *g, monster *z); 34 | void gene_sting (game *g, monster *z); 35 | void stare (game *g, monster *z); 36 | void fear_paralyze (game *g, monster *z); 37 | void photograph (game *g, monster *z); 38 | void tazer (game *g, monster *z); 39 | void smg (game *g, monster *z); 40 | void flamethrower (game *g, monster *z); 41 | void copbot (game *g, monster *z); 42 | void multi_robot (game *g, monster *z); // Pick from tazer, smg, flame 43 | void ratking (game *g, monster *z); 44 | void generator (game *g, monster *z); 45 | void upgrade (game *g, monster *z); 46 | void breathe (game *g, monster *z); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mondeath.h: -------------------------------------------------------------------------------- 1 | #ifndef _MONDEATH_H_ 2 | #define _MONDEATH_H_ 3 | 4 | class game; 5 | class monster; 6 | 7 | class mdeath 8 | { 9 | public: 10 | void normal (game *g, monster *z); // Drop a body 11 | void acid (game *g, monster *z); // Acid instead of a body 12 | void boomer (game *g, monster *z); // Explodes in vomit :3 13 | void kill_vines (game *g, monster *z); // Kill all nearby vines 14 | void vine_cut (game *g, monster *z); // Kill adjacent vine if it's cut 15 | void triffid_heart (game *g, monster *z); // Destroy all roots 16 | void fungus (game *g, monster *z); // Explodes in spores D: 17 | void fungusawake (game *g, monster *z); // Turn into live fungaloid 18 | void disintegrate (game *g, monster *z); // Falls apart 19 | void shriek (game *g, monster *z); // Screams loudly 20 | void worm (game *g, monster *z); // Spawns 2 half-worms 21 | void disappear (game *g, monster *z); // Hallucination disappears 22 | void guilt (game *g, monster *z); // Morale penalty 23 | void blobsplit (game *g, monster *z); // Creates more blobs 24 | void melt (game *g, monster *z); // Normal death, but melts 25 | void amigara (game *g, monster *z); // Removes hypnosis if last one 26 | void thing (game *g, monster *z); // Turn into a full thing 27 | void explode (game *g, monster *z); // Damaging explosion 28 | void ratking (game *g, monster *z); // Cure verminitis 29 | void kill_breathers (game *g, monster *z); // All breathers die 30 | 31 | void gameover (game *g, monster *z); // Game over! Defense mode 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /mongroup.h: -------------------------------------------------------------------------------- 1 | #ifndef _MONGROUP_H_ 2 | #define _MONGROUP_H_ 3 | 4 | #include "mtype.h" 5 | #include 6 | 7 | enum moncat_id { 8 | mcat_null = 0, 9 | mcat_forest, 10 | mcat_ant, 11 | mcat_bee, 12 | mcat_worm, 13 | mcat_zombie, 14 | mcat_triffid, 15 | mcat_fungi, 16 | mcat_goo, 17 | mcat_chud, 18 | mcat_sewer, 19 | mcat_swamp, 20 | mcat_lab, 21 | mcat_nether, 22 | mcat_spiral, 23 | mcat_vanilla_zombie, // Defense mode only 24 | mcat_spider, // Defense mode only 25 | mcat_robot, // Defense mode only 26 | num_moncats 27 | }; 28 | 29 | bool moncat_is_safe(moncat_id id); 30 | 31 | struct mongroup { 32 | moncat_id type; 33 | int posx, posy; 34 | unsigned char radius; 35 | unsigned int population; 36 | bool dying; 37 | mongroup(moncat_id ptype, int pposx, int pposy, unsigned char prad, 38 | unsigned int ppop) { 39 | type = ptype; 40 | posx = pposx; 41 | posy = pposy; 42 | radius = prad; 43 | population = ppop; 44 | dying = false; 45 | } 46 | bool is_safe() { return moncat_is_safe(type); }; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mongroupdef.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | #include "setvector.h" 3 | 4 | void game::init_moncats() 5 | { 6 | setvector( 7 | moncats[mcat_forest], 8 | mon_squirrel, mon_rabbit, mon_deer, mon_wolf, mon_bear, mon_spider_wolf, 9 | mon_spider_jumping, mon_dog, NULL); 10 | setvector( 11 | moncats[mcat_ant], 12 | mon_ant_larva, mon_ant, mon_ant_soldier, mon_ant_queen, NULL); 13 | setvector( 14 | moncats[mcat_bee], 15 | mon_bee, NULL); 16 | setvector( 17 | moncats[mcat_worm], 18 | mon_graboid, mon_worm, mon_halfworm, NULL); 19 | setvector( 20 | moncats[mcat_zombie], 21 | mon_zombie, mon_zombie_shrieker, mon_zombie_spitter, mon_zombie_fast, 22 | mon_zombie_electric, mon_zombie_brute, mon_zombie_hulk, 23 | mon_zombie_necro, mon_boomer, mon_skeleton, mon_zombie_grabber, 24 | mon_zombie_master, NULL); 25 | setvector( 26 | moncats[mcat_triffid], 27 | mon_triffid, mon_triffid_young, mon_vinebeast, mon_triffid_queen, NULL); 28 | setvector( 29 | moncats[mcat_fungi], 30 | mon_fungaloid, mon_fungaloid_dormant, mon_ant_fungus, mon_zombie_fungus, 31 | mon_boomer_fungus, mon_spore, mon_fungaloid_queen, mon_fungal_wall, 32 | NULL); 33 | setvector( 34 | moncats[mcat_goo], 35 | mon_blob, NULL); 36 | setvector( 37 | moncats[mcat_chud], 38 | mon_chud, mon_one_eye, mon_crawler, NULL); 39 | setvector( 40 | moncats[mcat_sewer], 41 | mon_sewer_fish, mon_sewer_snake, mon_sewer_rat, NULL); 42 | setvector( 43 | moncats[mcat_swamp], 44 | mon_mosquito, mon_dragonfly, mon_centipede, mon_frog, mon_slug, 45 | mon_dermatik_larva, mon_dermatik, NULL); 46 | setvector( 47 | moncats[mcat_lab], 48 | mon_zombie_scientist, mon_blob_small, mon_manhack, mon_skitterbot, 49 | NULL); 50 | setvector( 51 | moncats[mcat_nether], 52 | mon_flying_polyp, mon_hunting_horror, mon_mi_go, mon_yugg, mon_gelatin, 53 | mon_flaming_eye, mon_kreck, mon_blank, mon_gozu, NULL); 54 | setvector( 55 | moncats[mcat_spiral], 56 | mon_human_snail, mon_twisted_body, mon_vortex, NULL); 57 | setvector( 58 | moncats[mcat_vanilla_zombie], 59 | mon_zombie, NULL); 60 | setvector( 61 | moncats[mcat_spider], 62 | mon_spider_wolf, mon_spider_web, mon_spider_jumping, mon_spider_widow, 63 | NULL); 64 | setvector( 65 | moncats[mcat_robot], 66 | mon_manhack, mon_skitterbot, mon_secubot, mon_copbot, mon_molebot, 67 | mon_tripod, mon_chickenbot, mon_tankbot, NULL); 68 | } 69 | 70 | bool moncat_is_safe(moncat_id id) 71 | { 72 | if (id == mcat_null || id == mcat_forest) 73 | return true; 74 | return false; 75 | } 76 | -------------------------------------------------------------------------------- /monitemsdef.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | #include "setvector.h" 3 | 4 | void game::init_monitems() 5 | { 6 | setvector(monitems[mon_ant], 7 | mi_bugs, 1, NULL); 8 | monitems[mon_ant_soldier] = monitems[mon_ant]; 9 | monitems[mon_ant_queen] = monitems[mon_ant]; 10 | 11 | setvector(monitems[mon_zombie], 12 | mi_livingroom, 10,mi_kitchen, 8,mi_bedroom, 20,mi_dresser, 30, 13 | mi_softdrugs, 5,mi_harddrugs, 2,mi_tools, 6,mi_trash, 7, 14 | mi_ammo, 18,mi_pistols, 3,mi_shotguns, 2,mi_smg, 1, 15 | NULL); 16 | monitems[mon_zombie_shrieker] = monitems[mon_zombie]; 17 | monitems[mon_zombie_spitter] = monitems[mon_zombie]; 18 | monitems[mon_zombie_electric] = monitems[mon_zombie]; 19 | monitems[mon_zombie_fast] = monitems[mon_zombie]; 20 | monitems[mon_zombie_brute] = monitems[mon_zombie]; 21 | monitems[mon_zombie_hulk] = monitems[mon_zombie]; 22 | monitems[mon_zombie_fungus] = monitems[mon_zombie]; 23 | monitems[mon_boomer] = monitems[mon_zombie]; 24 | monitems[mon_boomer_fungus] = monitems[mon_zombie]; 25 | monitems[mon_zombie_necro] = monitems[mon_zombie]; 26 | monitems[mon_zombie_grabber] = monitems[mon_zombie]; 27 | monitems[mon_zombie_master] = monitems[mon_zombie]; 28 | 29 | setvector(monitems[mon_zombie_scientist], 30 | mi_dresser, 10,mi_harddrugs, 6,mi_chemistry, 10, 31 | mi_teleport, 6,mi_goo, 8,mi_cloning_vat, 1, 32 | mi_dissection, 10,mi_electronics, 9,mi_bionics, 1, 33 | mi_radio, 2,mi_textbooks, 3,NULL); 34 | 35 | setvector(monitems[mon_zombie_soldier], 36 | mi_dresser, 5,mi_ammo, 10,mi_pistols, 5, 37 | mi_shotguns, 2,mi_smg, 5,mi_bots, 1, 38 | mi_launchers, 2,mi_mil_rifles, 10,mi_grenades, 5, 39 | mi_mil_armor, 14,mi_mil_food, 5,mi_bionics_mil, 1, 40 | NULL); 41 | 42 | setvector(monitems[mon_biollante], 43 | mi_biollante, 1, NULL); 44 | 45 | setvector(monitems[mon_chud], 46 | mi_subway, 40,mi_sewer, 20,mi_trash, 5,mi_bedroom, 1, 47 | mi_dresser, 5,mi_ammo, 18, NULL); 48 | monitems[mon_one_eye] = monitems[mon_chud]; 49 | 50 | setvector(monitems[mon_bee], 51 | mi_bees, 1, NULL); 52 | 53 | setvector(monitems[mon_wasp], 54 | mi_wasps, 1, NULL); 55 | 56 | setvector(monitems[mon_dragonfly], 57 | mi_bugs, 1, NULL); 58 | monitems[mon_centipede] = monitems[mon_dragonfly]; 59 | monitems[mon_spider_wolf] = monitems[mon_dragonfly]; 60 | monitems[mon_spider_web] = monitems[mon_dragonfly]; 61 | monitems[mon_spider_jumping] = monitems[mon_dragonfly]; 62 | monitems[mon_spider_trapdoor] = monitems[mon_dragonfly]; 63 | monitems[mon_spider_widow] = monitems[mon_dragonfly]; 64 | 65 | setvector(monitems[mon_eyebot], 66 | mi_robots, 4, mi_ammo, 1,NULL); 67 | monitems[mon_manhack] = monitems[mon_eyebot]; 68 | monitems[mon_skitterbot] = monitems[mon_eyebot]; 69 | monitems[mon_secubot] = monitems[mon_eyebot]; 70 | monitems[mon_copbot] = monitems[mon_eyebot]; 71 | monitems[mon_molebot] = monitems[mon_eyebot]; 72 | monitems[mon_tripod] = monitems[mon_eyebot]; 73 | monitems[mon_chickenbot] = monitems[mon_eyebot]; 74 | monitems[mon_tankbot] = monitems[mon_eyebot]; 75 | monitems[mon_turret] = monitems[mon_eyebot]; 76 | } 77 | -------------------------------------------------------------------------------- /monster.h: -------------------------------------------------------------------------------- 1 | #ifndef _MONSTER_H_ 2 | #define _MONSTER_H_ 3 | 4 | #include "player.h" 5 | #include "mtype.h" 6 | #include "enums.h" 7 | #include 8 | 9 | class map; 10 | class player; 11 | class game; 12 | class item; 13 | 14 | enum monster_effect_type { 15 | ME_NULL = 0, 16 | ME_BEARTRAP, // Stuck in beartrap 17 | ME_POISONED, // Slowed, takes damage 18 | ME_ONFIRE, // Lit aflame 19 | ME_STUNNED, // Stumbling briefly 20 | ME_DOWNED, // Knocked down 21 | ME_BLIND, // Can't use sight 22 | ME_DEAF, // Can't use hearing 23 | ME_TARGETED, // Targeting locked on--for robots that shoot guns 24 | ME_DOCILE, // Don't attack other monsters--for tame monster 25 | ME_HIT_BY_PLAYER, // We shot or hit them 26 | ME_RUN, // For hit-and-run monsters; we're running for a bit; 27 | NUM_MONSTER_EFFECTS 28 | }; 29 | 30 | enum monster_attitude { 31 | MATT_NULL = 0, 32 | MATT_FRIEND, 33 | MATT_FLEE, 34 | MATT_IGNORE, 35 | MATT_FOLLOW, 36 | MATT_ATTACK, 37 | NUM_MONSTER_ATTITUDES 38 | }; 39 | 40 | struct monster_effect 41 | { 42 | monster_effect_type type; 43 | int duration; 44 | monster_effect(monster_effect_type T, int D) : type (T), duration (D) {} 45 | }; 46 | 47 | class monster { 48 | public: 49 | monster(); 50 | monster(mtype *t); 51 | monster(mtype *t, int x, int y); 52 | ~monster(); 53 | void poly(mtype *t); 54 | void spawn(int x, int y); // All this does is moves the monster to x,y 55 | 56 | // Access 57 | std::string name(); // Returns the monster's formal name 58 | std::string name_with_armor(); // Name, with whatever our armor is called 59 | void print_info(game *g, WINDOW* w); // Prints information to w. 60 | char symbol(); // Just our type's symbol; no context 61 | void draw(WINDOW* w, int plx, int ply, bool inv); 62 | nc_color color_with_effects(); // Color with fire, beartrapped, etc. 63 | // Inverts color if inv==true 64 | bool has_flag(m_flag f); // Returns true if f is set (see mtype.h) 65 | bool can_see(); // MF_SEES and no ME_BLIND 66 | bool can_hear(); // MF_HEARS and no ME_DEAF 67 | bool made_of(material m); // Returns true if it's made of m 68 | 69 | void load_info(std::string data, std::vector *mtypes); 70 | std::string save_info(); // String of all data, for save files 71 | void debug(player &u); // Gives debug info 72 | 73 | // Movement 74 | void receive_moves(); // Gives us movement points 75 | void shift(int sx, int sy); // Shifts the monster to the appropriate submap 76 | // Updates current pos AND our plans 77 | bool wander(); // Returns true if we have no plans 78 | bool can_move_to(map &m, int x, int y); // Can we move to (x, y)? 79 | bool will_reach(game *g, int x, int y); // Do we have plans to get to (x, y)? 80 | int turns_to_reach(game *g, int x, int y); // How long will it take? 81 | 82 | void set_dest(int x, int y, int &t); // Go in a straight line to (x, y) 83 | // t determines WHICH Bresenham line 84 | void wander_to(int x, int y, int f); // Try to get to (x, y), we don't know 85 | // the route. Give up after f steps. 86 | void plan(game *g); 87 | void move(game *g); // Actual movement 88 | void footsteps(game *g, int x, int y); // noise made by movement 89 | void friendly_move(game *g); 90 | 91 | point scent_move(game *g); 92 | point sound_move(game *g); 93 | void hit_player(game *g, player &p, bool can_grab = true); 94 | void move_to(game *g, int x, int y); 95 | void stumble(game *g, bool moved); 96 | void knock_back_from(game *g, int posx, int posy); 97 | 98 | // Combat 99 | bool is_fleeing(player &u); // True if we're fleeing 100 | monster_attitude attitude(player *u = NULL); // See the enum above 101 | int morale_level(player &u); // Looks at our HP etc. 102 | void process_triggers(game *g);// Process things that anger/scare us 103 | void process_trigger(monster_trigger trig, int amount);// Single trigger 104 | int trigger_sum(game *g, std::vector *triggers); 105 | int hit(game *g, player &p, body_part &bp_hit); // Returns a damage 106 | void hit_monster(game *g, int i); 107 | bool hurt(int dam); // Deals this dam damage; returns true if we dead 108 | int armor_cut(); // Natural armor, plus any worn armor 109 | int armor_bash(); // Natural armor, plus any worn armor 110 | int dodge(); // Natural dodge, or 0 if we're occupied 111 | int dodge_roll(); // For the purposes of comparing to player::hit_roll() 112 | int fall_damage(); // How much a fall hurts us 113 | void die(game *g); 114 | 115 | // Other 116 | void add_effect(monster_effect_type effect, int duration); 117 | bool has_effect(monster_effect_type effect); // True if we have the effect 118 | void rem_effect(monster_effect_type effect); // Remove a given effect 119 | void process_effects(game *g); // Process long-term effects 120 | bool make_fungus(game *g); // Makes this monster into a fungus version 121 | // Returns false if no such monster exists 122 | void make_friendly(); 123 | void add_item(item it); // Add an item to inventory 124 | 125 | // TEMP VALUES 126 | int posx, posy; 127 | int wandx, wandy; // Wander destination - Just try to move in that direction 128 | int wandf; // Urge to wander - Increased by sound, decrements each move 129 | std::vector inv; // Inventory 130 | std::vector effects; // Active effects, e.g. on fire 131 | 132 | // If we were spawned by the map, store our origin for later use 133 | int spawnmapx, spawnmapy, spawnposx, spawnposy; 134 | 135 | // DEFINING VALUES 136 | int moves, speed; 137 | int hp; 138 | int sp_timeout; 139 | int friendly; 140 | int anger, morale; 141 | int faction_id; // If we belong to a faction 142 | int mission_id; // If we're related to a mission 143 | mtype *type; 144 | bool dead; 145 | bool made_footstep; 146 | std::string unique_name; // If we're unique 147 | 148 | private: 149 | std::vector plans; 150 | }; 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /morale.h: -------------------------------------------------------------------------------- 1 | #ifndef _MORALE_H_ 2 | #define _MORALE_H_ 3 | 4 | #include 5 | 6 | #define MIN_MORALE_READ (-40) 7 | #define MIN_MORALE_CRAFT (-50) 8 | 9 | enum morale_type 10 | { 11 | MORALE_NULL = 0, 12 | MORALE_FOOD_GOOD, 13 | MORALE_MUSIC, 14 | MORALE_MARLOSS, 15 | MORALE_FEELING_GOOD, 16 | 17 | MORALE_CRAVING_NICOTINE, 18 | MORALE_CRAVING_CAFFEINE, 19 | MORALE_CRAVING_ALCOHOL, 20 | MORALE_CRAVING_OPIATE, 21 | MORALE_CRAVING_SPEED, 22 | MORALE_CRAVING_COCAINE, 23 | 24 | MORALE_FOOD_BAD, 25 | MORALE_VEGETARIAN, 26 | MORALE_WET, 27 | MORALE_FEELING_BAD, 28 | MORALE_KILLED_INNOCENT, 29 | MORALE_KILLED_FRIEND, 30 | MORALE_KILLED_MONSTER, 31 | 32 | MORALE_MOODSWING, 33 | MORALE_BOOK, 34 | 35 | MORALE_SCREAM, 36 | 37 | NUM_MORALE_TYPES 38 | }; 39 | 40 | struct morale_point 41 | { 42 | morale_type type; 43 | itype* item_type; 44 | int bonus; 45 | 46 | morale_point(morale_type T = MORALE_NULL, itype* I = NULL, int B = 0) : 47 | type (T), item_type (I), bonus (B) {}; 48 | 49 | std::string name(std::string morale_data[]) 50 | { 51 | std::string ret = morale_data[type]; 52 | std::string item_name = ""; 53 | if (item_type != NULL) 54 | item_name = item_type->name; 55 | size_t it = ret.find("%i"); 56 | while (it != std::string::npos) { 57 | ret.replace(it, 2, item_name); 58 | it = ret.find("%i"); 59 | } 60 | return ret; 61 | } 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /moraledata.h: -------------------------------------------------------------------------------- 1 | #ifndef _MORALEDATA_H_ 2 | #define _MORALEDATA_H_ 3 | 4 | #include 5 | #include "morale.h" 6 | 7 | std::string morale_data[NUM_MORALE_TYPES] = { 8 | "This is a bug", 9 | "Enjoyed %i", 10 | "Music", 11 | "Marloss Bliss", 12 | "Good Feeling", 13 | 14 | "Nicotine Craving", 15 | "Caffeine Craving", 16 | "Alcohol Craving", 17 | "Opiate Craving", 18 | "Speed Craving", 19 | "Cocaine Craving", 20 | 21 | "Disliked %i", 22 | "Ate Meat", 23 | "Wet", 24 | "Bad Feeling", 25 | "Killed Innocent", 26 | "Killed Friend", 27 | "Killed Mother", 28 | 29 | "Moodswing", 30 | "Read %i", 31 | "Heard Disturbing Scream" 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /mutation.h: -------------------------------------------------------------------------------- 1 | #ifndef _MUTATION_H_ 2 | #define _MUTATION_H_ 3 | 4 | #include "pldata.h" // See pldata.h for mutations--they're actually pl_flags 5 | #include 6 | 7 | enum mutation_category 8 | { 9 | MUTCAT_NULL = 0, 10 | MUTCAT_LIZARD, 11 | MUTCAT_BIRD, 12 | MUTCAT_FISH, 13 | MUTCAT_BEAST, 14 | MUTCAT_CATTLE, 15 | MUTCAT_INSECT, 16 | MUTCAT_PLANT, 17 | MUTCAT_SLIME, 18 | MUTCAT_TROGLO, 19 | MUTCAT_CEPHALOPOD, 20 | MUTCAT_SPIDER, 21 | MUTCAT_RAT, 22 | NUM_MUTATION_CATEGORIES 23 | }; 24 | 25 | // mutations_from_category() defines the lists; see mutation_data.cpp 26 | std::vector mutations_from_category(mutation_category cat); 27 | 28 | struct mutation_branch 29 | { 30 | bool valid; // True if this is a valid mutation (only used for flags < PF_MAX) 31 | std::vector prereqs; // Prerequisites; Only one is required 32 | std::vector cancels; // Mutations that conflict with this one 33 | std::vector replacements; // Mutations that replace this one 34 | std::vector additions; // Mutations that add to this one 35 | 36 | mutation_branch() { valid = false; }; 37 | 38 | }; 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /options.cpp: -------------------------------------------------------------------------------- 1 | #include "options.h" 2 | #include "output.h" 3 | 4 | #include 5 | #include 6 | 7 | option_table OPTIONS; 8 | 9 | option_key lookup_option_key(std::string id); 10 | bool option_is_bool(option_key id); 11 | void create_default_options(); 12 | std::string options_header(); 13 | 14 | void load_options() 15 | { 16 | std::ifstream fin; 17 | fin.open("data/options.txt"); 18 | if (!fin.is_open()) { 19 | fin.close(); 20 | create_default_options(); 21 | fin.open("data/options.txt"); 22 | if (!fin.is_open()) { 23 | debugmsg("Could neither read nor create ./data/options.txt"); 24 | return; 25 | } 26 | } 27 | 28 | while (!fin.eof()) { 29 | std::string id; 30 | fin >> id; 31 | if (id == "") 32 | getline(fin, id); // Empty line, chomp it 33 | else if (id[0] == '#') // # indicates a comment 34 | getline(fin, id); 35 | else { 36 | option_key key = lookup_option_key(id); 37 | if (key == OPT_NULL) { 38 | debugmsg("Bad option: %s", id.c_str()); 39 | getline(fin, id); 40 | } else if (option_is_bool(key)) { 41 | std::string val; 42 | fin >> val; 43 | if (val == "T") 44 | OPTIONS[key] = 1.; 45 | else 46 | OPTIONS[key] = 0.; 47 | } else { 48 | double val; 49 | fin >> val; 50 | OPTIONS[key] = val; 51 | } 52 | } 53 | if (fin.peek() == '\n') 54 | getline(fin, id); // Chomp 55 | } 56 | fin.close(); 57 | } 58 | 59 | option_key lookup_option_key(std::string id) 60 | { 61 | if (id == "use_celsius") 62 | return OPT_USE_CELSIUS; 63 | if (id == "use_metric_system") 64 | return OPT_USE_METRIC_SYS; 65 | if (id == "force_capital_yn") 66 | return OPT_FORCE_YN; 67 | if (id == "no_bright_backgrounds") 68 | return OPT_NO_CBLINK; 69 | if (id == "24_hour") 70 | return OPT_24_HOUR; 71 | if (id == "snap_to_target") 72 | return OPT_SNAP_TO_TARGET; 73 | if (id == "safemode") 74 | return OPT_SAFEMODE; 75 | if (id == "autosafemode") 76 | return OPT_AUTOSAFEMODE; 77 | 78 | return OPT_NULL; 79 | } 80 | 81 | std::string option_string(option_key key) 82 | { 83 | switch (key) { 84 | case OPT_USE_CELSIUS: return "use_celsius"; 85 | case OPT_USE_METRIC_SYS: return "use_metric_system"; 86 | case OPT_FORCE_YN: return "force_capital_yn"; 87 | case OPT_NO_CBLINK: return "no_bright_backgrounds"; 88 | case OPT_24_HOUR: return "24_hour"; 89 | case OPT_SNAP_TO_TARGET: return "snap_to_target"; 90 | case OPT_SAFEMODE: return "safemode"; 91 | case OPT_AUTOSAFEMODE: return "autosafemode"; 92 | default: return "unknown_option"; 93 | } 94 | return "unknown_option"; 95 | } 96 | 97 | std::string option_name(option_key key) 98 | { 99 | switch (key) { 100 | case OPT_USE_CELSIUS: return "Use Celsius"; 101 | case OPT_USE_METRIC_SYS: return "Use Metric System"; 102 | case OPT_FORCE_YN: return "Force Y/N in prompts"; 103 | case OPT_NO_CBLINK: return "No Bright Backgrounds"; 104 | case OPT_24_HOUR: return "24 Hour Time"; 105 | case OPT_SNAP_TO_TARGET: return "Snap to Target"; 106 | case OPT_SAFEMODE: return "Safemode on by default"; 107 | case OPT_AUTOSAFEMODE: return "Auto-Safemode on by default"; 108 | default: return "Unknown Option (BUG)"; 109 | } 110 | return "Big ol Bug"; 111 | } 112 | 113 | bool option_is_bool(option_key id) 114 | { 115 | switch (id) { 116 | default: 117 | return true; 118 | } 119 | return true; 120 | } 121 | 122 | void create_default_options() 123 | { 124 | std::ofstream fout; 125 | fout.open("data/options.txt"); 126 | if (!fout.is_open()) 127 | return; 128 | 129 | fout << options_header() << "\n\ 130 | # If true, use C not F\n\ 131 | use_celsius F\n\ 132 | # If true, use Km/h not mph\ 133 | use_metric_system F\n\ 134 | # If true, y/n prompts are case-sensitive, y and n are not accepted\n\ 135 | force_capital_yn T\n\ 136 | # If true, bright backgrounds are not used--some consoles are not compatible\n\ 137 | no_bright_backgrounds F\n\ 138 | # If true, use military time, not AM/PM\n\ 139 | 24_hour F\n\ 140 | # If true, automatically follow the crosshair when firing/throwing\n\ 141 | snap_to_target F\n\ 142 | # If true, safemode will be on after starting a new game or loading\n\ 143 | safemode T\n\ 144 | # If true, auto-safemode will be on after starting a new game or loading\n\ 145 | autosafemode F\n\ 146 | "; 147 | fout.close(); 148 | } 149 | 150 | std::string options_header() 151 | { 152 | return "\ 153 | # This is the options file. It works similarly to keymap.txt: the format is\n\ 154 | #