Powerups, PowerupGivers, HUBPOWER & PERSISTENTPOWER upgrade items

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!)
User avatar
LolaHThicc
Posts: 7
Joined: Wed Dec 10, 2025 1:08 pm
Preferred Pronouns: She/Her

Powerups, PowerupGivers, HUBPOWER & PERSISTENTPOWER upgrade items

Post by LolaHThicc »

Hello! I'm a total zcript/ACS newbie and like many intrepid doom modders on here, am working on a zdoom engine game. I would like to apologize in advance if i don't know all the termonology or have misunderstandings of key concepts about scripting, coding and general modding stuff, i've tried my best to learn what i can, and have consulted a number of zdoom topics to check for solutions that have been solved, but there are a number of things that just aren't clicking for me.

What i want feels like it should be pretty straightforward; here i have a powerup that will increase your movement speed permanently, in a game world that has one single, continuous hub. I have plans for a number of permanent upgrades, such as a damage resistance upgrade, a jump ability upgrade, etc.
I tried using a token system as suggested by another thread on here, but no matter what i do, i just cant seem to get the powerup to carry into another level. I am probably using the token wrong.

Code: Select all

class speedmod : PowerupGiver
{
	Default
	{
	+COUNTITEM;
	+INVENTORY.ALWAYSPICKUP;
	+INVENTORY.AUTOACTIVATE;
	+INVENTORY.HUBPOWER;
	+INVENTORY.PERSISTENTPOWER;
	Inventory.Icon "UPG4A0";
	Tag "Speed Module";
	Speed 1.5;
	Powerup.Type "PowerSpeed";
	Inventory.PickupMessage "Picked up a speed module; movement speed has been increased by 50%!";
	}
	States
	{
	Spawn:
		UPG4 A -1 Bright;
		Loop;
	Pickup:
	UPG4 A 0 
	{
	A_GiveInventory("SpeedToken");
	A_GiveInventory("ambPowerSpeed");
	}
	Stop;
	}
}

class ambPowerSpeed : PowerSpeed
{
	Default
	{
	+INVENTORY.HUBPOWER;
	+INVENTORY.PERSISTENTPOWER;
	Speed 1.5;
	Powerup.Duration 0x7FFFFFFF;
	Powerspeed.NoTrail 1;
	}
}

class SpeedToken : Inventory
{
    Default
    {
        +INVENTORY.UNDROPPABLE;
    }

    override void Travelled()
    {
        if (Owner != null)
        {
            Owner.GiveInventory('speedmod', 1);
		}
	}
}

I did try to use an ACS script to check for the token on entering a level, but it also has not worked for me.

Code: Select all

script 3 ENTER {
	if (CheckInventory("SpeedToken"),0)
	{
	giveinventory("ambpowerspeed",1);
	}
}
I openly admit that i'm definitely doing it wrong, and my patchwork solution of pulling code from different solutions into one place is probably not helping. I would appriciate any suggestions from anybody willing to walk a beginner through this. Thanks!
User avatar
Average Raven Fan
Posts: 14
Joined: Sat Oct 05, 2024 12:00 am

Re: Powerups, PowerupGivers, HUBPOWER & PERSISTENTPOWER upgrade items

Post by Average Raven Fan »

Code: Select all

version "4.3.0"

class SpeedBoost : PowerSpeed
{
	Default
	{
		Speed 1.5;
		Powerup.Duration 0x7FFFFFFF;
		Powerspeed.NoTrail 1;
	}
}

class ArtifactSpeedBoost : Inventory replaces ArtiSpeedBoots
{
	Default
	{
		Inventory.MaxAmount 1;
	}
	
	States
	{
	Spawn:
		SPED ABCDEFGH 3 Bright;
		Loop;
	}
	
	override void DoEffect()
	{
		if(Owner && !Owner.CountInv("SpeedBoost"))
		{
			Owner.GiveInventory("SpeedBoost", 1);
		}
		Super.DoEffect();
	}
}
I remember trying something like that with Hexen's speed boots. Here's the code I used! Change the sprites to fit your game and give it a go and see if that's what you wanted!
User avatar
LolaHThicc
Posts: 7
Joined: Wed Dec 10, 2025 1:08 pm
Preferred Pronouns: She/Her

Re: Powerups, PowerupGivers, HUBPOWER & PERSISTENTPOWER upgrade items

Post by LolaHThicc »

that did the trick, I was estatic to see it finally work xD
thanks for taking the time to help me out!

Return to “Scripting”