-
Notifications
You must be signed in to change notification settings - Fork 4
/
moria.c
194 lines (159 loc) · 6.05 KB
/
moria.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* moria.c
Port of imoria from VMS in pascal to linux in C. Joy. Here is the
copyright notice from the sources I started with (although trying to
maintain a copyright on something you put into the public domain seems
wrong somehow):
{ Moria Version 4.8 COPYRIGHT (c) Robert Alan Koeneke }
{ Public Domain }
{ }
{ I lovingly dedicate this game to hackers and adventurers }
{ everywhere... }
{ }
{ }
{ Designer and Programmer : Robert Alan Koeneke }
{ University of Oklahoma }
{ }
{ Assitant Programmers : Jimmey Wayne Todd }
{ University of Oklahoma }
{ }
{ Gary D. McAdoo }
{ University of Oklahoma }
{ }
{ Moria may be copied and modified freely as long as the above }
{ credits are retained. No one who-so-ever may sell or market }
{ this software in any form without the expressed written consent }
{ of the author Robert Alan Koeneke. }
{ }
*/
#define __MORIA_C__
#include "imoria.h"
/***********************************************************************/
int main(int argc, char *argv[], char *envp[])
{
/*// { SYSPRV stays off except when needed... }*/
game_state = GS_LOADING;
init_priv_switch();
priv_switch(0);
ENTER("main", "")
//init_signals();
// { Get the time player entered game }
start_time = time(NULL);
// { Get the directory location of the image }
get_paths();
// { Here comes the monsters.... }
load_monsters();
// { Check to see if an update is in progress -DMF- }
if (check_kickout()) {
writeln("Imoria is locked . . . Try playing conquest.");
writeln("Who knows *how* long this might take?");
exit_game();
}
// { Some necessary initializations }
msg_line = 1;
quart_height = trunc(SCREEN_HEIGHT/4);
quart_width = trunc(SCREEN_WIDTH /4);
dun_level = 0;
inven_temp = (treas_ptr)safe_malloc(sizeof(treas_rec),"inven_temp");
inven_temp->data = blank_treasure;
inven_temp->ok = false;
inven_temp->insides = 0;
inven_temp->next = nil;
inven_temp->is_in = false;
caught_message = nil;
old_message = nil;
old_mess_count = 0;
turn_counter = 100000;
// { Grab a random seed from the clock }
seed = get_seed();
// { Sort the objects by level }
sort_objects();
// { Init monster and treasure levels for allocate }
init_m_level();
init_t_level();
// { Init the store inventories }
store_init();
if (COST_ADJ != 1.00) price_adjust();
if (WEIGHT_ADJ != 1) item_weight_adjust();
bank_init();
// { Build the secret wizard and god passwords }
bpswd();
// { Check operating hours }
// { If not wizard then No_Control_Y }
// { Check or create hours.dat, print message }
intro(finam, argc, argv);
// { Init an IO channel for QIO }
/* init_channel(); */
clear_screen();
// { Generate a character, or retrieve old one... }
if (strlen(finam) > 0) {
// { Retrieve character }
game_state = GS_IGNORE_CTRL_C;
generate = get_char(finam,true);
py.flags.dead = true;
is_from_file = true;
save_char(false);
change_name();
magic_init(randes_seed);
} else {
// { Create character }
is_from_file = false;
strncpy(finam,"moriachar.sav",sizeof(vtype));
create_character();
char_inven_init();
if (class[py.misc.pclass].mspell) {
// { Magic realm }
learn_spell(&msg_flag);
gain_mana(spell_adj(INT));
} else if (class[py.misc.pclass].pspell) {
// { Clerical realm}
learn_prayer();
gain_mana(spell_adj(WIS));
} else if (class[py.misc.pclass].dspell) {
// { Druidical realm }
learn_druid();
gain_mana(druid_adj());
} else if (class[py.misc.pclass].bspell) {
// { Bardic realm }
learn_song(&msg_flag);
gain_mana(bard_adj());
}
py.misc.cmana = py.misc.mana;
randes_seed = seed; // { Description seed }
town_seed = seed; // { Town generation seed }
magic_init(randes_seed);
generate = true;
} /* end if (load/create character) */
if (py.misc.pclass == C_MONK) {
strcpy(bare_hands, "2d2");
}
if (class[py.misc.pclass].mspell || class[py.misc.pclass].pspell ||
class[py.misc.pclass].dspell || class[py.misc.pclass].bspell ||
class[py.misc.pclass].mental )
{
is_magii = true;
} else {
is_magii = false;
}
// { Begin the game }
replace_name();
set_gem_values();
set_difficulty(py.misc.diffic); // { Set difficulty of game }
player_max_exp = (integer)(player_exp[MAX_PLAYER_LEVEL-1]
* py.misc.expfact);
clear_from(1);
prt_stat_block();
// { Turn on message trapping, if requested }
// if (want_trap) set_the_trap();
set_seed(get_seed());
// { Loop till dead, or exit }
do {
//generate = true;
if (generate) generate_cave(); // { New level }
dungeon(); // { Dungeon logic }
generate = true;
} while (!death);
upon_death(); // { Character gets buried }
LEAVE("main", "")
return 0;
} /* end main */
/***********************************************************************/