Jump to content

[patch] New druid models for cat and bear forms


Recommended Posts

I've coded two patches to fix both the issue in the title and the tauren changing their skin-tones at the barbershop.

Important links I've come through:

Druid Forms underdev

List of Hair/Skin vs Model Texture

My Tauren Barbershop fix thread

It supports rev [10148] as of now.

Tauren Barbershop fix: Paste2

Druid shapeshifts: Paste2

The second patch needs the first.

Link to comment
Share on other sites

  • 40 years later...

this is a very nice file-hoster you used (working without clicking etc) - but many users won't download a file, so usally it is best to upload your code to pastebin.com or (better) paste2.org

first look: I think there is a Player.GetTeam() function - this should be easier then

Link to comment
Share on other sites

I just copied code from other places in the core.

Can I just edit this patch file or do I have to make a new patch ? Newbie here :)

EDIT:

Seems like I've done the same thing thenecromancer did. We have to research the dbcs more I guess. :/

The tauren skin changing part might prove useful though, I'll separate it from the current patch and post it in another thread (if I don't find anyone already working on it).

Can anyone delete this thread now ?

Link to comment
Share on other sites

can't compile with your patch because of typos. Now it's fixed

author:
gs94

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 26d2c82..38d7309 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -1076,8 +1076,8 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
{
    DEBUG_LOG("CMSG_ALTER_APPEARANCE");

-    uint32 Hair, Color, FacialHair;
-    recv_data >> Hair >> Color >> FacialHair;
+    uint32 Hair, Color, FacialHair, SkinTone;
+    recv_data >> Hair >> Color >> FacialHair >> SkinTone;

    BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);

@@ -1089,7 +1089,12 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    if(!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
        return;

-    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id);
+    BarberShopStyleEntry const* bs_skinTone = sBarberShopStyleStore.LookupEntry(SkinTone);
+
+    if(!bs_skinTone || bs_skinTone->type != 3 || bs_skinTone->race != _player->getRace() || bs_skinTone->gender != _player->getGender())
+        return;
+
+    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, bs_skinTone->hair_id);

    // 0 - ok
    // 1,3 - not enough money
@@ -1114,6 +1119,7 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    _player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id));
    _player->SetByteValue(PLAYER_BYTES, 3, uint8(Color));
    _player->SetByteValue(PLAYER_BYTES_2, 0, uint8(bs_facialHair->hair_id));
+    _player->SetByteValue(PLAYER_BYTES, 0, uint8(bs_skinTone->hair_id));

    _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8d08e08..93f0dd6 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -20700,7 +20700,7 @@ bool Player::CanCaptureTowerPoint()
           );
}

-uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair)
+uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone)
{
    uint32 level = getLevel();

@@ -20710,8 +20710,10 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);
    uint8 haircolor = GetByteValue(PLAYER_BYTES, 3);
    uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0);
+    uint8 skintone = GetByteValue(PLAYER_BYTES, 0);

-    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair))
+    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) &&
+       (skintone == newskintone))
        return 0;

    GtBarberShopCostBaseEntry const *bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1);
@@ -20730,6 +20732,9 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    if(facialhair != newfacialhair)
        cost += bsc->cost * 0.75f;                          // +3/4 of price

+    if(skintone != newskintone)
+        cost += bsc->cost * 0.5f;                           // +1/2 of price
+
    return uint32(cost);
}

diff --git a/src/game/Player.h b/src/game/Player.h
index e218063..fe09fef 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1150,7 +1150,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        std::string afkMsg;
        std::string dndMsg;

-        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
+        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone);

        PlayerSocial *GetSocial() { return m_social; }

diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 084e122..d15cf52 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -3161,25 +3161,86 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
            modelid = ssEntry->modelID_A;
        else
        {
-            // players are a bit difficult since the dbc has seldomly an horde modelid
-            // so we add hacks here to set the right model
-            if (Player::TeamForRace(target->getRace()) == ALLIANCE)
-                modelid = ssEntry->modelID_A;
-            else                                            // 3.2.3 only the moonkin form has this information
-                modelid = ssEntry->modelID_H;
-
+            // The following are the different shapeshifting models for cat/bear forms according
+            // to hair color for druids and skin tone for tauren introduced in patch 3.2
+            if (form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR)
+            {
+                if (Player::TeamForRace(target->getRace()) == ALLIANCE)
+                {
+                    uint8 hairColour = target->GetByteValue(PLAYER_BYTES, 3);
+                    if (form == FORM_CAT)
+                    {
+                        if (hairColour >= 0 && hairColour <= 2) modelid = 29407;
+                        else if (hairColour == 3 || hairColour == 5) modelid = 29405;
+                        else if (hairColour == 6) modelid = 892;
+                        else if (hairColour == 7) modelid = 29406;
+                        else if (hairColour == 4) modelid = 29408;
+                    }
+                    else
+                    {
+                        if (hairColour >= 0 && hairColour <= 2) modelid = 29413;
+                        else if (hairColour == 3 || hairColour == 5) modelid = 29415;
+                        else if (hairColour == 6) modelid = 29414;
+                        else if (hairColour == 7) modelid = 29417;
+                        else if (hairColour == 4) modelid = 29416;
+                    }
+                } 
+                else if (Player::TeamForRace(target->getRace()) == HORDE)
+                {
+                    uint8 skinColour = target->GetByteValue(PLAYER_BYTES, 0);
+                    if (target->getGender() == GENDER_MALE)
+                    {
+                        if (form == FORM_CAT)
+                        {
+                            if (skinColour >= 0 && skinColour <= 5) modelid = 29412;
+                            else if (skinColour >= 6 && skinColour <= 8) modelid = 29411;
+                            else if (skinColour >= 9 && skinColour <= 11) modelid = 29410;
+                            else if (skinColour >= 12 && skinColour <= 14 || skinColour == 18) modelid = 29409;
+                            else if (skinColour >= 15 && skinColour <= 17) modelid = 8571;
+                        }
+                        else
+                        {
+                            if (skinColour >= 0 && skinColour <= 2) modelid = 29418;
+                            else if (skinColour >= 3 && skinColour <= 5 || skinColour >= 12 && skinColour <= 14) modelid = 29419;
+                            else if (skinColour >= 9 && skinColour <= 11 || skinColour >= 15 && skinColour <= 17) modelid = 29420;
+                            else if (skinColour >= 6 && skinColour <= 8) modelid = 2289;
+                            else if (skinColour == 18) modelid = 29421;
+                        }
+                    }
+                    else
+                    {
+                        if (form == FORM_CAT)
+                        {
+                            if (skinColour >= 0 && skinColour <= 3) modelid = 29412;
+                            else if (skinColour == 4 || skinColour == 5) modelid = 29411;
+                            else if (skinColour == 6 || skinColour == 7) modelid = 29410;
+                            else if (skinColour == 8 || skinColour == 9) modelid = 8571;
+                            else if (skinColour == 10) modelid = 29409;
+                        }
+                        else
+                        {
+                            if (skinColour == 0 || skinColour == 1) modelid = 29418;
+                            else if (skinColour == 2 || skinColour == 3) modelid = 29419;
+                            else if (skinColour == 4 || skinColour == 5) modelid = 2289;
+                            else if (skinColour >= 6 && skinColour <= 9) modelid = 29420;
+                            else if (skinColour == 10) modelid = 29421;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                if (Player::TeamForRace(target->getRace()) == ALLIANCE) modelid = ssEntry->modelID_A;
+                if (Player::TeamForRace(target->getRace()) == HORDE) modelid = ssEntry->modelID_H;
+            }
            // no model found, if player is horde we look here for our hardcoded modelids
            if (!modelid && Player::TeamForRace(target->getRace()) == HORDE)
            {
-
                switch(form)
                {
                    case FORM_CAT:
-                        modelid = 8571;
-                        break;
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
-                        modelid = 2289;
                        break;
                    case FORM_FLIGHT:
                        modelid = 20872;

Link to comment
Share on other sites

Sorry guys, after I had the git problems I had to rewrite the code fast without compiling :S

Does it work well now ?

only one bug: barbershop doesn't works - pressing at "OK" button just doesn't make anything, you can sit for a hours with clicking it but no result :)

ok, for tauren's all works ok, but for others - no...

Any solutions? There should be a check like "if (players->GetRace() == tauren)" to fix it, but where we need to add the check?

Link to comment
Share on other sites

From 70ec5f0614f30899bb3ec7132f0bdccfece4f431 Mon Sep 17 00:00:00 2001
From: GS <[email protected]>
Date: Sat, 19 Jun 2010 14:33:14 +0300
Subject: [PATCH 1/2] Barbershop fixed for tauren and other classes

---
src/game/CharacterHandler.cpp |   17 ++++++++++++++---
src/game/Player.cpp           |    9 +++++++--
src/game/Player.h             |    2 +-
3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 5e4e242..0ee3083 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -1076,8 +1076,18 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
{
    DEBUG_LOG("CMSG_ALTER_APPEARANCE");

-    uint32 Hair, Color, FacialHair;
-    recv_data >> Hair >> Color >> FacialHair;
+    uint32 skinTone_id = -1;
+
+    uint32 Hair, Color, FacialHair, SkinTone;
+    if(_player->getRace() != RACE_TAUREN) recv_data >> Hair >> Color >> FacialHair;
+    else
+    {
+        recv_data >> Hair >> Color >> FacialHair >> SkinTone;
+        BarberShopStyleEntry const* bs_skinTone = sBarberShopStyleStore.LookupEntry(SkinTone);
+        if(!bs_skinTone || bs_skinTone->type != 3 || bs_skinTone->race != _player->getRace() || bs_skinTone->gender != _player->getGender())
+            return;
+        skinTone_id = bs_skinTone->hair_id;
+    }

    BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);

@@ -1089,7 +1099,7 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    if(!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
        return;

-    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id);
+    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, skinTone_id);

    // 0 - ok
    // 1,3 - not enough money
@@ -1114,6 +1124,7 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    _player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id));
    _player->SetByteValue(PLAYER_BYTES, 3, uint8(Color));
    _player->SetByteValue(PLAYER_BYTES_2, 0, uint8(bs_facialHair->hair_id));
+    if(_player->getRace() == RACE_TAUREN) _player->SetByteValue(PLAYER_BYTES, 0, uint8(skinTone_id));

    _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 2af1cd7..92c9aa8 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -20617,7 +20617,7 @@ bool Player::CanCaptureTowerPoint()
           );
}

-uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair)
+uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone)
{
    uint32 level = getLevel();

@@ -20627,8 +20627,10 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);
    uint8 haircolor = GetByteValue(PLAYER_BYTES, 3);
    uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0);
+    uint8 skintone = GetByteValue(PLAYER_BYTES, 0);

-    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair))
+    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) &&
+       ((skintone == newskintone) || (newskintone == -1)))
        return 0;

    GtBarberShopCostBaseEntry const *bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1);
@@ -20647,6 +20649,9 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    if(facialhair != newfacialhair)
        cost += bsc->cost * 0.75f;                          // +3/4 of price

+    if(skintone != newskintone && newskintone != -1)        // +1/2 of price
+        cost += bsc->cost * 0.5f;
+
    return uint32(cost);
}

diff --git a/src/game/Player.h b/src/game/Player.h
index 942d68f..bc8bd5c 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1136,7 +1136,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        std::string afkMsg;
        std::string dndMsg;

-        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
+        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone);

        PlayerSocial *GetSocial() { return m_social; }

-- 
1.7.0.2.msysgit.0

From f6ed46f7a9a122cea1d26f51b131bb94fe138f6c Mon Sep 17 00:00:00 2001
From: GS <[email protected]>
Date: Sat, 19 Jun 2010 15:25:23 +0300
Subject: [PATCH 2/2] New druid models implemented and barbershop fixed for all classes.

---
src/game/SpellAuras.cpp |   85 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 533c098..c2aeaf9 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -3029,25 +3029,88 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
            modelid = ssEntry->modelID_A;
        else
        {
-            // players are a bit difficult since the dbc has seldomly an horde modelid
-            // so we add hacks here to set the right model
-            if (Player::TeamForRace(target->getRace()) == ALLIANCE)
-                modelid = ssEntry->modelID_A;
-            else                                            // 3.2.3 only the moonkin form has this information
-                modelid = ssEntry->modelID_H;
+            Player *player = (Player*)target;
+            // The following are the different shapeshifting models for cat/bear forms according
+            // to hair color for druids and skin tone for tauren introduced in patch 3.2
+            if (form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR)
+            {
+                if (player->GetTeam() == ALLIANCE)
+                {
+                    uint8 hairColour = target->GetByteValue(PLAYER_BYTES, 3);
+                    if (form == FORM_CAT)
+                    {
+                        if (hairColour >= 0 && hairColour <= 2) modelid = 29407;
+                        else if (hairColour == 3 || hairColour == 5) modelid = 29405;
+                        else if (hairColour == 6) modelid = 892;
+                        else if (hairColour == 7) modelid = 29406;
+                        else if (hairColour == 4) modelid = 29408;
+                    }
+                    else
+                    {
+                        if (hairColour >= 0 && hairColour <= 2) modelid = 29413;
+                        else if (hairColour == 3 || hairColour == 5) modelid = 29415;
+                        else if (hairColour == 6) modelid = 29414;
+                        else if (hairColour == 7) modelid = 29417;
+                        else if (hairColour == 4) modelid = 29416;
+                    }
+                } 
+                else if (player->GetTeam() == HORDE)
+                {
+                    uint8 skinColour = target->GetByteValue(PLAYER_BYTES, 0);
+                    if (target->getGender() == GENDER_MALE)
+                    {
+                        if (form == FORM_CAT)
+                        {
+                            if (skinColour >= 0 && skinColour <= 5) modelid = 29412;
+                            else if (skinColour >= 6 && skinColour <= 8) modelid = 29411;
+                            else if (skinColour >= 9 && skinColour <= 11) modelid = 29410;
+                            else if (skinColour >= 12 && skinColour <= 14 || skinColour == 18) modelid = 29409;
+                            else if (skinColour >= 15 && skinColour <= 17) modelid = 8571;
+                        }
+                        else
+                        {
+                            if (skinColour >= 0 && skinColour <= 2) modelid = 29418;
+                            else if (skinColour >= 3 && skinColour <= 5 || skinColour >= 12 && skinColour <= 14) modelid = 29419;
+                            else if (skinColour >= 9 && skinColour <= 11 || skinColour >= 15 && skinColour <= 17) modelid = 29420;
+                            else if (skinColour >= 6 && skinColour <= 8) modelid = 2289;
+                            else if (skinColour == 18) modelid = 29421;
+                        }
+                    }
+                    else
+                    {
+                        if (form == FORM_CAT)
+                        {
+                            if (skinColour >= 0 && skinColour <= 3) modelid = 29412;
+                            else if (skinColour == 4 || skinColour == 5) modelid = 29411;
+                            else if (skinColour == 6 || skinColour == 7) modelid = 29410;
+                            else if (skinColour == 8 || skinColour == 9) modelid = 8571;
+                            else if (skinColour == 10) modelid = 29409;
+                        }
+                        else
+                        {
+                            if (skinColour == 0 || skinColour == 1) modelid = 29418;
+                            else if (skinColour == 2 || skinColour == 3) modelid = 29419;
+                            else if (skinColour == 4 || skinColour == 5) modelid = 2289;
+                            else if (skinColour >= 6 && skinColour <= 9) modelid = 29420;
+                            else if (skinColour == 10) modelid = 29421;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                if (player->GetTeam() == ALLIANCE) modelid = ssEntry->modelID_A;
+                else modelid = ssEntry->modelID_H;
+            }

            // no model found, if player is horde we look here for our hardcoded modelids
-            if (!modelid && Player::TeamForRace(target->getRace()) == HORDE)
+            if (!modelid && player->GetTeam() == HORDE)
            {
-
                switch(form)
                {
                    case FORM_CAT:
-                        modelid = 8571;
-                        break;
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
-                        modelid = 2289;
                        break;
                    case FORM_FLIGHT:
                        modelid = 20872;
-- 
1.7.0.2.msysgit.0

Try applying both the patches. First applies first. Everything should work.

This is for [10078]

Link to comment
Share on other sites

Compile errors under linux.

first at

(newskintone == -1)

second at

(skintone != newskintone && newskintone != -1)

it gives a error about these strings: because of limit of data diapason result is always false (first); result is always true (second)

it's because "newskintone" is declared as "uint8", changing it to "int8" should help but idk, maybe this will cause an additional issues

it also can be fixed by way of changing -1 to 0

Link to comment
Share on other sites

uint32 skinTone_id = -1;

Is it intended? It equals 0xffffffff

read this , its the same error

Compile errors under linux.

first at

(newskintone == -1)

second at

(skintone != newskintone && newskintone != -1)

it gives a error about these strings: because of limit of data diapason result is always false (first); result is always true (second)

it's because "newskintone" is declared as "uint8", changing it to "int8" should help but idk, maybe this will cause an additional issues

it also can be fixed by way of changing -1 to 0

Link to comment
Share on other sites

I had to make up some value so that the barbershop cost function ignores the skin changing cost. Guess I have to put race hacks there too :S

Try these:

From 6c895bcbde2f1e43313c9666d272b2c9bc73be4e Mon Sep 17 00:00:00 2001
From: GS <[email protected]>
Date: Mon, 21 Jun 2010 02:59:43 +0300
Subject: [PATCH 1/2] Different druid models introduced in patch 3.2.0 now work

---
src/game/SpellAuras.cpp |   84 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 74 insertions(+), 10 deletions(-)

diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 263e473..ff07883 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -3029,25 +3029,89 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
            modelid = ssEntry->modelID_A;
        else
        {
-            // players are a bit difficult since the dbc has seldomly an horde modelid
-            // so we add hacks here to set the right model
-            if (Player::TeamForRace(target->getRace()) == ALLIANCE)
-                modelid = ssEntry->modelID_A;
-            else                                            // 3.2.3 only the moonkin form has this information
-                modelid = ssEntry->modelID_H;
+            Player *player = (Player*)target;
+            // The following are the different shapeshifting models for cat/bear forms according
+            // to hair color for druids and skin tone for tauren introduced in patch 3.2
+            if (form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR)
+            {
+                if (player->GetTeam() == ALLIANCE)
+                {
+                    uint8 hairColour = target->GetByteValue(PLAYER_BYTES, 3);
+                    if (form == FORM_CAT)
+                    {
+                        if (hairColour >= 0 && hairColour <= 2) modelid = 29407;
+                        else if (hairColour == 3 || hairColour == 5) modelid = 29405;
+                        else if (hairColour == 6) modelid = 892;
+                        else if (hairColour == 7) modelid = 29406;
+                        else if (hairColour == 4) modelid = 29408;
+                    }
+                    else
+                    {
+                        if (hairColour >= 0 && hairColour <= 2) modelid = 29413;
+                        else if (hairColour == 3 || hairColour == 5) modelid = 29415;
+                        else if (hairColour == 6) modelid = 29414;
+                        else if (hairColour == 7) modelid = 29417;
+                        else if (hairColour == 4) modelid = 29416;
+                    }
+                } 
+                else if (player->GetTeam() == HORDE)
+                {
+                    uint8 skinColour = target->GetByteValue(PLAYER_BYTES, 0);
+                    if (target->getGender() == GENDER_MALE)
+                    {
+                        if (form == FORM_CAT)
+                        {
+                            if (skinColour >= 0 && skinColour <= 5) modelid = 29412;
+                            else if (skinColour >= 6 && skinColour <= 8) modelid = 29411;
+                            else if (skinColour >= 9 && skinColour <= 11) modelid = 29410;
+                            else if (skinColour >= 12 && skinColour <= 14 || skinColour == 18) modelid = 29409;
+                            else if (skinColour >= 15 && skinColour <= 17) modelid = 8571;
+                        }
+                        else
+                        {
+                            if (skinColour >= 0 && skinColour <= 2) modelid = 29418;
+                            else if (skinColour >= 3 && skinColour <= 5 || skinColour >= 12 && skinColour <= 14) modelid = 29419;
+                            else if (skinColour >= 9 && skinColour <= 11 || skinColour >= 15 && skinColour <= 17) modelid = 29420;
+                            else if (skinColour >= 6 && skinColour <= 8) modelid = 2289;
+                            else if (skinColour == 18) modelid = 29421;
+                        }
+                    }
+                    else
+                    {
+                        if (form == FORM_CAT)
+                        {
+                            if (skinColour >= 0 && skinColour <= 3) modelid = 29412;
+                            else if (skinColour == 4 || skinColour == 5) modelid = 29411;
+                            else if (skinColour == 6 || skinColour == 7) modelid = 29410;
+                            else if (skinColour == 8 || skinColour == 9) modelid = 8571;
+                            else if (skinColour == 10) modelid = 29409;
+                        }
+                        else
+                        {
+                            if (skinColour == 0 || skinColour == 1) modelid = 29418;
+                            else if (skinColour == 2 || skinColour == 3) modelid = 29419;
+                            else if (skinColour == 4 || skinColour == 5) modelid = 2289;
+                            else if (skinColour >= 6 && skinColour <= 9) modelid = 29420;
+                            else if (skinColour == 10) modelid = 29421;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                if (player->GetTeam() == ALLIANCE) modelid = ssEntry->modelID_A;
+                else modelid = ssEntry->modelID_H;
+            }

            // no model found, if player is horde we look here for our hardcoded modelids
-            if (!modelid && Player::TeamForRace(target->getRace()) == HORDE)
+            if (!modelid && player->GetTeam() == HORDE)
            {

                switch(form)
                {
                    case FORM_CAT:
-                        modelid = 8571;
-                        break;
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
-                        modelid = 2289;
                        break;
                    case FORM_FLIGHT:
                        modelid = 20872;
-- 
1.7.0.2.msysgit.0

From f74b77f4b5b3f3753a8be050303b1331dcb1b1f4 Mon Sep 17 00:00:00 2001
From: GS <[email protected]>
Date: Mon, 21 Jun 2010 01:41:06 +0300
Subject: [PATCH 2/2] Tauren can change their skintones at the barbershop

---
src/game/CharacterHandler.cpp |   15 ++++++++++++---
src/game/Player.cpp           |   10 +++++++---
src/game/Player.h             |    2 +-
3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 5e4e242..3e962e4 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -1076,8 +1076,16 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
{
    DEBUG_LOG("CMSG_ALTER_APPEARANCE");

-    uint32 Hair, Color, FacialHair;
-    recv_data >> Hair >> Color >> FacialHair;
+    uint32 Hair, Color, FacialHair, SkinTone = 0;
+    if(_player->getRace() != RACE_TAUREN) recv_data >> Hair >> Color >> FacialHair;
+    else
+    {
+        recv_data >> Hair >> Color >> FacialHair >> SkinTone;
+        BarberShopStyleEntry const* bs_skinTone = sBarberShopStyleStore.LookupEntry(SkinTone);
+        if(!bs_skinTone || bs_skinTone->type != 3 || bs_skinTone->race != _player->getRace() || bs_skinTone->gender != _player->getGender())
+            return;
+        SkinTone = bs_skinTone->hair_id;
+    }

    BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);

@@ -1089,7 +1097,7 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    if(!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
        return;

-    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id);
+    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, SkinTone);

    // 0 - ok
    // 1,3 - not enough money
@@ -1114,6 +1122,7 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    _player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id));
    _player->SetByteValue(PLAYER_BYTES, 3, uint8(Color));
    _player->SetByteValue(PLAYER_BYTES_2, 0, uint8(bs_facialHair->hair_id));
+    if(_player->getRace() == RACE_TAUREN) _player->SetByteValue(PLAYER_BYTES, 0, uint8(SkinTone));

    _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index fe43768..5497140 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -20607,7 +20607,7 @@ bool Player::CanCaptureTowerPoint()
           );
}

-uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair)
+uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone)
{
    uint32 level = getLevel();

@@ -20617,8 +20617,10 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);
    uint8 haircolor = GetByteValue(PLAYER_BYTES, 3);
    uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0);
+    uint8 skintone = GetByteValue(PLAYER_BYTES, 0);

-    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair))
+    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) &&
+       (getRace() != RACE_TAUREN || skintone == newskintone))
        return 0;

    GtBarberShopCostBaseEntry const *bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1);
@@ -20636,7 +20638,9 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n

    if(facialhair != newfacialhair)
        cost += bsc->cost * 0.75f;                          // +3/4 of price
-
+    
+    if(skintone != newskintone && getRace() == RACE_TAUREN) // +1/2 of price
+        cost += bsc->cost * 0.5f;
    return uint32(cost);
}

diff --git a/src/game/Player.h b/src/game/Player.h
index 548d464..9c75749 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1136,7 +1136,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        std::string afkMsg;
        std::string dndMsg;

-        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
+        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone);

        PlayerSocial *GetSocial() { return m_social; }

-- 
1.7.0.2.msysgit.0

Untested though :S I lack time and RAM. Please feel free to report any more bugs, and sorry for taking such a long time to develop such a small patch. I'm a newbie :)

Should work as of [10088]

Link to comment
Share on other sites

I care very much, gs94. It's just that I haven't yet had the chance to test your latest offering due to two things:

1. Real life responsibilities have kept me very busy lately

2. I'm slower than a snail jogging in molasses when it comes to patching and compiling a server.

But I'm working on patching up a new compile. Don't give up!

Link to comment
Share on other sites

Heh some hope finally. I do need some feedback, but take your time :)

By the way, I don't think you should test the shapeshift part. The same way has been posted on another thread and has been cancelled because it had hardcoded entries. Just try the barbershop part and tell me.

Link to comment
Share on other sites

Will do, but forgive me if I must sneak a peek at the shape-shifting cosmetics. lol

Sometimes you have to use the hard-coded hacks just to make sure everything is working before you turn attention toward how it should interact with the database.

I know the core devs hate hard-coding anything, but they've done it when they had to. So don't take any criticisms as a final judgement. Though it is preferred to be done a certain way before inclusion into the core, how you reach that point is entirely up to you as the developer.

The retail devs should have made some epic quests for the barbershop. Depending on which one you choose, complete the chain and then be rewarded with unlocking the "Mr. T" or "Ozzy" styles for your character. Could even make achievements out of them... "I Pity Da Fool!" and "You Bit The Head Off Of What??"

Link to comment
Share on other sites

Well me and thenecromancer definitely searched for a DBC way of doing this before thinking about hardcoding. For myself, I couldn't find anything binding those 5 models together. It's highly unlikely for Blizzard to change the models anytime soon. So why not just hardcode it ? :S

Link to comment
Share on other sites

I honestly do not believe there is any relation linking the models together with shared values.

After all, you'd think the Tauren models would have nothing to do with the Night Elf druid forms as they have no common base.

I know it's preferred to have everything stored in the database, but most class spells and pets have to treated as special cases in the code. It seems only logical the druid forms would also have to be coded in such a manner.... unless the entire approach to spells is fundamentally flawed.

If there's no corresponding DBC data to support the assertion that hard-coding values is wrong, then that assertion must then be placed in doubt and it is up to those making their case to defend it with hard data. Simply saying it is wrong does not make it true.

I'd say go with what your eyes and brain tell you. Trust your instincts as a programmer. The code speaks for itself. If it is internally self-consistent, the elegance of simplicity is it's own justification. There is nothing to prevent this patch from using hard-coded values and remain in the Core Mods section until such time as the core devs either prove their argument and require a rewrite or it is discovered your approach is instead the correct one.

So get to work! Druids need love, too. :)

Link to comment
Share on other sites

If there's no corresponding DBC data to support the assertion that hard-coding values is wrong, then that assertion must then be placed in doubt and it is up to those making their case to defend it with hard data. Simply saying it is wrong does not make it true.

Well, it's their decision. They say what's right and what's wrong. I sure hope they look into this the right way.

So get to work! Druids need love, too.

I almost finished mine. The patch just needs testing for now :)

Link to comment
Share on other sites

You've got your first volunteer for further testing, once you feel the code is good enough to go public. :)

It is indeed up to the MaNGOS devs as to what meets the established criteria for inclusion into the core. That's why we have the Core mods section. It is for patches that are either not considered to add a worthy retail-like feature or for works in progress that need further research and refinement.

The Druid Forms Cosmetics patch most definitely falls into that latter category. So please do not hesitate to work upon this patch. The finer details will come in their due course as testing, feedback, research, and further coding is done.

As for the models, I had a thought...

What if the reason there are no corresponding Horde values stored in the DBC is you're looking for the wrong values? Perhaps the Horde druid forms use the same base models and only the parts that are different, such as the Tauren horns, are needed. So what you would look for instead, as an example, are the values that add Tauren horns rather than an entire Tauren model for that form.

I remember a project some guy was working on for Phantasy Star Online. He was creating a model editor/viewer and got stuck until he realized the character models were stored in parts, using a two-dimensional array that referenced the coordinates where the splines were joined to make a whole model. This meant that the head, arms, torso with legs, and feet were matched together depending on what sort of gear the character was wearing. Fairly inefficient versus having basic models and then applying gear separately, but it did save quite a bit on CPU cycles and memory requirements.

Perhaps the racial features of the druid forms are stored and applied just like any other gear would be... Tauren horns might be regarded as a helm, while fur markings would be some sort of shirt.

All of this is pure guesswork on my part and I could be way off base. I work well with ideas, but the technical side of things I'll leave in your capable hands.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use