Jump to content
This Topic
  • 0

Making a Weapon Spawner and I need some help


Gianluco

Question

actor WeaponSpawner : RandomSpawner
{
	+NEVERRESPAWN //I think this flag is useless, but keep it just in case
	
    DropItem "BayonetRifle", 255, 2
	DropItem "Emperor", 255, 2
	DropItem "Shotgun", 255, 10
    DropItem "SuperShotgun", 255, 8
	DropITem "EmeraldSplash", 255, 4
    DropItem "Chaingun", 255, 5
    DropItem "RocketLauncher", 255, 4
	DropItem "CryoBow", 255, 4
	DropItem "PlasmaRifle", 255, 3
	DropItem "Flamer", 255, 1
	DropItem "BowSimple", 255, 1
	DropItem "Chainsaw", 255, 3
	DropItem "ReflectSword", 255, 3
	DropItem "BFG9000", 255, 2
}

ACTOR WeaponSpawnerNew : BrainStem 1112
{
  Radius 20
  Height 4
  +NOBLOCKMAP
  +MOVEWITHSECTOR
  +NOCLIP

  States
  {
  Spawn:
    SOUL A random(1, 140) //Sprite is just a way to see if it spawned correctly
    Goto Death
  Death:
    TNT1 A 0 A_SpawnItemEx("WeaponSpawner")
	TNT1 A 0 A_SpawnItemEx("WeaponRespawner", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER) //Tried fixing the "Following" problem by making the making either one of the two a master or child, but it didn't work
	TNT1 A 0
	Stop
  }
}

ACTOR WeaponRespawner : CustomInventory
{          
  Inventory.PickupMessage " "
  Inventory.PickupSound "misc/p_pkup"
  Inventory.Maxamount 0
  -COUNTITEM
  +INVENTORY.QUIET
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  States
  {
  Spawn:
    MEGA A 1  //Sprite is just a way to see if it spawned correctly
    Loop
  Pickup:
    TNT1 A 1 A_SpawnItemEx("WeaponSpawnerNew")
	TNT1 A 0
	Stop
  }
}

I'm making a spawner that creates random weapons and made this. Basically, the Initial Spawner (WeaponSpawnerNew) spawns the Random one (WeaponSpawner) and a Respawner (WeaponRespawner), which, when picked up along with the weapon spawned, spawns the Initial Spawner again.

 

This works good, but there's a slight problem: everytime the Respawner summons the Initial Spawner, it respawns in a (seemingly) random point around the player (probably because it's an inventory actor?). How do I fix this?

Edited by Gianluco

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 0

What if you create an actor that inherits from specialspot with a TID set in its code, then the spawner spawner could teleport back to the special spot before it spawned the weapon spawner? 

Share this post


Link to post
  • 0
  On 1/31/2024 at 4:03 AM, Nihlith said:

What if you create an actor that inherits from specialspot with a TID set in its code, then the spawner spawner could teleport back to the special spot before it spawned the weapon spawner? 

Expand  

So, you're saying that, in its pickup state, the spawner should teleport to the SpecialSpot and spawn the spawner there, or would it spawn it in every specialspot with the same tag?

Could you explain it a bit better? I think it may work, but will it work correctly with multiple of spawners on the map?

Share this post


Link to post
  • 0

If the special spot has it's TID defined in it's code and the spawner teleports to it, I think it will pick one at random if there is more than one. That would mean you'd need a separate specialspot/spawner pair for each weapon spawner placement....

Maybe this isn't the best way.

What if instead the spawner spawner, we'll call it spawner A, checks if there is a weapon within a certain distance of itself every second or so, when it finds one it does nothing but if it doesn't it spawns spawner B at it's own location. You could use the set master flag and destroy spawn flag to make sure it didn't double up on spawner B's. If the spawner B spawns a weapon in less than a second that might work. Because each spawner A is it's own entity you wouldn't need a new one for every random weapon placement. I think you'd need zscript to do this though.

I feel like there has to be an easier way though. Now it occurs to me that this sort of thing must have been done before. I would try to find deathwatch maps  with this sort of thing operating and dissect them to see how they work. There is a single player wad called reelism which has random weapon spawners. That might be worth checking out too.

Edited by Nihlith

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...