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:Wrath]  New Dungeon Difficulty  (Read 4422 times)

Nupper

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 339
    • View Profile
[QUESTION:Wrath]  New Dungeon Difficulty
« on: August 06, 2016, 09:26:23 pm »
I found code for a third Dungeon Difficulty in the client i was woundering how i could enable it on trinitycore.

Code: [Select]
DUNGEON_DIFFICULTY3 = "Epic (Unused)";
Code: [Select]
UnitPopupButtons["DUNGEON_DIFFICULTY3"] = { text = DUNGEON_DIFFICULTY3, dist = 0 };
I managed to make it visable in-game but atm the button is a dud (I renamed it to Mythic) :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #1 on: August 06, 2016, 11:21:22 pm »
In worldserver.conf, I enabled network debug logging by setting this value:
Code: [Select]
Logger.network=2,Console Server
With this, any time the server runs WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) (in gameHandlersMiscHandlers.cpp), it prints some debug info in the worldserver console. Then I used /run SetDungeonDifficulty(#). It worked for values of 1 and 2 (normal and heroic), but it didn't seem to send anything to the server with a difficulty value of 3.

That means you probably need to use AIO to send a request to set dungeon difficulty to 3. Hopefully you don't need to otherwise mess with the client to fix the unused difficulty. TrinityCore should be able to set your difficulty to 3 if it receives the request. You'll also need to increment the MAX_DUNGEON_DIFFICULTY constant. Not sure what else you'd need.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Nupper

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 339
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #2 on: August 06, 2016, 11:34:01 pm »
Quote from: "Grymskvll"
In worldserver.conf, I enabled network debug logging by setting this value:
Code: [Select]
Logger.network=2,Console Server
With this, any time the server runs WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) (in gameHandlersMiscHandlers.cpp), it prints some debug info in the worldserver console. Then I used /run SetDungeonDifficulty(#). It worked for values of 1 and 2 (normal and heroic), but it didn't seem to send anything to the server with a difficulty value of 3.

That means you probably need to use AIO to send a request to set dungeon difficulty to 3. Hopefully you don't need to otherwise mess with the client to fix the unused difficulty. TrinityCore should be able to set your difficulty to 3 if it receives the request. You'll also need to increment the MAX_DUNGEON_DIFFICULTY constant. Not sure what else you'd need.

Its a new discovery i think why make something for something unused...if you know what i mean i doubt trinity would have anything related to a third Difficulty.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #3 on: August 06, 2016, 11:40:33 pm »
Right, but if you wanted to make the button work, you would need to add a way to send the request to change the difficulty (using AIO, probably).

I don't know how dungeon difficulties themselves are implemented.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Nupper

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 339
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #4 on: August 06, 2016, 11:47:45 pm »
Quote from: "Grymskvll"
Right, but if you wanted to make the button work, you would need to add a way to send the request to change the difficulty (using AIO, probably).

I don't know how dungeon difficulties themselves are implemented.

Yeah a part from the UnitPop.lua i cannot find anything else so far.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #5 on: August 07, 2016, 12:54:17 am »
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Nupper

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 339
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #6 on: August 07, 2016, 01:26:30 am »
Quote from: "schlumpf"
https://wowdev.wiki/DB/Difficulty?
EPIC Dungeon difficulty was unused in wrath
trying to figure how to add it...
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #7 on: August 07, 2016, 03:48:11 am »
Quote from: "schlumpf"
https://wowdev.wiki/DB/Difficulty?

On that note, I guess you'd have to add epic difficulty entries in MapDifficulty.dbc.

From what I gather, TrinityCore gets creature stats from the world.creature_template database. I'm guessing that you would put a reference to an epic difficulty version of the creature in difficulty_entry_2 of the normal mode creature entry. At least, that's how it's done for raids.

So you would need to create new epic version entries in creature_template for each creature in each dungeon that you want to have an epic difficulty setting, and then reference those new epic versions in difficulty_entry_2 of the normal version.

Of course, that's not all you'd need to do to make the difficulty work.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #8 on: August 07, 2016, 05:56:00 pm »
Quote from: "Grymskvll"
You'll also need to increment the MAX_DUNGEON_DIFFICULTY constant. Not sure what else you'd need.

Oops nevermind that, it's not needed at all.

I tried adding an Eluna playermethod for setting dungeon difficulty (so that the button would work), and it worked... but with a major flaw. The client's difficulty doesn't get updated until you relog. I guess you would either have to send some kind of difficulty mode update from the server to the client, or else modify Wow.exe so that it accepts 3 as a valid SetDungeonDifficulty setting.

Edit: oops, just realized that the core has Player::SendDungeonDifficulty built in. After all, it has to update group members' dungeon difficulty when the party leader sets it.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #9 on: August 08, 2016, 03:15:00 am »
I'm stuck. I've managed to set dungeon difficulty to Epic from the interface and create an empty Epic difficulty instance, but I can't figure out how to spawn creatures. The earliest function I can find that's called when instance creatures are spawned is Creature::LoadCreatureFromDB, but none of the places that call that function are called when you create a dungeon instance... So what the hell is calling Creature::LoadCreatureFromDB???

If you want to try debugging, here's what I did to enable the Epic dungeon difficulty:

Look up the Map entry you want to have an Epic difficulty in Map.dbc, then in MapDifficulty.dbc, create a new entry for your Map ID with the difficulty field set to 2 (Epic).

This step wont work since there's something missing, but it will be required if someone figures it out. In your mysql world.creature_template, copy entries for all the heroic versions for creatures in that Map, but change the name to have a "(2)" at the end, just like how heroic versions have "(1)".
Make sure the new Epic entries you make have nothing in the "difficulty_entry_#" fields.
In all the normal mode entries in creature_template, add a reference to the new entry you made in difficulty_entry_2

In WorldSession.h, add this below "void HandleSetDungeonDifficultyOpcode(WorldPacket& recvData);":
Code: [Select]
void HandleSetDungeonDifficulty(Difficulty mode);

In MiscHandler.cpp, add:
Code: [Select]
void WorldSession::HandleSetDungeonDifficulty(Difficulty mode)
{
TC_LOG_DEBUG("network", "MSG_SET_DUNGEON_DIFFICULTY");

if (mode >= MAX_DUNGEON_DIFFICULTY)
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUID().GetCounter(), mode);
return;
}

if (Difficulty(mode) == _player->GetDungeonDifficulty())
return;

// cannot reset while in an instance
Map* map = _player->FindMap();
if (map && map->IsDungeon())
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!",
_player->GetName().c_str(), _player->GetGUID().GetCounter());
return;
}

Group* group = _player->GetGroup();
if (group)
{
if (group->IsLeader(_player->GetGUID()))
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* groupGuy = itr->GetSource();
if (!groupGuy)
continue;

if (!groupGuy->IsInMap(groupGuy))
return;

if (groupGuy->GetMap()->IsNonRaidDungeon())
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!",
_player->GetGUID().GetCounter(), groupGuy->GetName().c_str(), groupGuy->GetGUID().GetCounter());
return;
}
}
// the difficulty is set even if the instances can't be reset
//_player->SendDungeonDifficulty(true);
group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false, _player);
group->SetDungeonDifficulty(Difficulty(mode));
}
}
else
{
_player->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false);
_player->SetDungeonDifficulty(Difficulty(mode));
}
}

In Eluna's PlayerMethods.h, add:
Code: [Select]
/**
* Sets the [Player]s dungeon difficulty to the specified value
*
* @param uint32 difficulty
*/
int SetDungeonDifficulty(Eluna* /*E*/, lua_State* L, Player* player)
{
Difficulty difficulty = (Difficulty)Eluna::CHECKVAL<uint32>(L, 2, 0);

WorldSession* session = player->GetSession();
session->HandleSetDungeonDifficulty(difficulty);

bool isInGroup = (player->GetGroup() != 0);
player->SendDungeonDifficulty(isInGroup);

return 0;
}

In Eluna's LuaFunctions.cpp, in "ElunaRegister<Player> PlayerMethods[]" add:
Code: [Select]
{ "SetDungeonDifficulty", &LuaPlayer::SetDungeonDifficulty },

And add this AIO script to your server's lua_scripts folder:
Code: [Select]
local AIO = AIO or require("AIO")
AIO.AddAddon()

if AIO.IsServer() then
-- TrinityCore: starting from 0=normal, 1=heroic, 2=epic
local MAX_DUNGEON_DIFFICULTY = 3

function HandlePlayerSetDungeonDifficulty(player, msg)
-- difficulties start at 0 in TrinityCore, 1 in client
msg = tonumber(msg) - 1
if msg >= 0 and msg < MAX_DUNGEON_DIFFICULTY then
player:SetDungeonDifficulty(msg)
end
end
AIO.RegisterEvent("SetDungeonDifficulty", HandlePlayerSetDungeonDifficulty)

return
end


UnitPopupButtons["DUNGEON_DIFFICULTY3"] = { text = DUNGEON_DIFFICULTY3, dist = 0 };
UnitPopupMenus["DUNGEON_DIFFICULTY"] = { "DUNGEON_DIFFICULTY1", "DUNGEON_DIFFICULTY2", "DUNGEON_DIFFICULTY3" };
DUNGEON_DIFFICULTY_5PLAYER_EPIC = "5 Player (Epic)";

function SetDungeonDifficultyCustom(difficulty)
AIO.Msg():Add("SetDungeonDifficulty", difficulty):Send()
end


origSetDungeonDifficulty = SetDungeonDifficulty
SetDungeonDifficulty = function(...)
local difficulty = ...
if difficulty < 3 then
origSetDungeonDifficulty(difficulty)
else
SetDungeonDifficultyCustom(difficulty)
end
end

Apologies if there's any errors, I made some last minute changes as I was copying the code.

Edit: forgot to mention that if you want to try to add a new difficulty, you should try to add a heroic mode to a dungeon that normally doesn't have one first. That doesn't (or at least shouldn't) require the core mods and AIO script above, it should only require mysql database and DBC edits as far as I understand, but I can't even get that to work.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #10 on: August 08, 2016, 11:11:48 pm »
Holy shit, all the above DOES work, I just made the mistake of thinking that the server would spawn the Epic versions of creatures if there are Epic entries in world.creature_template, which is NOT the case! But the world.creature_template IS needed for automatically spawning the right version. What I did was enter an Epic instance, used ".npc add [NORMAL world.creature_template entry]", and the server automatically grabs the Epic version (referenced in "difficulty_entry_3" of the normal version of the creature_template).

What's the sane way to copy over all monster spawns from a normal dungeon? From what I understand, they're stored in world.creature
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #11 on: August 08, 2016, 11:46:07 pm »
Quote from: "Grymskvll"
What's the sane way to copy over all monster spawns from a normal dungeon? From what I understand, they're stored in world.creature

In world.creature, the spawnMask column determines which difficulties a creature will spawn on. So if you want to make every creature in a Map spawn for every difficulty, you can just set the spawnMask to 15 ("Spawned in all versions of maps").

To set this spawnMask for all creatures in a specific map, you can use this mysql statement (AT YOUR OWN RISK):
Code: [Select]
UPDATE world.creature SET spawnMask=15 WHERE map=[map ID];
Replace [map ID] with the map you want to change. You still need to add Epic difficulty entries for each creature_template in the dungeon. Otherwise it uses the heroic or normal version as fallback.

As far as I know, that leaves just two imperfections:
-the dungeon portal becomes invisible when you set difficulty to to Epic. If anyone has an idea how the game picks its instance portal models, please let me know
-the little dungeon difficulty indicator when you're inside a dungeon (in the top-right, next to the minimap) just displays "0". Odds are there's no blp for an Epic difficulty (like the skull flag for Heroic), so you probably need to do some interface modding, which wouldn't be an issue since you need to use an AIO script to make the difficulty selection menu work anyway. I'm a little dismayed that I couldn't even get the indicator to show "5", though, even with a modified client-side MapDifficulty.dbc
-game objects don't seem to be spawning, gotta figure out how that stuff works (like the web door in Azjol-Nerub)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Nupper

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 339
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #12 on: August 09, 2016, 09:43:29 am »
Quote from: "Grymskvll"
Quote from: "Grymskvll"
What's the sane way to copy over all monster spawns from a normal dungeon? From what I understand, they're stored in world.creature

In world.creature, the spawnMask column determines which difficulties a creature will spawn on. So if you want to make every creature in a Map spawn for every difficulty, you can just set the spawnMask to 15 ("Spawned in all versions of maps").

To set this spawnMask for all creatures in a specific map, you can use this mysql statement (AT YOUR OWN RISK):
Code: [Select]
UPDATE world.creature SET spawnMask=15 WHERE map=[map ID];
Replace [map ID] with the map you want to change. You still need to add Epic difficulty entries for each creature_template in the dungeon. Otherwise it uses the heroic or normal version as fallback.

As far as I know, that leaves just two imperfections:
-the dungeon portal becomes invisible when you set difficulty to to Epic. If anyone has an idea how the game picks its instance portal models, please let me know
-the little dungeon difficulty indicator when you're inside a dungeon (in the top-right, next to the minimap) just displays "0". Odds are there's no blp for an Epic difficulty (like the skull flag for Heroic), so you probably need to do some interface modding, which wouldn't be an issue since you need to use an AIO script to make the difficulty selection menu work anyway. I'm a little dismayed that I couldn't even get the indicator to show "5", though, even with a modified client-side MapDifficulty.dbc
-game objects don't seem to be spawning, gotta figure out how that stuff works (like the web door in Azjol-Nerub)
I am sure over time theses issues can be resolved :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 65
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #13 on: August 09, 2016, 10:36:22 pm »
To fix gameobjects, you need to set the spawnMask just like we did with creatures:
Code: [Select]
UPDATE world.gameobject SET spawnMask=15 WHERE map=[map ID];

For some reason, the maxplayers and difficultystring values in MapDifficulty.dbc don't get checked for newly created rows, and I can't figure out why. I'm guessing there's something missing in Map.dbc or something. I made a hacky workaround by hooking GetInstanceInfo(). It'll work for 5 man Epic dungeons.

Also I kind of completely neglected Epic raids. Unfortunately, Epic raids would need some more in-depth modding, since in world.creature_template, difficulty_entry_# only goes up to 3, meaning you can have up to 4 difficulty versions including the base. All 4 of these versions are already used by raids for N10, N25, H10 and H25. It could be as simple as adding more columns to the table, I don't know. Other than that you'd need to add another Eluna method (SetRaidDifficulty), get some AIO communication akin to the one I wrote for SetDungeonDifficulty, and add some extra conditions in the hooked GetInstanceInfo() to check for raid and difficulty so that maxplayers and difficultystring returned by it are correct, maybe mess with some core constants, add the necessary client strings, mess with the minimap indicator (more on that below).

Also, for some reason MiniMapInstanceDifficulty_OnEvent can't be overwritten in an AIO script properly. The modified version will just exist side by side with the original, and events will call the original instead of our modified version. That's not a huge problem, since you can just supply a modified Minimap.lua (where the function resides) in a custom patch, which would be necessary if you want Epic difficulty to have a different minimap indicator blp anyway. Speaking of which, I made an Epic difficulty instance banner, it's included in the patch below, along with a modified Minimap.lua

Preview (new epic banner on the right):


Looking at the banner now, I probably should've reduced the emblem's alpha a tiny bit. Oh well! The attached file also contains the Photoshop document for that image, as well as an updated AIO script.

So right now the issues are:
-invisible instance portal when you select Epic dungeon difficulty (no idea how this works)
-no Epic raid support
-hacky GetInstanceInfo() mod instead of properly loading maxplayers and the difficultystring from MapDifficulty.dbc

Mirror: https://a.fluntcaps.me/nywray.zip
« Last Edit: August 09, 2016, 11:01:51 pm by Admin »

Nupper

  • Registred Member
  • Creator of Worlds
  • *****
  • Posts: 339
    • View Profile
Re: [QUESTION:Wrath]  New Dungeon Difficulty
« Reply #14 on: August 09, 2016, 10:55:17 pm »
Quote from: "Grymskvll"
To fix gameobjects, you need to set the spawnMask just like we did with creatures:
Code: [Select]
SELECT * FROM world.gameobject WHERE map=[map ID];

For some reason, the maxplayers and difficultystring values in MapDifficulty.dbc don't get checked for newly created rows, and I can't figure out why. I'm guessing there's something missing in Map.dbc or something. I made a hacky workaround by hooking GetInstanceInfo(). It'll work for 5 man Epic dungeons.

Also I kind of completely neglected Epic raids. Unfortunately, Epic raids would need some more in-depth modding, since in world.creature_template, difficulty_entry_# only goes up to 3, meaning you can have up to 4 difficulty versions including the base. All 4 of these versions are already used by raids for N10, N25, H10 and H25. It could be as simple as adding more columns to the table, I don't know. Other than that you'd need to add another Eluna method (SetRaidDifficulty), get some AIO communication akin to the one I wrote for SetDungeonDifficulty, and add some extra conditions in the hooked GetInstanceInfo() to check for raid and difficulty so that maxplayers and difficultystring returned by it are correct, maybe mess with some core constants, add the necessary client strings, mess with the minimap indicator (more on that below).

Also, for some reason MiniMapInstanceDifficulty_OnEvent can't be overwritten in an AIO script properly. The modified version will just exist side by side with the original, and events will call the original instead of our modified version. That's not a huge problem, since you can just supply a modified Minimap.lua (where the function resides) in a custom patch, which would be necessary if you want Epic difficulty to have a different minimap indicator blp anyway. Speaking of which, I made an Epic difficulty instance banner, it's included in the patch below, along with a modified Minimap.lua

Preview (new epic banner on the right):


Looking at the banner now, I probably should've reduced the emblem's alpha a tiny bit. Oh well! The attached file also contains the Photoshop document for that image, as well as an updated AIO script.

So right now the issues are:
-invisible instance portal when you select Epic dungeon difficulty (no idea how this works)
-no Epic raid support
-hacky GetInstanceInfo() mod instead of properly loading maxplayers and the difficultystring from MapDifficulty.dbc

Mirror: https://a.fluntcaps.me/nywray.zip

Gameobject_Template
Code: [Select]
GAMEOBJECT_TYPE_DUNGEONDIFFICULTY = 31

    data0: mapID (From Map.dbc)
    data1: difficulty

     

     

0 5 man normal, 10 man normal
1 5 man heroic, 25 normal
2 5 Man Epic (Possibily), 10 man heroic
3 25 man heroic
« Last Edit: January 01, 1970, 01:00:00 am by Admin »