Jump to content

Question

Hello i have code here from cydh that changes the players race, this is working on rAthena. Although it's not compatible with herc. Anyone can help me with it? Thanks!


https://www.dropbox.com/scl/fi/msiy4c6fu5uwok1e0fhtx/bonus_bRace.diff?rlkey=4c41esca9fewia9n8uartp0jd&e=1&dl=0
 

doc/item_bonus.txt           | 1 +
 src/map/map.hpp              | 1 +
 src/map/pc.cpp               | 4 ++++
 src/map/pc.hpp               | 1 +
 src/map/script_constants.hpp | 1 +
 src/map/status.cpp           | 5 +++++
 6 files changed, 13 insertions(+)

diff --git a/doc/item_bonus.txt b/doc/item_bonus.txt
index 7ffe172b5..08ef4a571 100644
--- a/doc/item_bonus.txt
+++ b/doc/item_bonus.txt
@@ -260,6 +260,7 @@ Atk/Def
 -------
 bonus bAtkEle,e;          		Gives the player's attacks element e
 bonus bDefEle,e;          		Gives the player's defense element e
+bonus bRace,r;          		Set the player's race to race r
 
 bonus2 bMagicAtkEle,e,x;  		Increases damage of e element magic by x%
 
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 5200ff6b4..44073fbb2 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -429,6 +429,7 @@ enum _sp {
 
 	// Mercenaries
 	SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190,
+	SP_RACE,
 
 	// original 1000-
 	SP_ATTACKRANGE=1000,	SP_ATKELE,SP_DEFELE,	// 1000-1002
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index ab1040eca..be3d1cdee 100755
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -3217,6 +3217,10 @@ void pc_bonus(struct map_session_data *sd,int type,int val)
 			if (sd->state.lr_flag != 2)
 				sd->special_state.no_mado_fuel = 1;
 			break;
+		case SP_RACE:
+			PC_BONUS_CHK_RACE(val, SP_RACE);
+			sd->bonus.change_race = (enum e_race)val;
+			break;
 		default:
 			if (running_npc_stat_calc_event) {
 				ShowWarning("pc_bonus: unknown bonus type %d %d in OnPCStatCalcEvent!\n", type, val);
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 05e861c64..dfebca1d9 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -497,6 +497,7 @@ struct map_session_data {
 		int ematk; // matk bonus from equipment
 		int eatk; // atk bonus from equipment
 		uint8 absorb_dmg_maxhp; // [Cydh]
+		enum e_race change_race;
 		short critical_rangeatk;
 		short weapon_atk_rate, weapon_matk_rate;
 	} bonus;
diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp
index 5d5066a4e..2c8a2f0e9 100644
--- a/src/map/script_constants.hpp
+++ b/src/map/script_constants.hpp
@@ -731,6 +731,7 @@
 	export_constant2("bRegenPercentHP", SP_REGEN_PERCENT_HP);
 	export_constant2("bRegenPercentSP", SP_REGEN_PERCENT_SP);
 	export_constant2("bSkillDelay",SP_SKILL_DELAY);
+	export_constant2("bRace", SP_RACE);
 
 	/* equip indices */
 	export_constant(EQI_COMPOUND_ON);
diff --git a/src/map/status.cpp b/src/map/status.cpp
index d08be8e81..67546d1c2 100644
--- a/src/map/status.cpp
+++ b/src/map/status.cpp
@@ -3495,6 +3495,7 @@ int status_calc_pc_sub(struct map_session_data* sd, enum e_status_calc_opt opt)
 	);
 
 	memset (&sd->bonus, 0, sizeof(sd->bonus));
+	sd->bonus.change_race = RC_NONE_;
 
 	// Autobonus
 	pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true);
@@ -4208,6 +4209,10 @@ int status_calc_pc_sub(struct map_session_data* sd, enum e_status_calc_opt opt)
 		if (sc->data[SC_LAUDARAMUS])
 			sd->bonus.crit_atk_rate += 5 * sc->data[SC_LAUDARAMUS]->val1;
 	}
+
+	if (sd->bonus.change_race != RC_NONE_)
+		base_status->race = sd->bonus.change_race;
+
 	status_cpy(&sd->battle_status, base_status);
 
 // ----- CLIENT-SIDE REFRESH -----

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.