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.16 by root, Wed Dec 20 09:14:22 2006 UTC

292 /* If player can't move onto the space, can't steal from it. */ 292 /* 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))) 293 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)))
294 return 0; 294 return 0;
295 295
296 /* Find the topmost object at this spot */ 296 /* Find the topmost object at this spot */
297 for (tmp = get_map_ob (m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above); 297 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above);
298 298
299 /* For all the stacked objects at this point, attempt a steal */ 299 /* For all the stacked objects at this point, attempt a steal */
300 for (; tmp != NULL; tmp = next) 300 for (; tmp != NULL; tmp = next)
301 { 301 {
302 next = tmp->below; 302 next = tmp->below;
318 return 0; 318 return 0;
319 319
320 /* no xp for stealing from pets (of players) */ 320 /* no xp for stealing from pets (of players) */
321 if (QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->attack_movement == PETMOVE) 321 if (QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->attack_movement == PETMOVE)
322 { 322 {
323 object *owner = get_owner (tmp); 323 object *owner = tmp->owner;
324 324
325 if (owner != NULL && owner->type == PLAYER) 325 if (owner != NULL && owner->type == PLAYER)
326 return 0; 326 return 0;
327 } 327 }
328 328
383 { 383 {
384 new_draw_info (NDI_UNIQUE, 0, pl, "There is no lock there."); 384 new_draw_info (NDI_UNIQUE, 0, pl, "There is no lock there.");
385 return 0; 385 return 0;
386 } 386 }
387 387
388 for (tmp = get_map_ob (pl->map, x, y); tmp; tmp = tmp->above) 388 for (tmp = GET_MAP_OB (pl->map, x, y); tmp; tmp = tmp->above)
389 if (tmp->type == DOOR || tmp->type == LOCKED_DOOR) 389 if (tmp->type == DOOR || tmp->type == LOCKED_DOOR)
390 break; 390 break;
391 391
392 if (!tmp) 392 if (!tmp)
393 { 393 {
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);
1598 */ 1590 */
1599 1591
1600static object * 1592static object *
1601make_throw_ob (object *orig) 1593make_throw_ob (object *orig)
1602{ 1594{
1603 object *toss_item;
1604
1605 if (!orig) 1595 if (!orig)
1606 return NULL; 1596 return NULL;
1607 1597
1608 toss_item = get_object ();
1609 if (QUERY_FLAG (orig, FLAG_APPLIED)) 1598 if (QUERY_FLAG (orig, FLAG_APPLIED))
1610 { 1599 {
1611 LOG (llevError, "BUG: make_throw_ob(): ob is applied\n"); 1600 LOG (llevError, "BUG: make_throw_ob(): ob is applied\n");
1612 /* insufficient workaround, but better than nothing */ 1601 /* insufficient workaround, but better than nothing */
1613 CLEAR_FLAG (orig, FLAG_APPLIED); 1602 CLEAR_FLAG (orig, FLAG_APPLIED);
1614 } 1603 }
1615 copy_object (orig, toss_item); 1604
1605 object *toss_item = orig->clone ();
1606
1616 toss_item->type = THROWN_OBJ; 1607 toss_item->type = THROWN_OBJ;
1617 CLEAR_FLAG (toss_item, FLAG_CHANGING); 1608 CLEAR_FLAG (toss_item, FLAG_CHANGING);
1618 toss_item->stats.dam = 0; /* default damage */ 1609 toss_item->stats.dam = 0; /* default damage */
1619 insert_ob_in_ob (orig, toss_item); 1610 insert_ob_in_ob (orig, toss_item);
1620 return toss_item; 1611 return toss_item;
1700 1691
1701 if (!dir || (eff_str <= 1) || (mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, sx, sy) & MOVE_FLY_LOW)) 1692 if (!dir || (eff_str <= 1) || (mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, sx, sy) & MOVE_FLY_LOW))
1702 { 1693 {
1703 1694
1704 /* bounces off 'wall', and drops to feet */ 1695 /* bounces off 'wall', and drops to feet */
1705 remove_ob (throw_ob); 1696 throw_ob->remove ();
1706 throw_ob->x = part->x; 1697 throw_ob->x = part->x;
1707 throw_ob->y = part->y; 1698 throw_ob->y = part->y;
1708 insert_ob_in_map (throw_ob, part->map, op, 0); 1699 insert_ob_in_map (throw_ob, part->map, op, 0);
1709 if (op->type == PLAYER) 1700 if (op->type == PLAYER)
1710 { 1701 {
1729 */ 1720 */
1730 1721
1731 if ((throw_ob = get_split_ob (throw_ob, 1)) == NULL) 1722 if ((throw_ob = get_split_ob (throw_ob, 1)) == NULL)
1732 { 1723 {
1733 throw_ob = left; 1724 throw_ob = left;
1734 remove_ob (left); 1725 left->remove ();
1735 if (op->type == PLAYER) 1726 if (op->type == PLAYER)
1736 esrv_del_item (op->contr, left->count); 1727 esrv_del_item (op->contr, left->count);
1737 } 1728 }
1738 else if (op->type == PLAYER) 1729 else if (op->type == PLAYER)
1739 { 1730 {
1763 { 1754 {
1764 insert_ob_in_ob (throw_ob, op); 1755 insert_ob_in_ob (throw_ob, op);
1765 return 0; 1756 return 0;
1766 } 1757 }
1767 1758
1768 set_owner (throw_ob, op); 1759 throw_ob->set_owner (op);
1769 /* At some point in the attack code, the actual real object (op->inv) 1760 /* 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 1761 * becomes the hitter. As such, we need to make sure that has a proper
1771 * owner value so exp goes to the right place. 1762 * owner value so exp goes to the right place.
1772 */ 1763 */
1773 set_owner (throw_ob->inv, op); 1764 throw_ob->inv->set_owner (op);
1774 throw_ob->direction = dir; 1765 throw_ob->direction = dir;
1775 throw_ob->x = part->x; 1766 throw_ob->x = part->x;
1776 throw_ob->y = part->y; 1767 throw_ob->y = part->y;
1777 1768
1778 /* the damage bonus from the force of the throw */ 1769 /* the damage bonus from the force of the throw */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines