Informations from virtual function

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!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Informations from virtual function

Re: Informations from virtual function

by gwHero » Sat Feb 24, 2018 2:09 pm

Correct, it was more for this specific case.

Re: Informations from virtual function

by Apeirogon » Sat Feb 24, 2018 1:50 pm

It work only for this particular case.
But do we have, as example, can collide with events?

Looks like in this moment there are no way to obtain anything from virtual functions, without rewriting it.

Re: Informations from virtual function

by gwHero » Sat Feb 24, 2018 6:12 am

Just thinking.. maybe the event WorldThingDamaged would be of help?

Re: Informations from virtual function

by Apeirogon » Sat Feb 24, 2018 4:12 am

When I say "dont rewrite virtual functions" I mean "DONT TOUCH IT AT ALL, and left it pure and innocent as it was".

Like, I want make monster that remember all actors that hit it, pushing it into array "thing that I hate!!!!ONEONE", and pick target to chase from it depending of how much damage each of this actors inflict to it. Like, if caco inflict 30 damage to cyberdemon, imp 44 and player 12, cyberdemon first seek and destroy imp, then caco and only then player. Of course only if some one hit cyberdemon, while he chase player/dont have any target yet.

This can be easily, well....relatively easy, done with overiding damage mobj virtual. But it only works only for this cyberdemon/all actors that inherit from this base actor.
If I want do this for monster from other mod I need copy-paste code from my mod or change inheritance tree in other mod to make it inherit from my "monster base class".

I try do so using inventory items, give out each monster "thing that I hate" token/mark using spawn event handler, but they can get access to owners virtual functions "owner.super.damagemobj (paramethers)".
I focused on pointers, in case if this cant be done exactly as I want, save pointers and damage, to at least have monster that act "You hit me!? DIE!! And you hit me?! DIE!!! And you! And you! Oooo.... I see you come back from dead... I still remeber what you did last summer five minutes ago!!! DIE!!".

Maybe I should write this in first post...but this just example that I came up with one minutes ago...

Re: Informations from virtual function

by Matt » Sat Feb 24, 2018 2:07 am

Arctangent: "And I talk not about result, but for pointers."

I think Apeirogon means that sometimes an overridden virtual does some extra stuff that results in new data being produced that could be useful outside of the function. E.g., damagemobj might get you new information on damagetype, source, source's actual intended target, mass of inflictor, etc.

One other alternative would be to take whatever it is you want to do and actually put it inside that function, but that can get a bit bloaty.

Re: Informations from virtual function

by Arctangent » Sat Feb 24, 2018 12:23 am

I mean, if you mean actually rewriting the functions as opposed to avoiding overriding them entirely, you can just call i.e. return Super.DamageMobj( inflictor, source, damage, mod, flags, angle ); at the end of your overriden DamageMobj( inflictor, source, damage, mod, flags, angle ) and you'll retain the standard DamageMobj() functionality while being able to tack on your own, such as storing inflictor and source elsewhere.

Re: Informations from virtual function

by Matt » Fri Feb 23, 2018 10:10 pm

The only way I can think of is to create a pointer in the calling actor/thinker and store it in that...

Informations from virtual function

by Apeirogon » Sat Feb 17, 2018 9:40 am

Is there are any way to obtain data from virtual function? And I talk not about result, but for pointers. Mostly pointers...

Like, inside damage modj processed pointer "inflictor" and "source". I want extract that pointers, without rewriting damage mobj functions.
Is it possible?

Top