Browse Source

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!
Aleos 7 years ago
parent
commit
db37fc7ddd
4 changed files with 37 additions and 30 deletions
  1. 1 1
      conf/msg_conf/map_msg.conf
  2. 8 8
      db/re/skill_require_db.txt
  3. 1 0
      src/map/clif.h
  4. 27 21
      src/map/skill.cpp

+ 1 - 1
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
 

+ 8 - 8
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

+ 1 - 0
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,

+ 27 - 21
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