[SOLVED] Calculating the damage an actor would receive
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
[SOLVED] Calculating the damage an actor would receive
Is there a way to calculate the damage an actor would receive, modifed by DamageType, in DamageMobj, before returning Super.DamageMobj()?
The only way I could see it work is to create one specific item per actor, which has the exact same DamageFactors, and then given to the actor. This item could then be accessed in DamageMobj to call it's ModifyDamage or ApplyDamageFactors functions.
The only way I could see it work is to create one specific item per actor, which has the exact same DamageFactors, and then given to the actor. This item could then be accessed in DamageMobj to call it's ModifyDamage or ApplyDamageFactors functions.
Last edited by Cherno on Sat Apr 04, 2020 7:36 pm, edited 1 time in total.
Re: Calculating the effective damage an actor would receive
You mean calculate amount of damage actor would receive inside overridden damagemobj? If yes, then
Code: Select all
override int damagemobj(arguments)
{
int original_damage = super.damagemobj(arguments);
and virtual still executes, because its not hit return word
}
- phantombeta
- Posts: 2178
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Calculating the effective damage an actor would receive
As far as I can tell, the OP wants to calculate the damage that would be dealt but without actually dealing it. Your answer does not do that.
Re: Calculating the effective damage an actor would receive
Correct!phantombeta wrote:As far as I can tell, the OP wants to calculate the damage that would be dealt but without actually dealing it. Your answer does not do that.
Re: Calculating the effective damage an actor would receive
Hmm, I remember I doing something like that and use DamageMobj.
If its not work, there are ApplyDamageFactor function
https://github.com/coelckers/gzdoom/blo ... or.zs#L664
If its not work, there are ApplyDamageFactor function
https://github.com/coelckers/gzdoom/blo ... or.zs#L664
Re: Calculating the effective damage an actor would receive
AppplyDamageFactor is an Inventory function though, see OP.
Re: Calculating the effective damage an actor would receive
Eeeee, no, its an actor function.
Re: Calculating the effective damage an actor would receive
Sorry, I mistyped. It is indeed an actor function. However, it requires an Inventory class parameter.Apeirogon wrote:Eeeee, no, its an actor function.
Re: Calculating the effective damage an actor would receive
What makes you think so?
Its literally directly called in C++ DamageMobj function, to adjust damage by actors matching to damage type factor.
https://github.com/coelckers/gzdoom/blo ... .cpp#L1171
Target there is an actor which are harmed.
Its literally directly called in C++ DamageMobj function, to adjust damage by actors matching to damage type factor.
https://github.com/coelckers/gzdoom/blo ... .cpp#L1171
Target there is an actor which are harmed.
Re: Calculating the effective damage an actor would receive
From the wiki:
You are right again, the function can be called without passing anything but damage and mod. Thanks for the help!
The wiki article doesn't mention this quite important fact.
Edit:Returns the value passed to damage after adjustment, which is done by multiplying it with the chosen damage factor from the specified item class
You are right again, the function can be called without passing anything but damage and mod. Thanks for the help!
The wiki article doesn't mention this quite important fact.