Jump to content

Fix Blood Pill


Recommended Posts

  • Active Member

https://en-wiki.metin2.gameforge.com/index.php/Blood_Pill

-Items Blood Pill-

Fixed the Blood Pill item

 

Use by right clicking the item

When a Blood Pill is used you will notice a minus sign (-) to the left side of your character's screen . Clicking that takes one point from the stat you choose and you can add it to another stat later .

 

#1 Bug

If you have x94 stat and hit 4 pills and spend 4 stat at the end when you add another stat then the stat doubles from 90 to 160

 

#2 Bug

In some serverfiles it stat can be as high as -90 -80 -70 -30 -10

1) OPEN: cmd_general.cpp
2) Search: ACMD(do_stat_minus)
3) Change with:

ACMD(do_stat_minus)
{
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));

    if (!*arg1)
        return;

    if (ch->IsPolymorphed())
    {
        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑 중에는 능력을 올릴 수 없습니다."));
        return;
    }

    if (ch->GetPoint(POINT_STAT_RESET_COUNT) <= 0)
        return;

    if (!strcmp(arg1, "st"))
    {
        if (ch->GetRealPoint(POINT_ST) <= JobInitialPoints[ch->GetJob()].st)
            return;
        BYTE stpoints = 0;
        stpoints = POINT_ST;
        ch->SetRealPoint(stpoints, ch->GetRealPoint(stpoints) - 1);
        ch->SetPoint(stpoints, ch->GetPoint(stpoints) - 1);
        ch->ComputePoints();
        ch->PointChange(stpoints, 0);
    }
    else if (!strcmp(arg1, "dx"))
    {
        if (ch->GetRealPoint(POINT_DX) <= JobInitialPoints[ch->GetJob()].dx)
            return;
        BYTE dxpoints = 0;
        dxpoints = POINT_DX;
        ch->SetRealPoint(dxpoints, ch->GetRealPoint(dxpoints) - 1);
        ch->SetPoint(dxpoints, ch->GetPoint(dxpoints) - 1);
        ch->ComputePoints();
        ch->PointChange(dxpoints, 0);
    }
    else if (!strcmp(arg1, "ht"))
    {
        if (ch->GetRealPoint(POINT_HT) <= JobInitialPoints[ch->GetJob()].ht)
            return;
        BYTE htpoints = 0;
        htpoints = POINT_HT;
        ch->SetRealPoint(htpoints, ch->GetRealPoint(htpoints) - 1);
        ch->SetPoint(htpoints, ch->GetPoint(htpoints) - 1);
        ch->ComputePoints();
        ch->PointChange(htpoints, 0);
        ch->PointChange(POINT_MAX_SP, 0);
    }
    else if (!strcmp(arg1, "iq"))
    {
        if (ch->GetRealPoint(POINT_IQ) <= JobInitialPoints[ch->GetJob()].iq)
            return;
        BYTE iqpoints = 0;
        iqpoints = POINT_IQ;
        ch->SetRealPoint(iqpoints, ch->GetRealPoint(iqpoints) - 1);
        ch->SetPoint(iqpoints, ch->GetPoint(iqpoints) - 1);
        ch->ComputePoints();
        ch->PointChange(iqpoints, 0);
        ch->PointChange(POINT_MAX_HP, 0);
    }
    else
        return;

    ch->PointChange(POINT_STAT, + 1);
    ch->PointChange(POINT_STAT_RESET_COUNT, - 1);
    ch->ComputePoints();
}

 

 

Edited by Draveniou1
  • Metin2 Dev 4
  • Good 1
  • Love 2
Link to comment
Share on other sites

  • Honorable Member

From the default code, only POINT_MAX_SP and POINT_MAX_SP are swapped. The rest is the same. Am I missing something?
 

Small refactory: (using a table I can shorten far more)

ACMD(do_stat_minus)
{
	char arg1[256];
	one_argument(argument, arg1, sizeof(arg1));

	if (!*arg1)
		return;

	if (ch->IsPolymorphed())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("µÐ°© Áß¿¡´Â ´É·ÂÀ» ¿Ã¸± ¼ö ¾ø½À´Ï´Ù."));
		return;
	}

	if (ch->GetPoint(POINT_STAT_RESET_COUNT) <= 0)
		return;

	auto pointId = POINT_NONE;
	if (!strcmp(arg1, "st"))
	{
		pointId = POINT_ST;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].st)
			return;
	}
	else if (!strcmp(arg1, "dx"))
	{
		pointId = POINT_DX;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].dx)
			return;
	}
	else if (!strcmp(arg1, "ht"))
	{
		pointId = POINT_HT;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].ht)
			return;
	}
	else if (!strcmp(arg1, "iq"))
	{
		pointId = POINT_IQ;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].iq)
			return;
	}
	else
		return;

	if (pointId == POINT_NONE)
		return;

	ch->SetRealPoint(pointId, ch->GetRealPoint(pointId) - 1);
	ch->SetPoint(pointId, ch->GetPoint(pointId) - 1);
	ch->ComputePoints();
	ch->PointChange(pointId, 0);

	if (pointId == POINT_IQ) // HT?
		ch->PointChange(POINT_MAX_HP, 0);
	else if (pointId == POINT_HT) // IQ?
		ch->PointChange(POINT_MAX_SP, 0);

	ch->PointChange(POINT_STAT, +1);
	ch->PointChange(POINT_STAT_RESET_COUNT, -1);
	ch->ComputePoints();
}

 

  • Metin2 Dev 3
  • Love 1
Link to comment
Share on other sites

  • Active Member
21 minutes ago, martysama0134 said:

From the default code, only POINT_MAX_SP and POINT_MAX_SP are swapped. The rest is the same. Am I missing something?
 

Small refactory: (using a table I can shorten far more)

ACMD(do_stat_minus)
{
	char arg1[256];
	one_argument(argument, arg1, sizeof(arg1));

	if (!*arg1)
		return;

	if (ch->IsPolymorphed())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("µÐ°© Áß¿¡´Â ´É·ÂÀ» ¿Ã¸± ¼ö ¾ø½À´Ï´Ù."));
		return;
	}

	if (ch->GetPoint(POINT_STAT_RESET_COUNT) <= 0)
		return;

	auto pointId = POINT_NONE;
	if (!strcmp(arg1, "st"))
	{
		pointId = POINT_ST;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].st)
			return;
	}
	else if (!strcmp(arg1, "dx"))
	{
		pointId = POINT_DX;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].dx)
			return;
	}
	else if (!strcmp(arg1, "ht"))
	{
		pointId = POINT_HT;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].ht)
			return;
	}
	else if (!strcmp(arg1, "iq"))
	{
		pointId = POINT_IQ;
		if (ch->GetRealPoint(pointId) <= JobInitialPoints[ch->GetJob()].iq)
			return;
	}
	else
		return;

	if (pointId == POINT_NONE)
		return;

	ch->SetRealPoint(pointId, ch->GetRealPoint(pointId) - 1);
	ch->SetPoint(pointId, ch->GetPoint(pointId) - 1);
	ch->ComputePoints();
	ch->PointChange(pointId, 0);

	if (pointId == POINT_IQ) // HT?
		ch->PointChange(POINT_MAX_HP, 0);
	else if (pointId == POINT_HT) // IQ?
		ch->PointChange(POINT_MAX_SP, 0);

	ch->PointChange(POINT_STAT, +1);
	ch->PointChange(POINT_STAT_RESET_COUNT, -1);
	ch->ComputePoints();
}

 

Let's try this too

I think you need "BYTE" because it returns NULL if I'm not mistaken

I'm not 100% sure but I think we need BYTE in this case

  • Facepalm 1
Link to comment
Share on other sites

  • Active Member

I changed the code

The Code is 100% fixed and works perfectly

Idea by @ martysama0134 thanks you friends,  It helped me to make the code even better than before  

 

 

ACMD(do_stat_minus)
{
	char	arg1[256], arg2[256];
	two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
	int vlaxc = 1;
	str_to_number(vlaxc, arg2);
	if (!*arg1 || vlaxc <= 0)
		return;
	if (ch->IsPolymorphed())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑 중에는 능력을 올릴 수 없습니다."));
		return;
	}
	if (ch->GetPoint(POINT_STAT_RESET_COUNT) <= 0)
		return;

	BYTE idx = 0;
	
	if (!strcmp(arg1, "st"))
	{
		if (ch->GetRealPoint(POINT_ST) <= JobInitialPoints[ch->GetJob()].st)
		{
			return;
		}
		idx = POINT_ST;
	}
	else if (!strcmp(arg1, "dx"))
	{
		if (ch->GetRealPoint(POINT_DX) <= JobInitialPoints[ch->GetJob()].dx)
		{
			return;
		}
		idx = POINT_DX;
	}
	else if (!strcmp(arg1, "ht"))
	{
		if (ch->GetRealPoint(POINT_HT) <= JobInitialPoints[ch->GetJob()].ht)
		{
			return;
		}
		idx = POINT_HT;
	}
	else if (!strcmp(arg1, "iq"))
	{
		if (ch->GetRealPoint(POINT_IQ) <= JobInitialPoints[ch->GetJob()].iq)
		{
			return;
		}
		idx = POINT_IQ;
	}
	else
		return;

	if (idx == 0)
		return;

	if (vlaxc > ch->GetPoint(POINT_STAT_RESET_COUNT))
		vlaxc = ch->GetPoint(POINT_STAT_RESET_COUNT);

	if (ch->GetRealPoint(idx) - vlaxc > MAX_STAT)
		vlaxc = MAX_STAT + ch->GetRealPoint(idx);

	ch->SetRealPoint(idx, ch->GetRealPoint(idx) - vlaxc);
	ch->SetPoint(idx, ch->GetPoint(idx) - vlaxc);
	ch->ComputePoints();
	ch->PointChange(idx, 0);

	if (idx == POINT_IQ)
		ch->PointChange(POINT_MAX_HP, 0);
	else if (idx == POINT_HT)
		ch->PointChange(POINT_MAX_SP, 0);

	ch->PointChange(POINT_STAT, + vlaxc);
	ch->PointChange(POINT_STAT_RESET_COUNT, - vlaxc);
	ch->ComputePoints();
}

 

Edited by Draveniou1
  • Think 1
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.