Jump to content

Dice System


Recommended Posts

  • Premium

M2 Download Center

This is the hidden content, please
( Internal )

Heya, as title says it's party dice system self written (without CHAT_TYPE_DICE_INFO, it's up to you)

https://metin2.download/picture/C4ti9F2CYsYFODoIKlh3B9Ipin0XDARX/.gifv (sry for laggs - "wooden pc" ^^)

You can test possibility of same score there: https://repl.it/@Nevisor/Dice-FORINFOR

 

char_battle.cpp

//find
					if (ch->GetParty())
						ch = ch->GetParty()->GetNextOwnership(ch, GetX(), GetY());
//replace with
					if (ch->GetParty())
					{
						ch = ch->GetParty()->GetNextOwnership(ch, GetX(), GetY());

#ifdef __ENABLE_DICE_SYSTEM__
						ch = ch->GetParty()->Dice(ch, GetX(), GetY(), item->GetName());
#endif
					}

party.cpp

//at the end of file add
#ifdef __ENABLE_DICE_SYSTEM__
LPCHARACTER CParty::Dice(LPCHARACTER ch, long x, long y, const char * szName) //item name
{
	for (TMemberMap::iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
	{
		if (it->second.pCharacter->GetDesc() && DISTANCE_APPROX(it->second.pCharacter->GetX() - x, it->second.pCharacter->GetY() - y) < PARTY_DEFAULT_RANGE)
		{
			ChatPacketToAllMember(CHAT_TYPE_DICE_INFO, "|cffffe6ba*** Rolling for the following item: %s ***", szName);

			while (1)
			{
				LPCHARACTER pkWinner;
				int iDice = 0;
				int iDraw = 0;

				for (TMemberMap::iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
					if (it->second.pCharacter->GetDesc() && DISTANCE_APPROX(it->second.pCharacter->GetX() - x, it->second.pCharacter->GetY() - y) < PARTY_DEFAULT_RANGE)
					{
						int iScore = number(1, 10000);

						if (iScore == iDice)
							iDraw == iScore;
						else if (iDice == 0 || iScore > iDice)
						{
							pkWinner = it->second.pCharacter;
							iDice = iScore;
						}

						ChatPacketToAllMember(CHAT_TYPE_DICE_INFO, "|cffffe6ba*** ->\t\t\t\t\t%s - Dice score: %d ***", it->second.pCharacter->GetName(), iScore);
					}

				if (iDice != iDraw)
				{	
					ChatPacketToAllMember(CHAT_TYPE_DICE_INFO, "|cffbb00ff*** Winner of the item %s is: %s ***", szName, pkWinner->GetName());
					return pkWinner;
				}
				else 
				{
					ChatPacketToAllMember(CHAT_TYPE_DICE_INFO, "");
					ChatPacketToAllMember(CHAT_TYPE_DICE_INFO, "|cffffe6ba*** Rolling again for the following item: %s ***", szName);
				}
			}
		}
	}

	return ch;
}
#endif

party.h

//find
		void		P2PSetMemberLevel(DWORD pid, BYTE level);
//or
		bool		IsPartyInDungeon(int mapIndex);
//add bellow
#ifdef __ENABLE_DICE_SYSTEM__
		LPCHARACTER	Dice(LPCHARACTER ch, long x, long y, const char * szName);
#endif

length.h

enum EChatType
{
	CHAT_TYPE_TALKING,	/* 그냥 채팅 */
	CHAT_TYPE_INFO,	/* 정보 (아이템을 집었다, 경험치를 얻었다. 등) */
	CHAT_TYPE_NOTICE,	/* 공지사항 */
	CHAT_TYPE_PARTY,	/* 파티말 */
	CHAT_TYPE_GUILD,	/* 길드말 */
	CHAT_TYPE_COMMAND,	/* 일반 명령 */
	CHAT_TYPE_SHOUT,	/* 외치기 */
	CHAT_TYPE_WHISPER,
	CHAT_TYPE_BIG_NOTICE,
	CHAT_TYPE_MONARCH_NOTICE,
#ifdef __ENABLE_DICE_SYSTEM__
	CHAT_TYPE_DICE_INFO,
#endif
	CHAT_TYPE_MAX_NUM
};

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 24
  • Think 1
  • Confused 1
  • Good 4
  • Love 3
  • Love 19
Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...

if your group mate kills a metinstone on other map then you, game crashed:

 

(gdb) bt full
#0  0x0819b244 in CParty::Dice (this=0x33fbac80, ch=0x34745000, x=961715,
    y=265093, szName=0x2ab47941 "Segensschriftrolle") at party.cpp:1734
No locals.
#1  0x08090ada in CHARACTER::Reward (this=0x347a7000, bItemDrop=true)
    at char_battle.cpp:960
        ch = 0x34745000
        pq = {
  c = {<std::_Vector_base<std::pair<int, CHARACTER*>,std::allocator<std::pair<in                                                                                                                                                             t, CHARACTER*> > >> = {
      _M_impl = {<std::allocator<std::pair<int, CHARACTER*> >> = {<__gnu_cxx::ne                                                                                                                                                             w_allocator<std::pair<int, CHARACTER*> >> = {<No data fields>}, <No data fields>                                                                                                                                                             }, _M_start = 0x347985f0, _M_finish = 0x347985f0,
        _M_end_of_storage = 0x347985f8}}, <No data fields>},
  comp = {<std::binary_function<std::pair<int, CHARACTER*>,std::pair<int, CHARAC                                                                                                                                                             TER*>,bool>> = {<No data fields>}, <No data fields>}}
        total_dam = 578
        v = {<std::_Vector_base<CHARACTER*,std::allocator<CHARACTER*> >> = {
    _M_impl = {<std::allocator<CHARACTER*>> = {<__gnu_cxx::new_allocator<CHARACT                                                                                                                                                             ER*>> = {<No data fields>}, <No data fields>}, _M_start = 0x347985e0,
      _M_finish = 0x347985e4,
      _M_end_of_storage = 0x347985e4}}, <No data fields>}
        pkAttacker = 0x34745000
        pos = {x = 961715, y = 265093, z = 0}
---Type <return> to continue, or q <return> to quit---

 

 

you have an fix for this?

Link to comment
Share on other sites

Announcements



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