mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
Added inflictor, source and flag parameters to GetModifiedDamage on actors and ModifyDamage on inventory.
- The flags are used by DamageMobj so modders can determine radius damage, for example, by checking for DMG_EXPLOSION.
This commit is contained in:
parent
449610496f
commit
acc510dfb3
7 changed files with 17 additions and 14 deletions
|
@ -1422,7 +1422,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int ApplyDamageFactor(FName damagetype, int damage) const;
|
int ApplyDamageFactor(FName damagetype, int damage) const;
|
||||||
int GetModifiedDamage(FName damagetype, int damage, bool passive);
|
int GetModifiedDamage(FName damagetype, int damage, bool passive, AActor *inflictor, AActor *source, int flags = 0);
|
||||||
void DeleteAttachedLights();
|
void DeleteAttachedLights();
|
||||||
bool isFrozen();
|
bool isFrozen();
|
||||||
|
|
||||||
|
|
|
@ -1150,13 +1150,13 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
|
||||||
// Handle active damage modifiers (e.g. PowerDamage)
|
// Handle active damage modifiers (e.g. PowerDamage)
|
||||||
if (damage > 0 && !(flags & DMG_NO_ENHANCE))
|
if (damage > 0 && !(flags & DMG_NO_ENHANCE))
|
||||||
{
|
{
|
||||||
damage = source->GetModifiedDamage(mod, damage, false);
|
damage = source->GetModifiedDamage(mod, damage, false, inflictor, source, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle passive damage modifiers (e.g. PowerProtection), provided they are not afflicted with protection penetrating powers.
|
// Handle passive damage modifiers (e.g. PowerProtection), provided they are not afflicted with protection penetrating powers.
|
||||||
if (damage > 0 && !(flags & DMG_NO_PROTECT))
|
if (damage > 0 && !(flags & DMG_NO_PROTECT))
|
||||||
{
|
{
|
||||||
damage = target->GetModifiedDamage(mod, damage, true);
|
damage = target->GetModifiedDamage(mod, damage, true, inflictor, source, flags);
|
||||||
}
|
}
|
||||||
if (damage > 0 && !(flags & DMG_NO_FACTOR))
|
if (damage > 0 && !(flags & DMG_NO_FACTOR))
|
||||||
{
|
{
|
||||||
|
@ -1747,7 +1747,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPain
|
||||||
// Take half damage in trainer mode
|
// Take half damage in trainer mode
|
||||||
damage = int(damage * G_SkillProperty(SKILLP_DamageFactor) * sv_damagefactorplayer);
|
damage = int(damage * G_SkillProperty(SKILLP_DamageFactor) * sv_damagefactorplayer);
|
||||||
// Handle passive damage modifiers (e.g. PowerProtection)
|
// Handle passive damage modifiers (e.g. PowerProtection)
|
||||||
damage = target->GetModifiedDamage(player->poisontype, damage, true);
|
damage = target->GetModifiedDamage(player->poisontype, damage, true, nullptr, source);
|
||||||
// Modify with damage factors
|
// Modify with damage factors
|
||||||
damage = target->ApplyDamageFactor(player->poisontype, damage);
|
damage = target->ApplyDamageFactor(player->poisontype, damage);
|
||||||
|
|
||||||
|
|
|
@ -7217,15 +7217,15 @@ void AActor::ClearCounters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int AActor::GetModifiedDamage(FName damagetype, int damage, bool passive)
|
int AActor::GetModifiedDamage(FName damagetype, int damage, bool passive, AActor *inflictor, AActor *source, int flags)
|
||||||
{
|
{
|
||||||
auto inv = Inventory;
|
auto inv = Inventory;
|
||||||
while (inv != nullptr)
|
while (inv != nullptr)
|
||||||
{
|
{
|
||||||
IFVIRTUALPTRNAME(inv, NAME_Inventory, ModifyDamage)
|
IFVIRTUALPTRNAME(inv, NAME_Inventory, ModifyDamage)
|
||||||
{
|
{
|
||||||
VMValue params[5] = { (DObject*)inv, damage, int(damagetype), &damage, passive };
|
VMValue params[8] = { (DObject*)inv, damage, int(damagetype), &damage, passive, inflictor, source, flags };
|
||||||
VMCall(func, params, 5, nullptr, 0);
|
VMCall(func, params, 8, nullptr, 0);
|
||||||
}
|
}
|
||||||
inv = inv->Inventory;
|
inv = inv->Inventory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -799,9 +799,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, ClearCounters, ClearCounters)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetModifiedDamage(AActor *self, int type, int damage, bool passive)
|
static int GetModifiedDamage(AActor *self, int type, int damage, bool passive, AActor *inflictor, AActor *source, int flags)
|
||||||
{
|
{
|
||||||
return self->GetModifiedDamage(ENamedName(type), damage, passive);
|
return self->GetModifiedDamage(ENamedName(type), damage, passive, inflictor, source, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetModifiedDamage, GetModifiedDamage)
|
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetModifiedDamage, GetModifiedDamage)
|
||||||
|
@ -810,7 +810,10 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetModifiedDamage, GetModifiedDamage)
|
||||||
PARAM_NAME(type);
|
PARAM_NAME(type);
|
||||||
PARAM_INT(damage);
|
PARAM_INT(damage);
|
||||||
PARAM_BOOL(passive);
|
PARAM_BOOL(passive);
|
||||||
ACTION_RETURN_INT(self->GetModifiedDamage(type, damage, passive));
|
PARAM_OBJECT(inflictor, AActor);
|
||||||
|
PARAM_OBJECT(source, AActor);
|
||||||
|
PARAM_INT(flags);
|
||||||
|
ACTION_RETURN_INT(self->GetModifiedDamage(type, damage, passive, inflictor, source, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ApplyDamageFactor(AActor *self, int type, int damage)
|
static int ApplyDamageFactor(AActor *self, int type, int damage)
|
||||||
|
|
|
@ -651,7 +651,7 @@ class Actor : Thinker native
|
||||||
native void SpawnTeleportFog(Vector3 pos, bool beforeTele, bool setTarget);
|
native void SpawnTeleportFog(Vector3 pos, bool beforeTele, bool setTarget);
|
||||||
native Actor RoughMonsterSearch(int distance, bool onlyseekable = false, bool frontonly = false);
|
native Actor RoughMonsterSearch(int distance, bool onlyseekable = false, bool frontonly = false);
|
||||||
native int ApplyDamageFactor(Name damagetype, int damage);
|
native int ApplyDamageFactor(Name damagetype, int damage);
|
||||||
native int GetModifiedDamage(Name damagetype, int damage, bool passive);
|
native int GetModifiedDamage(Name damagetype, int damage, bool passive, Actor inflictor = null, Actor source = null, int flags = 0);
|
||||||
native bool CheckBossDeath();
|
native bool CheckBossDeath();
|
||||||
|
|
||||||
void A_Light(int extralight) { if (player) player.extralight = clamp(extralight, -20, 20); }
|
void A_Light(int extralight) { if (player) player.extralight = clamp(extralight, -20, 20); }
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ class Inventory : Actor
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
virtual void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive) {}
|
virtual void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor = null, Actor source = null, int flags = 0) {}
|
||||||
|
|
||||||
|
|
||||||
virtual bool Use (bool pickup) { return false; }
|
virtual bool Use (bool pickup) { return false; }
|
||||||
|
|
|
@ -1655,7 +1655,7 @@ class PowerDamage : Powerup
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive)
|
override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags)
|
||||||
{
|
{
|
||||||
if (!passive && damage > 0)
|
if (!passive && damage > 0)
|
||||||
{
|
{
|
||||||
|
@ -1749,7 +1749,7 @@ class PowerProtection : Powerup
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive)
|
override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags)
|
||||||
{
|
{
|
||||||
if (passive && damage > 0)
|
if (passive && damage > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue