- removed the FxDamageValue hack and implemented it properly using FxReturnStatement.

- added handling of damage functions for ZScript.
This commit is contained in:
Christoph Oelckers 2016-10-26 14:04:49 +02:00
commit 7c759f9fcf
8 changed files with 37 additions and 36 deletions

View file

@ -184,6 +184,28 @@ PFunction *FindClassMemberFunction(PClass *selfcls, PClass *funccls, FName name,
return funcsym;
}
//==========================================================================
//
// CreateDamageFunction
//
// creates a damage function from the given expression
//
//==========================================================================
void CreateDamageFunction(PClassActor *info, AActor *defaults, FxExpression *id, bool fromDecorate)
{
if (id == nullptr)
{
defaults->DamageFunc = nullptr;
}
else
{
auto dmg = new FxReturnStatement(new FxIntCast(id, true), id->ScriptPosition);
auto funcsym = CreateAnonymousFunction(info, TypeSInt32, VARF_Method);
defaults->DamageFunc = FunctionBuildList.AddFunction(funcsym, dmg, FStringf("%s.DamageFunction", info->TypeName.GetChars()), fromDecorate);
}
}
//==========================================================================
//
// LoadActors