how do you make something happen?
Moderator: Graf Zahl
- BlazingPhoenix
- Posts: 488
- Joined: Sun Aug 28, 2005 5:11
- Contact:
how do you make something happen?
how do you make a script activate after you kill a bunch of monsters? say I have two Imps that just spawned, I want a door to open or something after they die, how do I do this? thingcount or something?
-
- Posts: 58
- Joined: Sun Sep 11, 2005 20:31
- Location: nj
- Contact:
There are many ways to do this but here is how I would do it. Have each imp activate a script (lets say 1). And then I would use this code:ImpsLeft is a variable that tells us how many are remaining. When an imp dies it should run this script and decrease the imps left by 1. When there are 0 left it opens the door.
Code: Select all
#include "zcommon.acs"
int ImpsLeft = 2;
script 1 (void)
{
//i do not know if this works with acs if it doesn't use the other one below
if (--ImpsLeft == 0)
{
door_open(tag,speed,delay); //or whatever do command you want to use
}
//if the above code does not work then use this:
impsleft--;
if (ImpsLeft == 0)
{
door_open(tag,speed,delay);
}
}
- BlazingPhoenix
- Posts: 488
- Joined: Sun Aug 28, 2005 5:11
- Contact:
- solarsnowfall
- Persecution Complex
- Posts: 363
- Joined: Fri Aug 05, 2005 8:51
Either you left something out of that script, or I'm retarded. It doesn't make any sense to me, to do it that way.NecroMage wrote:When an imp dies it should run this script and decrease the imps left by 1. When there are 0 left it opens the door.
There are plenty of ways to do this, and here are two I would use.KingofFlames wrote:how do you make a script activate after you kill a bunch of monsters? say I have two Imps that just spawned, I want a door to open or something after they die, how do I do this? thingcount or something?
Code: Select all
script 1 open
{
if(thingcount(T_Imp, tid) == 0)
{
door_open(tag, speed, delay);
}
delay(1);
restart;
}
Code: Select all
script 1 open
{
until(thingcount(T_Imp, tid) == 0)
{
delay(1);
restart;
}
door_open(tag, speed, delay)
}
If you wanted to keep track of multiple kinds of monsters, put T_None in thingcount(); for the type. As long as all the monsters have the same tid, when the count reaches 0 (after they've all been killed) the door opens. Why is this better?
1.) Doesn't require the monster to activate a script.
2.) Doesn't require a variable.
-
- Posts: 36
- Joined: Tue Sep 06, 2005 14:25
I think his idea was to have the script activate on each of the imps, so when they die the script is run. When the first imp dies it subtracts one from the integer and stops there. When the second imp dies it finds the integer = 0 and opens the door.
This way you also avoid having a script running constantly in the background. Your script has the advantage that you won't have to put it on every monster the script involves. Pick your poison
This way you also avoid having a script running constantly in the background. Your script has the advantage that you won't have to put it on every monster the script involves. Pick your poison

- solarsnowfall
- Persecution Complex
- Posts: 363
- Joined: Fri Aug 05, 2005 8:51
- Graf Zahl
- GZDoom Developer
- Posts: 7148
- Joined: Wed Jul 20, 2005 9:48
- Location: Germany
- Contact:
- Enjay
- Developer
- Posts: 4748
- Joined: Tue Aug 30, 2005 23:19
- Location: Scotland
- Contact:
- MartinHowe
- Posts: 154
- Joined: Tue Aug 30, 2005 22:07
- Location: East Suffolk (UK)
- Graf Zahl
- GZDoom Developer
- Posts: 7148
- Joined: Wed Jul 20, 2005 9:48
- Location: Germany
- Contact: