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

Comparing deliantra/server/server/skills.C (file contents):
Revision 1.11 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.21 by pippijn, Sat Jan 6 14:42:31 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2003 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2003 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 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
159 * already -b.t. 160 * already -b.t.
160 */ 161 */
161 162
162 if (QUERY_FLAG (tmp, FLAG_WAS_WIZ) || QUERY_FLAG (tmp, FLAG_APPLIED) 163 if (QUERY_FLAG (tmp, FLAG_WAS_WIZ) || QUERY_FLAG (tmp, FLAG_APPLIED)
163 || !(tmp->type) 164 || !(tmp->type)
164 || tmp->type == EXPERIENCE || tmp->type == SPELL 165 || tmp->type == SPELL
165 || QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_STEAL) || tmp->invisible) 166 || QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_STEAL) || tmp->invisible)
166 continue; 167 continue;
167 168
168 /* Okay, try stealing this item. Dependent on dexterity of thief, 169 /* Okay, try stealing this item. Dependent on dexterity of thief,
169 * skill level, see the adj_stealroll fctn for more detail. 170 * skill level, see the adj_stealroll fctn for more detail.
292 /* If player can't move onto the space, can't steal from it. */ 293 /* If player can't move onto the space, can't steal from it. */
293 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) 294 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)))
294 return 0; 295 return 0;
295 296
296 /* Find the topmost object at this spot */ 297 /* Find the topmost object at this spot */
297 for (tmp = get_map_ob (m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above); 298 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above);
298 299
299 /* For all the stacked objects at this point, attempt a steal */ 300 /* For all the stacked objects at this point, attempt a steal */
300 for (; tmp != NULL; tmp = next) 301 for (; tmp != NULL; tmp = next)
301 { 302 {
302 next = tmp->below; 303 next = tmp->below;
318 return 0; 319 return 0;
319 320
320 /* no xp for stealing from pets (of players) */ 321 /* no xp for stealing from pets (of players) */
321 if (QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->attack_movement == PETMOVE) 322 if (QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->attack_movement == PETMOVE)
322 { 323 {
323 object *owner = get_owner (tmp); 324 object *owner = tmp->owner;
324 325
325 if (owner != NULL && owner->type == PLAYER) 326 if (owner != NULL && owner->type == PLAYER)
326 return 0; 327 return 0;
327 } 328 }
328 329
383 { 384 {
384 new_draw_info (NDI_UNIQUE, 0, pl, "There is no lock there."); 385 new_draw_info (NDI_UNIQUE, 0, pl, "There is no lock there.");
385 return 0; 386 return 0;
386 } 387 }
387 388
388 for (tmp = get_map_ob (pl->map, x, y); tmp; tmp = tmp->above) 389 for (tmp = GET_MAP_OB (pl->map, x, y); tmp; tmp = tmp->above)
389 if (tmp->type == DOOR || tmp->type == LOCKED_DOOR) 390 if (tmp->type == DOOR || tmp->type == LOCKED_DOOR)
390 break; 391 break;
391 392
392 if (!tmp) 393 if (!tmp)
393 { 394 {
494 * of jumping. 495 * of jumping.
495 */ 496 */
496static void 497static void
497stop_jump (object *pl, int dist, int spaces) 498stop_jump (object *pl, int dist, int spaces)
498{ 499{
499 fix_player (pl); 500 pl->update_stats ();
500 insert_ob_in_map (pl, pl->map, pl, 0); 501 pl->map->insert (pl, pl->x, pl->y, pl);
501} 502}
502
503 503
504static int 504static int
505attempt_jump (object *pl, int dir, int spaces, object *skill) 505attempt_jump (object *pl, int dir, int spaces, object *skill)
506{ 506{
507 object *tmp; 507 object *tmp;
514 * temporarily to allow player to aviod exits/archs that are not 514 * temporarily to allow player to aviod exits/archs that are not
515 * fly_on, fly_off. This will also prevent pickup of objects 515 * fly_on, fly_off. This will also prevent pickup of objects
516 * while jumping over them. 516 * while jumping over them.
517 */ 517 */
518 518
519 remove_ob (pl); 519 pl->remove ();
520 520
521 /* 521 /*
522 * I don't think this is actually needed - all the movement 522 * I don't think this is actually needed - all the movement
523 * code is handled in this function, and I don't see anyplace 523 * code is handled in this function, and I don't see anyplace
524 * that cares about the move_type being flying. 524 * that cares about the move_type being flying.
543 new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is blocked."); 543 new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is blocked.");
544 stop_jump (pl, i, spaces); 544 stop_jump (pl, i, spaces);
545 return 0; 545 return 0;
546 } 546 }
547 547
548 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 548 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
549 { 549 {
550 /* Jump into creature */ 550 /* Jump into creature */
551 if (QUERY_FLAG (tmp, FLAG_MONSTER) || (tmp->type == PLAYER && (!QUERY_FLAG (tmp, FLAG_WIZ) || !tmp->contr->hidden))) 551 if (QUERY_FLAG (tmp, FLAG_MONSTER) || (tmp->type == PLAYER && (!QUERY_FLAG (tmp, FLAG_WIZ) || !tmp->contr->hidden)))
552 { 552 {
553 new_draw_info_format (NDI_UNIQUE, 0, pl, "You jump into %s%s.", tmp->type == PLAYER ? "" : "the ", &tmp->name); 553 new_draw_info_format (NDI_UNIQUE, 0, pl, "You jump into %s%s.", tmp->type == PLAYER ? "" : "the ", &tmp->name);
638 esrv_update_item (UPD_FLAGS, pl, tmp); 638 esrv_update_item (UPD_FLAGS, pl, tmp);
639 success += calc_skill_exp (pl, tmp, skill); 639 success += calc_skill_exp (pl, tmp, skill);
640 } 640 }
641 641
642 /* Check ground, too, but only objects the player could pick up */ 642 /* Check ground, too, but only objects the player could pick up */
643 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp; tmp = tmp->above) 643 for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp; tmp = tmp->above)
644 if (can_pick (pl, tmp) && 644 if (can_pick (pl, tmp) &&
645 !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && 645 !QUERY_FLAG (tmp, FLAG_IDENTIFIED) &&
646 !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) 646 !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)
647 && (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) && tmp->item_power < skill->level) 647 && (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) && tmp->item_power < skill->level)
648 { 648 {
669 esrv_update_item (UPD_FLAGS, pl, tmp); 669 esrv_update_item (UPD_FLAGS, pl, tmp);
670 success += calc_skill_exp (pl, tmp, skill); 670 success += calc_skill_exp (pl, tmp, skill);
671 } 671 }
672 672
673 /* Check ground, too, but like above, only if the object can be picked up */ 673 /* Check ground, too, but like above, only if the object can be picked up */
674 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp; tmp = tmp->above) 674 for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp; tmp = tmp->above)
675 if (can_pick (pl, tmp) && 675 if (can_pick (pl, tmp) &&
676 !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && (is_magical (tmp)) && tmp->item_power < skill->level) 676 !QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && (is_magical (tmp)) && tmp->item_power < skill->level)
677 { 677 {
678 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 678 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL);
679 esrv_update_item (UPD_FLAGS, pl, tmp); 679 esrv_update_item (UPD_FLAGS, pl, tmp);
734 734
735 for (tmp = pl->inv; tmp; tmp = tmp->below) 735 for (tmp = pl->inv; tmp; tmp = tmp->below)
736 success += do_skill_ident2 (tmp, pl, obj_class, skill); 736 success += do_skill_ident2 (tmp, pl, obj_class, skill);
737 /* check the ground */ 737 /* check the ground */
738 738
739 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp; tmp = tmp->above) 739 for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp; tmp = tmp->above)
740 success += do_skill_ident2 (tmp, pl, obj_class, skill); 740 success += do_skill_ident2 (tmp, pl, obj_class, skill);
741 741
742 return success; 742 return success;
743} 743}
744 744
838 { 838 {
839 new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to orate to."); 839 new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to orate to.");
840 return 0; 840 return 0;
841 } 841 }
842 842
843 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 843 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
844 { 844 {
845 /* can't persuade players - return because there is nothing else 845 /* can't persuade players - return because there is nothing else
846 * on that space to charm. Same for multi space monsters and 846 * on that space to charm. Same for multi space monsters and
847 * special monsters - we don't allow them to be charmed, and there 847 * special monsters - we don't allow them to be charmed, and there
848 * is no reason to do further processing since they should be the 848 * is no reason to do further processing since they should be the
877 } 877 }
878 878
879 /* it's already allied! */ 879 /* it's already allied! */
880 if (QUERY_FLAG (tmp, FLAG_FRIENDLY) && (tmp->attack_movement == PETMOVE)) 880 if (QUERY_FLAG (tmp, FLAG_FRIENDLY) && (tmp->attack_movement == PETMOVE))
881 { 881 {
882 if (get_owner (tmp) == pl) 882 if (tmp->owner == pl)
883 { 883 {
884 new_draw_info (NDI_UNIQUE, 0, pl, "Your follower loves your speech.\n"); 884 new_draw_info (NDI_UNIQUE, 0, pl, "Your follower loves your speech.\n");
885 return 0; 885 return 0;
886 } 886 }
887 else if (skill->level > tmp->level) 887 else if (skill->level > tmp->level)
888 { 888 {
889 /* you steal the follower. Perhaps we should really look at the 889 /* you steal the follower. Perhaps we should really look at the
890 * level of the owner above? 890 * level of the owner above?
891 */ 891 */
892 set_owner (tmp, pl); 892 tmp->set_owner (pl);
893 new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to follow you instead!\n", query_name (tmp)); 893 new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to follow you instead!\n", query_name (tmp));
894 /* Abuse fix - don't give exp since this can otherwise 894 /* Abuse fix - don't give exp since this can otherwise
895 * be used by a couple players to gets lots of exp. 895 * be used by a couple players to gets lots of exp.
896 */ 896 */
897 return 0; 897 return 0;
908 /* Ok, got a 'sucker' lets try to make them a follower */ 908 /* Ok, got a 'sucker' lets try to make them a follower */
909 if (chance > 0 && tmp->level < (random_roll (0, chance - 1, pl, PREFER_HIGH) - 1)) 909 if (chance > 0 && tmp->level < (random_roll (0, chance - 1, pl, PREFER_HIGH) - 1))
910 { 910 {
911 new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to become your follower.\n", query_name (tmp)); 911 new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to become your follower.\n", query_name (tmp));
912 912
913 set_owner (tmp, pl); 913 tmp->set_owner (pl);
914 tmp->stats.exp = 0; 914 tmp->stats.exp = 0;
915 add_friendly_object (tmp); 915 add_friendly_object (tmp);
916 SET_FLAG (tmp, FLAG_FRIENDLY); 916 SET_FLAG (tmp, FLAG_FRIENDLY);
917 tmp->attack_movement = PETMOVE; 917 tmp->attack_movement = PETMOVE;
918 return calc_skill_exp (pl, tmp, skill); 918 return calc_skill_exp (pl, tmp, skill);
964 if (mflags & P_OUT_OF_MAP) 964 if (mflags & P_OUT_OF_MAP)
965 continue; 965 continue;
966 if (!(mflags & P_IS_ALIVE)) 966 if (!(mflags & P_IS_ALIVE))
967 continue; 967 continue;
968 968
969 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 969 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
970 { 970 {
971 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 971 if (QUERY_FLAG (tmp, FLAG_MONSTER))
972 break; 972 break;
973 /* can't affect players */ 973 /* can't affect players */
974 if (tmp->type == PLAYER) 974 if (tmp->type == PLAYER)
1034 mflags = get_map_flags (m, &m, x, y, &x, &y); 1034 mflags = get_map_flags (m, &m, x, y, &x, &y);
1035 if (mflags & P_OUT_OF_MAP) 1035 if (mflags & P_OUT_OF_MAP)
1036 continue; 1036 continue;
1037 1037
1038 /* Check everything in the square for trapness */ 1038 /* Check everything in the square for trapness */
1039 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 1039 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
1040 { 1040 {
1041 1041
1042 /* And now we'd better do an inventory traversal of each 1042 /* And now we'd better do an inventory traversal of each
1043 * of these objects' inventory 1043 * of these objects' inventory
1044 * We can narrow this down a bit - no reason to search through 1044 * We can narrow this down a bit - no reason to search through
1097 mflags = get_map_flags (m, &m, x, y, &x, &y); 1097 mflags = get_map_flags (m, &m, x, y, &x, &y);
1098 if (mflags & P_OUT_OF_MAP) 1098 if (mflags & P_OUT_OF_MAP)
1099 continue; 1099 continue;
1100 1100
1101 /* Check everything in the square for trapness */ 1101 /* Check everything in the square for trapness */
1102 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 1102 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
1103 { 1103 {
1104 /* And now we'd better do an inventory traversal of each 1104 /* And now we'd better do an inventory traversal of each
1105 * of these objects inventory. Like above, only 1105 * of these objects inventory. Like above, only
1106 * do this for interesting objects. 1106 * do this for interesting objects.
1107 */ 1107 */
1272 1272
1273 strcat (buf, msg); 1273 strcat (buf, msg);
1274 strcat (buf, "\n"); /* new msg needs a LF */ 1274 strcat (buf, "\n"); /* new msg needs a LF */
1275 if (item->nrof > 1) 1275 if (item->nrof > 1)
1276 { 1276 {
1277 newBook = get_object (); 1277 newBook = item->clone ();
1278 copy_object (item, newBook);
1279 decrease_ob (item); 1278 decrease_ob (item);
1280 esrv_send_item (pl, item); 1279 esrv_send_item (pl, item);
1281 newBook->nrof = 1; 1280 newBook->nrof = 1;
1282 newBook->msg = buf; 1281 newBook->msg = buf;
1283 newBook = insert_ob_in_ob (newBook, pl); 1282 newBook = insert_ob_in_ob (newBook, pl);
1358 1357
1359 if (random_roll (0, chosen_spell->level * 4 - 1, pl, PREFER_LOW) < skill->level) 1358 if (random_roll (0, chosen_spell->level * 4 - 1, pl, PREFER_LOW) < skill->level)
1360 { 1359 {
1361 if (scroll->nrof > 1) 1360 if (scroll->nrof > 1)
1362 { 1361 {
1363 newscroll = get_object (); 1362 newscroll = scroll->clone ();
1364 copy_object (scroll, newscroll);
1365 decrease_ob (scroll); 1363 decrease_ob (scroll);
1366 newscroll->nrof = 1; 1364 newscroll->nrof = 1;
1367 } 1365 }
1368 else 1366 else
1369 { 1367 {
1384 newscroll->level = MAX (skill->level, chosen_spell->level); 1382 newscroll->level = MAX (skill->level, chosen_spell->level);
1385 new_draw_info (NDI_UNIQUE, 0, pl, "In your confused state, you write down some odd spell."); 1383 new_draw_info (NDI_UNIQUE, 0, pl, "In your confused state, you write down some odd spell.");
1386 } 1384 }
1387 1385
1388 if (newscroll->inv) 1386 if (newscroll->inv)
1389 { 1387 newscroll->inv->destroy ();
1390 object *ninv;
1391 1388
1392 ninv = newscroll->inv; 1389 tmp = chosen_spell->clone ();
1393 remove_ob (ninv);
1394 free_object (ninv);
1395 }
1396 tmp = get_object ();
1397 copy_object (chosen_spell, tmp);
1398 insert_ob_in_ob (tmp, newscroll); 1390 insert_ob_in_ob (tmp, newscroll);
1399 1391
1400 /* Same code as from treasure.c - so they can better merge. 1392 /* Same code as from treasure.c - so they can better merge.
1401 * if players want to sell them, so be it. 1393 * if players want to sell them, so be it.
1402 */ 1394 */
1405 1397
1406 /* wait until finished manipulating the scroll before inserting it */ 1398 /* wait until finished manipulating the scroll before inserting it */
1407 if (newscroll == scroll) 1399 if (newscroll == scroll)
1408 { 1400 {
1409 /* Remove to correctly merge with other items which may exist in inventory */ 1401 /* Remove to correctly merge with other items which may exist in inventory */
1410 remove_ob (newscroll); 1402 newscroll->remove ();
1411 esrv_del_item (pl->contr, newscroll->count); 1403 esrv_del_item (pl->contr, newscroll->count);
1412 } 1404 }
1413 newscroll = insert_ob_in_ob (newscroll, pl); 1405 newscroll = insert_ob_in_ob (newscroll, pl);
1414 esrv_send_item (pl, newscroll); 1406 esrv_send_item (pl, newscroll);
1415 success = calc_skill_exp (pl, newscroll, skill); 1407 success = calc_skill_exp (pl, newscroll, skill);
1424 1416
1425 if (chosen_spell->level > skill->level || confused) 1417 if (chosen_spell->level > skill->level || confused)
1426 { /*backfire! */ 1418 { /*backfire! */
1427 new_draw_info (NDI_UNIQUE, 0, pl, "Ouch! Your attempt to write a new scroll strains your mind!"); 1419 new_draw_info (NDI_UNIQUE, 0, pl, "Ouch! Your attempt to write a new scroll strains your mind!");
1428 if (random_roll (0, 1, pl, PREFER_LOW) == 1) 1420 if (random_roll (0, 1, pl, PREFER_LOW) == 1)
1429 drain_specific_stat (pl, 4); 1421 pl->drain_specific_stat (4);
1430 else 1422 else
1431 { 1423 {
1432 confuse_player (pl, pl, 99); 1424 confuse_player (pl, pl, 99);
1433 return (-30 * chosen_spell->level); 1425 return (-30 * chosen_spell->level);
1434 } 1426 }
1439 confuse_player (pl, pl, 99); 1431 confuse_player (pl, pl, 99);
1440 } 1432 }
1441 else 1433 else
1442 new_draw_info (NDI_UNIQUE, 0, pl, "You fail to write a new scroll."); 1434 new_draw_info (NDI_UNIQUE, 0, pl, "You fail to write a new scroll.");
1443 } 1435 }
1436
1444 return 0; 1437 return 0;
1445} 1438}
1446 1439
1447/* write_on_item() - wrapper for write_note and write_scroll */ 1440/* write_on_item() - wrapper for write_note and write_scroll */
1448int 1441int
1598 */ 1591 */
1599 1592
1600static object * 1593static object *
1601make_throw_ob (object *orig) 1594make_throw_ob (object *orig)
1602{ 1595{
1603 object *toss_item;
1604
1605 if (!orig) 1596 if (!orig)
1606 return NULL; 1597 return NULL;
1607 1598
1608 toss_item = get_object ();
1609 if (QUERY_FLAG (orig, FLAG_APPLIED)) 1599 if (QUERY_FLAG (orig, FLAG_APPLIED))
1610 { 1600 {
1611 LOG (llevError, "BUG: make_throw_ob(): ob is applied\n"); 1601 LOG (llevError, "BUG: make_throw_ob(): ob is applied\n");
1612 /* insufficient workaround, but better than nothing */ 1602 /* insufficient workaround, but better than nothing */
1613 CLEAR_FLAG (orig, FLAG_APPLIED); 1603 CLEAR_FLAG (orig, FLAG_APPLIED);
1614 } 1604 }
1615 copy_object (orig, toss_item); 1605
1606 object *toss_item = orig->clone ();
1607
1616 toss_item->type = THROWN_OBJ; 1608 toss_item->type = THROWN_OBJ;
1617 CLEAR_FLAG (toss_item, FLAG_CHANGING); 1609 CLEAR_FLAG (toss_item, FLAG_CHANGING);
1618 toss_item->stats.dam = 0; /* default damage */ 1610 toss_item->stats.dam = 0; /* default damage */
1619 insert_ob_in_ob (orig, toss_item); 1611 insert_ob_in_ob (orig, toss_item);
1620 return toss_item; 1612 return toss_item;
1698 */ 1690 */
1699 mflags = get_map_flags (part->map, &m, part->x + freearr_x[dir], part->y + freearr_y[dir], &sx, &sy); 1691 mflags = get_map_flags (part->map, &m, part->x + freearr_x[dir], part->y + freearr_y[dir], &sx, &sy);
1700 1692
1701 if (!dir || (eff_str <= 1) || (mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, sx, sy) & MOVE_FLY_LOW)) 1693 if (!dir || (eff_str <= 1) || (mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, sx, sy) & MOVE_FLY_LOW))
1702 { 1694 {
1703
1704 /* bounces off 'wall', and drops to feet */ 1695 /* bounces off 'wall', and drops to feet */
1705 remove_ob (throw_ob); 1696 throw_ob->insert_at (part, op);
1706 throw_ob->x = part->x; 1697
1707 throw_ob->y = part->y;
1708 insert_ob_in_map (throw_ob, part->map, op, 0);
1709 if (op->type == PLAYER) 1698 if (op->type == PLAYER)
1710 { 1699 {
1711 if (eff_str <= 1) 1700 if (eff_str <= 1)
1712 {
1713 new_draw_info_format (NDI_UNIQUE, 0, op, "Your load is so heavy you drop %s to the ground.", query_name (throw_ob)); 1701 new_draw_info_format (NDI_UNIQUE, 0, op, "Your load is so heavy you drop %s to the ground.", query_name (throw_ob));
1714 }
1715 else if (!dir) 1702 else if (!dir)
1716 {
1717 new_draw_info_format (NDI_UNIQUE, 0, op, "You throw %s at the ground.", query_name (throw_ob)); 1703 new_draw_info_format (NDI_UNIQUE, 0, op, "You throw %s at the ground.", query_name (throw_ob));
1718 }
1719 else 1704 else
1720 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 1705 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
1721 } 1706 }
1707
1722 return 0; 1708 return 0;
1723 } /* if object can't be thrown */ 1709 } /* if object can't be thrown */
1724 1710
1725 left = throw_ob; /* these are throwing objects left to the player */ 1711 left = throw_ob; /* these are throwing objects left to the player */
1726 1712
1729 */ 1715 */
1730 1716
1731 if ((throw_ob = get_split_ob (throw_ob, 1)) == NULL) 1717 if ((throw_ob = get_split_ob (throw_ob, 1)) == NULL)
1732 { 1718 {
1733 throw_ob = left; 1719 throw_ob = left;
1734 remove_ob (left); 1720 left->remove ();
1735 if (op->type == PLAYER) 1721 if (op->type == PLAYER)
1736 esrv_del_item (op->contr, left->count); 1722 esrv_del_item (op->contr, left->count);
1737 } 1723 }
1738 else if (op->type == PLAYER) 1724 else if (op->type == PLAYER)
1739 { 1725 {
1763 { 1749 {
1764 insert_ob_in_ob (throw_ob, op); 1750 insert_ob_in_ob (throw_ob, op);
1765 return 0; 1751 return 0;
1766 } 1752 }
1767 1753
1768 set_owner (throw_ob, op); 1754 throw_ob->set_owner (op);
1769 /* At some point in the attack code, the actual real object (op->inv) 1755 /* At some point in the attack code, the actual real object (op->inv)
1770 * becomes the hitter. As such, we need to make sure that has a proper 1756 * becomes the hitter. As such, we need to make sure that has a proper
1771 * owner value so exp goes to the right place. 1757 * owner value so exp goes to the right place.
1772 */ 1758 */
1773 set_owner (throw_ob->inv, op); 1759 throw_ob->inv->set_owner (op);
1774 throw_ob->direction = dir; 1760 throw_ob->direction = dir;
1775 throw_ob->x = part->x;
1776 throw_ob->y = part->y;
1777 1761
1778 /* the damage bonus from the force of the throw */ 1762 /* the damage bonus from the force of the throw */
1779 dam = (int) (str_factor * dam_bonus[eff_str]); 1763 dam = (int) (str_factor * dam_bonus[eff_str]);
1780 1764
1781 /* Now, lets adjust the properties of the thrown_ob. */ 1765 /* Now, lets adjust the properties of the thrown_ob. */
1782 1766
1783 /* how far to fly */ 1767 /* how far to fly */
1784 throw_ob->last_sp = (eff_str * 3) / 5; 1768 throw_ob->last_sp = (eff_str * 3) / 5;
1785 1769
1786 /* speed */ 1770 /* speed */
1787 throw_ob->speed = (speed_bonus[eff_str] + 1.0) / 1.5; 1771 throw_ob->set_speed (min (1.0, speed_bonus[eff_str] + 1.0) / 1.5); /* no faster than an arrow! */
1788 throw_ob->speed = MIN (1.0, throw_ob->speed); /* no faster than an arrow! */
1789 1772
1790 /* item damage. Eff_str and item weight influence damage done */ 1773 /* item damage. Eff_str and item weight influence damage done */
1791 weight_f = (throw_ob->weight / 2000) > MAX_STAT ? MAX_STAT : (throw_ob->weight / 2000); 1774 weight_f = (throw_ob->weight / 2000) > MAX_STAT ? MAX_STAT : (throw_ob->weight / 2000);
1792 throw_ob->stats.dam += (dam / 3) + dam_bonus[weight_f] + (throw_ob->weight / 15000) - 2; 1775 throw_ob->stats.dam += (dam / 3) + dam_bonus[weight_f] + (throw_ob->weight / 15000) - 2;
1793 1776
1794 /* chance of breaking. Proportional to force used and weight of item */ 1777 /* chance of breaking. Proportional to force used and weight of item */
1795 throw_ob->stats.food = (dam / 2) + (throw_ob->weight / 60000); 1778 throw_ob->stats.food = (dam / 2) + (throw_ob->weight / 60000);
1796 1779
1797 /* replace 25 with a call to clone.arch wc? messes up w/ NPC */ 1780 /* replace 25 with a call to clone.arch wc? messes up w/ NPC */
1798 throw_ob->stats.wc = 25 - dex_bonus[op->stats.Dex] - thaco_bonus[eff_str] - skill->level; 1781 throw_ob->stats.wc = 25 - dex_bonus[op->stats.Dex] - thaco_bonus[eff_str] - skill->level;
1799
1800 1782
1801 /* the properties of objects which are meant to be thrown (ie dart, 1783 /* the properties of objects which are meant to be thrown (ie dart,
1802 * throwing knife, etc) will differ from ordinary items. Lets tailor 1784 * throwing knife, etc) will differ from ordinary items. Lets tailor
1803 * this stuff in here. 1785 * this stuff in here.
1804 */ 1786 */
1818 if (throw_ob->material & M_LEATHER) 1800 if (throw_ob->material & M_LEATHER)
1819 { 1801 {
1820 throw_ob->stats.dam -= 1; 1802 throw_ob->stats.dam -= 1;
1821 throw_ob->stats.food -= 10; 1803 throw_ob->stats.food -= 10;
1822 } 1804 }
1805
1823 if (throw_ob->material & M_GLASS) 1806 if (throw_ob->material & M_GLASS)
1824 throw_ob->stats.food += 60; 1807 throw_ob->stats.food += 60;
1825 1808
1826 if (throw_ob->material & M_ORGANIC) 1809 if (throw_ob->material & M_ORGANIC)
1827 { 1810 {
1828 throw_ob->stats.dam -= 3; 1811 throw_ob->stats.dam -= 3;
1829 throw_ob->stats.food += 55; 1812 throw_ob->stats.food += 55;
1830 } 1813 }
1814
1831 if (throw_ob->material & M_PAPER || throw_ob->material & M_CLOTH) 1815 if (throw_ob->material & M_PAPER || throw_ob->material & M_CLOTH)
1832 { 1816 {
1833 throw_ob->stats.dam -= 5; 1817 throw_ob->stats.dam -= 5;
1834 throw_ob->speed *= 0.8; 1818 throw_ob->speed *= 0.8;
1835 throw_ob->stats.wc += 3; 1819 throw_ob->stats.wc += 3;
1836 throw_ob->stats.food -= 30; 1820 throw_ob->stats.food -= 30;
1837 } 1821 }
1822
1838 /* light obj have more wind resistance, fly slower */ 1823 /* light obj have more wind resistance, fly slower */
1839 if (throw_ob->weight > 500) 1824 if (throw_ob->weight > 500)
1840 throw_ob->speed *= 0.8; 1825 throw_ob->speed *= 0.8;
1826
1841 if (throw_ob->weight > 50) 1827 if (throw_ob->weight > 50)
1842 throw_ob->speed *= 0.5; 1828 throw_ob->speed *= 0.5;
1843
1844 } /* else tailor thrown object */ 1829 } /* else tailor thrown object */
1845 1830
1846 /* some limits, and safeties (needed?) */ 1831 /* some limits, and safeties (needed?) */
1847 if (throw_ob->stats.dam < 0) 1832 if (throw_ob->stats.dam < 0)
1848 throw_ob->stats.dam = 0; 1833 throw_ob->stats.dam = 0;
1868 * In short summary, a throw can take anywhere between speed 5 and 1853 * In short summary, a throw can take anywhere between speed 5 and
1869 * speed 0.5 1854 * speed 0.5
1870 */ 1855 */
1871 op->speed_left -= 50 / pause_f; 1856 op->speed_left -= 50 / pause_f;
1872 1857
1873 update_ob_speed (throw_ob);
1874 throw_ob->speed_left = 0; 1858 throw_ob->speed_left = 0;
1875 throw_ob->map = part->map; 1859 throw_ob->map = part->map;
1876 1860
1877 throw_ob->move_type = MOVE_FLY_LOW; 1861 throw_ob->move_type = MOVE_FLY_LOW;
1878 throw_ob->move_on = MOVE_FLY_LOW | MOVE_WALK; 1862 throw_ob->move_on = MOVE_FLY_LOW | MOVE_WALK;
1888 LOG (llevDebug, " pause_f=%d \n", pause_f); 1872 LOG (llevDebug, " pause_f=%d \n", pause_f);
1889 LOG (llevDebug, " %s stats: wc=%d dam=%d dist=%d spd=%f break=%d\n", 1873 LOG (llevDebug, " %s stats: wc=%d dam=%d dist=%d spd=%f break=%d\n",
1890 throw_ob->name, throw_ob->stats.wc, throw_ob->stats.dam, throw_ob->last_sp, throw_ob->speed, throw_ob->stats.food); 1874 throw_ob->name, throw_ob->stats.wc, throw_ob->stats.dam, throw_ob->last_sp, throw_ob->speed, throw_ob->stats.food);
1891 LOG (llevDebug, "inserting tossitem (%d) into map\n", throw_ob->count); 1875 LOG (llevDebug, "inserting tossitem (%d) into map\n", throw_ob->count);
1892#endif 1876#endif
1893 insert_ob_in_map (throw_ob, part->map, op, 0); 1877
1878 throw_ob->insert_at (part, op);
1894 1879
1895 if (!throw_ob->destroyed ()) 1880 if (!throw_ob->destroyed ())
1896 move_arrow (throw_ob); 1881 move_arrow (throw_ob);
1897 1882
1898 return 1; 1883 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines