Stained Glass Smash with SpawnProjectile - how?

Wed Oct 27, 2021 5:31 am

I'm trying to recreate the Hexen staned glass window smash but using SpawnProjectile instead of Thing_ProjectileGravity. The reason is that I want to use a bunch of custom classes as the shards of flying glass and I'd rather spawn them by class name rather than a spawn id.

It's easy enough for me to spawn a single class of shard

Code:
SpawnProjectile (mirrortid, "NJSHARD1A", random(0, 255), random(10, 40), random(5, 20), 1, 0);


full script for smashing a mirror:
Spoiler:


but how do I set things so that the above line so that it will randomly pick from a pre-defined selection of actor class names? I'm going to guess that an array is involved and, as anyone who has read my posts in the past will know, I seem to have a mental block with them so go easy on me. ;)

Thanks.

Re: Stained Glass Smash with SpawnProjectile - how?

Wed Oct 27, 2021 6:31 am

Got it... I think. It seems to work anyway. Can someone please review just to check that I have it right?

First I declare a string array:
Code:
str SGShards[9] = {"NJSHARD1A", "NJSHARD2A", "NJSHARD3A", "NJSHARD4A", "NJSHARD5A", "NJSHARD6A", "NJSHARD7A", "NJSHARD8A", "NJSHARD9A"};

Then, later on, I use the array name in my SpawnProjectile line:
Code:
SpawnProjectile (sgglasstid, SGShards[random(0, 8)], random(0, 255), random(10, 40), random(5, 20), 1, 0);


Does that look right?

Re: Stained Glass Smash with SpawnProjectile - how?

Wed Oct 27, 2021 7:44 am

Yes, that looks right.

Re: Stained Glass Smash with SpawnProjectile - how?

Wed Oct 27, 2021 7:54 am

Perfect, thanks. :)