Custom regeneration items?

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
XASSASSINX
Posts: 380
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Custom regeneration items?

Post by XASSASSINX »

Hello guys, been some good time since i posted here. Anyways, i have a question in regards with Custom Inventory:

How do i make a certain item that has a custom regeneration function? As in, it takes for instance 70 tics (2 seconds) to start giving health, but before that, it gives small doses of health, say, 1 per 10 tics. after that, it gives alot of health quickly? I've tried alot, from doing stuff like this:

Code: Select all

ACTOR SSTimpakSlow : CustomInventory
{
	Game Doom
	States
	{
	Pickup:
		MEDI A 15 A_giveInventory("healthbonus", 1)
		MEDI A 15 A_giveInventory("healthbonus", 1)
		MEDI A 15 A_giveInventory("healthbonus", 1)
		MEDI A 15 A_giveInventory("healthbonus", 1)
		Stop
	}
}
(Ignore the health bonus, it was just a test)
To trying to give myself to regenerations powerups at the same time, but it seems like Doom can't handle two regeneration powerups at the same time.

I'm coming back to decorate, any tip on how to do so? Powerup, Custominventory, what is the best DECORATE method?
SanyaWaffles
Posts: 820
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields

Re: Custom regeneration items?

Post by SanyaWaffles »

the problem with CustomInventory is it does everything all at once, ignoring state duration in tics.

There's probably a way to do it combining DECORATE and ACS and there's definitely ways of doing it via ZScript.
XASSASSINX
Posts: 380
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Re: Custom regeneration items?

Post by XASSASSINX »

I've used A_GiveInventory to give myself health with te quick stimpak.
I'm trying to do a timer with the stimpak that last 10 seconds, and if you use another stimpak before this timer runs out, you take damage. I've tried alot of stuff, none of this worked.

Code: Select all

		STIM B 0 A_jumpIfnoammo("ReadyEmpty")
		STIM B 1 A_PlayWeaponSound("StimpakUse")
		STIM C 0 A_ZoomFactor(0.95)
		STIM C 1 A_TakeInventory("Stims", 1)
		STIM C 1 A_JumpIfInventory("StimpakTimer", 1, "Overdose")
		STIM C 0 A_GiveInventory("StimpakTimer")
		STIM C 1 A_SetBlend("Red", 0.5, 70)

Code: Select all

ACTOR StimpakTimer : PowerupGiver
{
    Inventory.Amount 2
    Powerup.duration -10
	Scale 0.10
	Powerup.type "PowerNothing"
	+INVENTORY.ALWAYSPICKUP
	+INVENTORY.AUTOACTIVATE
	States
	{
	Spawn:
	 STIM A -1
	 Loop
	}
}
This the the state that is supposed to remove your health, i've removed player health using an invisible explosion that takes your health (and your armor), i think you can only remove health via Zscript and ACS, right? But i have no idea where to start with those.
Not only that, but the item that has the timer also appears on my inventory as a "1" (if put it as a Give.Amount 0 it would dissapear and the state wouldn't consider it in my inventory) and i can use it! I have no idea how to fix this.

Code: Select all

	Overdose:
		STIM C 10 A_QuakeEx(0.8, 0.8, 1.3, 20, 0, 35, "")
		STIM C 2 A_SetBlend("Black", 1, 35)
		STIM C 3 A_TakeInventory("Health", 3, 0) 
		STIM C 3 A_TakeInventory("Health", 3, 0)
		STIM C 3 A_TakeInventory("Health", 3, 0)
		STIM C 3 A_TakeInventory("Health", 3, 0)
		STIM B 3 A_ZoomFactor(1)
		Goto Ready
Any help??
Jarewill
 
 
Posts: 1845
Joined: Sun Jul 21, 2019 8:54 am

Re: Custom regeneration items?

Post by Jarewill »

Posting snippets like that does make it a bit harder to help.

- Is "PowerNothing" defined anywhere?
- The reason why it appears in your inventory is because of how powerups work. It needs to have Inventory.MaxAmount 0 set up to prevent this.
- The PowerupGiver only gives the powerup and then gets removed, (unless it stays in the inventory) you need to check for PowerNothing for A_JumpIfInventory.
- There are other ways to deal with damaging the player. You could also use A_DamageSelf.
XASSASSINX
Posts: 380
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Re: Custom regeneration items?

Post by XASSASSINX »

- Is "PowerNothing" defined anywhere?
Yes, it is. Its simply defined as: "PowerNothing : Powerup {}"
- The reason why it appears in your inventory is because of how powerups work. It needs to have Inventory.MaxAmount 0 set up to prevent this.
Yes, i know, but if i do that, the item goes away and it doesn't count as being in my inventory, therefore the "Overdose" state never happens. It will only happen if it shows directly on my inventory.
- There are other ways to deal with damaging the player. You could also use A_DamageSelf.
What the hell? how didn't i ever NOT find this? This is so useful! thank you so much! It's actually now working, but is there any way to check precisely how much time there is left with a powerup? I know the "printinv" command, but it doens't show the time.

and one last question since i think this is the topic, is there a way to make a health item that heals a bit on a certain period, and after, say, 15 seconds, it heals you alot? CustomInventory gives its item instantly, is there any other way to do so without the use of Zscript?
Jarewill
 
 
Posts: 1845
Joined: Sun Jul 21, 2019 8:54 am

Re: Custom regeneration items?

Post by Jarewill »

XASSASSINX wrote:and one last question since i think this is the topic, is there a way to make a health item that heals a bit on a certain period, and after, say, 15 seconds, it heals you alot? CustomInventory gives its item instantly, is there any other way to do so without the use of Zscript?
I am not sure about DECORATE, but ACS can deal with it.
You can use HealThing to heal the player in the script and loop it with delays and While loops.
For example:
Spoiler:
Then you can activate the script in a pickup state of a custom inventory with ACS_NamedExecute.
XASSASSINX wrote:Yes, i know, but if i do that, the item goes away and it doesn't count as being in my inventory, therefore the "Overdose" state never happens. It will only happen if it shows directly on my inventory.
Like I said, it's better to make the PowerupGiver always activate itself with Inventory.MaxAmount 0 and check for the PowerNothing in A_JumpIfInventory:
Spoiler:
PowerNothing will instantly disappear from the player's inventory after 10 seconds, while PowerupGiver will be kept there until the player uses it.
XASSASSINX
Posts: 380
Joined: Tue Dec 20, 2016 4:53 pm
Location: MURICAA BROTHER! Just kidding, Brazil.

Re: Custom regeneration items?

Post by XASSASSINX »

Alright, thanks! I've been a good since i've done some ACS, and it was basic. You have to create an ACS file, put the "#include zdoom" something on it, and then compile it, right??
I think the process has changed definetly, is there a wiki page on how to do it?
Jarewill
 
 
Posts: 1845
Joined: Sun Jul 21, 2019 8:54 am

Re: Custom regeneration items?

Post by Jarewill »

You need to put #include "zcommon.acs" at the beginning of the file.
If you are also making a mod that should work with other levels, put the #library "scriptname" above the #include.

As for the wiki page, there's this with a lot of information and tutorials.

Return to “Tutorials”