1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_player_c = |
|
|
4 | * "$Id: player.C,v 1.18 2006/09/10 15:59:57 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The author can be reached via e-mail to crossfire-devel@real-time.com |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #include <global.h> |
24 | #include <global.h> |
31 | #ifndef WIN32 /* ---win32 remove headers */ |
|
|
32 | # include <pwd.h> |
25 | #include <pwd.h> |
33 | #endif |
|
|
34 | #ifndef __CEXTRACT__ |
|
|
35 | # include <sproto.h> |
26 | #include <sproto.h> |
36 | #endif |
|
|
37 | #include <sounds.h> |
27 | #include <sounds.h> |
38 | #include <living.h> |
28 | #include <living.h> |
39 | #include <object.h> |
29 | #include <object.h> |
40 | #include <spells.h> |
30 | #include <spells.h> |
41 | #include <skills.h> |
31 | #include <skills.h> |
42 | #include <newclient.h> |
|
|
43 | |
32 | |
44 | #ifdef COZY_SERVER |
33 | #ifdef COZY_SERVER |
45 | extern int same_party (partylist *a, partylist *b); |
34 | extern int same_party (partylist *a, partylist *b); |
46 | #endif |
35 | #endif |
47 | |
36 | |
… | |
… | |
93 | int comp; |
82 | int comp; |
94 | int size; |
83 | int size; |
95 | |
84 | |
96 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
85 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
97 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
86 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
98 | { |
|
|
99 | return; |
87 | return; |
100 | } |
88 | |
101 | motd[0] = '\0'; |
89 | motd[0] = '\0'; |
102 | size = 0; |
90 | size = 0; |
|
|
91 | |
103 | while (fgets (buf, MAX_BUF, fp) != NULL) |
92 | while (fgets (buf, MAX_BUF, fp) != NULL) |
104 | { |
93 | { |
105 | if (*buf == '#') |
94 | if (*buf == '#') |
106 | continue; |
95 | continue; |
|
|
96 | |
107 | strncat (motd + size, buf, HUGE_BUF - size); |
97 | strncat (motd + size, buf, HUGE_BUF - size); |
108 | size += strlen (buf); |
98 | size += strlen (buf); |
109 | } |
99 | } |
|
|
100 | |
110 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
101 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
111 | close_and_delete (fp, comp); |
102 | close_and_delete (fp, comp); |
112 | } |
103 | } |
113 | |
104 | |
114 | void |
105 | void |
… | |
… | |
120 | int comp; |
111 | int comp; |
121 | int size; |
112 | int size; |
122 | |
113 | |
123 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
114 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
124 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
115 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
125 | { |
|
|
126 | return; |
116 | return; |
127 | } |
117 | |
128 | rules[0] = '\0'; |
118 | rules[0] = '\0'; |
129 | size = 0; |
119 | size = 0; |
|
|
120 | |
130 | while (fgets (buf, MAX_BUF, fp) != NULL) |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
131 | { |
122 | { |
132 | if (*buf == '#') |
123 | if (*buf == '#') |
133 | continue; |
124 | continue; |
|
|
125 | |
134 | if (size + strlen (buf) >= HUGE_BUF) |
126 | if (size + strlen (buf) >= HUGE_BUF) |
135 | { |
127 | { |
136 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
128 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
137 | break; |
129 | break; |
138 | } |
130 | } |
|
|
131 | |
139 | strncat (rules + size, buf, HUGE_BUF - size); |
132 | strncat (rules + size, buf, HUGE_BUF - size); |
140 | size += strlen (buf); |
133 | size += strlen (buf); |
141 | } |
134 | } |
|
|
135 | |
142 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
136 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
143 | close_and_delete (fp, comp); |
137 | close_and_delete (fp, comp); |
144 | } |
138 | } |
145 | |
139 | |
146 | void |
140 | void |
… | |
… | |
154 | int size; |
148 | int size; |
155 | |
149 | |
156 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
150 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
157 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
151 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
158 | return; |
152 | return; |
|
|
153 | |
159 | news[0] = '\0'; |
154 | news[0] = '\0'; |
160 | subject[0] = '\0'; |
155 | subject[0] = '\0'; |
161 | size = 0; |
156 | size = 0; |
|
|
157 | |
162 | while (fgets (buf, MAX_BUF, fp) != NULL) |
158 | while (fgets (buf, MAX_BUF, fp) != NULL) |
163 | { |
159 | { |
164 | if (*buf == '#') |
160 | if (*buf == '#') |
165 | continue; |
161 | continue; |
|
|
162 | |
166 | if (*buf == '%') |
163 | if (*buf == '%') |
167 | { /* send one news */ |
164 | { /* send one news */ |
168 | if (size > 0) |
165 | if (size > 0) |
169 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
166 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
170 | strcpy (subject, buf + 1); |
167 | strcpy (subject, buf + 1); |
… | |
… | |
197 | return 0; |
194 | return 0; |
198 | |
195 | |
199 | for (; *cp != '\0'; cp++) |
196 | for (; *cp != '\0'; cp++) |
200 | if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') |
197 | if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') |
201 | return 0; |
198 | return 0; |
|
|
199 | |
202 | return 1; |
200 | return 1; |
203 | } |
201 | } |
204 | |
202 | |
205 | /* This no longer sets the player map. Also, it now updates |
203 | /* This no longer sets the player map. Also, it now updates |
206 | * all the pointers so the caller doesn't need to do that. |
204 | * all the pointers so the caller doesn't need to do that. |
… | |
… | |
214 | * the one that is passed. |
212 | * the one that is passed. |
215 | */ |
213 | */ |
216 | static player * |
214 | static player * |
217 | get_player (player *p) |
215 | get_player (player *p) |
218 | { |
216 | { |
219 | object *op = arch_to_object (get_player_archetype (NULL)); |
217 | object *op = arch_to_object (get_player_archetype (0)); |
220 | int i; |
218 | int i; |
221 | |
|
|
222 | if (!p) |
|
|
223 | { |
|
|
224 | p = new player; |
|
|
225 | |
|
|
226 | /* This adds the player in the linked list. There is extra |
|
|
227 | * complexity here because we want to add the new player at the |
|
|
228 | * end of the list - there is in fact no compelling reason that |
|
|
229 | * that needs to be done except for things like output of |
|
|
230 | * 'who'. |
|
|
231 | */ |
|
|
232 | player *tmp = first_player; |
|
|
233 | |
|
|
234 | while (tmp != NULL && tmp->next != NULL) |
|
|
235 | tmp = tmp->next; |
|
|
236 | if (tmp != NULL) |
|
|
237 | tmp->next = p; |
|
|
238 | else |
|
|
239 | first_player = p; |
|
|
240 | |
|
|
241 | p->next = NULL; |
|
|
242 | } |
|
|
243 | |
219 | |
244 | /* Clears basically the entire player structure except |
220 | /* Clears basically the entire player structure except |
245 | * for next and socket. |
221 | * for next and socket. |
246 | */ |
222 | */ |
247 | p->clear (); |
223 | p->clear (); |
… | |
… | |
266 | op->speed_left = 0.5; |
242 | op->speed_left = 0.5; |
267 | op->speed = 1.0; |
243 | op->speed = 1.0; |
268 | op->direction = 5; /* So player faces south */ |
244 | op->direction = 5; /* So player faces south */ |
269 | op->stats.wc = 2; |
245 | op->stats.wc = 2; |
270 | op->run_away = 25; /* Then we panick... */ |
246 | op->run_away = 25; /* Then we panick... */ |
|
|
247 | |
|
|
248 | { |
|
|
249 | int oldmon = p->socket->monitor_spells; // what a hack |
271 | p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
250 | p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
272 | |
|
|
273 | roll_stats (op); |
251 | roll_stats (op); |
|
|
252 | p->socket->monitor_spells = oldmon; |
|
|
253 | } |
274 | p->state = ST_ROLL_STAT; |
254 | p->state = ST_ROLL_STAT; |
275 | clear_los (op); |
255 | clear_los (op); |
276 | |
256 | |
277 | p->gen_sp_armour = 10; |
257 | p->gen_sp_armour = 10; |
278 | p->last_speed = -1; |
258 | p->last_speed = -1; |
… | |
… | |
283 | p->usekeys = containers; |
263 | p->usekeys = containers; |
284 | p->last_weapon_sp = -1; |
264 | p->last_weapon_sp = -1; |
285 | p->peaceful = 1; /* default peaceful */ |
265 | p->peaceful = 1; /* default peaceful */ |
286 | p->do_los = 1; |
266 | p->do_los = 1; |
287 | p->explore = 0; |
267 | p->explore = 0; |
288 | p->no_shout = 0; /* default can shout */ |
|
|
289 | |
268 | |
290 | strncpy (p->title, op->arch->clone.name, sizeof (p->title) - 1); |
269 | assign (p->title, op->arch->clone.name); |
291 | p->title[sizeof (p->title) - 1] = '\0'; |
|
|
292 | op->race = op->arch->clone.race; |
270 | op->race = op->arch->clone.race; |
293 | |
271 | |
294 | CLEAR_FLAG (op, FLAG_READY_SKILL); |
272 | CLEAR_FLAG (op, FLAG_READY_SKILL); |
295 | |
273 | |
296 | /* we need to clear these to -1 and not zero - otherwise, |
274 | /* we need to clear these to -1 and not zero - otherwise, |
… | |
… | |
301 | for (i = 0; i < NUM_SKILLS; i++) |
279 | for (i = 0; i < NUM_SKILLS; i++) |
302 | { |
280 | { |
303 | p->last_skill_exp[i] = -1; |
281 | p->last_skill_exp[i] = -1; |
304 | p->last_skill_ob[i] = NULL; |
282 | p->last_skill_ob[i] = NULL; |
305 | } |
283 | } |
|
|
284 | |
306 | for (i = 0; i < NROFATTACKS; i++) |
285 | for (i = 0; i < NROFATTACKS; i++) |
307 | { |
|
|
308 | p->last_resist[i] = -1; |
286 | p->last_resist[i] = -1; |
309 | } |
287 | |
310 | p->last_stats.exp = -1; |
288 | p->last_stats.exp = -1; |
311 | p->last_weight = (uint32) - 1; |
289 | p->last_weight = (uint32) - 1; |
312 | |
290 | |
313 | p->socket.update_look = 0; |
291 | p->socket->update_look = 0; |
314 | p->socket.look_position = 0; |
292 | p->socket->look_position = 0; |
|
|
293 | |
315 | return p; |
294 | return p; |
316 | } |
295 | } |
317 | |
296 | |
318 | /* This loads the first map an puts the player on it. */ |
297 | /* This loads the first map an puts the player on it. */ |
319 | static void |
298 | static void |
320 | set_first_map (object *op) |
299 | set_first_map (object *op) |
321 | { |
300 | { |
322 | strcpy (op->contr->maplevel, first_map_path); |
301 | strcpy (op->contr->maplevel, first_map_path); |
323 | op->x = -1; |
302 | op->x = -1; |
324 | op->y = -1; |
303 | op->y = -1; |
325 | enter_exit (op, NULL); |
304 | enter_exit (op, 0); |
326 | } |
305 | } |
327 | |
306 | |
328 | /* Tries to add player on the connection passwd in ns. |
307 | /* Tries to add player on the connection passwd in ns. |
329 | * All we can really get in this is some settings like host and display |
308 | * All we can really get in this is some settings like host and display |
330 | * mode. |
309 | * mode. |
331 | */ |
310 | */ |
332 | |
311 | |
333 | int |
312 | int |
334 | add_player (NewSocket * ns) |
313 | add_player (client *ns) |
335 | { |
314 | { |
336 | player *p; |
315 | player *p = new player; |
337 | |
316 | |
338 | p = get_player (NULL); |
|
|
339 | p->socket = *ns; |
317 | p->socket = ns; |
340 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
318 | ns->pl = p; |
341 | if (p->socket.faces_sent == NULL) |
319 | |
342 | fatal (OUT_OF_MEMORY); |
320 | p->next = first_player; |
343 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
321 | first_player = p; |
344 | /* Needed because the socket we just copied over needs to be cleared. |
322 | |
345 | * Note that this can result in a client reset if there is partial data |
323 | p = get_player (p); |
346 | * on the uncoming socket. |
324 | |
347 | */ |
|
|
348 | p->socket.inbuf.len = 0; |
|
|
349 | set_first_map (p->ob); |
325 | set_first_map (p->ob); |
350 | |
326 | |
351 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
327 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
352 | add_friendly_object (p->ob); |
328 | add_friendly_object (p->ob); |
353 | send_rules (p->ob); |
329 | send_rules (p->ob); |
354 | send_news (p->ob); |
330 | send_news (p->ob); |
355 | display_motd (p->ob); |
331 | display_motd (p->ob); |
|
|
332 | |
356 | get_name (p->ob); |
333 | get_name (p->ob); |
|
|
334 | |
357 | return 0; |
335 | return 0; |
358 | } |
336 | } |
359 | |
337 | |
360 | /* |
338 | /* |
361 | * get_player_archetype() return next player archetype from archetype |
339 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
371 | { |
349 | { |
372 | if (at == NULL || at->next == NULL) |
350 | if (at == NULL || at->next == NULL) |
373 | at = first_archetype; |
351 | at = first_archetype; |
374 | else |
352 | else |
375 | at = at->next; |
353 | at = at->next; |
|
|
354 | |
376 | if (at->clone.type == PLAYER) |
355 | if (at->clone.type == PLAYER) |
377 | return at; |
356 | return at; |
|
|
357 | |
378 | if (at == start) |
358 | if (at == start) |
379 | { |
359 | { |
380 | LOG (llevError, "No Player archetypes\n"); |
360 | LOG (llevError, "No Player archetypes\n"); |
381 | exit (-1); |
361 | exit (-1); |
382 | } |
362 | } |
383 | } |
363 | } |
384 | } |
364 | } |
385 | |
|
|
386 | |
365 | |
387 | object * |
366 | object * |
388 | get_nearest_player (object *mon) |
367 | get_nearest_player (object *mon) |
389 | { |
368 | { |
390 | object *op = NULL; |
369 | object *op = NULL; |
… | |
… | |
496 | path_to_player (object *mon, object *pl, unsigned mindiff) |
475 | path_to_player (object *mon, object *pl, unsigned mindiff) |
497 | { |
476 | { |
498 | rv_vector rv; |
477 | rv_vector rv; |
499 | sint16 x, y; |
478 | sint16 x, y; |
500 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
479 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
501 | mapstruct *m, *lastmap; |
480 | maptile *m, *lastmap; |
502 | |
481 | |
503 | get_rangevector (mon, pl, &rv, 0); |
482 | get_rangevector (mon, pl, &rv, 0); |
504 | |
483 | |
505 | if (rv.distance < mindiff) |
484 | if (rv.distance < mindiff) |
506 | return 0; |
485 | return 0; |
… | |
… | |
650 | (op->type == ARMOUR || op->type == BOOTS || |
629 | (op->type == ARMOUR || op->type == BOOTS || |
651 | op->type == CLOAK || op->type == HELMET || |
630 | op->type == CLOAK || op->type == HELMET || |
652 | op->type == SHIELD || op->type == GLOVES || |
631 | op->type == SHIELD || op->type == GLOVES || |
653 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
632 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
654 | { |
633 | { |
655 | remove_ob (op); |
634 | op->destroy (); |
656 | free_object (op); |
|
|
657 | continue; |
635 | continue; |
658 | } |
636 | } |
659 | } |
637 | } |
660 | |
638 | |
661 | /* This really needs to be better - we should really give |
639 | /* This really needs to be better - we should really give |
… | |
… | |
672 | if (tmp->type == op->type && tmp->name == op->name) |
650 | if (tmp->type == op->type && tmp->name == op->name) |
673 | break; |
651 | break; |
674 | |
652 | |
675 | if (tmp) |
653 | if (tmp) |
676 | { |
654 | { |
677 | remove_ob (op); |
655 | op->destroy (); |
678 | free_object (op); |
|
|
679 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
656 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
680 | continue; |
657 | continue; |
681 | } |
658 | } |
|
|
659 | |
682 | if (op->nrof > 1) |
660 | if (op->nrof > 1) |
683 | op->nrof = 1; |
661 | op->nrof = 1; |
684 | } |
662 | } |
685 | |
663 | |
686 | if (op->type == SPELLBOOK && op->inv) |
664 | if (op->type == SPELLBOOK && op->inv) |
… | |
… | |
698 | CLEAR_FLAG (op, FLAG_CURSED); |
676 | CLEAR_FLAG (op, FLAG_CURSED); |
699 | CLEAR_FLAG (op, FLAG_DAMNED); |
677 | CLEAR_FLAG (op, FLAG_DAMNED); |
700 | } |
678 | } |
701 | if (op->type == SPELL) |
679 | if (op->type == SPELL) |
702 | { |
680 | { |
703 | remove_ob (op); |
681 | op->destroy (); |
704 | free_object (op); |
|
|
705 | continue; |
682 | continue; |
706 | } |
683 | } |
707 | else if (op->type == SKILL) |
684 | else if (op->type == SKILL) |
708 | { |
685 | { |
709 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
686 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
722 | void |
699 | void |
723 | get_name (object *op) |
700 | get_name (object *op) |
724 | { |
701 | { |
725 | op->contr->write_buf[0] = '\0'; |
702 | op->contr->write_buf[0] = '\0'; |
726 | op->contr->state = ST_GET_NAME; |
703 | op->contr->state = ST_GET_NAME; |
727 | send_query (&op->contr->socket, 0, "What is your name?\n:"); |
704 | send_query (op->contr->socket, 0, "What is your name?\n:"); |
728 | } |
705 | } |
729 | |
706 | |
730 | void |
707 | void |
731 | get_password (object *op) |
708 | get_password (object *op) |
732 | { |
709 | { |
733 | op->contr->write_buf[0] = '\0'; |
710 | op->contr->write_buf[0] = '\0'; |
734 | op->contr->state = ST_GET_PASSWORD; |
711 | op->contr->state = ST_GET_PASSWORD; |
735 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
712 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
736 | } |
713 | } |
737 | |
714 | |
738 | void |
715 | void |
739 | play_again (object *op) |
716 | play_again (object *op) |
740 | { |
717 | { |
741 | op->contr->state = ST_PLAY_AGAIN; |
718 | op->contr->state = ST_PLAY_AGAIN; |
742 | op->chosen_skill = NULL; |
719 | op->chosen_skill = NULL; |
743 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
720 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
744 | /* a bit of a hack, but there are various places early in th |
721 | /* a bit of a hack, but there are various places early in th |
745 | * player creation process that a user can quit (eg, roll |
722 | * player creation process that a user can quit (eg, roll |
746 | * stats) that isn't removing the player. Taking a quick |
723 | * stats) that isn't removing the player. Taking a quick |
747 | * look, there are many places that call play_again without |
724 | * look, there are many places that call play_again without |
748 | * removing the player - it probably makes more sense |
725 | * removing the player - it probably makes more sense |
749 | * to leave it to play_again to remove the object in all |
726 | * to leave it to play_again to remove the object in all |
750 | * cases. |
727 | * cases. |
751 | */ |
728 | */ |
752 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
729 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
753 | remove_ob (op); |
730 | op->remove (); |
|
|
731 | |
754 | /* Need to set this to null - otherwise, it could point to garbage, |
732 | /* Need to set this to null - otherwise, it could point to garbage, |
755 | * and draw() doesn't check to see if the player is removed, only if |
733 | * and draw() doesn't check to see if the player is removed, only if |
756 | * the map is null or not swapped out. |
734 | * the map is null or not swapped out. |
757 | */ |
735 | */ |
758 | op->map = NULL; |
736 | op->map = NULL; |
759 | } |
737 | } |
760 | |
738 | |
761 | |
|
|
762 | int |
739 | int |
763 | receive_play_again (object *op, char key) |
740 | receive_play_again (object *op, char key) |
764 | { |
741 | { |
765 | if (key == 'q' || key == 'Q') |
742 | if (key == 'q' || key == 'Q') |
766 | { |
743 | { |
… | |
… | |
771 | else if (key == 'a' || key == 'A') |
748 | else if (key == 'a' || key == 'A') |
772 | { |
749 | { |
773 | player *pl = op->contr; |
750 | player *pl = op->contr; |
774 | shstr name = op->name; |
751 | shstr name = op->name; |
775 | |
752 | |
776 | remove_friendly_object (op); |
753 | op->contr = 0; |
777 | free_object (op); |
754 | op->type = 0; |
|
|
755 | op->destroy (1); |
778 | pl = get_player (pl); |
756 | pl = get_player (pl); |
779 | op = pl->ob; |
757 | op = pl->ob; |
780 | add_friendly_object (op); |
758 | add_friendly_object (op); |
781 | op->contr->password[0] = '~'; |
759 | op->contr->password[0] = '~'; |
782 | op->name = op->name_pl = 0; |
760 | op->name = op->name_pl = 0; |
… | |
… | |
785 | get_name (op); |
763 | get_name (op); |
786 | op->name = op->name_pl = name; |
764 | op->name = op->name_pl = name; |
787 | set_first_map (op); |
765 | set_first_map (op); |
788 | } |
766 | } |
789 | else |
767 | else |
790 | { |
|
|
791 | /* user pressed something else so just ask again... */ |
768 | /* user pressed something else so just ask again... */ |
792 | play_again (op); |
769 | play_again (op); |
793 | } |
770 | |
794 | return 0; |
771 | return 0; |
795 | } |
772 | } |
796 | |
773 | |
797 | void |
774 | void |
798 | confirm_password (object *op) |
775 | confirm_password (object *op) |
799 | { |
776 | { |
800 | |
777 | |
801 | op->contr->write_buf[0] = '\0'; |
778 | op->contr->write_buf[0] = '\0'; |
802 | op->contr->state = ST_CONFIRM_PASSWORD; |
779 | op->contr->state = ST_CONFIRM_PASSWORD; |
803 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
780 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
804 | } |
781 | } |
805 | |
782 | |
806 | void |
783 | void |
807 | get_party_password (object *op, partylist *party) |
784 | get_party_password (object *op, partylist *party) |
808 | { |
785 | { |
… | |
… | |
812 | return; |
789 | return; |
813 | } |
790 | } |
814 | op->contr->write_buf[0] = '\0'; |
791 | op->contr->write_buf[0] = '\0'; |
815 | op->contr->state = ST_GET_PARTY_PASSWORD; |
792 | op->contr->state = ST_GET_PARTY_PASSWORD; |
816 | op->contr->party_to_join = party; |
793 | op->contr->party_to_join = party; |
817 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
794 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
818 | } |
795 | } |
819 | |
796 | |
820 | |
797 | |
821 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
798 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
822 | int |
799 | int |
… | |
… | |
919 | |
896 | |
920 | void |
897 | void |
921 | Roll_Again (object *op) |
898 | Roll_Again (object *op) |
922 | { |
899 | { |
923 | esrv_new_player (op->contr, 0); |
900 | esrv_new_player (op->contr, 0); |
924 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
901 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
925 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
902 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
926 | } |
903 | } |
927 | |
904 | |
928 | void |
905 | void |
929 | Swap_Stat (object *op, int Swap_Second) |
906 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
996 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
973 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
997 | } |
974 | } |
998 | else |
975 | else |
999 | Swap_Stat (op, stat_trans[keynum]); |
976 | Swap_Stat (op, stat_trans[keynum]); |
1000 | |
977 | |
1001 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
978 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1002 | return 1; |
979 | return 1; |
1003 | } |
980 | } |
1004 | switch (key) |
981 | switch (key) |
1005 | { |
982 | { |
1006 | case 'n': |
983 | case 'n': |
1007 | case 'N': |
984 | case 'N': |
1008 | { |
985 | { |
1009 | SET_FLAG (op, FLAG_WIZ); |
986 | SET_FLAG (op, FLAG_WIZ); |
1010 | if (op->map == NULL) |
987 | if (op->map == NULL) |
1011 | { |
988 | { |
1012 | LOG (llevError, "Map == NULL in state 2\n"); |
989 | LOG (llevError, "Map == NULL in state 2\n"); |
1013 | break; |
990 | break; |
1014 | } |
991 | } |
1015 | |
992 | |
1016 | #if 0 |
993 | #if 0 |
1017 | /* So that enter_exit will put us at startx/starty */ |
994 | /* So that enter_exit will put us at startx/starty */ |
1018 | op->x = -1; |
995 | op->x = -1; |
1019 | |
996 | |
1020 | enter_exit (op, NULL); |
997 | enter_exit (op, NULL); |
1021 | #endif |
998 | #endif |
1022 | SET_ANIMATION (op, 2); /* So player faces south */ |
999 | SET_ANIMATION (op, 2); /* So player faces south */ |
1023 | /* Enter exit adds a player otherwise */ |
1000 | /* Enter exit adds a player otherwise */ |
1024 | add_statbonus (op); |
1001 | add_statbonus (op); |
1025 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
1002 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
1026 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1003 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1027 | op->contr->state = ST_CHANGE_CLASS; |
1004 | op->contr->state = ST_CHANGE_CLASS; |
1028 | if (op->msg) |
1005 | if (op->msg) |
1029 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1006 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1030 | return 0; |
|
|
1031 | } |
|
|
1032 | case 'y': |
|
|
1033 | case 'Y': |
|
|
1034 | roll_stats (op); |
|
|
1035 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1036 | return 1; |
|
|
1037 | |
|
|
1038 | case 'q': |
|
|
1039 | case 'Q': |
|
|
1040 | play_again (op); |
|
|
1041 | return 1; |
|
|
1042 | |
|
|
1043 | default: |
|
|
1044 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1045 | return 0; |
1007 | return 0; |
|
|
1008 | } |
|
|
1009 | case 'y': |
|
|
1010 | case 'Y': |
|
|
1011 | roll_stats (op); |
|
|
1012 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1013 | return 1; |
|
|
1014 | |
|
|
1015 | case 'q': |
|
|
1016 | case 'Q': |
|
|
1017 | play_again (op); |
|
|
1018 | return 1; |
|
|
1019 | |
|
|
1020 | default: |
|
|
1021 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1022 | return 0; |
1046 | } |
1023 | } |
1047 | return 0; |
1024 | return 0; |
1048 | } |
1025 | } |
1049 | |
1026 | |
1050 | /* This function takes the key that is passed, and does the |
1027 | /* This function takes the key that is passed, and does the |
… | |
… | |
1059 | { |
1036 | { |
1060 | int tmp_loop; |
1037 | int tmp_loop; |
1061 | |
1038 | |
1062 | if (key == 'q' || key == 'Q') |
1039 | if (key == 'q' || key == 'Q') |
1063 | { |
1040 | { |
1064 | remove_ob (op); |
1041 | op->remove (); |
1065 | play_again (op); |
1042 | play_again (op); |
1066 | return 0; |
1043 | return 0; |
1067 | } |
1044 | } |
1068 | if (key == 'd' || key == 'D') |
1045 | if (key == 'd' || key == 'D') |
1069 | { |
1046 | { |
1070 | char buf[MAX_BUF]; |
1047 | char buf[MAX_BUF]; |
1071 | |
1048 | |
1072 | /* this must before then initial items are given */ |
1049 | /* this must before then initial items are given */ |
1073 | esrv_new_player (op->contr, op->weight + op->carrying); |
1050 | esrv_new_player (op->contr, op->weight + op->carrying); |
|
|
1051 | |
1074 | create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); |
1052 | treasurelist *tl = find_treasurelist ("starting_wealth"); |
|
|
1053 | if (tl) |
|
|
1054 | create_treasure (tl, op, 0, 0, 0); |
1075 | |
1055 | |
1076 | INVOKE_PLAYER (BIRTH, op->contr); |
1056 | INVOKE_PLAYER (BIRTH, op->contr); |
1077 | INVOKE_PLAYER (LOGIN, op->contr); |
1057 | INVOKE_PLAYER (LOGIN, op->contr); |
1078 | |
1058 | |
1079 | op->contr->state = ST_PLAYING; |
1059 | op->contr->state = ST_PLAYING; |
… | |
… | |
1104 | { |
1084 | { |
1105 | object *tmp; |
1085 | object *tmp; |
1106 | char mapname[MAX_BUF]; |
1086 | char mapname[MAX_BUF]; |
1107 | |
1087 | |
1108 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1088 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1109 | tmp = get_object (); |
1089 | tmp = object::create (); |
1110 | EXIT_PATH (tmp) = mapname; |
1090 | EXIT_PATH (tmp) = mapname; |
1111 | EXIT_X (tmp) = op->x; |
1091 | EXIT_X (tmp) = op->x; |
1112 | EXIT_Y (tmp) = op->y; |
1092 | EXIT_Y (tmp) = op->y; |
1113 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1093 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1114 | * if the map isn't there, then stay on the |
1094 | * if the map isn't there, then stay on the |
1115 | * default initial map */ |
1095 | * default initial map */ |
1116 | free_object (tmp); |
1096 | tmp->destroy (); |
1117 | } |
1097 | } |
1118 | else |
1098 | else |
1119 | { |
|
|
1120 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1099 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1121 | } |
1100 | |
1122 | return 0; |
1101 | return 0; |
1123 | } |
1102 | } |
1124 | |
1103 | |
1125 | /* Following actually changes the race - this is the default command |
1104 | /* Following actually changes the race - this is the default command |
1126 | * if we don't match with one of the options above. |
1105 | * if we don't match with one of the options above. |
… | |
… | |
1131 | { |
1110 | { |
1132 | shstr name = op->name; |
1111 | shstr name = op->name; |
1133 | int x = op->x, y = op->y; |
1112 | int x = op->x, y = op->y; |
1134 | |
1113 | |
1135 | remove_statbonus (op); |
1114 | remove_statbonus (op); |
1136 | remove_ob (op); |
1115 | op->remove (); |
1137 | op->arch = get_player_archetype (op->arch); |
1116 | op->arch = get_player_archetype (op->arch); |
1138 | copy_object (&op->arch->clone, op); |
1117 | op->arch->clone.copy_to (op); |
1139 | op->instantiate (); |
1118 | op->instantiate (); |
1140 | op->stats = op->contr->orig_stats; |
1119 | op->stats = op->contr->orig_stats; |
1141 | op->name = op->name_pl = name; |
1120 | op->name = op->name_pl = name; |
1142 | op->x = x; |
1121 | op->x = x; |
1143 | op->y = y; |
1122 | op->y = y; |
1144 | SET_ANIMATION (op, 2); /* So player faces south */ |
1123 | SET_ANIMATION (op, 2); /* So player faces south */ |
1145 | insert_ob_in_map (op, op->map, op, 0); |
1124 | insert_ob_in_map (op, op->map, op, 0); |
1146 | strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); |
1125 | assign (op->contr->title, op->arch->clone.name); |
1147 | op->contr->title[sizeof (op->contr->title) - 1] = '\0'; |
|
|
1148 | add_statbonus (op); |
1126 | add_statbonus (op); |
1149 | tmp_loop = allowed_class (op); |
1127 | tmp_loop = allowed_class (op); |
1150 | } |
1128 | } |
|
|
1129 | |
1151 | update_object (op, UP_OBJ_FACE); |
1130 | update_object (op, UP_OBJ_FACE); |
1152 | esrv_update_item (UPD_FACE, op, op); |
1131 | esrv_update_item (UPD_FACE, op, op); |
1153 | fix_player (op); |
1132 | fix_player (op); |
1154 | op->stats.hp = op->stats.maxhp; |
1133 | op->stats.hp = op->stats.maxhp; |
1155 | op->stats.sp = op->stats.maxsp; |
1134 | op->stats.sp = op->stats.maxsp; |
1156 | op->stats.grace = 0; |
1135 | op->stats.grace = 0; |
|
|
1136 | |
1157 | if (op->msg) |
1137 | if (op->msg) |
1158 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1138 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
|
|
1139 | |
1159 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1140 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1160 | return 0; |
1141 | return 0; |
1161 | } |
1142 | } |
1162 | |
1143 | |
1163 | int |
1144 | int |
1164 | key_confirm_quit (object *op, char key) |
1145 | key_confirm_quit (object *op, char key) |
… | |
… | |
1186 | if (settings.set_title == TRUE) |
1167 | if (settings.set_title == TRUE) |
1187 | op->contr->own_title[0] = '\0'; |
1168 | op->contr->own_title[0] = '\0'; |
1188 | |
1169 | |
1189 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1170 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1190 | { |
1171 | { |
1191 | mapstruct *mp, *next; |
1172 | maptile *mp, *next; |
1192 | |
1173 | |
1193 | /* We need to hunt for any per player unique maps in memory and |
1174 | /* We need to hunt for any per player unique maps in memory and |
1194 | * get rid of them. The trailing slash in the path is intentional, |
1175 | * get rid of them. The trailing slash in the path is intentional, |
1195 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1176 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1196 | */ |
1177 | */ |
… | |
… | |
1202 | delete_map (mp); |
1183 | delete_map (mp); |
1203 | } |
1184 | } |
1204 | |
1185 | |
1205 | delete_character (op->name, 1); |
1186 | delete_character (op->name, 1); |
1206 | } |
1187 | } |
|
|
1188 | |
1207 | play_again (op); |
1189 | play_again (op); |
1208 | return 1; |
1190 | return 1; |
1209 | } |
1191 | } |
1210 | |
1192 | |
1211 | void |
1193 | void |
… | |
… | |
1243 | { |
1225 | { |
1244 | op->enemy = NULL; |
1226 | op->enemy = NULL; |
1245 | CLEAR_FLAG (op, FLAG_SCARED); |
1227 | CLEAR_FLAG (op, FLAG_SCARED); |
1246 | return; |
1228 | return; |
1247 | } |
1229 | } |
|
|
1230 | |
1248 | get_rangevector (op, op->enemy, &rv, 0); |
1231 | get_rangevector (op, op->enemy, &rv, 0); |
1249 | |
1232 | |
1250 | dir = absdir (4 + rv.direction); |
1233 | dir = absdir (4 + rv.direction); |
1251 | for (diff = 0; diff < 3; diff++) |
1234 | for (diff = 0; diff < 3; diff++) |
1252 | { |
1235 | { |
1253 | int m = 1 - (RANDOM () & 2); |
1236 | int m = 1 - (RANDOM () & 2); |
1254 | |
1237 | |
1255 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
1238 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
1256 | { |
|
|
1257 | return; |
1239 | return; |
1258 | } |
|
|
1259 | } |
1240 | } |
|
|
1241 | |
1260 | /* Cornered, get rid of scared */ |
1242 | /* Cornered, get rid of scared */ |
1261 | CLEAR_FLAG (op, FLAG_SCARED); |
1243 | CLEAR_FLAG (op, FLAG_SCARED); |
1262 | op->enemy = NULL; |
1244 | op->enemy = NULL; |
1263 | } |
1245 | } |
1264 | |
1246 | |
… | |
… | |
1269 | */ |
1251 | */ |
1270 | int |
1252 | int |
1271 | check_pick (object *op) |
1253 | check_pick (object *op) |
1272 | { |
1254 | { |
1273 | object *tmp, *next; |
1255 | object *tmp, *next; |
1274 | tag_t next_tag = 0, op_tag; |
|
|
1275 | int stop = 0; |
1256 | int stop = 0; |
1276 | int j, k, wvratio; |
1257 | int j, k, wvratio; |
1277 | char putstring[128], tmpstr[16]; |
1258 | char putstring[128], tmpstr[16]; |
1278 | |
1259 | |
1279 | |
|
|
1280 | /* if you're flying, you cna't pick up anything */ |
1260 | /* if you're flying, you cna't pick up anything */ |
1281 | if (op->move_type & MOVE_FLYING) |
1261 | if (op->move_type & MOVE_FLYING) |
1282 | return 1; |
1262 | return 1; |
1283 | |
1263 | |
1284 | op_tag = op->count; |
|
|
1285 | |
|
|
1286 | next = op->below; |
1264 | next = op->below; |
1287 | if (next) |
|
|
1288 | next_tag = next->count; |
|
|
1289 | |
1265 | |
1290 | /* loop while there are items on the floor that are not marked as |
1266 | /* loop while there are items on the floor that are not marked as |
1291 | * destroyed */ |
1267 | * destroyed */ |
1292 | while (next && !was_destroyed (next, next_tag)) |
1268 | while (next && !next->destroyed ()) |
1293 | { |
1269 | { |
1294 | tmp = next; |
1270 | tmp = next; |
1295 | next = tmp->below; |
1271 | next = tmp->below; |
1296 | if (next) |
|
|
1297 | next_tag = next->count; |
|
|
1298 | |
1272 | |
1299 | if (was_destroyed (op, op_tag)) |
1273 | if (op->destroyed ()) |
1300 | return 0; |
1274 | return 0; |
1301 | |
1275 | |
1302 | if (!can_pick (op, tmp)) |
1276 | if (!can_pick (op, tmp)) |
1303 | continue; |
1277 | continue; |
1304 | |
1278 | |
… | |
… | |
1312 | /* high not bit set? We're using the old autopickup model */ |
1286 | /* high not bit set? We're using the old autopickup model */ |
1313 | if (!(op->contr->mode & PU_NEWMODE)) |
1287 | if (!(op->contr->mode & PU_NEWMODE)) |
1314 | { |
1288 | { |
1315 | switch (op->contr->mode) |
1289 | switch (op->contr->mode) |
1316 | { |
1290 | { |
1317 | case 0: |
1291 | case 0: |
1318 | return 1; /* don't pick up */ |
1292 | return 1; /* don't pick up */ |
1319 | case 1: |
1293 | case 1: |
|
|
1294 | pick_up (op, tmp); |
|
|
1295 | return 1; |
|
|
1296 | case 2: |
|
|
1297 | pick_up (op, tmp); |
|
|
1298 | return 0; |
|
|
1299 | case 3: |
|
|
1300 | return 0; /* stop before pickup */ |
|
|
1301 | case 4: |
|
|
1302 | pick_up (op, tmp); |
|
|
1303 | break; |
|
|
1304 | case 5: |
|
|
1305 | pick_up (op, tmp); |
|
|
1306 | stop = 1; |
|
|
1307 | break; |
|
|
1308 | case 6: |
|
|
1309 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1320 | pick_up (op, tmp); |
1310 | pick_up (op, tmp); |
1321 | return 1; |
1311 | break; |
|
|
1312 | |
1322 | case 2: |
1313 | case 7: |
|
|
1314 | if (tmp->type == MONEY || tmp->type == GEM) |
1323 | pick_up (op, tmp); |
1315 | pick_up (op, tmp); |
1324 | return 0; |
1316 | break; |
1325 | case 3: |
1317 | |
1326 | return 0; /* stop before pickup */ |
1318 | default: |
1327 | case 4: |
1319 | /* use value density */ |
|
|
1320 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1321 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1328 | pick_up (op, tmp); |
1322 | pick_up (op, tmp); |
1329 | break; |
|
|
1330 | case 5: |
|
|
1331 | pick_up (op, tmp); |
|
|
1332 | stop = 1; |
|
|
1333 | break; |
|
|
1334 | case 6: |
|
|
1335 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1336 | pick_up (op, tmp); |
|
|
1337 | break; |
|
|
1338 | |
|
|
1339 | case 7: |
|
|
1340 | if (tmp->type == MONEY || tmp->type == GEM) |
|
|
1341 | pick_up (op, tmp); |
|
|
1342 | break; |
|
|
1343 | |
|
|
1344 | default: |
|
|
1345 | /* use value density */ |
|
|
1346 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1347 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
|
|
1348 | pick_up (op, tmp); |
|
|
1349 | } |
1323 | } |
1350 | } |
1324 | } |
1351 | else |
1325 | else |
1352 | { /* old model */ |
1326 | { /* old model */ |
1353 | /* NEW pickup handling */ |
1327 | /* NEW pickup handling */ |
… | |
… | |
1436 | /* question: don't pick up known-poisonous stuff? */ |
1410 | /* question: don't pick up known-poisonous stuff? */ |
1437 | if (op->contr->mode & PU_FOOD) |
1411 | if (op->contr->mode & PU_FOOD) |
1438 | if (tmp->type == FOOD) |
1412 | if (tmp->type == FOOD) |
1439 | { |
1413 | { |
1440 | pick_up (op, tmp); |
1414 | pick_up (op, tmp); |
1441 | if (0) |
|
|
1442 | fprintf (stderr, "FOOD\n"); |
|
|
1443 | continue; |
1415 | continue; |
1444 | } |
1416 | } |
|
|
1417 | |
1445 | if (op->contr->mode & PU_DRINK) |
1418 | if (op->contr->mode & PU_DRINK) |
1446 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1419 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1447 | { |
1420 | { |
1448 | pick_up (op, tmp); |
1421 | pick_up (op, tmp); |
1449 | if (0) |
|
|
1450 | fprintf (stderr, "DRINK\n"); |
|
|
1451 | continue; |
1422 | continue; |
1452 | } |
1423 | } |
1453 | |
1424 | |
1454 | if (op->contr->mode & PU_POTION) |
1425 | if (op->contr->mode & PU_POTION) |
1455 | if (tmp->type == POTION) |
1426 | if (tmp->type == POTION) |
1456 | { |
1427 | { |
1457 | pick_up (op, tmp); |
1428 | pick_up (op, tmp); |
1458 | if (0) |
|
|
1459 | fprintf (stderr, "POTION\n"); |
|
|
1460 | continue; |
1429 | continue; |
1461 | } |
1430 | } |
1462 | |
1431 | |
1463 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1432 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1464 | if (op->contr->mode & PU_SPELLBOOK) |
1433 | if (op->contr->mode & PU_SPELLBOOK) |
1465 | if (tmp->type == SPELLBOOK) |
1434 | if (tmp->type == SPELLBOOK) |
1466 | { |
1435 | { |
1467 | pick_up (op, tmp); |
1436 | pick_up (op, tmp); |
1468 | if (0) |
|
|
1469 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1470 | continue; |
1437 | continue; |
1471 | } |
1438 | } |
|
|
1439 | |
1472 | if (op->contr->mode & PU_SKILLSCROLL) |
1440 | if (op->contr->mode & PU_SKILLSCROLL) |
1473 | if (tmp->type == SKILLSCROLL) |
1441 | if (tmp->type == SKILLSCROLL) |
1474 | { |
1442 | { |
1475 | pick_up (op, tmp); |
1443 | pick_up (op, tmp); |
1476 | if (0) |
|
|
1477 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1478 | continue; |
1444 | continue; |
1479 | } |
1445 | } |
|
|
1446 | |
1480 | if (op->contr->mode & PU_READABLES) |
1447 | if (op->contr->mode & PU_READABLES) |
1481 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1448 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1482 | { |
1449 | { |
1483 | pick_up (op, tmp); |
1450 | pick_up (op, tmp); |
1484 | if (0) |
|
|
1485 | fprintf (stderr, "READABLES\n"); |
|
|
1486 | continue; |
1451 | continue; |
1487 | } |
1452 | } |
1488 | |
1453 | |
1489 | /* wands/staves/rods/horns */ |
1454 | /* wands/staves/rods/horns */ |
1490 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1455 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1491 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1456 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1492 | { |
1457 | { |
1493 | pick_up (op, tmp); |
1458 | pick_up (op, tmp); |
1494 | if (0) |
|
|
1495 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1496 | continue; |
1459 | continue; |
1497 | } |
1460 | } |
1498 | |
1461 | |
1499 | /* pick up all magical items */ |
1462 | /* pick up all magical items */ |
1500 | if (op->contr->mode & PU_MAGICAL) |
1463 | if (op->contr->mode & PU_MAGICAL) |
1501 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1464 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1502 | { |
1465 | { |
1503 | pick_up (op, tmp); |
1466 | pick_up (op, tmp); |
1504 | if (0) |
|
|
1505 | fprintf (stderr, "MAGICAL\n"); |
|
|
1506 | continue; |
1467 | continue; |
1507 | } |
1468 | } |
1508 | |
1469 | |
1509 | if (op->contr->mode & PU_VALUABLES) |
1470 | if (op->contr->mode & PU_VALUABLES) |
1510 | { |
1471 | { |
1511 | if (tmp->type == MONEY || tmp->type == GEM) |
1472 | if (tmp->type == MONEY || tmp->type == GEM) |
1512 | { |
1473 | { |
1513 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
1514 | if (0) |
|
|
1515 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1516 | continue; |
1475 | continue; |
1517 | } |
1476 | } |
1518 | } |
1477 | } |
1519 | |
1478 | |
1520 | /* rings & amulets - talismans seems to be typed AMULET */ |
1479 | /* rings & amulets - talismans seems to be typed AMULET */ |
1521 | if (op->contr->mode & PU_JEWELS) |
1480 | if (op->contr->mode & PU_JEWELS) |
1522 | if (tmp->type == RING || tmp->type == AMULET) |
1481 | if (tmp->type == RING || tmp->type == AMULET) |
1523 | { |
1482 | { |
1524 | pick_up (op, tmp); |
1483 | pick_up (op, tmp); |
|
|
1484 | continue; |
1525 | if (0) |
1485 | } |
1526 | fprintf (stderr, "JEWELS\n"); |
1486 | |
|
|
1487 | /* we don't forget dragon food */ |
|
|
1488 | if (op->contr->mode & PU_FLESH) |
|
|
1489 | if (tmp->type == FLESH) |
|
|
1490 | { |
|
|
1491 | pick_up (op, tmp); |
1527 | continue; |
1492 | continue; |
1528 | } |
1493 | } |
1529 | |
1494 | |
1530 | /* bows and arrows. Bows are good for selling! */ |
1495 | /* bows and arrows. Bows are good for selling! */ |
1531 | if (op->contr->mode & PU_BOW) |
1496 | if (op->contr->mode & PU_BOW) |
1532 | if (tmp->type == BOW) |
1497 | if (tmp->type == BOW) |
1533 | { |
1498 | { |
1534 | pick_up (op, tmp); |
1499 | pick_up (op, tmp); |
1535 | if (0) |
|
|
1536 | fprintf (stderr, "BOW\n"); |
|
|
1537 | continue; |
1500 | continue; |
1538 | } |
1501 | } |
|
|
1502 | |
1539 | if (op->contr->mode & PU_ARROW) |
1503 | if (op->contr->mode & PU_ARROW) |
1540 | if (tmp->type == ARROW) |
1504 | if (tmp->type == ARROW) |
1541 | { |
1505 | { |
1542 | pick_up (op, tmp); |
1506 | pick_up (op, tmp); |
1543 | if (0) |
|
|
1544 | fprintf (stderr, "ARROW\n"); |
|
|
1545 | continue; |
1507 | continue; |
1546 | } |
1508 | } |
1547 | |
1509 | |
1548 | /* all kinds of armor etc. */ |
1510 | /* all kinds of armor etc. */ |
1549 | if (op->contr->mode & PU_ARMOUR) |
1511 | if (op->contr->mode & PU_ARMOUR) |
1550 | if (tmp->type == ARMOUR) |
1512 | if (tmp->type == ARMOUR) |
1551 | { |
1513 | { |
1552 | pick_up (op, tmp); |
1514 | pick_up (op, tmp); |
1553 | if (0) |
|
|
1554 | fprintf (stderr, "ARMOUR\n"); |
|
|
1555 | continue; |
1515 | continue; |
1556 | } |
1516 | } |
|
|
1517 | |
1557 | if (op->contr->mode & PU_HELMET) |
1518 | if (op->contr->mode & PU_HELMET) |
1558 | if (tmp->type == HELMET) |
1519 | if (tmp->type == HELMET) |
1559 | { |
1520 | { |
1560 | pick_up (op, tmp); |
1521 | pick_up (op, tmp); |
1561 | if (0) |
|
|
1562 | fprintf (stderr, "HELMET\n"); |
|
|
1563 | continue; |
1522 | continue; |
1564 | } |
1523 | } |
|
|
1524 | |
1565 | if (op->contr->mode & PU_SHIELD) |
1525 | if (op->contr->mode & PU_SHIELD) |
1566 | if (tmp->type == SHIELD) |
1526 | if (tmp->type == SHIELD) |
1567 | { |
1527 | { |
1568 | pick_up (op, tmp); |
1528 | pick_up (op, tmp); |
1569 | if (0) |
|
|
1570 | fprintf (stderr, "SHIELD\n"); |
|
|
1571 | continue; |
1529 | continue; |
1572 | } |
1530 | } |
|
|
1531 | |
1573 | if (op->contr->mode & PU_BOOTS) |
1532 | if (op->contr->mode & PU_BOOTS) |
1574 | if (tmp->type == BOOTS) |
1533 | if (tmp->type == BOOTS) |
1575 | { |
1534 | { |
1576 | pick_up (op, tmp); |
1535 | pick_up (op, tmp); |
1577 | if (0) |
|
|
1578 | fprintf (stderr, "BOOTS\n"); |
|
|
1579 | continue; |
1536 | continue; |
1580 | } |
1537 | } |
|
|
1538 | |
1581 | if (op->contr->mode & PU_GLOVES) |
1539 | if (op->contr->mode & PU_GLOVES) |
1582 | if (tmp->type == GLOVES) |
1540 | if (tmp->type == GLOVES) |
1583 | { |
1541 | { |
1584 | pick_up (op, tmp); |
1542 | pick_up (op, tmp); |
1585 | if (0) |
|
|
1586 | fprintf (stderr, "GLOVES\n"); |
|
|
1587 | continue; |
1543 | continue; |
1588 | } |
1544 | } |
|
|
1545 | |
1589 | if (op->contr->mode & PU_CLOAK) |
1546 | if (op->contr->mode & PU_CLOAK) |
1590 | if (tmp->type == CLOAK) |
1547 | if (tmp->type == CLOAK) |
1591 | { |
1548 | { |
1592 | pick_up (op, tmp); |
1549 | pick_up (op, tmp); |
1593 | if (0) |
|
|
1594 | fprintf (stderr, "GLOVES\n"); |
|
|
1595 | continue; |
1550 | continue; |
1596 | } |
1551 | } |
1597 | |
1552 | |
1598 | /* hoping to catch throwing daggers here */ |
1553 | /* hoping to catch throwing daggers here */ |
1599 | if (op->contr->mode & PU_MISSILEWEAPON) |
1554 | if (op->contr->mode & PU_MISSILEWEAPON) |
1600 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1555 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1601 | { |
1556 | { |
1602 | pick_up (op, tmp); |
1557 | pick_up (op, tmp); |
1603 | if (0) |
|
|
1604 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1605 | continue; |
1558 | continue; |
1606 | } |
1559 | } |
1607 | |
1560 | |
1608 | /* careful: chairs and tables are weapons! */ |
1561 | /* careful: chairs and tables are weapons! */ |
1609 | if (op->contr->mode & PU_ALLWEAPON) |
1562 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1612 | { |
1565 | { |
1613 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1566 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1614 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1567 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1615 | { |
1568 | { |
1616 | pick_up (op, tmp); |
1569 | pick_up (op, tmp); |
1617 | if (0) |
|
|
1618 | fprintf (stderr, "WEAPON\n"); |
|
|
1619 | continue; |
1570 | continue; |
1620 | } |
1571 | } |
1621 | } |
1572 | } |
|
|
1573 | |
1622 | if (tmp->type == WEAPON && tmp->name == NULL) |
1574 | if (tmp->type == WEAPON && tmp->name == NULL) |
1623 | { |
1575 | { |
1624 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1576 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1625 | { |
1577 | { |
1626 | pick_up (op, tmp); |
1578 | pick_up (op, tmp); |
1627 | if (0) |
|
|
1628 | fprintf (stderr, "WEAPON\n"); |
|
|
1629 | continue; |
1579 | continue; |
1630 | } |
1580 | } |
1631 | } |
1581 | } |
1632 | } |
1582 | } |
1633 | |
1583 | |
1634 | /* misc stuff that's useful */ |
1584 | /* misc stuff that's useful */ |
1635 | if (op->contr->mode & PU_KEY) |
1585 | if (op->contr->mode & PU_KEY) |
1636 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1586 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1637 | { |
1587 | { |
1638 | pick_up (op, tmp); |
1588 | pick_up (op, tmp); |
1639 | if (0) |
|
|
1640 | fprintf (stderr, "KEY\n"); |
|
|
1641 | continue; |
1589 | continue; |
1642 | } |
1590 | } |
1643 | |
1591 | |
1644 | /* any of the last 4 bits set means we use the ratio for value |
1592 | /* any of the last 4 bits set means we use the ratio for value |
1645 | * pickups */ |
1593 | * pickups */ |
… | |
… | |
1667 | continue; |
1615 | continue; |
1668 | } |
1616 | } |
1669 | } |
1617 | } |
1670 | } /* the new pickup model */ |
1618 | } /* the new pickup model */ |
1671 | } |
1619 | } |
|
|
1620 | |
1672 | return !stop; |
1621 | return !stop; |
1673 | } |
1622 | } |
1674 | |
1623 | |
1675 | /* |
1624 | /* |
1676 | * Find an arrow in the inventory and after that |
1625 | * Find an arrow in the inventory and after that |
… | |
… | |
1775 | |
1724 | |
1776 | object * |
1725 | object * |
1777 | pick_arrow_target (object *op, const char *type, int dir) |
1726 | pick_arrow_target (object *op, const char *type, int dir) |
1778 | { |
1727 | { |
1779 | object *tmp = NULL; |
1728 | object *tmp = NULL; |
1780 | mapstruct *m; |
1729 | maptile *m; |
1781 | int i, mflags, found, number; |
1730 | int i, mflags, found, number; |
1782 | sint16 x, y; |
1731 | sint16 x, y; |
1783 | |
1732 | |
1784 | if (op->map == NULL) |
1733 | if (op->map == NULL) |
1785 | return find_arrow (op, type); |
1734 | return find_arrow (op, type); |
… | |
… | |
1845 | */ |
1794 | */ |
1846 | int |
1795 | int |
1847 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1796 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1848 | { |
1797 | { |
1849 | object *left, *bow; |
1798 | object *left, *bow; |
1850 | tag_t left_tag, tag; |
|
|
1851 | int bowspeed, mflags; |
1799 | int bowspeed, mflags; |
1852 | mapstruct *m; |
1800 | maptile *m; |
1853 | |
1801 | |
1854 | if (!dir) |
1802 | if (!dir) |
1855 | { |
1803 | { |
1856 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1804 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1857 | return 0; |
1805 | return 0; |
1858 | } |
1806 | } |
|
|
1807 | |
1859 | if (op->type == PLAYER) |
1808 | if (op->type == PLAYER) |
1860 | bow = op->contr->ranges[range_bow]; |
1809 | bow = op->contr->ranges[range_bow]; |
1861 | else |
1810 | else |
1862 | { |
1811 | { |
1863 | for (bow = op->inv; bow; bow = bow->below) |
1812 | for (bow = op->inv; bow; bow = bow->below) |
… | |
… | |
1871 | { |
1820 | { |
1872 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1821 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1873 | return 0; |
1822 | return 0; |
1874 | } |
1823 | } |
1875 | } |
1824 | } |
|
|
1825 | |
1876 | if (!bow->race || !bow->skill) |
1826 | if (!bow->race || !bow->skill) |
1877 | { |
1827 | { |
1878 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1828 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1879 | return 0; |
1829 | return 0; |
1880 | } |
1830 | } |
… | |
… | |
1882 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1832 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1883 | |
1833 | |
1884 | /* penalize ROF for bestarrow */ |
1834 | /* penalize ROF for bestarrow */ |
1885 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1835 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1886 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
1836 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1837 | |
1887 | if (bowspeed < 1) |
1838 | if (bowspeed < 1) |
1888 | bowspeed = 1; |
1839 | bowspeed = 1; |
1889 | |
1840 | |
1890 | if (arrow == NULL) |
1841 | if (arrow == NULL) |
1891 | { |
1842 | { |
… | |
… | |
1897 | else |
1848 | else |
1898 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1849 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1899 | return 0; |
1850 | return 0; |
1900 | } |
1851 | } |
1901 | } |
1852 | } |
|
|
1853 | |
1902 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1854 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1903 | if (mflags & P_OUT_OF_MAP) |
1855 | if (mflags & P_OUT_OF_MAP) |
1904 | { |
|
|
1905 | return 0; |
1856 | return 0; |
1906 | } |
1857 | |
1907 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1858 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1908 | { |
1859 | { |
1909 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1860 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1910 | return 0; |
1861 | return 0; |
1911 | } |
1862 | } |
1912 | |
1863 | |
1913 | /* this should not happen, but sometimes does */ |
1864 | /* this should not happen, but sometimes does */ |
1914 | if (arrow->nrof == 0) |
1865 | if (arrow->nrof == 0) |
1915 | { |
1866 | { |
1916 | remove_ob (arrow); |
1867 | arrow->destroy (); |
1917 | free_object (arrow); |
|
|
1918 | return 0; |
1868 | return 0; |
1919 | } |
1869 | } |
1920 | |
1870 | |
1921 | left = arrow; /* these are arrows left to the player */ |
1871 | left = arrow; /* these are arrows left to the player */ |
1922 | left_tag = left->count; |
|
|
1923 | arrow = get_split_ob (arrow, 1); |
1872 | arrow = get_split_ob (arrow, 1); |
1924 | if (arrow == NULL) |
1873 | if (!arrow) |
1925 | { |
1874 | { |
1926 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1875 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1927 | return 0; |
1876 | return 0; |
1928 | } |
1877 | } |
1929 | set_owner (arrow, op); |
1878 | |
|
|
1879 | arrow->set_owner (op); |
1930 | arrow->skill = bow->skill; |
1880 | arrow->skill = bow->skill; |
1931 | |
1881 | |
1932 | arrow->direction = dir; |
1882 | arrow->direction = dir; |
1933 | arrow->x = sx; |
1883 | arrow->x = sx; |
1934 | arrow->y = sy; |
1884 | arrow->y = sy; |
… | |
… | |
1942 | SET_ANIMATION (arrow, arrow->direction); |
1892 | SET_ANIMATION (arrow, arrow->direction); |
1943 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1893 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1944 | arrow->stats.hp = arrow->stats.dam; |
1894 | arrow->stats.hp = arrow->stats.dam; |
1945 | arrow->stats.grace = arrow->attacktype; |
1895 | arrow->stats.grace = arrow->attacktype; |
1946 | if (arrow->slaying != NULL) |
1896 | if (arrow->slaying != NULL) |
1947 | arrow->spellarg = strdup_local (arrow->slaying); |
1897 | arrow->spellarg = strdup (arrow->slaying); |
1948 | |
1898 | |
1949 | /* Note that this was different for monsters - they got their level |
1899 | /* Note that this was different for monsters - they got their level |
1950 | * added to the damage. I think the strength bonus is more proper. |
1900 | * added to the damage. I think the strength bonus is more proper. |
1951 | */ |
1901 | */ |
1952 | |
1902 | |
… | |
… | |
1970 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1920 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1971 | } |
1921 | } |
1972 | else |
1922 | else |
1973 | { |
1923 | { |
1974 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1924 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1975 | |
|
|
1976 | arrow->level = op->level; |
1925 | arrow->level = op->level; |
1977 | } |
1926 | } |
|
|
1927 | |
1978 | if (arrow->attacktype == AT_PHYSICAL) |
1928 | if (arrow->attacktype == AT_PHYSICAL) |
1979 | arrow->attacktype |= bow->attacktype; |
1929 | arrow->attacktype |= bow->attacktype; |
|
|
1930 | |
1980 | if (bow->slaying != NULL) |
1931 | if (bow->slaying) |
1981 | arrow->slaying = bow->slaying; |
1932 | arrow->slaying = bow->slaying; |
1982 | |
1933 | |
1983 | arrow->map = m; |
1934 | arrow->map = m; |
1984 | arrow->move_type = MOVE_FLY_LOW; |
1935 | arrow->move_type = MOVE_FLY_LOW; |
1985 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1936 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1986 | |
1937 | |
1987 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1938 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1988 | tag = arrow->count; |
|
|
1989 | insert_ob_in_map (arrow, m, op, 0); |
1939 | insert_ob_in_map (arrow, m, op, 0); |
1990 | |
1940 | |
1991 | if (!was_destroyed (arrow, tag)) |
1941 | if (!arrow->destroyed ()) |
1992 | move_arrow (arrow); |
1942 | move_arrow (arrow); |
1993 | |
1943 | |
1994 | if (op->type == PLAYER) |
1944 | if (op->type == PLAYER) |
1995 | { |
1945 | { |
1996 | if (was_destroyed (left, left_tag)) |
1946 | if (left->destroyed ()) |
1997 | esrv_del_item (op->contr, left_tag); |
1947 | esrv_del_item (op->contr, left->count); |
1998 | else |
1948 | else |
1999 | esrv_send_item (op, left); |
1949 | esrv_send_item (op, left); |
2000 | } |
1950 | } |
|
|
1951 | |
2001 | return 1; |
1952 | return 1; |
2002 | } |
1953 | } |
2003 | |
1954 | |
2004 | /* Special fire code for players - this takes into |
1955 | /* Special fire code for players - this takes into |
2005 | * account the special fire modes players can have |
1956 | * account the special fire modes players can have |
… | |
… | |
2101 | CLEAR_FLAG (item, FLAG_ANIMATE); |
2052 | CLEAR_FLAG (item, FLAG_ANIMATE); |
2102 | item->face = item->arch->clone.face; |
2053 | item->face = item->arch->clone.face; |
2103 | item->speed = 0; |
2054 | item->speed = 0; |
2104 | update_ob_speed (item); |
2055 | update_ob_speed (item); |
2105 | } |
2056 | } |
2106 | if ((tmp = is_player_inv (item))) |
2057 | if ((tmp = item->in_player ())) |
2107 | esrv_update_item (UPD_ANIM, tmp, item); |
2058 | esrv_update_item (UPD_ANIM, tmp, item); |
2108 | } |
2059 | } |
2109 | } |
2060 | } |
2110 | else if (item->type == ROD || item->type == HORN) |
2061 | else if (item->type == ROD || item->type == HORN) |
2111 | { |
2062 | { |
… | |
… | |
2125 | if (action_makes_visible (op)) |
2076 | if (action_makes_visible (op)) |
2126 | make_visible (op); |
2077 | make_visible (op); |
2127 | |
2078 | |
2128 | switch (op->contr->shoottype) |
2079 | switch (op->contr->shoottype) |
2129 | { |
2080 | { |
2130 | case range_none: |
2081 | case range_none: |
2131 | return; |
2082 | return; |
2132 | |
2083 | |
2133 | case range_bow: |
2084 | case range_bow: |
2134 | player_fire_bow (op, dir); |
2085 | player_fire_bow (op, dir); |
2135 | return; |
2086 | return; |
2136 | |
2087 | |
2137 | case range_magic: /* Casting spells */ |
2088 | case range_magic: /* Casting spells */ |
2138 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : NULL)); |
2089 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0)); |
2139 | return; |
2090 | return; |
2140 | |
2091 | |
2141 | case range_misc: |
2092 | case range_misc: |
2142 | fire_misc_object (op, dir); |
2093 | fire_misc_object (op, dir); |
2143 | return; |
2094 | return; |
2144 | |
2095 | |
2145 | case range_golem: /* Control summoned monsters from scrolls */ |
2096 | case range_golem: /* Control summoned monsters from scrolls */ |
2146 | if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) |
2097 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2147 | { |
2098 | { |
2148 | op->contr->ranges[range_golem] = NULL; |
2099 | op->contr->ranges[range_golem] = 0; |
2149 | op->contr->shoottype = range_none; |
2100 | op->contr->shoottype = range_none; |
2150 | op->contr->golem_count = 0; |
|
|
2151 | } |
2101 | } |
2152 | else |
2102 | else |
2153 | control_golem (op->contr->ranges[range_golem], dir); |
2103 | control_golem (op->contr->ranges[range_golem], dir); |
2154 | return; |
2104 | return; |
2155 | |
2105 | |
2156 | case range_skill: |
2106 | case range_skill: |
2157 | if (!op->chosen_skill) |
2107 | if (!op->chosen_skill) |
2158 | { |
2108 | { |
2159 | if (op->type == PLAYER) |
2109 | if (op->type == PLAYER) |
2160 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2110 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2161 | return; |
2111 | return; |
2162 | } |
2112 | } |
2163 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2113 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2164 | return; |
2114 | return; |
2165 | case range_builder: |
2115 | case range_builder: |
2166 | apply_map_builder (op, dir); |
2116 | apply_map_builder (op, dir); |
2167 | return; |
2117 | return; |
2168 | default: |
2118 | default: |
2169 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2119 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2170 | return; |
2120 | return; |
2171 | } |
2121 | } |
2172 | } |
2122 | } |
2173 | |
2123 | |
2174 | |
2124 | |
2175 | |
2125 | |
… | |
… | |
2262 | * 0 otherwise |
2212 | * 0 otherwise |
2263 | */ |
2213 | */ |
2264 | static int |
2214 | static int |
2265 | player_attack_door (object *op, object *door) |
2215 | player_attack_door (object *op, object *door) |
2266 | { |
2216 | { |
2267 | |
|
|
2268 | /* If its a door, try to find a use a key. If we do destroy the door, |
2217 | /* If its a door, try to find a use a key. If we do destroy the door, |
2269 | * might as well return immediately as there is nothing more to do - |
2218 | * might as well return immediately as there is nothing more to do - |
2270 | * otherwise, we fall through to the rest of the code. |
2219 | * otherwise, we fall through to the rest of the code. |
2271 | */ |
2220 | */ |
2272 | object *key = find_key (op, op, door); |
2221 | object *key = find_key (op, op, door); |
… | |
… | |
2310 | * It should keep the code cleaner. |
2259 | * It should keep the code cleaner. |
2311 | * When this is called, the players direction has been updated |
2260 | * When this is called, the players direction has been updated |
2312 | * (taking into account confusion.) The player is also actually |
2261 | * (taking into account confusion.) The player is also actually |
2313 | * going to try and move (not fire weapons). |
2262 | * going to try and move (not fire weapons). |
2314 | */ |
2263 | */ |
2315 | |
|
|
2316 | void |
2264 | void |
2317 | move_player_attack (object *op, int dir) |
2265 | move_player_attack (object *op, int dir) |
2318 | { |
2266 | { |
2319 | object *tmp, *mon; |
2267 | object *tmp, *mon; |
2320 | sint16 nx, ny; |
2268 | sint16 nx, ny; |
2321 | int on_battleground; |
2269 | int on_battleground; |
2322 | mapstruct *m; |
2270 | maptile *m; |
2323 | |
2271 | |
2324 | nx = freearr_x[dir] + op->x; |
2272 | nx = freearr_x[dir] + op->x; |
2325 | ny = freearr_y[dir] + op->y; |
2273 | ny = freearr_y[dir] + op->y; |
2326 | |
2274 | |
2327 | on_battleground = op_on_battleground (op, NULL, NULL); |
2275 | on_battleground = op_on_battleground (op, 0, 0); |
2328 | |
2276 | |
2329 | /* If braced, or can't move to the square, and it is not out of the |
2277 | /* If braced, or can't move to the square, and it is not out of the |
2330 | * map, attack it. Note order of if statement is important - don't |
2278 | * map, attack it. Note order of if statement is important - don't |
2331 | * want to be calling move_ob if braced, because move_ob will move the |
2279 | * want to be calling move_ob if braced, because move_ob will move the |
2332 | * player. This is a pretty nasty hack, because if we could |
2280 | * player. This is a pretty nasty hack, because if we could |
… | |
… | |
2344 | return; /* Don't think this should happen */ |
2292 | return; /* Don't think this should happen */ |
2345 | } |
2293 | } |
2346 | else |
2294 | else |
2347 | m = op->map; |
2295 | m = op->map; |
2348 | |
2296 | |
2349 | if ((tmp = get_map_ob (m, nx, ny)) == NULL) |
2297 | if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL) |
2350 | { |
2298 | { |
2351 | /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ |
2299 | /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */ |
2352 | return; |
2300 | return; |
2353 | } |
2301 | } |
2354 | |
2302 | |
2355 | mon = NULL; |
2303 | mon = 0; |
2356 | /* Go through all the objects, and find ones of interest. Only stop if |
2304 | /* Go through all the objects, and find ones of interest. Only stop if |
2357 | * we find a monster - that is something we know we want to attack. |
2305 | * we find a monster - that is something we know we want to attack. |
2358 | * if its a door or barrel (can roll) see if there may be monsters |
2306 | * if its a door or barrel (can roll) see if there may be monsters |
2359 | * on the space |
2307 | * on the space |
2360 | */ |
2308 | */ |
2361 | while (tmp != NULL) |
2309 | while (tmp) |
2362 | { |
2310 | { |
2363 | if (tmp == op) |
2311 | if (tmp == op) |
2364 | { |
2312 | { |
2365 | tmp = tmp->above; |
2313 | tmp = tmp->above; |
2366 | continue; |
2314 | continue; |
2367 | } |
2315 | } |
|
|
2316 | |
2368 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2317 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2369 | { |
2318 | { |
2370 | mon = tmp; |
2319 | mon = tmp; |
2371 | break; |
2320 | break; |
2372 | } |
2321 | } |
|
|
2322 | |
2373 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2323 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2374 | mon = tmp; |
2324 | mon = tmp; |
|
|
2325 | |
2375 | tmp = tmp->above; |
2326 | tmp = tmp->above; |
2376 | } |
2327 | } |
2377 | |
2328 | |
2378 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2329 | if (!mon) /* This happens anytime the player tries to move */ |
2379 | return; /* into a wall */ |
2330 | return; /* into a wall */ |
2380 | |
2331 | |
2381 | if (mon->head != NULL) |
2332 | if (mon->head) |
2382 | mon = mon->head; |
2333 | mon = mon->head; |
2383 | |
2334 | |
2384 | if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) |
2335 | if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) |
2385 | if (player_attack_door (op, mon)) |
2336 | if (player_attack_door (op, mon)) |
2386 | return; |
2337 | return; |
… | |
… | |
2398 | * player owns it and it is either friendly or unagressive. |
2349 | * player owns it and it is either friendly or unagressive. |
2399 | */ |
2350 | */ |
2400 | if ((op->type == PLAYER) |
2351 | if ((op->type == PLAYER) |
2401 | #if COZY_SERVER |
2352 | #if COZY_SERVER |
2402 | && |
2353 | && |
2403 | ((get_owner (mon) && get_owner (mon)->contr |
2354 | ((mon->owner && mon->owner->contr |
2404 | && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) |
2355 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2405 | #else |
2356 | #else |
2406 | && get_owner (mon) == op |
2357 | && mon->owner == op |
2407 | #endif |
2358 | #endif |
2408 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2359 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2409 | { |
2360 | { |
2410 | /* If we're braced, we don't want to switch places with it */ |
2361 | /* If we're braced, we don't want to switch places with it */ |
2411 | if (op->contr->braced) |
2362 | if (op->contr->braced) |
… | |
… | |
2423 | * attack them either. |
2374 | * attack them either. |
2424 | */ |
2375 | */ |
2425 | if ((mon->type == PLAYER || mon->enemy != op) && |
2376 | if ((mon->type == PLAYER || mon->enemy != op) && |
2426 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2377 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2427 | #ifdef PROHIBIT_PLAYERKILL |
2378 | #ifdef PROHIBIT_PLAYERKILL |
2428 | (op->contr->peaceful |
2379 | (op->contr->peaceful |
2429 | || (mon->type == PLAYER |
2380 | || (mon->type == PLAYER |
2430 | && mon->contr-> |
2381 | && mon->contr-> |
2431 | peaceful)) && |
2382 | peaceful)) && |
2432 | #else |
2383 | #else |
2433 | op->contr->peaceful && |
2384 | op->contr->peaceful && |
2434 | #endif |
2385 | #endif |
2435 | !on_battleground)) |
2386 | !on_battleground)) |
2436 | { |
2387 | { |
2437 | if (!op->contr->braced) |
2388 | if (!op->contr->braced) |
2438 | { |
2389 | { |
2439 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2390 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2440 | (void) push_ob (mon, dir, op); |
2391 | (void) push_ob (mon, dir, op); |
2441 | } |
2392 | } |
2442 | else |
2393 | else |
2443 | { |
|
|
2444 | new_draw_info (0, 0, op, "You withhold your attack"); |
2394 | new_draw_info (0, 0, op, "You withhold your attack"); |
2445 | } |
2395 | |
2446 | if (op->contr->tmp_invis || op->hide) |
2396 | if (op->contr->tmp_invis || op->hide) |
2447 | make_visible (op); |
2397 | make_visible (op); |
2448 | } |
2398 | } |
2449 | |
2399 | |
2450 | /* If the object is a boulder or other rollable object, then |
2400 | /* If the object is a boulder or other rollable object, then |
… | |
… | |
2478 | op->speed_left += op->speed / op->contr->weapon_sp; |
2428 | op->speed_left += op->speed / op->contr->weapon_sp; |
2479 | |
2429 | |
2480 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
2430 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
2481 | } |
2431 | } |
2482 | |
2432 | |
2483 | skill_attack (mon, op, 0, NULL, NULL); |
2433 | skill_attack (mon, op, 0, 0, 0); |
2484 | |
2434 | |
2485 | /* If attacking another player, that player gets automatic |
2435 | /* If attacking another player, that player gets automatic |
2486 | * hitback, and doesn't loose luck either. |
2436 | * hitback, and doesn't loose luck either. |
2487 | * Disable hitback on the battleground or if the target is |
2437 | * Disable hitback on the battleground or if the target is |
2488 | * the wiz. |
2438 | * the wiz. |
… | |
… | |
2490 | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) |
2440 | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) |
2491 | { |
2441 | { |
2492 | short luck = mon->stats.luck; |
2442 | short luck = mon->stats.luck; |
2493 | |
2443 | |
2494 | mon->contr->has_hit = 1; |
2444 | mon->contr->has_hit = 1; |
2495 | skill_attack (op, mon, 0, NULL, NULL); |
2445 | skill_attack (op, mon, 0, 0, 0); |
2496 | mon->stats.luck = luck; |
2446 | mon->stats.luck = luck; |
2497 | } |
2447 | } |
|
|
2448 | |
2498 | if (action_makes_visible (op)) |
2449 | if (action_makes_visible (op)) |
2499 | make_visible (op); |
2450 | make_visible (op); |
2500 | } |
2451 | } |
2501 | } /* if player should attack something */ |
2452 | } /* if player should attack something */ |
2502 | } |
2453 | } |
… | |
… | |
2537 | |
2488 | |
2538 | /* Add special check for newcs players and fire on - this way, the |
2489 | /* Add special check for newcs players and fire on - this way, the |
2539 | * server can handle repeat firing. |
2490 | * server can handle repeat firing. |
2540 | */ |
2491 | */ |
2541 | if (op->contr->fire_on || (op->contr->run_on && pick != 0)) |
2492 | if (op->contr->fire_on || (op->contr->run_on && pick != 0)) |
2542 | { |
|
|
2543 | op->direction = dir; |
2493 | op->direction = dir; |
2544 | } |
|
|
2545 | else |
2494 | else |
2546 | { |
|
|
2547 | op->direction = 0; |
2495 | op->direction = 0; |
2548 | } |
2496 | |
2549 | /* Update how the player looks. Use the facing, so direction may |
2497 | /* Update how the player looks. Use the facing, so direction may |
2550 | * get reset to zero. This allows for full animation capabilities |
2498 | * get reset to zero. This allows for full animation capabilities |
2551 | * for players. |
2499 | * for players. |
2552 | */ |
2500 | */ |
2553 | animate_object (op, op->facing); |
2501 | animate_object (op, op->facing); |
… | |
… | |
2598 | /* I've been seeing crashes where the golem has been destroyed, but |
2546 | /* I've been seeing crashes where the golem has been destroyed, but |
2599 | * the player object still points to the defunct golem. The code that |
2547 | * the player object still points to the defunct golem. The code that |
2600 | * destroys the golem looks correct, and it doesn't always happen, so |
2548 | * destroys the golem looks correct, and it doesn't always happen, so |
2601 | * put this in a a workaround to clean up the golem pointer. |
2549 | * put this in a a workaround to clean up the golem pointer. |
2602 | */ |
2550 | */ |
2603 | if (op->contr->ranges[range_golem] && |
|
|
2604 | ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) |
2551 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2605 | { |
|
|
2606 | op->contr->ranges[range_golem] = NULL; |
2552 | op->contr->ranges[range_golem] = 0; |
2607 | op->contr->golem_count = 0; |
|
|
2608 | } |
|
|
2609 | |
2553 | |
2610 | /* call this here - we also will call this in do_ericserver, but |
2554 | /* call this here - we also will call this in do_ericserver, but |
2611 | * the players time has been increased when doericserver has been |
2555 | * the players time has been increased when doericserver has been |
2612 | * called, so we recheck it here. |
2556 | * called, so we recheck it here. |
2613 | */ |
2557 | */ |
2614 | HandleClient (&op->contr->socket, op->contr); |
2558 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
|
|
2559 | for (int rep = 8; --rep && op->contr->socket->handle_command (); ) |
|
|
2560 | ; |
|
|
2561 | |
2615 | if (op->speed_left < 0) |
2562 | if (op->speed_left < 0) |
2616 | return 0; |
2563 | return 0; |
2617 | |
2564 | |
2618 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2565 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2619 | { |
2566 | { |
… | |
… | |
2628 | if (op->speed_left > 0) |
2575 | if (op->speed_left > 0) |
2629 | return 1; |
2576 | return 1; |
2630 | else |
2577 | else |
2631 | return 0; |
2578 | return 0; |
2632 | } |
2579 | } |
|
|
2580 | |
2633 | return 0; |
2581 | return 0; |
2634 | } |
2582 | } |
2635 | |
2583 | |
2636 | int |
2584 | int |
2637 | save_life (object *op) |
2585 | save_life (object *op) |
2638 | { |
2586 | { |
2639 | object *tmp; |
|
|
2640 | |
|
|
2641 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2587 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2642 | return 0; |
2588 | return 0; |
2643 | |
2589 | |
2644 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2590 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2645 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2591 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2646 | { |
2592 | { |
2647 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2593 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2648 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2594 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
|
|
2595 | |
2649 | if (op->contr) |
2596 | if (op->contr) |
2650 | esrv_del_item (op->contr, tmp->count); |
2597 | esrv_del_item (op->contr, tmp->count); |
2651 | remove_ob (tmp); |
2598 | |
2652 | free_object (tmp); |
2599 | tmp->destroy (); |
2653 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2600 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2601 | |
2654 | if (op->stats.hp < 0) |
2602 | if (op->stats.hp < 0) |
2655 | op->stats.hp = op->stats.maxhp; |
2603 | op->stats.hp = op->stats.maxhp; |
|
|
2604 | |
2656 | if (op->stats.food < 0) |
2605 | if (op->stats.food < 0) |
2657 | op->stats.food = 999; |
2606 | op->stats.food = 999; |
|
|
2607 | |
2658 | fix_player (op); |
2608 | fix_player (op); |
2659 | return 1; |
2609 | return 1; |
2660 | } |
2610 | } |
|
|
2611 | |
2661 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2612 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2662 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2613 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2663 | enter_player_savebed (op); /* bring him home. */ |
2614 | enter_player_savebed (op); /* bring him home. */ |
2664 | return 0; |
2615 | return 0; |
2665 | } |
2616 | } |
… | |
… | |
2679 | next = op->below; /* Make sure we have a good value, in case |
2630 | next = op->below; /* Make sure we have a good value, in case |
2680 | * we remove object 'op' |
2631 | * we remove object 'op' |
2681 | */ |
2632 | */ |
2682 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2633 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2683 | { |
2634 | { |
2684 | remove_ob (op); |
2635 | op->remove (); |
2685 | op->x = env->x; |
2636 | op->x = env->x; |
2686 | op->y = env->y; |
2637 | op->y = env->y; |
2687 | if (env->type == PLAYER) |
2638 | if (env->type == PLAYER) |
2688 | esrv_del_item (env->contr, op->count); |
2639 | esrv_del_item (env->contr, op->count); |
2689 | insert_ob_in_map (op, env->map, NULL, 0); |
2640 | insert_ob_in_map (op, env->map, NULL, 0); |
2690 | } |
2641 | } |
2691 | else if (op->inv) |
2642 | else if (op->inv) |
2692 | remove_unpaid_objects (op->inv, env); |
2643 | remove_unpaid_objects (op->inv, env); |
|
|
2644 | |
2693 | op = next; |
2645 | op = next; |
2694 | } |
2646 | } |
2695 | } |
2647 | } |
2696 | |
2648 | |
2697 | |
2649 | |
… | |
… | |
2712 | strcpy (buf2, " R.I.P.\n\n"); |
2664 | strcpy (buf2, " R.I.P.\n\n"); |
2713 | if (op->type == PLAYER) |
2665 | if (op->type == PLAYER) |
2714 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2666 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2715 | else |
2667 | else |
2716 | sprintf (buf, "%s\n", &op->name); |
2668 | sprintf (buf, "%s\n", &op->name); |
|
|
2669 | |
2717 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2670 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2718 | strcat (buf2, buf); |
2671 | strcat (buf2, buf); |
2719 | if (op->type == PLAYER) |
2672 | if (op->type == PLAYER) |
2720 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2673 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2721 | else |
2674 | else |
2722 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
2675 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2676 | |
2723 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2677 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2724 | strcat (buf2, buf); |
2678 | strcat (buf2, buf); |
2725 | if (op->type == PLAYER) |
2679 | if (op->type == PLAYER) |
2726 | { |
2680 | { |
2727 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2681 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2728 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2682 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2729 | strcat (buf2, buf); |
2683 | strcat (buf2, buf); |
2730 | } |
2684 | } |
|
|
2685 | |
2731 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2686 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2732 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2687 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2733 | strcat (buf2, buf); |
2688 | strcat (buf2, buf); |
|
|
2689 | |
2734 | return buf2; |
2690 | return buf2; |
2735 | } |
2691 | } |
2736 | |
2692 | |
2737 | |
2693 | |
2738 | |
2694 | |
… | |
… | |
2957 | { |
2913 | { |
2958 | char buf[MAX_BUF]; |
2914 | char buf[MAX_BUF]; |
2959 | int x, y; |
2915 | int x, y; |
2960 | |
2916 | |
2961 | //int i; |
2917 | //int i; |
2962 | mapstruct *map; /* this is for resurrection */ |
2918 | maptile *map; /* this is for resurrection */ |
2963 | |
2919 | |
2964 | /* int z; |
2920 | /* int z; |
2965 | int num_stats_lose; |
2921 | int num_stats_lose; |
2966 | int lost_a_stat; |
2922 | int lost_a_stat; |
2967 | int lose_this_stat; |
2923 | int lose_this_stat; |
… | |
… | |
2982 | { |
2938 | { |
2983 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2939 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2984 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2940 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2985 | |
2941 | |
2986 | /* restore player */ |
2942 | /* restore player */ |
2987 | at = find_archetype ("poisoning"); |
2943 | at = archetype::find ("poisoning"); |
2988 | tmp = present_arch_in_ob (at, op); |
2944 | tmp = present_arch_in_ob (at, op); |
2989 | if (tmp) |
2945 | if (tmp) |
2990 | { |
2946 | { |
2991 | remove_ob (tmp); |
2947 | tmp->destroy (); |
2992 | free_object (tmp); |
|
|
2993 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2948 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2994 | } |
2949 | } |
2995 | |
2950 | |
2996 | at = find_archetype ("confusion"); |
2951 | at = archetype::find ("confusion"); |
2997 | tmp = present_arch_in_ob (at, op); |
2952 | tmp = present_arch_in_ob (at, op); |
2998 | if (tmp) |
2953 | if (tmp) |
2999 | { |
2954 | { |
3000 | remove_ob (tmp); |
2955 | tmp->destroy (); |
3001 | free_object (tmp); |
|
|
3002 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2956 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3003 | } |
2957 | } |
3004 | |
2958 | |
3005 | cure_disease (op, 0); /* remove any disease */ |
2959 | cure_disease (op, 0); /* remove any disease */ |
3006 | op->stats.hp = op->stats.maxhp; |
2960 | op->stats.hp = op->stats.maxhp; |
3007 | if (op->stats.food <= 0) |
2961 | if (op->stats.food <= 0) |
3008 | op->stats.food = 999; |
2962 | op->stats.food = 999; |
3009 | |
2963 | |
3010 | /* create a bodypart-trophy to make the winner happy */ |
2964 | /* create a bodypart-trophy to make the winner happy */ |
3011 | tmp = arch_to_object (find_archetype ("finger")); |
2965 | tmp = arch_to_object (archetype::find ("finger")); |
3012 | if (tmp != NULL) |
2966 | if (tmp != NULL) |
3013 | { |
2967 | { |
3014 | sprintf (buf, "%s's finger", &op->name); |
2968 | sprintf (buf, "%s's finger", &op->name); |
3015 | tmp->name = buf; |
2969 | tmp->name = buf; |
3016 | sprintf (buf, " This finger has been cut off %s\n" |
2970 | sprintf (buf, " This finger has been cut off %s\n" |
… | |
… | |
3113 | lost_a_stat = 1; |
3067 | lost_a_stat = 1; |
3114 | } |
3068 | } |
3115 | else |
3069 | else |
3116 | { |
3070 | { |
3117 | /* deplete a stat */ |
3071 | /* deplete a stat */ |
3118 | archetype *deparch = find_archetype ("depletion"); |
3072 | archetype *deparch = archetype::find ("depletion"); |
3119 | object *dep; |
3073 | object *dep; |
3120 | |
3074 | |
3121 | dep = present_arch_in_ob (deparch, op); |
3075 | dep = present_arch_in_ob (deparch, op); |
3122 | if (!dep) |
3076 | if (!dep) |
3123 | { |
3077 | { |
… | |
… | |
3183 | /* determine_god() seems to not work sometimes... why is this? |
3137 | /* determine_god() seems to not work sometimes... why is this? |
3184 | Should I be using something else? GD */ |
3138 | Should I be using something else? GD */ |
3185 | const char *god = determine_god (op); |
3139 | const char *god = determine_god (op); |
3186 | |
3140 | |
3187 | if (god && (strcmp (god, "none"))) |
3141 | if (god && (strcmp (god, "none"))) |
3188 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3142 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3189 | else |
3143 | else |
3190 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3144 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3191 | } |
3145 | } |
|
|
3146 | #else |
|
|
3147 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3192 | #endif |
3148 | #endif |
3193 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3194 | |
3149 | |
3195 | /* Put a gravestone up where the character 'almost' died. List the |
3150 | /* Put a gravestone up where the character 'almost' died. List the |
3196 | * exp loss on the stone. |
3151 | * exp loss on the stone. |
3197 | */ |
3152 | */ |
3198 | tmp = arch_to_object (find_archetype ("gravestone")); |
3153 | tmp = arch_to_object (archetype::find ("gravestone")); |
3199 | sprintf (buf, "%s's gravestone", &op->name); |
3154 | sprintf (buf, "%s's gravestone", &op->name); |
3200 | tmp->name = buf; |
3155 | tmp->name = buf; |
3201 | sprintf (buf, "%s's gravestones", &op->name); |
3156 | sprintf (buf, "%s's gravestones", &op->name); |
3202 | tmp->name_pl = buf; |
3157 | tmp->name_pl = buf; |
3203 | sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); |
3158 | sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); |
3204 | tmp->msg = buf; |
3159 | tmp->msg = buf; |
3205 | tmp->x = op->x, tmp->y = op->y; |
3160 | tmp->x = op->x, tmp->y = op->y; |
3206 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3161 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3207 | |
3162 | |
3208 | /**************************************/ |
3163 | /**************************************/ |
3209 | /* */ |
3164 | /* */ |
3210 | /* Subtract the experience points, */ |
3165 | /* Subtract the experience points, */ |
3211 | /* if we died cause of food, give us */ |
3166 | /* if we died cause of food, give us */ |
3212 | /* food, and reset HP's... */ |
3167 | /* food, and reset HP's... */ |
3213 | /* */ |
3168 | /* */ |
3214 | |
|
|
3215 | /**************************************/ |
3169 | /**************************************/ |
3216 | |
3170 | |
3217 | /* remove any poisoning and confusion the character may be suffering. */ |
3171 | /* remove any poisoning and confusion the character may be suffering. */ |
3218 | /* restore player */ |
3172 | /* restore player */ |
3219 | at = find_archetype ("poisoning"); |
3173 | at = archetype::find ("poisoning"); |
|
|
3174 | tmp = present_arch_in_ob (at, op); |
|
|
3175 | |
|
|
3176 | if (tmp) |
|
|
3177 | { |
|
|
3178 | tmp->destroy (); |
|
|
3179 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3180 | } |
|
|
3181 | |
|
|
3182 | at = archetype::find ("confusion"); |
3220 | tmp = present_arch_in_ob (at, op); |
3183 | tmp = present_arch_in_ob (at, op); |
3221 | if (tmp) |
3184 | if (tmp) |
3222 | { |
3185 | { |
3223 | remove_ob (tmp); |
3186 | tmp->destroy (); |
3224 | free_object (tmp); |
|
|
3225 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3226 | } |
|
|
3227 | |
|
|
3228 | at = find_archetype ("confusion"); |
|
|
3229 | tmp = present_arch_in_ob (at, op); |
|
|
3230 | if (tmp) |
|
|
3231 | { |
|
|
3232 | remove_ob (tmp); |
|
|
3233 | free_object (tmp); |
|
|
3234 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3187 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3235 | } |
3188 | } |
|
|
3189 | |
3236 | cure_disease (op, 0); /* remove any disease */ |
3190 | cure_disease (op, 0); /* remove any disease */ |
3237 | |
3191 | |
3238 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3192 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3239 | apply_death_exp_penalty (op); |
3193 | apply_death_exp_penalty (op); |
3240 | if (op->stats.food < 100) |
3194 | if (op->stats.food < 100) |
… | |
… | |
3250 | */ |
3204 | */ |
3251 | |
3205 | |
3252 | if (is_in_shop (op)) |
3206 | if (is_in_shop (op)) |
3253 | remove_unpaid_objects (op->inv, op); |
3207 | remove_unpaid_objects (op->inv, op); |
3254 | |
3208 | |
3255 | /****************************************/ |
3209 | /****************************************/ |
3256 | /* */ |
3210 | /* */ |
3257 | /* Move player to his current respawn- */ |
3211 | /* Move player to his current respawn- */ |
3258 | /* position (usually last savebed) */ |
3212 | /* position (usually last savebed) */ |
3259 | /* */ |
3213 | /* */ |
3260 | |
|
|
3261 | /****************************************/ |
3214 | /****************************************/ |
3262 | |
3215 | |
3263 | enter_player_savebed (op); |
3216 | enter_player_savebed (op); |
3264 | |
3217 | |
3265 | /* Save the player before inserting the force to reduce |
3218 | /* Save the player before inserting the force to reduce |
3266 | * chance of abuse. |
3219 | * chance of abuse. |
… | |
… | |
3272 | * at his savebed location, and that can have long lasting |
3225 | * at his savebed location, and that can have long lasting |
3273 | * spell effects. So first see if there is a spell effect |
3226 | * spell effects. So first see if there is a spell effect |
3274 | * on the space that might harm the player. |
3227 | * on the space that might harm the player. |
3275 | */ |
3228 | */ |
3276 | will_kill_again = 0; |
3229 | will_kill_again = 0; |
3277 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3230 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3278 | { |
|
|
3279 | if (tmp->type == SPELL_EFFECT) |
3231 | if (tmp->type == SPELL_EFFECT) |
3280 | will_kill_again |= tmp->attacktype; |
3232 | will_kill_again |= tmp->attacktype; |
3281 | } |
3233 | |
3282 | if (will_kill_again) |
3234 | if (will_kill_again) |
3283 | { |
3235 | { |
3284 | object *force; |
3236 | object *force; |
3285 | int at; |
3237 | int at; |
3286 | |
3238 | |
… | |
… | |
3288 | /* 50 ticks should be enough time for the spell to abate */ |
3240 | /* 50 ticks should be enough time for the spell to abate */ |
3289 | force->speed = 0.1; |
3241 | force->speed = 0.1; |
3290 | force->speed_left = -5.0; |
3242 | force->speed_left = -5.0; |
3291 | SET_FLAG (force, FLAG_APPLIED); |
3243 | SET_FLAG (force, FLAG_APPLIED); |
3292 | for (at = 0; at < NROFATTACKS; at++) |
3244 | for (at = 0; at < NROFATTACKS; at++) |
3293 | { |
|
|
3294 | if (will_kill_again & (1 << at)) |
3245 | if (will_kill_again & (1 << at)) |
3295 | force->resist[at] = 100; |
3246 | force->resist[at] = 100; |
3296 | } |
3247 | |
3297 | insert_ob_in_ob (force, op); |
3248 | insert_ob_in_ob (force, op); |
3298 | fix_player (op); |
3249 | fix_player (op); |
3299 | |
3250 | |
3300 | } |
3251 | } |
3301 | |
|
|
3302 | /**************************************/ |
|
|
3303 | /* */ |
|
|
3304 | /* Repaint the characters inv, and */ |
|
|
3305 | /* stats, and show a nasty message ;) */ |
|
|
3306 | /* */ |
|
|
3307 | |
|
|
3308 | /**************************************/ |
|
|
3309 | |
3252 | |
3310 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
3253 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
3311 | return; |
3254 | return; |
3312 | } /* NOT_PERMADETH */ |
3255 | } /* NOT_PERMADETH */ |
3313 | else |
3256 | else |
… | |
… | |
3319 | op->contr->party = NULL; |
3262 | op->contr->party = NULL; |
3320 | if (settings.set_title == TRUE) |
3263 | if (settings.set_title == TRUE) |
3321 | op->contr->own_title[0] = '\0'; |
3264 | op->contr->own_title[0] = '\0'; |
3322 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3265 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3323 | check_score (op); |
3266 | check_score (op); |
|
|
3267 | |
3324 | if (op->contr->ranges[range_golem] != NULL) |
3268 | if (op->contr->ranges[range_golem]) |
3325 | { |
3269 | { |
3326 | remove_friendly_object (op->contr->ranges[range_golem]); |
3270 | remove_friendly_object (op->contr->ranges[range_golem]); |
3327 | remove_ob (op->contr->ranges[range_golem]); |
3271 | op->contr->ranges[range_golem]->destroy (); |
3328 | free_object (op->contr->ranges[range_golem]); |
|
|
3329 | op->contr->ranges[range_golem] = NULL; |
3272 | op->contr->ranges[range_golem] = 0; |
3330 | op->contr->golem_count = 0; |
|
|
3331 | } |
3273 | } |
|
|
3274 | |
3332 | loot_object (op); /* Remove some of the items for good */ |
3275 | loot_object (op); /* Remove some of the items for good */ |
3333 | remove_ob (op); |
3276 | op->remove (); |
3334 | op->direction = 0; |
3277 | op->direction = 0; |
3335 | |
3278 | |
3336 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3279 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3337 | { |
3280 | { |
3338 | delete_character (op->name, 0); |
3281 | delete_character (op->name, 0); |
… | |
… | |
3357 | op->map = map; |
3300 | op->map = map; |
3358 | /* please see resurrection.c: peterm */ |
3301 | /* please see resurrection.c: peterm */ |
3359 | dead_player (op); |
3302 | dead_player (op); |
3360 | } |
3303 | } |
3361 | else |
3304 | else |
3362 | { |
|
|
3363 | delete_character (op->name, 1); |
3305 | delete_character (op->name, 1); |
3364 | } |
3306 | } |
3365 | } |
3307 | |
3366 | play_again (op); |
3308 | play_again (op); |
3367 | |
3309 | |
3368 | /* peterm: added to create a corpse at deathsite. */ |
3310 | /* peterm: added to create a corpse at deathsite. */ |
3369 | tmp = arch_to_object (find_archetype ("corpse_pl")); |
3311 | tmp = arch_to_object (archetype::find ("corpse_pl")); |
3370 | sprintf (buf, "%s", &op->name); |
3312 | sprintf (buf, "%s", &op->name); |
3371 | tmp->name = tmp->name_pl = buf; |
3313 | tmp->name = tmp->name_pl = buf; |
3372 | tmp->level = op->level; |
3314 | tmp->level = op->level; |
3373 | tmp->x = x; |
3315 | tmp->x = x; |
3374 | tmp->y = y; |
3316 | tmp->y = y; |
… | |
… | |
3390 | } |
3332 | } |
3391 | |
3333 | |
3392 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3334 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3393 | { |
3335 | { |
3394 | next = tmp->below; |
3336 | next = tmp->below; |
3395 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3337 | if (tmp->invisible) |
3396 | continue; |
3338 | continue; |
3397 | remove_ob (tmp); |
3339 | tmp->remove (); |
3398 | tmp->x = op->x, tmp->y = op->y; |
3340 | tmp->x = op->x, tmp->y = op->y; |
3399 | if (tmp->type == CONTAINER) |
3341 | if (tmp->type == CONTAINER) |
3400 | { /* empty container to ground */ |
3342 | { /* empty container to ground */ |
3401 | loot_object (tmp); |
3343 | loot_object (tmp); |
3402 | } |
3344 | } |
3403 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3345 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3404 | { |
3346 | { |
3405 | if (tmp->nrof > 1) |
3347 | if (tmp->nrof > 1) |
3406 | { |
3348 | { |
3407 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3349 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3408 | free_object (tmp2); |
3350 | tmp2->destroy (); |
3409 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3351 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3410 | } |
3352 | } |
3411 | else |
3353 | else |
3412 | free_object (tmp); |
3354 | tmp->destroy (); |
3413 | } |
3355 | } |
3414 | else |
3356 | else |
3415 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3357 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3416 | } |
3358 | } |
3417 | } |
3359 | } |
… | |
… | |
3482 | if (op->type == PLAYER) |
3424 | if (op->type == PLAYER) |
3483 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3425 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3484 | |
3426 | |
3485 | cast_spell (op, throw_ob, dir, spob, NULL); |
3427 | cast_spell (op, throw_ob, dir, spob, NULL); |
3486 | |
3428 | |
3487 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3429 | throw_ob->destroy (); |
3488 | remove_ob (throw_ob); |
|
|
3489 | free_object (throw_ob); |
|
|
3490 | } |
3430 | } |
3491 | |
3431 | |
3492 | void |
3432 | void |
3493 | make_visible (object *op) |
3433 | make_visible (object *op) |
3494 | { |
3434 | { |
… | |
… | |
3508 | object *tmp = NULL; |
3448 | object *tmp = NULL; |
3509 | |
3449 | |
3510 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3450 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3511 | return 1; |
3451 | return 1; |
3512 | |
3452 | |
3513 | if (op->type == PLAYER) |
|
|
3514 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
3515 | if (tmp->type == EXPERIENCE && tmp->stats.Wis) |
|
|
3516 | if (QUERY_FLAG (tmp, FLAG_UNDEAD)) |
|
|
3517 | return 1; |
|
|
3518 | return 0; |
3453 | return 0; |
3519 | } |
3454 | } |
3520 | |
3455 | |
3521 | /* look at the surrounding terrain to determine |
3456 | /* look at the surrounding terrain to determine |
3522 | * the hideability of this object. Positive levels |
3457 | * the hideability of this object. Positive levels |
… | |
… | |
3610 | int |
3545 | int |
3611 | stand_near_hostile (object *who) |
3546 | stand_near_hostile (object *who) |
3612 | { |
3547 | { |
3613 | object *tmp = NULL; |
3548 | object *tmp = NULL; |
3614 | int i, friendly = 0, player = 0, mflags; |
3549 | int i, friendly = 0, player = 0, mflags; |
3615 | mapstruct *m; |
3550 | maptile *m; |
3616 | sint16 x, y; |
3551 | sint16 x, y; |
3617 | |
3552 | |
3618 | if (!who) |
3553 | if (!who) |
3619 | return 0; |
3554 | return 0; |
3620 | |
3555 | |
… | |
… | |
3637 | if (mflags & P_OUT_OF_MAP) |
3572 | if (mflags & P_OUT_OF_MAP) |
3638 | continue; |
3573 | continue; |
3639 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
3574 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
3640 | continue; |
3575 | continue; |
3641 | |
3576 | |
3642 | for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) |
3577 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
3643 | { |
3578 | { |
3644 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
3579 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
3645 | return 1; |
3580 | return 1; |
3646 | else if (tmp->type == PLAYER) |
3581 | else if (tmp->type == PLAYER) |
3647 | { |
3582 | { |
… | |
… | |
3701 | |
3636 | |
3702 | /* only the viewable area the player sees is updated by LOS |
3637 | /* only the viewable area the player sees is updated by LOS |
3703 | * code, so we need to restrict ourselves to that range of values |
3638 | * code, so we need to restrict ourselves to that range of values |
3704 | * for any meaningful values. |
3639 | * for any meaningful values. |
3705 | */ |
3640 | */ |
3706 | if (FABS (dx) <= (pl->contr->socket.mapx / 2) && |
3641 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3707 | FABS (dy) <= (pl->contr->socket.mapy / 2) && |
3642 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3708 | !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) |
3643 | !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) |
3709 | return 1; |
3644 | return 1; |
3710 | op = op->more; |
3645 | op = op->more; |
3711 | } |
3646 | } |
3712 | return 0; |
3647 | return 0; |
3713 | } |
3648 | } |