Quellcode durchsuchen

Updated geteleminfo script command (#8168)

* Updated geteleminfo script command
* Added a new <type> "2" that returns the class ID of the elemental spirit
* Fixed Dimensions Elemental* combos: item descriptions require high elemental spirit check
* Added new constants for geteleminfo

Thanks to @aleos89 @Badarosk0 !
Atemo vor 1 Jahr
Ursprung
Commit
a768af85ee
5 geänderte Dateien mit 34 neuen und 11 gelöschten Zeilen
  1. 4 2
      db/re/item_combos.yml
  2. 3 2
      doc/script_commands.txt
  3. 15 7
      src/map/script.cpp
  4. 7 0
      src/map/script.hpp
  5. 5 0
      src/map/script_constants.hpp

+ 4 - 2
db/re/item_combos.yml

@@ -46814,7 +46814,8 @@ Body:
          bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_WIND",2*.@sum;
          bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_POISON",2*.@sum;
          bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_GROUND",2*.@sum;
-         if (getskilllv("EM_ELEMENTAL_BUSTER") > 0) {
+         .@class_ = geteleminfo(ELEMINFO_CLASS);
+         if (getskilllv("EM_ELEMENTAL_BUSTER") > 0 && .@class_ >= 20816 && .@class_ <= 20820) {
             bonus4 bAutoSpellOnSkill,"EM_DIAMOND_STORM","EM_ELEMENTAL_BUSTER",getskilllv("EM_ELEMENTAL_BUSTER"),1000;
          }
       }
@@ -46835,7 +46836,8 @@ Body:
          bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_WIND",2*.@sum;
          bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_POISON",2*.@sum;
          bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_GROUND",2*.@sum;
-         if (getskilllv("EM_ELEMENTAL_BUSTER") > 0 && geteleminfo(0) > 0) {
+         .@class_ = geteleminfo(ELEMINFO_CLASS);
+         if (getskilllv("EM_ELEMENTAL_BUSTER") > 0 && .@class_ >= 20816 && .@class_ <= 20820) {
             bonus4 bAutoSpellOnSkill,"EM_TERRA_DRIVE","EM_ELEMENTAL_BUSTER",getskilllv("EM_ELEMENTAL_BUSTER"),1000;
          }
       }

+ 3 - 2
doc/script_commands.txt

@@ -8966,8 +8966,9 @@ Get info of elemental of attached player or player by char_id.
 Other info can be obtained by 'getunitdata' command.
 
 Valid types are:
-   0: Elemental ID
-   1: Elemental Game ID
+   ELEMINFO_ID        Elemental ID (ID unique to elementals unit type)
+   ELEMINFO_GAMEID    Elemental Game ID
+   ELEMINFO_CLASS     Elemental Class (ID defined in elemental_db.yml)
 
 ---------------------------------------
 \\

+ 15 - 7
src/map/script.cpp

@@ -24038,24 +24038,32 @@ BUILDIN_FUNC(ignoretimeout)
  * geteleminfo <type>{,<char_id>};
  **/
 BUILDIN_FUNC(geteleminfo) {
-	TBL_ELEM *ed = NULL;
-	TBL_PC *sd = NULL;
-	int type = script_getnum(st,2);
+	map_session_data *sd = nullptr;
 
 	if (!script_charid2sd(3, sd)) {
 		script_pushint(st, 0);
-		return SCRIPT_CMD_SUCCESS;
+		return SCRIPT_CMD_FAILURE;
 	}
 
+	s_elemental_data *ed = nullptr;
+
 	if (!(ed = sd->ed)) {
-		//ShowDebug("buildin_geteleminfo: Player doesn't have Elemental.\n");
 		script_pushint(st, 0);
 		return SCRIPT_CMD_SUCCESS;
 	}
 
+	int type = script_getnum(st,2);
+
 	switch (type) {
-		case 0: script_pushint(st, ed->elemental.elemental_id); break;
-		case 1: script_pushint(st, ed->bl.id); break;
+		case ELEMINFO_ID:
+			script_pushint(st, ed->elemental.elemental_id);
+			break;
+		case ELEMINFO_GAMEID:
+			script_pushint(st, ed->bl.id);
+			break;
+		case ELEMINFO_CLASS:
+			script_pushint(st, ed->elemental.class_);
+			break;
 		default:
 			ShowError("buildin_geteleminfo: Invalid type '%d'.\n", type);
 			script_pushint(st, 0);

+ 7 - 0
src/map/script.hpp

@@ -2185,6 +2185,13 @@ enum e_iteminfo : uint8 {
 	ITEMINFO_SUBTYPE,
 };
 
+/* geteleminfo script command */
+enum e_eleminfo : uint8 {
+	ELEMINFO_ID = 0,
+	ELEMINFO_GAMEID,
+	ELEMINFO_CLASS,
+};
+
 class ConstantDatabase : public YamlDatabase {
 public:
 	ConstantDatabase() : YamlDatabase("CONSTANT_DB", 1) {

+ 5 - 0
src/map/script_constants.hpp

@@ -10196,6 +10196,11 @@
 	export_constant(ITEMINFO_ARMORLEVEL);
 	export_constant(ITEMINFO_SUBTYPE);
 
+	/* geteleminfo script command */
+	export_constant(ELEMINFO_ID);
+	export_constant(ELEMINFO_GAMEID);
+	export_constant(ELEMINFO_CLASS);
+
 	/* refine types */
 	export_constant(REFINE_TYPE_ARMOR);
 	export_constant(REFINE_TYPE_WEAPON);