Jump to content

Distraught

Honorable Member
  • Posts

    194
  • Joined

  • Last visited

  • Days Won

    23
  • Feedback

    0%

Posts posted by Distraught

  1. Acutally you both are right.

    @metin2-factory says the ++i is running faster than the i++. It's true because i++ stores the old value and returns that and after adds 1 to the value of i. ++i only adds 1 and doesn't store the old value.

    BUT

    @Tasho is also right. I checked the runtime of both of our code (ran it 1.000.000 times and then calculated an average value). His code runs about 2x times faster than mine because of the optimalizations he did.

  2. M2 Download Center

    This is the hidden content, please
    ( Internal )

    Hey guyz,

     

    Today I made a small release. It's a new LUA function to check if all the members of the party have the specified item (and then it removes it).

    Let's start to make it work!

    Open party.h and search for: GetMemberMinLevel();

    After add this:

    bool		CheckItem(int targyID);

    Save and close the file.

    Open party.cpp and and the code below the function GetMemberMaxLevel:

    bool CParty::CheckItem(int targyID)
    {
    	int dbszam = 0;
    	itertype(m_memberMap) it = m_memberMap.begin();
    	
    	while (it!=m_memberMap.end())
    	{
    		if (!it->second.pCharacter)
    		{
    			++it;
    			continue;
    		}
    		if(it->second.pCharacter->CountSpecifyItem(targyID) > 0)
    			dbszam++;
    		
    		++it;
    	}
    	
    	if(GetNearMemberCount() <= dbszam)
    	{
    		itertype(m_memberMap) it2 = m_memberMap.begin();
    	
    		while (it2!=m_memberMap.end())
    		{
    			if (!it2->second.pCharacter)
    			{
    				++it2;
    				continue;
    			}
    			if(it2->second.pCharacter->CountSpecifyItem(targyID) > 0)
    				it2->second.pCharacter->RemoveSpecifyItem(targyID);
    		
    			++it2;
    		}
    	}else{return false;}
    	
    	return true;
    }

    Save the file and close it.

    Open questlua_party.cpp and add this function:

    int party_check_item(lua_State* L)
    	{
    		DWORD item_vnum;
    		if (lua_isnumber(L,1))
    		{
    			item_vnum = (DWORD)lua_tonumber(L, 1);
    		}
    		else
    		{
    			lua_pushboolean(L, 0);
    			return 1;
    		}
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (ch->GetParty())
    			lua_pushboolean(L,ch->GetParty()->CheckItem(item_vnum));
    		else
    			lua_pushboolean(L, 0);
    
    		return 1;
    	}

     

    Add the line below after { "is_in_dungeon",   party_is_in_dungeon   },

    { "check_item",	party_check_item	},

    Compile the game and we're done.

    In quests it will return a boolean value.

    You can use it like:

    if party.check_item(72702) then
    d.join(207)
    end

    In this case it checks if all the party members have the item with the ID of 72702 and then it removes from them and warps them to the dungeon.

     

     

    Don't copy it or at least mention my name!

    • Metin2 Dev 5
    • Love 3
  3. open char_quickslot.cpp and search for:

    	if (pItem->IsDragonSoul())
    		return;

    modify:

    if (pItem->IsDragonSoul() || pItem->GetVnum() == YOURITEMID)
      return;

     

    If you wanna add more items:

    if (pItem->IsDragonSoul() || pItem->GetVnum() == YOURITEMID || pItem->GetVnum() == YOURITEMID2 || pItem->GetVnum() == YOURITEMID3)
      return;

    I'm working now so I couldn't test it, but I think it's gonna work.

  4.  

    go to game/src/char_item.cp and search for: else if (true == CItemVnumHelper::IsLovePendant(dwVnum))

    after put something like:

    if (item->GetVnum() == YOURITEMID)
    {
     this->EffectPacket(ARMOR_RING); 
    }

    Then search for: bool CHARACTER::UnequipItem(LPITEM item)

    to this function put this:

    if (item->GetVnum() == YOURITEMID)
    {
     this->EffectPacket(ARMOR_RING); 
    }

     

    go to common/length.h and search for: 

    SE_EQUIP_LOVE_PENDANT,

    then put this under:

    ARMOR_RING,

    Now you can compile your game.

     

    open UserInterface/PythonNetworkStreamPhaseGameItem.cpp in your client source and search for: 

    case SE_EQUIP_LOVE_PENDANT:

    after put these:

    case ARMOR_RING:
    			CInstanceBase::ArmorRing();
    			break;

    Go to InstanceBase.h and search for: void OnUntargeted();

    Add under:

    void	ArmorRing();

    Search for: m_armorRefineEffect;

    Add under:

    bool					ringeffect;

    Now go to InstanceBase.cpp and at the beginning declare it: bool ringeffect = false;

    now search for: void CInstanceBase::__ClearArmorRefineEffect()

    After this function put this:

    void CInstanceBase::ArmorRing()
    {
      if (!ringeffect)
      {
    	__AttachEffect(EFFECT_REFINED + EFFECT_BODYARMOR_SPECIAL5);
        ringeffect = true;
      }
      else
      {
        __DetachEffect(EFFECT_REFINED + EFFECT_BODYARMOR_SPECIAL5);
        ringeffect = false;
      }
    }

    Now compile it.

    I couldn't test it, cause I'm working now but I think it's gonna work.

×
×
  • 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.