Safety Mechanism For Custom Inventory

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
hima3009
Posts: 25
Joined: Wed Oct 06, 2021 5:58 pm

Safety Mechanism For Custom Inventory

Post by hima3009 »

I've Made/collected this inventory items for my zandronum server but the problem is the items keep overriding themselves every time i press the use button which can easily happen accidentally.
Is there anything i can do to prevent using the items prematurely?
Attachments
INVDOOMhima.wad
(113.49 KiB) Downloaded 17 times
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Safety Mechanism For Custom Inventory

Post by Blue Shadow »

There are multiple items in that WAD you posted. Which item are you having trouble with?
hima3009
Posts: 25
Joined: Wed Oct 06, 2021 5:58 pm

Re: Safety Mechanism For Custom Inventory

Post by hima3009 »

All of them..
When you tybe "give all" command , you will get them with their maximum amout , but you can reactivate them all by the activation key even before their activation time has finished which will lead to accidental use and ultimately deplete them all.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Safety Mechanism For Custom Inventory

Post by Blue Shadow »

Here's the fixed version of the WAD: https://www.dropbox.com/s/ucnr6hnq8damn ... a.zip?dl=1

What I did:
  • Medikit - Changed from CustomInventory to [wiki=Classes:HealthPickup]HealthPickup[/wiki].
  • BlurSphereST and PowerStim - Changed from CustomInventory to [wiki=Classes:HealthPickup]PowerupGiver[/wiki].
hima3009
Posts: 25
Joined: Wed Oct 06, 2021 5:58 pm

Re: Safety Mechanism For Custom Inventory

Post by hima3009 »

Thank you very much, this is exactly what i wanted.
this was bugging me for the last 2 month yet i couldn't figure out what i should do, thought it needed some ACS fancy stuff.

Edit : let me know if I can execute ACS in PowerUpGiver.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Safety Mechanism For Custom Inventory

Post by Blue Shadow »

hima3009 wrote: Edit : let me know if I can execute ACS in PowerUpGiver.
No, you can't. Not by using DECORATE, anyway. You need [wiki]ZScript[/wiki] for that. If DECORATE is your only choice, which I imagine it is since Zandronum doesn't have ZScript, then you're going to have to change them back to CustomInventory if you want to do something extra, like executing an ACS script. However, doing so might send you back to square one with the problem you were having.
hima3009
Posts: 25
Joined: Wed Oct 06, 2021 5:58 pm

Re: Safety Mechanism For Custom Inventory

Post by hima3009 »

It's my fault i didn't state my plans first, so what i was planning to do is when you activate the item a timer is shown up somewhere in the screen to display how much time left before the item is depleted.
so probably what i'll do in the future is revert back Custominventory when every i learn about "Checkinventory" in ACS script.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Safety Mechanism For Custom Inventory

Post by Blue Shadow »

Instead of fiddling around with the item, you could run a looping ACS script which [wiki=GetActorPowerupTics]gets the time of the powerup[/wiki] in question and prints it on the screen. If you use an ENTER-type script, then you don't need to execute it from any item, as it's executed when the player enters the map.

Code: Select all

script "DrawPowerupsTime" Enter
{
    while (true)
    {
        // Do stuff here...

        Delay(1);
    }
} 
hima3009
Posts: 25
Joined: Wed Oct 06, 2021 5:58 pm

Re: Safety Mechanism For Custom Inventory

Post by hima3009 »

Hey, sorry to bother you.. can you give me a timer example for "PowerGhost" as i really tried all the stuff i know but i couldn't make a timer for the love of god.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Safety Mechanism For Custom Inventory

Post by Blue Shadow »

Here's something I quickly just put together:

Code: Select all

function int DoDrawPowerupTime (str powerup, int y)
{
    int tics = GetActorPowerupTics(0, powerup);

    if (tics > 0)
    {
        int ticsToSecs = tics / 35;
        int sec = ticsToSecs % 60;
        int min = (ticsToSecs % 3600) / 60;
        str seconds = StrParam(d:sec);
        if (sec < 10) seconds = StrParam(s:"0", s:seconds);
        str minutes = StrParam(d:min);
        if (min < 10) minutes = StrParam(s:"0", s:minutes);
        HudMessage(s:minutes, s:":", s:seconds; HUDMSG_PLAIN, 0, CR_FIRE, 0.05, y, 1873);
        y += 0.05;
    }

    return y;
}

script "DrawPowerupsTime" Enter
{
    int y;

    while (true)
    {
        y = DoDrawPowerupTime("PowerGhost", 0.05);
        y = DoDrawPowerupTime("PowerWeaponLevel2", y);
        y = DoDrawPowerupTime("PowerFlight", y);
        y = DoDrawPowerupTime("PowerInvulnerable", y);
        y = DoDrawPowerupTime("PowerTorch", y);
        Delay(1);
    }
}
What it does is draw the timers of the powerups you see in a list from the top-left corner of the screen.
hima3009
Posts: 25
Joined: Wed Oct 06, 2021 5:58 pm

Re: Safety Mechanism For Custom Inventory

Post by hima3009 »

That's exactly what i wanted , Thank you very much.
I edited the script to make it look the way i wanted:

here is the modification:

Code: Select all

#include "zcommon.acs"

function int DoDrawGhostTime (str powerup, int y)
{
    int tics = GetActorPowerupTics(0, powerup);

    if (tics > 0)
    {
        int ticsToSecs = tics / 35;
        int sec = ticsToSecs % 60;
        int min = (ticsToSecs % 3600) / 60;
        str seconds = StrParam(d:sec);
        if (sec < 10) seconds = StrParam(s:"0", s:seconds);
        str minutes = StrParam(d:min);
        if (min < 10) minutes = StrParam(s:"0", s:minutes);
        SetFont ("BIGFONT");
        HudMessage(s:"Blur Sphere"; HUDMSG_PLAIN, -5, CR_BLUE, 0.05, 0.4, 0.1);
        HudMessage(s:seconds; HUDMSG_PLAIN , 0, CR_Green, 0.16,0.4, 0.1);
        y += 0.05;
    }

    return y;
}


Script "DrawGhostTime" Enter 
{
 int y;

    while (true)
    {
        y = DoDrawGhostTime("PowerGhost", 0.05);
       
        Delay(1);
    }
}
Script "DrawGhostTimeagain" RESPAWN 
{
 int y;

    while (true)
    {
        y = DoDrawGhostTime("PowerGhost", 0.05);
       Delay(1);
        
    }
}





function int DoDrawSpeedTime (str powerup, int x)
{
    int tics = GetActorPowerupTics(0, powerup);

    if (tics > 0)
    {
        int ticsToSecs = tics / 35;
        int sec = ticsToSecs % 60;
        int min = (ticsToSecs % 3600) / 60;
        str seconds = StrParam(d:sec);
        if (sec < 10) seconds = StrParam(s:"0", s:seconds);
        str minutes = StrParam(d:min);
        if (min < 10) minutes = StrParam(s:"0", s:minutes);
        SetFont ("BIGFONT");
        HudMessage(s:"Speed"; HUDMSG_PLAIN, -6, CR_White, 0.05, 0.42, 0.1);
        HudMessage(s:seconds; HUDMSG_PLAIN , 0, CR_Green, 0.16,0.42, 0.1);
        x += 0.05;
    }

    return x;
}

script "DrawSpeedTime" ENTER
{
    int x;

    while (true)
    {
        x = DoDrawSpeedTime("PowerSpeed", 0.05);
       
        Delay(1);
    }
}
script "DrawSpeedTimeagain" RESPAWN
{
    int x;

    while (true)
    {
        x = DoDrawSpeedTime("PowerSpeed", 0.05);
       
        Delay(1);
    }
}

#Define DrawInvunTime      510
#Define DrawInvunTimeagain 511



function int DoDrawInvunTime (str powerup, int z)
{
    int tics = GetActorPowerupTics(0, powerup);

    if (tics > 0)
    {
        int ticsToSecs = tics / 35;
        int sec = ticsToSecs % 60;
        int min = (ticsToSecs % 3600) / 60;
        str seconds = StrParam(d:sec);
        if (sec < 10) seconds = StrParam(s:"0", s:seconds);
        str minutes = StrParam(d:min);
        if (min < 10) minutes = StrParam(s:"0", s:minutes);
        SetFont ("BIGFONT");
        HudMessage(s:"Invulnerable"; HUDMSG_PLAIN, -7, CR_GOLD, 0.05, 0.44, 0.1);
        HudMessage(s:seconds; HUDMSG_PLAIN , 0, CR_Green, 0.16,0.44, 0.1);
        z += 0.05;
    }

    return z;
}

script DrawInvunTime ENTER
{
    int z;

    while (true)
    {
        z = DoDrawInvunTime("PowerInvulnerable", 0.05);
       
        Delay(1);
		
    }
	
}
script DrawInvunTimeagain RESPAWN
{
    int z;

    while (true)
    {
        z = DoDrawInvunTime("PowerInvulnerable", 0.05);
       
        Delay(1);
    }
}

function int DoDrawAMPTime (str powerup, int a)
{
    int tics = GetActorPowerupTics(0, powerup);

    if (tics > 0)
    {
        int ticsToSecs = tics / 35;
        int sec = ticsToSecs % 60;
        int min = (ticsToSecs % 3600) / 60;
        str seconds = StrParam(d:sec);
        if (sec < 10) seconds = StrParam(s:"0", s:seconds);
        str minutes = StrParam(d:min);
        if (min < 10) minutes = StrParam(s:"0", s:minutes);
        SetFont ("BIGFONT");
        HudMessage(s:" Light Goggles "; HUDMSG_PLAIN, -8, CR_RED, 0.05, 0.46, 0.1);
        HudMessage(s:minutes, s:":",s:seconds; HUDMSG_PLAIN , 0, CR_Green, 0.165,0.46, 0.1);
        a += 0.05;
    }

    return a;
}

script "DrawAMPTime" ENTER
{
    int a;

    while (true)
    {
        a = DoDrawAMPTime("PowerLightAmp", 0.05);
       
        Delay(1);
    }
}
script "DrawAMPagain" RESPAWN
{
    int a;

    while (true)
    {
        a = DoDrawAMPTime("PowerLightAmp", 0.05);
       
        Delay(1);
    }
}


Post Reply

Return to “Scripting”