Setting life to a specific number is broken
Moderators: FranAvalon, Marek14, CCGHQ Admins
Setting life to a specific number is broken
by 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?
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?
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 10 guests