Powerups that lasts forever

Archive of the old editing forum
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.
Locked
User avatar
Duducrazy
Posts: 600
Joined: Sat Aug 21, 2004 6:16 pm

Powerups that lasts forever

Post by Duducrazy »

is there a way to make a powerup last forever instead of acting during a given time period?
User avatar
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

Post by Ryan Cordell »

The only way to do such a thing is to input a very high number. I don't remember the exact limit.
User avatar
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

Post by Cutmanmike »

I assume -1 doesn't work?
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Powerups that lasts forever

Post by Nash »

Cutmanmike wrote:I assume -1 doesn't work?
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.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Powerups that lasts forever

Post by Gez »

IIRC, -1 is used sometimes to mean "default value" which, in the case of powerups, is something like 30 seconds...
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Powerups that lasts forever

Post by Zippy »

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.
User avatar
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

Post by Macil »

Gez wrote:IIRC, -1 is used sometimes to mean "default value" which, in the case of powerups, is something like 30 seconds...
Maybe -2 could be implemented to mean forever / infinity?
User avatar
Duducrazy
Posts: 600
Joined: Sat Aug 21, 2004 6:16 pm

Re: Powerups that lasts forever

Post by Duducrazy »

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.
ok. now what's the maximum duration limit for a powerup? is it something like 9999?
User avatar
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

Post by Ryan Cordell »

Higher than that, I'm afraid!
User avatar
Ichor
Posts: 1784
Joined: Wed Jul 23, 2003 9:22 pm

Re: Powerups that lasts forever

Post by Ichor »

Much, much higher.

2147483647 or (2^31)-1
User avatar
MartinHowe
Posts: 2081
Joined: Mon Aug 11, 2003 1:50 pm
Preferred Pronouns: He/Him
Location: East Suffolk (UK)

Re: Powerups that lasts forever

Post by MartinHowe »

We really need an "asking for a forever powerup gets you a ban" note in the rules :P

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:
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:
  • 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 :P
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.

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
So use a two year amount and have done with it!
User avatar
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

Post by Matt »

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.
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Powerups that lasts forever

Post by Zippy »

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.
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.

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.
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: Powerups that lasts forever

Post by bagheadspidey »

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
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Powerups that lasts forever

Post by Ghastly »

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 :P).
Locked

Return to “Editing (Archive)”