Change Faction Items

Hi, i want to ask if there is any way to change items from alliance to horde, when is looted.

ETC: In Trial of the Crusader u have different loot for alliance and horde. I have interaction.group enabled. I want to ask, how to change item from alliance to horde. When first player enter as horde, the dungeon is horde, and loot too.

Is there any way to call something like player_factionchange_items, when player changing his faction.

I tried this.

diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 4fe38f1…a105640 100644
— a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -25491,6 +25491,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
if (loot->containerID > 0)
loot->DeleteLootItemFromContainerItemDB(item->itemid);

  •    GetSession()->CrossFactionItem();
    
    }
    else
    SendEquipError(msg, NULL, NULL, item->itemid);
    diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
    index 7f71b65…6f90a74 100644
    — a/src/server/game/Handlers/CharacterHandler.cpp
    +++ b/src/server/game/Handlers/CharacterHandler.cpp
    @@ -2157,3 +2157,24 @@ void WorldSession::SendBarberShopResult(BarberShopResult result)
    data << uint32(result);
    SendPacket(&data);
    }

+void WorldSession::CrossFactionItem()
+{

  • CharacterFactionChangeInfo factionChangeInfo;
  • TeamId team = TEAM_ALLIANCE;
  • uint32 lowGuid = factionChangeInfo.Guid.GetCounter();
  • SQLTransaction trans = CharacterDatabase.BeginTransaction();
  • // Item conversion
  • for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeItems.begin(); it != sObjectMgr->FactionChangeItems.end(); ++it)
  • {
  •    uint32 item_alliance = it->first;
    
  •    uint32 item_horde = it->second;
    
  •    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE);
    
  •    stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde));
    
  •    stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance));
    
  •    stmt->setUInt32(2, lowGuid);
    
  •    trans->Append(stmt);
    
  • }
    +}
    diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
    index 2035261…bd9e1fa 100644
    — a/src/server/game/Server/WorldSession.h
    +++ b/src/server/game/Server/WorldSession.h
    @@ -463,6 +463,7 @@ class WorldSession
    void SendCharFactionChange(ResponseCodes result, CharacterFactionChangeInfo const& factionChangeInfo);
    void SendSetPlayerDeclinedNamesResult(DeclinedNameResult result, ObjectGuid guid);
    void SendBarberShopResult(BarberShopResult result);
  •    void CrossFactionItem();
    
       // played time
       void HandlePlayedTime(WorldPacket& recvPacket);
    

But it not works. And need to change to only item what is looted, to change faction if is needed.