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.143 by root, Fri May 18 21:12:40 2007 UTC vs.
Revision 1.164 by root, Thu Aug 23 17:56:25 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT 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 2 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The author can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 22 */
24 23
25#include <global.h> 24#include <global.h>
26#include <sproto.h> 25#include <sproto.h>
27#include <sounds.h> 26#include <sounds.h>
157 op->x = -1; 156 op->x = -1;
158 op->y = -1; 157 op->y = -1;
159} 158}
160 159
161void 160void
162player::enter_map ()
163{
164 object *tmp = object::create ();
165
166 EXIT_PATH (tmp) = maplevel;
167 EXIT_X (tmp) = ob->x;
168 EXIT_Y (tmp) = ob->y;
169 ob->enter_exit (tmp);
170
171 tmp->destroy ();
172}
173
174void
175player::activate () 161player::activate ()
176{ 162{
177 if (active) 163 if (active)
178 return; 164 return;
179 165
181 ob->remove (); 167 ob->remove ();
182 ob->map = 0; 168 ob->map = 0;
183 ob->activate_recursive (); 169 ob->activate_recursive ();
184 CLEAR_FLAG (ob, FLAG_FRIENDLY); 170 CLEAR_FLAG (ob, FLAG_FRIENDLY);
185 add_friendly_object (ob); 171 add_friendly_object (ob);
186 enter_map ();
187} 172}
188 173
189void 174void
190player::deactivate () 175player::deactivate ()
191{ 176{
221 ob->close_container (); //TODO: client-specific 206 ob->close_container (); //TODO: client-specific
222 207
223 ns->update_look = 0; 208 ns->update_look = 0;
224 ns->look_position = 0; 209 ns->look_position = 0;
225 210
226 clear_los (ob); 211 clear_los (this);
227 212
228 ns->reset_stats (); 213 ns->reset_stats ();
229 214
230 /* make sure he's a player -- needed because of class change. */ 215 /* make sure he's a player -- needed because of class change. */
231 ob->type = PLAYER; // we are paranoid 216 ob->type = PLAYER; // we are paranoid
232 ob->race = ob->arch->clone.race; 217 ob->race = ob->arch->race;
233 218
234 ob->carrying = sum_weight (ob); 219 ob->carrying = sum_weight (ob);
235 link_player_skills (ob); 220 link_player_skills (ob);
236 221
237 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); 222 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
238 223
239 assign (title, ob->arch->clone.name); 224 assign (title, ob->arch->object::name);
240 225
241 /* if it's a dragon player, set the correct title here */ 226 /* if it's a dragon player, set the correct title here */
242 if (is_dragon_pl (ob)) 227 if (is_dragon_pl (ob))
243 { 228 {
244 object *tmp, *abil = 0, *skin = 0; 229 object *tmp, *abil = 0, *skin = 0;
245 230
246 shstr_cmp dragon_ability_force ("dragon_ability_force");
247 shstr_cmp dragon_skin_force ("dragon_skin_force");
248
249 for (tmp = ob->inv; tmp; tmp = tmp->below) 231 for (tmp = ob->inv; tmp; tmp = tmp->below)
250 if (tmp->type == FORCE) 232 if (tmp->type == FORCE)
251 if (tmp->arch->name == dragon_ability_force) 233 if (tmp->arch->archname == shstr_dragon_ability_force)
252 abil = tmp; 234 abil = tmp;
253 else if (tmp->arch->name == dragon_skin_force) 235 else if (tmp->arch->archname == shstr_dragon_skin_force)
254 skin = tmp; 236 skin = tmp;
255 237
256 set_dragon_name (ob, abil, skin); 238 set_dragon_name (ob, abil, skin);
257 } 239 }
258 240
302} 284}
303 285
304void 286void
305player::disconnect () 287player::disconnect ()
306{ 288{
289 if (ob)
290 {
291 ob->close_container (); //TODO: client-specific
292 ob->drop_unpaid_items ();
293 }
294
307 if (ns) 295 if (ns)
308 { 296 {
309 if (active) 297 if (active)
310 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); 298 INVOKE_PLAYER (LOGOUT, this, ARG_INT (0));
311 299
314 ns->reset_stats (); 302 ns->reset_stats ();
315 ns->pl = 0; 303 ns->pl = 0;
316 ns = 0; 304 ns = 0;
317 } 305 }
318 306
319 if (ob) 307 observe = ob;
320 ob->close_container (); //TODO: client-specific
321 308
322 deactivate (); 309 deactivate ();
323} 310}
324 311
325// the need for this function can be explained 312// the need for this function can be explained
326// by load_object not returning the object 313// by load_object not returning the object
327void 314void
328player::set_object (object *op) 315player::set_object (object *op)
329{ 316{
330 ob = op; 317 ob = observe = op;
331 ob->contr = this; /* this aren't yet in archetype */ 318 ob->contr = this; /* this aren't yet in archetype */
332 319
333 ob->speed = 1.0f; 320 ob->speed = 1.0f;
334 ob->speed_left = 0.5f; 321 ob->speed_left = 0.5f;
335 322
336 ob->direction = 5; /* So player faces south */ 323 ob->direction = 5; /* So player faces south */
324}
325
326void
327player::set_observe (object *op)
328{
329 observe = op ? op : ob;
330 do_los = 1;
337} 331}
338 332
339player::player () 333player::player ()
340{ 334{
341 /* There are some elements we want initialised to non zero value - 335 /* There are some elements we want initialised to non zero value -
369 if (ob) 363 if (ob)
370 { 364 {
371 ob->destroy_inv (false); 365 ob->destroy_inv (false);
372 ob->destroy (); 366 ob->destroy ();
373 } 367 }
368
369 ob = observe = 0;
374} 370}
375 371
376player::~player () 372player::~player ()
377{ 373{
378 /* Clear item stack */ 374 /* Clear item stack */
405 * Note: there MUST be at least one player archetype! 401 * Note: there MUST be at least one player archetype!
406 */ 402 */
407archetype * 403archetype *
408get_player_archetype (archetype *at) 404get_player_archetype (archetype *at)
409{ 405{
410 archetype *start = at; 406 archvec::iterator i = at ? archetypes.find (at) : archetypes.begin ();
411 407
412 for (;;) 408 for (;;)
413 { 409 {
414 if (at == NULL || at->next == NULL) 410 if (++i == archetypes.end ())
415 at = first_archetype; 411 i = archetypes.begin ();
416 else 412 else if (*i == at)
417 at = at->next; 413 cleanup ("not a single player archetype found");
418 414
419 if (at->clone.type == PLAYER) 415 if ((*i)->type == PLAYER)
420 return at; 416 return *i;
421
422 if (at == start)
423 {
424 LOG (llevError, "No Player archetypes\n");
425 exit (-1);
426 }
427 } 417 }
428} 418}
429 419
430object * 420object *
431get_nearest_player (object *mon) 421get_nearest_player (object *mon)
435 unsigned lastdist; 425 unsigned lastdist;
436 rv_vector rv; 426 rv_vector rv;
437 427
438 for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next) 428 for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next)
439 { 429 {
440 /* We should not find free objects on this friendly list, but it
441 * does periodically happen. Given that, lets deal with it.
442 * While unlikely, it is possible the next object on the friendly
443 * list is also free, so encapsulate this in a while loop.
444 */
445 while (QUERY_FLAG (ol->ob, FLAG_FREED) || !QUERY_FLAG (ol->ob, FLAG_FRIENDLY))
446 {
447 object *tmp = ol->ob;
448
449 /* Can't do much more other than log the fact, because the object
450 * itself will have been cleared.
451 */
452 LOG (llevDebug, "get_nearest_player: Found free/non friendly object '%s' on friendly list\n",
453 tmp->debug_desc ());
454 ol = ol->next;
455 remove_friendly_object (tmp);
456 if (!ol)
457 return op;
458 }
459
460 /* Remove special check for player from this. First, it looks to cause
461 * some crashes (ol->ob->contr not set properly?), but secondly, a more
462 * complicated method of state checking would be needed in any case -
463 * as it was, a clever player could type quit, and the function would
464 * skip them over while waiting for confirmation. Remove
465 * on_same_map check, as can_detect_enemy also does this
466 */
467 if (!can_detect_enemy (mon, ol->ob, &rv)) 430 if (!can_detect_enemy (mon, ol->ob, &rv))
468 continue; 431 continue;
469 432
470 if (lastdist > rv.distance) 433 if (lastdist > rv.distance)
471 { 434 {
921 if (*first_map_ext_path) 884 if (*first_map_ext_path)
922 { 885 {
923 object *tmp; 886 object *tmp;
924 char mapname[MAX_BUF]; 887 char mapname[MAX_BUF];
925 888
926 snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->name); 889 snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname);
927 tmp = object::create (); 890 tmp = object::create ();
928 EXIT_PATH (tmp) = mapname; 891 EXIT_PATH (tmp) = mapname;
929 EXIT_X (tmp) = ob->x; 892 EXIT_X (tmp) = ob->x;
930 EXIT_Y (tmp) = ob->y; 893 EXIT_Y (tmp) = ob->y;
931 ob->enter_exit (tmp); /* we don't really care if it succeeded; 894 ob->enter_exit (tmp); /* we don't really care if it succeeded;
950 int x = ob->x, y = ob->y; 913 int x = ob->x, y = ob->y;
951 914
952 ob->remove_statbonus (); 915 ob->remove_statbonus ();
953 ob->remove (); 916 ob->remove ();
954 ob->arch = get_player_archetype (ob->arch); 917 ob->arch = get_player_archetype (ob->arch);
955 ob->arch->clone.copy_to (ob); 918 ob->arch->copy_to (ob);
956 ob->instantiate (); 919 ob->instantiate ();
957 ob->stats = ob->contr->orig_stats; 920 ob->stats = ob->contr->orig_stats;
958 ob->name = ob->name_pl = name; 921 ob->name = ob->name_pl = name;
959 ob->x = x; 922 ob->x = x;
960 ob->y = y; 923 ob->y = y;
961 SET_ANIMATION (ob, 2); /* So player faces south */ 924 SET_ANIMATION (ob, 2); /* So player faces south */
962 insert_ob_in_map (ob, ob->map, ob, 0); 925 insert_ob_in_map (ob, ob->map, ob, 0);
963 assign (ob->contr->title, ob->arch->clone.name); 926 assign (ob->contr->title, ob->arch->object::name);
964 ob->add_statbonus (); 927 ob->add_statbonus ();
965 } 928 }
966 while (!allowed_class (ob)); 929 while (!allowed_class (ob));
967 930
968 update_object (ob, UP_OBJ_FACE); 931 update_object (ob, UP_OBJ_FACE);
1113 if (tmp->name != NULL) 1076 if (tmp->name != NULL)
1114 sprintf (putstring, "item name: %s item type: %d weight/value: %d", 1077 sprintf (putstring, "item name: %s item type: %d weight/value: %d",
1115 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1078 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))));
1116 else 1079 else
1117 sprintf (putstring, "item name: %s item type: %d weight/value: %d", 1080 sprintf (putstring, "item name: %s item type: %d weight/value: %d",
1118 &tmp->arch->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1081 &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))));
1119 1082
1120 new_draw_info (NDI_UNIQUE, 0, op, putstring); 1083 new_draw_info (NDI_UNIQUE, 0, op, putstring);
1121 } 1084 }
1122 1085
1123 /* philosophy: 1086 /* philosophy:
1198 pick_up (op, tmp); 1161 pick_up (op, tmp);
1199 continue; 1162 continue;
1200 } 1163 }
1201 1164
1202 if (op->contr->mode & PU_READABLES) 1165 if (op->contr->mode & PU_READABLES)
1203 if (tmp->type == BOOK || tmp->type == SCROLL) 1166 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE)
1204 { 1167 {
1205 pick_up (op, tmp); 1168 pick_up (op, tmp);
1206 continue; 1169 continue;
1207 } 1170 }
1208 1171
1316 /* careful: chairs and tables are weapons! */ 1279 /* careful: chairs and tables are weapons! */
1317 if (op->contr->mode & PU_ALLWEAPON) 1280 if (op->contr->mode & PU_ALLWEAPON)
1318 { 1281 {
1319 if (tmp->type == WEAPON && tmp->name != NULL) 1282 if (tmp->type == WEAPON && tmp->name != NULL)
1320 { 1283 {
1321 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1284 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL &&
1322 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1285 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL)
1323 { 1286 {
1324 pick_up (op, tmp); 1287 pick_up (op, tmp);
1325 continue; 1288 continue;
1326 } 1289 }
1327 } 1290 }
1328 1291
1329 if (tmp->type == WEAPON && tmp->name == NULL) 1292 if (tmp->type == WEAPON && tmp->name == NULL)
1330 { 1293 {
1331 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1294 if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL)
1332 { 1295 {
1333 pick_up (op, tmp); 1296 pick_up (op, tmp);
1334 continue; 1297 continue;
1335 } 1298 }
1336 } 1299 }
1361 if (tmp->name != NULL) 1324 if (tmp->name != NULL)
1362 { 1325 {
1363 fprintf (stderr, "%s", tmp->name); 1326 fprintf (stderr, "%s", tmp->name);
1364 } 1327 }
1365 else 1328 else
1366 fprintf (stderr, "%s", tmp->arch->name); 1329 fprintf (stderr, "%s", tmp->arch->archname);
1367 fprintf (stderr, ",%d] = ", tmp->type); 1330 fprintf (stderr, ",%d] = ", tmp->type);
1368 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1331 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))));
1369#endif 1332#endif
1370 continue; 1333 continue;
1371 } 1334 }
1441 else 1404 else
1442 { 1405 {
1443 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++) 1406 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++)
1444 { 1407 {
1445 attacktype = 1 << attacknum; 1408 attacktype = 1 << attacknum;
1446 if ((arrow->attacktype & attacktype) && (target->arch->clone.resist[attacknum]) < 0) 1409 if ((arrow->attacktype & attacktype) && (target->arch->resist[attacknum]) < 0)
1447 if (((arrow->magic + arrow->stats.dam) * (100 - target->arch->clone.resist[attacknum]) / 100) > betterby) 1410 if (((arrow->magic + arrow->stats.dam) * (100 - target->arch->resist[attacknum]) / 100) > betterby)
1448 { 1411 {
1449 tmp = arrow; 1412 tmp = arrow;
1450 betterby = (arrow->magic + arrow->stats.dam) * (100 - target->arch->clone.resist[attacknum]) / 100; 1413 betterby = (arrow->magic + arrow->stats.dam) * (100 - target->arch->resist[attacknum]) / 100;
1451 } 1414 }
1452 } 1415 }
1453 if ((2 + arrow->magic + arrow->stats.dam) > betterby) 1416 if ((2 + arrow->magic + arrow->stats.dam) > betterby)
1454 { 1417 {
1455 tmp = arrow; 1418 tmp = arrow;
1693 1656
1694 arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC); 1657 arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC);
1695 arrow->move_type = MOVE_FLY_LOW; 1658 arrow->move_type = MOVE_FLY_LOW;
1696 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1659 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1697 1660
1698 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1661 op->play_sound (sound_find ("fire_arrow"));
1699 m->insert (arrow, sx, sy, op); 1662 m->insert (arrow, sx, sy, op);
1700 1663
1701 if (!arrow->destroyed ()) 1664 if (!arrow->destroyed ())
1702 move_arrow (arrow); 1665 move_arrow (arrow);
1703 1666
1781 1744
1782 if (item->type == WAND) 1745 if (item->type == WAND)
1783 { 1746 {
1784 if (item->stats.food <= 0) 1747 if (item->stats.food <= 0)
1785 { 1748 {
1786 play_sound_player_only (op->contr, SOUND_WAND_POOF, 0, 0); 1749 op->contr->play_sound (sound_find ("wand_poof"));
1787 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s goes poof.", query_base_name (item, 0)); 1750 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s goes poof.", query_base_name (item, 0));
1788 1751
1789 return; 1752 return;
1790 } 1753 }
1791 } 1754 }
1792 else if (item->type == ROD || item->type == HORN) 1755 else if (item->type == ROD || item->type == HORN)
1793 { 1756 {
1794 if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) 1757 if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace))
1795 { 1758 {
1796 play_sound_player_only (op->contr, SOUND_WAND_POOF, 0, 0); 1759 op->contr->play_sound (sound_find ("wand_poof"));
1797 1760
1798 if (item->type == ROD) 1761 if (item->type == ROD)
1799 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); 1762 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0));
1800 else 1763 else
1801 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s needs more time to charge.", query_base_name (item, 0)); 1764 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s needs more time to charge.", query_base_name (item, 0));
1814 object *tmp; 1777 object *tmp;
1815 1778
1816 if (item->arch) 1779 if (item->arch)
1817 { 1780 {
1818 CLEAR_FLAG (item, FLAG_ANIMATE); 1781 CLEAR_FLAG (item, FLAG_ANIMATE);
1819 item->face = item->arch->clone.face; 1782 item->face = item->arch->face;
1820 item->set_speed (0); 1783 item->set_speed (0);
1821 } 1784 }
1822 1785
1823 if ((tmp = item->in_player ())) 1786 if ((tmp = item->in_player ()))
1824 esrv_update_item (UPD_ANIM, tmp, item); 1787 esrv_update_item (UPD_ANIM, tmp, item);
1990 /* If we found a key, do some extra work */ 1953 /* If we found a key, do some extra work */
1991 if (key) 1954 if (key)
1992 { 1955 {
1993 object *container = key->env; 1956 object *container = key->env;
1994 1957
1995 play_sound_map (op->map, op->x, op->y, SOUND_OPEN_DOOR);
1996
1997 if (action_makes_visible (op)) 1958 if (action_makes_visible (op))
1998 make_visible (op); 1959 make_visible (op);
1999 1960
2000 if (door->inv && (door->inv->type == RUNE || door->inv->type == TRAP)) 1961 if (door->inv && (door->inv->type == RUNE || door->inv->type == TRAP))
2001 spring_trap (door->inv, op); 1962 spring_trap (door->inv, op);
2114 2075
2115 if (op->speed_left > 0.f) 2076 if (op->speed_left > 0.f)
2116 { 2077 {
2117 --op->speed_left; 2078 --op->speed_left;
2118 2079
2119 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2080 op->play_sound (sound_find ("push_player"));
2120 push_ob (mon, dir, op); 2081 push_ob (mon, dir, op);
2121 2082
2122 if (op->contr->tmp_invis || op->hide) 2083 if (op->contr->tmp_invis || op->hide)
2123 make_visible (op); 2084 make_visible (op);
2124 2085
2143 { 2104 {
2144 --op->speed_left; 2105 --op->speed_left;
2145 2106
2146 if (!op->contr->braced) 2107 if (!op->contr->braced)
2147 { 2108 {
2148 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2109 op->play_sound (sound_find ("push_player"));
2149 push_ob (mon, dir, op); 2110 push_ob (mon, dir, op);
2150 } 2111 }
2151 else 2112 else
2152 new_draw_info (0, 0, op, "You withhold your attack"); 2113 new_draw_info (0, 0, op, "You withhold your attack");
2153 2114
2296 return 0; 2257 return 0;
2297 2258
2298 for (object *tmp = op->inv; tmp; tmp = tmp->below) 2259 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2299 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2260 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2300 { 2261 {
2301 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2262 op->play_sound (sound_find ("ob_evaporate"));
2302 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2263 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2303 2264
2304 if (op->contr) 2265 if (op->contr)
2305 esrv_del_item (op->contr, tmp->count); 2266 esrv_del_item (op->contr, tmp->count);
2306 2267
2326/* This goes throws the inventory and removes unpaid objects, and puts them 2287/* This goes throws the inventory and removes unpaid objects, and puts them
2327 * back in the map (location and map determined by values of env). This 2288 * back in the map (location and map determined by values of env). This
2328 * function will descend into containers. op is the object to start the search 2289 * function will descend into containers. op is the object to start the search
2329 * from. 2290 * from.
2330 */ 2291 */
2331void 2292static void
2332remove_unpaid_objects (object *op, object *env) 2293drop_unpaid_items (object *op, object *env)
2333{ 2294{
2334 while (op) 2295 while (op)
2335 { 2296 {
2336 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ 2297 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */
2337 2298
2341 esrv_del_item (env->contr, op->count); 2302 esrv_del_item (env->contr, op->count);
2342 2303
2343 op->insert_at (env); 2304 op->insert_at (env);
2344 } 2305 }
2345 else if (op->inv) 2306 else if (op->inv)
2346 remove_unpaid_objects (op->inv, env); 2307 drop_unpaid_items (op->inv, env);
2347 2308
2348 op = next; 2309 op = next;
2349 } 2310 }
2311}
2312
2313void
2314object::drop_unpaid_items ()
2315{
2316 if (!flag [FLAG_REMOVED])
2317 ::drop_unpaid_items (inv, this);
2350} 2318}
2351 2319
2352/* 2320/*
2353 * Returns pointer a static string containing gravestone text 2321 * Returns pointer a static string containing gravestone text
2354 * Moved from apply.c to player.c - player.c is what 2322 * Moved from apply.c to player.c - player.c is what
2449 gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace; 2417 gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace;
2450 else 2418 else
2451 { 2419 {
2452 gen_grace = op->stats.maxgrace; 2420 gen_grace = op->stats.maxgrace;
2453 rate_grace -= rate_grace / 2 * op->contr->gen_grace; 2421 rate_grace -= rate_grace / 2 * op->contr->gen_grace;
2454 }
2455
2456 /* Regenerate Spell Points */
2457 if (!op->contr->golem && --op->last_sp < 0)
2458 {
2459 gen_sp = gen_sp * 10 / (op->contr->gen_sp_armour < 10 ? 10 : op->contr->gen_sp_armour);
2460 if (op->stats.sp < op->stats.maxsp)
2461 {
2462 op->stats.sp++;
2463 /* dms do not consume food */
2464 if (!QUERY_FLAG (op, FLAG_WIZ))
2465 {
2466 op->stats.food--;
2467 if (op->contr->digestion < 0)
2468 op->stats.food += op->contr->digestion;
2469 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2470 op->stats.food = last_food;
2471 }
2472 }
2473
2474 if (max_sp > 1)
2475 {
2476 over_sp = (gen_sp + 10) / rate_sp;
2477 if (over_sp > 0)
2478 {
2479 if (op->stats.sp < op->stats.maxsp)
2480 {
2481 op->stats.sp += over_sp > max_sp ? max_sp : over_sp;
2482
2483 if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp))
2484 op->stats.sp--;
2485
2486 if (op->stats.sp > op->stats.maxsp)
2487 op->stats.sp = op->stats.maxsp;
2488 }
2489 op->last_sp = 0;
2490 }
2491 else
2492 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2493 }
2494 else
2495 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2496 } 2422 }
2497 2423
2498 /* Regenerate Grace */ 2424 /* Regenerate Grace */
2499 /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ 2425 /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */
2500 if (--op->last_grace < 0) 2426 if (--op->last_grace < 0)
2521 op->last_grace = rate_grace / (gen_grace < 20 ? 30 : gen_grace + 10); 2447 op->last_grace = rate_grace / (gen_grace < 20 ? 30 : gen_grace + 10);
2522 } 2448 }
2523 /* wearing stuff doesn't detract from grace generation. */ 2449 /* wearing stuff doesn't detract from grace generation. */
2524 } 2450 }
2525 2451
2452 if (op->stats.food > 0)
2453 {
2526 /* Regenerate Hit Points */ 2454 /* Regenerate Spell Points */
2527 if (--op->last_heal < 0) 2455 if (!op->contr->golem && --op->last_sp < 0)
2528 {
2529 if (op->stats.hp < op->stats.maxhp)
2530 { 2456 {
2531 op->stats.hp++; 2457 gen_sp = gen_sp * 10 / (op->contr->gen_sp_armour < 10 ? 10 : op->contr->gen_sp_armour);
2532 /* dms do not consume food */ 2458
2533 if (!QUERY_FLAG (op, FLAG_WIZ)) 2459 if (op->stats.sp < op->stats.maxsp)
2534 { 2460 {
2461 op->stats.sp++;
2462
2463 /* dms do not consume food */
2464 if (!QUERY_FLAG (op, FLAG_WIZ))
2465 {
2535 op->stats.food--; 2466 op->stats.food--;
2467
2536 if (op->contr->digestion < 0) 2468 if (op->contr->digestion < 0)
2537 op->stats.food += op->contr->digestion; 2469 op->stats.food += op->contr->digestion;
2538 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) 2470 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2539 op->stats.food = last_food; 2471 op->stats.food = last_food;
2472 }
2540 } 2473 }
2541 }
2542 2474
2543 if (max_hp > 1) 2475 if (max_sp > 1)
2544 {
2545 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2546 if (over_hp > 0)
2547 { 2476 {
2548 op->stats.sp += over_hp + (RANDOM () % rate_hp > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0; 2477 over_sp = (gen_sp + 10) / rate_sp;
2478 if (over_sp > 0)
2479 {
2480 if (op->stats.sp < op->stats.maxsp)
2481 {
2482 op->stats.sp += over_sp > max_sp ? max_sp : over_sp;
2483
2484 if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp))
2485 op->stats.sp--;
2486
2487 if (op->stats.sp > op->stats.maxsp)
2488 op->stats.sp = op->stats.maxsp;
2489 }
2490
2549 op->last_heal = 0; 2491 op->last_sp = 0;
2492 }
2493 else
2494 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2550 } 2495 }
2551 else 2496 else
2497 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2498 }
2499
2500 /* Regenerate Hit Points */
2501 if (--op->last_heal < 0)
2502 {
2503 if (op->stats.hp < op->stats.maxhp)
2552 { 2504 {
2553 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); 2505 op->stats.hp++;
2506
2507 /* dms do not consume food */
2508 if (!QUERY_FLAG (op, FLAG_WIZ))
2509 {
2510 op->stats.food--;
2511
2512 if (op->contr->digestion < 0)
2513 op->stats.food += op->contr->digestion;
2514 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2515 op->stats.food = last_food;
2516 }
2554 } 2517 }
2518
2519 if (max_hp > 1)
2520 {
2521 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2522
2523 if (over_hp > 0)
2524 {
2525 op->stats.sp += over_hp + (RANDOM () % rate_hp > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0;
2526 op->last_heal = 0;
2527 }
2528 else
2529 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10);
2555 } 2530 }
2556 else 2531 else
2557 {
2558 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); 2532 op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10);
2559 } 2533 }
2560 } 2534 }
2561 2535
2562 /* Digestion */ 2536 /* Digestion */
2563 if (--op->last_eat < 0) 2537 if (--op->last_eat < 0)
2564 { 2538 {
2565 int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; 2539 int bonus = max (0, op->contr->digestion),
2540 penalty = max (0, -op->contr->digestion);
2566 2541
2567 if (op->contr->gen_hp > 0)
2568 op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); 2542 op->last_eat = 25 * (1 + bonus) / (max (0, op->contr->gen_hp) + penalty + 1);
2569 else
2570 op->last_eat = 25 * (1 + bonus) / (penalty + 1);
2571 2543
2572 /* dms do not consume food */ 2544 /* dms do not consume food */
2573 if (!QUERY_FLAG (op, FLAG_WIZ)) 2545 if (!QUERY_FLAG (op, FLAG_WIZ))
2574 op->stats.food--; 2546 op->stats.food--;
2575 } 2547 }
2602 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2574 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2603 manual_apply (op, flesh, 0); 2575 manual_apply (op, flesh, 0);
2604 } 2576 }
2605 } 2577 }
2606 2578
2607 while (op->stats.food < 0 && op->stats.hp >= 0) 2579 if (op->stats.food < 0)
2608 op->stats.food++, op->stats.hp--; 2580 {
2581 op->stats.hp += op->stats.food;
2582 op->stats.food = 0;
2583 }
2609 2584
2610 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2585 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2611 kill_player (op); 2586 kill_player (op);
2612 } 2587 }
2613} 2588}
2635 archetype *at; 2610 archetype *at;
2636 object *tmp; 2611 object *tmp;
2637 2612
2638 if (save_life (op)) 2613 if (save_life (op))
2639 return; 2614 return;
2640
2641 2615
2642 /* If player dies on BATTLEGROUND, no stat/exp loss! For Combat-Arenas 2616 /* If player dies on BATTLEGROUND, no stat/exp loss! For Combat-Arenas
2643 * in cities ONLY!!! It is very important that this doesn't get abused. 2617 * in cities ONLY!!! It is very important that this doesn't get abused.
2644 * Look at op_on_battleground() for more info --AndreasV 2618 * Look at op_on_battleground() for more info --AndreasV
2645 */ 2619 */
2698 strcpy (op->contr->killer, "starvation"); 2672 strcpy (op->contr->killer, "starvation");
2699 } 2673 }
2700 else 2674 else
2701 sprintf (buf, "%s died.", &op->name); 2675 sprintf (buf, "%s died.", &op->name);
2702 2676
2703 play_sound_player_only (op->contr, SOUND_PLAYER_DIES, 0, 0); 2677 op->contr->play_sound (sound_find ("player_dies"));
2704 2678
2705 /* save the map location for corpse, gravestone */ 2679 /* save the map location for corpse, gravestone */
2706 x = op->x; 2680 x = op->x;
2707 y = op->y; 2681 y = op->y;
2708 map = op->map; 2682 map = op->map;
2885 2859
2886 /* 2860 /*
2887 * Check to see if the player has any unpaid items. If so, remove them 2861 * Check to see if the player has any unpaid items. If so, remove them
2888 * and put them back in the map. 2862 * and put them back in the map.
2889 */ 2863 */
2890 remove_unpaid_objects (op->inv, op); 2864 op->drop_unpaid_items ();
2891 2865
2892 /****************************************/ 2866 /****************************************/
2893 /* */ 2867 /* */
2894 /* Move player to his current respawn- */ 2868 /* Move player to his current respawn- */
2895 /* position (usually last savebed) */ 2869 /* position (usually last savebed) */
3035void 3009void
3036make_visible (object *op) 3010make_visible (object *op)
3037{ 3011{
3038 op->hide = 0; 3012 op->hide = 0;
3039 op->invisible = 0; 3013 op->invisible = 0;
3014
3040 if (op->type == PLAYER) 3015 if (op->type == PLAYER)
3041 { 3016 {
3042 op->contr->tmp_invis = 0; 3017 op->contr->tmp_invis = 0;
3043 op->contr->invis_race = 0; 3018 op->contr->invis_race = 0;
3044 } 3019 }
3047} 3022}
3048 3023
3049int 3024int
3050is_true_undead (object *op) 3025is_true_undead (object *op)
3051{ 3026{
3052 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) 3027 if (QUERY_FLAG (op->arch, FLAG_UNDEAD))
3053 return 1; 3028 return 1;
3054 3029
3055 return 0; 3030 return 0;
3056} 3031}
3057 3032
3058/* look at the surrounding terrain to determine 3033/* look at the surrounding terrain to determine
3059 * the hideability of this object. Positive levels 3034 * the hideability of this object. Positive levels
3060 * indicate greater hideability. 3035 * indicate greater hideability.
3061 */ 3036 */
3062
3063int 3037int
3064hideability (object *ob) 3038hideability (object *ob)
3065{ 3039{
3066 int i, level = 0, mflag; 3040 int i, level = 0, mflag;
3067 sint16 x, y; 3041 sint16 x, y;
3192 * object op. This function works fine for monsters, 3166 * object op. This function works fine for monsters,
3193 * but we dont worry if the object isnt the top one in 3167 * but we dont worry if the object isnt the top one in
3194 * a pile (say a coin under a table would return "viewable" 3168 * a pile (say a coin under a table would return "viewable"
3195 * by this routine). Another question, should we be 3169 * by this routine). Another question, should we be
3196 * concerned with the direction the player is looking 3170 * concerned with the direction the player is looking
3197 * in? Realistically, most of use cant see stuff behind 3171 * in? Realistically, most of us can't see stuff behind
3198 * our backs...on the other hand, does the "facing" direction 3172 * our backs...on the other hand, does the "facing" direction
3199 * imply the way your head, or body is facing? Its possible 3173 * imply the way your head, or body is facing? It's possible
3200 * for them to differ. Sigh, this fctn could get a bit more complex. 3174 * for them to differ. Sigh, this fctn could get a bit more complex.
3201 * -b.t. 3175 * -b.t.
3202 * This function is now map tiling safe. 3176 * This function is now map tiling safe.
3203 */ 3177 */
3204
3205int 3178int
3206player_can_view (object *pl, object *op) 3179player_can_view (object *pl, object *op)
3207{ 3180{
3208 rv_vector rv; 3181 rv_vector rv;
3209 int dx, dy; 3182 int dx, dy;
3221 3194
3222 get_rangevector (pl, op, &rv, 0x1); 3195 get_rangevector (pl, op, &rv, 0x1);
3223 3196
3224 /* starting with the 'head' part, lets loop 3197 /* starting with the 'head' part, lets loop
3225 * through the object and find if it has any 3198 * through the object and find if it has any
3226 * part that is in the los array but isnt on 3199 * part that is in the los array but isn't on
3227 * a blocked los square. 3200 * a blocked los square.
3228 * we use the archetype to figure out offsets. 3201 * we use the archetype to figure out offsets.
3229 */ 3202 */
3230 while (op) 3203 while (op)
3231 { 3204 {
3232 dx = rv.distance_x + op->arch->clone.x; 3205 dx = rv.distance_x + op->arch->x;
3233 dy = rv.distance_y + op->arch->clone.y; 3206 dy = rv.distance_y + op->arch->y;
3234 3207
3235 /* only the viewable area the player sees is updated by LOS 3208 /* only the viewable area the player sees is updated by LOS
3236 * code, so we need to restrict ourselves to that range of values 3209 * code, so we need to restrict ourselves to that range of values
3237 * for any meaningful values. 3210 * for any meaningful values.
3238 */ 3211 */
3239 if (FABS (dx) <= (pl->contr->ns->mapx / 2) && 3212 if (abs (dx) <= (pl->contr->ns->mapx / 2) &&
3240 FABS (dy) <= (pl->contr->ns->mapy / 2) && 3213 abs (dy) <= (pl->contr->ns->mapy / 2) &&
3241 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) 3214 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3242 return 1; 3215 return 1;
3216
3243 op = op->more; 3217 op = op->more;
3244 } 3218 }
3219
3245 return 0; 3220 return 0;
3246} 3221}
3247 3222
3248/* routine for both players and monsters. We call this when 3223/* routine for both players and monsters. We call this when
3249 * there is a possibility for our action distrubing our hiding 3224 * there is a possibility for our action distrubing our hiding
3252 * return 0. 3227 * return 0.
3253 */ 3228 */
3254int 3229int
3255action_makes_visible (object *op) 3230action_makes_visible (object *op)
3256{ 3231{
3257
3258 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) 3232 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
3259 { 3233 {
3260 if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) 3234 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
3261 return 0; 3235 return 0;
3262 3236
3268 { 3242 {
3269 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); 3243 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible");
3270 return 1; 3244 return 1;
3271 } 3245 }
3272 } 3246 }
3247
3273 return 0; 3248 return 0;
3274} 3249}
3275 3250
3276/* op_on_battleground - checks if the given object op (usually 3251/* op_on_battleground - checks if the given object op (usually
3277 * a player) is standing on a valid battleground-tile, 3252 * a player) is standing on a valid battleground-tile,
3282 * Default is to do the same as before, so only people wanting to have different points need worry about this 3257 * Default is to do the same as before, so only people wanting to have different points need worry about this
3283 */ 3258 */
3284int 3259int
3285op_on_battleground (object *op, int *x, int *y) 3260op_on_battleground (object *op, int *x, int *y)
3286{ 3261{
3287 object *tmp;
3288
3289 /* A battleground-tile needs the following attributes to be valid: 3262 /* A battleground-tile needs the following attributes to be valid:
3290 * is_floor 1 (has to be the FIRST floor beneath the player's feet), 3263 * is_floor 1 (has to be the FIRST floor beneath the player's feet),
3291 * name="battleground", no_pick 1, type=58 (type BATTLEGROUND) 3264 * name="battleground", no_pick 1, type=58 (type BATTLEGROUND)
3292 * and the exit-coordinates sp/hp must both be > 0. 3265 * and the exit-coordinates sp/hp must both be > 0.
3293 * => The intention here is to prevent abuse of the battleground- 3266 * => The intention here is to prevent abuse of the battleground-
3294 * feature (like pickable or hidden battleground tiles). */ 3267 * feature (like pickable or hidden battleground tiles). */
3295 for (tmp = op->below; tmp != NULL; tmp = tmp->below) 3268 for (object *tmp = op->below; tmp; tmp = tmp->below)
3296 { 3269 {
3297 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 3270 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
3298 { 3271 {
3299 if (QUERY_FLAG (tmp, FLAG_NO_PICK) && 3272 if (QUERY_FLAG (tmp, FLAG_NO_PICK)
3300 strcmp (tmp->name, "battleground") == 0 && tmp->type == BATTLEGROUND && EXIT_X (tmp) && EXIT_Y (tmp)) 3273 && tmp->type == BATTLEGROUND
3274 && tmp->name == shstr_battleground
3275 && EXIT_X (tmp) && EXIT_Y (tmp))
3301 { 3276 {
3302 /*before we assign the exit, check if this is a teambattle */ 3277 /* before we assign the exit, check if this is a teambattle */
3303 if (EXIT_ALT_X (tmp) && EXIT_ALT_Y (tmp) && EXIT_PATH (tmp)) 3278 if (EXIT_ALT_X (tmp) && EXIT_ALT_Y (tmp) && EXIT_PATH (tmp))
3304 { 3279 {
3305 object *invtmp;
3306
3307 for (invtmp = op->inv; invtmp != NULL; invtmp = invtmp->below) 3280 for (object *invtmp = op->inv; invtmp; invtmp = invtmp->below)
3308 { 3281 {
3309 if (invtmp->type == FORCE && invtmp->slaying && !strcmp (EXIT_PATH (tmp), invtmp->slaying)) 3282 if (invtmp->type == FORCE && invtmp->slaying && tmp->slaying == invtmp->slaying)
3310 { 3283 {
3311 if (x != NULL && y != NULL) 3284 if (x && y)
3312 *x = EXIT_ALT_X (tmp), *y = EXIT_ALT_Y (tmp); 3285 *x = EXIT_ALT_X (tmp), *y = EXIT_ALT_Y (tmp);
3286
3313 return 1; 3287 return 1;
3314 } 3288 }
3315 } 3289 }
3316 } 3290 }
3291
3317 if (x != NULL && y != NULL) 3292 if (x && y)
3318 *x = EXIT_X (tmp), *y = EXIT_Y (tmp); 3293 *x = EXIT_X (tmp), *y = EXIT_Y (tmp);
3294
3319 return 1; 3295 return 1;
3320 } 3296 }
3321 } 3297 }
3322 } 3298 }
3299
3323 /* If we got here, did not find a battleground */ 3300 /* If we got here, did not find a battleground */
3324 return 0; 3301 return 0;
3325} 3302}
3326 3303
3327/* 3304/*
3343 char buf[MAX_BUF]; /* tmp. string buffer */ 3320 char buf[MAX_BUF]; /* tmp. string buffer */
3344 int i = 0, j = 0; 3321 int i = 0, j = 0;
3345 3322
3346 /* get the appropriate treasurelist */ 3323 /* get the appropriate treasurelist */
3347 if (atnr == ATNR_FIRE) 3324 if (atnr == ATNR_FIRE)
3348 trlist = treasurelist::find ("dragon_ability_fire"); 3325 trlist = treasurelist::find (shstr_dragon_ability_fire);
3349 else if (atnr == ATNR_COLD) 3326 else if (atnr == ATNR_COLD)
3350 trlist = treasurelist::find ("dragon_ability_cold"); 3327 trlist = treasurelist::find (shstr_dragon_ability_cold);
3351 else if (atnr == ATNR_ELECTRICITY) 3328 else if (atnr == ATNR_ELECTRICITY)
3352 trlist = treasurelist::find ("dragon_ability_elec"); 3329 trlist = treasurelist::find (shstr_dragon_ability_elec);
3353 else if (atnr == ATNR_POISON) 3330 else if (atnr == ATNR_POISON)
3354 trlist = treasurelist::find ("dragon_ability_poison"); 3331 trlist = treasurelist::find (shstr_dragon_ability_poison);
3355 3332
3356 if (trlist == NULL || who->type != PLAYER) 3333 if (trlist == NULL || who->type != PLAYER)
3357 return; 3334 return;
3358 3335
3359 for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); 3336 for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++);
3363 /* LOG(llevDebug, "-> no more treasure for %s\n", change_resist_msg[atnr]); */ 3340 /* LOG(llevDebug, "-> no more treasure for %s\n", change_resist_msg[atnr]); */
3364 return; 3341 return;
3365 } 3342 }
3366 3343
3367 /* everything seems okay - now bring on the gift: */ 3344 /* everything seems okay - now bring on the gift: */
3368 item = &(tr->item->clone); 3345 item = tr->item;
3369 3346
3370 if (item->type == SPELL) 3347 if (item->type == SPELL)
3371 { 3348 {
3372 if (check_spell_known (who, item->name)) 3349 if (check_spell_known (who, item->name))
3373 return; 3350 return;
3432 { 3409 {
3433 /* forces in the treasurelist can alter the player's stats */ 3410 /* forces in the treasurelist can alter the player's stats */
3434 object *skin; 3411 object *skin;
3435 3412
3436 /* first get the dragon skin force */ 3413 /* first get the dragon skin force */
3437 shstr_cmp dragon_skin_force ("dragon_skin_force");
3438 for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below) 3414 for (skin = who->inv; skin && !(skin->arch->archname == shstr_dragon_skin_force); skin = skin->below)
3439 ; 3415 ;
3440 3416
3441 if (!skin) 3417 if (!skin)
3442 return; 3418 return;
3443 3419

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines