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.

CustomInventory: A_Log happens before pickup message?

Postby wildweasel » Wed Dec 20, 2017 7:11 pm

Code: Select allExpand view
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 allExpand view
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
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 15 Jul 2003

Re: CustomInventory: A_Log happens before pickup message?

Postby phantombeta » Wed Dec 20, 2017 10:55 pm

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 INVENTORY.AUTOACTIVATE and INVENTORY.ALWAYSPICKUP flags, setting the max to 1 and using the Use state instead.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: CustomInventory: A_Log happens before pickup message?

Postby wildweasel » Thu Dec 21, 2017 9:45 am

phantombeta wrote:You could use the INVENTORY.AUTOACTIVATE and INVENTORY.ALWAYSPICKUP 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.
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 15 Jul 2003


Return to Scripting

Who is online

Users browsing this forum: Awario [RSS] and 3 guests