RandomSpawner leaving empty space
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 5
- Joined: Tue Oct 09, 2018 4:07 pm
- Location: MinneSNOWta
RandomSpawner leaving empty space
For example, lets say a RandomSpawner replaces ShotGun I have it set to DropItem 3 weapons, each from a different mod. When I load up Mod 1 and Mod 2 in ZDL but not Mod 3, The RandomSpawner at one point selects the weapon from Mod 3, resulting in empty space in-game where the ShotGun would normally be
How do I tell the RandomSpawner to try again if a weapon it selects does not exist?
How do I tell the RandomSpawner to try again if a weapon it selects does not exist?
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: RandomSpawner leaving empty space
By [wiki=ZScript_virtual_functions]overriding[/wiki] RandomSpawner's ChooseSpawn() function:
These two lines in that function should be of interest to you.
Code: Select all
class MyRandomSpawner : RandomSpawner
{
override Name ChooseSpawn ()
{
// Copy the contents of the original function here, and modify as needed.
}
}
-
- Posts: 5
- Joined: Tue Oct 09, 2018 4:07 pm
- Location: MinneSNOWta
Re: RandomSpawner leaving empty space
Would this go in DECORATE or somewhere else?
Re: RandomSpawner leaving empty space
ZScript only.
-
- Posts: 5
- Joined: Tue Oct 09, 2018 4:07 pm
- Location: MinneSNOWta
Re: RandomSpawner leaving empty space
I was finally able to get around to making a zscript with the override, and using the new randomspawner class, however doing so resulted in Zandronum refusing to start up:
https://i.imgur.com/EdLNUvY.png
https://i.imgur.com/zlHr7Ns.png
https://i.imgur.com/7gbjPKm.png
What gives?
https://i.imgur.com/EdLNUvY.png
https://i.imgur.com/zlHr7Ns.png
https://i.imgur.com/7gbjPKm.png
What gives?
Re: RandomSpawner leaving empty space
Compatibility with Zandronum was not mentioned in the opening post. Zandy doesn't support ZScript last time I checked, so you're out of luck.
-
- Posts: 5
- Joined: Tue Oct 09, 2018 4:07 pm
- Location: MinneSNOWta
Re: RandomSpawner leaving empty space
;_;
Alrighty thank you
Alrighty thank you
Re: RandomSpawner leaving empty space
This is doable with some hacky trickery.
You make actors that inherit from the vanilla Doom weapons and give them the same names as the weapons in the mods your spawner intends to support. So if one of the mods isn't loaded, it spawns a Vanilla Doom weapon instead of nothing. Of course this has the problem that the other mods have to be loaded last.
There's a cleaner way with ACS that involves making a check if the spawned actor has spawned correctly, but i haven't tested it. Theoretically it should be this:
DECORATE
ACS
This example is not random and it spawns the same weapon unless the mod isn't loaded (of course you need to change "SomeModShotgun" to the weapon you want to spawn) but making it random isn't hard at all.
Of course, if you can give me more information (which mods are meant to be supported by this, specifically) i could make a complete version for you.
You make actors that inherit from the vanilla Doom weapons and give them the same names as the weapons in the mods your spawner intends to support. So if one of the mods isn't loaded, it spawns a Vanilla Doom weapon instead of nothing. Of course this has the problem that the other mods have to be loaded last.
There's a cleaner way with ACS that involves making a check if the spawned actor has spawned correctly, but i haven't tested it. Theoretically it should be this:
DECORATE
Code: Select all
ACTOR BackupShotgun : Shotgun {}
ACTOR ShotgunRandomSpawn : Inventory replaces Shotgun
+INVENTORY.ALWAYSPICKUP
states
{
Spawn:
TNT1 A 0
TNT1 A 0 ACS_NamedExecuteAlways("SpawnShotgun", 0)
TNT1 A -1
Stop
}
}
Code: Select all
Script "SpawnShotgun" (void)
{
int x = GetActorX(0);
int y = GetActorY(0);
int z = GetActorZ(0);
if(Spawn("SomeModShotgun",x, y, z == 0) {Spawn("BackupShotgun", x, y, z);}
}
Of course, if you can give me more information (which mods are meant to be supported by this, specifically) i could make a complete version for you.
- Arctangent
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
- Contact:
Re: RandomSpawner leaving empty space
That also has the issue that the new weapon won't have the intended flags, TID, or special, meaning it won't be dropped with half ammo from monster ( and, subsequently, can't be picked up for ammo when dropped by monsters while Weapon Stay is on ), and you'll break compatability with any map that manipulates the weapon with scripting or causes something to happen when the weapon is picked up.
Also, speaking of Weapon Stay, not only would the weapon not disappear after being picked up, but because the thing that's spawning it is an item that would be picked up and then disappear, you'd be able to get all of the weapons from a spawner by combining Weapon Stay and Items Respawn, because the weapons will, well, stay, but the item that spawns them would keep respawning and thus spawning more weapons.
Also, speaking of Weapon Stay, not only would the weapon not disappear after being picked up, but because the thing that's spawning it is an item that would be picked up and then disappear, you'd be able to get all of the weapons from a spawner by combining Weapon Stay and Items Respawn, because the weapons will, well, stay, but the item that spawns them would keep respawning and thus spawning more weapons.
Re: RandomSpawner leaving empty space
You can transfer the TID as long as you pass it as an argument to the script (thing i forgot to do there) and yeah, the weapon DOES dissapear when you grab it and the Inventory item (spawner) would also dissapear, and when the inventory item respawns, the weapon does so too.Arctangent wrote:That also has the issue that the new weapon won't have the intended flags, TID, or special, meaning it won't be dropped with half ammo from monster ( and, subsequently, can't be picked up for ammo when dropped by monsters while Weapon Stay is on ), and you'll break compatability with any map that manipulates the weapon with scripting or causes something to happen when the weapon is picked up.
Also, speaking of Weapon Stay, not only would the weapon not disappear after being picked up, but because the thing that's spawning it is an item that would be picked up and then disappear, you'd be able to get all of the weapons from a spawner by combining Weapon Stay and Items Respawn, because the weapons will, well, stay, but the item that spawns them would keep respawning and thus spawning more weapons.
I have used this method many times and i know what it does, the only thing that can make the weapon properly stay is RandomSpawner and that isn't viable for Zandronum in this case.
That's incorrect. The weapon will dissapear as if weapon stay wasn't active, but it will give full ammo.Arctangent wrote:( and, subsequently, can't be picked up for ammo when dropped by monsters while Weapon Stay is on )
This can be fixed by checking for the +DROPPED flag and spawning a different shotgun in that case. (or give it a CustomInventory item that sets the +DROPPED flag)