Getting attacking player TID/Pointer (Zandro-compatible)

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
User avatar
ConflagratedCanine
Posts: 29
Joined: Fri Feb 18, 2011 1:13 pm

Getting attacking player TID/Pointer (Zandro-compatible)

Post by ConflagratedCanine »

So I'm completely reworking an existing system for a multiplayer mod, one that would benefit significantly from being able to give inventory items to a player when they attack another.
Previously, I assumed A_GiveToTarget in a painstate would work the same way as it does in a deathstate: this is not the case, and I may have questioned if I was suffering from mild psychosis after producing no results.

I considered using the weapon code as players are the only bleeding actor in the game, but unfortunately all of my weapons, uh, "explode" as a means of simulating swing arcs - As far as I know, I can't trace a successful 'hit' from those back to the attacker.

I might need some help chewing this one out. :oops:
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: Getting attacking player TID/Pointer (Zandro-compatible)

Post by Leonard2 »

ConflagratedCanine wrote:I assumed A_GiveToTarget in a painstate would work the same way as it does in a deathstate: this is not the case
It does if you use the flag +QUICKTORETALIATE on the playerpawn actor.
By the way, for the flag to correctly work, make sure the playerpawn actor doesn't have the FRIENDLY flag set otherwise it will break (I ran into this issue myself previously).
This of course will work in 3.0.
One last thing, make sure in the decorate code that whatever you want to do with the pointer is done at the same time the pain state is entered (using stuff like acs_executewithresult) that way you can be sure the pointer will remain untouched by other parts of the engine (I heard there were some issues in the past with the target pointer, can't be 100% sure).
My memory could be playing tricks on me, it's been so long, tell me if this works out for you.
User avatar
ConflagratedCanine
Posts: 29
Joined: Fri Feb 18, 2011 1:13 pm

Re: Getting attacking player TID/Pointer (Zandro-compatible)

Post by ConflagratedCanine »

... I just gave all the weapons LOF/LOS checks so I can award inventory items for attempted strikes, as well. I'm going to add your suggestion and see if I can work it in for some extra flexibility.
Post Reply

Return to “Scripting”