diff options
-rw-r--r-- | src/map/atcommand.c | 15 | ||||
-rw-r--r-- | src/map/mob.c | 2 | ||||
-rw-r--r-- | src/map/pc.c | 27 | ||||
-rw-r--r-- | src/map/skill.c | 96 |
4 files changed, 76 insertions, 64 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index d9f4810ee..b92ca8c48 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5296,12 +5296,13 @@ ACMD(skillid) iter = db_iterator(skill->name2id_db); for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) { - int idx = skill->get_index(DB->data2i(data)); - if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->dbs->db[idx].desc, message, skillen) == 0) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s) + int skill_id = DB->data2i(data); + const char *skill_desc = skill->get_desc(skill_id); + if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_desc, message, skillen) == 0) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1164), skill_id, skill_desc, key.str); // skill %d: %s (%s) clif->message(fd, atcmd_output); - } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->dbs->db[idx].desc,message) ) ) { - snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); + } else if (found < MAX_SKILLID_PARTIAL_RESULTS && (stristr(key.str, message) != NULL || stristr(skill_desc, message) != NULL)) { + snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd, 1164), skill_id, skill_desc, key.str); found++; } } @@ -5428,7 +5429,7 @@ ACMD(skilltree) for (j = 0; j < VECTOR_LENGTH(entry->need); j++) { struct skill_tree_requirement *req = &VECTOR_INDEX(entry->need, j); if (pc->checkskill(sd, req->id) < req->lv) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), req->lv, skill->dbs->db[req->id].desc); // Player requires level %d of skill %s. + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), req->lv, skill->get_desc(req->id)); // Player requires level %d of skill %s. clif->message(fd, atcmd_output); meets = 0; } @@ -8686,7 +8687,7 @@ ACMD(cart) { int val = atoi(message); bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true; - unsigned int index = skill->get_index(MC_PUSHCART); + int index = skill->get_index(MC_PUSHCART); if (!*message || val < 0 || val > MAX_CARTS) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>). diff --git a/src/map/mob.c b/src/map/mob.c index 208617b5d..f509ecace 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4846,7 +4846,7 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) struct mob_skill *ms, gms; int mob_id; int i =0, j, tmp; - uint16 sidx = 0; + int sidx = 0; nullpo_retr(false, str); mob_id = atoi(str[0]); diff --git a/src/map/pc.c b/src/map/pc.c index 0636ebafa..f622b3d42 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1622,18 +1622,25 @@ int pc_calc_skilltree(struct map_session_data *sd) if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->dbs->db[i].nameid >= DC_HUMMING && skill->dbs->db[i].nameid <= DC_SERVICEFORYOU ) { //Enable Bard/Dancer spirit linked skills. - if( sd->status.sex ) - { //Link dancer skills to bard. - // i can be < 8? - if( sd->status.skill[i-8].lv < 10 ) + if (sd->status.sex) { + // Link dancer skills to bard. + if (i < 8) { + Assert_report(i >= 8); + continue; + } + if (sd->status.skill[i-8].lv < 10) continue; sd->status.skill[i].id = skill->dbs->db[i].nameid; sd->status.skill[i].lv = sd->status.skill[i-8].lv; // Set the level to the same as the linking skill sd->status.skill[i].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill - } else { //Link bard skills to dancer. - if( sd->status.skill[i].lv < 10 ) + } else { + // Link bard skills to dancer. + if (i < 8) { + Assert_report(i >= 8); + continue; + } + if (sd->status.skill[i].lv < 10) continue; - // i can be < 8? sd->status.skill[i-8].id = skill->dbs->db[i-8].nameid; sd->status.skill[i-8].lv = sd->status.skill[i].lv; // Set the level to the same as the linking skill sd->status.skill[i-8].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill @@ -4143,7 +4150,7 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4 *------------------------------------------*/ int pc_skill(struct map_session_data *sd, int id, int level, int flag) { - uint16 index = 0; + int index = 0; nullpo_ret(sd); if (!(index = skill->get_index(id))) { @@ -5869,7 +5876,7 @@ int pc_memo(struct map_session_data* sd, int pos) { * Return player sd skill_lv learned for given skill *------------------------------------------*/ int pc_checkskill(struct map_session_data *sd,uint16 skill_id) { - uint16 index = 0; + int index = 0; if(sd == NULL) return 0; if( skill_id >= GD_SKILLBASE && skill_id < GD_MAX ) { struct guild *g; @@ -7229,7 +7236,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) * Skill point allocation *------------------------------------------*/ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { - uint16 index = 0; + int index = 0; nullpo_ret(sd); if( skill_id >= GD_SKILLBASE && skill_id < GD_SKILLBASE+MAX_GUILDSKILL ) { diff --git a/src/map/skill.c b/src/map/skill.c index f03d72b5a..d2db6c1bb 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -3548,8 +3548,8 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, struct status_data *st; struct map_session_data *sd = NULL; int i, hp, sp, hp_rate, sp_rate, state, mhp; - uint16 idx; - int itemid[MAX_SKILL_ITEM_REQUIRE],amount[ARRAYLENGTH(itemid)],index[ARRAYLENGTH(itemid)]; + int idx; + int itemid[MAX_SKILL_ITEM_REQUIRE], amount[MAX_SKILL_ITEM_REQUIRE], index[MAX_SKILL_ITEM_REQUIRE]; if( lv < 1 || lv > MAX_SKILL_LEVEL ) return 0; @@ -3565,8 +3565,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, return 0; // Requirements - for( i = 0; i < ARRAYLENGTH(itemid); i++ ) - { + for (i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++) { itemid[i] = skill->dbs->db[idx].itemid[i]; amount[i] = skill->dbs->db[idx].amount[i]; } @@ -7039,7 +7038,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin // custom hack to make the mob display the skill, because these skills don't show the skill use text themselves //NOTE: mobs don't have the sprite animation that is used when performing this skill (will cause glitches) char temp[70]; - snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->dbs->db[skill_id].desc); + snprintf(temp, sizeof(temp), "%s : %s !!", md->name, skill->get_desc(skill_id)); clif->disp_overhead(&md->bl,temp); } break; @@ -7238,7 +7237,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( sd->skillitem != skill_id ) - status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded + status_zap(src, 0, skill->get_sp(skill_id, skill_lv)); // consume sp only if succeeded } break; @@ -7414,21 +7413,22 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( sd ) { - int x,bonus=100, potion = min(500+skill_lv,505); - x = skill_lv%11 - 1; - i = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[x]); - if (i == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[x] <= 0) { + int bonus = 100, potion = min(500+skill_lv,505); + int item_idx = skill_lv%11 - 1; + int item_id = skill->get_itemid(skill_id, item_idx); + int inventory_idx = pc->search_inventory(sd, item_id); + if (inventory_idx == INDEX_NOT_FOUND || item_id <= 0) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; } - if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->dbs->db[skill_id].amount[x]) { + if (sd->inventory_data[inventory_idx] == NULL || sd->status.inventory[inventory_idx].amount < skill->get_itemqty(skill_id, item_idx)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; } if( skill_id == AM_BERSERKPITCHER ) { - if (dstsd && dstsd->status.base_level < sd->inventory_data[i]->elv) { + if (dstsd != NULL && dstsd->status.base_level < sd->inventory_data[inventory_idx]->elv) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; @@ -7437,7 +7437,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin script->potion_flag = 1; script->potion_hp = script->potion_sp = script->potion_per_hp = script->potion_per_sp = 0; script->potion_target = bl->id; - script->run_use_script(sd, sd->inventory_data[i], 0); + script->run_use_script(sd, sd->inventory_data[inventory_idx], 0); script->potion_flag = script->potion_target = 0; if( sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ALCHEMIST ) bonus += sd->status.base_level; @@ -7964,14 +7964,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case WE_MALE: { - int hp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].hp_rate[skill_lv-1]; + int hp_rate = skill_lv == 0 ? 0 : skill->get_hp_rate(skill_id, skill_lv); int gain_hp = tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it cost the caster. [Skotlex] clif->skill_nodamage(src,bl,skill_id,status->heal(bl, gain_hp, 0, 0),1); } break; case WE_FEMALE: { - int sp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].sp_rate[skill_lv-1]; + int sp_rate = skill_lv == 0 ? 0 : skill->get_sp_rate(skill_id, skill_lv); int gain_sp = tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it cost the caster. [Skotlex] clif->skill_nodamage(src,bl,skill_id,status->heal(bl, 0, gain_sp, 0),1); } @@ -8034,16 +8034,17 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( battle_config.skill_removetrap_type ) { int i; // get back all items used to deploy the trap - for( i = 0; i < 10; i++ ) { - if( skill->dbs->db[su->group->skill_id].itemid[i] > 0 ) { + for (i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++) { + int nameid = skill->get_itemid(su->group->skill_id, i); + if (nameid > 0) { int success; - struct item item_tmp; - memset(&item_tmp,0,sizeof(item_tmp)); - item_tmp.nameid = skill->dbs->db[su->group->skill_id].itemid[i]; + struct item item_tmp = { 0 }; + int amount = skill->get_itemqty(su->group->skill_id, i); + item_tmp.nameid = nameid; item_tmp.identify = 1; - if (item_tmp.nameid && (success=pc->additem(sd,&item_tmp,skill->dbs->db[su->group->skill_id].amount[i],LOG_TYPE_SKILL)) != 0) { + if ((success = pc->additem(sd, &item_tmp, amount, LOG_TYPE_SKILL)) != 0) { clif->additem(sd,0,0,success); - map->addflooritem(&sd->bl, &item_tmp, skill->dbs->db[su->group->skill_id].amount[i], sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &item_tmp, amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); } } } @@ -8275,7 +8276,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin map->freeblock_unlock(); return 0; } - status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish] + status_zap(src, 0, skill->get_sp(skill_id, skill_lv)); // consume sp only if succeeded [Inkfish] do { int eff = rnd() % 14; if( eff == 5 ) @@ -11210,10 +11211,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui // Slim Pitcher [Celest] case CR_SLIMPITCHER: if (sd) { - int i = skill_lv%11 - 1; - int j = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[i]); - if (j == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[i] <= 0 - || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->dbs->db[skill_id].amount[i] + int item_idx = skill_lv%11 - 1; + int item_id = skill->get_itemid(skill_id, item_idx); + int inventory_idx = pc->search_inventory(sd, item_id); + int bonus; + if (inventory_idx == INDEX_NOT_FOUND || item_id <= 0 + || sd->inventory_data[inventory_idx] == NULL + || sd->status.inventory[inventory_idx].amount < skill->get_itemqty(skill_id, item_idx) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -11221,44 +11225,44 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui script->potion_flag = 1; script->potion_hp = 0; script->potion_sp = 0; - script->run_use_script(sd, sd->inventory_data[j], 0); + script->run_use_script(sd, sd->inventory_data[inventory_idx], 0); script->potion_flag = 0; //Apply skill bonuses - i = pc->checkskill(sd,CR_SLIMPITCHER)*10 + bonus = pc->checkskill(sd,CR_SLIMPITCHER)*10 + pc->checkskill(sd,AM_POTIONPITCHER)*10 + pc->checkskill(sd,AM_LEARNINGPOTION)*5 + pc->skillheal_bonus(sd, skill_id); - script->potion_hp = script->potion_hp * (100+i)/100; - script->potion_sp = script->potion_sp * (100+i)/100; + script->potion_hp = script->potion_hp * (100 + bonus) / 100; + script->potion_sp = script->potion_sp * (100 + bonus) / 100; - if(script->potion_hp > 0 || script->potion_sp > 0) { - i = skill->get_splash(skill_id, skill_lv); + if (script->potion_hp > 0 || script->potion_sp > 0) { + r = skill->get_splash(skill_id, skill_lv); map->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + src->m, x - r, y - r, x + r, y + r, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_PARTY|BCT_GUILD|1, skill->castend_nodamage_id); } } else { - int i = skill_lv%11 - 1; - struct item_data *item; - i = skill->dbs->db[skill_id].itemid[i]; - item = itemdb->search(i); + int item_idx = skill_lv%11 - 1; + int item_id = skill->get_itemid(skill_id, item_idx); + struct item_data *item = itemdb->search(item_id); + int bonus; script->potion_flag = 1; script->potion_hp = 0; script->potion_sp = 0; script->run(item->script,0,src->id,0); script->potion_flag = 0; - i = skill->get_max(CR_SLIMPITCHER)*10; + bonus = skill->get_max(CR_SLIMPITCHER)*10; - script->potion_hp = script->potion_hp * (100+i)/100; - script->potion_sp = script->potion_sp * (100+i)/100; + script->potion_hp = script->potion_hp * (100 + bonus)/100; + script->potion_sp = script->potion_sp * (100 + bonus)/100; - if(script->potion_hp > 0 || script->potion_sp > 0) { - i = skill->get_splash(skill_id, skill_lv); + if (script->potion_hp > 0 || script->potion_sp > 0) { + r = skill->get_splash(skill_id, skill_lv); map->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + src->m, x - r, y - r, x + r, y + r, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_PARTY|BCT_GUILD|1, skill->castend_nodamage_id); } } |