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.61 by root, Tue May 6 16:32:34 2008 UTC vs.
Revision 1.63 by root, Wed May 7 23:25:58 2008 UTC

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
311 case SK_HIDING: 311 case SK_HIDING:
312 exp = success = hide (op, skill); 312 exp = success = hide (op, skill);
313 break; 313 break;
314 314
315 case SK_JUMPING: 315 case SK_JUMPING:
316 success = jump (op, dir, skill); 316 exp = success = jump (op, dir, skill);
317 break; 317 break;
318 318
319 case SK_INSCRIPTION: 319 case SK_INSCRIPTION:
320 exp = success = write_on_item (op, string, skill); 320 exp = success = write_on_item (op, string, skill);
321 break; 321 break;
452 * Monsters have no skill use time because of the random nature in 452 * Monsters have no skill use time because of the random nature in
453 * which use_monster_skill is called already simulates this. 453 * which use_monster_skill is called already simulates this.
454 * If certain skills should take more/less time, that should be 454 * If certain skills should take more/less time, that should be
455 * in the code for the skill itself. 455 * in the code for the skill itself.
456 */ 456 */
457
458 if (op->type == PLAYER) 457 if (op->type == PLAYER)
459 op->speed_left -= 1.f; 458 op->speed_left -= 1.f;
460 459
461 /* this is a good place to add experience for successfull use of skills. 460 /* this is a good place to add experience for successfull use of skills.
462 * Note that add_exp() will figure out player/monster experience 461 * Note that add_exp() will figure out player/monster experience
817 * the caller should have set it appropriately). We still want to pass 816 * the caller should have set it appropriately). We still want to pass
818 * through that code if skill is set to change to the skill. 817 * through that code if skill is set to change to the skill.
819 */ 818 */
820 if (player *pl = op->contr) 819 if (player *pl = op->contr)
821 { 820 {
822 if (!pl->combat_ob) 821 if (skill)
822 op->change_skill (skill);
823 else
823 { 824 {
824 if (QUERY_FLAG (op, FLAG_READY_WEAPON))
825 {
826 for (tmp = op->inv; tmp; tmp = tmp->below)
827 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_APPLIED))
828 break;
829
830 if (!tmp)
831 LOG (llevError, "Could not find applied weapon on %s\n", &op->name);
832
833 pl->combat_ob = tmp;
834 }
835
836 if (!pl->combat_ob) 825 if (!pl->combat_ob)
837 { 826 {
827 if (QUERY_FLAG (op, FLAG_READY_WEAPON))
828 {
829 for (tmp = op->inv; tmp; tmp = tmp->below)
830 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_APPLIED))
831 break;
832
838 if (!skill) 833 if (!tmp)
834 LOG (llevError, "Could not find applied weapon on %s\n", &op->name);
835
836 pl->combat_ob = tmp;
837 }
838
839 if (!pl->combat_ob)
839 { 840 {
840 /* See if the players chosen skill is a combat skill, and use 841 /* See if the players chosen skill is a combat skill, and use
841 * it if appropriate. 842 * it if appropriate.
842 */ 843 */
843 if (op->chosen_skill && hth_skill_p (op->chosen_skill)) 844 if (op->chosen_skill && hth_skill_p (op->chosen_skill))
847 skill = find_player_hth_skill (op); 848 skill = find_player_hth_skill (op);
848 849
849 if (!skill) 850 if (!skill)
850 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); 851 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!");
851 } 852 }
853
854 if (skill)
855 {
856 op->change_skill (0);
857 apply_special (op, skill, AP_APPLY);
858 }
852 } 859 }
853 860
854 if (skill) 861 if (!pl->combat_ob)
855 { 862 {
856 op->change_skill (0); 863 LOG (llevError, "Could not find anything to attack on %s\n", &op->name);
857 apply_special (op, skill, AP_APPLY); 864 return 0;
858 } 865 }
859 } 866 }
860 867
861 if (!pl->combat_ob) 868 if (!op->change_weapon (pl->combat_ob))
862 {
863 LOG (llevError, "Could not find anything to attack on %s\n", &op->name);
864 return 0; 869 return 0;
865 }
866 } 870 }
867
868 if (!op->change_weapon (pl->combat_ob))
869 return 0;
870 871
871 /* lose invisiblity/hiding status for running attacks */ 872 /* lose invisiblity/hiding status for running attacks */
872 if (pl->tmp_invis) 873 if (pl->tmp_invis)
873 { 874 {
874 pl->tmp_invis = 0; 875 pl->tmp_invis = 0;
893 return success; 894 return success;
894} 895}
895 896
896/* skill_attack() - Core routine for use when we attack using a skills 897/* skill_attack() - Core routine for use when we attack using a skills
897 * system. In essence, this code handles 898 * system. In essence, this code handles
898 * all skill-based attacks, ie hth, missile and melee weapons should be 899 * all skill-based attacks, i.e. hth, missile and melee weapons should be
899 * treated here. If an opponent is already supplied by move_player(), 900 * treated here. If an opponent is already supplied by move_player(),
900 * we move right onto do_skill_attack(), otherwise we find if an 901 * we move right onto do_skill_attack(), otherwise we find if an
901 * appropriate opponent exists. 902 * appropriate opponent exists.
902 * 903 *
903 * This is called by move_player() and attack_hth() 904 * This is called by move_player() and attack_hth()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines