Skip to content

Commit

Permalink
WAGE: Implement performHealingMagic()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 14, 2016
1 parent df609fb commit adc5b87
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion engines/wage/combat.cpp
Expand Up @@ -254,7 +254,42 @@ void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
}

void WageEngine::performHealingMagic(Chr *chr, Obj *magicalObject) {
warning("STUB: performHealingMagic()");
char buf[512];

if (!chr->_playerCharacter) {
snprintf(buf, 512, "%s%s %ss %s%s.",
chr->getDefiniteArticle(true), chr->_name.c_str(),
magicalObject->_operativeVerb.c_str(),
getIndefiniteArticle(magicalObject->_name), magicalObject->_name.c_str());
appendText(buf);
}

int chance = _rnd->getRandomNumber(255);
if (chance < magicalObject->_accuracy) {
int type = magicalObject->_attackType;

if (type == Obj::HEALS_PHYSICAL_DAMAGE || type == Obj::HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE)
chr->_context._statVariables[PHYS_HIT_CUR] += magicalObject->_damage;

if (type == Obj::HEALS_SPIRITUAL_DAMAGE || type == Obj::HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE)
chr->_context._statVariables[SPIR_HIT_CUR] += magicalObject->_damage;

playSound(magicalObject->_sound);
appendText(magicalObject->_useMessage.c_str());

// TODO: what if enemy heals himself?
if (chr->_playerCharacter) {
double physicalPercent = (double)chr->_context._statVariables[PHYS_HIT_CUR] / chr->_context._statVariables[PHYS_HIT_BAS];
double spiritualPercent = (double)chr->_context._statVariables[SPIR_HIT_CUR] / chr->_context._statVariables[SPIR_HIT_BAS];
snprintf(buf, 256, "Your physical condition is %s.", getPercentMessage(physicalPercent));
appendText(buf);

snprintf(buf, 256, "Your spiritual condition is %s.", getPercentMessage(spiritualPercent));
appendText(buf);
}
}

decrementUses(magicalObject);
}

static const int directionsX[] = { 0, 0, 1, -1 };
Expand Down

0 comments on commit adc5b87

Please sign in to comment.