d2skills.c 1.34 KB
#include "d2skills.h"

#include <stdio.h>
#include <stdlib.h>

const char* getSkillName(D2S_SKILL skillID) {
    if(skillID > D2S_SKILL_NUMSKILLS || skillID < 0) {
        fprintf(stderr,"libd2char error: skillID %d doesn't exist\n",skillID);
        return NULL;
    }
    return skillNames[skillID];
}

D2S_SKILL getSkillIDFromCharOffset(D2S_CHARCLASS class, unsigned int offset) {
    if(offset < 0 || offset > D2S_SKILL_MAXSKILLS_PER_CHAR) {
        fprintf(stderr,"libd2char error: Invalid character skill offset: %d\n",offset);
        return D2S_SKILL_UNKNOWN;
    }
    switch(class) {
        case D2S_CHARCLASS_AMAZON:
            return amazonSkills[offset];
        break;
        case D2S_CHARCLASS_SORCERESS:
            return sorceressSkills[offset];
        break;
        case D2S_CHARCLASS_NECROMANCER:
            return necromancerSkills[offset];
        break;
        case D2S_CHARCLASS_PALADIN:
            return paladinSkills[offset];
        break;
        case D2S_CHARCLASS_BARBARIAN:
            return barbarianSkills[offset];
        break;
        case D2S_CHARCLASS_DRUID:
            return druidSkills[offset];
        break;
        case D2S_CHARCLASS_ASSASSIN:
            return assassinSkills[offset];
        break;
        case D2S_CHARCLASS_UNKNOWN:
        default:
            return D2S_SKILL_UNKNOWN;
        break;
    }
}