limiting time between script execution?
limiting time between script execution?
not sure if that's really the best title but here goes.
i think it'd be neat to have some sort of time freeze command (but without skulltag's lolorange screen time freeze sphere). something you could activate just by a single key press. say you press X and freeze command is activated for 5 seconds. but before you can do it again, the game forces you to wait some amount of seconds before you can activate it again.
some sort of hud indication of when it's available to use/ability to upgrade how frequently it's used and how long it lasts would eventually be cool too but i'll start with the basics
anyway i think i can set up global script stuff and key bindings but beyond the basics i am pretty clueless
i think it'd be neat to have some sort of time freeze command (but without skulltag's lolorange screen time freeze sphere). something you could activate just by a single key press. say you press X and freeze command is activated for 5 seconds. but before you can do it again, the game forces you to wait some amount of seconds before you can activate it again.
some sort of hud indication of when it's available to use/ability to upgrade how frequently it's used and how long it lasts would eventually be cool too but i'll start with the basics
anyway i think i can set up global script stuff and key bindings but beyond the basics i am pretty clueless
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2571
- Joined: Sat Jun 02, 2012 2:44 am
RE: limiting time between script execution?
Bind <keyhere> "freeze"
^ Do that in the console.
^ Do that in the console.
RE: limiting time between script execution?
If you wanted to make a mod that does that, you'd have to inherit from PowerTimeFreezer.
http://zdoom.org/wiki/Classes:PowerTimeFreezer
http://zdoom.org/wiki/Classes:PowerTimeFreezer
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

RE: limiting time between script execution?
yeah but the problem with that is i can keep pressing X to freeze and unfreeze whenever the hell i want. even if i added a bit that specified wait 100 tics and then unfreeze, there's nothing to stop me from just pushing the key again etc etc.Catastrophe wrote: Bind <keyhere> "freeze"
^ Do that in the console.
ah, thank you. it looks like that's virtually the same as the freeze command though right? and i guess since it's a powerup it's not quite the same as just binding something to a key and limiting usage of that key press. i'll look into it though, thank ye kindlyÆnima wrote: If you wanted to make a mod that does that, you'd have to inherit from PowerTimeFreezer.
http://zdoom.org/wiki/Classes:PowerTimeFreezer
RE: limiting time between script execution?
Time freeze powerup is NOT the same as the freeze command :U It freezes music.
On the other hand, freeze command doesn't work in multiplayer, while this does.
To limit the usage of a key for a certain amount of time, do next:
1) Create a dummy Inventory item. It does nothing, you can't use it, but it can sit in your inventory.
2) When executing the freeze script, check if you have this inventory. If yes, do nothing(probably display a message).
3) If you do not have it, give it and freeze time away. Execute another script while we're at it.
4) That script is going to just Delay() the required amount of time, and take the inventory away.
This is the most basic cooldown setup. It doesn't allow you to measure how much cooldown time you have left, though. To do that, you can give multiple of inventory items, take them one by one in each period of time, and measure the cooldown time remaining by the amount of items remaining. Experiment.
On the other hand, freeze command doesn't work in multiplayer, while this does.
To limit the usage of a key for a certain amount of time, do next:
1) Create a dummy Inventory item. It does nothing, you can't use it, but it can sit in your inventory.
2) When executing the freeze script, check if you have this inventory. If yes, do nothing(probably display a message).
3) If you do not have it, give it and freeze time away. Execute another script while we're at it.
4) That script is going to just Delay() the required amount of time, and take the inventory away.
This is the most basic cooldown setup. It doesn't allow you to measure how much cooldown time you have left, though. To do that, you can give multiple of inventory items, take them one by one in each period of time, and measure the cooldown time remaining by the amount of items remaining. Experiment.
RE: limiting time between script execution?
aha. in between my latest post and yours, HexaDoken, i started doing a similar method, but i couldn't get it to work anyway. i was trying to use ACS_Execute in the frames of the timefreeze decorate entry... as i said, didn't work, but it was unnecessary anyway. i ended up doing essentially what you suggested, but without the dumm inventory item. if you're curious:
[spoiler]#include "zcommon.acs"
int hastime;
Script 799 (void)
{
If(hastime == FALSE)
GiveInventory("timefreezer1", 1);
ACS_ExecuteAlways(800, 1, 0, 0, 0);
}
script 800 (void)
{
hastime = true;
Delay(200);
hastime = false;
}[/spoiler]
such a basic thing i've wanted to do for years... never bothered really trying though. what would be an advantage to your method verbatim HexaDoken over this one?
thank you all, it is much appreciated
edit: ok i found a problem. can apparently keep pushing the key really quickly and it'll keep repeating. will try to fix later sigh
[spoiler]#include "zcommon.acs"
int hastime;
Script 799 (void)
{
If(hastime == FALSE)
GiveInventory("timefreezer1", 1);
ACS_ExecuteAlways(800, 1, 0, 0, 0);
}
script 800 (void)
{
hastime = true;
Delay(200);
hastime = false;
}[/spoiler]
such a basic thing i've wanted to do for years... never bothered really trying though. what would be an advantage to your method verbatim HexaDoken over this one?
thank you all, it is much appreciated
edit: ok i found a problem. can apparently keep pushing the key really quickly and it'll keep repeating. will try to fix later sigh
Last edited by Tango on Wed Feb 13, 2013 6:05 am, edited 1 time in total.
RE: limiting time between script execution?
You should learn some ACS syntax. Particulary the fact that whatever goes to the If block must be in curly braces.
Like that. Also, I dunno why the second argument of your ACS_ExecuteAlways is 1, it should be 0.
Advantage of your method over mine is that it has a slightly less resource cost(I think?) while my method is actually multiplayer compatible.
Code: Select all
If(hastime == FALSE)
{
GiveInventory("timefreezer1", 1);
ACS_ExecuteAlways(800, 0, 0, 0, 0);
}
Advantage of your method over mine is that it has a slightly less resource cost(I think?) while my method is actually multiplayer compatible.
RE: limiting time between script execution?
I'm not sure what you want, but try something like this:
Decorate:
[spoiler][/spoiler]
ACS:
[spoiler][/spoiler]
The timer (aka X_CoolDown) will vanish after one second on its own (Zandronum checks for Powerups and their powerup duration. If the time counter is beyond the duration limit, the item goes away.)
Decorate:
[spoiler]
Code: Select all
Actor X_CoolDown : PowerDamage
{
DamageFactor "Nothing", 1.0
Powerup.Duration 35 //You can also type -1 instead of 35 for one second
}
ACS:
[spoiler]
Code: Select all
Script 100 (void) //This script gets executed by your button
{
if( CheckInventory("X_CoolDown") )
terminate;
/* .... do stuff .... */
}
The timer (aka X_CoolDown) will vanish after one second on its own (Zandronum checks for Powerups and their powerup duration. If the time counter is beyond the duration limit, the item goes away.)