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); |
… | |
… | |
291 | player::set_object (object *op) |
291 | player::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 | |
328 | void |
329 | void |
329 | player::set_observe (object *op) |
330 | player::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 | */ |
405 | archetype * |
406 | archetype * |
406 | get_player_archetype (archetype *at) |
407 | get_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 | |
635 | void |
642 | void |
636 | give_initial_items (object *pl, treasurelist * items) |
643 | give_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); |
… | |
… | |
832 | static void |
837 | static void |
833 | start_info (object *op) |
838 | start_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 | */ |
849 | void |
852 | void |
850 | player::chargen_race_done () |
853 | player::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 | |
… | |
… | |
1357 | * found object is returned. |
1360 | * found object is returned. |
1358 | */ |
1361 | */ |
1359 | object * |
1362 | object * |
1360 | find_arrow (object *op, const char *type) |
1363 | find_arrow (object *op, const char *type) |
1361 | { |
1364 | { |
1362 | object *tmp = 0; |
|
|
1363 | |
|
|
1364 | for (op = op->inv; op; op = op->below) |
1365 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1365 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
|
|
1366 | tmp = find_arrow (splay (op), type); |
|
|
1367 | else if (op->type == ARROW && op->race == type) |
1366 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1368 | return splay (op); |
1367 | return splay (tmp); |
1369 | |
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 | |
1370 | return tmp; |
1377 | return 0; |
1371 | } |
1378 | } |
1372 | |
1379 | |
1373 | /* |
1380 | /* |
1374 | * 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 |
1375 | * 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 |
… | |
… | |
1398 | } |
1405 | } |
1399 | } |
1406 | } |
1400 | else if (arrow->type == ARROW && arrow->race == type) |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1401 | { |
1408 | { |
1402 | /* allways prefer assasination/slaying */ |
1409 | /* allways prefer assasination/slaying */ |
1403 | if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) |
1410 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1404 | { |
1411 | { |
1405 | if (arrow->attacktype & AT_DEATH) |
1412 | if (arrow->attacktype & AT_DEATH) |
1406 | { |
1413 | { |
1407 | *better = 100; |
1414 | *better = 100; |
1408 | return arrow; |
1415 | return arrow; |
… | |
… | |
1596 | arrow->destroy (); |
1603 | arrow->destroy (); |
1597 | return 0; |
1604 | return 0; |
1598 | } |
1605 | } |
1599 | |
1606 | |
1600 | left = arrow; /* these are arrows left to the player */ |
1607 | left = arrow; /* these are arrows left to the player */ |
1601 | arrow = get_split_ob (arrow, 1); |
1608 | arrow = arrow->split (); |
1602 | if (!arrow) |
1609 | if (!arrow) |
1603 | { |
1610 | { |
1604 | 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); |
1605 | return 0; |
1612 | return 0; |
1606 | } |
1613 | } |
… | |
… | |
1673 | op->play_sound (sound_find ("fire_arrow")); |
1680 | op->play_sound (sound_find ("fire_arrow")); |
1674 | m->insert (arrow, sx, sy, op); |
1681 | m->insert (arrow, sx, sy, op); |
1675 | |
1682 | |
1676 | if (!arrow->destroyed ()) |
1683 | if (!arrow->destroyed ()) |
1677 | move_arrow (arrow); |
1684 | move_arrow (arrow); |
1678 | |
|
|
1679 | if (op->type == PLAYER) |
|
|
1680 | { |
|
|
1681 | if (left->destroyed ()) |
|
|
1682 | esrv_del_item (op->contr, left->count); |
|
|
1683 | else |
|
|
1684 | esrv_send_item (op, left); |
|
|
1685 | } |
|
|
1686 | |
1685 | |
1687 | return 1; |
1686 | return 1; |
1688 | } |
1687 | } |
1689 | |
1688 | |
1690 | /* Special fire code for players - this takes into |
1689 | /* Special fire code for players - this takes into |
… | |
… | |
1764 | return; |
1763 | return; |
1765 | } |
1764 | } |
1766 | } |
1765 | } |
1767 | else if (item->type == ROD || item->type == HORN) |
1766 | else if (item->type == ROD || item->type == HORN) |
1768 | { |
1767 | { |
1769 | 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)) |
1770 | { |
1773 | { |
1771 | op->contr->play_sound (sound_find ("wand_poof")); |
1774 | op->contr->play_sound (sound_find ("wand_poof")); |
1772 | |
1775 | |
1773 | if (item->type == ROD) |
1776 | if (item->type == ROD) |
1774 | 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)); |
… | |
… | |
1793 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1796 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1794 | item->face = item->arch->face; |
1797 | item->face = item->arch->face; |
1795 | item->set_speed (0); |
1798 | item->set_speed (0); |
1796 | } |
1799 | } |
1797 | |
1800 | |
1798 | if ((tmp = item->in_player ())) |
1801 | if (object *pl = item->visible_to ()) |
1799 | esrv_update_item (UPD_ANIM, tmp, item); |
1802 | esrv_update_item (UPD_ANIM, pl, item); |
1800 | } |
1803 | } |
1801 | } |
1804 | } |
1802 | else if (item->type == ROD || item->type == HORN) |
1805 | else if (item->type == ROD || item->type == HORN) |
1803 | drain_rod_charge (item); |
1806 | drain_rod_charge (item); |
1804 | } |
1807 | } |
… | |
… | |
1980 | 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); |
1981 | remove_door2 (door); /* remove door without violence ;-) */ |
1984 | remove_door2 (door); /* remove door without violence ;-) */ |
1982 | } |
1985 | } |
1983 | |
1986 | |
1984 | /* Do this after we print the message */ |
1987 | /* Do this after we print the message */ |
1985 | decrease_ob (key); /* Use up one of the keys */ |
1988 | key->decrease (); /* Use up one of the keys */ |
1986 | /* Need to update the weight the container the key was in */ |
|
|
1987 | if (container != op) |
|
|
1988 | esrv_update_item (UPD_WEIGHT, op, container); |
|
|
1989 | |
1989 | |
1990 | return 1; /* Nothing more to do below */ |
1990 | return 1; /* Nothing more to do below */ |
1991 | } |
1991 | } |
1992 | else if (door->type == LOCKED_DOOR) |
1992 | else if (door->type == LOCKED_DOOR) |
1993 | { |
1993 | { |
… | |
… | |
2174 | bool |
2174 | bool |
2175 | move_player (object *op, int dir) |
2175 | move_player (object *op, int dir) |
2176 | { |
2176 | { |
2177 | int pick; |
2177 | int pick; |
2178 | |
2178 | |
2179 | if (!op->map || op->map->in_memory != MAP_IN_MEMORY) |
2179 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2180 | return 0; |
2180 | return 0; |
2181 | |
2181 | |
2182 | /* Sanity check: make sure dir is valid */ |
2182 | /* Sanity check: make sure dir is valid */ |
2183 | if ((dir < 0) || (dir >= 9)) |
2183 | if ((dir < 0) || (dir >= 9)) |
2184 | { |
2184 | { |
… | |
… | |
2272 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2272 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2273 | { |
2273 | { |
2274 | op->play_sound (sound_find ("ob_evaporate")); |
2274 | op->play_sound (sound_find ("ob_evaporate")); |
2275 | 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)); |
2276 | |
2276 | |
2277 | if (op->contr) |
|
|
2278 | esrv_del_item (op->contr, tmp->count); |
|
|
2279 | |
|
|
2280 | tmp->destroy (); |
2277 | tmp->destroy (); |
2281 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2278 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2282 | |
2279 | |
2283 | if (op->stats.hp < 0) |
2280 | if (op->stats.hp < 0) |
2284 | op->stats.hp = op->stats.maxhp; |
2281 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
2296 | return 0; |
2293 | return 0; |
2297 | } |
2294 | } |
2298 | |
2295 | |
2299 | /* 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 |
2300 | * 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 |
2301 | * 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 |
2302 | * from. |
2299 | * from. |
2303 | */ |
2300 | */ |
2304 | static void |
2301 | static void |
2305 | drop_unpaid_items (object *op, object *env) |
2302 | drop_unpaid_items (object *op, object *env) |
2306 | { |
2303 | { |
2307 | while (op) |
2304 | while (op) |
2308 | { |
2305 | { |
2309 | 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' */ |
2310 | |
2307 | |
2311 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2308 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2312 | { |
|
|
2313 | if (env->type == PLAYER) |
|
|
2314 | esrv_del_item (env->contr, op->count); |
|
|
2315 | |
|
|
2316 | op->insert_at (env); |
2309 | op->insert_at (env); |
2317 | } |
|
|
2318 | else if (op->inv) |
2310 | else if (op->inv) |
2319 | drop_unpaid_items (op->inv, env); |
2311 | drop_unpaid_items (op->inv, env); |
2320 | |
2312 | |
2321 | op = next; |
2313 | op = next; |
2322 | } |
2314 | } |
… | |
… | |
2334 | * Moved from apply.c to player.c - player.c is what |
2326 | * Moved from apply.c to player.c - player.c is what |
2335 | * actually uses this function. player.c may not be quite the |
2327 | * actually uses this function. player.c may not be quite the |
2336 | * best, a misc file for object actions is probably better, |
2328 | * best, a misc file for object actions is probably better, |
2337 | * but there isn't one in the server directory. |
2329 | * but there isn't one in the server directory. |
2338 | */ |
2330 | */ |
2339 | char * |
2331 | const char * |
2340 | gravestone_text (object *op) |
2332 | gravestone_text (object *op) |
2341 | { |
2333 | { |
2342 | static char buf2[MAX_BUF]; |
2334 | static dynbuf_text buf; |
2343 | char buf[MAX_BUF]; |
|
|
2344 | time_t now = time (NULL); |
|
|
2345 | |
2335 | |
2346 | strcpy (buf2, " R.I.P.\n\n"); |
2336 | buf << "---- R.I.P. ----\n\n"; |
|
|
2337 | op->name; |
|
|
2338 | |
2347 | if (op->type == PLAYER) |
2339 | if (op->type == PLAYER) |
2348 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2340 | buf << " the " << op->contr->title; |
2349 | else |
|
|
2350 | sprintf (buf, "%s\n", &op->name); |
|
|
2351 | |
2341 | |
2352 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2342 | buf << "\n\n"; |
2353 | 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 | |
2354 | if (op->type == PLAYER) |
2348 | if (op->type == PLAYER) |
2355 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2349 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
2356 | else |
|
|
2357 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2358 | |
2350 | |
2359 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
|
|
2360 | strcat (buf2, buf); |
|
|
2361 | if (op->type == PLAYER) |
|
|
2362 | { |
2351 | { |
2363 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2352 | static char buf2[128]; |
2364 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2353 | time_t now = time (NULL); |
2365 | strcat (buf2, buf); |
|
|
2366 | } |
|
|
2367 | |
|
|
2368 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2354 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
2369 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2355 | buf << buf2; |
2370 | strcat (buf2, buf); |
2356 | } |
2371 | |
2357 | |
2372 | return buf2; |
2358 | return buf; |
2373 | } |
2359 | } |
2374 | |
2360 | |
2375 | void |
2361 | void |
2376 | do_some_living (object *op) |
2362 | do_some_living (object *op) |
2377 | { |
2363 | { |
… | |
… | |
2651 | { |
2637 | { |
2652 | tmp->name = format ("%s's finger" , &op->name); |
2638 | tmp->name = format ("%s's finger" , &op->name); |
2653 | tmp->name_pl = format ("%s's fingers", &op->name); |
2639 | tmp->name_pl = format ("%s's fingers", &op->name); |
2654 | tmp->msg = format ( |
2640 | tmp->msg = format ( |
2655 | "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", |
2656 | &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 () |
2657 | ); |
2645 | ); |
2658 | tmp->value = 0, tmp->type = 0; |
2646 | tmp->value = 0, tmp->type = 0; |
2659 | tmp->materialname = "organics"; |
2647 | tmp->materialname = "organics"; |
2660 | tmp->insert_at (op, tmp); |
2648 | tmp->insert_at (op, tmp); |
2661 | } |
2649 | } |
… | |
… | |
2669 | INVOKE_PLAYER (DEATH, op->contr); |
2657 | INVOKE_PLAYER (DEATH, op->contr); |
2670 | |
2658 | |
2671 | command_kill_pets (op, 0); |
2659 | command_kill_pets (op, 0); |
2672 | |
2660 | |
2673 | if (op->stats.food < 0) |
2661 | if (op->stats.food < 0) |
2674 | strcpy (op->contr->killer, "starvation"); |
2662 | { |
|
|
2663 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2664 | op->contr->killer->destroy (); |
|
|
2665 | } |
2675 | |
2666 | |
2676 | op->contr->play_sound (sound_find ("player_dies")); |
2667 | op->contr->play_sound (sound_find ("player_dies")); |
2677 | |
2668 | |
2678 | /* save the map location for corpse, gravestone */ |
2669 | /* save the map location for corpse, gravestone */ |
2679 | x = op->x; |
2670 | x = op->x; |
… | |
… | |
2812 | tmp = arch_to_object (archetype::find ("gravestone")); |
2803 | tmp = arch_to_object (archetype::find ("gravestone")); |
2813 | sprintf (buf, "%s's gravestone", &op->name); |
2804 | sprintf (buf, "%s's gravestone", &op->name); |
2814 | tmp->name = buf; |
2805 | tmp->name = buf; |
2815 | sprintf (buf, "%s's gravestones", &op->name); |
2806 | sprintf (buf, "%s's gravestones", &op->name); |
2816 | tmp->name_pl = buf; |
2807 | tmp->name_pl = buf; |
2817 | 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 ()); |
2818 | tmp->msg = buf; |
2809 | tmp->msg = buf; |
2819 | tmp->x = op->x, tmp->y = op->y; |
2810 | tmp->x = op->x, tmp->y = op->y; |
2820 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2811 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2821 | |
2812 | |
2822 | /**************************************/ |
2813 | /**************************************/ |
… | |
… | |
2927 | |
2918 | |
2928 | 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)))) |
2929 | { |
2920 | { |
2930 | if (tmp->nrof > 1) |
2921 | if (tmp->nrof > 1) |
2931 | { |
2922 | { |
2932 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2923 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2933 | tmp2->destroy (); |
|
|
2934 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2924 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2935 | } |
2925 | } |
2936 | else |
2926 | else |
2937 | tmp->destroy (); |
2927 | tmp->destroy (); |
2938 | } |
2928 | } |
… | |
… | |
2949 | void |
2939 | void |
2950 | fix_weight (void) |
2940 | fix_weight (void) |
2951 | { |
2941 | { |
2952 | for_all_players (pl) |
2942 | for_all_players (pl) |
2953 | { |
2943 | { |
2954 | int old = pl->ob->carrying, sum = sum_weight (pl->ob); |
2944 | sint32 old = pl->ob->carrying; |
2955 | |
2945 | |
2956 | if (old == sum) |
2946 | pl->ob->update_weight (); |
2957 | continue; |
2947 | |
|
|
2948 | if (old != pl->ob->carrying) |
|
|
2949 | { |
2958 | pl->ob->update_stats (); |
2950 | pl->ob->update_stats (); |
2959 | 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 | } |
2960 | } |
2953 | } |
2961 | } |
2954 | } |
2962 | |
2955 | |
2963 | void |
2956 | void |
2964 | fix_luck (void) |
2957 | fix_luck (void) |
… | |
… | |
3050 | * as bad as carrying a light on a pitch dark map */ |
3043 | * as bad as carrying a light on a pitch dark map */ |
3051 | if (has_carried_lights (ob)) |
3044 | if (has_carried_lights (ob)) |
3052 | level = -(10 + (2 * ob->map->darkness)); |
3045 | level = -(10 + (2 * ob->map->darkness)); |
3053 | |
3046 | |
3054 | /* scan through all nearby squares for terrain to hide in */ |
3047 | /* scan through all nearby squares for terrain to hide in */ |
3055 | 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]) |
3056 | { |
3051 | { |
3057 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3052 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3058 | if (mflag & P_OUT_OF_MAP) |
3053 | if (mflag & P_OUT_OF_MAP) |
3059 | { |
|
|
3060 | continue; |
3054 | continue; |
3061 | } |
3055 | |
3062 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3056 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3063 | level += 2; |
3057 | level += 2; |
3064 | else /* open terrain! */ |
3058 | else /* open terrain! */ |
3065 | level -= 1; |
3059 | level -= 1; |
3066 | } |
3060 | } |
… | |
… | |
3453 | else |
3447 | else |
3454 | { |
3448 | { |
3455 | /* generate misc. treasure */ |
3449 | /* generate misc. treasure */ |
3456 | tmp = arch_to_object (tr->item); |
3450 | tmp = arch_to_object (tr->item); |
3457 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3451 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3458 | tmp = insert_ob_in_ob (tmp, who); |
3452 | who->insert (tmp); |
3459 | if (who->type == PLAYER) |
|
|
3460 | esrv_send_item (who, tmp); |
|
|
3461 | } |
3453 | } |
3462 | } |
3454 | } |
3463 | |
3455 | |
3464 | /** |
3456 | /** |
3465 | * Unready an object for a player. This function does nothing if the object was |
3457 | * Unready an object for a player. This function does nothing if the object was |