Jump to content

DrTurk

Inactive Member
  • Posts

    220
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by DrTurk

  1. 6 hours ago, martysama0134 said:

    There are far better solutions than using std::map or std::unordered_map (which still takes a lot of ram for no reason for each mob):

     (I included the most important parts)

    You also forgot the CubeItems, and we could probably fit the quickslot too.

     

    With your changes -> 430MB

    Without your changes -> 775MB

    thats impressiv

    Spoiler

  2. 1 hour ago, Kafa said:

     

    Can i ask you what you did at start_position.cpp/,h ? 

    If you talking about that ->

    char g_nation_name[4][32] =
    {
    	"",
    	"½Å¼ö±¹",
    	"õÁ¶±¹",
    	"Áø³ë±¹",
    };

    I removed castle/monarch etc. on my source so i didnt had to translate that, but the same is for priv_empire function.

    I send Sonitex my way how i have done this, but i think its better i keep that for me. I dont have alot knowledge about coding, so I dont really know if it works with alot of players. My way is a very dirty solution for the problem 😅

    • Metin2 Dev 1
  3. ye better, the thing that i did was without checking if the string is empty

    also created something for whisper because of duel:

    pkVictim->LocaleWhisperPacket(WHISPER_TYPE_SYSTEM , pkChr, 503, "%s challenged you to a battle!", pkChr->GetName());

    but the ugliest part that i did was for the priv_empire, no one wants to see what i did there 🤣

    • Lmao 1
  4. Ye didnt fix this yet, i'll fix that as soon as i have time for that.

    ok just edit this in client src:

    bool CPythonNetworkStream::RecvLocaleChatPacket()
    {
    	TPacketGCLocaleChat kChat;
    
    	if (!Recv(sizeof(kChat), &kChat))
    		return false;
    
    	std::string localeString = "";
    	bool bSuccess = LocaleStringManager::Instance().FillLocaleString(kChat.format, localeString);
    
    	if (!bSuccess)
    		return false;
    
    	if (CHAT_TYPE_NOTICE == kChat.type)
    	{
    		PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_SetTipMessage", Py_BuildValue("(s)", localeString.c_str()));
    	}
    	else if (CHAT_TYPE_BIG_NOTICE == kChat.type)
    	{
    		PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_SetBigMessage", Py_BuildValue("(s)", localeString.c_str()));
    	}
    
    	if (!localeString.empty())
    		CPythonChat::Instance().AppendChat(kChat.type, localeString.c_str());
    
    	return true;
    }

     

    • Good 1
  5. Just create another function like that:

    void SendNoticeMapLocal(DWORD dwIndex, const char* c_pszBuf, int nMapIndex, bool bBigFont, ...)
    {
    	BYTE type = 0;
    
    	const DESC_MANAGER::DESC_SET& c_ref_set = DESC_MANAGER::instance().GetClientSet();
    	if (!c_pszBuf)
    		return;
    
    	DESC_MANAGER::DESC_SET::const_iterator it = c_ref_set.begin();
    
    	while (it != c_ref_set.end())
    	{
    		LPDESC d = *(it++);
    
    		if (d->GetCharacter())
    		{
    			if (d->GetCharacter()->GetMapIndex() != nMapIndex)
    				continue;
    
    			bool isNotice = false;
    			if (c_pszBuf == "%s")
    			{
    				char chatbuf[CHAT_MAX_LEN + 1];
    				va_list args;
    
    				va_start(args, c_pszBuf);
    				vsnprintf(chatbuf, sizeof(chatbuf), c_pszBuf, args);
    				va_end(args);
    
    				strlcpy(chatbuf, c_pszBuf, sizeof(chatbuf));
    				isNotice = true;
    			}
    
    			TEMP_BUFFER buf;
    
    			if (bBigFont == true)
    			{
    				type = CHAT_TYPE_BIG_NOTICE;
    			}
    			else
    			{
    				type = CHAT_TYPE_NOTICE;
    			}
    
    			TPacketGCLocaleChat packet;
    			packet.header = HEADER_GC_LOCALE_CHAT;
    			packet.size = sizeof(TPacketGCLocaleChat);
    			packet.type = type;
    			packet.format = dwIndex;
    
    			va_list args;
    
    			va_start(args, bBigFont);
    			FindFormatSpecifiers(c_pszBuf, args, &packet.size, &buf);
    			va_end(args);
    
    			d->Packet(&packet, sizeof(packet));
    
    			if (buf.size())
    				d->Packet(buf.read_peek(), buf.size());
    		}
    	}
    }

    then you can use it like that:

    void WeddingMap::SetEnded(DWORD dwMapIndex)
    	{
    		if (m_pEndEvent)
    		{
    			sys_err("WeddingMap::SetEnded - ALREADY EndEvent(m_pEndEvent=%x)", get_pointer(m_pEndEvent));
    			return;
    		}
    
    		wedding_map_info* info = AllocEventInfo<wedding_map_info>();
    
    		info->pWeddingMap = this;
    
    		m_pEndEvent = event_create(wedding_end_event, info, PASSES_PER_SEC(5));
    
    		SendNoticeMapLocal(889, " ", dwMapIndex, true);
    		SendNoticeMapLocal(447, " ", dwMapIndex, true);

     

    • Love 2
  6. 25 minutes ago, ReFresh said:

    @DrTurk Thanks I'll try. But why did you remove that functions instead of calling Dead(); function? It should be the same thing as we call the Stun(); am I right? But mystery is why Stun(); function is able to remove these affects without editing something.

    as i said i had this problem even before i modifyed the dead function, but only when you one shot someone with a poison skill.

    i can redo my dead function modify and it will also bug when killed with one shot which has 100% poison rate

  7. 12 hours ago, ReFresh said:

    I just tried your code edits and it has at least one bug with removing char affect like poison. Try to kill the player with ninja char skill Poisoned Arrow, player will die with poison affect on yourself.

    I tried to call Dead(); function instead of your changes, but there is still the same bug with affects. Dead(); is not removing the poison, bleed, etc. affects. I couldn't find differences between why Stun(); function removing the affects correctly and Dead(); function not.

      Hide contents
    if (GetHP() <= 0)
    	{
    		Stun(); or Dead(); can be called but only Stun(); removing the affects before death correctly
    
    		if (pAttacker && !pAttacker->IsNPC())
    			m_dwKillerPID = pAttacker->GetPlayerID();
    		else
    			m_dwKillerPID = 0;
    	}
    
    return false;

     

    Would be really nice if someone can solve this problem.

    Isnt that a normal m2 problem with bleed/poison/fire when you one shot someone with it?

    I fixxed this before i did this change.

     

    Just add

    	if (ch->IsDead())
    	{
    		ch->RemovePoison();
    	}

    like that:

    EVENTFUNC(poison_event)
    {
    	TPoisonEventInfo * info = dynamic_cast<TPoisonEventInfo *>( event->info );
    	
    	if ( info == NULL )
    	{
    		sys_err( "poison_event> <Factor> Null pointer" );
    		return 0;
    	}
    
    	LPCHARACTER ch = info->ch;
    
    	if (ch == NULL) 
    	{
    		return 0;
    	}
    	LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().FindByPID(info->attacker_pid);
    
    	if (ch->IsDead())
    	{
    		ch->RemovePoison();
    	}
    
    	int dam = ch->GetMaxHP() * GetPoisonDamageRate(ch) / 1000;
    	if (test_server) ch->ChatPacket(CHAT_TYPE_NOTICE, "Poison Damage %d", dam);
    
    	if (ch->Damage(pkAttacker, dam, DAMAGE_TYPE_POISON))
    	{
    		ch->m_pkPoisonEvent = NULL;
    		return 0;
    	}
    
    	--info->count;
    
    	if (info->count)
    		return PASSES_PER_SEC(3);
    	else
    	{
    		ch->m_pkPoisonEvent = NULL;
    		return 0;
    	}
    }

     

    same thing with fire:

    EVENTFUNC(fire_event)
    {
    	TFireEventInfo * info = dynamic_cast<TFireEventInfo *>( event->info );
    
    	if ( info == NULL )
    	{
    		sys_err( "fire_event> <Factor> Null pointer" );
    		return 0;
    	}
    
    	LPCHARACTER ch = info->ch;
    	if (ch == NULL) 
    	{
    		return 0;
    	}
    	LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().FindByPID(info->attacker_pid);
    
    	if (ch->IsDead())
    	{
    		ch->RemoveFire();
    	}
    
    	int dam = info->amount;
    	if (test_server) ch->ChatPacket(CHAT_TYPE_NOTICE, "Fire Damage %d", dam);
    
    	if (ch->Damage(pkAttacker, dam, DAMAGE_TYPE_FIRE))
    	{
    		ch->m_pkFireEvent = NULL;
    		return 0;
    	}
    
    	--info->count;
    
    	if (info->count)
    		return PASSES_PER_SEC(3);
    	else
    	{
    		ch->m_pkFireEvent = NULL;
    		return 0;
    	}
    }

     

  8. char.cpp --> remove that:

    m_dwKillerPID = 0;

    char.h --> remove that:

    DWORD				m_dwKillerPID;

     

    char_battle.cpp --> remove/change that:

    if (!pkKiller && m_dwKillerPID)
    		pkKiller = CHARACTER_MANAGER::instance().FindByPID(m_dwKillerPID);
    
    	m_dwKillerPID = 0;

    change that:

    if (GetHP() <= 0)
    	{
    		Stun();
    
    		if (pAttacker && !pAttacker->IsNPC())
    			m_dwKillerPID = pAttacker->GetPlayerID();
    		else
    			m_dwKillerPID = 0;
    	}

    to this:

    if (GetHP() <= 0)
    	{
    		Dead(pAttacker);
    	}

     

    • Love 1
  9. Change this:

            if (iSizeBuffer > 0)
            {
                TEMP_BUFFER    tempbuf;
                LPBUFFER lpBufferDecrypt = tempbuf.getptr();
                buffer_adjust_size(lpBufferDecrypt, iSizeBuffer);
                int iSizeAfter = TEA_Decrypt((DWORD*)buffer_write_peek(lpBufferDecrypt),
                    (DWORD*)buffer_read_peek(m_lpInputBuffer),
                    GetDecryptionKey(),

    to this:

    		if (iSizeBuffer > 0)
    		{
    			LPBUFFER lpBufferDecrypt = buffer_new(iSizeBuffer);
    
    			int iSizeAfter = TEA_Decrypt((DWORD*)buffer_write_peek(lpBufferDecrypt),
    				(DWORD*)buffer_read_peek(m_lpInputBuffer),
    				GetDecryptionKey(),
    				iSizeBuffer);

     

    • Metin2 Dev 2
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.