- exported a few more functions.

- refactored the ModifyDamage interface to be more scripting friendly.

In general it should be avoided having to call directly into chained inventory functions because they are very problematic and prone to errors. So this got wrapped into a single handler (on AActor, not AInventory!) which will later make it easier to refactor the parameters of ModifyDamage to work better for scripting and avoid the chaining.
This commit is contained in:
Christoph Oelckers 2016-11-27 11:59:47 +01:00
commit b10ffb5133
8 changed files with 71 additions and 11 deletions

View file

@ -7158,6 +7158,23 @@ DEFINE_ACTION_FUNCTION(AActor, ClearCounters)
return 0;
}
int AActor::GetModifiedDamage(FName damagetype, int damage, bool passive)
{
if (Inventory != nullptr)
Inventory->ModifyDamage(damage, damagetype, damage, false);
return damage;
}
DEFINE_ACTION_FUNCTION(AActor, GetModifiedDamage)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_NAME(type);
PARAM_INT(damage);
PARAM_BOOL(passive);
ACTION_RETURN_INT(self->GetModifiedDamage(type, damage, passive));
}
int AActor::ApplyDamageFactor(FName damagetype, int damage) const
{
damage = int(damage * DamageFactor);
@ -7168,6 +7185,14 @@ int AActor::ApplyDamageFactor(FName damagetype, int damage) const
return damage;
}
DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactor)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_NAME(type);
PARAM_INT(damage);
ACTION_RETURN_INT(self->ApplyDamageFactor(type, damage));
}
void AActor::SetTranslation(FName trname)
{