ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.174 by root, Thu Nov 8 19:43:27 2007 UTC vs.
Revision 1.194 by root, Sun May 4 19:41:51 2008 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
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
215 215
216 /* make sure he's a player -- needed because of class change. */ 216 /* make sure he's a player -- needed because of class change. */
217 ob->type = PLAYER; // we are paranoid 217 ob->type = PLAYER; // we are paranoid
218 ob->race = ob->arch->race; 218 ob->race = ob->arch->race;
219 219
220 ob->carrying = sum_weight (ob); 220 ob->update_weight ();
221 link_player_skills (ob); 221 link_player_skills (ob);
222 222
223 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); 223 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
224 224
225 assign (title, ob->arch->object::name); 225 assign (title, ob->arch->object::name);
239 set_dragon_name (ob, abil, skin); 239 set_dragon_name (ob, abil, skin);
240 } 240 }
241 241
242 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); 242 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!");
243 243
244 esrv_new_player (this, ob->weight + ob->carrying); 244 esrv_new_player (this);
245 245
246 ob->update_stats (); 246 ob->update_stats ();
247 247
248 ns->floorbox_update (); 248 ns->floorbox_update ();
249 esrv_send_inventory (ob, ob); 249 esrv_send_inventory (ob, ob);
291player::set_object (object *op) 291player::set_object (object *op)
292{ 292{
293 ob = observe = op; 293 ob = observe = op;
294 ob->contr = this; /* this aren't yet in archetype */ 294 ob->contr = this; /* this aren't yet in archetype */
295 295
296 ob->speed = 1.0f; 296 ob->speed = 1.0f;
297 ob->speed_left = 0.5f; 297 ob->speed_left = 0.5f;
298 298
299 ob->direction = 5; /* So player faces south */ 299 ob->direction = 5; /* So player faces south */
300 300
301 ob->flag [FLAG_READY_WEAPON] = false; 301 ob->flag [FLAG_READY_WEAPON] = false;
302 ob->flag [FLAG_READY_SKILL] = false; 302 ob->flag [FLAG_READY_SKILL] = false;
303 ob->flag [FLAG_READY_BOW] = false; 303 ob->flag [FLAG_READY_BOW] = false;
304 304
321 combat_ob = op; 321 combat_ob = op;
322 break; 322 break;
323 } 323 }
324 324
325 ob->change_weapon (combat_ob ? combat_ob : ranged_ob); 325 ob->change_weapon (combat_ob ? combat_ob : ranged_ob);
326 ob->deactivate (); // change_Weapon activates, fix this better
326} 327}
327 328
328void 329void
329player::set_observe (object *op) 330player::set_observe (object *op)
330{ 331{
403 * Note: there MUST be at least one player archetype! 404 * Note: there MUST be at least one player archetype!
404 */ 405 */
405archetype * 406archetype *
406get_player_archetype (archetype *at) 407get_player_archetype (archetype *at)
407{ 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
408 archvec::iterator i = at ? archetypes.find (at) : archetypes.begin (); 415 archvec::iterator i = archetypes.find (nat);
409 416
410 for (;;) 417 for (;;)
411 { 418 {
412 if (++i == archetypes.end ()) 419 if (++i == archetypes.end ())
413 i = archetypes.begin (); 420 i = archetypes.begin ();
631 638
632 return firstdir; 639 return firstdir;
633} 640}
634 641
635void 642void
636give_initial_items (object *pl, treasurelist * items) 643give_initial_items (object *pl, treasurelist *items)
637{ 644{
638 object *op, *next = NULL;
639
640 if (pl->randomitems != NULL) 645 if (pl->randomitems)
641 create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); 646 create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0);
642 647
643 for (op = pl->inv; op; op = next) 648 for (object *next, *op = pl->inv; op; op = next)
644 { 649 {
645 next = op->below; 650 next = op->below;
646 651
647 /* Forces get applied per default, unless they have the 652 /* Forces get applied per default, unless they have the
648 * 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
653 /* we never give weapons/armour if these cannot be used 658 /* we never give weapons/armour if these cannot be used
654 * by this player due to race restrictions 659 * by this player due to race restrictions
655 */ 660 */
656 if (pl->type == PLAYER) 661 if (pl->type == PLAYER)
657 { 662 {
658 if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) && 663 if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR)
664 &&
659 (op->type == ARMOUR || op->type == BOOTS || 665 (op->type == ARMOUR || op->type == BOOTS
660 op->type == CLOAK || op->type == HELMET || 666 || op->type == CLOAK || op->type == HELMET
661 op->type == SHIELD || op->type == GLOVES || 667 || op->type == SHIELD || op->type == GLOVES
668 || op->type == BRACERS || op->type == GIRDLE))
662 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))
663 { 670 {
664 op->destroy (); 671 op->destroy ();
665 continue; 672 continue;
666 } 673 }
667 } 674 }
690 if (op->nrof > 1) 697 if (op->nrof > 1)
691 op->nrof = 1; 698 op->nrof = 1;
692 } 699 }
693 700
694 if (op->type == SPELLBOOK && op->inv) 701 if (op->type == SPELLBOOK && op->inv)
695 {
696 CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); 702 CLEAR_FLAG (op->inv, FLAG_STARTEQUIP);
697 }
698 703
699 /* Give starting characters identified, uncursed, and undamned 704 /* Give starting characters identified, uncursed, and undamned
700 * 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
701 * merged properly. 706 * merged properly.
702 */ 707 */
703 if (need_identify (op)) 708 if (need_identify (op))
704 { 709 {
705 SET_FLAG (op, FLAG_IDENTIFIED); 710 SET_FLAG (op, FLAG_IDENTIFIED);
706 CLEAR_FLAG (op, FLAG_CURSED); 711 CLEAR_FLAG (op, FLAG_CURSED);
707 CLEAR_FLAG (op, FLAG_DAMNED); 712 CLEAR_FLAG (op, FLAG_DAMNED);
708 } 713 }
714
709 if (op->type == SPELL) 715 if (op->type == SPELL)
710 { 716 {
711 op->destroy (); 717 op->destroy ();
712 continue; 718 continue;
713 } 719 }
715 { 721 {
716 SET_FLAG (op, FLAG_CAN_USE_SKILL); 722 SET_FLAG (op, FLAG_CAN_USE_SKILL);
717 op->stats.exp = 0; 723 op->stats.exp = 0;
718 op->level = 1; 724 op->level = 1;
719 } 725 }
720 /* lock all 'normal items by default */ 726 else /* lock all 'normal items by default */
721 else
722 SET_FLAG (op, FLAG_INV_LOCKED); 727 SET_FLAG (op, FLAG_INV_LOCKED);
723 } /* for loop of objects in player inv */ 728 } /* for loop of objects in player inv */
724 729
725 /* Need to set up the skill pointers */ 730 /* Need to set up the skill pointers */
726 link_player_skills (pl); 731 link_player_skills (pl);
832static void 837static void
833start_info (object *op) 838start_info (object *op)
834{ 839{
835 char buf[MAX_BUF]; 840 char buf[MAX_BUF];
836 841
837 sprintf (buf, "Welcome to Crossfire v%s!", VERSION); 842 sprintf (buf, "Welcome to Deliantra v%s!", VERSION);
838 new_draw_info (NDI_UNIQUE, 0, op, buf); 843 new_draw_info (NDI_UNIQUE, 0, op, buf);
839 //new_draw_info (NDI_UNIQUE, 0, op, "Press `?' for help");
840 //new_draw_info (NDI_UNIQUE, 0, op, " ");
841} 844}
842 845
843/* This function takes the key that is passed, and does the 846/* This function takes the key that is passed, and does the
844 * appropriate action with it (change race, or other things). 847 * appropriate action with it (change race, or other things).
845 * The function name is for historical reasons - now we have 848 * The function name is for historical reasons - now we have
848 */ 851 */
849void 852void
850player::chargen_race_done () 853player::chargen_race_done ()
851{ 854{
852 /* this must before then initial items are given */ 855 /* this must before then initial items are given */
853 esrv_new_player (ob->contr, ob->weight + ob->carrying); 856 esrv_new_player (ob->contr);
854 857
855 treasurelist *tl = treasurelist::find ("starting_wealth"); 858 treasurelist *tl = treasurelist::find ("starting_wealth");
856 if (tl) 859 if (tl)
857 create_treasure (tl, ob, 0, 0, 0); 860 create_treasure (tl, ob, 0, 0, 0);
858 861
1008 if (op->move_type & MOVE_FLYING) 1011 if (op->move_type & MOVE_FLYING)
1009 return 1; 1012 return 1;
1010 1013
1011 next = op->below; 1014 next = op->below;
1012 1015
1016 int cnt = MAX_ITEM_PER_DROP;
1017#define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0)
1018
1013 /* 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
1014 * destroyed */ 1020 * destroyed */
1015 while (next && !next->destroyed ()) 1021 while (next && !next->destroyed ())
1016 { 1022 {
1017 tmp = next; 1023 tmp = next;
1018 next = tmp->below; 1024 next = tmp->below;
1019 1025
1026 if (cnt <= 0)
1027 {
1028 op->failmsg ("Couldn't pickup all items at once.");
1029 return 0;
1030 }
1031
1020 if (op->destroyed ()) 1032 if (op->destroyed ())
1021 return 0; 1033 return 0;
1022 1034
1023 if (!can_pick (op, tmp)) 1035 if (!can_pick (op, tmp))
1024 continue; 1036 continue;
1025 1037
1026 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) 1038 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE)
1027 { 1039 {
1028 if (item_matched_string (op, tmp, op->contr->search_str)) 1040 if (item_matched_string (op, tmp, op->contr->search_str))
1029 pick_up (op, tmp); 1041 CHK_PICK_PICKUP;
1030 continue; 1042 continue;
1031 } 1043 }
1032 1044
1033 /* high not bit set? We're using the old autopickup model */ 1045 /* high not bit set? We're using the old autopickup model */
1034 if (!(op->contr->mode & PU_NEWMODE)) 1046 if (!(op->contr->mode & PU_NEWMODE))
1036 switch (op->contr->mode) 1048 switch (op->contr->mode)
1037 { 1049 {
1038 case 0: 1050 case 0:
1039 return 1; /* don't pick up */ 1051 return 1; /* don't pick up */
1040 case 1: 1052 case 1:
1041 pick_up (op, tmp); 1053 CHK_PICK_PICKUP;
1042 return 1; 1054 return 1;
1043 case 2: 1055 case 2:
1044 pick_up (op, tmp); 1056 CHK_PICK_PICKUP;
1045 return 0; 1057 return 0;
1046 case 3: 1058 case 3:
1047 return 0; /* stop before pickup */ 1059 return 0; /* stop before pickup */
1048 case 4: 1060 case 4:
1049 pick_up (op, tmp); 1061 CHK_PICK_PICKUP;
1050 break; 1062 break;
1051 case 5: 1063 case 5:
1052 pick_up (op, tmp); 1064 CHK_PICK_PICKUP;
1053 stop = 1; 1065 stop = 1;
1054 break; 1066 break;
1055 case 6: 1067 case 6:
1056 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1068 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)
1057 pick_up (op, tmp); 1069 && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1070 CHK_PICK_PICKUP;
1058 break; 1071 break;
1059 1072
1060 case 7: 1073 case 7:
1061 if (tmp->type == MONEY || tmp->type == GEM) 1074 if (tmp->type == MONEY || tmp->type == GEM)
1062 pick_up (op, tmp); 1075 CHK_PICK_PICKUP;
1063 break; 1076 break;
1064 1077
1065 default: 1078 default:
1066 /* use value density */ 1079 /* use value density */
1067 if (!QUERY_FLAG (tmp, FLAG_UNPAID) 1080 if (!QUERY_FLAG (tmp, FLAG_UNPAID)
1068 && (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)
1069 pick_up (op, tmp); 1082 CHK_PICK_PICKUP;
1070 } 1083 }
1071 } 1084 }
1072 else 1085 else
1073 { /* old model */ 1086 { /* old model */
1074 /* NEW pickup handling */ 1087 /* NEW pickup handling */
1129 /* all food and drink if desired */ 1142 /* all food and drink if desired */
1130 /* question: don't pick up known-poisonous stuff? */ 1143 /* question: don't pick up known-poisonous stuff? */
1131 if (op->contr->mode & PU_FOOD) 1144 if (op->contr->mode & PU_FOOD)
1132 if (tmp->type == FOOD) 1145 if (tmp->type == FOOD)
1133 { 1146 {
1134 pick_up (op, tmp); 1147 CHK_PICK_PICKUP;
1135 continue; 1148 continue;
1136 } 1149 }
1137 1150
1138 if (op->contr->mode & PU_DRINK) 1151 if (op->contr->mode & PU_DRINK)
1139 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)))
1140 { 1153 {
1141 pick_up (op, tmp); 1154 CHK_PICK_PICKUP;
1142 continue; 1155 continue;
1143 } 1156 }
1144 1157
1145 if (op->contr->mode & PU_POTION) 1158 if (op->contr->mode & PU_POTION)
1146 if (tmp->type == POTION) 1159 if (tmp->type == POTION)
1147 { 1160 {
1148 pick_up (op, tmp); 1161 CHK_PICK_PICKUP;
1149 continue; 1162 continue;
1150 } 1163 }
1151 1164
1152 /* spellbooks, skillscrolls and normal books/scrolls */ 1165 /* spellbooks, skillscrolls and normal books/scrolls */
1153 if (op->contr->mode & PU_SPELLBOOK) 1166 if (op->contr->mode & PU_SPELLBOOK)
1154 if (tmp->type == SPELLBOOK) 1167 if (tmp->type == SPELLBOOK)
1155 { 1168 {
1156 pick_up (op, tmp); 1169 CHK_PICK_PICKUP;
1157 continue; 1170 continue;
1158 } 1171 }
1159 1172
1160 if (op->contr->mode & PU_SKILLSCROLL) 1173 if (op->contr->mode & PU_SKILLSCROLL)
1161 if (tmp->type == SKILLSCROLL) 1174 if (tmp->type == SKILLSCROLL)
1162 { 1175 {
1163 pick_up (op, tmp); 1176 CHK_PICK_PICKUP;
1164 continue; 1177 continue;
1165 } 1178 }
1166 1179
1167 if (op->contr->mode & PU_READABLES) 1180 if (op->contr->mode & PU_READABLES)
1168 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) 1181 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE)
1169 { 1182 {
1170 pick_up (op, tmp); 1183 CHK_PICK_PICKUP;
1171 continue; 1184 continue;
1172 } 1185 }
1173 1186
1174 /* wands/staves/rods/horns */ 1187 /* wands/staves/rods/horns */
1175 if (op->contr->mode & PU_MAGIC_DEVICE) 1188 if (op->contr->mode & PU_MAGIC_DEVICE)
1176 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1189 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1177 { 1190 {
1178 pick_up (op, tmp); 1191 CHK_PICK_PICKUP;
1179 continue; 1192 continue;
1180 } 1193 }
1181 1194
1182 /* pick up all magical items */ 1195 /* pick up all magical items */
1183 if (op->contr->mode & PU_MAGICAL) 1196 if (op->contr->mode & PU_MAGICAL)
1184 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))
1185 { 1198 {
1186 pick_up (op, tmp); 1199 CHK_PICK_PICKUP;
1187 continue; 1200 continue;
1188 } 1201 }
1189 1202
1190 if (op->contr->mode & PU_VALUABLES) 1203 if (op->contr->mode & PU_VALUABLES)
1191 { 1204 {
1192 if (tmp->type == MONEY || tmp->type == GEM) 1205 if (tmp->type == MONEY || tmp->type == GEM)
1193 { 1206 {
1194 pick_up (op, tmp); 1207 CHK_PICK_PICKUP;
1195 continue; 1208 continue;
1196 } 1209 }
1197 } 1210 }
1198 1211
1199 /* rings & amulets - talismans seems to be typed AMULET */ 1212 /* rings & amulets - talismans seems to be typed AMULET */
1200 if (op->contr->mode & PU_JEWELS) 1213 if (op->contr->mode & PU_JEWELS)
1201 if (tmp->type == RING || tmp->type == AMULET) 1214 if (tmp->type == RING || tmp->type == AMULET)
1202 { 1215 {
1203 pick_up (op, tmp); 1216 CHK_PICK_PICKUP;
1204 continue; 1217 continue;
1205 } 1218 }
1206 1219
1207 /* we don't forget dragon food */ 1220 /* we don't forget dragon food */
1208 if (op->contr->mode & PU_FLESH) 1221 if (op->contr->mode & PU_FLESH)
1209 if (tmp->type == FLESH) 1222 if (tmp->type == FLESH)
1210 { 1223 {
1211 pick_up (op, tmp); 1224 CHK_PICK_PICKUP;
1212 continue; 1225 continue;
1213 } 1226 }
1214 1227
1215 /* bows and arrows. Bows are good for selling! */ 1228 /* bows and arrows. Bows are good for selling! */
1216 if (op->contr->mode & PU_BOW) 1229 if (op->contr->mode & PU_BOW)
1217 if (tmp->type == BOW) 1230 if (tmp->type == BOW)
1218 { 1231 {
1219 pick_up (op, tmp); 1232 CHK_PICK_PICKUP;
1220 continue; 1233 continue;
1221 } 1234 }
1222 1235
1223 if (op->contr->mode & PU_ARROW) 1236 if (op->contr->mode & PU_ARROW)
1224 if (tmp->type == ARROW) 1237 if (tmp->type == ARROW)
1225 { 1238 {
1226 pick_up (op, tmp); 1239 CHK_PICK_PICKUP;
1227 continue; 1240 continue;
1228 } 1241 }
1229 1242
1230 /* all kinds of armor etc. */ 1243 /* all kinds of armor etc. */
1231 if (op->contr->mode & PU_ARMOUR) 1244 if (op->contr->mode & PU_ARMOUR)
1232 if (tmp->type == ARMOUR) 1245 if (tmp->type == ARMOUR)
1233 { 1246 {
1234 pick_up (op, tmp); 1247 CHK_PICK_PICKUP;
1235 continue; 1248 continue;
1236 } 1249 }
1237 1250
1238 if (op->contr->mode & PU_HELMET) 1251 if (op->contr->mode & PU_HELMET)
1239 if (tmp->type == HELMET) 1252 if (tmp->type == HELMET)
1240 { 1253 {
1241 pick_up (op, tmp); 1254 CHK_PICK_PICKUP;
1242 continue; 1255 continue;
1243 } 1256 }
1244 1257
1245 if (op->contr->mode & PU_SHIELD) 1258 if (op->contr->mode & PU_SHIELD)
1246 if (tmp->type == SHIELD) 1259 if (tmp->type == SHIELD)
1247 { 1260 {
1248 pick_up (op, tmp); 1261 CHK_PICK_PICKUP;
1249 continue; 1262 continue;
1250 } 1263 }
1251 1264
1252 if (op->contr->mode & PU_BOOTS) 1265 if (op->contr->mode & PU_BOOTS)
1253 if (tmp->type == BOOTS) 1266 if (tmp->type == BOOTS)
1254 { 1267 {
1255 pick_up (op, tmp); 1268 CHK_PICK_PICKUP;
1256 continue; 1269 continue;
1257 } 1270 }
1258 1271
1259 if (op->contr->mode & PU_GLOVES) 1272 if (op->contr->mode & PU_GLOVES)
1260 if (tmp->type == GLOVES) 1273 if (tmp->type == GLOVES)
1261 { 1274 {
1262 pick_up (op, tmp); 1275 CHK_PICK_PICKUP;
1263 continue; 1276 continue;
1264 } 1277 }
1265 1278
1266 if (op->contr->mode & PU_CLOAK) 1279 if (op->contr->mode & PU_CLOAK)
1267 if (tmp->type == CLOAK) 1280 if (tmp->type == CLOAK)
1268 { 1281 {
1269 pick_up (op, tmp); 1282 CHK_PICK_PICKUP;
1270 continue; 1283 continue;
1271 } 1284 }
1272 1285
1273 /* hoping to catch throwing daggers here */ 1286 /* hoping to catch throwing daggers here */
1274 if (op->contr->mode & PU_MISSILEWEAPON) 1287 if (op->contr->mode & PU_MISSILEWEAPON)
1275 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1288 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1276 { 1289 {
1277 pick_up (op, tmp); 1290 CHK_PICK_PICKUP;
1278 continue; 1291 continue;
1279 } 1292 }
1280 1293
1281 /* careful: chairs and tables are weapons! */ 1294 /* careful: chairs and tables are weapons! */
1282 if (op->contr->mode & PU_ALLWEAPON) 1295 if (op->contr->mode & PU_ALLWEAPON)
1284 if (tmp->type == WEAPON && tmp->name != NULL) 1297 if (tmp->type == WEAPON && tmp->name != NULL)
1285 { 1298 {
1286 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 &&
1287 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) 1300 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL)
1288 { 1301 {
1289 pick_up (op, tmp); 1302 CHK_PICK_PICKUP;
1290 continue; 1303 continue;
1291 } 1304 }
1292 } 1305 }
1293 1306
1294 if (tmp->type == WEAPON && tmp->name == NULL) 1307 if (tmp->type == WEAPON && tmp->name == NULL)
1295 { 1308 {
1296 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)
1297 { 1310 {
1298 pick_up (op, tmp); 1311 CHK_PICK_PICKUP;
1299 continue; 1312 continue;
1300 } 1313 }
1301 } 1314 }
1302 } 1315 }
1303 1316
1304 /* misc stuff that's useful */ 1317 /* misc stuff that's useful */
1305 if (op->contr->mode & PU_KEY) 1318 if (op->contr->mode & PU_KEY)
1306 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1319 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1307 { 1320 {
1308 pick_up (op, tmp); 1321 CHK_PICK_PICKUP;
1309 continue; 1322 continue;
1310 } 1323 }
1311 1324
1312 /* 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
1313 * pickups */ 1326 * pickups */
1318 /* >=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
1319 * and multiply them by 5, giving 0..15*5== 5..75 */ 1332 * and multiply them by 5, giving 0..15*5== 5..75 */
1320 wvratio = (op->contr->mode & PU_RATIO) * 5; 1333 wvratio = (op->contr->mode & PU_RATIO) * 5;
1321 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)
1322 { 1335 {
1323 pick_up (op, tmp); 1336 CHK_PICK_PICKUP;
1324#if 0 1337#if 0
1325 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1338 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1326 if (tmp->name != NULL) 1339 if (tmp->name != NULL)
1327 { 1340 {
1328 fprintf (stderr, "%s", tmp->name); 1341 fprintf (stderr, "%s", tmp->name);
1347 * found object is returned. 1360 * found object is returned.
1348 */ 1361 */
1349object * 1362object *
1350find_arrow (object *op, const char *type) 1363find_arrow (object *op, const char *type)
1351{ 1364{
1352 object *tmp = 0;
1353
1354 for (op = op->inv; op; op = op->below) 1365 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1355 if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED))
1356 tmp = find_arrow (splay (op), type);
1357 else if (op->type == ARROW && op->race == type) 1366 if (tmp->type == ARROW && !strcmp (&tmp->race, type))
1358 return splay (op); 1367 return splay (tmp);
1359 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);
1374 return arrow;
1375 }
1376
1360 return tmp; 1377 return 0;
1361} 1378}
1362 1379
1363/* 1380/*
1364 * 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
1365 * 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
1388 } 1405 }
1389 } 1406 }
1390 else if (arrow->type == ARROW && arrow->race == type) 1407 else if (arrow->type == ARROW && arrow->race == type)
1391 { 1408 {
1392 /* allways prefer assasination/slaying */ 1409 /* allways prefer assasination/slaying */
1393 if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) 1410 if (target->race && arrow->slaying && strstr (arrow->slaying, target->race))
1394 { 1411 {
1395 if (arrow->attacktype & AT_DEATH) 1412 if (arrow->attacktype & AT_DEATH)
1396 { 1413 {
1397 *better = 100; 1414 *better = 100;
1398 return arrow; 1415 return arrow;
1586 arrow->destroy (); 1603 arrow->destroy ();
1587 return 0; 1604 return 0;
1588 } 1605 }
1589 1606
1590 left = arrow; /* these are arrows left to the player */ 1607 left = arrow; /* these are arrows left to the player */
1591 arrow = get_split_ob (arrow, 1); 1608 arrow = arrow->split ();
1592 if (!arrow) 1609 if (!arrow)
1593 { 1610 {
1594 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);
1595 return 0; 1612 return 0;
1596 } 1613 }
1663 op->play_sound (sound_find ("fire_arrow")); 1680 op->play_sound (sound_find ("fire_arrow"));
1664 m->insert (arrow, sx, sy, op); 1681 m->insert (arrow, sx, sy, op);
1665 1682
1666 if (!arrow->destroyed ()) 1683 if (!arrow->destroyed ())
1667 move_arrow (arrow); 1684 move_arrow (arrow);
1668
1669 if (op->type == PLAYER)
1670 {
1671 if (left->destroyed ())
1672 esrv_del_item (op->contr, left->count);
1673 else
1674 esrv_send_item (op, left);
1675 }
1676 1685
1677 return 1; 1686 return 1;
1678} 1687}
1679 1688
1680/* Special fire code for players - this takes into 1689/* Special fire code for players - this takes into
1754 return; 1763 return;
1755 } 1764 }
1756 } 1765 }
1757 else if (item->type == ROD || item->type == HORN) 1766 else if (item->type == ROD || item->type == HORN)
1758 { 1767 {
1759 if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) 1768 sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace);
1769
1770 // using the maximum of the rods charge allows at least one spell cast
1771 // for a rod or horn, this fixes some broken rods.
1772 if (item->stats.hp < MIN (spell_sp, item->stats.maxhp))
1760 { 1773 {
1761 op->contr->play_sound (sound_find ("wand_poof")); 1774 op->contr->play_sound (sound_find ("wand_poof"));
1762 1775
1763 if (item->type == ROD) 1776 if (item->type == ROD)
1764 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); 1777 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0));
1783 CLEAR_FLAG (item, FLAG_ANIMATE); 1796 CLEAR_FLAG (item, FLAG_ANIMATE);
1784 item->face = item->arch->face; 1797 item->face = item->arch->face;
1785 item->set_speed (0); 1798 item->set_speed (0);
1786 } 1799 }
1787 1800
1788 if ((tmp = item->in_player ())) 1801 if (object *pl = item->visible_to ())
1789 esrv_update_item (UPD_ANIM, tmp, item); 1802 esrv_update_item (UPD_ANIM, pl, item);
1790 } 1803 }
1791 } 1804 }
1792 else if (item->type == ROD || item->type == HORN) 1805 else if (item->type == ROD || item->type == HORN)
1793 drain_rod_charge (item); 1806 drain_rod_charge (item);
1794 } 1807 }
1970 op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); 1983 op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN);
1971 remove_door2 (door); /* remove door without violence ;-) */ 1984 remove_door2 (door); /* remove door without violence ;-) */
1972 } 1985 }
1973 1986
1974 /* Do this after we print the message */ 1987 /* Do this after we print the message */
1975 decrease_ob (key); /* Use up one of the keys */ 1988 key->decrease (); /* Use up one of the keys */
1976 /* Need to update the weight the container the key was in */
1977 if (container != op)
1978 esrv_update_item (UPD_WEIGHT, op, container);
1979 1989
1980 return 1; /* Nothing more to do below */ 1990 return 1; /* Nothing more to do below */
1981 } 1991 }
1982 else if (door->type == LOCKED_DOOR) 1992 else if (door->type == LOCKED_DOOR)
1983 { 1993 {
2164bool 2174bool
2165move_player (object *op, int dir) 2175move_player (object *op, int dir)
2166{ 2176{
2167 int pick; 2177 int pick;
2168 2178
2169 if (!op->map || op->map->in_memory != MAP_IN_MEMORY) 2179 if (!op->map || op->map->in_memory != MAP_ACTIVE)
2170 return 0; 2180 return 0;
2171 2181
2172 /* Sanity check: make sure dir is valid */ 2182 /* Sanity check: make sure dir is valid */
2173 if ((dir < 0) || (dir >= 9)) 2183 if ((dir < 0) || (dir >= 9))
2174 { 2184 {
2262 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2272 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2263 { 2273 {
2264 op->play_sound (sound_find ("ob_evaporate")); 2274 op->play_sound (sound_find ("ob_evaporate"));
2265 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2275 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2266 2276
2267 if (op->contr)
2268 esrv_del_item (op->contr, tmp->count);
2269
2270 tmp->destroy (); 2277 tmp->destroy ();
2271 CLEAR_FLAG (op, FLAG_LIFESAVE); 2278 CLEAR_FLAG (op, FLAG_LIFESAVE);
2272 2279
2273 if (op->stats.hp < 0) 2280 if (op->stats.hp < 0)
2274 op->stats.hp = op->stats.maxhp; 2281 op->stats.hp = op->stats.maxhp;
2286 return 0; 2293 return 0;
2287} 2294}
2288 2295
2289/* This goes throws the inventory and removes unpaid objects, and puts them 2296/* This goes throws the inventory and removes unpaid objects, and puts them
2290 * back in the map (location and map determined by values of env). This 2297 * back in the map (location and map determined by values of env). This
2291 * function will descend into containers. op is the object to start the search 2298 * function will descend into containers. op is the object to start the search
2292 * from. 2299 * from.
2293 */ 2300 */
2294static void 2301static void
2295drop_unpaid_items (object *op, object *env) 2302drop_unpaid_items (object *op, object *env)
2296{ 2303{
2297 while (op) 2304 while (op)
2298 { 2305 {
2299 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ 2306 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */
2300 2307
2301 if (QUERY_FLAG (op, FLAG_UNPAID)) 2308 if (QUERY_FLAG (op, FLAG_UNPAID))
2302 {
2303 if (env->type == PLAYER)
2304 esrv_del_item (env->contr, op->count);
2305
2306 op->insert_at (env); 2309 op->insert_at (env);
2307 }
2308 else if (op->inv) 2310 else if (op->inv)
2309 drop_unpaid_items (op->inv, env); 2311 drop_unpaid_items (op->inv, env);
2310 2312
2311 op = next; 2313 op = next;
2312 } 2314 }
2324 * Moved from apply.c to player.c - player.c is what 2326 * Moved from apply.c to player.c - player.c is what
2325 * actually uses this function. player.c may not be quite the 2327 * actually uses this function. player.c may not be quite the
2326 * best, a misc file for object actions is probably better, 2328 * best, a misc file for object actions is probably better,
2327 * but there isn't one in the server directory. 2329 * but there isn't one in the server directory.
2328 */ 2330 */
2329char * 2331const char *
2330gravestone_text (object *op) 2332gravestone_text (object *op)
2331{ 2333{
2332 static char buf2[MAX_BUF]; 2334 static dynbuf_text buf;
2333 char buf[MAX_BUF];
2334 time_t now = time (NULL);
2335 2335
2336 strcpy (buf2, " R.I.P.\n\n"); 2336 buf << "---- R.I.P. ----\n\n";
2337 op->name;
2338
2337 if (op->type == PLAYER) 2339 if (op->type == PLAYER)
2338 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2340 buf << " the " << op->contr->title;
2339 else
2340 sprintf (buf, "%s\n", &op->name);
2341 2341
2342 strncat (buf2, " ", 20 - strlen (buf) / 2); 2342 buf << "\n\n";
2343 strcat (buf2, buf); 2343
2344 buf << "who was level ";
2345 buf << (sint32)op->level << "\n\n" // OO breakdown
2346 << " when " << (op->contr ? "killed" : "died") << "\n\n";
2347
2344 if (op->type == PLAYER) 2348 if (op->type == PLAYER)
2345 sprintf (buf, "who was in level %d when killed\n", op->level); 2349 buf << "by " << op->contr->killer_name () << ".\n\n";
2346 else
2347 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2348 2350
2349 strncat (buf2, " ", 20 - strlen (buf) / 2);
2350 strcat (buf2, buf);
2351 if (op->type == PLAYER)
2352 { 2351 {
2353 sprintf (buf, "by %s.\n\n", op->contr->killer); 2352 static char buf2[128];
2354 strncat (buf2, " ", 21 - strlen (buf) / 2); 2353 time_t now = time (NULL);
2355 strcat (buf2, buf);
2356 }
2357
2358 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2354 strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now));
2359 strncat (buf2, " ", 20 - strlen (buf) / 2); 2355 buf << buf2;
2360 strcat (buf2, buf); 2356 }
2361 2357
2362 return buf2; 2358 return buf;
2363} 2359}
2364 2360
2365void 2361void
2366do_some_living (object *op) 2362do_some_living (object *op)
2367{ 2363{
2576 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2572 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2577 manual_apply (op, flesh, 0); 2573 manual_apply (op, flesh, 0);
2578 } 2574 }
2579 } 2575 }
2580 2576
2581 if (op->stats.food < 0) 2577 if (op->stats.food < 0 && op->stats.hp >= -op->stats.food)
2582 { 2578 {
2583 op->stats.hp += op->stats.food; 2579 op->stats.hp += op->stats.food;
2584 op->stats.food = 0; 2580 op->stats.food = 0;
2585 } 2581 }
2586 2582
2641 { 2637 {
2642 tmp->name = format ("%s's finger" , &op->name); 2638 tmp->name = format ("%s's finger" , &op->name);
2643 tmp->name_pl = format ("%s's fingers", &op->name); 2639 tmp->name_pl = format ("%s's fingers", &op->name);
2644 tmp->msg = format ( 2640 tmp->msg = format (
2645 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", 2641 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n",
2646 &op->name, op->contr->title, (int) (op->level), op->contr->killer 2642 &op->name, op->contr->title,
2643 (int)op->level,
2644 op->contr->killer_name ()
2647 ); 2645 );
2648 tmp->value = 0, tmp->type = 0; 2646 tmp->value = 0, tmp->type = 0;
2649 tmp->materialname = "organics"; 2647 tmp->materialname = "organics";
2650 tmp->insert_at (op, tmp); 2648 tmp->insert_at (op, tmp);
2651 } 2649 }
2659 INVOKE_PLAYER (DEATH, op->contr); 2657 INVOKE_PLAYER (DEATH, op->contr);
2660 2658
2661 command_kill_pets (op, 0); 2659 command_kill_pets (op, 0);
2662 2660
2663 if (op->stats.food < 0) 2661 if (op->stats.food < 0)
2664 strcpy (op->contr->killer, "starvation"); 2662 {
2663 op->contr->killer = archetype::get ("killer_starvation");
2664 op->contr->killer->destroy ();
2665 }
2665 2666
2666 op->contr->play_sound (sound_find ("player_dies")); 2667 op->contr->play_sound (sound_find ("player_dies"));
2667 2668
2668 /* save the map location for corpse, gravestone */ 2669 /* save the map location for corpse, gravestone */
2669 x = op->x; 2670 x = op->x;
2802 tmp = arch_to_object (archetype::find ("gravestone")); 2803 tmp = arch_to_object (archetype::find ("gravestone"));
2803 sprintf (buf, "%s's gravestone", &op->name); 2804 sprintf (buf, "%s's gravestone", &op->name);
2804 tmp->name = buf; 2805 tmp->name = buf;
2805 sprintf (buf, "%s's gravestones", &op->name); 2806 sprintf (buf, "%s's gravestones", &op->name);
2806 tmp->name_pl = buf; 2807 tmp->name_pl = buf;
2807 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); 2808 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_name ());
2808 tmp->msg = buf; 2809 tmp->msg = buf;
2809 tmp->x = op->x, tmp->y = op->y; 2810 tmp->x = op->x, tmp->y = op->y;
2810 insert_ob_in_map (tmp, op->map, NULL, 0); 2811 insert_ob_in_map (tmp, op->map, NULL, 0);
2811 2812
2812 /**************************************/ 2813 /**************************************/
2917 2918
2918 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) 2919 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3))))
2919 { 2920 {
2920 if (tmp->nrof > 1) 2921 if (tmp->nrof > 1)
2921 { 2922 {
2922 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2923 tmp->decrease (rndm (1, tmp->nrof - 1));
2923 tmp2->destroy ();
2924 insert_ob_in_map (tmp, op->map, NULL, 0); 2924 insert_ob_in_map (tmp, op->map, NULL, 0);
2925 } 2925 }
2926 else 2926 else
2927 tmp->destroy (); 2927 tmp->destroy ();
2928 } 2928 }
2939void 2939void
2940fix_weight (void) 2940fix_weight (void)
2941{ 2941{
2942 for_all_players (pl) 2942 for_all_players (pl)
2943 { 2943 {
2944 int old = pl->ob->carrying, sum = sum_weight (pl->ob); 2944 sint32 old = pl->ob->carrying;
2945 2945
2946 if (old == sum) 2946 pl->ob->update_weight ();
2947 continue; 2947
2948 if (old != pl->ob->carrying)
2949 {
2948 pl->ob->update_stats (); 2950 pl->ob->update_stats ();
2949 LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, old, sum); 2951 LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, (int)old, (int)pl->ob->carrying);
2952 }
2950 } 2953 }
2951} 2954}
2952 2955
2953void 2956void
2954fix_luck (void) 2957fix_luck (void)
3040 * as bad as carrying a light on a pitch dark map */ 3043 * as bad as carrying a light on a pitch dark map */
3041 if (has_carried_lights (ob)) 3044 if (has_carried_lights (ob))
3042 level = -(10 + (2 * ob->map->darkness)); 3045 level = -(10 + (2 * ob->map->darkness));
3043 3046
3044 /* scan through all nearby squares for terrain to hide in */ 3047 /* scan through all nearby squares for terrain to hide in */
3045 for (i = 0, x = ob->x, y = ob->y; i < 9; i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) 3048 for (i = 0, x = ob->x, y = ob->y;
3049 i <= SIZEOFFREE1;
3050 i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i])
3046 { 3051 {
3047 mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); 3052 mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL);
3048 if (mflag & P_OUT_OF_MAP) 3053 if (mflag & P_OUT_OF_MAP)
3049 {
3050 continue; 3054 continue;
3051 } 3055
3052 if (mflag & P_BLOCKSVIEW) /* something to hide near! */ 3056 if (mflag & P_BLOCKSVIEW) /* something to hide near! */
3053 level += 2; 3057 level += 2;
3054 else /* open terrain! */ 3058 else /* open terrain! */
3055 level -= 1; 3059 level -= 1;
3056 } 3060 }
3067 * spot (surrounded by clear terrain in broad daylight). -b.t. 3071 * spot (surrounded by clear terrain in broad daylight). -b.t.
3068 */ 3072 */
3069void 3073void
3070do_hidden_move (object *op) 3074do_hidden_move (object *op)
3071{ 3075{
3072 int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); 3076 int hide = 0;
3073 object *skop;
3074 3077
3075 if (!op || !op->map) 3078 if (!op || !op->map)
3076 return; 3079 return;
3077 3080
3078 skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); 3081 object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING);
3082 int num = random_roll (0, 19, op, PREFER_LOW);
3079 3083
3080 /* its *extremely* hard to run and sneak/hide at the same time! */ 3084 /* its *extremely* hard to run and sneak/hide at the same time! */
3081 if (op->type == PLAYER && op->contr->run_on) 3085 if (op->type == PLAYER && op->contr->run_on)
3082 if (!skop || num >= skop->level) 3086 if (!skop || num >= skop->level)
3083 { 3087 {
3093 num -= hide; 3097 num -= hide;
3094 3098
3095 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) 3099 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0))
3096 { 3100 {
3097 make_visible (op); 3101 make_visible (op);
3102
3098 if (op->type == PLAYER) 3103 if (op->type == PLAYER)
3099 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); 3104 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!");
3100 } 3105 }
3101 else if (op->type == PLAYER && skop) 3106 else if (op->type == PLAYER && skop)
3102 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); 3107 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0);
3443 else 3448 else
3444 { 3449 {
3445 /* generate misc. treasure */ 3450 /* generate misc. treasure */
3446 tmp = arch_to_object (tr->item); 3451 tmp = arch_to_object (tr->item);
3447 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3452 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp));
3448 tmp = insert_ob_in_ob (tmp, who); 3453 who->insert (tmp);
3449 if (who->type == PLAYER)
3450 esrv_send_item (who, tmp);
3451 } 3454 }
3452} 3455}
3453 3456
3454/** 3457/**
3455 * Unready an object for a player. This function does nothing if the object was 3458 * Unready an object for a player. This function does nothing if the object was

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines