Retail V21 (SetLevelUpGift)

Results 1 to 5 of 5
  1. #1
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    LocalhostLocation
    1,842Posts

    Retail V21 (SetLevelUpGift)

    This is from the retail source and has been converted.

    Replace the entire function of:
    Code:
    CEventLua::SetLevelUpGift
    With:
    Code:
    #ifdef __EVENTLUA_GIFT
    void CEventLua::SetLevelUpGift(CUser* pUser, int nLevel)
    {
    	if (!IsPossible())
    		return;
    
    	if (m_Lua.GetLuaFunction("GetLevelUpGift"))
    	{
    		m_Lua.PushNumber(nLevel);
    		m_Lua.PushString(pUser->m_playAccount.lpszAccount);
    		m_Lua.PushNumber(pUser->GetLegendChar());
    		m_Lua.PushNumber(pUser->GetJob());
    		m_Lua.CallLuaFunction(4, 1);
    
    		if (m_Lua.IsNil(-1))
    		{
    			m_Lua.Pop(0);
    			return;
    		}
    
    		m_Lua.PushNil();
    		while (m_Lua.TableLoop(-2))
    		{
    			DWORD dwItemId = CScript::GetDefineNum(m_Lua.GetFieldToString(-1, "strItemId"));
    			int	nItemNum = (int)m_Lua.GetFieldToNumber(-1, "nItemNum");
    
    			if (!prj.GetItemProp(dwItemId))
    			{
    				Error("CEventLua::SetLevelUpGift() - ItemProp is NULL. ItemId = \"%s\"", m_Lua.GetFieldToString(-1, "strItemId"));
    				m_Lua.Pop(1);
    				continue;
    			}
    
    			CItemElem itemElem;
    			itemElem.m_dwItemId = dwItemId;
    			itemElem.m_nItemNum = nItemNum;
    			itemElem.SetFlag(static_cast<BYTE>(m_Lua.GetFieldToNumber(-1, "byFlag")));
    			itemElem.SetSerialNumber();
    
    			LogItemInfo aLogItem;
    			aLogItem.Action = "E";
    			aLogItem.SendName = pUser->GetName();
    			aLogItem.WorldId = pUser->GetWorld()->GetID();
    			aLogItem.Gold = aLogItem.Gold2 = pUser->GetGold();
    
    			if (pUser->CreateItem(&itemElem))
    			{
    				aLogItem.RecvName = "EVENT_LEVELUP_GIFT";
    				g_DPSrvr.OnLogItem(aLogItem, &itemElem, nItemNum);
    			}
    			else
    			{
    				g_dpDBClient.SendQueryPostMail(pUser->m_idPlayer, 0, itemElem, 0, "", "");
    				aLogItem.RecvName = "EVENT_LEVELUP_GIFT_POST";
    				g_DPSrvr.OnLogItem(aLogItem, &itemElem, nItemNum);
    			}
    
    			pUser->AddDefinedText(TID_GAME_EVENT_LEVELUP_GIFT, "\"%s\"", itemElem.GetName());
    			m_Lua.Pop(1);
    		}
    	}
    	m_Lua.Pop(0);
    }
    #endif
    EventFunc.lua
    Below:
    Code:
    ITEM = 4
    MONSTER = 5
    Add:
    Code:
    LEGEND_CLASS_NORMAL		= 0
    LEGEND_CLASS_MASTER		= 1
    LEGEND_CLASS_HERO		= 2
    LEGEND_CLASS_LEGENDHERO	= 3
    
    JOB_VAGRANT			= 0
    JOB_MERCENARY			= 1
    JOB_ACROBAT			= 2
    JOB_ASSIST			= 3
    JOB_MAGICIAN			= 4
    JOB_PUPPETEER			= 5
    JOB_KNIGHT			= 6
    JOB_BLADE			= 7
    JOB_JESTER			= 8
    JOB_RANGER			= 9
    JOB_RINGMASTER			= 10
    JOB_BILLPOSTER			= 11
    JOB_PSYCHIKEEPER		= 12
    JOB_ELEMENTOR			= 13
    JOB_GATEKEEPER			= 14
    JOB_DOPPLER			= 15
    JOB_KNIGHT_MASTER		= 16
    JOB_BLADE_MASTER		= 17
    JOB_JESTER_MASTER		= 18
    JOB_RANGER_MASTER		= 19
    JOB_RINGMASTER_MASTER		= 20
    JOB_BILLPOSTER_MASTER		= 21
    JOB_PSYCHIKEEPER_MASTER		= 22
    JOB_ELEMENTOR_MASTER		= 23
    JOB_KNIGHT_HERO			= 24
    JOB_BLADE_HERO			= 25
    JOB_JESTER_HERO			= 26
    JOB_RANGER_HERO			= 27
    JOB_RINGMASTER_HERO		= 28
    JOB_BILLPOSTER_HERO		= 29
    JOB_PSYCHIKEEPER_HERO		= 30
    JOB_ELEMENTOR_HERO		= 31
    JOB_LORDTEMPLER_HERO		= 32
    JOB_STORMBLADE_HERO		= 33
    JOB_WINDLURKER_HERO		= 34
    JOB_CRACKSHOOTER_HERO		= 35
    JOB_FLORIST_HERO		= 36
    JOB_FORCEMASTER_HERO		= 37
    JOB_MENTALIST_HERO		= 38
    JOB_ELEMENTORLORD_HERO		= 39
    JOB_MAX				= 40
    Replace entire function:
    Code:
    SetLevelUpGift
    With:
    Code:
    function SetLevelUpGift( nLevel, strAccount, strItemId, nItemNum, byFlag, nLegendClass, nJob )
        local nEventId = #tEvent
        local nSize = #tEvent[nEventId].Gift
      
        tEvent[nEventId].Gift[nSize+1] = {}
        tEvent[nEventId].Gift[nSize+1].nLevel = nLevel
        tEvent[nEventId].Gift[nSize+1].strAccount = strAccount
        tEvent[nEventId].Gift[nSize+1].strItemId = strItemId
        tEvent[nEventId].Gift[nSize+1].nItemNum = nItemNum
        tEvent[nEventId].Gift[nSize+1].byFlag = byFlag
        tEvent[nEventId].Gift[nSize+1].nLegendClass = nLegendClass
        tEvent[nEventId].Gift[nSize+1].nJob = nJob
    end
    Replace entire function:
    Code:
    GetLevelUpGift
    With:
    Code:
    function GetLevelUpGift( nLevel, strAccount, nLegendClass, nJob )
    	local nCount = 1
    	local tGiftList = {}
    	local tList = GetEventList()
    	for i in pairs(tList) do
    		local tGift = tEvent[tList[i]].Gift
    		for j in pairs(tGift) do
    			local nTemp = string.find( strAccount, tGift[j].strAccount )
    			if( (tGift[j].strAccount == "all") or (nTemp ~= nil) ) then 
    				if( (tGift[j].nJob == JOB_MAX ) or ( tGift[j].nJob == nJob ) ) then
    					if( tGift[j].nLevel == nLevel and tGift[j].nLegendClass == nLegendClass ) then
    						tGiftList[nCount] = {}
    						tGiftList[nCount].strItemId = tGift[j].strItemId
    						tGiftList[nCount].nItemNum = tGift[j].nItemNum
    						tGiftList[nCount].byFlag = tGift[j].byFlag
    						nCount = nCount + 1
    					end
    				end
    			end
    		end
    	end
    	
    	return tGiftList
    end
    Event.lua
    Replace:
    Code:
    ---- 11. SetLevelUpGift( nLevel, "all", ItemId, nNum, byFlag ) -- 레벨업 선물( nLevel달성시 아이템 지급, "all" 부분에 특정 계정 지정 가능(예. "__bu" - 버디, "__an" - 엔젤 )
    With:
    Code:
    ---- 11. SetLevelUpGift( nLevel, "all", ItemId, nNum, byFlag, nLegendClass, nJob ) -- 레벨업 선물( nLevel달성시 아이템 지급, "all" 부분에 특정 계정 지정 가능(예. "__bu" - 버디, "__an" - 엔젤 ), nJob으로 직업지정(JOB_MAX 기입시 모든 직업)
    You then are able to do events like this:
    Code:
    AddEvent( "JOB EVENT TEST" )
    --{
        SetTime( "2007-06-08 14:23", "2099-06-08 16:11" )
        SetLevelUpGift( 60, "all", "II_SYS_SYS_SCR_BX_PET_LAWOLF7", 1, 2, LEGEND_CLASS_NORMAL, JOB_KNIGHT )
        SetLevelUpGift( 80, "all", "II_SYS_SYS_SCR_BX_PET_LAWOLF7", 1, 2, LEGEND_CLASS_MASTER, JOB_KNIGHT_MASTER )
        SetLevelUpGift( 125, "all", "II_SYS_SYS_SCR_BX_PET_LAWOLF7", 1, 2, LEGEND_CLASS_HERO, JOB_KNIGHT_HERO)
        SetLevelUpGift( 140, "all", "II_SYS_SYS_SCR_BX_PET_LAWOLF7", 1, 2, LEGEND_CLASS_LEGEND_HERO, JOB_LORDTEMPLER_HERO )    
    --}
    Thanks to @Hyellow for reporting a missing piece.
    Last edited by Ketchup; 24-01-21 at 02:01 PM.
    Discord: ηєxυѕ#0003 | Forum Contact: Click Here | Community Rules & Guidelines: Click Here


  2. #2
    Registered distance101 is offline
    MemberRank
    Feb 2019 Join Date
    3Posts

    Re: Retail V21 (SetLevelUpGift)

    this is what im looking for thank you for the release

  3. #3
    Member Hyellow is offline
    MemberRank
    Feb 2020 Join Date
    44Posts

    Re: Retail V21 (SetLevelUpGift)

    Forgot this

    Replace Entire function:
    Code:
    GetLevelUpGift
    With:
    Code:
    function GetLevelUpGift( nLevel, strAccount, nLegendClass, nJob )    local nCount = 1    local tGiftList = {}    local tList = GetEventList()    for i in pairs(tList) do        local tGift = tEvent[tList[i]].Gift        for j in pairs(tGift) do            local nTemp = string.find( strAccount, tGift[j].strAccount )            if( (tGift[j].strAccount == "all") or (nTemp ~= nil) ) then                 if( (tGift[j].nJob == JOB_MAX ) or ( tGift[j].nJob == nJob ) ) then                    if( tGift[j].nLevel == nLevel and tGift[j].nLegendClass == nLegendClass ) then                        tGiftList[nCount] = {}                        tGiftList[nCount].strItemId = tGift[j].strItemId                        tGiftList[nCount].nItemNum = tGift[j].nItemNum                        tGiftList[nCount].byFlag = tGift[j].byFlag                        nCount = nCount + 1                    end                end            end        end    end        return tGiftListend
    Last edited by Hyellow; 24-01-21 at 02:03 PM.

  4. #4
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    LocalhostLocation
    1,842Posts

    Re: Retail V21 (SetLevelUpGift)

    Quote Originally Posted by Hyellow View Post
    Forgot this

    Replace Entire function:
    Code:
    GetLevelUpGift
    With:
    Code:
    function GetLevelUpGift( nLevel, strAccount, nLegendClass, nJob )    local nCount = 1    local tGiftList = {}    local tList = GetEventList()    for i in pairs(tList) do        local tGift = tEvent[tList[i]].Gift        for j in pairs(tGift) do            local nTemp = string.find( strAccount, tGift[j].strAccount )            if( (tGift[j].strAccount == "all") or (nTemp ~= nil) ) then                 if( (tGift[j].nJob == JOB_MAX ) or ( tGift[j].nJob == nJob ) ) then                    if( tGift[j].nLevel == nLevel and tGift[j].nLegendClass == nLegendClass ) then                        tGiftList[nCount] = {}                        tGiftList[nCount].strItemId = tGift[j].strItemId                        tGiftList[nCount].nItemNum = tGift[j].nItemNum                        tGiftList[nCount].byFlag = tGift[j].byFlag                        nCount = nCount + 1                    end                end            end        end    end        return tGiftListend
    Thanks for spotting this! I updated the main post with it.
    Discord: ηєxυѕ#0003 | Forum Contact: Click Here | Community Rules & Guidelines: Click Here

  5. #5
    Member Siono01 is offline
    MemberRank
    May 2020 Join Date
    62Posts

    Re: Retail V21 (SetLevelUpGift)

    Thanks for sharing



Advertisement