1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_player_c = |
|
|
4 | * "$Id: player.C,v 1.19 2006/09/11 23:53:30 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); |
356 | get_name (p->ob); |
332 | get_name (p->ob); |
|
|
333 | |
357 | return 0; |
334 | return 0; |
358 | } |
335 | } |
359 | |
336 | |
360 | /* |
337 | /* |
361 | * get_player_archetype() return next player archetype from archetype |
338 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
371 | { |
348 | { |
372 | if (at == NULL || at->next == NULL) |
349 | if (at == NULL || at->next == NULL) |
373 | at = first_archetype; |
350 | at = first_archetype; |
374 | else |
351 | else |
375 | at = at->next; |
352 | at = at->next; |
|
|
353 | |
376 | if (at->clone.type == PLAYER) |
354 | if (at->clone.type == PLAYER) |
377 | return at; |
355 | return at; |
|
|
356 | |
378 | if (at == start) |
357 | if (at == start) |
379 | { |
358 | { |
380 | LOG (llevError, "No Player archetypes\n"); |
359 | LOG (llevError, "No Player archetypes\n"); |
381 | exit (-1); |
360 | exit (-1); |
382 | } |
361 | } |
383 | } |
362 | } |
384 | } |
363 | } |
385 | |
|
|
386 | |
364 | |
387 | object * |
365 | object * |
388 | get_nearest_player (object *mon) |
366 | get_nearest_player (object *mon) |
389 | { |
367 | { |
390 | object *op = NULL; |
368 | object *op = NULL; |
… | |
… | |
496 | path_to_player (object *mon, object *pl, unsigned mindiff) |
474 | path_to_player (object *mon, object *pl, unsigned mindiff) |
497 | { |
475 | { |
498 | rv_vector rv; |
476 | rv_vector rv; |
499 | sint16 x, y; |
477 | sint16 x, y; |
500 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
478 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
501 | mapstruct *m, *lastmap; |
479 | maptile *m, *lastmap; |
502 | |
480 | |
503 | get_rangevector (mon, pl, &rv, 0); |
481 | get_rangevector (mon, pl, &rv, 0); |
504 | |
482 | |
505 | if (rv.distance < mindiff) |
483 | if (rv.distance < mindiff) |
506 | return 0; |
484 | return 0; |
… | |
… | |
650 | (op->type == ARMOUR || op->type == BOOTS || |
628 | (op->type == ARMOUR || op->type == BOOTS || |
651 | op->type == CLOAK || op->type == HELMET || |
629 | op->type == CLOAK || op->type == HELMET || |
652 | op->type == SHIELD || op->type == GLOVES || |
630 | op->type == SHIELD || op->type == GLOVES || |
653 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
631 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
654 | { |
632 | { |
655 | remove_ob (op); |
633 | op->destroy (); |
656 | free_object (op); |
|
|
657 | continue; |
634 | continue; |
658 | } |
635 | } |
659 | } |
636 | } |
660 | |
637 | |
661 | /* This really needs to be better - we should really give |
638 | /* This really needs to be better - we should really give |
… | |
… | |
672 | if (tmp->type == op->type && tmp->name == op->name) |
649 | if (tmp->type == op->type && tmp->name == op->name) |
673 | break; |
650 | break; |
674 | |
651 | |
675 | if (tmp) |
652 | if (tmp) |
676 | { |
653 | { |
677 | remove_ob (op); |
654 | op->destroy (); |
678 | free_object (op); |
|
|
679 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
655 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
680 | continue; |
656 | continue; |
681 | } |
657 | } |
|
|
658 | |
682 | if (op->nrof > 1) |
659 | if (op->nrof > 1) |
683 | op->nrof = 1; |
660 | op->nrof = 1; |
684 | } |
661 | } |
685 | |
662 | |
686 | if (op->type == SPELLBOOK && op->inv) |
663 | if (op->type == SPELLBOOK && op->inv) |
… | |
… | |
698 | CLEAR_FLAG (op, FLAG_CURSED); |
675 | CLEAR_FLAG (op, FLAG_CURSED); |
699 | CLEAR_FLAG (op, FLAG_DAMNED); |
676 | CLEAR_FLAG (op, FLAG_DAMNED); |
700 | } |
677 | } |
701 | if (op->type == SPELL) |
678 | if (op->type == SPELL) |
702 | { |
679 | { |
703 | remove_ob (op); |
680 | op->destroy (); |
704 | free_object (op); |
|
|
705 | continue; |
681 | continue; |
706 | } |
682 | } |
707 | else if (op->type == SKILL) |
683 | else if (op->type == SKILL) |
708 | { |
684 | { |
709 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
685 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
722 | void |
698 | void |
723 | get_name (object *op) |
699 | get_name (object *op) |
724 | { |
700 | { |
725 | op->contr->write_buf[0] = '\0'; |
701 | op->contr->write_buf[0] = '\0'; |
726 | op->contr->state = ST_GET_NAME; |
702 | op->contr->state = ST_GET_NAME; |
727 | send_query (&op->contr->socket, 0, "What is your name?\n:"); |
703 | send_query (op->contr->socket, 0, "What is your name?\n:"); |
728 | } |
704 | } |
729 | |
705 | |
730 | void |
706 | void |
731 | get_password (object *op) |
707 | get_password (object *op) |
732 | { |
708 | { |
733 | op->contr->write_buf[0] = '\0'; |
709 | op->contr->write_buf[0] = '\0'; |
734 | op->contr->state = ST_GET_PASSWORD; |
710 | op->contr->state = ST_GET_PASSWORD; |
735 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
711 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
736 | } |
712 | } |
737 | |
713 | |
738 | void |
714 | void |
739 | play_again (object *op) |
715 | play_again (object *op) |
740 | { |
716 | { |
741 | op->contr->state = ST_PLAY_AGAIN; |
717 | op->contr->state = ST_PLAY_AGAIN; |
742 | op->chosen_skill = NULL; |
718 | op->chosen_skill = NULL; |
743 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
719 | 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 |
720 | /* a bit of a hack, but there are various places early in th |
745 | * player creation process that a user can quit (eg, roll |
721 | * player creation process that a user can quit (eg, roll |
746 | * stats) that isn't removing the player. Taking a quick |
722 | * stats) that isn't removing the player. Taking a quick |
747 | * look, there are many places that call play_again without |
723 | * look, there are many places that call play_again without |
748 | * removing the player - it probably makes more sense |
724 | * removing the player - it probably makes more sense |
749 | * to leave it to play_again to remove the object in all |
725 | * to leave it to play_again to remove the object in all |
750 | * cases. |
726 | * cases. |
751 | */ |
727 | */ |
752 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
728 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
753 | remove_ob (op); |
729 | op->remove (); |
754 | /* Need to set this to null - otherwise, it could point to garbage, |
730 | /* 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 |
731 | * and draw() doesn't check to see if the player is removed, only if |
756 | * the map is null or not swapped out. |
732 | * the map is null or not swapped out. |
757 | */ |
733 | */ |
758 | op->map = NULL; |
734 | op->map = NULL; |
… | |
… | |
772 | player *pl = op->contr; |
748 | player *pl = op->contr; |
773 | shstr name = op->name; |
749 | shstr name = op->name; |
774 | |
750 | |
775 | op->contr = 0; |
751 | op->contr = 0; |
776 | op->type = 0; |
752 | op->type = 0; |
777 | op->free (1); |
753 | op->destroy (1); |
778 | pl = get_player (pl); |
754 | pl = get_player (pl); |
779 | op = pl->ob; |
755 | op = pl->ob; |
780 | add_friendly_object (op); |
756 | add_friendly_object (op); |
781 | op->contr->password[0] = '~'; |
757 | op->contr->password[0] = '~'; |
782 | op->name = op->name_pl = 0; |
758 | op->name = op->name_pl = 0; |
… | |
… | |
797 | confirm_password (object *op) |
773 | confirm_password (object *op) |
798 | { |
774 | { |
799 | |
775 | |
800 | op->contr->write_buf[0] = '\0'; |
776 | op->contr->write_buf[0] = '\0'; |
801 | op->contr->state = ST_CONFIRM_PASSWORD; |
777 | op->contr->state = ST_CONFIRM_PASSWORD; |
802 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
778 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
803 | } |
779 | } |
804 | |
780 | |
805 | void |
781 | void |
806 | get_party_password (object *op, partylist *party) |
782 | get_party_password (object *op, partylist *party) |
807 | { |
783 | { |
… | |
… | |
811 | return; |
787 | return; |
812 | } |
788 | } |
813 | op->contr->write_buf[0] = '\0'; |
789 | op->contr->write_buf[0] = '\0'; |
814 | op->contr->state = ST_GET_PARTY_PASSWORD; |
790 | op->contr->state = ST_GET_PARTY_PASSWORD; |
815 | op->contr->party_to_join = party; |
791 | op->contr->party_to_join = party; |
816 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
792 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
817 | } |
793 | } |
818 | |
794 | |
819 | |
795 | |
820 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
796 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
821 | int |
797 | int |
… | |
… | |
918 | |
894 | |
919 | void |
895 | void |
920 | Roll_Again (object *op) |
896 | Roll_Again (object *op) |
921 | { |
897 | { |
922 | esrv_new_player (op->contr, 0); |
898 | esrv_new_player (op->contr, 0); |
923 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
899 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
924 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
900 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
925 | } |
901 | } |
926 | |
902 | |
927 | void |
903 | void |
928 | Swap_Stat (object *op, int Swap_Second) |
904 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
995 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
971 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
996 | } |
972 | } |
997 | else |
973 | else |
998 | Swap_Stat (op, stat_trans[keynum]); |
974 | Swap_Stat (op, stat_trans[keynum]); |
999 | |
975 | |
1000 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
976 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1001 | return 1; |
977 | return 1; |
1002 | } |
978 | } |
1003 | switch (key) |
979 | switch (key) |
1004 | { |
980 | { |
1005 | case 'n': |
981 | case 'n': |
1006 | case 'N': |
982 | case 'N': |
1007 | { |
983 | { |
1008 | SET_FLAG (op, FLAG_WIZ); |
984 | SET_FLAG (op, FLAG_WIZ); |
1009 | if (op->map == NULL) |
985 | if (op->map == NULL) |
1010 | { |
986 | { |
1011 | LOG (llevError, "Map == NULL in state 2\n"); |
987 | LOG (llevError, "Map == NULL in state 2\n"); |
1012 | break; |
988 | break; |
1013 | } |
989 | } |
1014 | |
990 | |
1015 | #if 0 |
991 | #if 0 |
1016 | /* So that enter_exit will put us at startx/starty */ |
992 | /* So that enter_exit will put us at startx/starty */ |
1017 | op->x = -1; |
993 | op->x = -1; |
1018 | |
994 | |
1019 | enter_exit (op, NULL); |
995 | enter_exit (op, NULL); |
1020 | #endif |
996 | #endif |
1021 | SET_ANIMATION (op, 2); /* So player faces south */ |
997 | SET_ANIMATION (op, 2); /* So player faces south */ |
1022 | /* Enter exit adds a player otherwise */ |
998 | /* Enter exit adds a player otherwise */ |
1023 | add_statbonus (op); |
999 | add_statbonus (op); |
1024 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
1000 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
1025 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1001 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1026 | op->contr->state = ST_CHANGE_CLASS; |
1002 | op->contr->state = ST_CHANGE_CLASS; |
1027 | if (op->msg) |
1003 | if (op->msg) |
1028 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1004 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1029 | return 0; |
|
|
1030 | } |
|
|
1031 | case 'y': |
|
|
1032 | case 'Y': |
|
|
1033 | roll_stats (op); |
|
|
1034 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1035 | return 1; |
|
|
1036 | |
|
|
1037 | case 'q': |
|
|
1038 | case 'Q': |
|
|
1039 | play_again (op); |
|
|
1040 | return 1; |
|
|
1041 | |
|
|
1042 | default: |
|
|
1043 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1044 | return 0; |
1005 | return 0; |
|
|
1006 | } |
|
|
1007 | case 'y': |
|
|
1008 | case 'Y': |
|
|
1009 | roll_stats (op); |
|
|
1010 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1011 | return 1; |
|
|
1012 | |
|
|
1013 | case 'q': |
|
|
1014 | case 'Q': |
|
|
1015 | play_again (op); |
|
|
1016 | return 1; |
|
|
1017 | |
|
|
1018 | default: |
|
|
1019 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1020 | return 0; |
1045 | } |
1021 | } |
1046 | return 0; |
1022 | return 0; |
1047 | } |
1023 | } |
1048 | |
1024 | |
1049 | /* This function takes the key that is passed, and does the |
1025 | /* This function takes the key that is passed, and does the |
… | |
… | |
1058 | { |
1034 | { |
1059 | int tmp_loop; |
1035 | int tmp_loop; |
1060 | |
1036 | |
1061 | if (key == 'q' || key == 'Q') |
1037 | if (key == 'q' || key == 'Q') |
1062 | { |
1038 | { |
1063 | remove_ob (op); |
1039 | op->remove (); |
1064 | play_again (op); |
1040 | play_again (op); |
1065 | return 0; |
1041 | return 0; |
1066 | } |
1042 | } |
1067 | if (key == 'd' || key == 'D') |
1043 | if (key == 'd' || key == 'D') |
1068 | { |
1044 | { |
1069 | char buf[MAX_BUF]; |
1045 | char buf[MAX_BUF]; |
1070 | |
1046 | |
1071 | /* this must before then initial items are given */ |
1047 | /* this must before then initial items are given */ |
1072 | esrv_new_player (op->contr, op->weight + op->carrying); |
1048 | esrv_new_player (op->contr, op->weight + op->carrying); |
|
|
1049 | |
1073 | create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); |
1050 | treasurelist *tl = find_treasurelist ("starting_wealth"); |
|
|
1051 | if (tl) |
|
|
1052 | create_treasure (tl, op, 0, 0, 0); |
1074 | |
1053 | |
1075 | INVOKE_PLAYER (BIRTH, op->contr); |
1054 | INVOKE_PLAYER (BIRTH, op->contr); |
1076 | INVOKE_PLAYER (LOGIN, op->contr); |
1055 | INVOKE_PLAYER (LOGIN, op->contr); |
1077 | |
1056 | |
1078 | op->contr->state = ST_PLAYING; |
1057 | op->contr->state = ST_PLAYING; |
… | |
… | |
1103 | { |
1082 | { |
1104 | object *tmp; |
1083 | object *tmp; |
1105 | char mapname[MAX_BUF]; |
1084 | char mapname[MAX_BUF]; |
1106 | |
1085 | |
1107 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1086 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1108 | tmp = get_object (); |
1087 | tmp = object::create (); |
1109 | EXIT_PATH (tmp) = mapname; |
1088 | EXIT_PATH (tmp) = mapname; |
1110 | EXIT_X (tmp) = op->x; |
1089 | EXIT_X (tmp) = op->x; |
1111 | EXIT_Y (tmp) = op->y; |
1090 | EXIT_Y (tmp) = op->y; |
1112 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1091 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1113 | * if the map isn't there, then stay on the |
1092 | * if the map isn't there, then stay on the |
1114 | * default initial map */ |
1093 | * default initial map */ |
1115 | free_object (tmp); |
1094 | tmp->destroy (); |
1116 | } |
1095 | } |
1117 | else |
1096 | else |
1118 | { |
|
|
1119 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1097 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1120 | } |
1098 | |
1121 | return 0; |
1099 | return 0; |
1122 | } |
1100 | } |
1123 | |
1101 | |
1124 | /* Following actually changes the race - this is the default command |
1102 | /* Following actually changes the race - this is the default command |
1125 | * if we don't match with one of the options above. |
1103 | * if we don't match with one of the options above. |
… | |
… | |
1130 | { |
1108 | { |
1131 | shstr name = op->name; |
1109 | shstr name = op->name; |
1132 | int x = op->x, y = op->y; |
1110 | int x = op->x, y = op->y; |
1133 | |
1111 | |
1134 | remove_statbonus (op); |
1112 | remove_statbonus (op); |
1135 | remove_ob (op); |
1113 | op->remove (); |
1136 | op->arch = get_player_archetype (op->arch); |
1114 | op->arch = get_player_archetype (op->arch); |
1137 | copy_object (&op->arch->clone, op); |
1115 | op->arch->clone.copy_to (op); |
1138 | op->instantiate (); |
1116 | op->instantiate (); |
1139 | op->stats = op->contr->orig_stats; |
1117 | op->stats = op->contr->orig_stats; |
1140 | op->name = op->name_pl = name; |
1118 | op->name = op->name_pl = name; |
1141 | op->x = x; |
1119 | op->x = x; |
1142 | op->y = y; |
1120 | op->y = y; |
1143 | SET_ANIMATION (op, 2); /* So player faces south */ |
1121 | SET_ANIMATION (op, 2); /* So player faces south */ |
1144 | insert_ob_in_map (op, op->map, op, 0); |
1122 | insert_ob_in_map (op, op->map, op, 0); |
1145 | strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); |
1123 | assign (op->contr->title, op->arch->clone.name); |
1146 | op->contr->title[sizeof (op->contr->title) - 1] = '\0'; |
|
|
1147 | add_statbonus (op); |
1124 | add_statbonus (op); |
1148 | tmp_loop = allowed_class (op); |
1125 | tmp_loop = allowed_class (op); |
1149 | } |
1126 | } |
1150 | |
1127 | |
1151 | update_object (op, UP_OBJ_FACE); |
1128 | update_object (op, UP_OBJ_FACE); |
1152 | esrv_update_item (UPD_FACE, op, op); |
1129 | esrv_update_item (UPD_FACE, op, op); |
1153 | fix_player (op); |
1130 | fix_player (op); |
1154 | op->stats.hp = op->stats.maxhp; |
1131 | op->stats.hp = op->stats.maxhp; |
1155 | op->stats.sp = op->stats.maxsp; |
1132 | op->stats.sp = op->stats.maxsp; |
1156 | op->stats.grace = 0; |
1133 | op->stats.grace = 0; |
|
|
1134 | |
1157 | if (op->msg) |
1135 | if (op->msg) |
1158 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1136 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
|
|
1137 | |
1159 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1138 | 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; |
1139 | return 0; |
1161 | } |
1140 | } |
1162 | |
1141 | |
1163 | int |
1142 | int |
1164 | key_confirm_quit (object *op, char key) |
1143 | key_confirm_quit (object *op, char key) |
… | |
… | |
1186 | if (settings.set_title == TRUE) |
1165 | if (settings.set_title == TRUE) |
1187 | op->contr->own_title[0] = '\0'; |
1166 | op->contr->own_title[0] = '\0'; |
1188 | |
1167 | |
1189 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1168 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1190 | { |
1169 | { |
1191 | mapstruct *mp, *next; |
1170 | maptile *mp, *next; |
1192 | |
1171 | |
1193 | /* We need to hunt for any per player unique maps in memory and |
1172 | /* 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, |
1173 | * 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 |
1174 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1196 | */ |
1175 | */ |
… | |
… | |
1270 | */ |
1249 | */ |
1271 | int |
1250 | int |
1272 | check_pick (object *op) |
1251 | check_pick (object *op) |
1273 | { |
1252 | { |
1274 | object *tmp, *next; |
1253 | object *tmp, *next; |
1275 | tag_t next_tag = 0, op_tag; |
|
|
1276 | int stop = 0; |
1254 | int stop = 0; |
1277 | int j, k, wvratio; |
1255 | int j, k, wvratio; |
1278 | char putstring[128], tmpstr[16]; |
1256 | char putstring[128], tmpstr[16]; |
1279 | |
1257 | |
1280 | |
|
|
1281 | /* if you're flying, you cna't pick up anything */ |
1258 | /* if you're flying, you cna't pick up anything */ |
1282 | if (op->move_type & MOVE_FLYING) |
1259 | if (op->move_type & MOVE_FLYING) |
1283 | return 1; |
1260 | return 1; |
1284 | |
1261 | |
1285 | op_tag = op->count; |
|
|
1286 | |
|
|
1287 | next = op->below; |
1262 | next = op->below; |
1288 | if (next) |
|
|
1289 | next_tag = next->count; |
|
|
1290 | |
1263 | |
1291 | /* loop while there are items on the floor that are not marked as |
1264 | /* loop while there are items on the floor that are not marked as |
1292 | * destroyed */ |
1265 | * destroyed */ |
1293 | while (next && !was_destroyed (next, next_tag)) |
1266 | while (next && !next->destroyed ()) |
1294 | { |
1267 | { |
1295 | tmp = next; |
1268 | tmp = next; |
1296 | next = tmp->below; |
1269 | next = tmp->below; |
1297 | if (next) |
|
|
1298 | next_tag = next->count; |
|
|
1299 | |
1270 | |
1300 | if (was_destroyed (op, op_tag)) |
1271 | if (op->destroyed ()) |
1301 | return 0; |
1272 | return 0; |
1302 | |
1273 | |
1303 | if (!can_pick (op, tmp)) |
1274 | if (!can_pick (op, tmp)) |
1304 | continue; |
1275 | continue; |
1305 | |
1276 | |
… | |
… | |
1313 | /* high not bit set? We're using the old autopickup model */ |
1284 | /* high not bit set? We're using the old autopickup model */ |
1314 | if (!(op->contr->mode & PU_NEWMODE)) |
1285 | if (!(op->contr->mode & PU_NEWMODE)) |
1315 | { |
1286 | { |
1316 | switch (op->contr->mode) |
1287 | switch (op->contr->mode) |
1317 | { |
1288 | { |
1318 | case 0: |
1289 | case 0: |
1319 | return 1; /* don't pick up */ |
1290 | return 1; /* don't pick up */ |
1320 | case 1: |
1291 | case 1: |
|
|
1292 | pick_up (op, tmp); |
|
|
1293 | return 1; |
|
|
1294 | case 2: |
|
|
1295 | pick_up (op, tmp); |
|
|
1296 | return 0; |
|
|
1297 | case 3: |
|
|
1298 | return 0; /* stop before pickup */ |
|
|
1299 | case 4: |
|
|
1300 | pick_up (op, tmp); |
|
|
1301 | break; |
|
|
1302 | case 5: |
|
|
1303 | pick_up (op, tmp); |
|
|
1304 | stop = 1; |
|
|
1305 | break; |
|
|
1306 | case 6: |
|
|
1307 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1321 | pick_up (op, tmp); |
1308 | pick_up (op, tmp); |
1322 | return 1; |
1309 | break; |
|
|
1310 | |
1323 | case 2: |
1311 | case 7: |
|
|
1312 | if (tmp->type == MONEY || tmp->type == GEM) |
1324 | pick_up (op, tmp); |
1313 | pick_up (op, tmp); |
1325 | return 0; |
1314 | break; |
1326 | case 3: |
1315 | |
1327 | return 0; /* stop before pickup */ |
1316 | default: |
1328 | case 4: |
1317 | /* use value density */ |
|
|
1318 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1319 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1329 | pick_up (op, tmp); |
1320 | pick_up (op, tmp); |
1330 | break; |
|
|
1331 | case 5: |
|
|
1332 | pick_up (op, tmp); |
|
|
1333 | stop = 1; |
|
|
1334 | break; |
|
|
1335 | case 6: |
|
|
1336 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1337 | pick_up (op, tmp); |
|
|
1338 | break; |
|
|
1339 | |
|
|
1340 | case 7: |
|
|
1341 | if (tmp->type == MONEY || tmp->type == GEM) |
|
|
1342 | pick_up (op, tmp); |
|
|
1343 | break; |
|
|
1344 | |
|
|
1345 | default: |
|
|
1346 | /* use value density */ |
|
|
1347 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1348 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
|
|
1349 | pick_up (op, tmp); |
|
|
1350 | } |
1321 | } |
1351 | } |
1322 | } |
1352 | else |
1323 | else |
1353 | { /* old model */ |
1324 | { /* old model */ |
1354 | /* NEW pickup handling */ |
1325 | /* NEW pickup handling */ |
… | |
… | |
1437 | /* question: don't pick up known-poisonous stuff? */ |
1408 | /* question: don't pick up known-poisonous stuff? */ |
1438 | if (op->contr->mode & PU_FOOD) |
1409 | if (op->contr->mode & PU_FOOD) |
1439 | if (tmp->type == FOOD) |
1410 | if (tmp->type == FOOD) |
1440 | { |
1411 | { |
1441 | pick_up (op, tmp); |
1412 | pick_up (op, tmp); |
1442 | if (0) |
|
|
1443 | fprintf (stderr, "FOOD\n"); |
|
|
1444 | continue; |
1413 | continue; |
1445 | } |
1414 | } |
|
|
1415 | |
1446 | if (op->contr->mode & PU_DRINK) |
1416 | if (op->contr->mode & PU_DRINK) |
1447 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1417 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1448 | { |
1418 | { |
1449 | pick_up (op, tmp); |
1419 | pick_up (op, tmp); |
1450 | if (0) |
|
|
1451 | fprintf (stderr, "DRINK\n"); |
|
|
1452 | continue; |
1420 | continue; |
1453 | } |
1421 | } |
1454 | |
1422 | |
1455 | if (op->contr->mode & PU_POTION) |
1423 | if (op->contr->mode & PU_POTION) |
1456 | if (tmp->type == POTION) |
1424 | if (tmp->type == POTION) |
1457 | { |
1425 | { |
1458 | pick_up (op, tmp); |
1426 | pick_up (op, tmp); |
1459 | if (0) |
|
|
1460 | fprintf (stderr, "POTION\n"); |
|
|
1461 | continue; |
1427 | continue; |
1462 | } |
1428 | } |
1463 | |
1429 | |
1464 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1430 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1465 | if (op->contr->mode & PU_SPELLBOOK) |
1431 | if (op->contr->mode & PU_SPELLBOOK) |
1466 | if (tmp->type == SPELLBOOK) |
1432 | if (tmp->type == SPELLBOOK) |
1467 | { |
1433 | { |
1468 | pick_up (op, tmp); |
1434 | pick_up (op, tmp); |
1469 | if (0) |
|
|
1470 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1471 | continue; |
1435 | continue; |
1472 | } |
1436 | } |
|
|
1437 | |
1473 | if (op->contr->mode & PU_SKILLSCROLL) |
1438 | if (op->contr->mode & PU_SKILLSCROLL) |
1474 | if (tmp->type == SKILLSCROLL) |
1439 | if (tmp->type == SKILLSCROLL) |
1475 | { |
1440 | { |
1476 | pick_up (op, tmp); |
1441 | pick_up (op, tmp); |
1477 | if (0) |
|
|
1478 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1479 | continue; |
1442 | continue; |
1480 | } |
1443 | } |
|
|
1444 | |
1481 | if (op->contr->mode & PU_READABLES) |
1445 | if (op->contr->mode & PU_READABLES) |
1482 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1446 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1483 | { |
1447 | { |
1484 | pick_up (op, tmp); |
1448 | pick_up (op, tmp); |
1485 | if (0) |
|
|
1486 | fprintf (stderr, "READABLES\n"); |
|
|
1487 | continue; |
1449 | continue; |
1488 | } |
1450 | } |
1489 | |
1451 | |
1490 | /* wands/staves/rods/horns */ |
1452 | /* wands/staves/rods/horns */ |
1491 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1453 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1492 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1454 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1493 | { |
1455 | { |
1494 | pick_up (op, tmp); |
1456 | pick_up (op, tmp); |
1495 | if (0) |
|
|
1496 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1497 | continue; |
1457 | continue; |
1498 | } |
1458 | } |
1499 | |
1459 | |
1500 | /* pick up all magical items */ |
1460 | /* pick up all magical items */ |
1501 | if (op->contr->mode & PU_MAGICAL) |
1461 | if (op->contr->mode & PU_MAGICAL) |
1502 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1462 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1503 | { |
1463 | { |
1504 | pick_up (op, tmp); |
1464 | pick_up (op, tmp); |
1505 | if (0) |
|
|
1506 | fprintf (stderr, "MAGICAL\n"); |
|
|
1507 | continue; |
1465 | continue; |
1508 | } |
1466 | } |
1509 | |
1467 | |
1510 | if (op->contr->mode & PU_VALUABLES) |
1468 | if (op->contr->mode & PU_VALUABLES) |
1511 | { |
1469 | { |
1512 | if (tmp->type == MONEY || tmp->type == GEM) |
1470 | if (tmp->type == MONEY || tmp->type == GEM) |
1513 | { |
1471 | { |
1514 | pick_up (op, tmp); |
1472 | pick_up (op, tmp); |
1515 | if (0) |
|
|
1516 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1517 | continue; |
1473 | continue; |
1518 | } |
1474 | } |
1519 | } |
1475 | } |
1520 | |
1476 | |
1521 | /* rings & amulets - talismans seems to be typed AMULET */ |
1477 | /* rings & amulets - talismans seems to be typed AMULET */ |
1522 | if (op->contr->mode & PU_JEWELS) |
1478 | if (op->contr->mode & PU_JEWELS) |
1523 | if (tmp->type == RING || tmp->type == AMULET) |
1479 | if (tmp->type == RING || tmp->type == AMULET) |
1524 | { |
1480 | { |
1525 | pick_up (op, tmp); |
1481 | pick_up (op, tmp); |
|
|
1482 | continue; |
1526 | if (0) |
1483 | } |
1527 | fprintf (stderr, "JEWELS\n"); |
1484 | |
|
|
1485 | /* we don't forget dragon food */ |
|
|
1486 | if (op->contr->mode & PU_FLESH) |
|
|
1487 | if (tmp->type == FLESH) |
|
|
1488 | { |
|
|
1489 | pick_up (op, tmp); |
1528 | continue; |
1490 | continue; |
1529 | } |
1491 | } |
1530 | |
1492 | |
1531 | /* bows and arrows. Bows are good for selling! */ |
1493 | /* bows and arrows. Bows are good for selling! */ |
1532 | if (op->contr->mode & PU_BOW) |
1494 | if (op->contr->mode & PU_BOW) |
1533 | if (tmp->type == BOW) |
1495 | if (tmp->type == BOW) |
1534 | { |
1496 | { |
1535 | pick_up (op, tmp); |
1497 | pick_up (op, tmp); |
1536 | if (0) |
|
|
1537 | fprintf (stderr, "BOW\n"); |
|
|
1538 | continue; |
1498 | continue; |
1539 | } |
1499 | } |
|
|
1500 | |
1540 | if (op->contr->mode & PU_ARROW) |
1501 | if (op->contr->mode & PU_ARROW) |
1541 | if (tmp->type == ARROW) |
1502 | if (tmp->type == ARROW) |
1542 | { |
1503 | { |
1543 | pick_up (op, tmp); |
1504 | pick_up (op, tmp); |
1544 | if (0) |
|
|
1545 | fprintf (stderr, "ARROW\n"); |
|
|
1546 | continue; |
1505 | continue; |
1547 | } |
1506 | } |
1548 | |
1507 | |
1549 | /* all kinds of armor etc. */ |
1508 | /* all kinds of armor etc. */ |
1550 | if (op->contr->mode & PU_ARMOUR) |
1509 | if (op->contr->mode & PU_ARMOUR) |
1551 | if (tmp->type == ARMOUR) |
1510 | if (tmp->type == ARMOUR) |
1552 | { |
1511 | { |
1553 | pick_up (op, tmp); |
1512 | pick_up (op, tmp); |
1554 | if (0) |
|
|
1555 | fprintf (stderr, "ARMOUR\n"); |
|
|
1556 | continue; |
1513 | continue; |
1557 | } |
1514 | } |
|
|
1515 | |
1558 | if (op->contr->mode & PU_HELMET) |
1516 | if (op->contr->mode & PU_HELMET) |
1559 | if (tmp->type == HELMET) |
1517 | if (tmp->type == HELMET) |
1560 | { |
1518 | { |
1561 | pick_up (op, tmp); |
1519 | pick_up (op, tmp); |
1562 | if (0) |
|
|
1563 | fprintf (stderr, "HELMET\n"); |
|
|
1564 | continue; |
1520 | continue; |
1565 | } |
1521 | } |
|
|
1522 | |
1566 | if (op->contr->mode & PU_SHIELD) |
1523 | if (op->contr->mode & PU_SHIELD) |
1567 | if (tmp->type == SHIELD) |
1524 | if (tmp->type == SHIELD) |
1568 | { |
1525 | { |
1569 | pick_up (op, tmp); |
1526 | pick_up (op, tmp); |
1570 | if (0) |
|
|
1571 | fprintf (stderr, "SHIELD\n"); |
|
|
1572 | continue; |
1527 | continue; |
1573 | } |
1528 | } |
|
|
1529 | |
1574 | if (op->contr->mode & PU_BOOTS) |
1530 | if (op->contr->mode & PU_BOOTS) |
1575 | if (tmp->type == BOOTS) |
1531 | if (tmp->type == BOOTS) |
1576 | { |
1532 | { |
1577 | pick_up (op, tmp); |
1533 | pick_up (op, tmp); |
1578 | if (0) |
|
|
1579 | fprintf (stderr, "BOOTS\n"); |
|
|
1580 | continue; |
1534 | continue; |
1581 | } |
1535 | } |
|
|
1536 | |
1582 | if (op->contr->mode & PU_GLOVES) |
1537 | if (op->contr->mode & PU_GLOVES) |
1583 | if (tmp->type == GLOVES) |
1538 | if (tmp->type == GLOVES) |
1584 | { |
1539 | { |
1585 | pick_up (op, tmp); |
1540 | pick_up (op, tmp); |
1586 | if (0) |
|
|
1587 | fprintf (stderr, "GLOVES\n"); |
|
|
1588 | continue; |
1541 | continue; |
1589 | } |
1542 | } |
|
|
1543 | |
1590 | if (op->contr->mode & PU_CLOAK) |
1544 | if (op->contr->mode & PU_CLOAK) |
1591 | if (tmp->type == CLOAK) |
1545 | if (tmp->type == CLOAK) |
1592 | { |
1546 | { |
1593 | pick_up (op, tmp); |
1547 | pick_up (op, tmp); |
1594 | if (0) |
|
|
1595 | fprintf (stderr, "GLOVES\n"); |
|
|
1596 | continue; |
1548 | continue; |
1597 | } |
1549 | } |
1598 | |
1550 | |
1599 | /* hoping to catch throwing daggers here */ |
1551 | /* hoping to catch throwing daggers here */ |
1600 | if (op->contr->mode & PU_MISSILEWEAPON) |
1552 | if (op->contr->mode & PU_MISSILEWEAPON) |
1601 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1553 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1602 | { |
1554 | { |
1603 | pick_up (op, tmp); |
1555 | pick_up (op, tmp); |
1604 | if (0) |
|
|
1605 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1606 | continue; |
1556 | continue; |
1607 | } |
1557 | } |
1608 | |
1558 | |
1609 | /* careful: chairs and tables are weapons! */ |
1559 | /* careful: chairs and tables are weapons! */ |
1610 | if (op->contr->mode & PU_ALLWEAPON) |
1560 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1613 | { |
1563 | { |
1614 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1564 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1615 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1565 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1616 | { |
1566 | { |
1617 | pick_up (op, tmp); |
1567 | pick_up (op, tmp); |
1618 | if (0) |
|
|
1619 | fprintf (stderr, "WEAPON\n"); |
|
|
1620 | continue; |
1568 | continue; |
1621 | } |
1569 | } |
1622 | } |
1570 | } |
|
|
1571 | |
1623 | if (tmp->type == WEAPON && tmp->name == NULL) |
1572 | if (tmp->type == WEAPON && tmp->name == NULL) |
1624 | { |
1573 | { |
1625 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1574 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1626 | { |
1575 | { |
1627 | pick_up (op, tmp); |
1576 | pick_up (op, tmp); |
1628 | if (0) |
|
|
1629 | fprintf (stderr, "WEAPON\n"); |
|
|
1630 | continue; |
1577 | continue; |
1631 | } |
1578 | } |
1632 | } |
1579 | } |
1633 | } |
1580 | } |
1634 | |
1581 | |
1635 | /* misc stuff that's useful */ |
1582 | /* misc stuff that's useful */ |
1636 | if (op->contr->mode & PU_KEY) |
1583 | if (op->contr->mode & PU_KEY) |
1637 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1584 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1638 | { |
1585 | { |
1639 | pick_up (op, tmp); |
1586 | pick_up (op, tmp); |
1640 | if (0) |
|
|
1641 | fprintf (stderr, "KEY\n"); |
|
|
1642 | continue; |
1587 | continue; |
1643 | } |
1588 | } |
1644 | |
1589 | |
1645 | /* any of the last 4 bits set means we use the ratio for value |
1590 | /* any of the last 4 bits set means we use the ratio for value |
1646 | * pickups */ |
1591 | * pickups */ |
… | |
… | |
1668 | continue; |
1613 | continue; |
1669 | } |
1614 | } |
1670 | } |
1615 | } |
1671 | } /* the new pickup model */ |
1616 | } /* the new pickup model */ |
1672 | } |
1617 | } |
|
|
1618 | |
1673 | return !stop; |
1619 | return !stop; |
1674 | } |
1620 | } |
1675 | |
1621 | |
1676 | /* |
1622 | /* |
1677 | * Find an arrow in the inventory and after that |
1623 | * Find an arrow in the inventory and after that |
… | |
… | |
1776 | |
1722 | |
1777 | object * |
1723 | object * |
1778 | pick_arrow_target (object *op, const char *type, int dir) |
1724 | pick_arrow_target (object *op, const char *type, int dir) |
1779 | { |
1725 | { |
1780 | object *tmp = NULL; |
1726 | object *tmp = NULL; |
1781 | mapstruct *m; |
1727 | maptile *m; |
1782 | int i, mflags, found, number; |
1728 | int i, mflags, found, number; |
1783 | sint16 x, y; |
1729 | sint16 x, y; |
1784 | |
1730 | |
1785 | if (op->map == NULL) |
1731 | if (op->map == NULL) |
1786 | return find_arrow (op, type); |
1732 | return find_arrow (op, type); |
… | |
… | |
1846 | */ |
1792 | */ |
1847 | int |
1793 | int |
1848 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1794 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1849 | { |
1795 | { |
1850 | object *left, *bow; |
1796 | object *left, *bow; |
1851 | tag_t left_tag, tag; |
|
|
1852 | int bowspeed, mflags; |
1797 | int bowspeed, mflags; |
1853 | mapstruct *m; |
1798 | maptile *m; |
1854 | |
1799 | |
1855 | if (!dir) |
1800 | if (!dir) |
1856 | { |
1801 | { |
1857 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1802 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1858 | return 0; |
1803 | return 0; |
1859 | } |
1804 | } |
|
|
1805 | |
1860 | if (op->type == PLAYER) |
1806 | if (op->type == PLAYER) |
1861 | bow = op->contr->ranges[range_bow]; |
1807 | bow = op->contr->ranges[range_bow]; |
1862 | else |
1808 | else |
1863 | { |
1809 | { |
1864 | for (bow = op->inv; bow; bow = bow->below) |
1810 | for (bow = op->inv; bow; bow = bow->below) |
… | |
… | |
1872 | { |
1818 | { |
1873 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1819 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1874 | return 0; |
1820 | return 0; |
1875 | } |
1821 | } |
1876 | } |
1822 | } |
|
|
1823 | |
1877 | if (!bow->race || !bow->skill) |
1824 | if (!bow->race || !bow->skill) |
1878 | { |
1825 | { |
1879 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1826 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1880 | return 0; |
1827 | return 0; |
1881 | } |
1828 | } |
… | |
… | |
1883 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1830 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1884 | |
1831 | |
1885 | /* penalize ROF for bestarrow */ |
1832 | /* penalize ROF for bestarrow */ |
1886 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1833 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1887 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
1834 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1835 | |
1888 | if (bowspeed < 1) |
1836 | if (bowspeed < 1) |
1889 | bowspeed = 1; |
1837 | bowspeed = 1; |
1890 | |
1838 | |
1891 | if (arrow == NULL) |
1839 | if (arrow == NULL) |
1892 | { |
1840 | { |
… | |
… | |
1898 | else |
1846 | else |
1899 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1847 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1900 | return 0; |
1848 | return 0; |
1901 | } |
1849 | } |
1902 | } |
1850 | } |
|
|
1851 | |
1903 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1852 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1904 | if (mflags & P_OUT_OF_MAP) |
1853 | if (mflags & P_OUT_OF_MAP) |
1905 | { |
|
|
1906 | return 0; |
1854 | return 0; |
1907 | } |
1855 | |
1908 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1856 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1909 | { |
1857 | { |
1910 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1858 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1911 | return 0; |
1859 | return 0; |
1912 | } |
1860 | } |
1913 | |
1861 | |
1914 | /* this should not happen, but sometimes does */ |
1862 | /* this should not happen, but sometimes does */ |
1915 | if (arrow->nrof == 0) |
1863 | if (arrow->nrof == 0) |
1916 | { |
1864 | { |
1917 | remove_ob (arrow); |
1865 | arrow->destroy (); |
1918 | free_object (arrow); |
|
|
1919 | return 0; |
1866 | return 0; |
1920 | } |
1867 | } |
1921 | |
1868 | |
1922 | left = arrow; /* these are arrows left to the player */ |
1869 | left = arrow; /* these are arrows left to the player */ |
1923 | left_tag = left->count; |
|
|
1924 | arrow = get_split_ob (arrow, 1); |
1870 | arrow = get_split_ob (arrow, 1); |
1925 | if (arrow == NULL) |
1871 | if (!arrow) |
1926 | { |
1872 | { |
1927 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1873 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1928 | return 0; |
1874 | return 0; |
1929 | } |
1875 | } |
1930 | set_owner (arrow, op); |
1876 | |
|
|
1877 | arrow->set_owner (op); |
1931 | arrow->skill = bow->skill; |
1878 | arrow->skill = bow->skill; |
1932 | |
1879 | |
1933 | arrow->direction = dir; |
1880 | arrow->direction = dir; |
1934 | arrow->x = sx; |
1881 | arrow->x = sx; |
1935 | arrow->y = sy; |
1882 | arrow->y = sy; |
… | |
… | |
1943 | SET_ANIMATION (arrow, arrow->direction); |
1890 | SET_ANIMATION (arrow, arrow->direction); |
1944 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1891 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1945 | arrow->stats.hp = arrow->stats.dam; |
1892 | arrow->stats.hp = arrow->stats.dam; |
1946 | arrow->stats.grace = arrow->attacktype; |
1893 | arrow->stats.grace = arrow->attacktype; |
1947 | if (arrow->slaying != NULL) |
1894 | if (arrow->slaying != NULL) |
1948 | arrow->spellarg = strdup_local (arrow->slaying); |
1895 | arrow->spellarg = strdup (arrow->slaying); |
1949 | |
1896 | |
1950 | /* Note that this was different for monsters - they got their level |
1897 | /* Note that this was different for monsters - they got their level |
1951 | * added to the damage. I think the strength bonus is more proper. |
1898 | * added to the damage. I think the strength bonus is more proper. |
1952 | */ |
1899 | */ |
1953 | |
1900 | |
… | |
… | |
1971 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1918 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1972 | } |
1919 | } |
1973 | else |
1920 | else |
1974 | { |
1921 | { |
1975 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1922 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1976 | |
|
|
1977 | arrow->level = op->level; |
1923 | arrow->level = op->level; |
1978 | } |
1924 | } |
|
|
1925 | |
1979 | if (arrow->attacktype == AT_PHYSICAL) |
1926 | if (arrow->attacktype == AT_PHYSICAL) |
1980 | arrow->attacktype |= bow->attacktype; |
1927 | arrow->attacktype |= bow->attacktype; |
|
|
1928 | |
1981 | if (bow->slaying != NULL) |
1929 | if (bow->slaying) |
1982 | arrow->slaying = bow->slaying; |
1930 | arrow->slaying = bow->slaying; |
1983 | |
1931 | |
1984 | arrow->map = m; |
1932 | arrow->map = m; |
1985 | arrow->move_type = MOVE_FLY_LOW; |
1933 | arrow->move_type = MOVE_FLY_LOW; |
1986 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1934 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1987 | |
1935 | |
1988 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1936 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1989 | tag = arrow->count; |
|
|
1990 | insert_ob_in_map (arrow, m, op, 0); |
1937 | insert_ob_in_map (arrow, m, op, 0); |
1991 | |
1938 | |
1992 | if (!was_destroyed (arrow, tag)) |
1939 | if (!arrow->destroyed ()) |
1993 | move_arrow (arrow); |
1940 | move_arrow (arrow); |
1994 | |
1941 | |
1995 | if (op->type == PLAYER) |
1942 | if (op->type == PLAYER) |
1996 | { |
1943 | { |
1997 | if (was_destroyed (left, left_tag)) |
1944 | if (left->destroyed ()) |
1998 | esrv_del_item (op->contr, left_tag); |
1945 | esrv_del_item (op->contr, left->count); |
1999 | else |
1946 | else |
2000 | esrv_send_item (op, left); |
1947 | esrv_send_item (op, left); |
2001 | } |
1948 | } |
|
|
1949 | |
2002 | return 1; |
1950 | return 1; |
2003 | } |
1951 | } |
2004 | |
1952 | |
2005 | /* Special fire code for players - this takes into |
1953 | /* Special fire code for players - this takes into |
2006 | * account the special fire modes players can have |
1954 | * account the special fire modes players can have |
… | |
… | |
2126 | if (action_makes_visible (op)) |
2074 | if (action_makes_visible (op)) |
2127 | make_visible (op); |
2075 | make_visible (op); |
2128 | |
2076 | |
2129 | switch (op->contr->shoottype) |
2077 | switch (op->contr->shoottype) |
2130 | { |
2078 | { |
2131 | case range_none: |
2079 | case range_none: |
2132 | return; |
2080 | return; |
2133 | |
2081 | |
2134 | case range_bow: |
2082 | case range_bow: |
2135 | player_fire_bow (op, dir); |
2083 | player_fire_bow (op, dir); |
2136 | return; |
2084 | return; |
2137 | |
2085 | |
2138 | case range_magic: /* Casting spells */ |
2086 | case range_magic: /* Casting spells */ |
2139 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : NULL)); |
2087 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0)); |
2140 | return; |
2088 | return; |
2141 | |
2089 | |
2142 | case range_misc: |
2090 | case range_misc: |
2143 | fire_misc_object (op, dir); |
2091 | fire_misc_object (op, dir); |
2144 | return; |
2092 | return; |
2145 | |
2093 | |
2146 | case range_golem: /* Control summoned monsters from scrolls */ |
2094 | case range_golem: /* Control summoned monsters from scrolls */ |
2147 | if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) |
2095 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2148 | { |
2096 | { |
2149 | op->contr->ranges[range_golem] = NULL; |
2097 | op->contr->ranges[range_golem] = 0; |
2150 | op->contr->shoottype = range_none; |
2098 | op->contr->shoottype = range_none; |
2151 | op->contr->golem_count = 0; |
|
|
2152 | } |
2099 | } |
2153 | else |
2100 | else |
2154 | control_golem (op->contr->ranges[range_golem], dir); |
2101 | control_golem (op->contr->ranges[range_golem], dir); |
2155 | return; |
2102 | return; |
2156 | |
2103 | |
2157 | case range_skill: |
2104 | case range_skill: |
2158 | if (!op->chosen_skill) |
2105 | if (!op->chosen_skill) |
2159 | { |
2106 | { |
2160 | if (op->type == PLAYER) |
2107 | if (op->type == PLAYER) |
2161 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2108 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2162 | return; |
2109 | return; |
2163 | } |
2110 | } |
2164 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2111 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2165 | return; |
2112 | return; |
2166 | case range_builder: |
2113 | case range_builder: |
2167 | apply_map_builder (op, dir); |
2114 | apply_map_builder (op, dir); |
2168 | return; |
2115 | return; |
2169 | default: |
2116 | default: |
2170 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2117 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2171 | return; |
2118 | return; |
2172 | } |
2119 | } |
2173 | } |
2120 | } |
2174 | |
2121 | |
2175 | |
2122 | |
2176 | |
2123 | |
… | |
… | |
2318 | move_player_attack (object *op, int dir) |
2265 | move_player_attack (object *op, int dir) |
2319 | { |
2266 | { |
2320 | object *tmp, *mon; |
2267 | object *tmp, *mon; |
2321 | sint16 nx, ny; |
2268 | sint16 nx, ny; |
2322 | int on_battleground; |
2269 | int on_battleground; |
2323 | mapstruct *m; |
2270 | maptile *m; |
2324 | |
2271 | |
2325 | nx = freearr_x[dir] + op->x; |
2272 | nx = freearr_x[dir] + op->x; |
2326 | ny = freearr_y[dir] + op->y; |
2273 | ny = freearr_y[dir] + op->y; |
2327 | |
2274 | |
2328 | on_battleground = op_on_battleground (op, NULL, NULL); |
2275 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2364 | if (tmp == op) |
2311 | if (tmp == op) |
2365 | { |
2312 | { |
2366 | tmp = tmp->above; |
2313 | tmp = tmp->above; |
2367 | continue; |
2314 | continue; |
2368 | } |
2315 | } |
|
|
2316 | |
2369 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2317 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2370 | { |
2318 | { |
2371 | mon = tmp; |
2319 | mon = tmp; |
2372 | break; |
2320 | break; |
2373 | } |
2321 | } |
|
|
2322 | |
2374 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2323 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2375 | mon = tmp; |
2324 | mon = tmp; |
|
|
2325 | |
2376 | tmp = tmp->above; |
2326 | tmp = tmp->above; |
2377 | } |
2327 | } |
2378 | |
2328 | |
2379 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2329 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2380 | return; /* into a wall */ |
2330 | return; /* into a wall */ |
… | |
… | |
2399 | * player owns it and it is either friendly or unagressive. |
2349 | * player owns it and it is either friendly or unagressive. |
2400 | */ |
2350 | */ |
2401 | if ((op->type == PLAYER) |
2351 | if ((op->type == PLAYER) |
2402 | #if COZY_SERVER |
2352 | #if COZY_SERVER |
2403 | && |
2353 | && |
2404 | ((get_owner (mon) && get_owner (mon)->contr |
2354 | ((mon->owner && mon->owner->contr |
2405 | && 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) |
2406 | #else |
2356 | #else |
2407 | && get_owner (mon) == op |
2357 | && mon->owner == op |
2408 | #endif |
2358 | #endif |
2409 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2359 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2410 | { |
2360 | { |
2411 | /* 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 */ |
2412 | if (op->contr->braced) |
2362 | if (op->contr->braced) |
… | |
… | |
2599 | /* I've been seeing crashes where the golem has been destroyed, but |
2549 | /* I've been seeing crashes where the golem has been destroyed, but |
2600 | * the player object still points to the defunct golem. The code that |
2550 | * the player object still points to the defunct golem. The code that |
2601 | * destroys the golem looks correct, and it doesn't always happen, so |
2551 | * destroys the golem looks correct, and it doesn't always happen, so |
2602 | * put this in a a workaround to clean up the golem pointer. |
2552 | * put this in a a workaround to clean up the golem pointer. |
2603 | */ |
2553 | */ |
2604 | if (op->contr->ranges[range_golem] && |
|
|
2605 | ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) |
2554 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2606 | { |
|
|
2607 | op->contr->ranges[range_golem] = NULL; |
2555 | op->contr->ranges[range_golem] = 0; |
2608 | op->contr->golem_count = 0; |
|
|
2609 | } |
|
|
2610 | |
2556 | |
2611 | /* call this here - we also will call this in do_ericserver, but |
2557 | /* call this here - we also will call this in do_ericserver, but |
2612 | * the players time has been increased when doericserver has been |
2558 | * the players time has been increased when doericserver has been |
2613 | * called, so we recheck it here. |
2559 | * called, so we recheck it here. |
2614 | */ |
2560 | */ |
2615 | HandleClient (&op->contr->socket, op->contr); |
2561 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
|
|
2562 | for (int rep = 8; --rep && op->contr->socket->handle_command (); ) |
|
|
2563 | ; |
|
|
2564 | |
2616 | if (op->speed_left < 0) |
2565 | if (op->speed_left < 0) |
2617 | return 0; |
2566 | return 0; |
2618 | |
2567 | |
2619 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2568 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2620 | { |
2569 | { |
… | |
… | |
2629 | if (op->speed_left > 0) |
2578 | if (op->speed_left > 0) |
2630 | return 1; |
2579 | return 1; |
2631 | else |
2580 | else |
2632 | return 0; |
2581 | return 0; |
2633 | } |
2582 | } |
|
|
2583 | |
2634 | return 0; |
2584 | return 0; |
2635 | } |
2585 | } |
2636 | |
2586 | |
2637 | int |
2587 | int |
2638 | save_life (object *op) |
2588 | save_life (object *op) |
2639 | { |
2589 | { |
2640 | object *tmp; |
|
|
2641 | |
|
|
2642 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2590 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2643 | return 0; |
2591 | return 0; |
2644 | |
2592 | |
2645 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2593 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2646 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2594 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2647 | { |
2595 | { |
2648 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2596 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2649 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2597 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
|
|
2598 | |
2650 | if (op->contr) |
2599 | if (op->contr) |
2651 | esrv_del_item (op->contr, tmp->count); |
2600 | esrv_del_item (op->contr, tmp->count); |
2652 | remove_ob (tmp); |
2601 | |
2653 | free_object (tmp); |
2602 | tmp->destroy (); |
2654 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2603 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2604 | |
2655 | if (op->stats.hp < 0) |
2605 | if (op->stats.hp < 0) |
2656 | op->stats.hp = op->stats.maxhp; |
2606 | op->stats.hp = op->stats.maxhp; |
|
|
2607 | |
2657 | if (op->stats.food < 0) |
2608 | if (op->stats.food < 0) |
2658 | op->stats.food = 999; |
2609 | op->stats.food = 999; |
|
|
2610 | |
2659 | fix_player (op); |
2611 | fix_player (op); |
2660 | return 1; |
2612 | return 1; |
2661 | } |
2613 | } |
|
|
2614 | |
2662 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2615 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2663 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2616 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2664 | enter_player_savebed (op); /* bring him home. */ |
2617 | enter_player_savebed (op); /* bring him home. */ |
2665 | return 0; |
2618 | return 0; |
2666 | } |
2619 | } |
… | |
… | |
2680 | next = op->below; /* Make sure we have a good value, in case |
2633 | next = op->below; /* Make sure we have a good value, in case |
2681 | * we remove object 'op' |
2634 | * we remove object 'op' |
2682 | */ |
2635 | */ |
2683 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2636 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2684 | { |
2637 | { |
2685 | remove_ob (op); |
2638 | op->remove (); |
2686 | op->x = env->x; |
2639 | op->x = env->x; |
2687 | op->y = env->y; |
2640 | op->y = env->y; |
2688 | if (env->type == PLAYER) |
2641 | if (env->type == PLAYER) |
2689 | esrv_del_item (env->contr, op->count); |
2642 | esrv_del_item (env->contr, op->count); |
2690 | insert_ob_in_map (op, env->map, NULL, 0); |
2643 | insert_ob_in_map (op, env->map, NULL, 0); |
2691 | } |
2644 | } |
2692 | else if (op->inv) |
2645 | else if (op->inv) |
2693 | remove_unpaid_objects (op->inv, env); |
2646 | remove_unpaid_objects (op->inv, env); |
|
|
2647 | |
2694 | op = next; |
2648 | op = next; |
2695 | } |
2649 | } |
2696 | } |
2650 | } |
2697 | |
2651 | |
2698 | |
2652 | |
… | |
… | |
2713 | strcpy (buf2, " R.I.P.\n\n"); |
2667 | strcpy (buf2, " R.I.P.\n\n"); |
2714 | if (op->type == PLAYER) |
2668 | if (op->type == PLAYER) |
2715 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2669 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2716 | else |
2670 | else |
2717 | sprintf (buf, "%s\n", &op->name); |
2671 | sprintf (buf, "%s\n", &op->name); |
|
|
2672 | |
2718 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2673 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2719 | strcat (buf2, buf); |
2674 | strcat (buf2, buf); |
2720 | if (op->type == PLAYER) |
2675 | if (op->type == PLAYER) |
2721 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2676 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2722 | else |
2677 | else |
2723 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
2678 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2679 | |
2724 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2680 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2725 | strcat (buf2, buf); |
2681 | strcat (buf2, buf); |
2726 | if (op->type == PLAYER) |
2682 | if (op->type == PLAYER) |
2727 | { |
2683 | { |
2728 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2684 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2729 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2685 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2730 | strcat (buf2, buf); |
2686 | strcat (buf2, buf); |
2731 | } |
2687 | } |
|
|
2688 | |
2732 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2689 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2733 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2690 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2734 | strcat (buf2, buf); |
2691 | strcat (buf2, buf); |
|
|
2692 | |
2735 | return buf2; |
2693 | return buf2; |
2736 | } |
2694 | } |
2737 | |
2695 | |
2738 | |
2696 | |
2739 | |
2697 | |
… | |
… | |
2958 | { |
2916 | { |
2959 | char buf[MAX_BUF]; |
2917 | char buf[MAX_BUF]; |
2960 | int x, y; |
2918 | int x, y; |
2961 | |
2919 | |
2962 | //int i; |
2920 | //int i; |
2963 | mapstruct *map; /* this is for resurrection */ |
2921 | maptile *map; /* this is for resurrection */ |
2964 | |
2922 | |
2965 | /* int z; |
2923 | /* int z; |
2966 | int num_stats_lose; |
2924 | int num_stats_lose; |
2967 | int lost_a_stat; |
2925 | int lost_a_stat; |
2968 | int lose_this_stat; |
2926 | int lose_this_stat; |
… | |
… | |
2983 | { |
2941 | { |
2984 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2942 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2985 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2943 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2986 | |
2944 | |
2987 | /* restore player */ |
2945 | /* restore player */ |
2988 | at = find_archetype ("poisoning"); |
2946 | at = archetype::find ("poisoning"); |
2989 | tmp = present_arch_in_ob (at, op); |
2947 | tmp = present_arch_in_ob (at, op); |
2990 | if (tmp) |
2948 | if (tmp) |
2991 | { |
2949 | { |
2992 | remove_ob (tmp); |
2950 | tmp->destroy (); |
2993 | free_object (tmp); |
|
|
2994 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2951 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2995 | } |
2952 | } |
2996 | |
2953 | |
2997 | at = find_archetype ("confusion"); |
2954 | at = archetype::find ("confusion"); |
2998 | tmp = present_arch_in_ob (at, op); |
2955 | tmp = present_arch_in_ob (at, op); |
2999 | if (tmp) |
2956 | if (tmp) |
3000 | { |
2957 | { |
3001 | remove_ob (tmp); |
2958 | tmp->destroy (); |
3002 | free_object (tmp); |
|
|
3003 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2959 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3004 | } |
2960 | } |
3005 | |
2961 | |
3006 | cure_disease (op, 0); /* remove any disease */ |
2962 | cure_disease (op, 0); /* remove any disease */ |
3007 | op->stats.hp = op->stats.maxhp; |
2963 | op->stats.hp = op->stats.maxhp; |
3008 | if (op->stats.food <= 0) |
2964 | if (op->stats.food <= 0) |
3009 | op->stats.food = 999; |
2965 | op->stats.food = 999; |
3010 | |
2966 | |
3011 | /* create a bodypart-trophy to make the winner happy */ |
2967 | /* create a bodypart-trophy to make the winner happy */ |
3012 | tmp = arch_to_object (find_archetype ("finger")); |
2968 | tmp = arch_to_object (archetype::find ("finger")); |
3013 | if (tmp != NULL) |
2969 | if (tmp != NULL) |
3014 | { |
2970 | { |
3015 | sprintf (buf, "%s's finger", &op->name); |
2971 | sprintf (buf, "%s's finger", &op->name); |
3016 | tmp->name = buf; |
2972 | tmp->name = buf; |
3017 | sprintf (buf, " This finger has been cut off %s\n" |
2973 | sprintf (buf, " This finger has been cut off %s\n" |
… | |
… | |
3114 | lost_a_stat = 1; |
3070 | lost_a_stat = 1; |
3115 | } |
3071 | } |
3116 | else |
3072 | else |
3117 | { |
3073 | { |
3118 | /* deplete a stat */ |
3074 | /* deplete a stat */ |
3119 | archetype *deparch = find_archetype ("depletion"); |
3075 | archetype *deparch = archetype::find ("depletion"); |
3120 | object *dep; |
3076 | object *dep; |
3121 | |
3077 | |
3122 | dep = present_arch_in_ob (deparch, op); |
3078 | dep = present_arch_in_ob (deparch, op); |
3123 | if (!dep) |
3079 | if (!dep) |
3124 | { |
3080 | { |
… | |
… | |
3184 | /* determine_god() seems to not work sometimes... why is this? |
3140 | /* determine_god() seems to not work sometimes... why is this? |
3185 | Should I be using something else? GD */ |
3141 | Should I be using something else? GD */ |
3186 | const char *god = determine_god (op); |
3142 | const char *god = determine_god (op); |
3187 | |
3143 | |
3188 | if (god && (strcmp (god, "none"))) |
3144 | if (god && (strcmp (god, "none"))) |
3189 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3145 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3190 | else |
3146 | else |
3191 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3147 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3192 | } |
3148 | } |
|
|
3149 | #else |
|
|
3150 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3193 | #endif |
3151 | #endif |
3194 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3195 | |
3152 | |
3196 | /* Put a gravestone up where the character 'almost' died. List the |
3153 | /* Put a gravestone up where the character 'almost' died. List the |
3197 | * exp loss on the stone. |
3154 | * exp loss on the stone. |
3198 | */ |
3155 | */ |
3199 | tmp = arch_to_object (find_archetype ("gravestone")); |
3156 | tmp = arch_to_object (archetype::find ("gravestone")); |
3200 | sprintf (buf, "%s's gravestone", &op->name); |
3157 | sprintf (buf, "%s's gravestone", &op->name); |
3201 | tmp->name = buf; |
3158 | tmp->name = buf; |
3202 | sprintf (buf, "%s's gravestones", &op->name); |
3159 | sprintf (buf, "%s's gravestones", &op->name); |
3203 | tmp->name_pl = buf; |
3160 | tmp->name_pl = buf; |
3204 | 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); |
3161 | 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); |
3205 | tmp->msg = buf; |
3162 | tmp->msg = buf; |
3206 | tmp->x = op->x, tmp->y = op->y; |
3163 | tmp->x = op->x, tmp->y = op->y; |
3207 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3164 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3208 | |
3165 | |
3209 | /**************************************/ |
3166 | /**************************************/ |
3210 | /* */ |
3167 | /* */ |
3211 | /* Subtract the experience points, */ |
3168 | /* Subtract the experience points, */ |
3212 | /* if we died cause of food, give us */ |
3169 | /* if we died cause of food, give us */ |
3213 | /* food, and reset HP's... */ |
3170 | /* food, and reset HP's... */ |
3214 | /* */ |
3171 | /* */ |
3215 | |
|
|
3216 | /**************************************/ |
3172 | /**************************************/ |
3217 | |
3173 | |
3218 | /* remove any poisoning and confusion the character may be suffering. */ |
3174 | /* remove any poisoning and confusion the character may be suffering. */ |
3219 | /* restore player */ |
3175 | /* restore player */ |
3220 | at = find_archetype ("poisoning"); |
3176 | at = archetype::find ("poisoning"); |
|
|
3177 | tmp = present_arch_in_ob (at, op); |
|
|
3178 | |
|
|
3179 | if (tmp) |
|
|
3180 | { |
|
|
3181 | tmp->destroy (); |
|
|
3182 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3183 | } |
|
|
3184 | |
|
|
3185 | at = archetype::find ("confusion"); |
3221 | tmp = present_arch_in_ob (at, op); |
3186 | tmp = present_arch_in_ob (at, op); |
3222 | if (tmp) |
3187 | if (tmp) |
3223 | { |
3188 | { |
3224 | remove_ob (tmp); |
3189 | tmp->destroy (); |
3225 | free_object (tmp); |
|
|
3226 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3227 | } |
|
|
3228 | |
|
|
3229 | at = find_archetype ("confusion"); |
|
|
3230 | tmp = present_arch_in_ob (at, op); |
|
|
3231 | if (tmp) |
|
|
3232 | { |
|
|
3233 | remove_ob (tmp); |
|
|
3234 | free_object (tmp); |
|
|
3235 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3190 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3236 | } |
3191 | } |
|
|
3192 | |
3237 | cure_disease (op, 0); /* remove any disease */ |
3193 | cure_disease (op, 0); /* remove any disease */ |
3238 | |
3194 | |
3239 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3195 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3240 | apply_death_exp_penalty (op); |
3196 | apply_death_exp_penalty (op); |
3241 | if (op->stats.food < 100) |
3197 | if (op->stats.food < 100) |
… | |
… | |
3251 | */ |
3207 | */ |
3252 | |
3208 | |
3253 | if (is_in_shop (op)) |
3209 | if (is_in_shop (op)) |
3254 | remove_unpaid_objects (op->inv, op); |
3210 | remove_unpaid_objects (op->inv, op); |
3255 | |
3211 | |
3256 | /****************************************/ |
3212 | /****************************************/ |
3257 | /* */ |
3213 | /* */ |
3258 | /* Move player to his current respawn- */ |
3214 | /* Move player to his current respawn- */ |
3259 | /* position (usually last savebed) */ |
3215 | /* position (usually last savebed) */ |
3260 | /* */ |
3216 | /* */ |
3261 | |
|
|
3262 | /****************************************/ |
3217 | /****************************************/ |
3263 | |
3218 | |
3264 | enter_player_savebed (op); |
3219 | enter_player_savebed (op); |
3265 | |
3220 | |
3266 | /* Save the player before inserting the force to reduce |
3221 | /* Save the player before inserting the force to reduce |
3267 | * chance of abuse. |
3222 | * chance of abuse. |
… | |
… | |
3274 | * spell effects. So first see if there is a spell effect |
3229 | * spell effects. So first see if there is a spell effect |
3275 | * on the space that might harm the player. |
3230 | * on the space that might harm the player. |
3276 | */ |
3231 | */ |
3277 | will_kill_again = 0; |
3232 | will_kill_again = 0; |
3278 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3233 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3279 | { |
|
|
3280 | if (tmp->type == SPELL_EFFECT) |
3234 | if (tmp->type == SPELL_EFFECT) |
3281 | will_kill_again |= tmp->attacktype; |
3235 | will_kill_again |= tmp->attacktype; |
3282 | } |
3236 | |
3283 | if (will_kill_again) |
3237 | if (will_kill_again) |
3284 | { |
3238 | { |
3285 | object *force; |
3239 | object *force; |
3286 | int at; |
3240 | int at; |
3287 | |
3241 | |
… | |
… | |
3289 | /* 50 ticks should be enough time for the spell to abate */ |
3243 | /* 50 ticks should be enough time for the spell to abate */ |
3290 | force->speed = 0.1; |
3244 | force->speed = 0.1; |
3291 | force->speed_left = -5.0; |
3245 | force->speed_left = -5.0; |
3292 | SET_FLAG (force, FLAG_APPLIED); |
3246 | SET_FLAG (force, FLAG_APPLIED); |
3293 | for (at = 0; at < NROFATTACKS; at++) |
3247 | for (at = 0; at < NROFATTACKS; at++) |
3294 | { |
|
|
3295 | if (will_kill_again & (1 << at)) |
3248 | if (will_kill_again & (1 << at)) |
3296 | force->resist[at] = 100; |
3249 | force->resist[at] = 100; |
3297 | } |
3250 | |
3298 | insert_ob_in_ob (force, op); |
3251 | insert_ob_in_ob (force, op); |
3299 | fix_player (op); |
3252 | fix_player (op); |
3300 | |
3253 | |
3301 | } |
3254 | } |
3302 | |
3255 | |
… | |
… | |
3312 | op->contr->party = NULL; |
3265 | op->contr->party = NULL; |
3313 | if (settings.set_title == TRUE) |
3266 | if (settings.set_title == TRUE) |
3314 | op->contr->own_title[0] = '\0'; |
3267 | op->contr->own_title[0] = '\0'; |
3315 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3268 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3316 | check_score (op); |
3269 | check_score (op); |
|
|
3270 | |
3317 | if (op->contr->ranges[range_golem] != NULL) |
3271 | if (op->contr->ranges[range_golem]) |
3318 | { |
3272 | { |
3319 | remove_friendly_object (op->contr->ranges[range_golem]); |
3273 | remove_friendly_object (op->contr->ranges[range_golem]); |
3320 | remove_ob (op->contr->ranges[range_golem]); |
3274 | op->contr->ranges[range_golem]->destroy (); |
3321 | free_object (op->contr->ranges[range_golem]); |
|
|
3322 | op->contr->ranges[range_golem] = NULL; |
3275 | op->contr->ranges[range_golem] = 0; |
3323 | op->contr->golem_count = 0; |
|
|
3324 | } |
3276 | } |
|
|
3277 | |
3325 | loot_object (op); /* Remove some of the items for good */ |
3278 | loot_object (op); /* Remove some of the items for good */ |
3326 | remove_ob (op); |
3279 | op->remove (); |
3327 | op->direction = 0; |
3280 | op->direction = 0; |
3328 | |
3281 | |
3329 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3282 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3330 | { |
3283 | { |
3331 | delete_character (op->name, 0); |
3284 | delete_character (op->name, 0); |
… | |
… | |
3356 | } |
3309 | } |
3357 | |
3310 | |
3358 | play_again (op); |
3311 | play_again (op); |
3359 | |
3312 | |
3360 | /* peterm: added to create a corpse at deathsite. */ |
3313 | /* peterm: added to create a corpse at deathsite. */ |
3361 | tmp = arch_to_object (find_archetype ("corpse_pl")); |
3314 | tmp = arch_to_object (archetype::find ("corpse_pl")); |
3362 | sprintf (buf, "%s", &op->name); |
3315 | sprintf (buf, "%s", &op->name); |
3363 | tmp->name = tmp->name_pl = buf; |
3316 | tmp->name = tmp->name_pl = buf; |
3364 | tmp->level = op->level; |
3317 | tmp->level = op->level; |
3365 | tmp->x = x; |
3318 | tmp->x = x; |
3366 | tmp->y = y; |
3319 | tmp->y = y; |
… | |
… | |
3384 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3337 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3385 | { |
3338 | { |
3386 | next = tmp->below; |
3339 | next = tmp->below; |
3387 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3340 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3388 | continue; |
3341 | continue; |
3389 | remove_ob (tmp); |
3342 | tmp->remove (); |
3390 | tmp->x = op->x, tmp->y = op->y; |
3343 | tmp->x = op->x, tmp->y = op->y; |
3391 | if (tmp->type == CONTAINER) |
3344 | if (tmp->type == CONTAINER) |
3392 | { /* empty container to ground */ |
3345 | { /* empty container to ground */ |
3393 | loot_object (tmp); |
3346 | loot_object (tmp); |
3394 | } |
3347 | } |
3395 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3348 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3396 | { |
3349 | { |
3397 | if (tmp->nrof > 1) |
3350 | if (tmp->nrof > 1) |
3398 | { |
3351 | { |
3399 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3352 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3400 | free_object (tmp2); |
3353 | tmp2->destroy (); |
3401 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3354 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3402 | } |
3355 | } |
3403 | else |
3356 | else |
3404 | free_object (tmp); |
3357 | tmp->destroy (); |
3405 | } |
3358 | } |
3406 | else |
3359 | else |
3407 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3360 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3408 | } |
3361 | } |
3409 | } |
3362 | } |
… | |
… | |
3474 | if (op->type == PLAYER) |
3427 | if (op->type == PLAYER) |
3475 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3428 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3476 | |
3429 | |
3477 | cast_spell (op, throw_ob, dir, spob, NULL); |
3430 | cast_spell (op, throw_ob, dir, spob, NULL); |
3478 | |
3431 | |
3479 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3432 | throw_ob->destroy (); |
3480 | remove_ob (throw_ob); |
|
|
3481 | free_object (throw_ob); |
|
|
3482 | } |
3433 | } |
3483 | |
3434 | |
3484 | void |
3435 | void |
3485 | make_visible (object *op) |
3436 | make_visible (object *op) |
3486 | { |
3437 | { |
… | |
… | |
3602 | int |
3553 | int |
3603 | stand_near_hostile (object *who) |
3554 | stand_near_hostile (object *who) |
3604 | { |
3555 | { |
3605 | object *tmp = NULL; |
3556 | object *tmp = NULL; |
3606 | int i, friendly = 0, player = 0, mflags; |
3557 | int i, friendly = 0, player = 0, mflags; |
3607 | mapstruct *m; |
3558 | maptile *m; |
3608 | sint16 x, y; |
3559 | sint16 x, y; |
3609 | |
3560 | |
3610 | if (!who) |
3561 | if (!who) |
3611 | return 0; |
3562 | return 0; |
3612 | |
3563 | |
… | |
… | |
3693 | |
3644 | |
3694 | /* only the viewable area the player sees is updated by LOS |
3645 | /* only the viewable area the player sees is updated by LOS |
3695 | * code, so we need to restrict ourselves to that range of values |
3646 | * code, so we need to restrict ourselves to that range of values |
3696 | * for any meaningful values. |
3647 | * for any meaningful values. |
3697 | */ |
3648 | */ |
3698 | if (FABS (dx) <= (pl->contr->socket.mapx / 2) && |
3649 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3699 | FABS (dy) <= (pl->contr->socket.mapy / 2) && |
3650 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3700 | !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) |
3651 | !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) |
3701 | return 1; |
3652 | return 1; |
3702 | op = op->more; |
3653 | op = op->more; |
3703 | } |
3654 | } |
3704 | return 0; |
3655 | return 0; |
3705 | } |
3656 | } |