diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/mmo.h | 2 | ||||
-rw-r--r-- | src/map/skill.c | 86 | ||||
-rw-r--r-- | src/map/skill.h | 6 |
3 files changed, 50 insertions, 44 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h index ec1b2948a..f6eca919c 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -218,7 +218,7 @@ #define MAX_FAME 1000000000 #define MAX_CART 100 #ifndef MAX_SKILL_DB -#define MAX_SKILL_DB 1510 ///< Maximum number of skills in the skill DB (compacted array size) +#define MAX_SKILL_DB 1314 ///< Maximum number of skills in the skill DB (compacted array size) #endif #ifndef MAX_SKILL_ID #define MAX_SKILL_ID 10015 // [Ind/Hercules] max used skill ID diff --git a/src/map/skill.c b/src/map/skill.c index 4579b2ea7..61db40723 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -67,20 +67,6 @@ #define SKILLUNITTIMER_INTERVAL 100 -// ranges reserved for mapping skill ids to skilldb offsets -#define HM_SKILLRANGEMIN 750 -#define HM_SKILLRANGEMAX (HM_SKILLRANGEMIN + MAX_HOMUNSKILL) -#define MC_SKILLRANGEMIN (HM_SKILLRANGEMAX + 1) -#define MC_SKILLRANGEMAX (MC_SKILLRANGEMIN + MAX_MERCSKILL) -#define EL_SKILLRANGEMIN (MC_SKILLRANGEMAX + 1) -#define EL_SKILLRANGEMAX (EL_SKILLRANGEMIN + MAX_ELEMENTALSKILL) -#define GD_SKILLRANGEMIN (EL_SKILLRANGEMAX + 1) -#define GD_SKILLRANGEMAX (GD_SKILLRANGEMIN + MAX_GUILDSKILL) - -#if GD_SKILLRANGEMAX > 999 - #error GD_SKILLRANGEMAX is greater than 999 -#endif - static struct skill_interface skill_s; static struct s_skill_dbs skilldbs; @@ -110,41 +96,55 @@ static int skill_name2id(const char *name) /// Returns the skill's array index, or 0 (Unknown Skill). static int skill_get_index(int skill_id) { - // avoid ranges reserved for mapping guild/homun/mercenary skills - if( (skill_id >= GD_SKILLRANGEMIN && skill_id <= GD_SKILLRANGEMAX) - || (skill_id >= HM_SKILLRANGEMIN && skill_id <= HM_SKILLRANGEMAX) - || (skill_id >= MC_SKILLRANGEMIN && skill_id <= MC_SKILLRANGEMAX) - || (skill_id >= EL_SKILLRANGEMIN && skill_id <= EL_SKILLRANGEMAX) ) + int skillRange[] = { NV_BASIC, NPC_LEX_AETERNA, + KN_CHARGEATK, SA_ELEMENTWIND, + RK_ENCHANTBLADE, AB_SILENTIUM, + WL_WHITEIMPRISON, SC_FEINTBOMB, + LG_CANNONSPEAR, SR_GENTLETOUCH_REVITALIZE, + WA_SWING_DANCE, WA_MOONLIT_SERENADE, + MI_RUSH_WINDMILL, MI_HARMONIZE, + WM_LESSON, WM_UNLIMITED_HUMMING_VOICE, + SO_FIREWALK, SO_EARTH_INSIGNIA, + GN_TRAINING_SWORD, GN_SLINGITEM_RANGEMELEEATK, + AB_SECRAMENT, LG_OVERBRAND_PLUSATK, + ALL_ODINS_RECALL, ALL_LIGHTGUARD, + RL_GLITTERING_GREED, RL_GLITTERING_GREED_ATK, + KO_YAMIKUMO, OB_AKAITSUKI, + ECL_SNOWFLIP, ALL_THANATOS_RECALL, + GC_DARKCROW, NC_MAGMA_ERUPTION_DOTDAMAGE, + SU_BASIC_SKILL, SU_SPIRITOFSEA, + HLIF_HEAL, MH_VOLCANIC_ASH, + MS_BASH, MER_INVINCIBLEOFF2, + EL_CIRCLE_OF_FIRE, EL_STONE_RAIN, + GD_APPROVAL, GD_DEVELOPMENT + CUSTOM_SKILL_RANGES}; + int length = sizeof(skillRange) / sizeof(int); + STATIC_ASSERT(sizeof(skillRange) / sizeof(int) % 2 == 0, "skill_get_index: skillRange should be multiple of 2"); + + + if (skill_id < skillRange[0] || skill_id > skillRange[length - 1]) { + ShowWarning("skill_get_index: skill id '%d' is not being handled!\n", skill_id); return 0; + } - // map skill id to skill db index - if( skill_id >= GD_SKILLBASE ) - skill_id = GD_SKILLRANGEMIN + skill_id - GD_SKILLBASE; - else if( skill_id >= EL_SKILLBASE ) - skill_id = EL_SKILLRANGEMIN + skill_id - EL_SKILLBASE; - else if( skill_id >= MC_SKILLBASE ) - skill_id = MC_SKILLRANGEMIN + skill_id - MC_SKILLBASE; - else if( skill_id >= HM_SKILLBASE ) - skill_id = HM_SKILLRANGEMIN + skill_id - HM_SKILLBASE; - //[Ind/Hercules] GO GO GO LESS! - http://herc.ws/board/topic/512-skill-id-processing-overhaul/ - else if( skill_id > 1019 && skill_id < 8001 ) { - if( skill_id < 2058 ) // 1020 - 2000 are empty - skill_id = 1020 + skill_id - 2001; - else if( skill_id < 2549 ) // 2058 - 2200 are empty - 1020+57 - skill_id = (1077) + skill_id - 2201; - else if ( skill_id < 3036 ) // 2549 - 3000 are empty - 1020+57+348 - skill_id = (1425) + skill_id - 3001; - else if ( skill_id < 5044 ) // 3036 - 5000 are empty - 1020+57+348+35 - skill_id = (1460) + skill_id - 5001; - else - ShowWarning("skill_get_index: skill id '%d' is not being handled!\n",skill_id); + int skill_idx = 0; + // Map Skill ID to Skill Indexes (in reverse order) + for (int i = 0; i < length; i += 2) { + // Check if SkillID belongs to this range. + if (skill_id <= skillRange[i + 1] && skill_id >= skillRange[i]) { + skill_idx += (skillRange[i + 1] - skill_id); + break; + } + // Add the difference of current range + skill_idx += (skillRange[i + 1] - skillRange[i] + 1); } - // validate result - if (skill_id <= 0|| skill_id >= MAX_SKILL_DB) + if (skill_idx >= MAX_SKILL_DB) { + ShowWarning("skill_get_index: skill id '%d'(idx: %d) is not being handled as it exceeds MAX_SKILL_DB!\n", skill_id, skill_idx); return 0; + } - return skill_id; + return skill_idx; } static const char *skill_get_name(int skill_id) diff --git a/src/map/skill.h b/src/map/skill.h index dbda6470f..188a1c927 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -59,6 +59,12 @@ struct status_change_entry; #define MAX_SKILLUNITGROUPTICKSET 25 #define MAX_SKILL_NAME_LENGTH 32 +// Custom Skill Ranges is used in skill_get_index, to allocate indexes based on ID and gaps between 2 SkillID +#ifndef CUSTOM_SKILL_RANGES + #define CUSTOM_SKILL_RANGES +#endif // CUSTOM_SKILL_RANGES + + // (Epoque:) To-do: replace this macro with some sort of skill tree check (rather than hard-coded skill names) #define skill_ischangesex(id) ( \ ((id) >= BD_ADAPTATION && (id) <= DC_SERVICEFORYOU) || ((id) >= CG_ARROWVULCAN && (id) <= CG_MARIONETTE) || \ |