Jump to content
  • 0

Sash Absorption % Calculation


Shahin
Go to solution Solved by Ikarus_,

Question

Hello guys, is there anyone willing to share the Absorption % code from item.cpp ?

I have Miss-matching sash absorption for weapon and armor. It is not Precise. The min & Max values absorpted are not correct and i don't know how to correct it myself...

 

The code from item.cpp starts:

if ((GetType() == ITEM_COSTUME) && (GetSubType() == COSTUME_SASH) && (GetSocket(SASH_ABSORBED_SOCKET)))

 

Thank you ^^

Link to post

Recommended Posts

  • 1
  • Solution

the problem about the 29 vs 28 is just a rounding error.

i m enoght sure you will solve it by making the 'viewed value' identical to the server side value (which is added as bonus) by copying from the c++ the formula and applying it to the python formula in uitooltip.py.

 

long lAttGrade = pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5];
if (pkItemAbsorbed->alValues[3] > pkItemAbsorbed->alValues[4])
	lAttGrade = pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5];

double dValue = lAttGrade * GetSocket(ACCE_ABSORPTION_SOCKET);
dValue = (double)dValue / 100;
dValue = (double)dValue + .5;

 

 

I suspect that the other formula into python is a bit different (especially for the + .5)

 

I ll update this post asap with the other fix (min and max attack) because it's longer to explain and i ve to find the time.

 

 

############### update ############

Spoiler

 let's start with where the server is 'applying' the min and max attack to use it to calculate the damage (in short, where they are really used).

let's change it in order to consider the sash attack (min and max):

 

hit damage calculation part in battle.cpp:





#ifdef ENABLE_ACCE_SYSTEM //replace it with your define for sash
static void ApplyAcceAttackValue(LPITEM pkItem, int* pdamMin, int* pdamMax) 
{
	LPCHARACTER ch = pkItem ? pkItem->GetOwner() : NULL;
	if (!ch)
		return;

	LPITEM acceItem = ch->GetWear(WEAR_COSTUME_ACCE);
	if (!acceItem)
		return;

	TItemTable* pkItemAbsorbed = ITEM_MANAGER::instance().GetTable(acceItem->GetSocket(ACCE_ABSORBED_SOCKET));
	if (!pkItemAbsorbed)
		return;

	if (pkItemAbsorbed->bType != ITEM_WEAPON)
		return;

	double AttBonusMax = static_cast<double>(pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5]);
	AttBonusMax *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	AttBonusMax /= 100;
	AttBonusMax += 0.5;

	double AttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5]);
	AttBonusMin *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	AttBonusMin /= 100;
	AttBonusMin += 0.5;

	*pdamMax += static_cast<int>(AttBonusMax);
	*pdamMin += static_cast<int>(AttBonusMin);
}
#endif


void Item_GetDamage(LPITEM pkItem, int* pdamMin, int* pdamMax)
{
	*pdamMin = 0;
	*pdamMax = 1;

	if (!pkItem)
		return;

	switch (pkItem->GetType())
	{
		case ITEM_ROD:
		case ITEM_PICK:
			return;
	}

	if (pkItem->GetType() != ITEM_WEAPON)
		sys_err("Item_GetDamage - !ITEM_WEAPON vnum=%d, type=%d", pkItem->GetOriginalVnum(), pkItem->GetType());

	*pdamMin = pkItem->GetValue(3);
	*pdamMax = pkItem->GetValue(4);

#ifdef ENABLE_ACCE_SYSTEM //replace it with your define for sash
	ApplyAcceAttackValue(pkItem, pdamMin, pdamMax);
#endif
}

 

 

 

skill damage calculation part in char_skill.cpp:

 





#ifdef ENABLE_ACCE_SYSTEM //replace it with your define for sash
#include "item_manager.h"
static void ApplyAcceAttackValue(LPITEM pkItem, int* pWepAtt, int* pMagAtt)
{
	LPCHARACTER ch = pkItem ? pkItem->GetOwner() : NULL;
	if (!ch)
		return;

	LPITEM acceItem = ch->GetWear(WEAR_COSTUME_ACCE);
	if (!acceItem)
		return;

	TItemTable* pkItemAbsorbed = ITEM_MANAGER::instance().GetTable(acceItem->GetSocket(ACCE_ABSORBED_SOCKET));
	if (!pkItemAbsorbed)
		return;

	if (pkItemAbsorbed->bType != ITEM_WEAPON)
		return;

	double WepAttBonusMax = static_cast<double>(pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5]);
	WepAttBonusMax *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	WepAttBonusMax /= 100;
	WepAttBonusMax += 0.5;

	double WepAttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5]);
	WepAttBonusMin *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	WepAttBonusMin /= 100;
	WepAttBonusMin += 0.5;

	double MagAttBonusMax = static_cast<double>(pkItemAbsorbed->alValues[2] + pkItemAbsorbed->alValues[5]);
	MagAttBonusMax *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	MagAttBonusMax /= 100;
	MagAttBonusMax += 0.5;

	double MagAttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[1] + pkItemAbsorbed->alValues[5]);
	MagAttBonusMin *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	MagAttBonusMin /= 100;
	MagAttBonusMin += 0.5;

	if(pWepAtt)
		*pWepAtt += number(static_cast<int>(WepAttBonusMin), static_cast<int>(WepAttBonusMax));

	if(pMagAtt)
		*pMagAtt += number(static_cast<int>(MagAttBonusMin), static_cast<int>(MagAttBonusMax));
}
#endif

void SetPolyVarForAttack(LPCHARACTER ch, CSkillProto * pkSk, LPITEM pkWeapon)
{
	if (ch->IsPC())
	{
		if (pkWeapon && pkWeapon->GetType() == ITEM_WEAPON)
		{
			int iWep = number(pkWeapon->GetValue(3), pkWeapon->GetValue(4));
			iWep += pkWeapon->GetValue(5);

			int iMtk = number(pkWeapon->GetValue(1), pkWeapon->GetValue(2));
			iMtk += pkWeapon->GetValue(5);

#ifdef ENABLE_ACCE_SYSTEM //replace it with your define for sash
			ApplyAcceAttackValue(pkWeapon, &iWep, &iMtk);
#endif

			pkSk->SetPointVar("wep", iWep);
			pkSk->SetPointVar("mtk", iMtk);
			pkSk->SetPointVar("mwep", iMtk);
		}
		else
		{
			pkSk->SetPointVar("wep", 0);
			pkSk->SetPointVar("mtk", 0);
			pkSk->SetPointVar("mwep", 0);
		}
	}
	else
	{
		int iWep = number(ch->GetMobDamageMin(), ch->GetMobDamageMax());
		pkSk->SetPointVar("wep", iWep);
		pkSk->SetPointVar("mwep", iWep);
		pkSk->SetPointVar("mtk", iWep);
	}
}

 

 

 

 

 

 

Now we can just remove the part where the sash is applying the attack grade (it's here that is doing wrong) in item.cpp so let's remove it:





			else if (pkItemAbsorbed->bType == ITEM_WEAPON)
			{
				long lAttGrade = pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5];
				if (pkItemAbsorbed->alValues[3] > pkItemAbsorbed->alValues[4])
					lAttGrade = pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5];

				double dValue = lAttGrade * GetSocket(ACCE_ABSORPTION_SOCKET);
				dValue = (double)dValue / 100;
				dValue = (double)dValue + .5;
				lAttGrade = (long) dValue;
				if (((pkItemAbsorbed->alValues[3] > 0) && (lAttGrade < 1)) || ((pkItemAbsorbed->alValues[4] > 0) && (lAttGrade < 1)))
					lAttGrade += 1;
				else if ((pkItemAbsorbed->alValues[3] > 0) || (pkItemAbsorbed->alValues[4] > 0))
					lAttGrade += 1;

				m_pOwner->ApplyPoint(APPLY_ATT_GRADE_BONUS, bAdd ? lAttGrade : -lAttGrade);

				long lAttMagicGrade = pkItemAbsorbed->alValues[2] + pkItemAbsorbed->alValues[5];
				if (pkItemAbsorbed->alValues[1] > pkItemAbsorbed->alValues[2])
					lAttMagicGrade = pkItemAbsorbed->alValues[1] + pkItemAbsorbed->alValues[5];

				dValue = lAttMagicGrade * GetSocket(ACCE_ABSORPTION_SOCKET);
				dValue = (double)dValue / 100;
				dValue = (double)dValue + .5;
				lAttMagicGrade = (long) dValue;
				if (((pkItemAbsorbed->alValues[1] > 0) && (lAttMagicGrade < 1)) || ((pkItemAbsorbed->alValues[2] > 0) && (lAttMagicGrade < 1)))
					lAttMagicGrade += 1;
				else if ((pkItemAbsorbed->alValues[1] > 0) || (pkItemAbsorbed->alValues[2] > 0))
					lAttMagicGrade += 1;

				m_pOwner->ApplyPoint(APPLY_MAGIC_ATT_GRADE, bAdd ? lAttMagicGrade : -lAttMagicGrade);
			}

 

 

 

 

 

 

 

 

 

 

Client side part:

 

 

Let's open uitooltip.py in order to solve the 28 vs 29 value bug.

here the changes to make:





#find
		def CalcAcceValue(self, value, abs):
			if not value:
				return 0
			
			valueCalc = int((round(value * abs) / 100) - 0.5) + int(int((round(value * abs) / 100) - 0.5) > 0)
			if valueCalc <= 0 and value > 0:
				value = 1
			else:
				value = valueCalc
			
			return value

#replace with
		def CalcAcceValue(self, value, abs):
			if not value:
				return 0
			
			valueCalc 	= round(value * abs) / 100
			valueCalc 	+= 0.5 #changed the -0.5 which + 0.5 (rounding bug)
			valueCalc 	= int(valueCalc) +1 if valueCalc > 0 else int(valueCalc)
			value 		= 1 if (valueCalc <= 0 and value > 0) else valueCalc
			return value

 

 

 

 

after that we can finally solve the bug in the character board (where is only summed the max attack)

 


void CPythonPlayer::__UpdateBattleStatus()
{
	m_playerStatus.SetPoint(POINT_NONE, 0);
	m_playerStatus.SetPoint(POINT_EVADE_RATE, __GetEvadeRate());
	m_playerStatus.SetPoint(POINT_HIT_RATE, __GetHitRate());
	m_playerStatus.SetPoint(POINT_MIN_WEP, m_dwWeaponMinPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MAX_WEP, m_dwWeaponMaxPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MIN_MAGIC_WEP, m_dwWeaponMinMagicPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MAX_MAGIC_WEP, m_dwWeaponMaxMagicPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MIN_ATK, __GetTotalAtk(m_dwWeaponMinPower, m_dwWeaponAddPower));
	m_playerStatus.SetPoint(POINT_MAX_ATK, __GetTotalAtk(m_dwWeaponMaxPower, m_dwWeaponAddPower));

#ifdef ENABLE_ACCE_SYSTEM //change it with your sash define
	auto ItemData = GetItemData({INVENTORY, c_Costume_Slot_Acce});
	if (ItemData)
	{
		auto AbsorbedVnum = ItemData->alSockets[1];
		if (AbsorbedVnum != 0 && CItemManager::Instance().SelectItemData(AbsorbedVnum))
		{
			auto SelectedItemData = CItemManager::Instance().GetSelectedItemDataPointer();
			if (SelectedItemData->GetType() == CItemData::ITEM_TYPE_WEAPON || (SelectedItemData->GetType() == CItemData::ITEM_TYPE_COSTUME && SelectedItemData->GetSubType() == CItemData::COSTUME_WEAPON))
			{
				auto oldMinWep = m_playerStatus.GetPoint(POINT_MIN_WEP);
				auto oldMaxWep = m_playerStatus.GetPoint(POINT_MAX_WEP);

				auto oldMinMag = m_playerStatus.GetPoint(POINT_MIN_MAGIC_WEP);
				auto oldMaxMag = m_playerStatus.GetPoint(POINT_MAX_MAGIC_WEP);

				auto oldMinAtt = m_playerStatus.GetPoint(POINT_MIN_ATK);
				auto oldMaxAtt = m_playerStatus.GetPoint(POINT_MAX_ATK);

				double sashAbsorbPerc = static_cast<double>(ItemData->alSockets[0]);
				auto sashMinWep = static_cast<double>(SelectedItemData->GetValue(3) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0) + 0.5;
				auto sashMaxWep = static_cast<double>(SelectedItemData->GetValue(4) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0) + 0.5;
				auto sashMinMag = static_cast<double>(SelectedItemData->GetValue(1) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0) + 0.5;
				auto sashMaxMag = static_cast<double>(SelectedItemData->GetValue(2) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0) + 0.5;


				m_playerStatus.SetPoint(POINT_MIN_WEP, oldMinWep + sashMinWep);
				m_playerStatus.SetPoint(POINT_MAX_WEP, oldMaxWep + sashMaxWep);

				m_playerStatus.SetPoint(POINT_MIN_MAGIC_WEP, oldMinMag + sashMinMag);
				m_playerStatus.SetPoint(POINT_MAX_MAGIC_WEP, oldMaxMag + sashMaxMag);

				m_playerStatus.SetPoint(POINT_MIN_ATK, oldMinAtt + sashMinWep);
				m_playerStatus.SetPoint(POINT_MAX_ATK, oldMaxAtt + sashMaxWep);
			}
		}
	}
#endif
}

 

 

 

 

 


 

 

 

 

VERY BIG DISCLAIMER:

IT'S UNTESTED AND UNCOMPILED CODE.

VISUAL STUDIO DOESNT SHOW ANY ERROR SO YOU SHOULDN'T GET ERRORS ON COMPILING.

SINCE IS UNTESTED I SUGGEST TO TEST IT BEFORE TO APPLY IT TO AN OPEN SERVER.

 

 

 

 

 

 

Edited by Ikarus_ (see edit history)
  • Love 2

My youtube channel  on which you can see my works here

Link to post
  • 0

Hello @Ikarus_, thank you for your feedback. 

  • I have Lennt 0.3, the __SASH_SYSTEM__

I have the same lines in my system as well, but i have a problem calculating both values.

10e23f6448a7d40a9a58beedf34551a5.gif

The problem is: Only Max Value from the weapon was absorpted, and set to both Max and Min values.. (server side) Client side is normal as it should be...

 

Socket 0 is set for the sash absorption % , i see that. 

QgtP5AC.png

Socket 1 is set for the Max value of weapon attack value

 

Also, if you can see, i have the values incremented by 1. Instead of receiving 28 max value, i get 29. The same thing at Magical attack.

 

What i am trying to say: How to make the sash take both Min & Max values from my item? instead of only Max values?

Also how to get that value normal, not incremented?

 

If your values are correct, could you send me your item.cpp ? I need to see the Calculation formula as some other lines from there, i might've forgot something...

 

 

 

Edited by Shahin (see edit history)
Link to post
  • 0
20 hours ago, Ikarus_ said:

the problem about the 29 vs 28 is just a rounding error.

i m enoght sure you will solve it by making the 'viewed value' identical to the server side value (which is added as bonus) by copying from the c++ the formula and applying it to the python formula in uitooltip.py.

 

long lAttGrade = pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5];
if (pkItemAbsorbed->alValues[3] > pkItemAbsorbed->alValues[4])
	lAttGrade = pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5];

double dValue = lAttGrade * GetSocket(ACCE_ABSORPTION_SOCKET);
dValue = (double)dValue / 100;
dValue = (double)dValue + .5;

 

 

I suspect that the other formula into python is a bit different (especially for the + .5)

 

I ll update this post asap with the other fix (min and max attack) because it's longer to explain and i ve to find the time.

If you'd like, you can add me on discord and i will copy paste the fix afterwards.

Shahin#4229

 

Link to post
  • 0

Nope thanks, i really prefer to write here what i ve to explain you, because i don't really do this for you, i do this for the whole community. I prefer my explanation to be accessible to all who have your problem.

 

I ve updated with the complete answer.

Edited by Ikarus_ (see edit history)
  • Love 5

My youtube channel  on which you can see my works here

Link to post
  • 0
On 11/3/2020 at 2:06 AM, Ikarus_ said:

Nope thanks, i really prefer to write here what i ve to explain you, because i don't really do this for you, i do this for the whole community. I prefer my explanation to be accessible to all who have your problem.

 

I ve updated with the complete answer.

The client side works, but the server side compilation gave me an error.

Please, take a look:

RXbAt7k.png

 

Link to post
  • 0
16 minutes ago, Ikarus_ said:

put them as static void

 

void ApplyAcceAttackValue(LPITEM pkItem, int* pdamMin, int* pdamMax) 

 

i've changed in the code above

The values for Magic attack for min and max are good now, but i don't get Normal Attack bonuses at all...

Link to post
  • 0
2 minutes ago, Shahin said:

The values for Magic attack for min and max are good now, but i don't get Normal Attack bonuses at all...

 

Can you please show me your void CPythonPlayer::__UpdateBattleStatus()

 

Can you please try to hit a mob with and without the sash to check if server-side the bonus are applied?

 

And last question, can you tell me if you changed the define with your one?

Edited by Ikarus_ (see edit history)
  • Love 1

My youtube channel  on which you can see my works here

Link to post
  • 0
7 minutes ago, Ikarus_ said:

 

Can you please show me your void CPythonPlayer::__UpdateBattleStatus()

 

Can you please try to hit a mob with and without the sash to check if server-side the bonus are applied?

 

And last question, can you tell me if you changed the define with your one?

Define is changed, i checked before doing any modifications, also, if it wans't a good define, neither magic attack should've work, right?

 

Normal attack with or without the sash is the same while attacking a mob.

 

CPythonPlayer::__UpdateBattleStatus():

Spoiler

void CPythonPlayer::__UpdateBattleStatus()
{
    m_playerStatus.SetPoint(POINT_NONE, 0);
    m_playerStatus.SetPoint(POINT_EVADE_RATE, __GetEvadeRate());
    m_playerStatus.SetPoint(POINT_HIT_RATE, __GetHitRate());
    m_playerStatus.SetPoint(POINT_MIN_WEP, m_dwWeaponMinPower + m_dwWeaponAddPower);
    m_playerStatus.SetPoint(POINT_MAX_WEP, m_dwWeaponMaxPower + m_dwWeaponAddPower);
    m_playerStatus.SetPoint(POINT_MIN_MAGIC_WEP, m_dwWeaponMinMagicPower + m_dwWeaponAddPower);
    m_playerStatus.SetPoint(POINT_MAX_MAGIC_WEP, m_dwWeaponMaxMagicPower + m_dwWeaponAddPower);
    m_playerStatus.SetPoint(POINT_MIN_ATK, __GetTotalAtk(m_dwWeaponMinPower, m_dwWeaponAddPower));
    m_playerStatus.SetPoint(POINT_MAX_ATK, __GetTotalAtk(m_dwWeaponMaxPower, m_dwWeaponAddPower));

#ifdef ENABLE_SASH_SYSTEM
    auto ItemData = GetItemData({ INVENTORY, c_Costume_Slot_Sash });
    if (ItemData)
    {
        auto AbsorbedVnum = ItemData->alSockets[1];
        if (AbsorbedVnum != 0 && CItemManager::Instance().SelectItemData(AbsorbedVnum))
        {
            auto SelectedItemData = CItemManager::Instance().GetSelectedItemDataPointer();
            if (SelectedItemData->GetType() == CItemData::ITEM_TYPE_WEAPON)
            {
                auto oldMinWep = m_playerStatus.GetPoint(POINT_MIN_WEP);
                auto oldMaxWep = m_playerStatus.GetPoint(POINT_MAX_WEP);
                auto oldMinMag = m_playerStatus.GetPoint(POINT_MIN_MAGIC_WEP);
                auto oldMaxMag = m_playerStatus.GetPoint(POINT_MAX_MAGIC_WEP);

                double sashAbsorbPerc = static_cast<double>(ItemData->alSockets[0]);
                auto sashMinWep = static_cast<double>(SelectedItemData->GetValue(3) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc / 100.0);
                auto sashMaxWep = static_cast<double>(SelectedItemData->GetValue(4) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc / 100.0);
                auto sashMinMag = static_cast<double>(SelectedItemData->GetValue(1) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc / 100.0);
                auto sashMaxMag = static_cast<double>(SelectedItemData->GetValue(2) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc / 100.0);


                m_playerStatus.SetPoint(POINT_MIN_WEP, oldMinWep + sashMinWep);
                m_playerStatus.SetPoint(POINT_MAX_WEP, oldMaxWep + sashMaxWep);
                m_playerStatus.SetPoint(POINT_MIN_MAGIC_WEP, oldMinMag + sashMinMag);
                m_playerStatus.SetPoint(POINT_MAX_MAGIC_WEP, oldMaxMag + sashMaxMag);
            }
        }
    }
#endif
}

 

 

My server define is __SASH_SYSTEM__

My binary define is ENABLE_SASH_SYSTEM

Checked in both service.h & locale_inc.h

Edited by Shahin (see edit history)
Link to post
  • 0

Let's debug it one by one.

At first, the hit damage adjustments.

 

//todebug help you to find where i ve added debug

 



#ifdef ENABLE_ACCE_SYSTEM //replace it with your define for sash
static void ApplyAcceAttackValue(LPITEM pkItem, int* pdamMin, int* pdamMax) 
{
	LPCHARACTER ch = pkItem ? pkItem->GetOwner() : NULL;
	if (!ch)
		return;

	LPITEM acceItem = ch->GetWear(WEAR_COSTUME_ACCE);
	if (!acceItem)
		return;

	TItemTable* pkItemAbsorbed = ITEM_MANAGER::instance().GetTable(acceItem->GetSocket(ACCE_ABSORBED_SOCKET));
	if (!pkItemAbsorbed)
		return;

	if (pkItemAbsorbed->bType != ITEM_WEAPON)
		return;

	double AttBonusMax = static_cast<double>(pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5]);
	AttBonusMax *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	AttBonusMax /= 100;
	AttBonusMax += 0.5;

	double AttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5]);
	AttBonusMin *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET);
	AttBonusMin /= 100;
	AttBonusMin += 0.5;
      
    //todebug
    if(ch->IsPhase(PHASE_GAME))
    	ch->ChatPacket(CHAT_TYPE_INFO, "Going to add to your attack : min(%0.2f) max(%0.2f) ", AttBonusMin, AttBonusMax);
      
	*pdamMax += static_cast<int>(AttBonusMax);
	*pdamMin += static_cast<int>(AttBonusMin);
}

 

 

You may need to add #include "desc.h" at the beginning of the file if you got errors on IsPhase line

 

In order to debug the code you need to use a sash with attack min and max as bonuses and to hit a mob

 

Edited by Ikarus_ (see edit history)
  • Love 1

My youtube channel  on which you can see my works here

Link to post
  • 0
7 minutes ago, WeedHex said:

Meme Reaction GIF by Silicon Valley

Dear WeedHex, i have tried your version of calculation, but sadly only one value was set for bot Min and Max.

Your Calculation Method might be good but the sash absorption in lennt v0.3 is wrong for gathering both value. It is using one value for both min and max...

 

Thanks to @Ikarus_ i managed to make the Magic attack work as it should (min and max values), and we try to make normal attack work as well.

 

Link to post
  • 0
1 hour ago, Shahin said:

OaE15Og.png

#include "desc.h" was already included in the file and still with errors

 

My bad, ch->GetDesc()->IsPhase

 

  • Love 1

My youtube channel  on which you can see my works here

Link to post
  • 0
4 minutes ago, Ikarus_ said:

 

My bad, ch->GetDesc()->IsPhase

 

JtDjgJJ.png

with the code:

    //todebug
    if(ch->GetDesc()->IsPhase)
        ch->ChatPacket(CHAT_TYPE_INFO, "Going to add to your attack : min(%0.2f) max(%0.2f) ", AttBonusMin, AttBonusMax);

 

Link to post
  • 0
2 hours ago, Shahin said:

JtDjgJJ.png

with the code:


    //todebug
    if(ch->GetDesc()->IsPhase)
        ch->ChatPacket(CHAT_TYPE_INFO, "Going to add to your attack : min(%0.2f) max(%0.2f) ", AttBonusMin, AttBonusMax);

 

 

I ve confused you i think.

here the complete ifstatement

if(ch->GetDesc()->IsPhase(PHASE_GAME))

 

Edited by Ikarus_ (see edit history)
  • Love 1

My youtube channel  on which you can see my works here

Link to post
  • 0
2 hours ago, Ikarus_ said:

 

I ve confused you i think.

here the complete ifstatement

if(ch->GetDesc()->IsPhase(PHASE_GAME))

 

There is no text appearing while ingame when i equip a sash. 

Tried building other sashes and still nothing.

I guess the code is not read by the static void ApplyAcceAttackValue from battle.cpp

what now?

Link to post
  • 0
  • VIP
7 hours ago, Ikarus_ said:

In order to debug the code you need to use a sash with attack min and max as bonuses and to hit a mob

He did say, that you have to hit a mob.

Link to post
  • 0
17 minutes ago, Jxxkub said:

He did say, that you have to hit a mob.

 

4 hours ago, Ikarus_ said:

 

I ve confused you i think.

here the complete ifstatement


if(ch->GetDesc()->IsPhase(PHASE_GAME))

 

Thank you guys, so it was working server side but it is not showing in game

9Vc4nei.png

 

 

Edited by Shahin (see edit history)
Link to post
  • 0

Ok so the bug is just a visual bug.

You have to wear a sash with att min and max and to read the client syserr.txt

Let's debug it. (look at //todebug comment)

 

void CPythonPlayer::__UpdateBattleStatus()
{
	m_playerStatus.SetPoint(POINT_NONE, 0);
	m_playerStatus.SetPoint(POINT_EVADE_RATE, __GetEvadeRate());
	m_playerStatus.SetPoint(POINT_HIT_RATE, __GetHitRate());
	m_playerStatus.SetPoint(POINT_MIN_WEP, m_dwWeaponMinPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MAX_WEP, m_dwWeaponMaxPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MIN_MAGIC_WEP, m_dwWeaponMinMagicPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MAX_MAGIC_WEP, m_dwWeaponMaxMagicPower+m_dwWeaponAddPower);
	m_playerStatus.SetPoint(POINT_MIN_ATK, __GetTotalAtk(m_dwWeaponMinPower, m_dwWeaponAddPower));
	m_playerStatus.SetPoint(POINT_MAX_ATK, __GetTotalAtk(m_dwWeaponMaxPower, m_dwWeaponAddPower));

#ifdef ENABLE_ACCE_SYSTEM //change it with your sash define
	auto ItemData = GetItemData({INVENTORY, c_Costume_Slot_Acce});
	if (ItemData)
	{
		auto AbsorbedVnum = ItemData->alSockets[1];
		if (AbsorbedVnum != 0 && CItemManager::Instance().SelectItemData(AbsorbedVnum))
		{
			auto SelectedItemData = CItemManager::Instance().GetSelectedItemDataPointer();
			if (SelectedItemData->GetType() == CItemData::ITEM_TYPE_WEAPON)
			{
				auto oldMinWep = m_playerStatus.GetPoint(POINT_MIN_WEP);
				auto oldMaxWep = m_playerStatus.GetPoint(POINT_MAX_WEP);
				auto oldMinMag = m_playerStatus.GetPoint(POINT_MIN_MAGIC_WEP);
				auto oldMaxMag = m_playerStatus.GetPoint(POINT_MAX_MAGIC_WEP);

				double sashAbsorbPerc = static_cast<double>(ItemData->alSockets[0]);
				auto sashMinWep = static_cast<double>(SelectedItemData->GetValue(3) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0);
				auto sashMaxWep = static_cast<double>(SelectedItemData->GetValue(4) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0);
				auto sashMinMag = static_cast<double>(SelectedItemData->GetValue(1) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0);
				auto sashMaxMag = static_cast<double>(SelectedItemData->GetValue(2) + SelectedItemData->GetValue(5)) * (sashAbsorbPerc/100.0);
				
				//todebug
				TraceError("Going to add to your points : wep(min %f  max %f)  mag(min %f  max%f)", sashMinWep, sashMaxWep, sashMinMag, sashMaxMag);

				m_playerStatus.SetPoint(POINT_MIN_WEP, oldMinWep + sashMinWep);
				m_playerStatus.SetPoint(POINT_MAX_WEP, oldMaxWep + sashMaxWep);
				m_playerStatus.SetPoint(POINT_MIN_MAGIC_WEP, oldMinMag + sashMinMag);
				m_playerStatus.SetPoint(POINT_MAX_MAGIC_WEP, oldMaxMag + sashMaxMag);
			}
		}
	}
#endif
}

 

 

We should replace the if statement with this:
 

			if (SelectedItemData->GetType() == CItemData::ITEM_TYPE_WEAPON || (SelectedItemData->GetType() == CItemData::ITEM_TYPE_COSTUME && SelectedItemData->GetSubType() == CItemData::COSTUME_WEAPON))

 

Edited by Ikarus_ (see edit history)
  • Love 1

My youtube channel  on which you can see my works here

Link to post
  • 0
12 minutes ago, Ikarus_ said:

can i see your Status board (aka character window) while wearing the sash and without sash?

0c4af020503c115c138c10d2e487f7f3.gifAlso the increment now should be rounded with -.05 on sash , haha

The status board for magic damage is ok with the server side, also for attack rate.

The only thing is to show att damage in Caracter Board, also to round this :

wep(min 20.000000  max 28.000000)  mag(min 13.000000  max17.400000) to 17.000000

 

Edited by Shahin (see edit history)
Link to post
  • 0

I've updated the code at the first message about void CPythonPlayer::__UpdateBattleStatus()

copy it again from there and let me know.

I think i ve solved both the problem you reported

  • Love 1

My youtube channel  on which you can see my works here

Link to post
  • 0
51 minutes ago, Ikarus_ said:

I've updated the code at the first message about void CPythonPlayer::__UpdateBattleStatus()

copy it again from there and let me know.

I think i ve solved both the problem you reported

It is working PERFECT!! :D 

Also:

Urx8PGm.png The rounding bug was not a bug anymore after your serverside&clientside source fix.

Thank you very very much ! 

 

One last question: 

HYgg2tR.png

I see i'm getting the server side value +.5

why is that?

Edited by Shahin (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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