1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
… | |
… | |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <sproto.h> |
25 | #include <sproto.h> |
26 | #include <sounds.h> |
26 | #include <sounds.h> |
… | |
… | |
183 | |
183 | |
184 | if (ob->map) |
184 | if (ob->map) |
185 | maplevel = ob->map->path; |
185 | maplevel = ob->map->path; |
186 | |
186 | |
187 | ob->remove (); |
187 | ob->remove (); |
|
|
188 | ob->enemy = 0; // sometimes keeps an extra refcount on itself |
188 | ob->map = 0; |
189 | ob->map = 0; |
189 | party = 0; |
190 | party = 0; |
190 | |
191 | |
191 | combat_ob = ranged_ob = 0; //TODO, should be special marker, non-refcounted, not this |
192 | combat_ob = ranged_ob = 0; //TODO, should be special marker, non-refcounted, not this |
192 | |
193 | |
… | |
… | |
214 | |
215 | |
215 | /* make sure he's a player -- needed because of class change. */ |
216 | /* make sure he's a player -- needed because of class change. */ |
216 | ob->type = PLAYER; // we are paranoid |
217 | ob->type = PLAYER; // we are paranoid |
217 | ob->race = ob->arch->race; |
218 | ob->race = ob->arch->race; |
218 | |
219 | |
219 | ob->carrying = sum_weight (ob); |
220 | ob->update_weight (); |
220 | link_player_skills (ob); |
221 | link_player_skills (ob); |
221 | |
222 | |
222 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
223 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
223 | |
224 | |
224 | assign (title, ob->arch->object::name); |
225 | assign (title, ob->arch->object::name); |
… | |
… | |
240 | |
241 | |
241 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
242 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
242 | |
243 | |
243 | esrv_new_player (this, ob->weight + ob->carrying); |
244 | esrv_new_player (this, ob->weight + ob->carrying); |
244 | |
245 | |
|
|
246 | ob->update_stats (); |
|
|
247 | |
|
|
248 | ns->floorbox_update (); |
|
|
249 | esrv_send_inventory (ob, ob); |
|
|
250 | esrv_add_spells (this, 0); |
|
|
251 | |
|
|
252 | activate (); |
|
|
253 | |
|
|
254 | send_rules (ob); |
|
|
255 | send_news (ob); |
|
|
256 | display_motd (ob); |
|
|
257 | |
|
|
258 | INVOKE_PLAYER (CONNECT, this); |
|
|
259 | INVOKE_PLAYER (LOGIN, this); |
|
|
260 | } |
|
|
261 | |
|
|
262 | void |
|
|
263 | player::disconnect () |
|
|
264 | { |
|
|
265 | if (ob) |
|
|
266 | { |
|
|
267 | ob->close_container (); //TODO: client-specific |
|
|
268 | ob->drop_unpaid_items (); |
|
|
269 | } |
|
|
270 | |
|
|
271 | if (ns) |
|
|
272 | { |
|
|
273 | if (active) |
|
|
274 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
|
|
275 | |
|
|
276 | INVOKE_PLAYER (DISCONNECT, this); |
|
|
277 | |
|
|
278 | ns->reset_stats (); |
|
|
279 | ns->pl = 0; |
|
|
280 | ns = 0; |
|
|
281 | } |
|
|
282 | |
|
|
283 | observe = ob; |
|
|
284 | |
|
|
285 | deactivate (); |
|
|
286 | } |
|
|
287 | |
|
|
288 | // the need for this function can be explained |
|
|
289 | // by load_object not returning the object |
|
|
290 | void |
|
|
291 | player::set_object (object *op) |
|
|
292 | { |
|
|
293 | ob = observe = op; |
|
|
294 | ob->contr = this; /* this aren't yet in archetype */ |
|
|
295 | |
|
|
296 | ob->speed = 1.0f; |
|
|
297 | ob->speed_left = 0.5f; |
|
|
298 | |
|
|
299 | ob->direction = 5; /* So player faces south */ |
|
|
300 | |
245 | ob->flag [FLAG_READY_WEAPON] = false; |
301 | ob->flag [FLAG_READY_WEAPON] = false; |
246 | ob->flag [FLAG_READY_SKILL] = false; |
302 | ob->flag [FLAG_READY_SKILL] = false; |
247 | ob->flag [FLAG_READY_BOW] = false; |
303 | ob->flag [FLAG_READY_BOW] = false; |
248 | |
304 | |
249 | for (object *op = ob->inv; op; op = op->below) |
305 | for (object *op = ob->inv; op; op = op->below) |
… | |
… | |
265 | combat_ob = op; |
321 | combat_ob = op; |
266 | break; |
322 | break; |
267 | } |
323 | } |
268 | |
324 | |
269 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
270 | ob->update_stats (); |
326 | ob->deactivate (); // change_Weapon activates, fix this better |
271 | |
|
|
272 | ns->floorbox_update (); |
|
|
273 | esrv_send_inventory (ob, ob); |
|
|
274 | esrv_add_spells (this, 0); |
|
|
275 | |
|
|
276 | activate (); |
|
|
277 | |
|
|
278 | send_rules (ob); |
|
|
279 | send_news (ob); |
|
|
280 | display_motd (ob); |
|
|
281 | |
|
|
282 | INVOKE_PLAYER (CONNECT, this); |
|
|
283 | INVOKE_PLAYER (LOGIN, this); |
|
|
284 | } |
|
|
285 | |
|
|
286 | void |
|
|
287 | player::disconnect () |
|
|
288 | { |
|
|
289 | if (ob) |
|
|
290 | { |
|
|
291 | ob->close_container (); //TODO: client-specific |
|
|
292 | ob->drop_unpaid_items (); |
|
|
293 | } |
|
|
294 | |
|
|
295 | if (ns) |
|
|
296 | { |
|
|
297 | if (active) |
|
|
298 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
|
|
299 | |
|
|
300 | INVOKE_PLAYER (DISCONNECT, this); |
|
|
301 | |
|
|
302 | ns->reset_stats (); |
|
|
303 | ns->pl = 0; |
|
|
304 | ns = 0; |
|
|
305 | } |
|
|
306 | |
|
|
307 | observe = ob; |
|
|
308 | |
|
|
309 | deactivate (); |
|
|
310 | } |
|
|
311 | |
|
|
312 | // the need for this function can be explained |
|
|
313 | // by load_object not returning the object |
|
|
314 | void |
|
|
315 | player::set_object (object *op) |
|
|
316 | { |
|
|
317 | ob = observe = op; |
|
|
318 | ob->contr = this; /* this aren't yet in archetype */ |
|
|
319 | |
|
|
320 | ob->speed = 1.0f; |
|
|
321 | ob->speed_left = 0.5f; |
|
|
322 | |
|
|
323 | ob->direction = 5; /* So player faces south */ |
|
|
324 | } |
327 | } |
325 | |
328 | |
326 | void |
329 | void |
327 | player::set_observe (object *op) |
330 | player::set_observe (object *op) |
328 | { |
331 | { |
… | |
… | |
401 | * Note: there MUST be at least one player archetype! |
404 | * Note: there MUST be at least one player archetype! |
402 | */ |
405 | */ |
403 | archetype * |
406 | archetype * |
404 | get_player_archetype (archetype *at) |
407 | get_player_archetype (archetype *at) |
405 | { |
408 | { |
|
|
409 | // archetypes could have been reloaded |
|
|
410 | archetype *nat = at ? archetype::find (at->archname) : archetypes [0]; |
|
|
411 | |
|
|
412 | if (!nat) |
|
|
413 | return at; |
|
|
414 | |
406 | archvec::iterator i = at ? archetypes.find (at) : archetypes.begin (); |
415 | archvec::iterator i = archetypes.find (nat); |
407 | |
416 | |
408 | for (;;) |
417 | for (;;) |
409 | { |
418 | { |
410 | if (++i == archetypes.end ()) |
419 | if (++i == archetypes.end ()) |
411 | i = archetypes.begin (); |
420 | i = archetypes.begin (); |
… | |
… | |
629 | |
638 | |
630 | return firstdir; |
639 | return firstdir; |
631 | } |
640 | } |
632 | |
641 | |
633 | void |
642 | void |
634 | give_initial_items (object *pl, treasurelist * items) |
643 | give_initial_items (object *pl, treasurelist *items) |
635 | { |
644 | { |
636 | object *op, *next = NULL; |
|
|
637 | |
|
|
638 | if (pl->randomitems != NULL) |
645 | if (pl->randomitems) |
639 | create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); |
646 | create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); |
640 | |
647 | |
641 | for (op = pl->inv; op; op = next) |
648 | for (object *next, *op = pl->inv; op; op = next) |
642 | { |
649 | { |
643 | next = op->below; |
650 | next = op->below; |
644 | |
651 | |
645 | /* Forces get applied per default, unless they have the |
652 | /* Forces get applied per default, unless they have the |
646 | * flag "neutral" set. Sorry but I can't think of a better way |
653 | * flag "neutral" set. Sorry but I can't think of a better way |
… | |
… | |
651 | /* we never give weapons/armour if these cannot be used |
658 | /* we never give weapons/armour if these cannot be used |
652 | * by this player due to race restrictions |
659 | * by this player due to race restrictions |
653 | */ |
660 | */ |
654 | if (pl->type == PLAYER) |
661 | if (pl->type == PLAYER) |
655 | { |
662 | { |
656 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) && |
663 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) |
|
|
664 | && |
657 | (op->type == ARMOUR || op->type == BOOTS || |
665 | (op->type == ARMOUR || op->type == BOOTS |
658 | op->type == CLOAK || op->type == HELMET || |
666 | || op->type == CLOAK || op->type == HELMET |
659 | op->type == SHIELD || op->type == GLOVES || |
667 | || op->type == SHIELD || op->type == GLOVES |
|
|
668 | || op->type == BRACERS || op->type == GIRDLE)) |
660 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
669 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
661 | { |
670 | { |
662 | op->destroy (); |
671 | op->destroy (); |
663 | continue; |
672 | continue; |
664 | } |
673 | } |
665 | } |
674 | } |
… | |
… | |
688 | if (op->nrof > 1) |
697 | if (op->nrof > 1) |
689 | op->nrof = 1; |
698 | op->nrof = 1; |
690 | } |
699 | } |
691 | |
700 | |
692 | if (op->type == SPELLBOOK && op->inv) |
701 | if (op->type == SPELLBOOK && op->inv) |
693 | { |
|
|
694 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
702 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
695 | } |
|
|
696 | |
703 | |
697 | /* Give starting characters identified, uncursed, and undamned |
704 | /* Give starting characters identified, uncursed, and undamned |
698 | * items. Just don't identify gold or silver, or it won't be |
705 | * items. Just don't identify gold or silver, or it won't be |
699 | * merged properly. |
706 | * merged properly. |
700 | */ |
707 | */ |
701 | if (need_identify (op)) |
708 | if (need_identify (op)) |
702 | { |
709 | { |
703 | SET_FLAG (op, FLAG_IDENTIFIED); |
710 | SET_FLAG (op, FLAG_IDENTIFIED); |
704 | CLEAR_FLAG (op, FLAG_CURSED); |
711 | CLEAR_FLAG (op, FLAG_CURSED); |
705 | CLEAR_FLAG (op, FLAG_DAMNED); |
712 | CLEAR_FLAG (op, FLAG_DAMNED); |
706 | } |
713 | } |
|
|
714 | |
707 | if (op->type == SPELL) |
715 | if (op->type == SPELL) |
708 | { |
716 | { |
709 | op->destroy (); |
717 | op->destroy (); |
710 | continue; |
718 | continue; |
711 | } |
719 | } |
… | |
… | |
713 | { |
721 | { |
714 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
722 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
715 | op->stats.exp = 0; |
723 | op->stats.exp = 0; |
716 | op->level = 1; |
724 | op->level = 1; |
717 | } |
725 | } |
718 | /* lock all 'normal items by default */ |
726 | else /* lock all 'normal items by default */ |
719 | else |
|
|
720 | SET_FLAG (op, FLAG_INV_LOCKED); |
727 | SET_FLAG (op, FLAG_INV_LOCKED); |
721 | } /* for loop of objects in player inv */ |
728 | } /* for loop of objects in player inv */ |
722 | |
729 | |
723 | /* Need to set up the skill pointers */ |
730 | /* Need to set up the skill pointers */ |
724 | link_player_skills (pl); |
731 | link_player_skills (pl); |
… | |
… | |
830 | static void |
837 | static void |
831 | start_info (object *op) |
838 | start_info (object *op) |
832 | { |
839 | { |
833 | char buf[MAX_BUF]; |
840 | char buf[MAX_BUF]; |
834 | |
841 | |
835 | sprintf (buf, "Welcome to Crossfire v%s!", VERSION); |
842 | sprintf (buf, "Welcome to Deliantra v%s!", VERSION); |
836 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
843 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
837 | //new_draw_info (NDI_UNIQUE, 0, op, "Press `?' for help"); |
|
|
838 | //new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
839 | } |
844 | } |
840 | |
845 | |
841 | /* This function takes the key that is passed, and does the |
846 | /* This function takes the key that is passed, and does the |
842 | * appropriate action with it (change race, or other things). |
847 | * appropriate action with it (change race, or other things). |
843 | * The function name is for historical reasons - now we have |
848 | * The function name is for historical reasons - now we have |
… | |
… | |
1006 | if (op->move_type & MOVE_FLYING) |
1011 | if (op->move_type & MOVE_FLYING) |
1007 | return 1; |
1012 | return 1; |
1008 | |
1013 | |
1009 | next = op->below; |
1014 | next = op->below; |
1010 | |
1015 | |
|
|
1016 | int cnt = MAX_ITEM_PER_DROP; |
|
|
1017 | #define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0) |
|
|
1018 | |
1011 | /* loop while there are items on the floor that are not marked as |
1019 | /* loop while there are items on the floor that are not marked as |
1012 | * destroyed */ |
1020 | * destroyed */ |
1013 | while (next && !next->destroyed ()) |
1021 | while (next && !next->destroyed ()) |
1014 | { |
1022 | { |
1015 | tmp = next; |
1023 | tmp = next; |
1016 | next = tmp->below; |
1024 | next = tmp->below; |
1017 | |
1025 | |
|
|
1026 | if (cnt <= 0) |
|
|
1027 | { |
|
|
1028 | op->failmsg ("Couldn't pickup all items at once."); |
|
|
1029 | return 0; |
|
|
1030 | } |
|
|
1031 | |
1018 | if (op->destroyed ()) |
1032 | if (op->destroyed ()) |
1019 | return 0; |
1033 | return 0; |
1020 | |
1034 | |
1021 | if (!can_pick (op, tmp)) |
1035 | if (!can_pick (op, tmp)) |
1022 | continue; |
1036 | continue; |
1023 | |
1037 | |
1024 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1038 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1025 | { |
1039 | { |
1026 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1040 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1027 | pick_up (op, tmp); |
1041 | CHK_PICK_PICKUP; |
1028 | continue; |
1042 | continue; |
1029 | } |
1043 | } |
1030 | |
1044 | |
1031 | /* high not bit set? We're using the old autopickup model */ |
1045 | /* high not bit set? We're using the old autopickup model */ |
1032 | if (!(op->contr->mode & PU_NEWMODE)) |
1046 | if (!(op->contr->mode & PU_NEWMODE)) |
… | |
… | |
1034 | switch (op->contr->mode) |
1048 | switch (op->contr->mode) |
1035 | { |
1049 | { |
1036 | case 0: |
1050 | case 0: |
1037 | return 1; /* don't pick up */ |
1051 | return 1; /* don't pick up */ |
1038 | case 1: |
1052 | case 1: |
1039 | pick_up (op, tmp); |
1053 | CHK_PICK_PICKUP; |
1040 | return 1; |
1054 | return 1; |
1041 | case 2: |
1055 | case 2: |
1042 | pick_up (op, tmp); |
1056 | CHK_PICK_PICKUP; |
1043 | return 0; |
1057 | return 0; |
1044 | case 3: |
1058 | case 3: |
1045 | return 0; /* stop before pickup */ |
1059 | return 0; /* stop before pickup */ |
1046 | case 4: |
1060 | case 4: |
1047 | pick_up (op, tmp); |
1061 | CHK_PICK_PICKUP; |
1048 | break; |
1062 | break; |
1049 | case 5: |
1063 | case 5: |
1050 | pick_up (op, tmp); |
1064 | CHK_PICK_PICKUP; |
1051 | stop = 1; |
1065 | stop = 1; |
1052 | break; |
1066 | break; |
1053 | case 6: |
1067 | case 6: |
1054 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1068 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) |
1055 | pick_up (op, tmp); |
1069 | && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1070 | CHK_PICK_PICKUP; |
1056 | break; |
1071 | break; |
1057 | |
1072 | |
1058 | case 7: |
1073 | case 7: |
1059 | if (tmp->type == MONEY || tmp->type == GEM) |
1074 | if (tmp->type == MONEY || tmp->type == GEM) |
1060 | pick_up (op, tmp); |
1075 | CHK_PICK_PICKUP; |
1061 | break; |
1076 | break; |
1062 | |
1077 | |
1063 | default: |
1078 | default: |
1064 | /* use value density */ |
1079 | /* use value density */ |
1065 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
1080 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
1066 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1081 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1067 | pick_up (op, tmp); |
1082 | CHK_PICK_PICKUP; |
1068 | } |
1083 | } |
1069 | } |
1084 | } |
1070 | else |
1085 | else |
1071 | { /* old model */ |
1086 | { /* old model */ |
1072 | /* NEW pickup handling */ |
1087 | /* NEW pickup handling */ |
… | |
… | |
1127 | /* all food and drink if desired */ |
1142 | /* all food and drink if desired */ |
1128 | /* question: don't pick up known-poisonous stuff? */ |
1143 | /* question: don't pick up known-poisonous stuff? */ |
1129 | if (op->contr->mode & PU_FOOD) |
1144 | if (op->contr->mode & PU_FOOD) |
1130 | if (tmp->type == FOOD) |
1145 | if (tmp->type == FOOD) |
1131 | { |
1146 | { |
1132 | pick_up (op, tmp); |
1147 | CHK_PICK_PICKUP; |
1133 | continue; |
1148 | continue; |
1134 | } |
1149 | } |
1135 | |
1150 | |
1136 | if (op->contr->mode & PU_DRINK) |
1151 | if (op->contr->mode & PU_DRINK) |
1137 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1152 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1138 | { |
1153 | { |
1139 | pick_up (op, tmp); |
1154 | CHK_PICK_PICKUP; |
1140 | continue; |
1155 | continue; |
1141 | } |
1156 | } |
1142 | |
1157 | |
1143 | if (op->contr->mode & PU_POTION) |
1158 | if (op->contr->mode & PU_POTION) |
1144 | if (tmp->type == POTION) |
1159 | if (tmp->type == POTION) |
1145 | { |
1160 | { |
1146 | pick_up (op, tmp); |
1161 | CHK_PICK_PICKUP; |
1147 | continue; |
1162 | continue; |
1148 | } |
1163 | } |
1149 | |
1164 | |
1150 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1165 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1151 | if (op->contr->mode & PU_SPELLBOOK) |
1166 | if (op->contr->mode & PU_SPELLBOOK) |
1152 | if (tmp->type == SPELLBOOK) |
1167 | if (tmp->type == SPELLBOOK) |
1153 | { |
1168 | { |
1154 | pick_up (op, tmp); |
1169 | CHK_PICK_PICKUP; |
1155 | continue; |
1170 | continue; |
1156 | } |
1171 | } |
1157 | |
1172 | |
1158 | if (op->contr->mode & PU_SKILLSCROLL) |
1173 | if (op->contr->mode & PU_SKILLSCROLL) |
1159 | if (tmp->type == SKILLSCROLL) |
1174 | if (tmp->type == SKILLSCROLL) |
1160 | { |
1175 | { |
1161 | pick_up (op, tmp); |
1176 | CHK_PICK_PICKUP; |
1162 | continue; |
1177 | continue; |
1163 | } |
1178 | } |
1164 | |
1179 | |
1165 | if (op->contr->mode & PU_READABLES) |
1180 | if (op->contr->mode & PU_READABLES) |
1166 | if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) |
1181 | if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) |
1167 | { |
1182 | { |
1168 | pick_up (op, tmp); |
1183 | CHK_PICK_PICKUP; |
1169 | continue; |
1184 | continue; |
1170 | } |
1185 | } |
1171 | |
1186 | |
1172 | /* wands/staves/rods/horns */ |
1187 | /* wands/staves/rods/horns */ |
1173 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1188 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1174 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1189 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1175 | { |
1190 | { |
1176 | pick_up (op, tmp); |
1191 | CHK_PICK_PICKUP; |
1177 | continue; |
1192 | continue; |
1178 | } |
1193 | } |
1179 | |
1194 | |
1180 | /* pick up all magical items */ |
1195 | /* pick up all magical items */ |
1181 | if (op->contr->mode & PU_MAGICAL) |
1196 | if (op->contr->mode & PU_MAGICAL) |
1182 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1197 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1183 | { |
1198 | { |
1184 | pick_up (op, tmp); |
1199 | CHK_PICK_PICKUP; |
1185 | continue; |
1200 | continue; |
1186 | } |
1201 | } |
1187 | |
1202 | |
1188 | if (op->contr->mode & PU_VALUABLES) |
1203 | if (op->contr->mode & PU_VALUABLES) |
1189 | { |
1204 | { |
1190 | if (tmp->type == MONEY || tmp->type == GEM) |
1205 | if (tmp->type == MONEY || tmp->type == GEM) |
1191 | { |
1206 | { |
1192 | pick_up (op, tmp); |
1207 | CHK_PICK_PICKUP; |
1193 | continue; |
1208 | continue; |
1194 | } |
1209 | } |
1195 | } |
1210 | } |
1196 | |
1211 | |
1197 | /* rings & amulets - talismans seems to be typed AMULET */ |
1212 | /* rings & amulets - talismans seems to be typed AMULET */ |
1198 | if (op->contr->mode & PU_JEWELS) |
1213 | if (op->contr->mode & PU_JEWELS) |
1199 | if (tmp->type == RING || tmp->type == AMULET) |
1214 | if (tmp->type == RING || tmp->type == AMULET) |
1200 | { |
1215 | { |
1201 | pick_up (op, tmp); |
1216 | CHK_PICK_PICKUP; |
1202 | continue; |
1217 | continue; |
1203 | } |
1218 | } |
1204 | |
1219 | |
1205 | /* we don't forget dragon food */ |
1220 | /* we don't forget dragon food */ |
1206 | if (op->contr->mode & PU_FLESH) |
1221 | if (op->contr->mode & PU_FLESH) |
1207 | if (tmp->type == FLESH) |
1222 | if (tmp->type == FLESH) |
1208 | { |
1223 | { |
1209 | pick_up (op, tmp); |
1224 | CHK_PICK_PICKUP; |
1210 | continue; |
1225 | continue; |
1211 | } |
1226 | } |
1212 | |
1227 | |
1213 | /* bows and arrows. Bows are good for selling! */ |
1228 | /* bows and arrows. Bows are good for selling! */ |
1214 | if (op->contr->mode & PU_BOW) |
1229 | if (op->contr->mode & PU_BOW) |
1215 | if (tmp->type == BOW) |
1230 | if (tmp->type == BOW) |
1216 | { |
1231 | { |
1217 | pick_up (op, tmp); |
1232 | CHK_PICK_PICKUP; |
1218 | continue; |
1233 | continue; |
1219 | } |
1234 | } |
1220 | |
1235 | |
1221 | if (op->contr->mode & PU_ARROW) |
1236 | if (op->contr->mode & PU_ARROW) |
1222 | if (tmp->type == ARROW) |
1237 | if (tmp->type == ARROW) |
1223 | { |
1238 | { |
1224 | pick_up (op, tmp); |
1239 | CHK_PICK_PICKUP; |
1225 | continue; |
1240 | continue; |
1226 | } |
1241 | } |
1227 | |
1242 | |
1228 | /* all kinds of armor etc. */ |
1243 | /* all kinds of armor etc. */ |
1229 | if (op->contr->mode & PU_ARMOUR) |
1244 | if (op->contr->mode & PU_ARMOUR) |
1230 | if (tmp->type == ARMOUR) |
1245 | if (tmp->type == ARMOUR) |
1231 | { |
1246 | { |
1232 | pick_up (op, tmp); |
1247 | CHK_PICK_PICKUP; |
1233 | continue; |
1248 | continue; |
1234 | } |
1249 | } |
1235 | |
1250 | |
1236 | if (op->contr->mode & PU_HELMET) |
1251 | if (op->contr->mode & PU_HELMET) |
1237 | if (tmp->type == HELMET) |
1252 | if (tmp->type == HELMET) |
1238 | { |
1253 | { |
1239 | pick_up (op, tmp); |
1254 | CHK_PICK_PICKUP; |
1240 | continue; |
1255 | continue; |
1241 | } |
1256 | } |
1242 | |
1257 | |
1243 | if (op->contr->mode & PU_SHIELD) |
1258 | if (op->contr->mode & PU_SHIELD) |
1244 | if (tmp->type == SHIELD) |
1259 | if (tmp->type == SHIELD) |
1245 | { |
1260 | { |
1246 | pick_up (op, tmp); |
1261 | CHK_PICK_PICKUP; |
1247 | continue; |
1262 | continue; |
1248 | } |
1263 | } |
1249 | |
1264 | |
1250 | if (op->contr->mode & PU_BOOTS) |
1265 | if (op->contr->mode & PU_BOOTS) |
1251 | if (tmp->type == BOOTS) |
1266 | if (tmp->type == BOOTS) |
1252 | { |
1267 | { |
1253 | pick_up (op, tmp); |
1268 | CHK_PICK_PICKUP; |
1254 | continue; |
1269 | continue; |
1255 | } |
1270 | } |
1256 | |
1271 | |
1257 | if (op->contr->mode & PU_GLOVES) |
1272 | if (op->contr->mode & PU_GLOVES) |
1258 | if (tmp->type == GLOVES) |
1273 | if (tmp->type == GLOVES) |
1259 | { |
1274 | { |
1260 | pick_up (op, tmp); |
1275 | CHK_PICK_PICKUP; |
1261 | continue; |
1276 | continue; |
1262 | } |
1277 | } |
1263 | |
1278 | |
1264 | if (op->contr->mode & PU_CLOAK) |
1279 | if (op->contr->mode & PU_CLOAK) |
1265 | if (tmp->type == CLOAK) |
1280 | if (tmp->type == CLOAK) |
1266 | { |
1281 | { |
1267 | pick_up (op, tmp); |
1282 | CHK_PICK_PICKUP; |
1268 | continue; |
1283 | continue; |
1269 | } |
1284 | } |
1270 | |
1285 | |
1271 | /* hoping to catch throwing daggers here */ |
1286 | /* hoping to catch throwing daggers here */ |
1272 | if (op->contr->mode & PU_MISSILEWEAPON) |
1287 | if (op->contr->mode & PU_MISSILEWEAPON) |
1273 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1288 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1274 | { |
1289 | { |
1275 | pick_up (op, tmp); |
1290 | CHK_PICK_PICKUP; |
1276 | continue; |
1291 | continue; |
1277 | } |
1292 | } |
1278 | |
1293 | |
1279 | /* careful: chairs and tables are weapons! */ |
1294 | /* careful: chairs and tables are weapons! */ |
1280 | if (op->contr->mode & PU_ALLWEAPON) |
1295 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1282 | if (tmp->type == WEAPON && tmp->name != NULL) |
1297 | if (tmp->type == WEAPON && tmp->name != NULL) |
1283 | { |
1298 | { |
1284 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
1299 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
1285 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
1300 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
1286 | { |
1301 | { |
1287 | pick_up (op, tmp); |
1302 | CHK_PICK_PICKUP; |
1288 | continue; |
1303 | continue; |
1289 | } |
1304 | } |
1290 | } |
1305 | } |
1291 | |
1306 | |
1292 | if (tmp->type == WEAPON && tmp->name == NULL) |
1307 | if (tmp->type == WEAPON && tmp->name == NULL) |
1293 | { |
1308 | { |
1294 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
1309 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
1295 | { |
1310 | { |
1296 | pick_up (op, tmp); |
1311 | CHK_PICK_PICKUP; |
1297 | continue; |
1312 | continue; |
1298 | } |
1313 | } |
1299 | } |
1314 | } |
1300 | } |
1315 | } |
1301 | |
1316 | |
1302 | /* misc stuff that's useful */ |
1317 | /* misc stuff that's useful */ |
1303 | if (op->contr->mode & PU_KEY) |
1318 | if (op->contr->mode & PU_KEY) |
1304 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1319 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1305 | { |
1320 | { |
1306 | pick_up (op, tmp); |
1321 | CHK_PICK_PICKUP; |
1307 | continue; |
1322 | continue; |
1308 | } |
1323 | } |
1309 | |
1324 | |
1310 | /* any of the last 4 bits set means we use the ratio for value |
1325 | /* any of the last 4 bits set means we use the ratio for value |
1311 | * pickups */ |
1326 | * pickups */ |
… | |
… | |
1316 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1331 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1317 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1332 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1318 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1333 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1319 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
1334 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
1320 | { |
1335 | { |
1321 | pick_up (op, tmp); |
1336 | CHK_PICK_PICKUP; |
1322 | #if 0 |
1337 | #if 0 |
1323 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1338 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1324 | if (tmp->name != NULL) |
1339 | if (tmp->name != NULL) |
1325 | { |
1340 | { |
1326 | fprintf (stderr, "%s", tmp->name); |
1341 | fprintf (stderr, "%s", tmp->name); |
… | |
… | |
1345 | * found object is returned. |
1360 | * found object is returned. |
1346 | */ |
1361 | */ |
1347 | object * |
1362 | object * |
1348 | find_arrow (object *op, const char *type) |
1363 | find_arrow (object *op, const char *type) |
1349 | { |
1364 | { |
1350 | object *tmp = 0; |
|
|
1351 | |
|
|
1352 | for (op = op->inv; op; op = op->below) |
1365 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1353 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
|
|
1354 | tmp = find_arrow (op, type); |
|
|
1355 | else if (op->type == ARROW && op->race == type) |
1366 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
|
|
1367 | return splay (tmp); |
|
|
1368 | |
|
|
1369 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
|
|
1370 | if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && !strcmp (&tmp->race, type)) |
|
|
1371 | if (object *arrow = find_arrow (tmp, type)) |
|
|
1372 | { |
|
|
1373 | splay (tmp); |
1356 | return op; |
1374 | return arrow; |
|
|
1375 | } |
1357 | |
1376 | |
1358 | return tmp; |
1377 | return 0; |
1359 | } |
1378 | } |
1360 | |
1379 | |
1361 | /* |
1380 | /* |
1362 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1381 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1363 | * against the target. A full test is not performed, simply a basic test |
1382 | * against the target. A full test is not performed, simply a basic test |
… | |
… | |
1584 | arrow->destroy (); |
1603 | arrow->destroy (); |
1585 | return 0; |
1604 | return 0; |
1586 | } |
1605 | } |
1587 | |
1606 | |
1588 | left = arrow; /* these are arrows left to the player */ |
1607 | left = arrow; /* these are arrows left to the player */ |
1589 | arrow = get_split_ob (arrow, 1); |
1608 | arrow = arrow->split (); |
1590 | if (!arrow) |
1609 | if (!arrow) |
1591 | { |
1610 | { |
1592 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1611 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1593 | return 0; |
1612 | return 0; |
1594 | } |
1613 | } |
… | |
… | |
1661 | op->play_sound (sound_find ("fire_arrow")); |
1680 | op->play_sound (sound_find ("fire_arrow")); |
1662 | m->insert (arrow, sx, sy, op); |
1681 | m->insert (arrow, sx, sy, op); |
1663 | |
1682 | |
1664 | if (!arrow->destroyed ()) |
1683 | if (!arrow->destroyed ()) |
1665 | move_arrow (arrow); |
1684 | move_arrow (arrow); |
1666 | |
|
|
1667 | if (op->type == PLAYER) |
|
|
1668 | { |
|
|
1669 | if (left->destroyed ()) |
|
|
1670 | esrv_del_item (op->contr, left->count); |
|
|
1671 | else |
|
|
1672 | esrv_send_item (op, left); |
|
|
1673 | } |
|
|
1674 | |
1685 | |
1675 | return 1; |
1686 | return 1; |
1676 | } |
1687 | } |
1677 | |
1688 | |
1678 | /* Special fire code for players - this takes into |
1689 | /* Special fire code for players - this takes into |
… | |
… | |
1963 | |
1974 | |
1964 | if (door->type == DOOR) |
1975 | if (door->type == DOOR) |
1965 | hit_player (door, 9998, op, AT_PHYSICAL, 1); /* Break through the door */ |
1976 | hit_player (door, 9998, op, AT_PHYSICAL, 1); /* Break through the door */ |
1966 | else if (door->type == LOCKED_DOOR) |
1977 | else if (door->type == LOCKED_DOOR) |
1967 | { |
1978 | { |
1968 | new_draw_info_format (NDI_UNIQUE, NDI_BROWN, op, "You open the door with the %s", query_short_name (key)); |
1979 | op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); |
1969 | remove_door2 (door); /* remove door without violence ;-) */ |
1980 | remove_door2 (door); /* remove door without violence ;-) */ |
1970 | } |
1981 | } |
1971 | |
1982 | |
1972 | /* Do this after we print the message */ |
1983 | /* Do this after we print the message */ |
1973 | decrease_ob (key); /* Use up one of the keys */ |
1984 | key->decrease (); /* Use up one of the keys */ |
1974 | /* Need to update the weight the container the key was in */ |
1985 | /* Need to update the weight the container the key was in */ |
1975 | if (container != op) |
1986 | if (container != op) |
1976 | esrv_update_item (UPD_WEIGHT, op, container); |
1987 | esrv_update_item (UPD_WEIGHT, op, container); |
1977 | |
1988 | |
1978 | return 1; /* Nothing more to do below */ |
1989 | return 1; /* Nothing more to do below */ |
1979 | } |
1990 | } |
1980 | else if (door->type == LOCKED_DOOR) |
1991 | else if (door->type == LOCKED_DOOR) |
1981 | { |
1992 | { |
1982 | /* Might as well return now - no other way to open this */ |
1993 | /* Might as well return now - no other way to open this */ |
1983 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); |
1994 | op->failmsg (door->msg ? &door->msg : "Hmm, you miss the certain something to open this door..."); |
1984 | return 1; |
1995 | return 1; |
1985 | } |
1996 | } |
1986 | |
1997 | |
1987 | return 0; |
1998 | return 0; |
1988 | } |
1999 | } |
… | |
… | |
2108 | { |
2119 | { |
2109 | op->play_sound (sound_find ("push_player")); |
2120 | op->play_sound (sound_find ("push_player")); |
2110 | push_ob (mon, dir, op); |
2121 | push_ob (mon, dir, op); |
2111 | } |
2122 | } |
2112 | else |
2123 | else |
2113 | new_draw_info (0, 0, op, "You withhold your attack"); |
2124 | op->statusmsg ("You withhold your attack"); |
2114 | |
2125 | |
2115 | if (op->contr->tmp_invis || op->hide) |
2126 | if (op->contr->tmp_invis || op->hide) |
2116 | make_visible (op); |
2127 | make_visible (op); |
2117 | |
2128 | |
2118 | return true; |
2129 | return true; |
… | |
… | |
2162 | bool |
2173 | bool |
2163 | move_player (object *op, int dir) |
2174 | move_player (object *op, int dir) |
2164 | { |
2175 | { |
2165 | int pick; |
2176 | int pick; |
2166 | |
2177 | |
2167 | if (!op->map || op->map->in_memory != MAP_IN_MEMORY) |
2178 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2168 | return 0; |
2179 | return 0; |
2169 | |
2180 | |
2170 | /* Sanity check: make sure dir is valid */ |
2181 | /* Sanity check: make sure dir is valid */ |
2171 | if ((dir < 0) || (dir >= 9)) |
2182 | if ((dir < 0) || (dir >= 9)) |
2172 | { |
2183 | { |
… | |
… | |
2593 | * file. |
2604 | * file. |
2594 | */ |
2605 | */ |
2595 | void |
2606 | void |
2596 | kill_player (object *op) |
2607 | kill_player (object *op) |
2597 | { |
2608 | { |
|
|
2609 | int x, y; |
2598 | char buf[MAX_BUF]; |
2610 | char buf[MAX_BUF]; |
2599 | int x, y; |
|
|
2600 | |
|
|
2601 | //int i; |
|
|
2602 | maptile *map; /* this is for resurrection */ |
2611 | maptile *map; /* this is for resurrection */ |
2603 | |
|
|
2604 | /* int z; |
|
|
2605 | int num_stats_lose; |
|
|
2606 | int lost_a_stat; |
|
|
2607 | int lose_this_stat; |
|
|
2608 | int this_stat; */ |
|
|
2609 | int will_kill_again; |
2612 | int will_kill_again; |
2610 | archetype *at; |
2613 | archetype *at; |
2611 | object *tmp; |
2614 | object *tmp; |
2612 | |
2615 | |
2613 | if (save_life (op)) |
2616 | if (save_life (op)) |
… | |
… | |
2635 | { |
2638 | { |
2636 | tmp->destroy (); |
2639 | tmp->destroy (); |
2637 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2640 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2638 | } |
2641 | } |
2639 | |
2642 | |
2640 | cure_disease (op, 0); /* remove any disease */ |
2643 | cure_disease (op, 0, 0); /* remove any disease */ |
2641 | op->stats.hp = op->stats.maxhp; |
2644 | op->stats.hp = op->stats.maxhp; |
2642 | if (op->stats.food <= 0) |
2645 | if (op->stats.food <= 0) |
2643 | op->stats.food = 999; |
2646 | op->stats.food = 999; |
2644 | |
2647 | |
2645 | /* create a bodypart-trophy to make the winner happy */ |
2648 | /* create a bodypart-trophy to make the winner happy */ |
2646 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2649 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2647 | { |
2650 | { |
2648 | sprintf (buf, "%s's finger", &op->name); |
2651 | tmp->name = format ("%s's finger" , &op->name); |
2649 | tmp->name = buf; |
2652 | tmp->name_pl = format ("%s's fingers", &op->name); |
2650 | sprintf (buf, " This finger has been cut off %s\n" |
2653 | tmp->msg = format ( |
2651 | " the %s, when he was defeated at\n level %d by %s.\n", |
2654 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2652 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2655 | &op->name, op->contr->title, (int) (op->level), op->contr->killer |
2653 | tmp->msg = buf; |
2656 | ); |
2654 | tmp->value = 0, tmp->type = 0; |
2657 | tmp->value = 0, tmp->type = 0; |
2655 | tmp->materialname = "organics"; |
2658 | tmp->materialname = "organics"; |
2656 | tmp->insert_at (op, tmp); |
2659 | tmp->insert_at (op, tmp); |
2657 | } |
2660 | } |
2658 | |
2661 | |
… | |
… | |
2665 | INVOKE_PLAYER (DEATH, op->contr); |
2668 | INVOKE_PLAYER (DEATH, op->contr); |
2666 | |
2669 | |
2667 | command_kill_pets (op, 0); |
2670 | command_kill_pets (op, 0); |
2668 | |
2671 | |
2669 | if (op->stats.food < 0) |
2672 | if (op->stats.food < 0) |
2670 | { |
|
|
2671 | sprintf (buf, "%s starved to death.", &op->name); |
|
|
2672 | strcpy (op->contr->killer, "starvation"); |
2673 | strcpy (op->contr->killer, "starvation"); |
2673 | } |
|
|
2674 | else |
|
|
2675 | sprintf (buf, "%s died.", &op->name); |
|
|
2676 | |
2674 | |
2677 | op->contr->play_sound (sound_find ("player_dies")); |
2675 | op->contr->play_sound (sound_find ("player_dies")); |
2678 | |
2676 | |
2679 | /* save the map location for corpse, gravestone */ |
2677 | /* save the map location for corpse, gravestone */ |
2680 | x = op->x; |
2678 | x = op->x; |
… | |
… | |
2845 | { |
2843 | { |
2846 | tmp->destroy (); |
2844 | tmp->destroy (); |
2847 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2845 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2848 | } |
2846 | } |
2849 | |
2847 | |
2850 | cure_disease (op, 0); /* remove any disease */ |
2848 | cure_disease (op, 0, 0); /* remove any disease */ |
2851 | |
2849 | |
2852 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2850 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2853 | apply_death_exp_penalty (op); |
2851 | apply_death_exp_penalty (op); |
2854 | if (op->stats.food < 100) |
2852 | if (op->stats.food < 100) |
2855 | op->stats.food = 900; |
2853 | op->stats.food = 900; |
… | |
… | |
2928 | |
2926 | |
2929 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2927 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2930 | { |
2928 | { |
2931 | if (tmp->nrof > 1) |
2929 | if (tmp->nrof > 1) |
2932 | { |
2930 | { |
2933 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2931 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2934 | tmp2->destroy (); |
|
|
2935 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2932 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2936 | } |
2933 | } |
2937 | else |
2934 | else |
2938 | tmp->destroy (); |
2935 | tmp->destroy (); |
2939 | } |
2936 | } |
… | |
… | |
2950 | void |
2947 | void |
2951 | fix_weight (void) |
2948 | fix_weight (void) |
2952 | { |
2949 | { |
2953 | for_all_players (pl) |
2950 | for_all_players (pl) |
2954 | { |
2951 | { |
2955 | int old = pl->ob->carrying, sum = sum_weight (pl->ob); |
2952 | sint32 old = pl->ob->carrying; |
2956 | |
2953 | |
2957 | if (old == sum) |
2954 | pl->ob->update_weight (); |
2958 | continue; |
2955 | |
|
|
2956 | if (old != pl->ob->carrying) |
|
|
2957 | { |
2959 | pl->ob->update_stats (); |
2958 | pl->ob->update_stats (); |
2960 | LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, old, sum); |
2959 | LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, (int)old, (int)pl->ob->carrying); |
|
|
2960 | } |
2961 | } |
2961 | } |
2962 | } |
2962 | } |
2963 | |
2963 | |
2964 | void |
2964 | void |
2965 | fix_luck (void) |
2965 | fix_luck (void) |
… | |
… | |
3009 | void |
3009 | void |
3010 | make_visible (object *op) |
3010 | make_visible (object *op) |
3011 | { |
3011 | { |
3012 | op->hide = 0; |
3012 | op->hide = 0; |
3013 | op->invisible = 0; |
3013 | op->invisible = 0; |
|
|
3014 | |
3014 | if (op->type == PLAYER) |
3015 | if (op->type == PLAYER) |
3015 | { |
3016 | { |
3016 | op->contr->tmp_invis = 0; |
3017 | op->contr->tmp_invis = 0; |
3017 | op->contr->invis_race = 0; |
3018 | op->contr->invis_race = 0; |
3018 | } |
3019 | } |
… | |
… | |
3031 | |
3032 | |
3032 | /* look at the surrounding terrain to determine |
3033 | /* look at the surrounding terrain to determine |
3033 | * the hideability of this object. Positive levels |
3034 | * the hideability of this object. Positive levels |
3034 | * indicate greater hideability. |
3035 | * indicate greater hideability. |
3035 | */ |
3036 | */ |
3036 | |
|
|
3037 | int |
3037 | int |
3038 | hideability (object *ob) |
3038 | hideability (object *ob) |
3039 | { |
3039 | { |
3040 | int i, level = 0, mflag; |
3040 | int i, level = 0, mflag; |
3041 | sint16 x, y; |
3041 | sint16 x, y; |
… | |
… | |
3051 | * as bad as carrying a light on a pitch dark map */ |
3051 | * as bad as carrying a light on a pitch dark map */ |
3052 | if (has_carried_lights (ob)) |
3052 | if (has_carried_lights (ob)) |
3053 | level = -(10 + (2 * ob->map->darkness)); |
3053 | level = -(10 + (2 * ob->map->darkness)); |
3054 | |
3054 | |
3055 | /* scan through all nearby squares for terrain to hide in */ |
3055 | /* scan through all nearby squares for terrain to hide in */ |
3056 | for (i = 0, x = ob->x, y = ob->y; i < 9; i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
3056 | for (i = 0, x = ob->x, y = ob->y; |
|
|
3057 | i <= SIZEOFFREE1; |
|
|
3058 | i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
3057 | { |
3059 | { |
3058 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3060 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3059 | if (mflag & P_OUT_OF_MAP) |
3061 | if (mflag & P_OUT_OF_MAP) |
3060 | { |
|
|
3061 | continue; |
3062 | continue; |
3062 | } |
3063 | |
3063 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3064 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3064 | level += 2; |
3065 | level += 2; |
3065 | else /* open terrain! */ |
3066 | else /* open terrain! */ |
3066 | level -= 1; |
3067 | level -= 1; |
3067 | } |
3068 | } |
… | |
… | |
3495 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
3496 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
3496 | return 0; |
3497 | return 0; |
3497 | |
3498 | |
3498 | return 100 - blocked_los [x][y]; |
3499 | return 100 - blocked_los [x][y]; |
3499 | } |
3500 | } |
|
|
3501 | |
|
|
3502 | void |
|
|
3503 | player::infobox (const char *title, const char *msg, int color) |
|
|
3504 | { |
|
|
3505 | send_msg (color | NDI_DEF | NDI_REPLY | NDI_CLEAR, title, msg); |
|
|
3506 | } |
|
|
3507 | |
|
|
3508 | void |
|
|
3509 | player::statusmsg (const char *msg, int color) |
|
|
3510 | { |
|
|
3511 | send_msg (color | NDI_REPLY, INFO_CHANNEL, msg); |
|
|
3512 | } |
|
|
3513 | |
|
|
3514 | void |
|
|
3515 | player::failmsg (const char *msg, int color) |
|
|
3516 | { |
|
|
3517 | play_sound (sound_find ("generic_failure")); |
|
|
3518 | statusmsg (msg, color); |
|
|
3519 | } |
|
|
3520 | |