… | |
… | |
116 | |
116 | |
117 | news[0] = '\0'; |
117 | news[0] = '\0'; |
118 | subject[0] = '\0'; |
118 | subject[0] = '\0'; |
119 | size = 0; |
119 | size = 0; |
120 | |
120 | |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
121 | while (fgets (buf, MAX_BUF, fp)) |
122 | { |
122 | { |
123 | if (*buf == '#') |
123 | if (*buf == '#') |
124 | continue; |
124 | continue; |
125 | |
125 | |
126 | if (*buf == '%') |
126 | if (*buf == '%') |
… | |
… | |
194 | return; |
194 | return; |
195 | |
195 | |
196 | terminate_all_pets (ob); |
196 | terminate_all_pets (ob); |
197 | remove_friendly_object (ob); |
197 | remove_friendly_object (ob); |
198 | ob->deactivate_recursive (); |
198 | ob->deactivate_recursive (); |
|
|
199 | maplevel = ob->map->path; |
199 | ob->remove (); |
200 | ob->remove (); |
200 | ob->map = 0; |
201 | ob->map = 0; |
|
|
202 | party = 0; |
201 | |
203 | |
202 | // for weird reasons, this is often "ob", keeping a circular reference |
204 | // for weird reasons, this is often "ob", keeping a circular reference |
203 | ranges [range_skill] = 0; |
205 | ranges [range_skill] = 0; |
204 | |
206 | |
205 | players.erase (this); |
207 | players.erase (this); |
… | |
… | |
211 | player::connect (client *ns) |
213 | player::connect (client *ns) |
212 | { |
214 | { |
213 | this->ns = ns; |
215 | this->ns = ns; |
214 | ns->pl = this; |
216 | ns->pl = this; |
215 | |
217 | |
|
|
218 | run_on = 0; |
|
|
219 | fire_on = 0; |
|
|
220 | ob->close_container (); //TODO: client-specific |
|
|
221 | |
216 | ns->update_look = 0; |
222 | ns->update_look = 0; |
217 | ns->look_position = 0; |
223 | ns->look_position = 0; |
218 | |
224 | |
219 | clear_los (ob); |
225 | clear_los (ob); |
220 | |
226 | |
221 | //TODO: must move into client |
227 | ns->reset_stats (); |
222 | /* we need to clear these to -1 and not zero - otherwise, |
|
|
223 | * if a player quits and starts a new character, we wont |
|
|
224 | * send new values to the client, as things like exp start |
|
|
225 | * at zero. |
|
|
226 | */ |
|
|
227 | for (int i = 0; i < NUM_SKILLS; i++) |
|
|
228 | last_skill_exp[i] = -1; |
|
|
229 | |
|
|
230 | for (int i = 0; i < NROFATTACKS; i++) |
|
|
231 | last_resist[i] = -1; |
|
|
232 | |
|
|
233 | last_weapon_sp = -1; |
|
|
234 | last_level = -1; |
|
|
235 | last_stats.exp = -1; |
|
|
236 | last_weight = (uint32) - 1; |
|
|
237 | last_flags = 0; |
|
|
238 | last_weight = 0; |
|
|
239 | last_weight_limit = 0; |
|
|
240 | last_path_attuned = 0; |
|
|
241 | last_path_repelled = 0; |
|
|
242 | last_path_denied = 0; |
|
|
243 | last_speed = 0; |
|
|
244 | run_on = 0; |
|
|
245 | fire_on = 0; |
|
|
246 | memset (&last_stats, 0, sizeof (living)); //TODO dirty |
|
|
247 | |
228 | |
248 | /* make sure he's a player -- needed because of class change. */ |
229 | /* make sure he's a player -- needed because of class change. */ |
249 | ob->type = PLAYER; // we are paranoid |
230 | ob->type = PLAYER; // we are paranoid |
250 | ob->race = ob->arch->clone.race; |
231 | ob->race = ob->arch->clone.race; |
251 | |
232 | |
… | |
… | |
256 | link_player_skills (ob); |
237 | link_player_skills (ob); |
257 | |
238 | |
258 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
239 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
259 | |
240 | |
260 | assign (title, ob->arch->clone.name); |
241 | assign (title, ob->arch->clone.name); |
261 | |
|
|
262 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
|
|
263 | * from the class, and not race. I don't see any way to get the class information |
|
|
264 | * to then update this. I don't think this will actually break anything - anyone |
|
|
265 | * that can use armour should be able to use a shield. What this may 'break' |
|
|
266 | * are features new characters get, eg, if someone starts up with a Q, they |
|
|
267 | * should be able to use a shield. However, old Q's won't get that advantage. |
|
|
268 | */ |
|
|
269 | if (QUERY_FLAG (ob, FLAG_USE_ARMOUR)) |
|
|
270 | SET_FLAG (ob, FLAG_USE_SHIELD); |
|
|
271 | |
242 | |
272 | /* if it's a dragon player, set the correct title here */ |
243 | /* if it's a dragon player, set the correct title here */ |
273 | if (is_dragon_pl (ob)) |
244 | if (is_dragon_pl (ob)) |
274 | { |
245 | { |
275 | object *tmp, *abil = 0, *skin = 0; |
246 | object *tmp, *abil = 0, *skin = 0; |
… | |
… | |
315 | if (active) |
286 | if (active) |
316 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
287 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
317 | |
288 | |
318 | INVOKE_PLAYER (DISCONNECT, this); |
289 | INVOKE_PLAYER (DISCONNECT, this); |
319 | |
290 | |
|
|
291 | ns->reset_stats (); |
320 | ns->pl = 0; |
292 | ns->pl = 0; |
321 | this->ns = 0; |
293 | this->ns = 0; |
322 | } |
294 | } |
|
|
295 | |
|
|
296 | if (ob) |
|
|
297 | ob->close_container (); //TODO: client-specific |
323 | |
298 | |
324 | deactivate (); |
299 | deactivate (); |
325 | } |
300 | } |
326 | |
301 | |
327 | // the need for this function can be explained |
302 | // the need for this function can be explained |
328 | // by load_object not returning the object |
303 | // by load_object not returning the object |
329 | void |
304 | void |
330 | player::set_object (object *op) |
305 | player::set_object (object *op) |
331 | { |
306 | { |
332 | ob = op; |
307 | ob = op; |
333 | ob->contr = this; /* this aren't yet in archetype */ |
308 | ob->contr = this; /* this aren't yet in archetype */ |
334 | |
309 | |
335 | ob->speed_left = 0.5; |
310 | ob->speed_left = 0.5; |
336 | ob->speed = 1.0; |
311 | ob->speed = 1.0; |
337 | ob->direction = 5; /* So player faces south */ |
312 | ob->direction = 5; /* So player faces south */ |
338 | ob->stats.wc = 2; |
|
|
339 | ob->run_away = 25; /* Then we panick... */ |
|
|
340 | |
|
|
341 | ob->roll_stats (); |
|
|
342 | } |
313 | } |
343 | |
314 | |
344 | player::player () |
315 | player::player () |
345 | { |
316 | { |
346 | /* There are some elements we want initialised to non zero value - |
317 | /* There are some elements we want initialised to non zero value - |
… | |
… | |
390 | player::create () |
361 | player::create () |
391 | { |
362 | { |
392 | player *pl = new player; |
363 | player *pl = new player; |
393 | |
364 | |
394 | pl->set_object (arch_to_object (get_player_archetype (0))); |
365 | pl->set_object (arch_to_object (get_player_archetype (0))); |
|
|
366 | |
|
|
367 | pl->ob->roll_stats (); |
|
|
368 | pl->ob->stats.wc = 2; |
|
|
369 | pl->ob->run_away = 25; /* Then we panick... */ |
|
|
370 | |
395 | set_first_map (pl->ob); |
371 | set_first_map (pl->ob); |
396 | |
372 | |
397 | return pl; |
373 | return pl; |
398 | } |
374 | } |
399 | |
375 | |
… | |
… | |
545 | x = mon->x; |
521 | x = mon->x; |
546 | y = mon->y; |
522 | y = mon->y; |
547 | m = mon->map; |
523 | m = mon->map; |
548 | dir = rv.direction; |
524 | dir = rv.direction; |
549 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
525 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
550 | diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); |
526 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
|
|
527 | |
551 | /* If we can't solve it within the search distance, return now. */ |
528 | /* If we can't solve it within the search distance, return now. */ |
552 | if (diff > max) |
529 | if (diff > max) |
553 | return 0; |
530 | return 0; |
|
|
531 | |
554 | while (diff > 1 && max > 0) |
532 | while (diff > 1 && max > 0) |
555 | { |
533 | { |
556 | lastx = x; |
534 | lastx = x; |
557 | lasty = y; |
535 | lasty = y; |
558 | lastmap = m; |
536 | lastmap = m; |
… | |
… | |
640 | max--; |
618 | max--; |
641 | lastdir = dir; |
619 | lastdir = dir; |
642 | if (!firstdir) |
620 | if (!firstdir) |
643 | firstdir = dir; |
621 | firstdir = dir; |
644 | } |
622 | } |
|
|
623 | |
645 | if (diff <= 1) |
624 | if (diff <= 1) |
646 | { |
625 | { |
647 | /* Recalculate diff (distance) because we may not have actually |
626 | /* Recalculate diff (distance) because we may not have actually |
648 | * headed toward player for entire distance. |
627 | * headed toward player for entire distance. |
649 | */ |
628 | */ |
650 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
629 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
651 | diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); |
630 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
652 | } |
631 | } |
|
|
632 | |
653 | if (diff > max) |
633 | if (diff > max) |
654 | return 0; |
634 | return 0; |
655 | } |
635 | } |
|
|
636 | |
656 | /* If we reached the max, didn't find a direction in time */ |
637 | /* If we reached the max, didn't find a direction in time */ |
657 | if (!max) |
638 | if (!max) |
658 | return 0; |
639 | return 0; |
659 | |
640 | |
660 | return firstdir; |
641 | return firstdir; |
… | |
… | |
774 | roll_stat (void) |
755 | roll_stat (void) |
775 | { |
756 | { |
776 | int a[4], i, j, k; |
757 | int a[4], i, j, k; |
777 | |
758 | |
778 | for (i = 0; i < 4; i++) |
759 | for (i = 0; i < 4; i++) |
779 | a[i] = (int) RANDOM () % 6 + 1; |
760 | a[i] = (int) rndm (6) + 1; |
780 | |
761 | |
781 | for (i = 0, j = 0, k = 7; i < 4; i++) |
762 | for (i = 0, j = 0, k = 7; i < 4; i++) |
782 | if (a[i] < k) |
763 | if (a[i] < k) |
783 | k = a[i], j = i; |
764 | k = a[i], j = i; |
784 | |
765 | |
… | |
… | |
914 | * to save here. |
895 | * to save here. |
915 | */ |
896 | */ |
916 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name); |
897 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name); |
917 | make_path_to_file (buf); |
898 | make_path_to_file (buf); |
918 | |
899 | |
919 | #ifdef AUTOSAVE |
|
|
920 | op->contr->last_save_tick = pticks; |
|
|
921 | #endif |
|
|
922 | start_info (op); |
900 | start_info (op); |
923 | CLEAR_FLAG (op, FLAG_WIZ); |
901 | CLEAR_FLAG (op, FLAG_WIZ); |
924 | give_initial_items (op, op->randomitems); |
902 | give_initial_items (op, op->randomitems); |
925 | link_player_skills (op); |
903 | link_player_skills (op); |
926 | esrv_send_inventory (op, op); |
904 | esrv_send_inventory (op, op); |
… | |
… | |
1400 | * found object is returned. |
1378 | * found object is returned. |
1401 | */ |
1379 | */ |
1402 | object * |
1380 | object * |
1403 | find_arrow (object *op, const char *type) |
1381 | find_arrow (object *op, const char *type) |
1404 | { |
1382 | { |
1405 | object *tmp = NULL; |
1383 | object *tmp = 0; |
1406 | |
1384 | |
1407 | for (op = op->inv; op; op = op->below) |
1385 | for (op = op->inv; op; op = op->below) |
1408 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
1386 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
1409 | tmp = find_arrow (op, type); |
1387 | tmp = find_arrow (op, type); |
1410 | else if (op->type == ARROW && op->race == type) |
1388 | else if (op->type == ARROW && op->race == type) |
1411 | return op; |
1389 | return op; |
|
|
1390 | |
1412 | return tmp; |
1391 | return tmp; |
1413 | } |
1392 | } |
1414 | |
1393 | |
1415 | /* |
1394 | /* |
1416 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1395 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1417 | * against the target. A full test is not performed, simply a basic test |
1396 | * against the target. A full test is not performed, simply a basic test |
1418 | * of resistances. The archer is making a quick guess at what he sees down |
1397 | * of resistances. The archer is making a quick guess at what he sees down |
1419 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1398 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1420 | */ |
1399 | */ |
1421 | |
|
|
1422 | object * |
1400 | object * |
1423 | find_better_arrow (object *op, object *target, const char *type, int *better) |
1401 | find_better_arrow (object *op, object *target, const char *type, int *better) |
1424 | { |
1402 | { |
1425 | object *tmp = NULL, *arrow, *ntmp; |
1403 | object *tmp = NULL, *arrow, *ntmp; |
1426 | int attacknum, attacktype, betterby = 0, i; |
1404 | int attacknum, attacktype, betterby = 0, i; |
… | |
… | |
1886 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
1864 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
1887 | return; |
1865 | return; |
1888 | } |
1866 | } |
1889 | } |
1867 | } |
1890 | |
1868 | |
1891 | |
|
|
1892 | |
|
|
1893 | /* find_key |
1869 | /* find_key |
1894 | * We try to find a key for the door as passed. If we find a key |
1870 | * We try to find a key for the door as passed. If we find a key |
1895 | * and successfully use it, we return the key, otherwise NULL |
1871 | * and successfully use it, we return the key, otherwise NULL |
1896 | * This function merges both normal and locked door, since the logic |
1872 | * This function merges both normal and locked door, since the logic |
1897 | * for both is the same - just the specific key is different. |
1873 | * for both is the same - just the specific key is different. |
1898 | * pl is the player, |
1874 | * pl is the player, |
1899 | * inv is the objects inventory to searched |
1875 | * inv is the objects inventory to searched |
1900 | * door is the door we are trying to match against. |
1876 | * door is the door we are trying to match against. |
1901 | * This function can be called recursively to search containers. |
1877 | * This function can be called recursively to search containers. |
1902 | */ |
1878 | */ |
1903 | |
|
|
1904 | object * |
1879 | object * |
1905 | find_key (object *pl, object *container, object *door) |
1880 | find_key (object *pl, object *container, object *door) |
1906 | { |
1881 | { |
1907 | object *tmp, *key; |
1882 | object *tmp, *key; |
1908 | |
1883 | |
1909 | /* Should not happen, but sanity checking is never bad */ |
1884 | /* Should not happen, but sanity checking is never bad */ |
1910 | if (container->inv == NULL) |
1885 | if (!container->inv) |
1911 | return NULL; |
1886 | return 0; |
1912 | |
1887 | |
1913 | /* First, lets try to find a key in the top level inventory */ |
1888 | /* First, lets try to find a key in the top level inventory */ |
1914 | for (tmp = container->inv; tmp != NULL; tmp = tmp->below) |
1889 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1915 | { |
1890 | { |
1916 | if (door->type == DOOR && tmp->type == KEY) |
1891 | if (door->type == DOOR && tmp->type == KEY) |
1917 | break; |
1892 | break; |
1918 | /* For sanity, we should really check door type, but other stuff |
1893 | /* For sanity, we should really check door type, but other stuff |
1919 | * (like containers) can be locked with special keys |
1894 | * (like containers) can be locked with special keys |
1920 | */ |
1895 | */ |
1921 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1896 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1922 | break; |
1897 | break; |
1923 | } |
1898 | } |
|
|
1899 | |
1924 | /* No key found - lets search inventories now */ |
1900 | /* No key found - lets search inventories now */ |
1925 | /* If we find and use a key in an inventory, return at that time. |
1901 | /* If we find and use a key in an inventory, return at that time. |
1926 | * otherwise, if we search all the inventories and still don't find |
1902 | * otherwise, if we search all the inventories and still don't find |
1927 | * a key, return |
1903 | * a key, return |
1928 | */ |
1904 | */ |
1929 | if (!tmp) |
1905 | if (!tmp) |
1930 | { |
1906 | { |
1931 | for (tmp = container->inv; tmp != NULL; tmp = tmp->below) |
1907 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1932 | { |
1908 | { |
1933 | /* No reason to search empty containers */ |
1909 | /* No reason to search empty containers */ |
1934 | if (tmp->type == CONTAINER && tmp->inv) |
1910 | if (tmp->type == CONTAINER && tmp->inv) |
1935 | { |
1911 | { |
1936 | if ((key = find_key (pl, tmp, door)) != NULL) |
1912 | if ((key = find_key (pl, tmp, door))) |
1937 | return key; |
1913 | return key; |
1938 | } |
1914 | } |
1939 | } |
1915 | } |
|
|
1916 | |
1940 | if (!tmp) |
1917 | if (!tmp) |
1941 | return NULL; |
1918 | return NULL; |
1942 | } |
1919 | } |
|
|
1920 | |
1943 | /* We get down here if we have found a key. Now if its in a container, |
1921 | /* We get down here if we have found a key. Now if its in a container, |
1944 | * see if we actually want to use it |
1922 | * see if we actually want to use it |
1945 | */ |
1923 | */ |
1946 | if (pl != container) |
1924 | if (pl != container) |
1947 | { |
1925 | { |
… | |
… | |
1968 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1946 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1969 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1947 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1970 | return NULL; |
1948 | return NULL; |
1971 | } |
1949 | } |
1972 | } |
1950 | } |
|
|
1951 | |
1973 | return tmp; |
1952 | return tmp; |
1974 | } |
1953 | } |
1975 | |
1954 | |
1976 | /* moved door processing out of move_player_attack. |
1955 | /* moved door processing out of move_player_attack. |
1977 | * returns 1 if player has opened the door with a key |
1956 | * returns 1 if player has opened the door with a key |
… | |
… | |
1995 | play_sound_map (op->map, op->x, op->y, SOUND_OPEN_DOOR); |
1974 | play_sound_map (op->map, op->x, op->y, SOUND_OPEN_DOOR); |
1996 | if (action_makes_visible (op)) |
1975 | if (action_makes_visible (op)) |
1997 | make_visible (op); |
1976 | make_visible (op); |
1998 | if (door->inv && (door->inv->type == RUNE || door->inv->type == TRAP)) |
1977 | if (door->inv && (door->inv->type == RUNE || door->inv->type == TRAP)) |
1999 | spring_trap (door->inv, op); |
1978 | spring_trap (door->inv, op); |
|
|
1979 | |
2000 | if (door->type == DOOR) |
1980 | if (door->type == DOOR) |
2001 | { |
|
|
2002 | hit_player (door, 9998, op, AT_PHYSICAL, 1); /* Break through the door */ |
1981 | hit_player (door, 9998, op, AT_PHYSICAL, 1); /* Break through the door */ |
2003 | } |
|
|
2004 | else if (door->type == LOCKED_DOOR) |
1982 | else if (door->type == LOCKED_DOOR) |
2005 | { |
1983 | { |
2006 | new_draw_info_format (NDI_UNIQUE, NDI_BROWN, op, "You open the door with the %s", query_short_name (key)); |
1984 | new_draw_info_format (NDI_UNIQUE, NDI_BROWN, op, "You open the door with the %s", query_short_name (key)); |
2007 | remove_door2 (door); /* remove door without violence ;-) */ |
1985 | remove_door2 (door); /* remove door without violence ;-) */ |
2008 | } |
1986 | } |
|
|
1987 | |
2009 | /* Do this after we print the message */ |
1988 | /* Do this after we print the message */ |
2010 | decrease_ob (key); /* Use up one of the keys */ |
1989 | decrease_ob (key); /* Use up one of the keys */ |
2011 | /* Need to update the weight the container the key was in */ |
1990 | /* Need to update the weight the container the key was in */ |
2012 | if (container != op) |
1991 | if (container != op) |
2013 | esrv_update_item (UPD_WEIGHT, op, container); |
1992 | esrv_update_item (UPD_WEIGHT, op, container); |
|
|
1993 | |
2014 | return 1; /* Nothing more to do below */ |
1994 | return 1; /* Nothing more to do below */ |
2015 | } |
1995 | } |
2016 | else if (door->type == LOCKED_DOOR) |
1996 | else if (door->type == LOCKED_DOOR) |
2017 | { |
1997 | { |
2018 | /* Might as well return now - no other way to open this */ |
1998 | /* Might as well return now - no other way to open this */ |
2019 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); |
1999 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); |
2020 | return 1; |
2000 | return 1; |
2021 | } |
2001 | } |
|
|
2002 | |
2022 | return 0; |
2003 | return 0; |
2023 | } |
2004 | } |
2024 | |
2005 | |
2025 | /* This function is just part of a breakup from move_player. |
2006 | /* This function is just part of a breakup from move_player. |
2026 | * It should keep the code cleaner. |
2007 | * It should keep the code cleaner. |
… | |
… | |
2232 | return 0; |
2213 | return 0; |
2233 | } |
2214 | } |
2234 | |
2215 | |
2235 | /* peterm: added following line */ |
2216 | /* peterm: added following line */ |
2236 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2217 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2237 | dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); |
2218 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2238 | |
2219 | |
2239 | op->facing = dir; |
2220 | op->facing = dir; |
2240 | |
2221 | |
2241 | if (op->hide) |
2222 | if (op->hide) |
2242 | do_hidden_move (op); |
2223 | do_hidden_move (op); |
… | |
… | |
2383 | * from. |
2364 | * from. |
2384 | */ |
2365 | */ |
2385 | void |
2366 | void |
2386 | remove_unpaid_objects (object *op, object *env) |
2367 | remove_unpaid_objects (object *op, object *env) |
2387 | { |
2368 | { |
2388 | object *next; |
|
|
2389 | |
|
|
2390 | while (op) |
2369 | while (op) |
2391 | { |
2370 | { |
2392 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2371 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2393 | |
2372 | |
2394 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2373 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
… | |
… | |
2724 | tmp->name = buf; |
2703 | tmp->name = buf; |
2725 | sprintf (buf, " This finger has been cut off %s\n" |
2704 | sprintf (buf, " This finger has been cut off %s\n" |
2726 | " the %s, when he was defeated at\n level %d by %s.\n", |
2705 | " the %s, when he was defeated at\n level %d by %s.\n", |
2727 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2706 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2728 | tmp->msg = buf; |
2707 | tmp->msg = buf; |
2729 | tmp->value = 0, tmp->material = 0, tmp->type = 0; |
2708 | tmp->value = 0, tmp->type = 0; |
2730 | tmp->materialname = NULL; |
2709 | tmp->materialname = "organics"; |
2731 | tmp->insert_at (op, tmp); |
2710 | tmp->insert_at (op, tmp); |
2732 | } |
2711 | } |
2733 | |
2712 | |
2734 | /* teleport defeated player to new destination */ |
2713 | /* teleport defeated player to new destination */ |
2735 | transfer_ob (op, x, y, 0, NULL); |
2714 | transfer_ob (op, x, y, 0, NULL); |
… | |
… | |
2987 | void |
2966 | void |
2988 | loot_object (object *op) |
2967 | loot_object (object *op) |
2989 | { /* Grab and destroy some treasure */ |
2968 | { /* Grab and destroy some treasure */ |
2990 | object *tmp, *tmp2, *next; |
2969 | object *tmp, *tmp2, *next; |
2991 | |
2970 | |
2992 | if (op->container) |
2971 | op->close_container (); /* close open sack first */ |
2993 | esrv_apply_container (op, op->container); /* close open sack first */ |
|
|
2994 | |
2972 | |
2995 | for (tmp = op->inv; tmp; tmp = next) |
2973 | for (tmp = op->inv; tmp; tmp = next) |
2996 | { |
2974 | { |
2997 | next = tmp->below; |
2975 | next = tmp->below; |
2998 | |
2976 | |
2999 | if (tmp->invisible) |
2977 | if (tmp->invisible) |
3000 | continue; |
2978 | continue; |
3001 | |
2979 | |
3002 | tmp->remove (); |
2980 | tmp->remove (); |
3003 | tmp->x = op->x, tmp->y = op->y; |
2981 | tmp->x = op->x, tmp->y = op->y; |
|
|
2982 | |
3004 | if (tmp->type == CONTAINER) |
2983 | if (tmp->type == CONTAINER) |
3005 | { /* empty container to ground */ |
2984 | loot_object (tmp); /* empty container to ground */ |
3006 | loot_object (tmp); |
2985 | |
3007 | } |
|
|
3008 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
2986 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
3009 | { |
2987 | { |
3010 | if (tmp->nrof > 1) |
2988 | if (tmp->nrof > 1) |
3011 | { |
2989 | { |
3012 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2990 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3013 | tmp2->destroy (); |
2991 | tmp2->destroy (); |
… | |
… | |
3024 | /* |
3002 | /* |
3025 | * fix_weight(): Check recursively the weight of all players, and fix |
3003 | * fix_weight(): Check recursively the weight of all players, and fix |
3026 | * what needs to be fixed. Refresh windows and fix speed if anything |
3004 | * what needs to be fixed. Refresh windows and fix speed if anything |
3027 | * was changed. |
3005 | * was changed. |
3028 | */ |
3006 | */ |
3029 | |
|
|
3030 | void |
3007 | void |
3031 | fix_weight (void) |
3008 | fix_weight (void) |
3032 | { |
3009 | { |
3033 | for_all_players (pl) |
3010 | for_all_players (pl) |
3034 | { |
3011 | { |
… | |
… | |
3547 | * not readied. |
3524 | * not readied. |
3548 | */ |
3525 | */ |
3549 | void |
3526 | void |
3550 | player_unready_range_ob (player *pl, object *ob) |
3527 | player_unready_range_ob (player *pl, object *ob) |
3551 | { |
3528 | { |
3552 | rangetype i; |
|
|
3553 | |
|
|
3554 | for (i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1)) |
3529 | for (rangetype i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1)) |
3555 | { |
|
|
3556 | if (pl->ranges[i] == ob) |
3530 | if (pl->ranges[i] == ob) |
3557 | { |
3531 | { |
3558 | pl->ranges[i] = NULL; |
3532 | pl->ranges[i] = 0; |
3559 | if (pl->shoottype == i) |
3533 | if (pl->shoottype == i) |
3560 | { |
|
|
3561 | pl->shoottype = range_none; |
3534 | pl->shoottype = range_none; |
3562 | } |
|
|
3563 | } |
3535 | } |
3564 | } |
|
|
3565 | } |
3536 | } |
|
|
3537 | |
|
|
3538 | sint8 |
|
|
3539 | player::visibility_at (maptile *map, int x, int y) const |
|
|
3540 | { |
|
|
3541 | if (!ns) |
|
|
3542 | return 0; |
|
|
3543 | |
|
|
3544 | int dx, dy; |
|
|
3545 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
|
|
3546 | return 0; |
|
|
3547 | |
|
|
3548 | x += dx - ns->current_x + ns->mapx / 2; |
|
|
3549 | y += dy - ns->current_y + ns->mapy / 2; |
|
|
3550 | |
|
|
3551 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
|
|
3552 | return 0; |
|
|
3553 | |
|
|
3554 | return 100 - blocked_los [x][y]; |
|
|
3555 | } |