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.54 by root, Mon May 28 21:28:36 2007 UTC vs.
Revision 1.58 by root, Sun Jul 1 05:00:20 2007 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT 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 * Crossfire TRT is free software; you can redistribute it and/or modify it 8 * Crossfire TRT is free software: you can redistribute it and/or modify
9 * under the terms of the GNU General Public License as published by the Free 9 * it under the terms of the GNU General Public License as published by
10 * Software Foundation; either version 2 of the License, or (at your option) 10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, but 13 * This program is distributed in the hope that it will be useful,
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License along 18 * You should have received a copy of the GNU General Public License
19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 20 *
22 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 22 */
24 23
25/* Created July 95 to separate skill utilities from actual skills -b.t. */ 24/* Created July 95 to separate skill utilities from actual skills -b.t. */
61 * subtypes. 60 * subtypes.
62 */ 61 */
63void 62void
64init_skills (void) 63init_skills (void)
65{ 64{
66 for (archetype *at = first_archetype; at; at = at->next) 65 for_all_archetypes (at)
67 if (at->clone.type == SKILL) 66 if (at->type == SKILL)
68 { 67 {
69 if (skill_names[at->clone.subtype]) 68 if (skill_names[at->subtype])
70 LOG (llevError, "init_skills: multiple skill using same subtype %d, %s, %s\n", 69 LOG (llevError, "init_skills: multiple skill using same subtype %d, %s, %s\n",
71 at->clone.subtype, &skill_names[at->clone.subtype], &at->clone.skill); 70 at->subtype, &skill_names[at->subtype], &at->skill);
72 else 71 else
73 skill_names[at->clone.subtype] = at->clone.skill; 72 skill_names[at->subtype] = at->skill;
74 } 73 }
75 74
76 /* This isn't really an error if there is no skill subtype set, but 75 /* This isn't really an error if there is no skill subtype set, but
77 * checking for this may catch some user errors. 76 * checking for this may catch some user errors.
78 */ 77 */
548 /* if skill really is a skill, then we can look at the skill archetype for 547 /* if skill really is a skill, then we can look at the skill archetype for
549 * bse reward value (exp) and level multiplier factor. 548 * bse reward value (exp) and level multiplier factor.
550 */ 549 */
551 if (skill->type == SKILL) 550 if (skill->type == SKILL)
552 { 551 {
553 base += skill->arch->clone.stats.exp; 552 base += skill->arch->stats.exp;
554 if (settings.simple_exp) 553 if (settings.simple_exp)
555 { 554 {
556 if (skill->arch->clone.level) 555 if (skill->arch->level)
557 lvl_mult = (float) skill->arch->clone.level / 100.0; 556 lvl_mult = (float) skill->arch->level / 100.0;
558 else 557 else
559 lvl_mult = 1.0; /* no adjustment */ 558 lvl_mult = 1.0; /* no adjustment */
560 } 559 }
561 else 560 else
562 { 561 {
563 if (skill->level) 562 if (skill->level)
564 lvl_mult = ((float) skill->arch->clone.level * (float) op_lvl) / ((float) skill->level * 100.0); 563 lvl_mult = ((float) skill->arch->level * (float) op_lvl) / ((float) skill->level * 100.0);
565 else 564 else
566 lvl_mult = 1.0; 565 lvl_mult = 1.0;
567 } 566 }
568 } 567 }
569 else 568 else
657 * Note this function is a bit more complicated becauase we 656 * Note this function is a bit more complicated becauase we
658 * we want ot sort the skills before printing them. If we 657 * we want ot sort the skills before printing them. If we
659 * just dumped this as we found it, this would be a bit 658 * just dumped this as we found it, this would be a bit
660 * simpler. 659 * simpler.
661 */ 660 */
662 661//TODO: egad, do it in perl, do not suffer from the big buffer on stack, make it one single drawinfo.
663void 662void
664show_skills (object *op, const char *search) 663show_skills (object *op, const char *search)
665{ 664{
666 object *tmp = NULL; 665 object *tmp = NULL;
667 char buf[MAX_BUF]; 666 char buf[MAX_BUF];
669 int i, num_skills_found = 0; 668 int i, num_skills_found = 0;
670 static const char *const periods = "........................................"; 669 static const char *const periods = "........................................";
671 670
672 /* Need to have a pointer and use strdup for qsort to work properly */ 671 /* Need to have a pointer and use strdup for qsort to work properly */
673 char skills[NUM_SKILLS][MAX_BUF]; 672 char skills[NUM_SKILLS][MAX_BUF];
674
675 673
676 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 674 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
677 { 675 {
678 if (tmp->type == SKILL) 676 if (tmp->type == SKILL)
679 { 677 {
682 /* Basically want to fill this out to 40 spaces with periods */ 680 /* Basically want to fill this out to 40 spaces with periods */
683 sprintf (buf, "%s%s", &tmp->name, periods); 681 sprintf (buf, "%s%s", &tmp->name, periods);
684 buf[40] = 0; 682 buf[40] = 0;
685 683
686 if (settings.permanent_exp_ratio) 684 if (settings.permanent_exp_ratio)
687 {
688 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)", 685 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 "/%d%%)",
689 buf, tmp->level, tmp->stats.exp, 686 buf, tmp->level, tmp->stats.exp,
690 level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp)); 687 level_exp (tmp->level + 1, op->expmul), clipped_percent (tmp->perm_exp, tmp->stats.exp));
691 }
692 else 688 else
693 {
694 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")", 689 sprintf (skills[num_skills_found++], "%slvl:%3d (xp:%" PRId64 "/%" PRId64 ")",
695 buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul)); 690 buf, tmp->level, tmp->stats.exp, level_exp (tmp->level + 1, op->expmul));
696 } 691
697 /* I don't know why some characters get a bunch of skills, but 692 /* I don't know why some characters get a bunch of skills, but
698 * it sometimes happens (maybe a leftover from bugier earlier code 693 * it sometimes happens (maybe a leftover from bugier earlier code
699 * and those character are still about). In any case, lets handle 694 * and those character are still about). In any case, lets handle
700 * it so it doesn't crash the server - otherwise, one character may 695 * it so it doesn't crash the server - otherwise, one character may
701 * crash the server numerous times. 696 * crash the server numerous times.
707 break; 702 break;
708 } 703 }
709 } 704 }
710 } 705 }
711 706
712 clear_win_info (op);
713 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:"); 707 new_draw_info (NDI_UNIQUE, 0, op, "Player skills:");
714 if (num_skills_found > 1) 708 if (num_skills_found > 1)
715 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp); 709 qsort (skills, num_skills_found, MAX_BUF, (int (*)(const void *, const void *)) std::strcmp);
716 710
717 for (i = 0; i < num_skills_found; i++) 711 for (i = 0; i < num_skills_found; i++)
858 if (!skill) 852 if (!skill)
859 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!"); 853 new_draw_info (NDI_BLACK, 0, op, "You have no unarmed combat skills!");
860 } 854 }
861 } 855 }
862 856
857 if (skill)
858 {
863 op->change_skill (0); 859 op->change_skill (0);
864 apply_special (op, skill, AP_APPLY); 860 apply_special (op, skill, AP_APPLY);
861 }
865 } 862 }
866 863
867 if (!pl->combat_ob) 864 if (!pl->combat_ob)
868 { 865 {
869 LOG (llevError, "Could not find anything to attack on %s\n", &op->name); 866 LOG (llevError, "Could not find anything to attack on %s\n", &op->name);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines