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: [QUESTION] Trinity C++ Mod for third faction and C++ syntax  (Read 3521 times)

canabalt

  • Registred Member
  • MWCS Enthusiast
  • *****
  • Posts: 2
    • View Profile
[QUESTION] Trinity C++ Mod for third faction and C++ syntax
« on: March 21, 2013, 02:47:58 pm »
Hi Modcraft, i am sorry to trouble you with yet another "help i dont understand this basic problem and need others to spoonfeed me the answer" but the shoutbox is down, so i cannot voice my simple problem on there in the hopes somebody notices.

I have been Attempting to modify Trinitys' source to allow for the addition of a Third Faction, in this case called in-code as TEAM_NEUTRAL and while i understand the most basic of basic of basic c++, and have modified trinity a basic amount, i am still rather useless at certain parts.
namely these lines of code for the determining of a characters TeamId.

    static uint32 TeamForRace(uint8 race);
            uint32 GetTeam() const { return m_team; }
            TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
            void setFactionForRace(uint8 race);

The line in question i am confused about is
    TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }

Because c++ uses the boolean conditional operator (Variable == X ? X : Y) i am unable to turn this statement into an operator that handles interger values.
(I am thrown off with the whole const { return X } part and do not know were to put the if/else if statements)

How would i go about changing it so instead it goes something like:

    TeamId GetTeamId() const { return m_team;
        if (m_team == ALLIANCE)
                       TEAM_ALLIANCE;
                       else if (m_team == HORDE)
                       TEAM_HORDE;
                        else
                       TEAM_NEUTRAL;

(Except works)
So that it allows me to input a third value if m_team throws a value besides horde/alliance faction IDs
and without Visual Studio sezureing at my poor ability to syntax and inability to go from uint32 to constant.

Thanks for any help, and sorry if this thread is either lacking in information required to help, or just plain hard to understand/inconvenient.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #1 on: March 21, 2013, 02:52:48 pm »
Something like this would work:

Code: [Select]
TeamId GetTeamId() const {
if (m_team == ALLIANCE)
return TEAM_ALLIANCE;
else if (m_team == HORDE)
return TEAM_HORDE;
else if (m_team == NEUTRAL)
return TEAM_NEUTRAL;
}

Since:

Code: [Select]
TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE;

Returns TEAM_ALLIANCE if the condition is true, else it returns TEAM_HORDE.

Teams are handled client side as well, a lot of modifications are going to be required to get a new 'team' implemented properly I think, though I haven't researched the matter greatly.

What I did is had a new boolean in the player class handling whether the player was a neutral race, then set them to a friendly faction and such.

edit: Skim-read thread, you already had this except. If it's moaning about it being a constant function when returning values, just remove the constant part. It doesn't need to be, just makes things more efficient.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #2 on: March 22, 2013, 08:57:45 am »
Would it be possible to just recode the stuff so we can have teams defined from DBC or MySQL and no need to hack around in code every time. This would also be a good goal for all the rest like races or classes or whatever.

Like a modding core. And perhaps Trinity will take back the patches and merg in main core.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #3 on: March 22, 2013, 11:57:31 am »
Quote from: "Steff"
Would it be possible to just recode the stuff so we can have teams defined from DBC or MySQL and no need to hack around in code every time. This would also be a good goal for all the rest like races or classes or whatever.

Like a modding core. And perhaps Trinity will take back the patches and merg in main core.

It's a confusing one. Trinity and Mangos both aim to emulate Blizzard as far as possible, replicating the same procedures to create an almost identical server. They do not really support the addition or modification of existing data. So they wouldn't accept such changes.

It's just a bit hypocritical of them to act this way and still only partially load data from DBC's - much more could be retrieved from there rather than the database.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

deep6ixed

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 189
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #4 on: March 22, 2013, 10:47:19 pm »
I don't understand that either.  One of the latest revisions on trinity core hard codes the talent tabs directly into the core.  Why would you do that?  Every time Blizz moves talents around, you would have to then patch the code.  

Ah well, we do what we must I guess.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #5 on: March 22, 2013, 11:39:50 pm »
Quote from: "deep6ixed"
I don't understand that either.  One of the latest revisions on trinity core hard codes the talent tabs directly into the core.  Why would you do that?  Every time Blizz moves talents around, you would have to then patch the code.  

Ah well, we do what we must I guess.
Trinity is not concepted to be used for modded private servers. It's supposed to be easily modifyable, but we have different approaches and desires to what the developers intend to enable. Beside, that they try to have it as "learning project", officially.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #6 on: March 23, 2013, 10:38:56 am »
Will try to talk again to some devs and see theirs points :) Lets see what we can do .
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #7 on: March 23, 2013, 12:44:22 pm »
Quote from: "Steff"
Will try to talk again to some devs and see theirs points :) Lets see what we can do .
If you have devs that can do the script, all you have to do is make a functioning code and PR it. If it works properly and makes it easier, it gets included. Simple as that.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #8 on: March 23, 2013, 01:19:29 pm »
The idea was to make together modding related changes on an own core fork and then send the patches to trinity devs.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #9 on: March 23, 2013, 01:24:43 pm »
Quote from: "Steff"
The idea was to make together modding related changes on an own core fork and then send the patches to trinity devs.
That would work.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

canabalt

  • Registred Member
  • MWCS Enthusiast
  • *****
  • Posts: 2
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #10 on: March 25, 2013, 01:16:45 pm »
Thanks StoneHarry, that fixed my problem. unfortunatly i still must have done something wrong with all the other variables and functions i needed to edit and while it compiles and runs, it still doesnt have the desired effect im aiming for.

Also yes i am aware i need to modify client files aswell, i managed to (using arcemu, not trinity) simulate a pseudo-third faction by editing the Faction, FactionTemplate and FactionGroup DBCs by creating a third faction in FactionGroup.DBC and then adding a custom entry in Faction.DBC based off the  [Player, Human] entry ID and then add bitmasks that suit this third entry into Faction.DBC and FactionTemplate.DBC.

But the problem lies in the fact that it behaves just like an alliance character when it comes to the chat, party and who list, so ill have to do a bit more work.

Also on an unrelated note, ive been messing around with the addition of a third useable resource (ie mana) based off mana and while i can make the changes to the core easily and even edit PlayerFrames.lua and .xml to 'show' what/were the bar should be, im having trouble making the text show and acknowledge the number of that resource.

Is there anyway i can get the client to communicate with the server to retrieve this quantity? i believe that mana is retieved through the API event UNIT_MAXMANA in Playerframes, but in the case of a third resource i would need to create my own ie. UNIT_RESOURCE3, is there a way to do such a thing?
I am almost certain there is an easy way to have this third resource shown, but im a bit dumb when it comes to scripting, any ideas?

PS: Sorry for my 4 day late reply, i have been busy with uni work.
PPS: Also sorry for the long posts, im not used to posting online.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] Trinity C++ Mod for third faction and C++ syn
« Reply #11 on: March 26, 2013, 11:37:01 pm »
Quote from: "canabalt"
Thanks StoneHarry, that fixed my problem. unfortunatly i still must have done something wrong with all the other variables and functions i needed to edit and while it compiles and runs, it still doesnt have the desired effect im aiming for.

Also yes i am aware i need to modify client files aswell, i managed to (using arcemu, not trinity) simulate a pseudo-third faction by editing the Faction, FactionTemplate and FactionGroup DBCs by creating a third faction in FactionGroup.DBC and then adding a custom entry in Faction.DBC based off the  [Player, Human] entry ID and then add bitmasks that suit this third entry into Faction.DBC and FactionTemplate.DBC.

But the problem lies in the fact that it behaves just like an alliance character when it comes to the chat, party and who list, so ill have to do a bit more work.

Also on an unrelated note, ive been messing around with the addition of a third useable resource (ie mana) based off mana and while i can make the changes to the core easily and even edit PlayerFrames.lua and .xml to 'show' what/were the bar should be, im having trouble making the text show and acknowledge the number of that resource.

Is there anyway i can get the client to communicate with the server to retrieve this quantity? i believe that mana is retieved through the API event UNIT_MAXMANA in Playerframes, but in the case of a third resource i would need to create my own ie. UNIT_RESOURCE3, is there a way to do such a thing?
I am almost certain there is an easy way to have this third resource shown, but im a bit dumb when it comes to scripting, any ideas?

PS: Sorry for my 4 day late reply, i have been busy with uni work.
PPS: Also sorry for the long posts, im not used to posting online.

Ah, I did not think as far ahead as to consider the effects of how people would display on who etc. The client requests this information and the server sends it to them - I guess you cold filter it manually for characters that are flagged as neutral.

As far as a third resource go, I do not know if you could implement it the same way the original resources are handled. You could hack fix it by using invisible addon messages and sending messages like "[SMSG] UpdateResource3 1000" and have the client react to that. However, that is incredible hacky.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »