Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Sign in to follow this  
Doomankhamun

Making a random monster replacer (almost there) (zScript)

Question

Hello,


I've been messing around with DECORATE files, and I managed to understand how to replace 1/10th of the zombiemen in a map with a custom monster. The problem is that most monsters under Realm667 use ZSCRIPT and I wanted to try some of them (I know some of them have an 'OLDCODE' file, but at this point I'd like to have more control and just try to understand the actual scripting).
So, I've downloaded some randomizers to try to understand some very simple functions but I'm afraid I might be too dumb, some mods include so much stuff it's hard to wrap your head around them.

Do you have any tip or any example ZSCRIPTs somewhere I might have missed? The idea is simple: create a monster replacer mod with random chance (small chance that a shotgunner will be replaced by this custom actor; another smaller chance that it might get replaced with this other custom actor; etc.)

 

Cheers

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 0

You can make a randomizer in a very simple way.

 

This is what I'm using for a randomizer.

Class UndeadSpawner : Actor Replaces ZombieMan //Replacing the standard Zombieman will let my random spawner to spawn a random undead in place of any zombieman
{
	static const string deads[] = { "Undead1", "Undead2", "Undead3" }; //using an array to store the classes that I want to use as "replacers"
	Default
	{
		//$Category Monsters
		//$Sprite 2FODA1
		//$Angled
		Height 52;
		Radius 18;
		+NOINTERACTION
		Tag "Undead Spawner";
	}
	States
	{
	Spawn:
		TNT1 A 1 NoDelay A_SpawnItemEx(deads[random(0,2)], 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION); //33% chance to get 1 of the 3 undead
		Stop;
	}
}

 

In your case you want something like this:

Class ShotgunnerReplacer : Actor Replaces ShotgunGuy //Replace the shotun guy
{
	static const string guys[] = { "CustomMonster1", "CustomMonster2", "ShotgunGuyDef", "ShotgunGuyDef" }; //About 50% to get one of the 2 new monsters and 50% of getting a normal shotgunguy
	Default
	{
		//$Category Monsters
		//$Sprite SPOSA1
		//$Angled
		Height 56;
		Radius 20;
		+NOINTERACTION
		Tag "Shotgunner Spawner";
	}
	States
	{
	Spawn:
		TNT1 A 1 NoDelay A_SpawnItemEx(guys[random(0,3)], 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION);
		Stop;
	}
}

And you need to make a new class to get the normal shotgunner, because you're replacing them all, so they don't "exist" anymore and you cannot spawn them, that's why I'm spawning a ShotfgunGuyDef.

Just make the new class that inherits everything from the normal shotgunguy and you're done:

Class ShotgunGuyDef : ShotgunGuy {}

 

Share this post


Link to post
  • 0

Thanks a lot Kan, this solves a lot of doubts.

When I'm merging the monsters into a single .wad or .pk3, I guess it doesn't really matter where I put the randomiser function?

Eventually I'd like to have a single file that tells the game something like this:

- replace Zombieman with this, or this, or this;

- replace That with this, this, etc.

 

I think my confusion comes from the fact that I really have no idea how to merge mods. Thanks a lot btw!

Share this post


Link to post
  • 0

I recommend to simply use the RandomSpawner class.

 

It is used like this (this example replaces Zombieman with random monster from "Undead 1-3" just like Kan's first example):

class UndeadSpawner : RandomSpawner replaces Zombieman
{
	default
	{
		DropItem "Undead1";
		DropItem "Undead2";
		DropItem "Undead3";
	}
}

 

The link documenting the class explains how to change probabilities for the individual monsters to spawn.

Share this post


Link to post
  • 0

Thanks jaeden.

I did manage to make something spawn using zscript. I have a question though, before I even start doing something serious.

Is there no way to simply include the .wad or .pk3 in my custom .pk3, without modifying its structure? I'll explain: right now I managed to make a monster spawn but I had to move all the specific files under the correct directories (sprites, sounds, etc). Is this something I have to do, or is there a better way I have overlooked?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×