… | |
… | |
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 | |
… | |
… | |
1405 | } |
1405 | } |
1406 | } |
1406 | } |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1408 | { |
1408 | { |
1409 | /* allways prefer assasination/slaying */ |
1409 | /* allways prefer assasination/slaying */ |
1410 | if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) |
1410 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1411 | { |
1411 | { |
1412 | if (arrow->attacktype & AT_DEATH) |
1412 | if (arrow->attacktype & AT_DEATH) |
1413 | { |
1413 | { |
1414 | *better = 100; |
1414 | *better = 100; |
1415 | return arrow; |
1415 | return arrow; |
… | |
… | |
1763 | return; |
1763 | return; |
1764 | } |
1764 | } |
1765 | } |
1765 | } |
1766 | else if (item->type == ROD || item->type == HORN) |
1766 | else if (item->type == ROD || item->type == HORN) |
1767 | { |
1767 | { |
1768 | 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)) |
1769 | { |
1773 | { |
1770 | op->contr->play_sound (sound_find ("wand_poof")); |
1774 | op->contr->play_sound (sound_find ("wand_poof")); |
1771 | |
1775 | |
1772 | if (item->type == ROD) |
1776 | if (item->type == ROD) |
1773 | 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)); |
… | |
… | |
2322 | * Moved from apply.c to player.c - player.c is what |
2326 | * Moved from apply.c to player.c - player.c is what |
2323 | * actually uses this function. player.c may not be quite the |
2327 | * actually uses this function. player.c may not be quite the |
2324 | * best, a misc file for object actions is probably better, |
2328 | * best, a misc file for object actions is probably better, |
2325 | * but there isn't one in the server directory. |
2329 | * but there isn't one in the server directory. |
2326 | */ |
2330 | */ |
2327 | char * |
2331 | const char * |
2328 | gravestone_text (object *op) |
2332 | gravestone_text (object *op) |
2329 | { |
2333 | { |
2330 | static char buf2[MAX_BUF]; |
2334 | static dynbuf_text buf; |
2331 | char buf[MAX_BUF]; |
|
|
2332 | time_t now = time (NULL); |
|
|
2333 | |
2335 | |
2334 | strcpy (buf2, " R.I.P.\n\n"); |
2336 | buf << "---- R.I.P. ----\n\n"; |
|
|
2337 | op->name; |
|
|
2338 | |
2335 | if (op->type == PLAYER) |
2339 | if (op->type == PLAYER) |
2336 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2340 | buf << " the " << op->contr->title; |
2337 | else |
|
|
2338 | sprintf (buf, "%s\n", &op->name); |
|
|
2339 | |
2341 | |
2340 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2342 | buf << "\n\n"; |
2341 | 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 | |
2342 | if (op->type == PLAYER) |
2348 | if (op->type == PLAYER) |
2343 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2349 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
2344 | else |
|
|
2345 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2346 | |
2350 | |
2347 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
|
|
2348 | strcat (buf2, buf); |
|
|
2349 | if (op->type == PLAYER) |
|
|
2350 | { |
2351 | { |
2351 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2352 | static char buf2[128]; |
2352 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2353 | time_t now = time (NULL); |
2353 | strcat (buf2, buf); |
|
|
2354 | } |
|
|
2355 | |
|
|
2356 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2354 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
2357 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2355 | buf << buf2; |
2358 | strcat (buf2, buf); |
2356 | } |
2359 | |
2357 | |
2360 | return buf2; |
2358 | return buf; |
2361 | } |
2359 | } |
2362 | |
2360 | |
2363 | void |
2361 | void |
2364 | do_some_living (object *op) |
2362 | do_some_living (object *op) |
2365 | { |
2363 | { |
… | |
… | |
2639 | { |
2637 | { |
2640 | tmp->name = format ("%s's finger" , &op->name); |
2638 | tmp->name = format ("%s's finger" , &op->name); |
2641 | tmp->name_pl = format ("%s's fingers", &op->name); |
2639 | tmp->name_pl = format ("%s's fingers", &op->name); |
2642 | tmp->msg = format ( |
2640 | tmp->msg = format ( |
2643 | "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", |
2644 | &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 () |
2645 | ); |
2645 | ); |
2646 | tmp->value = 0, tmp->type = 0; |
2646 | tmp->value = 0, tmp->type = 0; |
2647 | tmp->materialname = "organics"; |
2647 | tmp->materialname = "organics"; |
2648 | tmp->insert_at (op, tmp); |
2648 | tmp->insert_at (op, tmp); |
2649 | } |
2649 | } |
… | |
… | |
2657 | INVOKE_PLAYER (DEATH, op->contr); |
2657 | INVOKE_PLAYER (DEATH, op->contr); |
2658 | |
2658 | |
2659 | command_kill_pets (op, 0); |
2659 | command_kill_pets (op, 0); |
2660 | |
2660 | |
2661 | if (op->stats.food < 0) |
2661 | if (op->stats.food < 0) |
2662 | strcpy (op->contr->killer, "starvation"); |
2662 | { |
|
|
2663 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2664 | op->contr->killer->destroy (); |
|
|
2665 | } |
2663 | |
2666 | |
2664 | op->contr->play_sound (sound_find ("player_dies")); |
2667 | op->contr->play_sound (sound_find ("player_dies")); |
2665 | |
2668 | |
2666 | /* save the map location for corpse, gravestone */ |
2669 | /* save the map location for corpse, gravestone */ |
2667 | x = op->x; |
2670 | x = op->x; |
… | |
… | |
2800 | tmp = arch_to_object (archetype::find ("gravestone")); |
2803 | tmp = arch_to_object (archetype::find ("gravestone")); |
2801 | sprintf (buf, "%s's gravestone", &op->name); |
2804 | sprintf (buf, "%s's gravestone", &op->name); |
2802 | tmp->name = buf; |
2805 | tmp->name = buf; |
2803 | sprintf (buf, "%s's gravestones", &op->name); |
2806 | sprintf (buf, "%s's gravestones", &op->name); |
2804 | tmp->name_pl = buf; |
2807 | tmp->name_pl = buf; |
2805 | 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 ()); |
2806 | tmp->msg = buf; |
2809 | tmp->msg = buf; |
2807 | tmp->x = op->x, tmp->y = op->y; |
2810 | tmp->x = op->x, tmp->y = op->y; |
2808 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2811 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2809 | |
2812 | |
2810 | /**************************************/ |
2813 | /**************************************/ |