关灯
开启左侧

临时修改阵营的代码-让玩家在游戏中阵营临时改变

  [复制链接]
admin实名认证 发表于 2016-4-19 22:55:13 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
diff --git a/sql/updates/patchtraitor_characters_characters.sql b/sql/updates/patchtraitor_characters_characters.sqlnew file mode 100644
index 0000000..eb980b7
--- /dev/null
+++ b/sql/updates/patchtraitor_characters_characters.sql
-0,0 +1,2 @@
+ALTER TABLE `characters`
+   ADD COLUMN `faction` int(10) UNSIGNED default 0 AFTER race;
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 9fc50e7..a68d2c9 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
-72,7 +72,7 @@ bool LoginQueryHolder::Initialize()
         "position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost,"
         "resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty,"
         "arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
-        "health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
+        "health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, faction FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP,           "SELECT groupId FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES,  "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS,           "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 034d8e6..458f90d 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
-134,6 +134,7 @@ ChatCommand * ChatHandler::getCommandTable()
         { "deleted",        SEC_GAMEMASTER,     true,  NULL,                                           "", characterDeletedCommandTable},
         { "erase",          SEC_CONSOLE,        true,  &ChatHandler::HandleCharacterEraseCommand,      "", NULL },
         { "level",          SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleCharacterLevelCommand,      "", NULL },
+        { "switchteam",     SEC_GAMEMASTER,     true,  &ChatHandler::HandleCharacterSwitchTeamCommand, "", NULL },
         { "rename",         SEC_GAMEMASTER,     true,  &ChatHandler::HandleCharacterRenameCommand,     "", NULL },
         { "reputation",     SEC_GAMEMASTER,     true,  &ChatHandler::HandleCharacterReputationCommand, "", NULL },
         { "titles",         SEC_GAMEMASTER,     true,  &ChatHandler::HandleCharacterTitlesCommand,     "", NULL },
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 24ac20e..23da045 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
-134,6 +134,7 @@ class ChatHandler
         bool HandleCharacterLevelCommand(const char* args);
         bool HandleCharacterRenameCommand(const char * args);
         bool HandleCharacterReputationCommand(const char* args);
+        bool HandleCharacterSwitchTeamCommand(const char* args);
         bool HandleCharacterTitlesCommand(const char* args);

         bool HandleDebugAnimCommand(const char* args);
diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp
index deeb3a9..1dccb34 100644
--- a/src/game/GuildHandler.cpp
+++ b/src/game/GuildHandler.cpp
-121,6 +121,14 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)

     DEBUG_LOG("Player %s Invited %s to Join his Guild", GetPlayer()->GetName(), Invitedname.c_str());

+    // If player is an enemy of the current player, give warning
+    if (player->GetTeam() != GetPlayer()->GetTeam())
+        if (player->IsInWorld())
+        {
+            player->GetSession()->SendNotification("You have been invited to join an enemy guild.");
+            sWorld.SendServerMessage(SERVER_MSG_STRING, "By joining an enemy guild, you will be a traitor. You will lose your reputation with your people.", player);
+        }
+
     player->SetGuildIdInvited(GetPlayer()->GetGuildId());
     // Put record into guildlog
     guild->LogGuildEvent(GUILD_EVENT_LOG_INVITE_PLAYER, GetPlayer()->GetGUIDLow(), player->GetGUIDLow(), 0);
-205,6 +213,10 @@ void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/)
     guild->LogGuildEvent(GUILD_EVENT_LOG_JOIN_GUILD, GetPlayer()->GetGUIDLow(), 0, 0);

     guild->BroadcastEvent(GE_JOINED, player->GetGUID(), 1, player->GetName(), "", "");
+
+    // If player was an enemy to the current player, change to a traitor
+    if (player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(guild->GetLeader()))
+        player->changeFactionToOpposite(player->getRace());
}

void WorldSession::HandleGuildDeclineOpcode(WorldPacket& /*recvPacket*/)
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 10d4286..7c0e233 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
-3683,6 +3683,28 @@ bool ChatHandler::HandleCharacterReputationCommand(const char* args)
     return true;
}

+bool ChatHandler::HandleCharacterSwitchTeamCommand(const char* args)
+{
+    Player* target;
+    uint64 target_guid;
+    std::string target_name;
+    if(!extractPlayerTarget((char*)args,&target,&target_guid,&target_name))
+        return false;
+
+    if(target)
+    {
+        PSendSysMessage("You changed teams for player %s.", GetNameLink(target).c_str());
+        target->changeFactionToOpposite(target->getRace());
+    }
+    else
+    {
+        PSendSysMessage(LANG_NO_CHAR_SELECTED);
+        return false;
+    }
+
+    return true;
+}
+
//change standstate
bool ChatHandler::HandleModifyStandStateCommand(const char* args)
{
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 2579242..fcd9b70 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
-1542,16 +1542,20 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(const uint64 &guid) const
     // prevent DB access for online player
     if(Player* player = GetPlayer(guid))
     {
-        return Player::TeamForRace(player->getRace());
+        return player->GetTeam();
     }

-    QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
+    QueryResult *result = CharacterDatabase.PQuery("SELECT race, faction FROM characters WHERE guid = '%u'", GUID_LOPART(guid));

     if(result)
     {
         uint8 race = (*result)[0].GetUInt8();
+        uint8 faction = (*result)[1].GetUInt32();
         delete result;
-        return Player::TeamForRace(race);
+        if ( (faction != 0) && (faction != Player::getFactionForRace(race)) )
+            return Player::TeamForRace(Player::getOppositeRace(race));
+        else
+            return Player::TeamForRace(race);
     }

     return 0;
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 490536c..4d223f9 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
-472,6 +472,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
     m_GuildIdInvited = 0;
     m_ArenaTeamIdInvited = 0;

+    m_faction = 0;
+
     m_atLoginFlags = AT_LOGIN_NONE;

     mSemaphoreTeleport_Near = false;
-6221,10 +6223,110 @@ uint32 Player::getFactionForRace(uint8 race)
     return rEntry->FactionID;
}

+/**
+ * Gets the opposite race of the given race
+ *
+ * @param race the race to get the opposite of
+ * @returns the opposite race
+ *
+ */
+uint8 Player::getOppositeRace(uint8 race)
+{
+    switch(race)
+    {
+        case RACE_HUMAN         : return RACE_ORC;
+        case RACE_ORC           : return RACE_HUMAN;
+        case RACE_DWARF         : return RACE_UNDEAD_PLAYER;
+        case RACE_UNDEAD_PLAYER : return RACE_DWARF;
+        case RACE_NIGHTELF      : return RACE_TAUREN;
+        case RACE_TAUREN        : return RACE_NIGHTELF;
+        case RACE_GNOME         : return RACE_TROLL;
+        case RACE_TROLL         : return RACE_GNOME;
+        case RACE_DRAENEI       : return RACE_BLOODELF;
+        case RACE_BLOODELF      : return RACE_DRAENEI;
+    }
+
+    sLog.outError("Race %u not found", uint32(race));
+    return RACE_HUMAN;
+}
+
+/**
+ * Changes the player's faction and notifies
+ *
+ * @param race the race of the player
+ *
+ */
+void Player::changeFactionToOpposite(uint8 race)
+{
+    uint8 raceto;
+
+    // determine which race to use as a base
+    if (IsTraitor())
+        raceto = race;
+    else
+        raceto = getOppositeRace(race);
+
+    // set reputation to base defaults for current race
+    m_reputationMgr.SetBaseDefaults();
+
+    // change race faction and team
+    m_faction = getFactionForRace( raceto );
+    setFactionForRace( race );
+
+    // set reputation to base defaults for new race faction
+    m_reputationMgr.SetBaseDefaults();
+
+    // send reputation to client to allow it properly work without a relogin
+    m_reputationMgr.SendInitialReputations();
+    m_reputationMgr.SendStates();
+
+    // add team languages
+    // although client doesn't allow them to be used
+    if(!IsInWorld())
+    {
+        addSpell(668, true, true, true, false);
+        addSpell(669, true, true, true, false);
+    }
+    else
+    {
+        learnSpell(668, true);
+        learnSpell(669, true);
+    }
+
+    DEBUG_LOG("PLAYER changed to opposite (Class: %u Race: %u)", uint32(getClass()), uint32(raceto));
+
+    // build message to let everyone know
+    std::string strmessage = GetName();
+    if (IsTraitor())
+        strmessage += " is a traitor and switched to the ";
+    else
+        strmessage += " is a double traitor and switched back to the ";
+
+    if (GetTeam() == ALLIANCE)
+        strmessage += "Alliance";
+    else
+        strmessage += "Horde";
+    strmessage += "!";
+
+    // send messages to all players and current player
+    sWorld.SendServerMessage(SERVER_MSG_STRING, strmessage.c_str());
+    sWorld.SendServerMessage(SERVER_MSG_STRING, "You are a traitor! Your reputation has been lost with your people.", this);
+}
+
void Player::setFactionForRace(uint8 race)
{
-    m_team = TeamForRace(race);
-    setFaction( getFactionForRace(race) );
+    uint8 temprace;
+    temprace = race;
+
+    // Does the faction match for the given race; IsTraitor
+    if ( (m_faction != 0) && (m_faction != getFactionForRace(race)) )
+    {
+        temprace = getOppositeRace(race);
+    }
+
+    m_team = TeamForRace(temprace);
+    m_faction = getFactionForRace(temprace);
+    setFaction( m_faction );
}

ReputationRank Player::GetReputationRank(uint32 faction) const
-14942,8 +15044,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
     //"resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty,"
     // 39           40                41                42                    43          44          45              46           47               48              49
     //"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
-    // 50      51      52      53      54      55      56      57      58         59          60             61              62      63           64
-    //"health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars  FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
+    // 50      51      52      53      54      55      56      57      58         59          60             61              62      63           64          65
+    //"health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, faction  FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
     QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);

     if(!result)
-15034,6 +15136,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )

     //Need to call it to initialize m_team (m_team can be calculated from race)
     //Other way is to saves m_team into characters table.
+    m_faction = fields[65].GetUInt32();
     setFactionForRace(getRace());
     SetCharm(NULL);

-16634,7 +16737,7 @@ void Player::SaveToDB()
         "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, "
         "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, "
         "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, "
-        "power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars) VALUES ("
+        "power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, faction) VALUES ("
         << GetGUIDLow() << ", "
         << GetSession()->GetAccountId() << ", '"
         << sql_name << "', "
-16756,6 +16859,9 @@ void Player::SaveToDB()
     }
     ss << "',";
     ss << uint32(GetByteValue(PLAYER_FIELD_BYTES, 2));
+
+    ss << ",";
+    ss << uint32(m_faction);
     ss << ")";

     CharacterDatabase.Execute( ss.str().c_str() );
diff --git a/src/game/Player.h b/src/game/Player.h
index 548d464..d6d97d4 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
-1955,7 +1955,16 @@ class MANGOS_DLL_SPEC Player : public Unit
         static uint32 TeamForRace(uint8 race);
         uint32 GetTeam() const { return m_team; }
         static uint32 getFactionForRace(uint8 race);
+        static uint8 getOppositeRace(uint8 race);
+        /// Gets the player's actual RaceMask in case of traitor
+        uint32 getRaceMaskReal() const { return 1 << (getRace()-1); }
+        /// Gets the player's opposite RaceMask to determine reputation difference
+        uint32 getRaceMaskOpposite() const { return 1 << (Player::getOppositeRace(getRace())-1); }
+        /// Changes the player's faction to the opposing side
+        void changeFactionToOpposite(uint8 race);
         void setFactionForRace(uint8 race);
+        /// Check if the player is a traitor
+        bool IsTraitor() const { return m_team == TeamForRace( getOppositeRace(getRace()) ); }

         void InitDisplayIds();

-2454,6 +2463,7 @@ class MANGOS_DLL_SPEC Player : public Unit
         ObjectGuid m_lootGuid;

         uint32 m_team;
+        uint32 m_faction;
         uint32 m_nextSave;
         time_t m_speakTime;
         uint32 m_speakCount;
diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp
index d0d7c2f..1aa9211 100644
--- a/src/game/ReputationMgr.cpp
+++ b/src/game/ReputationMgr.cpp
-48,6 +48,19 @@ int32 ReputationMgr::GetReputation(uint32 faction_id) const
     return GetReputation(factionEntry);
}

+int32 ReputationMgr::GetBaseReputation(uint32 faction_id) const
+{
+    FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
+
+    if (!factionEntry)
+    {
+        sLog.outError("ReputationMgr::GetBaseReputation: Can't get reputation of %s for unknown faction (faction id) #%u.",m_player->GetName(), faction_id);
+        return 0;
+    }
+
+    return GetBaseReputation(factionEntry);
+}
+
int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const
{
     if (!factionEntry)
-55,12 +68,100 @@ int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const

     uint32 raceMask = m_player->getRaceMask();
     uint32 classMask = m_player->getClassMask();
-    for (int i=0; i < 4; i++)
+
+    if (m_player->IsTraitor())
     {
-        if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
-            (factionEntry->BaseRepClassMask[i]==0 ||
-            (factionEntry->BaseRepClassMask[i] & classMask) ) )
-            return factionEntry->BaseRepValue[i];
+        uint32 raceMaskReal = m_player->getRaceMaskReal();
+
+        for (int i=0; i < 4; i++)
+        {
+            if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
+                (factionEntry->BaseRepClassMask[i]==0 ||
+                (factionEntry->BaseRepClassMask[i] & classMask) ) )
+                return factionEntry->BaseRepValue[i];
+        }
+    }
+    else
+    {
+        for (int i=0; i < 4; i++)
+        {
+            if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
+                (factionEntry->BaseRepClassMask[i]==0 ||
+                (factionEntry->BaseRepClassMask[i] & classMask) ) )
+                return factionEntry->BaseRepValue[i];
+        }
+    }
+
+    // in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0
+    return 0;
+}
+
+/**
+ * Gets the FactionEntry from the faction_id and returns the difference
+ * of the opposite race's reputation for it.
+ *
+ * @param faction_id the id number of the faction to be returned.
+ * @returns the difference between the opposing races reputation.
+ *
+ */
+int32 ReputationMgr::GetBaseReputationDifference(uint32 faction_id) const
+{
+    FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
+
+    if (!factionEntry)
+    {
+        sLog.outError("ReputationMgr::GetBaseReputationOpposite: Can't get reputation of %s for unknown faction (faction id) #%u.",m_player->GetName(), faction_id);
+        return 0;
+    }
+
+    return GetBaseReputationDifference(factionEntry);
+}
+
+/**
+ * Gets the current race's difference of reputation of the
+ * factionEntry and the opposite race's reputation.
+ *
+ * @param factionEntry the faction to be returned.
+ * @returns the difference between the opposing races reputation.
+ *
+ */
+int32 ReputationMgr::GetBaseReputationDifference(FactionEntry const* factionEntry) const
+{
+    if (!factionEntry)
+        return 0;
+
+    uint32 raceMask = m_player->getRaceMask();
+    uint32 classMask = m_player->getClassMask();
+
+    if (m_player->IsTraitor())
+    {
+        uint32 raceMaskReal = m_player->getRaceMaskReal();
+
+        for (int i=0; i < 4; i++)
+        {
+            if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
+                (factionEntry->BaseRepClassMask[i]==0 ||
+                (factionEntry->BaseRepClassMask[i] & classMask) ) )
+            {
+                for (int ri=0; ri < 4; ri++)
+                {
+                    if( (factionEntry->BaseRepRaceMask[ri] & raceMaskReal) &&
+                        (factionEntry->BaseRepClassMask[ri]==0 ||
+                        (factionEntry->BaseRepClassMask[ri] & classMask) ) )
+                        return factionEntry->BaseRepValue[i] - factionEntry->BaseRepValue[ri];
+                }
+            }
+        }
+    }
+    else
+    {
+        for (int i=0; i < 4; i++)
+        {
+            if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
+                (factionEntry->BaseRepClassMask[i]==0 ||
+                (factionEntry->BaseRepClassMask[i] & classMask) ) )
+                return factionEntry->BaseRepValue[i];
+        }
     }

     // in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0
-133,13 +234,17 @@ void ReputationMgr::SendState(FactionState const* faction) const
{
     if(faction->Flags & FACTION_FLAG_VISIBLE)               //If faction is visible then update it
     {
+        int32 standing = faction->Standing;
+        if (m_player->IsTraitor())
+            standing += GetBaseReputationDifference(faction->ID);
+
         WorldPacket data(SMSG_SET_FACTION_STANDING, (16));  // last check 2.4.0
         data << (float) 0;                                  // unk 2.4.0
         data << (uint8) 0;                                  // wotlk 8634
         data << (uint32) 1;                                 // count
         // for
         data << (uint32) faction->ReputationListID;
-        data << (uint32) faction->Standing;
+        data << (uint32) standing;
         // end for
         m_player->SendDirectMessage(&data);
     }
-154,6 +259,10 @@ void ReputationMgr::SendInitialReputations()

     for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
     {
+        int32 standing = itr->second.Standing;
+        if (m_player->IsTraitor())
+            standing += GetBaseReputationDifference(itr->second.ID);
+
         // fill in absent fields
         for (; a != itr->first; a++)
         {
-163,7 +272,7 @@ void ReputationMgr::SendInitialReputations()

         // fill in encountered data
         data << uint8  (itr->second.Flags);
-        data << uint32 (itr->second.Standing);
+        data << uint32 (standing);

         ++a;
     }
-226,6 +335,45 @@ void ReputationMgr::Initialize()
     }
}

+/**
+ * This method is called to set the defaults for the originally visible, at peace,
+ * at war, or invisible for the current race.
+ *
+ */
+void ReputationMgr::SetBaseDefaults()
+{
+    for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
+    {
+        FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
+
+        if( factionEntry && (factionEntry->reputationListID >= 0))
+        {
+            FactionState* faction = &m_factions[factionEntry->reputationListID];
+            uint32 defaultFlags = GetDefaultStateFlags(factionEntry);
+
+            // if faction matches any flags then update
+            // this resets the default standings to 0, should be better way for this
+            if( (defaultFlags & FACTION_FLAG_VISIBLE) ||
+                (defaultFlags & FACTION_FLAG_INVISIBLE_FORCED) ||
+                (defaultFlags & FACTION_FLAG_AT_WAR) ||
+                (defaultFlags & FACTION_FLAG_PEACE_FORCED) )
+            {
+                if (faction->Standing != 0)
+                {
+                    faction->Standing = 0;
+                    faction->Changed = true;
+                }
+
+                if (faction->Flags != defaultFlags)
+                {
+                    faction->Flags = defaultFlags;
+                    faction->Changed = true;
+                }
+            }
+        }
+    }
+}
+
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
     SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
diff --git a/src/game/ReputationMgr.h b/src/game/ReputationMgr.h
index 37d4312..1235dec 100644
--- a/src/game/ReputationMgr.h
+++ b/src/game/ReputationMgr.h
-87,9 +87,41 @@ class ReputationMgr
             return repItr != m_factions.end() ? &repItr->second : NULL;
         }

+        /**
+         * Gets the FactionEntry from the faction_id and returns the reputation for it.
+         *
+         * @param faction_id the id number of the faction to be returned.
+         *
+         */
         int32 GetReputation(uint32 faction_id) const;
         int32 GetReputation(FactionEntry const* factionEntry) const;
+        /**
+         * Gets the FactionEntry from the faction_id and returns the base reputation for it.
+         *
+         * @param faction_id the id number of the faction to be returned.
+         * @returns the base reputation.
+         *
+         */
+        int32 GetBaseReputation(uint32 faction_id) const;
         int32 GetBaseReputation(FactionEntry const* factionEntry) const;
+        /**
+         * Gets the FactionEntry from the faction_id and returns the difference
+         * of the opposite race's reputation for it.
+         *
+         * @param faction_id the id number of the faction to be returned.
+         * @returns the difference between the opposing races reputation.
+         *
+         */
+        int32 GetBaseReputationDifference(uint32 faction_id) const;
+        /**
+         * Gets the current race's difference of reputation of the
+         * factionEntry and the opposite race's reputation.
+         *
+         * @param factionEntry the faction to be returned.
+         * @returns the difference between the opposing races reputation.
+         *
+         */
+        int32 GetBaseReputationDifference(FactionEntry const* factionEntry) const;

         ReputationRank GetRank(FactionEntry const* factionEntry) const;
         ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
-117,6 +149,8 @@ class ReputationMgr

         void ApplyForceReaction(uint32 faction_id,ReputationRank rank,bool apply);

+        void SetBaseDefaults();
+
     public:                                                 // senders
         void SendInitialReputations();
         void SendForceReactions();
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 3bc6524..e092646 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
-3031,13 +3031,13 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
         {
             // 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)
+            if (((Player*)target)->GetTeam() == ALLIANCE)
                 modelid = ssEntry->modelID_A;
             else                                            // 3.2.3 only the moonkin form has this information
                 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*)target)->GetTeam() == HORDE)
             {

                 switch(form)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index a280dd8..cb4b762 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
-11661,6 +11661,19 @@ uint32 Unit::GetCreatureType() const
         return ((Creature*)this)->GetCreatureInfo()->type;
}

+uint32 Unit::getRaceMask() const
+{
+    if (GetTypeId() == TYPEID_PLAYER)
+    {
+        if (getFaction() != Player::getFactionForRace(getRace()))
+            return 1 << (Player::getOppositeRace(getRace())-1);
+        else
+            return 1 << (getRace()-1);
+    }
+    else
+        return 1 << (getRace()-1);
+}
+
/*#######################################
########                         ########
########       STAT SYSTEM       ########
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 76533ff..e27f04c 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
-1174,7 +1174,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
         virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); }
         void SetLevel(uint32 lvl);
         uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); }
-        uint32 getRaceMask() const { return 1 << (getRace()-1); }
+        uint32 getRaceMask() const;
         uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
         uint32 getClassMask() const { return 1 << (getClass()-1); }
         uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }

标签:游戏
 

精彩评论2

倒序浏览
13188082775 发表于 2021-9-2 19:07:28 | 显示全部楼层
 
谢谢大大,请问这代码怎么用呢?
 
我回来了 发表于 2016-12-5 12:50:02 | 显示全部楼层
 
感谢楼主分享,祝愿吾爱尚玩越来越好!
 
VIP介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 最佳新人

    注册账号后积极发帖的会员
  • 活跃会员

    经常参与各类话题的讨论,发帖内容较有主见
  • 热心会员

    经常帮助其他会员答疑
  • 推广达人

    积极宣传本站,为本站带来更多注册会员
  • 宣传达人

    积极宣传本站,为本站带来更多的用户访问量
  • 灌水之王

    经常在论坛发帖,且发帖量较大
  • 突出贡献

    长期对论坛的繁荣而不断努力,或多次提出建设性意见
  • 优秀版主

    活跃且尽责职守的版主
  • 荣誉管理

    曾经为论坛做出突出贡献目前已离职的版主
  • 论坛元老

    为论坛做出突出贡献的会员

0关注

5粉丝

3421帖子

排行榜
作者专栏

QQ交流群&&微信订阅号

QQ交流群

微信订阅号

吾爱尚玩资源基地永久域名:

Www.523Play.Com

在线管理员QQ:1589479632

邮箱:Email@523play.com

QQ交流群:558936238

Copyright   ©2015-2116  吾爱尚玩资源基地|523play.comPowered by©523Pplay.Com技术支持:吾爱尚玩资源基地