CustomInventory: A_Log happens before pickup message?

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
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

CustomInventory: A_Log happens before pickup message?

Post by wildweasel »

Code: Select all

ACTOR ShotgunGiver : CustomInventory replaces Shotgun
{
	Inventory.PickupMessage "KS-23 Riot Shotgun: \"Turns a riot into a laugh riot!\""
	Inventory.PickupSound "misc/w_pkup"
	Scale 0.3
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_CheckFlag("TOSSED", "DropNothing")
		KSSG A -1
		Wait
	DropNothing:
		TNT1 A 0
		Stop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("PumpShotgun", 1, 2)
		TNT1 A 0 A_GiveInventory("PumpShotgun", 1)
		Stop
		TNT1 A 0 A_GiveInventory("DualPumpShotgun", 1)
		TNT1 A 0 A_Log("Now with twice the taste! (Dual Wield)")
		Stop
	}
}
This CustomInventory item is designed to handle the giving of dual-wielding for a specific weapon in WW-Cola3 - it gives PumpShotgun first, but DualPumpShotgun if the player already has PumpShotgun, and then displays an auxiliary pickup message indicating that dual-wield is available. However, I'm noticing that the A_Log statement is appearing before the natural pickup message in game, for example:

Code: Select all

Now with twice the taste! (Dual Wield)
KS-23 Riot Shotgun: "Turns a riot into a laugh riot!"
Which doesn't quite fit the intended delivery of the message. Is this some sort of undefined behavior I'm encountering here? Is there a more proper way to make the A_Log happen after the pickup message?
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: CustomInventory: A_Log happens before pickup message?

Post by phantombeta »

It's the normal behaviour. The Pickup state is run when picking up, and it allows you to determine whether or not to pick up by using the "Stop" and "Fail" flow control keywords, which means it's necessary to have it run before you've actually picked the item up.
You could use the [wiki=Actor_flags#INVENTORY.AUTOACTIVATE]INVENTORY.AUTOACTIVATE[/wiki] and [wiki=Actor_flags#INVENTORY.ALWAYSPICKUP]INVENTORY.ALWAYSPICKUP[/wiki] flags, setting the max to 1 and using the Use state instead.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: CustomInventory: A_Log happens before pickup message?

Post by wildweasel »

phantombeta wrote:You could use the [wiki=Actor_flags#INVENTORY.AUTOACTIVATE]INVENTORY.AUTOACTIVATE[/wiki] and [wiki=Actor_flags#INVENTORY.ALWAYSPICKUP]INVENTORY.ALWAYSPICKUP[/wiki] flags, setting the max to 1 and using the Use state instead.
Strangely, that produces the same behavior, so I've realized what I could do instead is nullify the normal pickup message and simply place an A_Log in both cases, producing a unique message instead of tacking a second message after the normal one.

Thank you for the explanation, though. I'd wondered about that.
Post Reply

Return to “Scripting”