From db37fc7dddb7bc2df82394715d85505b3c90c9d2 Mon Sep 17 00:00:00 2001 From: Aleos Date: Sat, 14 Oct 2017 22:37:55 -0400 Subject: [PATCH] Fixes required equipment check for skills (#2374) * Fixes required equipment check for skills * Fixes #2372. * Required equipment check was allowing the skill to cast without the proper equipment. * Adjusted the skill fail messages to their appropriate responses. Thanks to @M4karov, @exneval, @Jeybla, and @Lemongrass3110! --- conf/msg_conf/map_msg.conf | 2 +- db/re/skill_require_db.txt | 16 ++++++------- src/map/clif.h | 1 + src/map/skill.cpp | 48 +++++++++++++++++++++----------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index 1b90e991e8..2aaad96344 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -753,7 +753,7 @@ 719: Personal rate information will be shown. //Skill messages -720: %s is required. +//720: Free 721: [%s] Poison effect was applied to the weapon. //722: Free diff --git a/db/re/skill_require_db.txt b/db/re/skill_require_db.txt index 965efc91ce..78012a66ac 100644 --- a/db/re/skill_require_db.txt +++ b/db/re/skill_require_db.txt @@ -684,20 +684,20 @@ 2259,0,0,20,0,0,0,99,0,0,mado,0,0,2139,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_FLAMELAUNCHER 2260,0,0,20,0,0,0,99,0,0,mado,0,0,6146,1,6147,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_COLDSLOWER 2261,0,0,30:45:60,0,0,0,99,8,1,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_ARMSCANNON -2262,0,0,20:40:60,0,0,0,99,0,0,mado,0,0,2800,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_ACCELERATION +2262,0,0,20:40:60,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2800 //NC_ACCELERATION 2263,0,0,25,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2801 //NC_HOVERING 2264,0,0,5,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_F_SIDESLIDE 2265,0,0,5,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_B_SIDESLIDE -2267,0,0,200,0,0,0,99,0,0,mado,0,0,2802,0,6146,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_SELFDESTRUCTION -2268,0,0,100,0,0,0,99,0,0,mado,0,0,6360,3,6363,3,6362,3,6361,3,2803,0,0,0,0,0,0,0,0,0,6146,2,0 //NC_SHAPESHIFT -2269,0,0,20,0,0,0,99,0,0,mado,0,0,2804,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_EMERGENCYCOOL +2267,0,0,200,0,0,0,99,0,0,mado,0,0,6146,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2802 //NC_SELFDESTRUCTION +2268,0,0,100,0,0,0,99,0,0,mado,0,0,6360,3,6363,3,6362,3,6361,3,6146,2,0,0,0,0,0,0,0,0,0,0,2803 //NC_SHAPESHIFT +2269,0,0,20,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2804 //NC_EMERGENCYCOOL 2270,0,0,45,0,0,0,99,0,0,mado,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_INFRAREDSCAN 2271,0,0,30,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_ANALYZE -2272,0,0,60:70:80,0,0,0,99,0,0,mado,0,0,2805,0,6146,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_MAGNETICFIELD -2273,0,0,80:90:100,0,0,0,99,0,0,mado,0,0,2806,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_NEUTRALBARRIER -2274,0,0,80:100:120,0,0,0,99,0,0,mado,0,0,2808,0,6146,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_STEALTHFIELD -2275,0,0,25:30:35:40:45,0,0,0,99,0,0,mado,0,0,12392,1,12392,1,12393,1,12393,1,12394,1,0,0,0,0,0,0,0,0,2807,0,0 //NC_REPAIR +2272,0,0,60:70:80,0,0,0,99,0,0,mado,0,0,6146,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2805 //NC_MAGNETICFIELD +2273,0,0,80:90:100,0,0,0,99,0,0,mado,0,0,6146,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2806 //NC_NEUTRALBARRIER +2274,0,0,80:100:120,0,0,0,99,0,0,mado,0,0,6146,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2808 //NC_STEALTHFIELD +2275,0,0,25:30:35:40:45,0,0,0,99,0,0,mado,0,0,12392,1,12392,1,12393,1,12393,1,12394,1,0,0,0,0,0,0,0,0,0,0,2807 //NC_REPAIR 2278,0,0,20:22:24:26:28,0,0,0,6:7,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_AXEBOOMERANG 2279,0,0,20:22:24:26:28,0,0,0,6:7,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //NC_POWERSWING diff --git a/src/map/clif.h b/src/map/clif.h index 396a253507..861710dde2 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -456,6 +456,7 @@ enum useskill_fail_cause //XXX_USESKILL_FAIL_II_HELLS_PLANT_BOTTLE = 68, //XXX_USESKILL_FAIL_II_MANDRAGORA_FLOWERPOT = 69, USESKILL_FAIL_MANUAL_NOTIFY = 70, + // CAUTION: client uses unidentified display name for displaying the required item. Still broken on 2017-05-31 [Lemongrass] USESKILL_FAIL_NEED_ITEM = 71, USESKILL_FAIL_NEED_EQUIPMENT = 72, USESKILL_FAIL_COMBOSKILL = 73, diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 489dc66ea0..de39bc75d5 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -15213,7 +15213,6 @@ bool skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_i if( skill_check_pc_partner(sd,skill_id,&skill_lv,1,0) <= 0 && require.itemid[0] && sd->special_state.no_gemstone == 0 && ((i = pc_search_inventory(sd,require.itemid[0])) < 0 || sd->inventory.u.items_inventory[i].amount < require.amount[0]) ) { - //clif_skill_fail(sd,skill_id,USESKILL_FAIL_NEED_ITEM,require.amount[0],require.itemid[0]); clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return false; } @@ -15555,27 +15554,38 @@ bool skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_i } } - //check if equipped item + // Check for equipped item(s) if (require.eqItem_count) { + uint8 count = require.eqItem_count; + for (i = 0; i < require.eqItem_count; i++) { uint16 reqeqit = require.eqItem[i]; if (!reqeqit) - break; //no required item; get out of here - if (!pc_checkequip2(sd,reqeqit,EQI_ACC_L,EQI_MAX)) { - if (i == require.eqItem_count) { - switch(skill_id) { - case RL_P_ALTER: - clif_msg(sd, SKILL_NEED_HOLY_BULLET); - break; - default: - clif_skill_fail(sd, skill_id, USESKILL_FAIL_THIS_WEAPON, 0); - break; + break; // Skill has no required item(s); get out of here + switch(skill_id) { // Specific skills require multiple items while default will handle singular cases + case NC_PILEBUNKER: + case RL_P_ALTER: + if (!pc_checkequip2(sd,reqeqit,EQI_ACC_L,EQI_MAX)) { + count--; + if (!count) { + if( skill_id == RL_P_ALTER ){ + clif_msg( sd, SKILL_NEED_HOLY_BULLET ); + }else{ + clif_skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); + } + return false; + } else + continue; } - return false; - } - } else - break; // Wearing an applicable item. + break; + default: + if (!pc_checkequip2(sd,reqeqit,EQI_ACC_L,EQI_MAX)) { + clif_skill_fail(sd,skill_id,USESKILL_FAIL_NEED_EQUIPMENT,reqeqit<<16); + return false; + } + break; + } } } @@ -15816,11 +15826,7 @@ bool skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, else clif_skill_fail(sd, RL_SLUGSHOT, USESKILL_FAIL_NEED_MORE_BULLET, 0); // Bullet is required. } else { - char output[CHAT_SIZE_MAX]; - //Official is using msgstringtable.txt for each requirement failure - //clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - sprintf(output, msg_txt(sd,720), itemdb_jname(require.itemid[i])); // %s is required. - clif_messagecolor(&sd->bl,color_table[COLOR_RED],output,false,SELF); + clif_skill_fail( sd, skill_id, USESKILL_FAIL_NEED_ITEM, ( require.itemid[i] << 16 ) | require.amount[i] ); // [%s] required '%d' amount. } return false; } else if (skill_id == RL_SLUGSHOT) // Slug found - simulate priority and cancel the loop