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.65 by root, Mon Sep 22 05:45:55 2008 UTC vs.
Revision 1.67 by root, Thu Sep 25 04:09:57 2008 UTC

84 * up the last_skills[] array in the player object. 84 * up the last_skills[] array in the player object.
85 * the last_skills[] is used to more quickly lookup skills - 85 * the last_skills[] is used to more quickly lookup skills -
86 * mostly used for sending exp. 86 * mostly used for sending exp.
87 */ 87 */
88void 88void
89link_player_skills (object *op) 89player::link_skills ()
90{ 90{
91 for (int i = 0; i < NUM_SKILLS; ++i)
92 last_skill_ob [i] = 0;
93
91 for (object *tmp = op->inv; tmp; tmp = tmp->below) 94 for (object *tmp = ob->inv; tmp; tmp = tmp->below)
92 if (tmp->type == SKILL) 95 if (tmp->type == SKILL)
93 { 96 {
94 /* This is really a warning, hence no else below */ 97 assert (IN_RANGE_EXC (tmp->subtype, 0, NUM_SKILLS));
95 if (op->contr->last_skill_ob[tmp->subtype] && op->contr->last_skill_ob[tmp->subtype] != tmp)
96 LOG (llevError, "Multiple skills with the same subtype? %s, %s\n",
97 &op->contr->last_skill_ob[tmp->subtype]->skill, &tmp->skill);
98 98
99 if (tmp->subtype >= NUM_SKILLS) 99 if (last_skill_ob [tmp->subtype] != tmp)
100 LOG (llevError, "Invalid subtype number %d (range 0-%d)\n", tmp->subtype, NUM_SKILLS);
101 else
102 { 100 {
101 /* This is really a warning, hence no else below */
102 if (last_skill_ob [tmp->subtype])
103 LOG (llevError, "Multiple skills with the same subtype? %s, %s\n",
104 &last_skill_ob [tmp->subtype]->skill, &tmp->skill);
105
103 op->contr->last_skill_ob[tmp->subtype] = tmp; 106 last_skill_ob [tmp->subtype] = tmp;
104 op->contr->ns->last_skill_exp[tmp->subtype] = -1; //TODO: this should go 107 if (ns)
108 ns->last_skill_exp [tmp->subtype] = -1;
105 } 109 }
106 } 110 }
107} 111}
108 112
109static object * 113static object *
149 * but not the skill itself, give it to them. 153 * but not the skill itself, give it to them.
150 */ 154 */
151 object *skill = find_skill (who, skill_tool->skill); 155 object *skill = find_skill (who, skill_tool->skill);
152 156
153 if (!skill) 157 if (!skill)
154 {
155 skill = give_skill_by_name (who, skill_tool->skill); 158 skill = give_skill_by_name (who, skill_tool->skill);
156 link_player_skills (who);
157 }
158 159
159 if (!skill_tool->flag [FLAG_APPLIED]) 160 if (!skill_tool->flag [FLAG_APPLIED])
160 if (apply_special (who, splay (skill_tool), AP_APPLY | AP_NO_READY)) 161 if (apply_special (who, splay (skill_tool), AP_APPLY | AP_NO_READY))
161 return 0; 162 return 0;
162 163
618 LOG (llevError, "skill scroll %s does not have valid skill name (%s).\n", &scroll->name, &scroll->skill); 619 LOG (llevError, "skill scroll %s does not have valid skill name (%s).\n", &scroll->name, &scroll->skill);
619 return 2; 620 return 2;
620 } 621 }
621 622
622 SET_FLAG (tmp, FLAG_CAN_USE_SKILL); 623 SET_FLAG (tmp, FLAG_CAN_USE_SKILL);
623 link_player_skills (pl); 624
624 return 1; 625 return 1;
625} 626}
626 627
627/* Gives a percentage clipped to 0% -> 100% of a/b. */ 628/* Gives a percentage clipped to 0% -> 100% of a/b. */
628/* Probably belongs in some global utils-type file? */ 629/* Probably belongs in some global utils-type file? */
654 * just dumped this as we found it, this would be a bit 655 * just dumped this as we found it, this would be a bit
655 * simpler. 656 * simpler.
656 */ 657 */
657//TODO: egad, do it in perl, do not suffer from the big buffer on stack, make it one single drawinfo. 658//TODO: egad, do it in perl, do not suffer from the big buffer on stack, make it one single drawinfo.
658void 659void
659show_skills (object *op, const char *search) 660show_skills (object *pl, const char *search)
660{ 661{
661 const char *cp; 662 const char *cp;
662 int i, num_skills_found = 0; 663 int i, num_skills_found = 0;
663 const char *const periods = ".............................."; // 30 664 const char *const periods = ".............................."; // 30
664 665
665 /* Need to have a pointer and use strdup for qsort to work properly */ 666 /* Need to have a pointer and use strdup for qsort to work properly */
666 char skills[NUM_SKILLS][128]; // d'oh 667 char skills[NUM_SKILLS][128]; // d'oh
668
669 object *op = pl->contr->ob;
667 670
668 for (object *tmp = op->inv; tmp; tmp = tmp->below) 671 for (object *tmp = op->inv; tmp; tmp = tmp->below)
669 { 672 {
670 if (tmp->type == SKILL) 673 if (tmp->type == SKILL)
671 { 674 {
716 719
717 msg << "Your equipped item power is " << (int)op->contr->item_power 720 msg << "Your equipped item power is " << (int)op->contr->item_power
718 << " out of " << int (op->level * settings.item_power_factor) 721 << " out of " << int (op->level * settings.item_power_factor)
719 << ".\n"; 722 << ".\n";
720 723
721 op->contr->infobox (MSG_CHANNEL ("skills"), msg); 724 pl->contr->infobox (MSG_CHANNEL ("skills"), msg);
722} 725}
723 726
724/* use_skill() - similar to invoke command, it executes the skill in the 727/* use_skill() - similar to invoke command, it executes the skill in the
725 * direction that the user is facing. Returns false if we are unable to 728 * direction that the user is facing. Returns false if we are unable to
726 * change to the requested skill, or were unable to use the skill properly. 729 * change to the requested skill, or were unable to use the skill properly.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines