1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
… | |
… | |
32 | #include <algorithm> |
33 | #include <algorithm> |
33 | #include <functional> |
34 | #include <functional> |
34 | |
35 | |
35 | playervec players; |
36 | playervec players; |
36 | |
37 | |
37 | void |
|
|
38 | display_motd (const object *op) |
|
|
39 | { |
|
|
40 | char buf[MAX_BUF]; |
|
|
41 | char motd[HUGE_BUF]; |
|
|
42 | FILE *fp; |
|
|
43 | int comp; |
|
|
44 | int size; |
|
|
45 | |
|
|
46 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
|
|
47 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
|
|
48 | return; |
|
|
49 | |
|
|
50 | motd[0] = '\0'; |
|
|
51 | size = 0; |
|
|
52 | |
|
|
53 | while (fgets (buf, MAX_BUF, fp)) |
|
|
54 | { |
|
|
55 | if (*buf == '#') |
|
|
56 | continue; |
|
|
57 | |
|
|
58 | strncat (motd + size, buf, HUGE_BUF - size); |
|
|
59 | size += strlen (buf); |
|
|
60 | } |
|
|
61 | |
|
|
62 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
|
|
63 | close_and_delete (fp, comp); |
|
|
64 | } |
|
|
65 | |
|
|
66 | void |
|
|
67 | send_rules (const object *op) |
|
|
68 | { |
|
|
69 | char buf[MAX_BUF]; |
|
|
70 | char rules[HUGE_BUF]; |
|
|
71 | FILE *fp; |
|
|
72 | int comp; |
|
|
73 | int size; |
|
|
74 | |
|
|
75 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
|
|
76 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
|
|
77 | return; |
|
|
78 | |
|
|
79 | rules[0] = '\0'; |
|
|
80 | size = 0; |
|
|
81 | |
|
|
82 | while (fgets (buf, MAX_BUF, fp)) |
|
|
83 | { |
|
|
84 | if (*buf == '#') |
|
|
85 | continue; |
|
|
86 | |
|
|
87 | if (size + strlen (buf) >= HUGE_BUF) |
|
|
88 | { |
|
|
89 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
|
|
90 | break; |
|
|
91 | } |
|
|
92 | |
|
|
93 | strncat (rules + size, buf, HUGE_BUF - size); |
|
|
94 | size += strlen (buf); |
|
|
95 | } |
|
|
96 | |
|
|
97 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
|
|
98 | close_and_delete (fp, comp); |
|
|
99 | } |
|
|
100 | |
|
|
101 | void |
|
|
102 | send_news (const object *op) |
|
|
103 | { |
|
|
104 | char buf[MAX_BUF]; |
|
|
105 | char news[HUGE_BUF]; |
|
|
106 | char subject[MAX_BUF]; |
|
|
107 | FILE *fp; |
|
|
108 | int comp; |
|
|
109 | int size; |
|
|
110 | |
|
|
111 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
|
|
112 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
|
|
113 | return; |
|
|
114 | |
|
|
115 | news[0] = '\0'; |
|
|
116 | subject[0] = '\0'; |
|
|
117 | size = 0; |
|
|
118 | |
|
|
119 | while (fgets (buf, MAX_BUF, fp)) |
|
|
120 | { |
|
|
121 | if (*buf == '#') |
|
|
122 | continue; |
|
|
123 | |
|
|
124 | if (*buf == '%') |
|
|
125 | { /* send one news */ |
|
|
126 | if (size > 0) |
|
|
127 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
|
|
128 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, |
|
|
129 | "INFORMATION: %s\n%s", (char *)"%s\n%s", |
|
|
130 | subject, news); /*send previously read news */ |
|
|
131 | |
|
|
132 | strcpy (subject, buf + 1); |
|
|
133 | strip_endline (subject); |
|
|
134 | size = 0; |
|
|
135 | news[0] = '\0'; |
|
|
136 | } |
|
|
137 | else |
|
|
138 | { |
|
|
139 | if (size + strlen (buf) >= HUGE_BUF) |
|
|
140 | { |
|
|
141 | LOG (llevDebug, "Warning, one news item has size > %d bytes.\n", HUGE_BUF); |
|
|
142 | break; |
|
|
143 | } |
|
|
144 | strncat (news + size, buf, HUGE_BUF - size); |
|
|
145 | size += strlen (buf); |
|
|
146 | } |
|
|
147 | } |
|
|
148 | |
|
|
149 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
|
|
150 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", (char *)"%s\n%s", subject, news); |
|
|
151 | close_and_delete (fp, comp); |
|
|
152 | } |
|
|
153 | |
|
|
154 | /* This loads the first map an puts the player on it. */ |
38 | /* This loads the first map an puts the player on it. */ |
155 | static void |
39 | static void |
156 | set_first_map (object *op) |
40 | set_first_map (object *op) |
157 | { |
41 | { |
158 | op->contr->maplevel = first_map_path; |
42 | op->contr->maplevel = first_map_path; |
… | |
… | |
252 | esrv_send_inventory (ob, ob); |
136 | esrv_send_inventory (ob, ob); |
253 | esrv_add_spells (this, 0); |
137 | esrv_add_spells (this, 0); |
254 | |
138 | |
255 | activate (); |
139 | activate (); |
256 | |
140 | |
257 | send_rules (ob); |
|
|
258 | send_news (ob); |
|
|
259 | display_motd (ob); |
|
|
260 | |
|
|
261 | INVOKE_PLAYER (CONNECT, this); |
141 | INVOKE_PLAYER (CONNECT, this); |
262 | INVOKE_PLAYER (LOGIN, this); |
142 | INVOKE_PLAYER (LOGIN, this); |
263 | } |
143 | } |
264 | |
144 | |
265 | void |
145 | void |
… | |
… | |
281 | ns->reset_stats (); |
161 | ns->reset_stats (); |
282 | ns->pl = 0; |
162 | ns->pl = 0; |
283 | ns = 0; |
163 | ns = 0; |
284 | } |
164 | } |
285 | |
165 | |
286 | observe = ob; |
166 | // this is important for the player scheduler to get the correct refcount |
|
|
167 | // when ns = 0 |
|
|
168 | observe = viewpoint = ob; |
287 | |
169 | |
288 | deactivate (); |
170 | deactivate (); |
289 | } |
171 | } |
290 | |
172 | |
291 | // the need for this function can be explained |
173 | // the need for this function can be explained |
292 | // by load_object not returning the object |
174 | // by load_object not returning the object |
293 | void |
175 | void |
294 | player::set_object (object *op) |
176 | player::set_object (object *op) |
295 | { |
177 | { |
296 | ob = observe = op; |
178 | ob = observe = viewpoint = op; |
297 | ob->contr = this; /* this aren't yet in archetype */ |
179 | ob->contr = this; /* this aren't yet in archetype */ |
298 | |
180 | |
299 | ob->speed = 1.0f; |
181 | ob->speed = 1.0f; |
300 | ob->speed_left = 0.5f; |
182 | ob->speed_left = 0.5f; |
301 | |
183 | |
… | |
… | |
330 | } |
212 | } |
331 | |
213 | |
332 | void |
214 | void |
333 | player::set_observe (object *op) |
215 | player::set_observe (object *op) |
334 | { |
216 | { |
335 | observe = op ? op : ob; |
217 | observe = viewpoint = op ? op : ob; |
|
|
218 | do_los = 1; |
|
|
219 | } |
|
|
220 | |
|
|
221 | void |
|
|
222 | player::set_viewpoint (object *op) |
|
|
223 | { |
|
|
224 | viewpoint = op ? op : (object *)observe; |
336 | do_los = 1; |
225 | do_los = 1; |
337 | } |
226 | } |
338 | |
227 | |
339 | player::player () |
228 | player::player () |
340 | { |
229 | { |
… | |
… | |
369 | { |
258 | { |
370 | ob->destroy_inv (false); |
259 | ob->destroy_inv (false); |
371 | ob->destroy (); |
260 | ob->destroy (); |
372 | } |
261 | } |
373 | |
262 | |
374 | ob = observe = 0; |
263 | ob = observe = viewpoint = 0; |
375 | } |
264 | } |
376 | |
265 | |
377 | player::~player () |
266 | player::~player () |
378 | { |
267 | { |
379 | /* Clear item stack */ |
268 | /* Clear item stack */ |
… | |
… | |
673 | op->destroy (); |
562 | op->destroy (); |
674 | continue; |
563 | continue; |
675 | } |
564 | } |
676 | } |
565 | } |
677 | |
566 | |
678 | /* This really needs to be better - we should really give |
567 | /* Here we remove duplicated skills (as duplicated spell objects have |
679 | * a substitute spellbook. The problem is that we don't really |
568 | * _very_ confusing effects for players), which could for instance be |
680 | * have a good idea what to replace it with (need something like |
569 | * generated by bad treasurelists. - elmex |
681 | * a first level treasurelist for each skill.) |
|
|
682 | * remove duplicate skills also |
|
|
683 | */ |
570 | */ |
684 | if (op->type == SPELLBOOK || op->type == SKILL) |
571 | if (op->type == SKILL) |
685 | { |
572 | { |
686 | object *tmp; |
|
|
687 | |
|
|
688 | for (tmp = op->below; tmp; tmp = tmp->below) |
573 | for (object *tmp = op->below; tmp; tmp = tmp->below) |
689 | if (tmp->type == op->type && tmp->name == op->name) |
574 | if (tmp->type == op->type && tmp->name == op->name) |
690 | break; |
|
|
691 | |
|
|
692 | if (tmp) |
|
|
693 | { |
575 | { |
694 | op->destroy (); |
576 | op->destroy (); |
|
|
577 | LOG (llevError, |
695 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
578 | "give_initial_items: Removing duplicate skill %s\n", &tmp->name); |
696 | continue; |
579 | break; |
697 | } |
580 | } |
698 | |
581 | |
699 | if (op->nrof > 1) |
582 | if (op->nrof > 1) |
700 | op->nrof = 1; |
583 | op->nrof = 1; |
701 | } |
584 | } |
702 | |
585 | |
… | |
… | |
1008 | CHK_PICK_PICKUP; |
891 | CHK_PICK_PICKUP; |
1009 | |
892 | |
1010 | continue; |
893 | continue; |
1011 | } |
894 | } |
1012 | |
895 | |
1013 | /* NEW pickup handling */ |
896 | /* pickup handling */ |
1014 | if (op->contr->mode & PU_DEBUG) |
897 | if (op->contr->mode & PU_DEBUG) |
1015 | { |
898 | { |
1016 | /* some debugging code to figure out item information */ |
899 | /* some debugging code to figure out item information */ |
1017 | const char *str = tmp->name |
900 | const char *str = tmp->name |
1018 | ? format ("item name: %s item type: %d weight/value: %d", |
901 | ? format ("item name: %s item type: %d weight/value: %d", |
… | |
… | |
1020 | : format ("item name: %s item type: %d weight/value: %d", |
903 | : format ("item name: %s item type: %d weight/value: %d", |
1021 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
904 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1022 | |
905 | |
1023 | new_draw_info (NDI_UNIQUE, 0, op, str); |
906 | new_draw_info (NDI_UNIQUE, 0, op, str); |
1024 | } |
907 | } |
|
|
908 | |
|
|
909 | if (op->contr->mode & PU_INHIBIT) |
|
|
910 | return 1; |
|
|
911 | |
|
|
912 | if (!(op->contr->mode & PU_ENABLE)) // TODO: fix client |
|
|
913 | return 1; |
1025 | |
914 | |
1026 | /* philosophy: |
915 | /* philosophy: |
1027 | * It's easy to grab an item type from a pile, as long as it's |
916 | * It's easy to grab an item type from a pile, as long as it's |
1028 | * generic. This takes no game-time. For more detailed pickups |
917 | * generic. This takes no game-time. For more detailed pickups |
1029 | * and selections, select-items should be used. This is a |
918 | * and selections, select-items should be used. This is a |
… | |
… | |
1037 | /* the first two modes are exclusive: if NOTHING we return, if |
926 | /* the first two modes are exclusive: if NOTHING we return, if |
1038 | * STOP then we stop. All the rest are applied sequentially, |
927 | * STOP then we stop. All the rest are applied sequentially, |
1039 | * meaning if any test passes, the item gets picked up. */ |
928 | * meaning if any test passes, the item gets picked up. */ |
1040 | |
929 | |
1041 | /* if mode is set to pick nothing up, return */ |
930 | /* if mode is set to pick nothing up, return */ |
1042 | if (op->contr->mode & PU_NOTHING) |
931 | if (op->contr->mode == PU_NOTHING) |
1043 | return 1; |
932 | return 1; |
1044 | |
933 | |
1045 | /* if mode is set to stop when encountering objects, return */ |
934 | /* if mode is set to stop when encountering objects, return */ |
1046 | /* take STOP before INHIBIT since it doesn't actually pick |
935 | /* take STOP before INHIBIT since it doesn't actually pick |
1047 | * anything up */ |
936 | * anything up */ |
… | |
… | |
1215 | } |
1104 | } |
1216 | |
1105 | |
1217 | /* careful: chairs and tables are weapons! */ |
1106 | /* careful: chairs and tables are weapons! */ |
1218 | if (op->contr->mode & PU_ALLWEAPON) |
1107 | if (op->contr->mode & PU_ALLWEAPON) |
1219 | { |
1108 | { |
1220 | if (tmp->type == WEAPON && tmp->name != NULL) |
1109 | if (tmp->type == WEAPON) |
1221 | { |
1110 | if (!tmp->arch->archname.contains ("table") && !tmp->arch->archname.contains ("chair")) |
1222 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
|
|
1223 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
|
|
1224 | { |
1111 | { |
1225 | CHK_PICK_PICKUP; |
1112 | CHK_PICK_PICKUP; |
1226 | continue; |
1113 | continue; |
1227 | } |
1114 | } |
1228 | } |
|
|
1229 | |
|
|
1230 | if (tmp->type == WEAPON && tmp->name == NULL) |
|
|
1231 | { |
|
|
1232 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
|
|
1233 | { |
|
|
1234 | CHK_PICK_PICKUP; |
|
|
1235 | continue; |
|
|
1236 | } |
|
|
1237 | } |
|
|
1238 | } |
1115 | } |
1239 | |
1116 | |
1240 | /* misc stuff that's useful */ |
1117 | /* misc stuff that's useful */ |
1241 | if (op->contr->mode & PU_KEY) |
1118 | if (op->contr->mode & PU_KEY) |
1242 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1119 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
… | |
… | |
1304 | * against the target. A full test is not performed, simply a basic test |
1181 | * against the target. A full test is not performed, simply a basic test |
1305 | * of resistances. The archer is making a quick guess at what he sees down |
1182 | * of resistances. The archer is making a quick guess at what he sees down |
1306 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1183 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1307 | */ |
1184 | */ |
1308 | object * |
1185 | object * |
1309 | find_better_arrow (object *op, object *target, const char *type, int *better) |
1186 | find_better_arrow (object *op, object *target, shstr_cmp type, int *better) |
1310 | { |
1187 | { |
1311 | object *tmp = NULL, *arrow, *ntmp; |
1188 | object *tmp = NULL, *arrow, *ntmp; |
1312 | int attacknum, attacktype, betterby = 0, i; |
1189 | int attacknum, attacktype, betterby = 0, i; |
1313 | |
1190 | |
1314 | if (!type) |
1191 | if (!type) |
… | |
… | |
1318 | { |
1195 | { |
1319 | if (arrow->type == CONTAINER && arrow->race == type && QUERY_FLAG (arrow, FLAG_APPLIED)) |
1196 | if (arrow->type == CONTAINER && arrow->race == type && QUERY_FLAG (arrow, FLAG_APPLIED)) |
1320 | { |
1197 | { |
1321 | i = 0; |
1198 | i = 0; |
1322 | ntmp = find_better_arrow (arrow, target, type, &i); |
1199 | ntmp = find_better_arrow (arrow, target, type, &i); |
|
|
1200 | |
1323 | if (i > betterby) |
1201 | if (i > betterby) |
1324 | { |
1202 | { |
1325 | tmp = ntmp; |
1203 | tmp = ntmp; |
1326 | betterby = i; |
1204 | betterby = i; |
1327 | } |
1205 | } |
1328 | } |
1206 | } |
1329 | else if (arrow->type == ARROW && arrow->race == type) |
1207 | else if (arrow->type == ARROW && arrow->race == type) |
1330 | { |
1208 | { |
1331 | /* allways prefer assasination/slaying */ |
1209 | /* allways prefer assasination/slaying */ |
1332 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1210 | if (target->race && arrow->slaying.contains (target->race)) |
1333 | { |
1211 | { |
1334 | if (arrow->attacktype & AT_DEATH) |
1212 | if (arrow->attacktype & AT_DEATH) |
1335 | { |
1213 | { |
1336 | *better = 100; |
1214 | *better = 100; |
1337 | return arrow; |
1215 | return arrow; |
… | |
… | |
1352 | { |
1230 | { |
1353 | tmp = arrow; |
1231 | tmp = arrow; |
1354 | betterby = (arrow->magic + arrow->stats.dam) * (100 - target->arch->resist[attacknum]) / 100; |
1232 | betterby = (arrow->magic + arrow->stats.dam) * (100 - target->arch->resist[attacknum]) / 100; |
1355 | } |
1233 | } |
1356 | } |
1234 | } |
|
|
1235 | |
1357 | if ((2 + arrow->magic + arrow->stats.dam) > betterby) |
1236 | if ((2 + arrow->magic + arrow->stats.dam) > betterby) |
1358 | { |
1237 | { |
1359 | tmp = arrow; |
1238 | tmp = arrow; |
1360 | betterby = 2 + arrow->magic + arrow->stats.dam; |
1239 | betterby = 2 + arrow->magic + arrow->stats.dam; |
1361 | } |
1240 | } |
|
|
1241 | |
1362 | if (arrow->title && (1 + arrow->magic + arrow->stats.dam) > betterby) |
1242 | if (arrow->title && (1 + arrow->magic + arrow->stats.dam) > betterby) |
1363 | { |
1243 | { |
1364 | tmp = arrow; |
1244 | tmp = arrow; |
1365 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1245 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1366 | } |
1246 | } |
… | |
… | |
1380 | * op = the shooter |
1260 | * op = the shooter |
1381 | * type = bow->race |
1261 | * type = bow->race |
1382 | * dir = fire direction |
1262 | * dir = fire direction |
1383 | */ |
1263 | */ |
1384 | object * |
1264 | object * |
1385 | pick_arrow_target (object *op, const char *type, int dir) |
1265 | pick_arrow_target (object *op, shstr_cmp type, int dir) |
1386 | { |
1266 | { |
1387 | object *tmp = NULL; |
1267 | object *tmp = NULL; |
1388 | maptile *m; |
1268 | maptile *m; |
1389 | int i, mflags, found, number; |
1269 | int i, mflags, found, number; |
1390 | sint16 x, y; |
1270 | sint16 x, y; |
… | |
… | |
1476 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1356 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1477 | return 0; |
1357 | return 0; |
1478 | } |
1358 | } |
1479 | |
1359 | |
1480 | // optimisation: move object to top so we will find it quickly again |
1360 | // optimisation: move object to top so we will find it quickly again |
1481 | if (bow->below) |
1361 | splay (bow); |
1482 | { |
|
|
1483 | bow->remove (); |
|
|
1484 | op->insert (bow); |
|
|
1485 | } |
|
|
1486 | } |
1362 | } |
1487 | |
1363 | |
1488 | if (!bow->race || !bow->skill) |
1364 | if (!bow->race || !bow->skill) |
1489 | { |
1365 | { |
1490 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1366 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
… | |
… | |
1536 | arrow->direction = dir; |
1412 | arrow->direction = dir; |
1537 | |
1413 | |
1538 | arrow->stats.sp = arrow->stats.wc; /* save original wc, dam, attacktype and slaying */ |
1414 | arrow->stats.sp = arrow->stats.wc; /* save original wc, dam, attacktype and slaying */ |
1539 | arrow->stats.hp = arrow->stats.dam; |
1415 | arrow->stats.hp = arrow->stats.dam; |
1540 | arrow->stats.grace = arrow->attacktype; |
1416 | arrow->stats.grace = arrow->attacktype; |
1541 | |
1417 | arrow->custom_name = arrow->slaying; |
1542 | if (arrow->slaying) |
|
|
1543 | arrow->spellarg = strdup (arrow->slaying); |
|
|
1544 | |
1418 | |
1545 | #if 0 |
1419 | #if 0 |
1546 | if (player *pl = op->contr) |
1420 | if (player *pl = op->contr) |
1547 | { |
1421 | { |
1548 | float speed = pl->weapon_sp; |
1422 | float speed = pl->weapon_sp; |
… | |
… | |
1762 | case BOW: |
1636 | case BOW: |
1763 | player_fire_bow (op, dir); |
1637 | player_fire_bow (op, dir); |
1764 | break; |
1638 | break; |
1765 | |
1639 | |
1766 | case SPELL: |
1640 | case SPELL: |
1767 | spellcost = cast_spell (op, op, dir, ob, pl->spellparam[0] ? pl->spellparam : 0); |
1641 | spellcost = cast_spell (op, op, dir, ob, *pl->spellparam ? pl->spellparam : 0); |
1768 | break; |
1642 | break; |
1769 | |
1643 | |
1770 | case BUILDER: |
1644 | case BUILDER: |
1771 | apply_map_builder (op, dir); |
1645 | apply_map_builder (op, dir); |
1772 | break; |
1646 | break; |
… | |
… | |
1781 | } |
1655 | } |
1782 | |
1656 | |
1783 | return true; |
1657 | return true; |
1784 | } |
1658 | } |
1785 | |
1659 | |
1786 | /* find_key |
1660 | static object * |
1787 | * We try to find a key for the door as passed. If we find a key |
|
|
1788 | * and successfully use it, we return the key, otherwise NULL |
|
|
1789 | * This function merges both normal and locked door, since the logic |
|
|
1790 | * for both is the same - just the specific key is different. |
|
|
1791 | * pl is the player, |
|
|
1792 | * inv is the objects inventory to searched |
|
|
1793 | * door is the door we are trying to match against. |
|
|
1794 | * This function can be called recursively to search containers. |
|
|
1795 | */ |
|
|
1796 | object * |
|
|
1797 | find_key (object *pl, object *container, object *door) |
1661 | find_key_ (object *pl, object *container, object *door) |
1798 | { |
1662 | { |
1799 | object *tmp, *key; |
1663 | object *tmp, *key; |
1800 | |
1664 | |
1801 | /* Should not happen, but sanity checking is never bad */ |
1665 | /* Should not happen, but sanity checking is never bad */ |
1802 | if (!container->inv) |
1666 | if (!container->inv) |
… | |
… | |
1805 | /* First, lets try to find a key in the top level inventory */ |
1669 | /* First, lets try to find a key in the top level inventory */ |
1806 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1670 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1807 | { |
1671 | { |
1808 | if (door->type == DOOR && tmp->type == KEY) |
1672 | if (door->type == DOOR && tmp->type == KEY) |
1809 | break; |
1673 | break; |
|
|
1674 | |
1810 | /* For sanity, we should really check door type, but other stuff |
1675 | /* For sanity, we should really check door type, but other stuff |
1811 | * (like containers) can be locked with special keys |
1676 | * (like containers) can be locked with special keys |
1812 | */ |
1677 | */ |
1813 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1678 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1814 | break; |
1679 | break; |
… | |
… | |
1820 | * a key, return |
1685 | * a key, return |
1821 | */ |
1686 | */ |
1822 | if (!tmp) |
1687 | if (!tmp) |
1823 | { |
1688 | { |
1824 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1689 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1825 | { |
|
|
1826 | /* No reason to search empty containers */ |
1690 | /* No reason to search empty containers */ |
1827 | if (tmp->type == CONTAINER && tmp->inv) |
1691 | if (tmp->type == CONTAINER && tmp->inv) |
1828 | { |
|
|
1829 | if ((key = find_key (pl, tmp, door))) |
1692 | if ((key = find_key_ (pl, tmp, door))) |
1830 | return key; |
1693 | return key; |
1831 | } |
|
|
1832 | } |
|
|
1833 | |
1694 | |
1834 | if (!tmp) |
1695 | if (!tmp) |
1835 | return NULL; |
1696 | return 0; |
1836 | } |
1697 | } |
1837 | |
1698 | |
1838 | /* We get down here if we have found a key. Now if its in a container, |
1699 | /* We get down here if we have found a key. Now if its in a container, |
1839 | * see if we actually want to use it |
1700 | * see if we actually want to use it |
1840 | */ |
1701 | */ |
1841 | if (pl != container) |
1702 | if (pl != container) |
1842 | { |
1703 | { |
1843 | /* Only let players use keys in containers */ |
1704 | /* Only let players use keys in containers */ |
1844 | if (!pl->contr) |
1705 | if (!pl->contr) |
1845 | return NULL; |
1706 | return 0; |
|
|
1707 | |
1846 | /* cases where this fails: |
1708 | /* cases where this fails: |
1847 | * If we only search the player inventory, return now since we |
1709 | * If we only search the player inventory, return now since we |
1848 | * are not in the players inventory. |
1710 | * are not in the players inventory. |
1849 | * If the container is not active, return now since only active |
1711 | * If the container is not active, return now since only active |
1850 | * containers can be used. |
1712 | * containers can be used. |
… | |
… | |
1854 | * inv must have been an container and must have been active. |
1716 | * inv must have been an container and must have been active. |
1855 | * |
1717 | * |
1856 | * Change the color so that the message doesn't disappear with |
1718 | * Change the color so that the message doesn't disappear with |
1857 | * all the others. |
1719 | * all the others. |
1858 | */ |
1720 | */ |
1859 | if (pl->contr->usekeys == key_inventory || |
1721 | if (pl->contr->usekeys == key_inventory |
1860 | !QUERY_FLAG (container, FLAG_APPLIED) || |
1722 | || !QUERY_FLAG (container, FLAG_APPLIED) |
1861 | (pl->contr->usekeys == keyrings && (!container->race || strcmp (container->race, "keys")))) |
1723 | || (pl->contr->usekeys == keyrings && container->race != shstr_keys)) |
1862 | { |
1724 | { |
1863 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1725 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1864 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1726 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1865 | return NULL; |
1727 | return NULL; |
1866 | } |
1728 | } |
1867 | } |
1729 | } |
1868 | |
1730 | |
1869 | return tmp; |
1731 | return tmp; |
|
|
1732 | } |
|
|
1733 | |
|
|
1734 | /* find_key |
|
|
1735 | * We try to find a key for the door as passed. If we find a key |
|
|
1736 | * and successfully use it, we return the key, otherwise NULL |
|
|
1737 | * This function merges both normal and locked door, since the logic |
|
|
1738 | * for both is the same - just the specific key is different. |
|
|
1739 | * pl is the player, |
|
|
1740 | * inv is the objects inventory to searched |
|
|
1741 | * door is the door we are trying to match against. |
|
|
1742 | * This function can be called recursively to search containers. |
|
|
1743 | */ |
|
|
1744 | object * |
|
|
1745 | find_key (object *pl, object *container, object *door) |
|
|
1746 | { |
|
|
1747 | if (door->slaying && is_match_expr (door->slaying)) |
|
|
1748 | { |
|
|
1749 | // for match expressions, we try to find the key by applying the match |
|
|
1750 | // to the op itself, which is supposed to find the "key", instead |
|
|
1751 | // of searching through containers ourselves. |
|
|
1752 | |
|
|
1753 | return match_one (door->slaying, container, door, pl, pl); |
|
|
1754 | } |
|
|
1755 | else |
|
|
1756 | return find_key_ (pl, container, door); |
1870 | } |
1757 | } |
1871 | |
1758 | |
1872 | /* moved door processing out of move_player_attack. |
1759 | /* moved door processing out of move_player_attack. |
1873 | * returns 1 if player has opened the door with a key |
1760 | * returns 1 if player has opened the door with a key |
1874 | * such that the caller should not do anything more, |
1761 | * such that the caller should not do anything more, |
… | |
… | |
1924 | * going to try and move (not fire weapons). |
1811 | * going to try and move (not fire weapons). |
1925 | */ |
1812 | */ |
1926 | bool |
1813 | bool |
1927 | move_player_attack (object *op, int dir) |
1814 | move_player_attack (object *op, int dir) |
1928 | { |
1815 | { |
|
|
1816 | if (!op->contr->braced && op->speed_left > 0.f && move_ob (op, dir, op)) |
|
|
1817 | { |
|
|
1818 | --op->speed_left; |
|
|
1819 | return true; |
|
|
1820 | } |
|
|
1821 | |
1929 | int on_battleground; |
1822 | int on_battleground; |
1930 | |
1823 | |
1931 | sint16 nx = freearr_x[dir] + op->x; |
1824 | sint16 nx = freearr_x[dir] + op->x; |
1932 | sint16 ny = freearr_y[dir] + op->y; |
1825 | sint16 ny = freearr_y[dir] + op->y; |
1933 | |
1826 | |
1934 | on_battleground = op_on_battleground (op, 0, 0); |
1827 | on_battleground = op_on_battleground (op, 0, 0); |
1935 | |
1828 | |
1936 | if (out_of_map (op->map, nx, ny)) |
1829 | if (out_of_map (op->map, nx, ny)) |
1937 | return false; |
1830 | return false; |
1938 | |
|
|
1939 | if (!op->contr->braced && op->speed_left > 0.f && move_ob (op, dir, op)) |
|
|
1940 | { |
|
|
1941 | --op->speed_left; |
|
|
1942 | return true; |
|
|
1943 | } |
|
|
1944 | |
1831 | |
1945 | /* If braced, or can't move to the square, and it is not out of the |
1832 | /* If braced, or can't move to the square, and it is not out of the |
1946 | * map, attack it. Note order of if statement is important - don't |
1833 | * map, attack it. Note order of if statement is important - don't |
1947 | * want to be calling move_ob if braced, because move_ob will move the |
1834 | * want to be calling move_ob if braced, because move_ob will move the |
1948 | * player. This is a pretty nasty hack, because if we could |
1835 | * player. This is a pretty nasty hack, because if we could |
… | |
… | |
2525 | */ |
2412 | */ |
2526 | void |
2413 | void |
2527 | kill_player (object *op) |
2414 | kill_player (object *op) |
2528 | { |
2415 | { |
2529 | int x, y; |
2416 | int x, y; |
2530 | char buf[MAX_BUF]; |
|
|
2531 | maptile *map; /* this is for resurrection */ |
2417 | maptile *map; /* this is for resurrection */ |
2532 | int will_kill_again; |
2418 | int will_kill_again; |
2533 | archetype *at; |
2419 | archetype *at; |
2534 | object *tmp; |
2420 | object *tmp; |
2535 | |
2421 | |
2536 | if (save_life (op)) |
2422 | if (save_life (op)) |
2537 | return; |
2423 | return; |
|
|
2424 | |
|
|
2425 | dynbuf_text deathtab; |
|
|
2426 | |
|
|
2427 | /* restore player */ |
|
|
2428 | at = archetype::find ("poisoning"); |
|
|
2429 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2430 | { |
|
|
2431 | tmp->destroy (); |
|
|
2432 | deathtab << "Your body feels cleansed...\r"; |
|
|
2433 | } |
|
|
2434 | |
|
|
2435 | at = archetype::find ("confusion"); |
|
|
2436 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2437 | { |
|
|
2438 | tmp->destroy (); |
|
|
2439 | deathtab << "Your mind feels clearer...\r"; |
|
|
2440 | } |
|
|
2441 | |
|
|
2442 | cure_disease (op, 0, 0); /* remove any disease */ |
|
|
2443 | |
|
|
2444 | max_it (op->stats.hp , op->stats.maxhp); |
|
|
2445 | max_it (op->stats.sp , op->stats.maxsp); |
|
|
2446 | max_it (op->stats.grace, op->stats.maxgrace); |
|
|
2447 | |
|
|
2448 | if (op->stats.food <= 0) |
|
|
2449 | op->stats.food = 999; |
|
|
2450 | |
|
|
2451 | // remove all spell effects that are active |
|
|
2452 | // to avoid long-term effects such as word-of-recall |
|
|
2453 | for (object *item = op->inv; item; ) |
|
|
2454 | { |
|
|
2455 | object *next = item->below; |
|
|
2456 | |
|
|
2457 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2458 | item->destroy (); |
|
|
2459 | |
|
|
2460 | item = next; |
|
|
2461 | } |
2538 | |
2462 | |
2539 | /* If player dies on BATTLEGROUND, no stat/exp loss! For Combat-Arenas |
2463 | /* If player dies on BATTLEGROUND, no stat/exp loss! For Combat-Arenas |
2540 | * in cities ONLY!!! It is very important that this doesn't get abused. |
2464 | * in cities ONLY!!! It is very important that this doesn't get abused. |
2541 | * Look at op_on_battleground() for more info --AndreasV |
2465 | * Look at op_on_battleground() for more info --AndreasV |
2542 | */ |
2466 | */ |
2543 | if (op_on_battleground (op, &x, &y)) |
2467 | if (op_on_battleground (op, &x, &y)) |
2544 | { |
2468 | { |
2545 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2469 | deathtab << "You almost died in combat, but local medics have saved your life...\r"; |
2546 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
|
|
2547 | |
|
|
2548 | /* restore player */ |
|
|
2549 | at = archetype::find ("poisoning"); |
|
|
2550 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2551 | { |
|
|
2552 | tmp->destroy (); |
|
|
2553 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
2554 | } |
|
|
2555 | |
|
|
2556 | at = archetype::find ("confusion"); |
|
|
2557 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2558 | { |
|
|
2559 | tmp->destroy (); |
|
|
2560 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
|
|
2561 | } |
|
|
2562 | |
|
|
2563 | cure_disease (op, 0, 0); /* remove any disease */ |
|
|
2564 | op->stats.hp = op->stats.maxhp; |
|
|
2565 | if (op->stats.food <= 0) |
|
|
2566 | op->stats.food = 999; |
|
|
2567 | |
2470 | |
2568 | /* create a bodypart-trophy to make the winner happy */ |
2471 | /* create a bodypart-trophy to make the winner happy */ |
2569 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2472 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2570 | { |
2473 | { |
2571 | tmp->name = format ("%s's finger" , &op->name); |
2474 | tmp->name = format ("%s's finger" , &op->name); |
… | |
… | |
2582 | } |
2485 | } |
2583 | |
2486 | |
2584 | /* teleport defeated player to new destination */ |
2487 | /* teleport defeated player to new destination */ |
2585 | transfer_ob (op, x, y, 0, NULL); |
2488 | transfer_ob (op, x, y, 0, NULL); |
2586 | op->contr->braced = 0; |
2489 | op->contr->braced = 0; |
|
|
2490 | |
|
|
2491 | op->contr->infobox (MSG_CHANNEL ("death"), deathtab); |
2587 | return; |
2492 | return; |
2588 | } |
2493 | } |
|
|
2494 | |
|
|
2495 | deathtab << "You were killed by " << op->contr->killer_name () << ".\n\n"; |
|
|
2496 | deathtab << "T<YOU HAVE DIED>\n\n"; |
2589 | |
2497 | |
2590 | INVOKE_PLAYER (DEATH, op->contr); |
2498 | INVOKE_PLAYER (DEATH, op->contr); |
2591 | |
2499 | |
2592 | command_kill_pets (op, 0); |
2500 | command_kill_pets (op, 0); |
2593 | |
2501 | |
… | |
… | |
2688 | } |
2596 | } |
2689 | } |
2597 | } |
2690 | |
2598 | |
2691 | if (lose_this_stat) |
2599 | if (lose_this_stat) |
2692 | { |
2600 | { |
2693 | this_stat = get_attr_value (&(dep->stats), i); |
2601 | this_stat = get_attr_value (&dep->stats, i); |
2694 | /* We could try to do something clever like find another |
2602 | /* We could try to do something clever like find another |
2695 | * stat to reduce if this fails. But chances are, if |
2603 | * stat to reduce if this fails. But chances are, if |
2696 | * stats have been depleted to -50, all are pretty low |
2604 | * stats have been depleted to -50, all are pretty low |
2697 | * and should be roughly the same, so it shouldn't make a |
2605 | * and should be roughly the same, so it shouldn't make a |
2698 | * difference. |
2606 | * difference. |
… | |
… | |
2712 | /* If no stat lost, tell the player. */ |
2620 | /* If no stat lost, tell the player. */ |
2713 | if (!lost_a_stat) |
2621 | if (!lost_a_stat) |
2714 | { |
2622 | { |
2715 | /* determine_god() seems to not work sometimes... why is this? |
2623 | /* determine_god() seems to not work sometimes... why is this? |
2716 | Should I be using something else? GD */ |
2624 | Should I be using something else? GD */ |
2717 | const char *god = determine_god (op); |
2625 | shstr_tmp god = determine_god (op); |
2718 | |
2626 | |
2719 | if (god && (strcmp (god, "none"))) |
2627 | if (god != shstr_none) |
2720 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2628 | deathtab << "For a brief moment you feel the holy presence of " << god << " protecting you.\r"; |
2721 | else |
2629 | else |
2722 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2630 | deathtab << "For a brief moment you feel a holy presence protecting you.\r"; |
2723 | } |
2631 | } |
2724 | #else |
2632 | #else |
2725 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely."); |
2633 | deathtab << "For a brief moment you feel a holy presence protecting you from losing yourself completely."; |
2726 | #endif |
2634 | #endif |
2727 | |
2635 | |
2728 | /* Put a gravestone up where the character 'almost' died. List the |
2636 | /* Put a gravestone up where the character 'almost' died. List the |
2729 | * exp loss on the stone. |
2637 | * exp loss on the stone. |
2730 | */ |
2638 | */ |
… | |
… | |
2737 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2645 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2738 | |
2646 | |
2739 | /**************************************/ |
2647 | /**************************************/ |
2740 | /* */ |
2648 | /* */ |
2741 | /* Subtract the experience points, */ |
2649 | /* Subtract the experience points, */ |
2742 | /* if we died cause of food, give us */ |
|
|
2743 | /* food, and reset HP's... */ |
|
|
2744 | /* */ |
2650 | /* */ |
2745 | /**************************************/ |
2651 | /**************************************/ |
2746 | |
2652 | |
2747 | /* remove any poisoning and confusion the character may be suffering. */ |
|
|
2748 | /* restore player */ |
|
|
2749 | at = archetype::find ("poisoning"); |
|
|
2750 | tmp = present_arch_in_ob (at, op); |
|
|
2751 | |
|
|
2752 | if (tmp) |
|
|
2753 | { |
|
|
2754 | tmp->destroy (); |
|
|
2755 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
2756 | } |
|
|
2757 | |
|
|
2758 | at = archetype::find ("confusion"); |
|
|
2759 | tmp = present_arch_in_ob (at, op); |
|
|
2760 | if (tmp) |
|
|
2761 | { |
|
|
2762 | tmp->destroy (); |
|
|
2763 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
|
|
2764 | } |
|
|
2765 | |
|
|
2766 | cure_disease (op, 0, 0); /* remove any disease */ |
|
|
2767 | |
|
|
2768 | // remove all spell effects that are active |
|
|
2769 | // to avoid long-term effects such as word-of-recall |
|
|
2770 | for (object *item = op->inv; item; ) |
|
|
2771 | { |
|
|
2772 | object *next = item->below; |
|
|
2773 | |
|
|
2774 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2775 | item->destroy (); |
|
|
2776 | |
|
|
2777 | item = next; |
|
|
2778 | } |
|
|
2779 | |
|
|
2780 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2653 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2781 | apply_death_exp_penalty (op); |
2654 | apply_death_exp_penalty (op); |
2782 | |
|
|
2783 | if (op->stats.food < 100) |
|
|
2784 | op->stats.food = 900; |
|
|
2785 | |
|
|
2786 | op->stats.hp = op->stats.maxhp; |
|
|
2787 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
|
|
2788 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
|
|
2789 | |
2655 | |
2790 | /* |
2656 | /* |
2791 | * Check to see if the player has any unpaid items. If so, remove them |
2657 | * Check to see if the player has any unpaid items. If so, remove them |
2792 | * and put them back in the map. |
2658 | * and put them back in the map. |
2793 | */ |
2659 | */ |
… | |
… | |
2830 | |
2696 | |
2831 | insert_ob_in_ob (force, op); |
2697 | insert_ob_in_ob (force, op); |
2832 | op->update_stats (); |
2698 | op->update_stats (); |
2833 | } |
2699 | } |
2834 | |
2700 | |
2835 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2701 | op->contr->infobox (MSG_CHANNEL ("death"), deathtab); |
2836 | } |
2702 | } |
2837 | |
2703 | |
2838 | void |
2704 | void |
2839 | loot_object (object *op) |
2705 | loot_object (object *op) |
2840 | { /* Grab and destroy some treasure */ |
2706 | { /* Grab and destroy some treasure */ |
… | |
… | |
2978 | level = ob->map->darklevel () - 2; |
2844 | level = ob->map->darklevel () - 2; |
2979 | |
2845 | |
2980 | /* this also picks up whether the object is glowing. |
2846 | /* this also picks up whether the object is glowing. |
2981 | * If you carry a light on a non-dark map, its not |
2847 | * If you carry a light on a non-dark map, its not |
2982 | * as bad as carrying a light on a pitch dark map */ |
2848 | * as bad as carrying a light on a pitch dark map */ |
2983 | if (has_carried_lights (ob)) |
2849 | if (ob->has_carried_lights ()) |
2984 | level = -(10 + (2 * ob->map->darklevel ())); |
2850 | level = -(10 + (2 * ob->map->darklevel ())); |
2985 | |
2851 | |
2986 | /* scan through all nearby squares for terrain to hide in */ |
2852 | /* scan through all nearby squares for terrain to hide in */ |
2987 | for (i = 0, x = ob->x, y = ob->y; |
2853 | for (i = 0, x = ob->x, y = ob->y; |
2988 | i <= SIZEOFFREE1; |
2854 | i <= SIZEOFFREE1; |