Actor.Used does not work

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Actor.Used does not work

Post by Talon1024 »

I don't know if this is a bug with my ZScript code or GZDoom, but it looks like Actor.Used does nothing. The comment above the method definition in zscript/actor.txt indicates that it is called whenever someone presses "Use" on the actor. So, I tried using it myself, and now the zip line does not work as intended.

BTW, I searched the GZDoom source code using grep, and there were no matches for "DEFINE_ACTION_FUNCTION(AActor, Used)".
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Actor.Used does not work

Post by _mental_ »

Please define "does not work". The following sample work as expected for me

Code: Select all

class UsableTechLamp : TechLamp
{
	override bool Used(Actor user)
	{
		Console.Printf("Hello! I'm just a TechLamp");
		return false;
	}
}
Do 'summon UsableTechLamp' and press use on it. The message will be printed.

DEFINE_ACTION_FUNCTION is used for native methods only. Actor.Used() is fully defined in ZScript. In C++ code it's called from here.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Actor.Used does not work

Post by Blue Shadow »

From the commit message:
This method will only be called if the actor does not have the USESPECIAL flag - that one will be handled as before.
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Actor.Used does not work

Post by Talon1024 »

Thanks. I found out for myself that the USESPECIAL flag prevented Actor.Used from being called after doing a bit of experimenting.

I guess it's a question of either allowing Actor.Used and USESPECIAL to be combined, or explicitly specifying that Actor.Used cannot be used with USESPECIAL.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Actor.Used does not work

Post by Graf Zahl »

Both methods have mutually exclusive semantics. And the flag being a switchable property, unlike the virtual method, has to be given priority.
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Actor.Used does not work

Post by Talon1024 »

How about changing the comment above Actor.Used to this, then?

Code: Select all

// Called when the player presses 'use' and an actor is found, except if the
// UseSpecial flag is set. Use level.ExecuteSpecial to call action specials
// instead.
Pull request
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Actor.Used does not work

Post by Blue Shadow »

[wiki=Used]I added the function to the wiki[/wiki].
Post Reply

Return to “Closed Bugs [GZDoom]”