Summon random thing

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
Mr. J
Posts: 77
Joined: Fri Aug 22, 2003 4:39 pm
Location: U.S.A.
Contact:

Summon random thing

Post by Mr. J »

Hey, does anyone know how to summon a random thing in a script?
I see the SNDINFO lump uses a random-like thing where the game will play a random sound, from a list in the file. Well, is there a script that'll do that same thing, but spawn a thing, in this case a DECORATE actor, semi-randomly, from a list of choices?
...I can do a lot, but scripts are really hard, for some reason. :?

Thanks a lot, in advance. 8-)
User avatar
Necromage
Posts: 484
Joined: Thu Feb 10, 2005 3:13 pm
Location: NJ
Contact:

Post by Necromage »

You have to tinker with this but this is something that could work:

Code: Select all

#include "zcommon.acs"

script 1 (void)
{
int RandomProjectile = random(1,5); 
//1 is the lower and five is the higher
//change the values based on what how many projectiles you want

if RandomProjectile == 1
{
   Thing_Projectile(tid, type, angle, speed, vspeed); 
//tid is the mapspot tag
//type is the type of projectile, each if-then should spawn a different projectile
//angle is the angle the projectile travels
//speed is the speed of the projectile
//vspeed is the virticle speed of the projectile
}
}

//then you keep having if-then clauses for all the projectiles you want
//I think type is the spawnid, which can be looked up in the wiki
User avatar
Mr. J
Posts: 77
Joined: Fri Aug 22, 2003 4:39 pm
Location: U.S.A.
Contact:

Post by Mr. J »

"Thing_Projectile"? Hmm... I was expecting something like:
'SpawnSpot("nameofDECORATEactor",26);"

I'll tinker with it, and see if It's what I was thinking.


Thanks!
User avatar
jallamann
Posts: 2271
Joined: Mon May 24, 2004 8:25 am
Location: Ålesund, Norway
Contact:

Post by jallamann »

Code: Select all

str randomness[10] = { "decorateactor1", "decorateactor2", bla bla bla, "decorateactor10" };
// the [10] means you can put up to 10 actors inside the array ( the {} brackets), increase this number if you need more than ten possibilities

script 1 (void)
{
int blargh = random(1,10); //this picks a random monster from 1 to 10 inclusive. Have the last number equal the amount of entries in the array.
spawnspot(randomness[blargh], mapspot);
}
This should work, but I'm no expert on arrays ;)
User avatar
Mr. J
Posts: 77
Joined: Fri Aug 22, 2003 4:39 pm
Location: U.S.A.
Contact:

Post by Mr. J »

WOW! Yeah, that was it all right. I had some trouble at first getting it to work. It tended to get stuck on one actor, and just spawn it over again. But. after a little adjustment, it seems to work great!


Thanks, jallmann.
... You ever drink the Grolsch with a little ceramic stopper-thing, and a wire at the top of the bottle?
User avatar
jallamann
Posts: 2271
Joined: Mon May 24, 2004 8:25 am
Location: Ålesund, Norway
Contact:

Post by jallamann »

Glad to be of help :)

I drink it either from the can or from a glass ;)
It's not often you see foreign beer in anything else than cans here in Norway :|
Locked

Return to “Editing (Archive)”