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

Comparing deliantra/server/server/skill_util.C (file contents):
Revision 1.93 by root, Sat Apr 10 05:12:57 2010 UTC vs.
Revision 1.94 by root, Sun Apr 11 00:34:06 2010 UTC

257 /* Not 100% sure if this will work with new movement code - 257 /* Not 100% sure if this will work with new movement code -
258 * the levitation skill has move_type for flying, so when 258 * the levitation skill has move_type for flying, so when
259 * equipped, that should transfer to player, when not, 259 * equipped, that should transfer to player, when not,
260 * shouldn't. 260 * shouldn't.
261 */ 261 */
262 if (QUERY_FLAG (skill, FLAG_APPLIED)) 262 if (skill->flag [FLAG_APPLIED])
263 { 263 {
264 CLEAR_FLAG (skill, FLAG_APPLIED); 264 skill->clr_flag (FLAG_APPLIED);
265 new_draw_info (NDI_UNIQUE, 0, op, "You come to earth."); 265 new_draw_info (NDI_UNIQUE, 0, op, "You come to earth.");
266 } 266 }
267 else 267 else
268 { 268 {
269 SET_FLAG (skill, FLAG_APPLIED); 269 skill->set_flag (FLAG_APPLIED);
270 new_draw_info (NDI_UNIQUE, 0, op, "You rise into the air!"); 270 new_draw_info (NDI_UNIQUE, 0, op, "You rise into the air!");
271 } 271 }
272 272
273 op->update_stats (); 273 op->update_stats ();
274 success = 1; 274 success = 1;
364 364
365 for (object *next, *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = next) 365 for (object *next, *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = next)
366 { 366 {
367 next = tmp->above; 367 next = tmp->above;
368 368
369 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 369 if (tmp->flag [FLAG_IS_CAULDRON])
370 { 370 {
371 found_cauldron = true; 371 found_cauldron = true;
372 372
373 if (tmp->skill != skill->skill) 373 if (tmp->skill != skill->skill)
374 { 374 {
378 break; 378 break;
379 } 379 }
380 380
381 attempt_do_alchemy (op, tmp, skill); 381 attempt_do_alchemy (op, tmp, skill);
382 382
383 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 383 if (tmp->flag [FLAG_APPLIED])
384 esrv_send_inventory (op, tmp); 384 esrv_send_inventory (op, tmp);
385 } 385 }
386 } 386 }
387 387
388 if (!found_cauldron) 388 if (!found_cauldron)
517 } 517 }
518 else 518 else
519 { /* all other items/living creatures */ 519 { /* all other items/living creatures */
520 op_exp = op->stats.exp; 520 op_exp = op->stats.exp;
521 op_lvl = op->level; 521 op_lvl = op->level;
522 if (!QUERY_FLAG (op, FLAG_ALIVE)) 522 if (!op->flag [FLAG_ALIVE])
523 op_lvl += 5 * abs (op->magic); /* for ident/make items */ 523 op_lvl += 5 * abs (op->magic); /* for ident/make items */
524 } 524 }
525 525
526 if (op_lvl < 1) 526 if (op_lvl < 1)
527 op_lvl = 1; 527 op_lvl = 1;
591 } 591 }
592 592
593 object *tmp = find_skill (pl, scroll->skill); 593 object *tmp = find_skill (pl, scroll->skill);
594 594
595 /* player already knows it */ 595 /* player already knows it */
596 if (tmp && QUERY_FLAG (tmp, FLAG_CAN_USE_SKILL)) 596 if (tmp && tmp->flag [FLAG_CAN_USE_SKILL])
597 return 0; 597 return 0;
598 598
599 /* now a random change to learn, based on player Int. 599 /* now a random change to learn, based on player Int.
600 * give bonus based on level - otherwise stupid characters 600 * give bonus based on level - otherwise stupid characters
601 * might never be able to learn anything. 601 * might never be able to learn anything.
610 { 610 {
611 LOG (llevError, "skill scroll %s does not have valid skill name (%s).\n", &scroll->name, &scroll->skill); 611 LOG (llevError, "skill scroll %s does not have valid skill name (%s).\n", &scroll->name, &scroll->skill);
612 return 2; 612 return 2;
613 } 613 }
614 614
615 SET_FLAG (tmp, FLAG_CAN_USE_SKILL); 615 tmp->set_flag (FLAG_CAN_USE_SKILL);
616 616
617 return 1; 617 return 1;
618} 618}
619 619
620/* Gives a percentage clipped to 0% -> 100% of a/b. */ 620/* Gives a percentage clipped to 0% -> 100% of a/b. */
795 */ 795 */
796static object * 796static object *
797find_player_hth_skill (object *op) 797find_player_hth_skill (object *op)
798{ 798{
799 for (object *tmp = op->inv; tmp; tmp = tmp->below) 799 for (object *tmp = op->inv; tmp; tmp = tmp->below)
800 if (tmp->type == SKILL && QUERY_FLAG (tmp, FLAG_CAN_USE_SKILL) && hth_skill_p (tmp)) 800 if (tmp->type == SKILL && tmp->flag [FLAG_CAN_USE_SKILL] && hth_skill_p (tmp))
801 return tmp; 801 return tmp;
802 802
803 return 0; 803 return 0;
804} 804}
805 805
833 } 833 }
834 else 834 else
835 { 835 {
836 if (!pl->combat_ob) 836 if (!pl->combat_ob)
837 { 837 {
838 if (QUERY_FLAG (op, FLAG_READY_WEAPON)) 838 if (op->flag [FLAG_READY_WEAPON])
839 { 839 {
840 for (tmp = op->inv; tmp; tmp = tmp->below) 840 for (tmp = op->inv; tmp; tmp = tmp->below)
841 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_APPLIED)) 841 if (tmp->type == WEAPON && tmp->flag [FLAG_APPLIED])
842 break; 842 break;
843 843
844 if (!tmp) 844 if (!tmp)
845 LOG (llevError, "Could not find applied weapon on %s\n", &op->name); 845 LOG (llevError, "Could not find applied weapon on %s\n", &op->name);
846 846
888 888
889 int success = attack_ob (tmp, op); 889 int success = attack_ob (tmp, op);
890 890
891 /* print appropriate messages to the player */ 891 /* print appropriate messages to the player */
892 892
893 if (success && string && tmp && !QUERY_FLAG (tmp, FLAG_FREED)) 893 if (success && string && tmp && !tmp->flag [FLAG_FREED])
894 { 894 {
895 if (op->type == PLAYER) 895 if (op->type == PLAYER)
896 new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp)); 896 new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp));
897 else if (tmp->type == PLAYER) 897 else if (tmp->type == PLAYER)
898 new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string); 898 new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string);
941 /* space must be blocked for there to be anything interesting to do */ 941 /* space must be blocked for there to be anything interesting to do */
942 if (!OB_TYPE_MOVE_BLOCK (pl, GET_MAP_MOVE_BLOCK (m, tx, ty))) 942 if (!OB_TYPE_MOVE_BLOCK (pl, GET_MAP_MOVE_BLOCK (m, tx, ty)))
943 return 0; 943 return 0;
944 944
945 for (tmp = GET_MAP_OB (m, tx, ty); tmp; tmp = tmp->above) 945 for (tmp = GET_MAP_OB (m, tx, ty); tmp; tmp = tmp->above)
946 if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR) 946 if ((tmp->flag [FLAG_ALIVE] && tmp->stats.hp >= 0) || tmp->flag [FLAG_CAN_ROLL] || tmp->type == LOCKED_DOOR)
947 { 947 {
948 /* Don't attack party members */ 948 /* Don't attack party members */
949 if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party)) 949 if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party))
950 return 0; 950 return 0;
951 951
973static int 973static int
974attack_hth (object *pl, int dir, const char *string, object *skill) 974attack_hth (object *pl, int dir, const char *string, object *skill)
975{ 975{
976 object *enemy = NULL, *weapon; 976 object *enemy = NULL, *weapon;
977 977
978 if (QUERY_FLAG (pl, FLAG_READY_WEAPON)) 978 if (pl->flag [FLAG_READY_WEAPON])
979 for (weapon = pl->inv; weapon; weapon = weapon->below) 979 for (weapon = pl->inv; weapon; weapon = weapon->below)
980 { 980 {
981 if (weapon->type == WEAPON && QUERY_FLAG (weapon, FLAG_APPLIED)) 981 if (weapon->type == WEAPON && weapon->flag [FLAG_APPLIED])
982 { 982 {
983 CLEAR_FLAG (weapon, FLAG_APPLIED); 983 weapon->clr_flag (FLAG_APPLIED);
984 CLEAR_FLAG (pl, FLAG_READY_WEAPON); 984 pl->clr_flag (FLAG_READY_WEAPON);
985 pl->update_stats (); 985 pl->update_stats ();
986 if (pl->type == PLAYER) 986 if (pl->type == PLAYER)
987 { 987 {
988 new_draw_info (NDI_UNIQUE, 0, pl, "You unwield your weapon in order to attack."); 988 new_draw_info (NDI_UNIQUE, 0, pl, "You unwield your weapon in order to attack.");
989 esrv_update_item (UPD_FLAGS, pl, weapon); 989 esrv_update_item (UPD_FLAGS, pl, weapon);
1007 */ 1007 */
1008static int 1008static int
1009attack_melee_weapon (object *op, int dir, const char *string, object *skill) 1009attack_melee_weapon (object *op, int dir, const char *string, object *skill)
1010{ 1010{
1011 1011
1012 if (!QUERY_FLAG (op, FLAG_READY_WEAPON)) 1012 if (!op->flag [FLAG_READY_WEAPON])
1013 { 1013 {
1014 if (op->type == PLAYER) 1014 if (op->type == PLAYER)
1015 new_draw_info (NDI_UNIQUE, 0, op, "You have no ready weapon to attack with!"); 1015 new_draw_info (NDI_UNIQUE, 0, op, "You have no ready weapon to attack with!");
1016 1016
1017 return 0; 1017 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines