Return type for Decorate weapon functions

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
Rip and Tear
Posts: 185
Joined: Tue May 02, 2017 3:54 pm

Return type for Decorate weapon functions

Post by Rip and Tear »

Suggestion:
Add return types to Decorate weapon functions like A_CustomPunch for accessing the actor hit by the attack (if any).
User avatar
Rachael
Posts: 13557
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Return type for Decorate weapon functions

Post by Rachael »

I don't think that's possible for the simple reason that multiple actors can be damaged in one hit, and ZScript has no method of handling multiple return values like Lua (as far as I know).

Plus, certain "hits" have a delayed effect and therefore can't be returned by a function like this anyway.
User avatar
Rip and Tear
Posts: 185
Joined: Tue May 02, 2017 3:54 pm

Re: Return type for Decorate weapon functions

Post by Rip and Tear »

Rachael wrote:I don't think that's possible for the simple reason that multiple actors can be damaged in one hit, and ZScript has no method of handling multiple return values like Lua (as far as I know).

Plus, certain "hits" have a delayed effect and therefore can't be returned by a function like this anyway.
It wouldn't be feasible for every single attack function, but there are still functions like A_CustomPunch and A_Saw that preform instant hitscan attacks that can only hit one target.
User avatar
phantombeta
Posts: 2088
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Return type for Decorate weapon functions

Post by phantombeta »

Rachael wrote:I don't think that's possible for the simple reason that multiple actors can be damaged in one hit, and ZScript has no method of handling multiple return values like Lua (as far as I know).

Plus, certain "hits" have a delayed effect and therefore can't be returned by a function like this anyway.
[wiki=ZScript_functions#Multiple_Returns]The wiki says it can return multiple values, apparently.[/wiki]
Couldn't it return a dynamic array anyway? (Since IIRC ZScript has those natively)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Return type for Decorate weapon functions

Post by Graf Zahl »

Multiple returns in the given context are not possible because you need to know up front how many values there are, and there's an internal compiler limit of 8.
Dynamic scripts cannot be returned because those are not but structs internally.
Post Reply

Return to “Feature Suggestions [GZDoom]”