Page 1 of 1
(SOLVED)Powerup that spawns something as it lasts?
Posted: Sat Nov 12, 2016 11:38 pm
by FranckyFox2468
I'm wondering if it's possible to make a powerup that spawns something (like a spam of projectiles or an explosion) every X tics while it lasts?
Re: (DECORATE)Powerup that spawns something as it lasts?
Posted: Sat Nov 12, 2016 11:51 pm
by Ænima
Use an ACS script.
Re: (DECORATE)Powerup that spawns something as it lasts?
Posted: Sun Nov 13, 2016 1:05 am
by FranckyFox2468
An exemple would be nice if possible. That is a well done one, unless its as basic as an inventory check so it spawns something. But wouldn't even know how to do so at a player's position.
Re: (DECORATE)Powerup that spawns something as it lasts?
Posted: Sun Nov 13, 2016 1:09 am
by ZZYZX
Subclass this in decorate
http://zdoom.org/wiki/Classes:CustomInventory
Then make an ACS library
http://zdoom.org/wiki/Libraries
In the ACS library, create a script like this one (this script starts and executes some code every second for 10 seconds):
Code: Select all
script 666 (void)
{
for (int i = 0; i < 10; i++)
{
// spawn something here.
Delay(35);
}
}
Then put an ACS_ExecuteWithResult(666) in your CustomInventory thing in Pickup: state (if the powerup is used instantly) or Use: state (if it's stored in the inventory).
Player position can be received with
GetActor# family of functions.
Spawning is done by the
Spawn family (see the bottom of this page for other spawn-related functions).
Re: (DECORATE)Powerup that spawns something as it lasts?
Posted: Sun Nov 13, 2016 1:39 am
by FranckyFox2468
Neat, ill try it out whenever i can!
Re: (DECORATE)Powerup that spawns something as it lasts?
Posted: Sun Nov 13, 2016 5:03 pm
by FranckyFox2468
Uh, i would like to ask another question, if the spawn is done via a script and not via a decorate or an actor itself, wouldn't it result the projectile to hurt the user of the projectile as well and its allies?
EDIT: I tried a work around in the meantime of an inventory item that loops its effect for as long as the powerup is detected on the player but i seem to be running out of luck... Only does it once you pick up the item then it stops
Re: (DECORATE)Powerup that spawns something as it lasts?
Posted: Sun Nov 13, 2016 7:20 pm
by FranckyFox2468
ZZYZX wrote:Subclass this in decorate
http://zdoom.org/wiki/Classes:CustomInventory
Then make an ACS library
http://zdoom.org/wiki/Libraries
In the ACS library, create a script like this one (this script starts and executes some code every second for 10 seconds):
Code: Select all
script 666 (void)
{
for (int i = 0; i < 10; i++)
{
// spawn something here.
Delay(35);
}
}
Then put an ACS_ExecuteWithResult(666) in your CustomInventory thing in Pickup: state (if the powerup is used instantly) or Use: state (if it's stored in the inventory).
Player position can be received with
GetActor# family of functions.
Spawning is done by the
Spawn family (see the bottom of this page for other spawn-related functions).
Don't know if i'm doing this right but nothing seems to be spawning:
Code: Select all
script 600 (void)
{
for (int i = 0; i < 30; i++)
{
str class = "StarmanAOE";
do {
delay(1);
int x = GetActorX(0);
int y = GetActorY(0);
int z = GetActorZ(0);
int angle = GetActorAngle(0);
} until (Spawn(class, x, y, z, 0, angle));
Delay(1);
}
}
I'm pretty awful when it comes to ACS ^^'
EDIT: Figured its because i forgot to put #include "zcommon.acs", tho what is weird is that instead of counting seconds it counts ticks, like it only lasts 10-30 tics. And it also hurts allied players as i feared.
EDIT2: I figured a work around using ZZYZX's script (Will remember to give him a special thanks if this project gets finished), instead of spawning something every X tics, it gives an item to the player that spawns something every X tics. So it doesn't affect the player and nor allied players :D. Thanks for the help guys!