Monster Buffs Extension

03/20/2019 17:00 Duscansi#1
Hello all,

I started learning programming using a clean V15 Flyff Source.
I'm currently working with VS2017 and the files released by Blouflash.
I implemented following the tutorial the monsterbuffs system and now wanted to extend it with probability and time for the buffs.

I basically don't want getting this buff everytime, but with a specific probability for about 30 Seconds to get a little bonus for leveling/grinding.

My idea was doing it like the randomoption.inc where i add 2 new colums for the probability and the duration for the buffs.

My Problem is that I don't really have a clue how to implement it in the source...

Can someone help me out?

Thanks in advance
03/20/2019 20:54 Crimal#2
Add this in Project.h
Code:
#ifdef __MONSTER_BUFFS
struct MonsterBuffData
{
	int m_BuffId;
	int m_Chance;
};
#endif
Then change the corresponding code:
Code:
#ifdef __MONSTER_BUFFS
	map<int, MonsterBuffData>   m_mapMonsterBuffs;
	BOOL			LoadMonsterBuffs(LPCTSTR lpszFilename);
#endif // __MONSTER_BUFFS
Code:
#ifdef __MONSTER_BUFFS
BOOL CProject::LoadMonsterBuffs(LPCTSTR lpszFilename)
{
	CScript script;
	if (script.Load(lpszFilename) == FALSE)
	{
		Error("Failed to load: %s", lpszFilename);
		return FALSE;
	}

	int monsterID = script.GetNumber();
	while (script.tok != FINISHED)
	{
		MonsterBuffData data;
		data.m_BuffId = script.GetNumber();
		data.m_Chance = script.GetNumber();
		m_mapMonsterBuffs.insert(make_pair(monsterID, data));
		monsterID = script.GetNumber();
	}
	return TRUE;
}
#endif // __MONSTER_BUFFS
Code:
#ifdef __MONSTER_BUFFS
	map< int, MonsterBuffData >::iterator it = prj.m_mapMonsterBuffs.find(m_pDefender->m_dwIndex);
	if (prj.m_mapMonsterBuffs.end() != it)
	{
		MonsterBuffData data = it->second;
		if ((int)xRandom(1000) < data.m_Chance)
		{
			ItemProp* pProp = prj.GetItemProp(data.m_BuffId);
			if (pProp)
				m_pAttacker->DoApplySkill(m_pAttacker, pProp, NULL);
		}
	}
#endif // __MONSTER_BUFFS
Now you cann add another column in your MonsterBuffs.inc:
Code:
MI_AIBATT1	II_SYS_SYS_LS_LOVE  500
MI_AIBATT2	II_SYS_SYS_LS_BLESSING 100
10 = 1%
03/21/2019 09:38 Duscansi#3
Quote:
Originally Posted by Crimal View Post
Add this in Project.h
Code:
#ifdef __MONSTER_BUFFS
struct MonsterBuffData
{
	int m_BuffId;
	int m_Chance;
};
#endif
Then change the corresponding code:
Code:
#ifdef __MONSTER_BUFFS
	map<int, MonsterBuffData>   m_mapMonsterBuffs;
	BOOL			LoadMonsterBuffs(LPCTSTR lpszFilename);
#endif // __MONSTER_BUFFS
Code:
#ifdef __MONSTER_BUFFS
BOOL CProject::LoadMonsterBuffs(LPCTSTR lpszFilename)
{
	CScript script;
	if (script.Load(lpszFilename) == FALSE)
	{
		Error("Failed to load: %s", lpszFilename);
		return FALSE;
	}

	int monsterID = script.GetNumber();
	while (script.tok != FINISHED)
	{
		MonsterBuffData data;
		data.m_BuffId = script.GetNumber();
		data.m_Chance = script.GetNumber();
		m_mapMonsterBuffs.insert(make_pair(monsterID, data));
		monsterID = script.GetNumber();
	}
	return TRUE;
}
#endif // __MONSTER_BUFFS
Code:
#ifdef __MONSTER_BUFFS
	map< int, MonsterBuffData >::iterator it = prj.m_mapMonsterBuffs.find(m_pDefender->m_dwIndex);
	if (prj.m_mapMonsterBuffs.end() != it)
	{
		MonsterBuffData data = it->second;
		if ((int)xRandom(1000) < data.m_Chance)
		{
			ItemProp* pProp = prj.GetItemProp(data.m_BuffId);
			if (pProp)
				m_pAttacker->DoApplySkill(m_pAttacker, pProp, NULL);
		}
	}
#endif // __MONSTER_BUFFS
Now you cann add another column in your MonsterBuffs.inc:
Code:
MI_AIBATT1	II_SYS_SYS_LS_LOVE  500
MI_AIBATT2	II_SYS_SYS_LS_BLESSING 100
10 = 1%
Thank you very much :D