This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [SOLVED] [QUESTION:WotlK] Third faction problem  (Read 2079 times)

Semga

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 6
    • View Profile
[SOLVED] [QUESTION:WotlK] Third faction problem
« on: October 25, 2015, 06:03:24 pm »
Hello. So, I wanted to exclude night elves from Alliance team and create a separate team for them.
Firstly, I added a team in FactionGroup.dbc, here is the result:
 

 
Secondly, I edited ChrRaces.dbc, changed teamID in 8th column to 2 for night elves. As far as I understand, this value will be later used on server in Player.cpp method uint32 Player::TeamForRace, but let’s talk about that later.
So ChrRaces.dbc here:

 
Then I edited Faction.dbc:  removed Alliance racemasks from night elves faction 69 Darnas and removed night elves racemask from all alliance factions like Stormwind, Alliance and etc. Edited hostile races masks and friendly racemasks. Set parentFactionId to 1161(my new faction category, it’s a copy of Alliance faction category except for changed name and friendly/enemy racemasks and changed reputationIndex(2th column)). There is no problem here. Just for example, faction 69 looks like:

1783 - racemask of all races without nelfs and 8 - night elves.
Next, FactionTemplate.dbc. Parsed it and added to Hostile factionGroup mask(6th column) my new factionGroup mask 16 for Kaldorei, where Alliance faction is presented as hostile. Then edited player factionTemplate with id 4 which goes for night elves players. Changed FightSupport(4th column) to 17(As far as I understand, it’s a mask from FactionGroup which means 1+16 where 1 - Player, 16 - Kaldorei. For example for Horde player(orc) we have 1+4 and for human 1+2). Friendly mask(5th column) edited to 16 and enemy hostile mask to 14(which is 2(Alliance)+4(Horde)+8(Monsters)).
 
Okay, a bit about the core.
Added new data to enums

Changed Player class method TeamForRace(added new case)
uint32 Player::TeamForRace(uint8 race)
{
    if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race))
    {
        switch (rEntry->TeamID)
        {
            case 1: return HORDE;
            case 2: return NELF; // ADDED MY CASE HERE
            case 7: return ALLIANCE;
        }
        TC_LOG_ERROR("entities.player", "Race (%u) has wrong teamid (%u) in DBC: wrong DBC files?", uint32(race), rEntry->TeamID);
    }
    else
        TC_LOG_ERROR("entities.player", "Race (%u) not found in DBC: wrong DBC files?", uint32(race));
 
    return ALLIANCE;
}
 
And ofc changed const method GetTeamId()
 
TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : m_team == HORDE ? TEAM_HORDE : TEAM_NELF; }
 
So... Now my problem: everything works fine except that I can’t create a night elf character because client GlueXML does not create a button for night elves. Reason goes to CharacterCreate.lua file where lua function CharacterCreateEnumerateRaces() being called with lua funciton GetAvailableRaces() as params. So GetAvailableRaces() returns all needed races exept night elves. I see no reason why this is happening because if I try to create a night elf without a patched FactionTemplate.dbc on client and then set patched dbc back and try to play as night elf created before everything works as it should in every damn aspect.
After some research I came to conclusion that problem source is FightSupport(4th column) in FactionTemplate. As I told before, I set it to 17 as it should be for night elf player factiontemplate with id 4, as I described before too. But that’s also the reason it doesn’t work.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Semga

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 6
    • View Profile
Re: [SOLVED] [QUESTION:WotlK] Third faction problem
« Reply #1 on: January 04, 2017, 04:40:43 am »
Took me a lot of time to find the issue. FactionTemplate.dbc fields 3, 4, 5 can have values with byte size and maybe even more... Here it comes. Client read each of them as byte(or more) but checks made out in function 4E1880(GetAvailableRaces) are made only on 4 bits. So you can have only 4 factions. In every other place client stores and checks it properly, so it's still possible to implement factions in somekind hacky way with client memory writing/client patching. Custom factions still CAN be done for NPCs easily. By factions I mean FactionGroups(Horde and etc).
Hope this helps someone and it won't take so much time for someone to find it out by himself. And feel free to point me out if I am wrong.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Semga

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 6
    • View Profile
Re: [SOLVED] [QUESTION:WotlK] Third faction problem
« Reply #2 on: February 28, 2017, 02:50:28 pm »
After some time spend on the issue again: I have been wrong with the function. Problem with races comes in function(this time I am 100% sure) on address 0x004E1C20. It runs through races and factiongroups and devides them by Alliance or Horde. If race has other faction than those two hardcoded, then race marked as unavalible for creation.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Barbz

  • Registred Member
  • LUA Script Tinker
  • *****
  • Posts: 48
    • View Profile
    • YHOOL
Re: [SOLVED] [QUESTION:WotlK] Third faction problem
« Reply #3 on: April 11, 2017, 07:18:39 pm »
This is interesting but it shouldn't be "[SOLVED]".

Смердокрыл

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 445
    • View Profile
Re: [SOLVED] [QUESTION:WotlK] Third faction problem
« Reply #4 on: April 17, 2017, 03:41:31 pm »
Those banners look familiar, yet they aren't in the game files. I wonder, where did you get them?
or no.
At least I tried.