Powerups that lasts forever
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Powerups that lasts forever
is there a way to make a powerup last forever instead of acting during a given time period?
- Ryan Cordell
- Posts: 4349
- Joined: Sun Feb 06, 2005 6:39 am
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Capital of Explodistan
Re: Powerups that lasts forever
The only way to do such a thing is to input a very high number. I don't remember the exact limit.
- Cutmanmike
- Posts: 11353
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Re: Powerups that lasts forever
I assume -1 doesn't work?
Re: Powerups that lasts forever
Nope. Something to do with inconsistencies on what -1 means, internally. MartinHowe explained it much better a while back in his morph code cleanup thread if I'm not mistaken.Cutmanmike wrote:I assume -1 doesn't work?
Re: Powerups that lasts forever
IIRC, -1 is used sometimes to mean "default value" which, in the case of powerups, is something like 30 seconds...
Re: Powerups that lasts forever
And as always gets mentioned, special "forever" behavior isn't needed since if you input a high enough time you can get a powerup that lasts for two years, which is more than long enough for anybody's needs.
- Macil
- Posts: 2529
- Joined: Mon Mar 22, 2004 7:00 pm
- Preferred Pronouns: He/Him
- Location: California, USA. Previously known as "Agent ME".
- Contact:
Re: Powerups that lasts forever
Maybe -2 could be implemented to mean forever / infinity?Gez wrote:IIRC, -1 is used sometimes to mean "default value" which, in the case of powerups, is something like 30 seconds...
Re: Powerups that lasts forever
ok. now what's the maximum duration limit for a powerup? is it something like 9999?Zippy wrote:And as always gets mentioned, special "forever" behavior isn't needed since if you input a high enough time you can get a powerup that lasts for two years, which is more than long enough for anybody's needs.
- Ryan Cordell
- Posts: 4349
- Joined: Sun Feb 06, 2005 6:39 am
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Capital of Explodistan
Re: Powerups that lasts forever
Higher than that, I'm afraid!
Re: Powerups that lasts forever
Much, much higher.
2147483647 or (2^31)-1
2147483647 or (2^31)-1
- MartinHowe
- Posts: 2081
- Joined: Mon Aug 11, 2003 1:50 pm
- Preferred Pronouns: He/Him
- Location: East Suffolk (UK)
Re: Powerups that lasts forever
We really need an "asking for a forever powerup gets you a ban" note in the rules 
To get "Infinity" in this case, use 2147483647 (about two years).
Zero means "use the default".
Minus one (or indeed minus anything else) means "ignore the minus and use the absolute value" (no I don't know why Randy did that).
As for the rest:

To get "Infinity" in this case, use 2147483647 (about two years).
Zero means "use the default".
Minus one (or indeed minus anything else) means "ignore the minus and use the absolute value" (no I don't know why Randy did that).
As for the rest:
So use a two year amount and have done with it!A long time ago, in a thread far far away, MartinHowe wrote:This is one of those annoying situations where something is theoretically necessary but in practice you'll get away with "doing xxxx". Because of their ability to abstractly model the world and thus see pitfalls that many people can't, good programmers hate to rely on corner-cutting -- even if the corner is practially always guaranteed to be safely "cuttable". It leaves a feeling of "yeah, but what if"? After all who can forget those immortal lines:
Part of the problem is that inside the engine, some powerups (ab?)use their countdown timers for things other than counting down, for example the flash duration of Berserk, the end-of-power flash for other powerups, etc. Some things even count up, rather than down.
- Hey, it's 1970, people won't even be using Unix by 2029 - whoever designed time_t
- Nobody will ever need more than 640K - Billy Boy to IBM in 1980
- The world will need about 7 computers - IBM themselves in the late 1940's
- 31st December 1999? Heck this OS will be dead by then and I'll be retired - thousands of programmers in the 1970's and 80's
- DoomScript will be finished by... - no, I'm not going there
One solution would be to have -1 mean "infinite", 0 stays as "the default", always count up, have a separate "stop if >=" stored value, adjust the animation conditionals accordingly, and have an "infinite" flag; if the "infinite" flag is set, subtract 1073741824 from the up-counter when it reaches 2147483647 - (2147483647 % n), where "n" is the largest "modulo" value used by any powerup animation and contrain all "n"'s to be powers of two and < 1073741824. This would involve a small, but non-trivial, amount of work which it why it will probably never happen!D
- 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: Powerups that lasts forever
Here's a really hacky idea:
When the powerup is picked up, have the player fire a "projectile" that's really an invisible dummy actor that doesn't interact with anything. Every <duration of the powerup> the actor uses A_GivetoTarget to replenish the powerup.
Still needs a bit of tweaking to get it to work in multiplayer or across levels, though.
When the powerup is picked up, have the player fire a "projectile" that's really an invisible dummy actor that doesn't interact with anything. Every <duration of the powerup> the actor uses A_GivetoTarget to replenish the powerup.
Still needs a bit of tweaking to get it to work in multiplayer or across levels, though.
Re: Powerups that lasts forever
Why is that even necessary? If you set the duration high enough you can have powerups which last real world days, weeks, months, or even years. Having somebody run the wad, pick up the powerup, and then leaving it running for years to have the powerup actually run out and be disappointed by its timeout is an absurd chain of events whose probability of occurance is less likely than the sudden implosion of all matter in the universe. Basically, the powerup will never run out. Ever. It may not be technically infinite, but it is infinite in practice, thus there is absolutely no need for any kind of hack whatsoever.Vaecrius wrote:Here's a really hacky idea:
When the powerup is picked up, have the player fire a "projectile" that's really an invisible dummy actor that doesn't interact with anything. Every <duration of the powerup> the actor uses A_GivetoTarget to replenish the powerup.
Still needs a bit of tweaking to get it to work in multiplayer or across levels, though.
Going across levels with an infinite powerup is also very simple. Use ACS and a global variable to record when the player has obtained the powerup, and give it to them again at the start of every level.
- bagheadspidey
- Posts: 1490
- Joined: Sat Oct 20, 2007 10:31 pm
- Contact:
Re: Powerups that lasts forever
The number is much easier to write and remember in hex. It's a 7 followed by 7 Fs, with zero x in front of it meaning it's a hexadecimal number. For example:
powerup.duration 0x7FFFFFFF
powerup.duration 0x7FFFFFFF
Re: Powerups that lasts forever
Heh, if a powerup lasts whole real-world weeks (even days), then they probably deserve to have it bug out.
Thanks, by the way. For reasons I can't remember, I was going to ask the maximum powerup time (I remember the thread with MartinHowe's post containing those hilarious (in retrospect) quotes
).
Thanks, by the way. For reasons I can't remember, I was going to ask the maximum powerup time (I remember the thread with MartinHowe's post containing those hilarious (in retrospect) quotes
