1 (edited by amir_cinderella 2014-04-08 07:56:48)

Hey Guys!
I'm Here To Release This Little System That I Think Really Useful.

What It DoEs ?

Change Race / Gender .

http://pastebin.com/bufhSynr

and apply this diff in your source

diff --git a/src/game/Player.h b/src/game/Player.h
index e30701e..2692d51 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1707,6 +1707,8 @@ class Player : public Unit, public GridObject<Player>
         TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
         static uint32 getFactionForRace(uint8 race);
         void setFactionForRace(uint8 race);
+        
+         void InitDisplayIds();
 
         bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
         void RewardPlayerAndGroupAtKill(Unit* pVictim);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 951b5b8..0d21414 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -543,7 +543,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
     SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
     SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH);
 
-    switch(gender)
+  /*  switch(gender)
     {
         case GENDER_FEMALE:
             SetDisplayId(info->displayId_f);
@@ -557,13 +557,14 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
             sLog.outError("Invalid gender %u for player",gender);
             return false;
             break;
-    }
+    }*/
 
     setFactionForRace(race);
 
     uint32 RaceClassGender = (race) | (class_ << 8) | (gender << 16);
 
     SetUInt32Value(UNIT_FIELD_BYTES_0, (RaceClassGender | (powertype << 24)));
+    InitDisplayIds();
     SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield);
     SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY | UNIT_BYTE2_FLAG_UNK5);
     SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
@@ -14829,6 +14830,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
     SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32());
     SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[48].GetUInt32());
 
+    InitDisplayIds();
     // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
     for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
     {
@@ -16494,7 +16496,7 @@ void Player::SaveToDB()
     SetByteValue(UNIT_FIELD_BYTES_2, 3, 0);                 // shapeshift
     SetByteValue(UNIT_FIELD_BYTES_1, 3, 0);                 // stand flags?
     RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
-    SetDisplayId(GetNativeDisplayId());
+  //  SetDisplayId(GetNativeDisplayId());
 
     std::string sql_name = m_name;
     CharacterDatabase.escape_string(sql_name);
@@ -16639,7 +16641,7 @@ void Player::SaveToDB()
     CharacterDatabase.CommitTransaction();
 
     // restore state (before aura apply, if aura remove flag then aura must set it ack by self)
-    SetDisplayId(tmp_displayid);
+  //  SetDisplayId(tmp_displayid);
     SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes);
     SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2);
     SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags);
@@ -18276,6 +18278,31 @@ void Player::InitDataForForm(bool reapplyMods)
     UpdateAttackPowerAndDamage();
     UpdateAttackPowerAndDamage(true);
 }
+void Player::InitDisplayIds()
+   {
+       PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
+       if(!info)
+      {
+           sLog.outError("Player %u has incorrect race/class pair. Can't init display ids.", GetGUIDLow());
+           return;
+      }
+   
+      uint8 gender = getGender();
+       switch(gender)
+      {
+           case GENDER_FEMALE:
+               SetDisplayId(info->displayId_f );
+               SetNativeDisplayId(info->displayId_f );
+               break;
+           case GENDER_MALE:
+               SetDisplayId(info->displayId_m );
+               SetNativeDisplayId(info->displayId_m );
+               break;
+           default:
+               sLog.outError("Invalid gender %u for player",gender);
+               return;
+       }
+   }
 
 // Return true is the bought item has a max count to force refresh of window by caller
 bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot)

Sry For Bad Eng

2 (edited by Doka 2014-05-07 16:10:09)

Hello,
I didnt test this still but its very useful for Funservers,
there is chance anyone to rewrite it to req item ?,(Gender Token, Race Token)

3 (edited by Vagabonden 2016-09-07 19:43:26)

I understand the changes you have to make in player.cpp + player.h ?

But what about http://pastebin.com/bufhSynr?

I make a cpp file named "whatever" and put it into scripts -> Custom ?

Than i make a NPC and give it scriptname "racechanger" ?

Correct?

Since none of that worked when i did it sad

I know how to do sql, not C++ yet hmm

maybe you need to add it to the scriptloader?

i don't know if there where made changes, and its not needed any more but in the past this was needed.

yust look at the scriptloader, you see you have only to call the AddSC_racechanger method in there

Thanks for sharing smile