Intentionally making a Pickup Delay

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!)
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Intentionally making a Pickup Delay

Post by Matt »

I can think of a couple approaches to this.

What exactly is the desired effect?

Is it something like this?

1. Stand in front of thing
2. Hold use in front of thing for 100 tics ("Plucking apple from tree...")
3. On success, the real item is on standby for xyz tics ("Apple plucked and eaten. Digesting...")
4. While waiting for those xyz tics, player is free to go anywhere ("Digesting...")
5. Once the xyz tics are up, the item is fully "done" ("Apple digested. Blood sugar restored to normal.")
6. The original object interacted with stays exactly where it is and does not move ("There are more apples in this tree.")
User avatar
AFADoomer
Posts: 1324
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: Intentionally making a Pickup Delay

Post by AFADoomer »

Caligari87 wrote:I think something like this may be more in line with the intent

Code: Select all

int holdCounter;

override void touch(Actor toucher){ }

override bool used(Actor user)
{
    holdCounter++;
    if(holdCounter >= 100)
    {
        Super.touch(user);
    }
// Tell the player that they weren't really holding down use, so that this function will re-run on the next tick as long as you keep holding down use
    if (user.player) { user.player.usedown = false; } 
    return true;
}
Of course you'll want to add some extra code to reset the hold counter if the item isn't being actively used
I added a line (the comment and the next line) to Caligari's example that should make this code work... I've implemented an almost identical solution in the current Blade of Agony dev builds, so I know this works.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Intentionally making a Pickup Delay

Post by Caligari87 »

Code: Select all

if (user.player) { user.player.usedown = false; }
That is wicked clever.

8-)
User avatar
insightguy
Posts: 1730
Joined: Tue Mar 22, 2011 11:54 pm

Re: Intentionally making a Pickup Delay

Post by insightguy »

AFADoomer wrote:
Caligari87 wrote:I think something like this may be more in line with the intent

Code: Select all

int holdCounter;

override void touch(Actor toucher){ }

override bool used(Actor user)
{
    holdCounter++;
    if(holdCounter >= 100)
    {
        Super.touch(user);
    }
// Tell the player that they weren't really holding down use, so that this function will re-run on the next tick as long as you keep holding down use
    if (user.player) { user.player.usedown = false; } 
    return true;
}
Of course you'll want to add some extra code to reset the hold counter if the item isn't being actively used
I added a line (the comment and the next line) to Caligari's example that should make this code work... I've implemented an almost identical solution in the current Blade of Agony dev builds, so I know this works.
AFADoomer, If I could Kiss you now I would. Thanks! This is exactly what I was looking for.

Now All I need to do is figureout why A_takeinventory does not work.
Post Reply

Return to “Scripting”