Page 1 of 1

CustomInventory with Non-Zero Frame Durations

Posted: Wed Jun 25, 2014 1:02 am
by Popsoap
CustomInventory has one handicap where both the Pickup and Use states are run at 0 tics regardless of what they are set to.

This is a (slightly hacky) workaround using the PowerTargeter actor to create powerups which have non-zero frame durations. Some uses for this include:
  • Regeneration powerups that aren't locked at 5 HP/Sec.
  • Powerups which regenerate ammo over time.
  • Powerups that only affect the player after a given amount of time.
  • Flashlights in OpenGL.

Code: Select all

Actor AmmoRegenerator : PowerupGiver
{
	Powerup.Type AmmoRegenerator
	+AUTOACTIVATE
	+ALWAYSPICKUP
}

Actor PowerAmmoRegenerator : PowerTargeter // Needs to inherit from PowerTargeter to work
{
	Powerup.Duration 350
	States
	{
	Targeter:
		TNT1 AA 0 // These 2 frames prevent accuracy upgrades from affecting the powerup
		TNT1 A 0 A_GiveInventory("Clip", 10)
		TNT1 A 0 A_GiveInventory("Shell", 4)
		TNT1 A 0 A_GiveInventory("RocketAmmo", 1)
		TNT1 A 35 A_GiveInventory("Cell", 20)
		Loop
	}
}

RE: CustomInventory with Non-Zero Frame Durations

Posted: Wed Jun 25, 2014 6:38 am
by Ijon Tichy
Or you could use an ACS script, which isn't incredibly hacky.

RE: CustomInventory with Non-Zero Frame Durations

Posted: Fri Jun 27, 2014 12:17 am
by Ninjamander
thanks for the share, nice to know some decorate alternative over some acs one.

RE: CustomInventory with Non-Zero Frame Durations

Posted: Mon Sep 28, 2015 5:00 am
by ZzZombo
Ijon Tichy wrote: Or you could use an ACS script, which isn't incredibly hacky.
Never was fond of separating the logic in several places. Also it can't do certain things like checking for actor flags w/o using CustomInventory... or the hassle w/ changing the script, saving, recompiling, saving again. And it doesn't help that you may need to quickly switch between the two lumps continuously.

RE: CustomInventory with Non-Zero Frame Durations

Posted: Mon Sep 28, 2015 2:37 pm
by fr blood
Thanks a lot for that, this will help me a lot !

RE: CustomInventory with Non-Zero Frame Durations

Posted: Mon Sep 28, 2015 2:44 pm
by ZzZombo
One last thing: can there be several PowerTargeters at the same time on one unit?

RE: CustomInventory with Non-Zero Frame Durations

Posted: Mon Sep 28, 2015 3:04 pm
by Ivan
I'd say, given on other powerup behaviors, there can but I wouldn't bet on it. Targeter is a weird powerup specific to Strife so who knows...

RE: CustomInventory with Non-Zero Frame Durations

Posted: Mon Sep 28, 2015 4:27 pm
by Ænima
I would personally go with ACS only because you can manipulate the duration based on skill level or make "upgrades" for the powerup that would increase the duration if you wanted to.

But if for some reason you wanted a DECORATE-only method then this is nifty. Good find, Popsoap.

RE: CustomInventory with Non-Zero Frame Durations

Posted: Tue Sep 29, 2015 12:44 am
by ZzZombo
A_SetTics() exists :O