Tutorial : DoAddBuff function upgrade

04/01/2017 15:27 FlyServices#1
Hi, this tutorial aims to modify the DoAddBuff function in order to be able to choose the buff time. So, just copy and past the snippet in Ctrl.cpp/Ctrl.h

Code:
#ifdef __DO_ADD_BUFF
void CCtrl::DoAddBuff( DWORD dwSkill, int nLevel, int nTime, CCtrl *pTarget )
{
	if( pTarget )
	{
		ItemProp* pSkillProp;
		AddSkillProp* pAddSkillProp;
		GetSkillProp( &pSkillProp, &pAddSkillProp, dwSkill, nLevel, "DoActiveSkill" );
		
		if( pAddSkillProp )
		{
			DWORD dwSkillTime2 = pAddSkillProp->dwSkillTime;
			if( nTime && nTime > 0 )
			{
				nTime *= 1000;
				pAddSkillProp->dwSkillTime = nTime;
			}
			DoApplySkill( pTarget, pSkillProp, pAddSkillProp, 0, 0, FALSE, 0 );
#ifdef __WORLDSERVER        
			g_UserMng.AddDoApplySkill( this, pTarget->GetId(), dwSkill, nLevel );
#endif // __WORLDSERVER
			pAddSkillProp->dwSkillTime = dwSkillTime2;
		}
	}
}
#endif // __DO_ADD_BUFF
Code:
#ifdef __DO_ADD_BUFF
	void			DoAddBuff( DWORD dwSkill, int nLevel, int nTime, CCtrl *pTarget );
#endif // __DO_ADD_BUFF
Format example :
Code:
pUserTarget->DoAddBuff( SI_ASS_CHEER_CANNONBALL, 20, 3600, pUserTarget );
04/01/2017 16:10 Rhyder`#2
Makesure pTarget must not be NULL :) include target check to avoid server crash :)
04/01/2017 17:11 Sedrika#3
Quote:
Originally Posted by Rhyder` View Post
Makesure pTarget must not be NULL :) include target check to avoid server crash :)
First line in function: if (pTarget)

Also checking for nTime && nTime > 0 is the same.
04/01/2017 17:58 FlyServices#4
Quote:
Originally Posted by Sedrika View Post
First line in function: if (pTarget)

Also checking for nTime && nTime > 0 is the same.
Time > 0 => if you put 0, the buff time depend your INT
04/01/2017 18:49 Mognakor#5
Nobody noticing the obvious bug?

You modify your resource props, but never reset the value to the original one.

So either copy the original value into a temporal variable and modify the temporary variable, or reset the modified resource to the original one.
04/04/2017 05:04 FlyffServices#6
if( nTime && nTime > 0 )

If nTime higher than 0 then its always true (if(ntime)). Why you double check it lol

its like

if( variable && variable => 1 && isset(variable) && variable == true)

looooooooooooooooooooooooooooooooooooooooooooooooo ooooooool
04/04/2017 11:03 FlyServices#7
Quote:
Originally Posted by FlyffServices View Post
if( nTime && nTime > 0 )

If nTime higher than 0 then its always true (if(ntime)). Why you double check it lol

its like

if( variable && variable => 1 && isset(variable) && variable == true)

looooooooooooooooooooooooooooooooooooooooooooooooo ooooooool
Thank's Sedrika's parrot :handsdown: