Welcome to AC Web.
Results 1 to 8 of 8
  1. #1
    AshamaneCore Contributer

    Join Date
    Mar 2009
    Posts
    1,331

    [TuT-Eluna] New Dungeon Difficulty


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    In WorldSession.h, add this below "void HandleSetDungeonDifficultyOpcode(WorldPacket& recvData);":
    Code:
    void HandleSetDungeonDifficulty(Difficulty mode);
    In MiscHandler.cpp, add:
    Code:
    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:
    	/**
    	* 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:
    { "SetDungeonDifficulty", &LuaPlayer::SetDungeonDifficulty },
    And add this AIO script to your server's lua_scripts folder:
    Code:
    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
    
    DUNGEON_DIFFICULTY_5PLAYER_EPIC = "5 Player Epic";
    DUNGEON_DIFFICULTY3 = "5 Player Epic";
    
    UnitPopupButtons["DUNGEON_DIFFICULTY3"] = { text = DUNGEON_DIFFICULTY3, dist = 0 };
    UnitPopupMenus["DUNGEON_DIFFICULTY"] = { "DUNGEON_DIFFICULTY1", "DUNGEON_DIFFICULTY2", "DUNGEON_DIFFICULTY3" };
    
    
    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
    
    
    -- Dirty hack. Can't get it to load data from MapDifficulty.dbc for the difficultrystring and maxplayers for new rows, even though editing existing rows works...
    origGetInstanceInfo = GetInstanceInfo;
    GetInstanceInfo = function(...)
    	local name, instanceType, difficulty, difficultyString, maxPlayers, playerDifficulty, isDynamicInstance = origGetInstanceInfo();
    	
    	-- if epic dungeon difficulty
    	if ( instanceType == "party" and difficulty == 3 ) then
    		maxPlayers = 5;
    		difficultyString = DUNGEON_DIFFICULTY_5PLAYER_EPIC;
    	end
    	
    	return name, instanceType, difficulty, difficultyString, maxPlayers, playerDifficulty, isDynamicInstance;
    end
    Instance Portals (Gameobject_Template)
    Code:
    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, 10 man heroic
    3	25 man heroic
    Creatures_template use Dungeon_entry_3 or 2

    add to client:
    Dungeon Difficulty Files
    Lua = Server Side
    MPQ = Client Side

    MapDifficulty.dbc needs updating
    Version ID = 2
    You need to change the last field in MapDifficulty.dbc to "DUNGEON_DIFFICULTY_5PLAYER_EPIC"


    Spawnmasks:
    4
    Spawned only in 10-man heroic versions of maps (or Epic Dungeons (Untested))

    Or 15 for all.

    Previews of my versions:

    Mythic Mode (Epic) Instance portal


    Mythic Mode (Epic) inside.

    Credits: Nupper, Grymskvll
    Last edited by Nupper; 08-11-2016 at 10:35 AM.

  2. #2
    good

  3. #3
    whoamidev.com

    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    1,181
    Why would you use a int function if you are returning 0?

  4. #4
    weird like that

    Join Date
    Feb 2010
    Location
    http://rochet2.github.io/
    Posts
    5,280
    Quote Originally Posted by mattias9410 View Post
    Why would you use a int function if you are returning 0?
    Because the function is required to have a specific signature. He cannot choose the return type.
    In practice the number returned indicates the amount of values the function pushed to the lua stack.

  5. #5
    Great release, thanks for sharing!

  6. #6
    whoamidev.com

    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    1,181
    Quote Originally Posted by Rochet2 View Post
    Because the function is required to have a specific signature. He cannot choose the return type.
    In practice the number returned indicates the amount of values the function pushed to the lua stack.
    Aah I see, thanks for clearing that out, I have almost 0 skills in C++. Just C#

  7. #7
    Nupper you know how to add new flag on item, Like Heroic item ( i want make a custom; Mythic item) ??

  8. #8


    Join Date
    Mar 2014
    Location
    http://strong-wow.com
    Posts
    1,199

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Great gonna test it

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •