It is currently 19 Apr 2024, 23:32
   
Text Size

Setting life to a specific number is broken

Moderators: FranAvalon, Marek14, CCGHQ Admins

Setting life to a specific number is broken

Postby travolter » 16 Nov 2012, 20:35

Here's how CLifeModifier is applied to a player (Modifiers.cpp, starting at line 599):

Code:
if (m_bReplacement)
{
ATLASSERT(!SpecialNumber::IsSpecialNumber(GET_INTEGER(m_nLifeDelta)));
if (SpecialNumber::IsSpecialNumber(GET_INTEGER(m_nLifeDelta)))
return;

pPlayer->SetLife(m_nLifeDelta);
return;
}

Life nLifeDelta(m_nLifeDelta);
if (m_nLifeDelta == Life(SpecialNumber::DivideBy2RoundUp))
{
Life nPreviousLife(pPlayer->GetLife());
Life nNewLife(nPreviousLife / Life(2));
nLifeDelta = nNewLife - nPreviousLife;
}
else
if (m_nLifeDelta == Life(SpecialNumber::DivideBy2RoundDown))
{
Life nPreviousLife(pPlayer->GetLife());
Life nNewLife((nPreviousLife + Life(1)) / Life(2));
nLifeDelta = nNewLife - nPreviousLife;
}
else
if (m_nLifeDelta == Life(SpecialNumber::MultiplyBy2))
{
nLifeDelta = pPlayer->GetLife();
}

if (nLifeDelta == Life(0))
return;

if (nLifeDelta<Life(0) && m_DamageType == DamageType::NotDealingDamage)
pPlayer->AddLifeLossTakenThisTurn(-nLifeDelta);
pPlayer->ChangeLife(
Damage(m_pSourceCard, nLifeDelta, m_Preventable, m_DamageType));



That first bit is the part that checks whether it's replacing the life total. If it is, it sets the player's life right there, doesn't do AddLifeLossTakenThisTurn (which should happen if that player loses life), and doesn't go through ChangeLife at all, so it's incompatible with Boon Reflection.

I tried moving Life nLifeDelta(m_nLifeDelta); to the beginning of that section, then setting nLifeDelta inside the "if (m_bReplacement)" bit to "m_nLifeDelta - pPlayer->GetLife()"

No formatting errors. It compiles. But it crashes every time Blessed Wind tries to resolve.

I thought maybe the problem was that m_Preventable was set to Preventable and m_DamageType was set to NonCombatDamage by default, so I set those (to NotPreventable and NotDealingDamage) in Modifiers.h line 622. It still crashed. (That might have caused problems with other cards, but I think if that was the problem, it at least would have solved this one.)

I've spent over 2 hours on just this. Please, does anybody have any idea what's going wrong here?
travolter
 
Posts: 250
Joined: 26 Mar 2012, 17:56
Has thanked: 4 times
Been thanked: 8 times

Return to Engine Bugs

Who is online

Users browsing this forum: No registered users and 10 guests


Who is online

In total there are 10 users online :: 0 registered, 0 hidden and 10 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 10 guests

Login Form