id Tech Forums

id Tech 4 (Doom3/Prey/Q4) => id Tech 4 Scripting => Topic started by: calan on October 29, 2014, 08:51:26 PM

Title: Random non-encounters?
Post by: calan on October 29, 2014, 08:51:26 PM
I'm amazed that I can't find a mod to truly randomize the appearance of monsters in D3. I've played around with the settings in sikkmod, and it works well for cramming more monsters into the game. But...  in order to be truly random, the canned/scripted monsters that jump out from their cubby holes need to be randomized as well.

Is there ANYTHING out there that will cause the scripted AI to simply not appear sometimes (most of the times?), and cause random monsters to appear in different places? To me this would be the number one enhancement to extend gameplay.

I have a mod compilation as well as a lot of my own stuff all playing nice together. I just need some maps/scripts/ whatever, without a bunch of other fluff like pink weapons, atomic grenades, etc.  :)

- Craig

P.S. Still loving D3 even after 10 years. I'm amazed at how well it holds up and am thankful for the continuing community!
Title: Re: Random non-encounters?
Post by: The Happy Friar on October 30, 2014, 10:44:56 AM
Not for the stock game, that I'm aware of.

I've done it before with custom maps/mods.
Title: Re: Random non-encounters?
Post by: calan on October 30, 2014, 11:38:26 AM
Got any that you'd like to share?  :)

BTW - Thanks for setting up this site!
Title: Re: Random non-encounters?
Post by: The Happy Friar on October 31, 2014, 06:32:38 AM
Don't have much time right now (common theme this month :/ ) but my mod has randomized zombies: http://www.moddb.com/mods/the-happy-friars-last-stand
Title: Re: Random non-encounters?
Post by: calan on November 03, 2014, 03:18:02 PM
Is there an easy way to edit a map file, find the monsters, and enter some code that will only let them spawn randomly?
Title: Re: Random non-encounters?
Post by: BielBdeLuna on November 04, 2014, 05:24:37 AM
map files are text files, I guess you can always find and replace.
Title: Re: Random non-encounters?
Post by: BloodRayne on November 04, 2014, 10:55:47 AM
Quote from: calan on November 03, 2014, 03:18:02 PM
Is there an easy way to edit a map file, find the monsters, and enter some code that will only let them spawn randomly?

You need to define randomly spawning enemies more clearly.

Most enemies in Doom3 work by using predetermined pathing (AAS pathing) which follows hints for the monsters to follow and make their way through the map. You can't really spawn an enemy randomly without first defining a position where it can do so cleanly, without sticking half inside a wall, or in a place where it can't navigate.

So there needs to be logic in the placement of the monsters. When I made the now unavailable 'Ultimate Mod' for Doom 3, it included a randomized spawn system. But what that did was spawn new monsters in the place where old ones had died after a random amount of time, creating the illusion where they're sort of following you.

The best way to do real random monsters is create custom spawnpoints. Add a script with a random timer and spawn a monster, when the monster dies have it trigger the random spawner again so it spawns another one. Then replace all monster entities that don't have special spawnargs or animations in with this monster spawner, and using the editor, place extra random spawn points by hand.

Grimm has all this logic, you might want to check out how that was implemented here: http://www.moddb.com/mods/grimm-quest-for-the-gatherers-key
Title: Re: Random non-encounters?
Post by: calan on November 04, 2014, 11:55:41 AM
Thanks BloodRayne.

What I'm shooting for right now is much simpler.... I just want a way to make existing monsters only appear "sometimes". Some type of script that uses random numbers to control if they can spawn, or if they stay inactive and hidden.

Another thought I had was to use something like that ^ in conjunction with the random encounters code in sikkmod. This is all speculative without any study of the code (I'm still in learning mode), but would it be possible to invisibly spawn a pre-placed monster and then kill it immediately...thus setting up a random respawn? If so, it should be fairly easy to generate a lot of randomness without changing the existing maps...other than adding the script to each existing monster.

My thought experiment is that you add a script to each desired monster (or maybe a global script in the monster ai?) that sometimes lets it function as scripted, sometimes keeps it completely inactive, and sometimes spawns it invisibly and then immediately kills it (thus hopefully triggering a random respawn).

Seems doable, but I don't have the scripting/level knowledge to actually put it in place to test. If someone can help me with the script and process (or just help flesh out the details as I'm learning), I'll go through the maps and set it all up. Could be very interesting.



Title: Re: Random non-encounters?
Post by: calan on November 04, 2014, 05:14:01 PM
someone add this entity/value pair to ai_monster_base, that can be set for each monster in a level:

spawn_control
0 = never
1 = every time (normal)

Between 0 and 1 is a probability of spawning percentage. (I.E. a value of .4 would mean that the monster comes to life and shows up about 40% of the time.)

2 = invisible spawn and quick death, to trigger sikkmod random encounter.


*****

...or if it can be done without recompiling the SDK, teach me.   :D
Title: Re: Random non-encounters?
Post by: solarsplace on November 05, 2014, 05:24:14 AM
Hi

Try adding this code to monster_base::monster_begin as shown below. It should do what you want, or at least give you a head start. As you said, you will need to add a key value pair ( "spawn_control" / float value ) to each AI you want to participate in this functionality.

The code appears to work, but I will leave the in depth testing to you  ;)

/*
=====================
monster_base::monster_begin
=====================
*/
void monster_base::monster_begin() {

// ***************************************
// ***************************************

float rndChance = 0;
float rndNumber = 0;

rndChance = getFloatKey( "spawn_control" );
if ( rndChance == 0 ) { rndChance = 1.0; } // Need to set a default value of always spawn.
rndNumber = random( 1.0 );

if ( rndChance == 0 ) {
// No chance of spawning, just remove.
self.remove();
return;
}

if ( rndChance == 2 ) {
// Always kill.
self.hide();
self.kill();
return;
}

if ( rndChance > 0 && rndChance < 1 ) { // If rndChance == 1 always spawn.

// If a random number between 0 and 1 is greater than
// the AI chance number then remove the AI.

if ( rndNumber > rndChance ) {
self.remove();
return;
}
}

// ***************************************
// ***************************************


Hope that helps.

Cheers
Title: Re: Random non-encounters?
Post by: calan on November 05, 2014, 09:24:16 AM
Awesome, but I have a dumb question.

How do I add the "spawn_control" value to the monster defs? Is it as simple as just putting "spawn_control   1.0" in "monster_default.def", and then over-riding it in whatever monster defs that I want a different value?

Thanks much!
Title: Re: Random non-encounters?
Post by: solarsplace on November 05, 2014, 09:45:34 AM
Hi

The default value is set in the script as a 1.0 meaning the AI will behave as if nothing is different.

rndChance = getFloatKey( "spawn_control" );
if ( rndChance == 0 ) { rndChance = 1.0; } // Need to set a default value of always spawn.


To change the "spawn_control" values for the AI entities you want, you will need to load the Doom 3 Editor (Or DarkRadiant etc) and locate and select the AI you want to change. The in the entity inspector in the editor you will see existing key / value pairs for each AI. Just add a new key value pair such as "spawn_control" / 0.4 etc.

You could also locate the entityDef file for a specific AI and add a new key / val into that meaning all AI of that type get that key / val setting.

There is a concern that if you blanket apply this to the AI, you are probably going to get issues with some of the standard game maps if they rely on an AI being there for some script event. You could possibly break parts of the game with some existing script threads crashing and halting execution because the IA they were manipulating was removed or killed off already.

Cheers
Title: Re: Random non-encounters?
Post by: calan on November 05, 2014, 10:10:10 AM
That's what I thought on defining the spawn_control values... tried it both ways and not having luck yet, but still working on it. Probably just operator error.  :)

Interesting thought on the scripting errors. Is there an easy way to see which monsters in a level are "needed" and should be left alone?
Title: Re: Random non-encounters?
Post by: The Happy Friar on November 05, 2014, 10:48:18 AM
the easiest way may be to play through the game with a key bound to "toggle g_stoptime".  Then (I forget the console command) find the entity name (when time is stopped) & load up the map script & do a search for that entity.  Also do a search of the map (in a text editor should be fine).  If you find a script that references that monster, or the map has entities that call to or from that monster, it might not be wise to change it.
Title: Re: Random non-encounters?
Post by: calan on November 05, 2014, 11:40:54 AM
Still no luck. Here is what I have:

monster_default.def

entityDef monster_default {
"editor_color" "1 .5 0"
        ...
        ...
        ...

// ***** CAS random non-encounters *****
"spawn_control"    "1.0"
"editor_var spawn_control"    "Controls how often monster spawns. 0 = never, 1 = always. Values between 0 and 1 cause monster to spawn x% of the time. A value of 2 causes the monster to spawn and then be killed immediately, to trigger a random encounter."

}


ai_monster_base.script

void monster_base::monster_begin() {

// ***************************************  CAS random non-encounters begin  **********************************

float rndChance = 0;
float rndNumber = 0;

rndChance = getFloatKey( "spawn_control" );
if ( rndChance == 0 ) { rndChance = 1.0; } // Need to set a default value of always spawn.
rndNumber = random( 1.0 );

if ( rndChance == 0 ) {
// No chance of spawning, just remove.
self.remove();
return;
}

if ( rndChance == 2 ) {
// Always kill.
self.hide();
self.kill();
return;
}

if ( rndChance > 0 && rndChance < 1 ) { // If rndChance == 1 always spawn.

// If a random number between 0 and 1 is greater than
// the AI chance number then remove the AI.

if ( rndNumber > rndChance ) {
self.remove();
return;
}
}

// ***************************************  CAS random non-encounters  end  ***********************************


float teleportType;
string triggerAnim;
float waittime;
        ...
        ...
        ...
        ...
}



big_map.map

...
...
...
// entity 1
{
"anim" "idle"
"classname" "monster_zombie_boney"
"name" "monster_zombie_boney_1"
"origin" "272 168 0"
"angle" "180"
"trigger" "1"
"spawn_control" "0.5"
}
...
...



I know the script is reading the spawn_control value from the map, because I can change it from 0 to 1 in the map entity def and it responds as it should. But, the script isn't working as I expect it to.

rndChance = 0, no monsters (as expected)
rndChance = 1, monsters always spawn (as expected)
rndChance = anything between 0 and 1, monsters always spawn
rndChance = 2, monsters never spawn and nothing ever happens. Random encounters is working though, because if I spawn a monster and then kill it, another one will spawn.

Still investigating....

EDIT:

Ok, it looks like the random encounters is working when rndChance = 2. The RE monsters weren't spawning because I'm in the corner of a test room, and they won't appear until I look away. I thought if I set the teleport value, they would spawn no matter if I was looking or not, but that doesn't seem to be the case. I still have to look away, and then POOF!...  there they are.

Still can't get the random appearance to work though.
Title: Re: Random non-encounters?
Post by: solarsplace on November 05, 2014, 12:05:53 PM
Hi

Sorry, small bug :(

Change this:

rndNumber = random( 1.0 );

To this:

rndNumber = sys.random( 1.0 );

Cheers
Title: Re: Random non-encounters?
Post by: calan on November 05, 2014, 12:22:10 PM
Still no worky.

I've discovered that if I use a spawn_control value of .5 or lower, Bernie never spawns. If I use .6 or higher, he always spawns.

Something else that is a bit odd....if Bernie is set to not spawn (either by a value of 0 or anything below .5), there is a brief flicker of his flame that fades out as the room comes into view. Not sure if that is relevant or not.

EDIT: Would re-seeding the random generator help? How (can) you do that in the D3 scripting engine?
Title: Re: Random non-encounters?
Post by: Ivan_the_B on November 05, 2014, 02:45:31 PM
The seed is only random in multiplayer games.
I guess it made testing the singleplayer maps easier.
You need the SDK to change that.
Title: Re: Random non-encounters?
Post by: calan on November 05, 2014, 05:18:49 PM
Ok, I have some more info, and I'm even more confused.  :)


I changed the script up a little. The value for "spawn_control" can now be:

0 = monster never spawns
1 = monster always spawns
2 = monster spawns then dies
3 = one of the above behaviors is randomly selected every time the monster is created.

Here is the script in ai_monster_base.script. Notice that I added some sys warnings to show what is going on.:


/*
=====================
monster_base::monster_begin
=====================
*/
void monster_base::monster_begin() {

float spawnControl = 0;
float rndNumber = 0;

spawnControl = getFloatKey( "spawn_control" );
rndNumber = sys.random(3) ;

if (spawnControl <= 0 ) {
// No chance of spawning, just remove.
self.remove();
sys.warning( "spawnControl = 0; monster not spawned");
return;
}

if (spawnControl > 0 && spawnControl <= 1) {
// always spawn
sys.warning( "spawnControl = 1; monster spawned");
return;
}

if (spawnControl > 1 && spawnControl <= 2) {
// spawn, then kill immediately
self.hide();
self.kill();
sys.warning( "spawnControl = 2; monster spawned and killed");
return;
}

if (spawnControl > 2) {
// randomized.appearances

if (rndNumber > 0 && rndNumber < 1 ) {
// don't spawn
self.remove();
sys.warning( "spawnControl = 3; monster not spawned (random: " + rndNumber + ")");
return;
}
if (rndNumber >= 1 && rndNumber < 2 ) {
// spawn
sys.warning( "spawnControl = 3; monster spawned (random: " + rndNumber + ")");
return;
}
if (rndNumber >= 2) {
// spawn, then kill immediately
self.hide();
self.kill();
sys.warning( "spawnControl = 3; monster spawned and killed (random: " + rndNumber + ")");
return;
}
}

        ...
        ...
        ...



and here is the default value in monster_default.def:


        ...
        ...
"spawn_control"  "3"   //   set to random behavior for testing an unmodified map
"editor_var spawn_control"    "Controls how often monster spawns. 0 = never, 1 = always, 2 = spawn and die, 3 = random. A value of 2 causes the monster to spawn and then be killed immediately, to trigger a random encounter."
        ...
        ...


First, the good news. I loaded up an unmodified Alpha Labs 1 map, and the script seemed to work fine. Unfortunately, their weren't many monsters hanging around. For some reason, the random values assigned to each monster increase in an almost linear fashion as each monster is created. So the first monsters were all between 0 and 1, and never spawned. The middle monsters were set from 1 to 2 and did spawn, and by the end of the map the monsters were in the 2's and were being set to spawn and then be killed. While this may have made for a crazy map (easy at first, nightmare at the end), it isn't what I want.

Why would the random numbers increase as the monsters are being created? (It almost has to be a function of the RNG not being reseeded on each call I think).  How do I get a truly random number between 0 and 3 when each monster is created, if I can't re-seed the RNG each time?

Another issue I'm having is that the spawn_control values in my test map (with 3 monsters) don't appear to be getting passed through. The monsters always get created with whatever spawn_control value I set in the monster_default.def file...or so it seems.

So close!   :)


FWIW, even with this only partially working, playing through the first part of Alpha Labs (which I've gone through a hundred times) was quite different and fun.
Title: Re: Random non-encounters?
Post by: The Happy Friar on November 05, 2014, 10:31:57 PM
I took a look at the random monster/zombie spawner I made years ago and I must of had the same issue with the float numbers.  This is the code I made to randomly choose a zombie and it always worked:
    float num_zom_types = 22 - 1;        //number of zombie types to choose from.  ALL must be setup below!  NOTE: 1 is subtracted because the random function could pick 0
    float x = 0;                //temp counting var
    float random_x = int(sys.random(num_zom_types));            //random number generated
    entity zombie_spawn;            //entity used for spawning


Notice I had 22 possible choices and the random could only be an int.  It would randomly choose between 0 and 21.

EDIT: script is here: http://sterlingshield.net/home/steve/doom3/06jan.html
Title: Re: Random non-encounters?
Post by: calan on November 06, 2014, 12:40:07 AM
I'll give the integer approach a try.

Those script utilities look very interesting, if I can ever figure out what they are doing and how to use them.  My approach to using the scripted death of existing monsters to create new ones via sikk's random encounters isn't working out so well (random number issues aside). I usually just end up with a lot less monsters. I really wish it was simpler to just spawn monsters randomly anywhere in a map.

Thanks for the help!
Title: Re: Random non-encounters?
Post by: solarsplace on November 06, 2014, 05:35:36 AM
Quote from: Ivan_the_B on November 05, 2014, 02:45:31 PM
The seed is only random in multiplayer games.
I guess it made testing the singleplayer maps easier.
You need the SDK to change that.

Hi

Well, learnt something new!

Ivan has given us the answer already  ;)

You can cast the float to an int all you like but the outcome will still be the same :P

Because the script calls sys.random at the same time every time on map load, rather than at a random time during the map:

Your random number will always be the same on initial map load if your map scripts events process at a consistent initial game frame each time you load the map. Which in most cases it will unless you change something about how the script timing operates.

This is because if the game type is single player the random number generator is initialized with a random seed value of 0 every time. As Ivan already pointed out, this is likely to make testing single player maps consistent when reloading multiple times maybe...

If it is a multiplayer type game it is initialized to pseudo random number.

I have made the change in the Sikkmod SDK to make it always initialized to a pseudo random number.

/*
===================
idGameLocal::LoadMap

Initializes all map variables common to both save games and spawned games.
===================
*/
void idGameLocal::LoadMap( const char *mapName, int randseed ) {

...
...
...

// reset the random number generator.
// random.SetSeed( isMultiplayer ? randseed : 0 );
// Solarsplace - 6th Nov 2014 - Always reset the random number generator. Not just for multiplayer.
random.SetSeed( randseed );


There is a new game00.zip attached. Extract it into your mod folder there is the game00.pk4 inside. I recommend you backup your old game00.pk4 in case this does not work out and you want to revert.

Thanks



Title: Re: Random non-encounters?
Post by: The Happy Friar on November 06, 2014, 08:09:42 AM
"Way back when" I did lots of test with random numbers, float vs int.  Float had a lot less randomness vs int for most proposes.  I'd print the random numbers to the console and they would be different sets each time I'd run the map.  When I tested float vs int, I never got 1.0 or 0.  When I tested ints (with the script I posted) I'd get 0 and 21 after a couple runs. 

My theory is this: int avoid rounding problems, float's don't.  If you want a random int between 0 and 21, there's only 22 possibilities.  if you get a float it's truncated or rounded (I forget).  If you want a random float between 0 and 1 & D3 supports 6 decimal points(not sure), there's 1 million possibilities.  People just don't normally think down to that level of detail when wanting a random number, but, in theory, a number between 0 and 21 has the same possibility as a float between 0 and .000021.  I want to say that even if I tried to get a random number between 0 and 21 and didn't use an int it always tended to be on the low end though (under 1).  I'd have to run tests again to see.

On another randomness note, you could use game time to help random numbers along with more "randomness".  I would figure because odds are you'd never take the exact same amount of time to get to the trigger that calls the script.  Might be 0.001234 seconds different, but that's a different number then 0.000000.

EDIT: currenttime - (int(currenttime)) should trunk the time so you get just a decimal & no whole number.  IE 234.534534 = current time, int(234.534534) = 235 (if it rounds).  That would leave -0.534534 as your value.  That could be a random value of it's own!
Title: Re: Random non-encounters?
Post by: solarsplace on November 06, 2014, 09:41:24 AM
Quote from: calan on November 05, 2014, 05:18:49 PM

...snip

For some reason, the random values assigned to each monster increase in an almost linear fashion as each monster is created.

... snip ...

Why would the random numbers increase as the monsters are being created? (It almost has to be a function of the RNG not being reseeded on each call I think)

snip ...


Hi

This turned into quite an interesting topic :)

Happy Friar makes some good points about the use of int vs float and that is something to bear in mind that is quite easily overlooked.

Calan is also quite right about the random seed being the issue for scripts that run random at map load. This is why you see the numbers increasing in a repeatable way each frame. Because the random seed is initalised to 0 and not a pseudo random in the beginning.

ID_INLINE int idRandom::RandomInt( void ) {
seed = 69069 * seed + 1;
return ( seed & idRandom::MAX_RAND );
}


So basically you probably wont notice this lack of randomness if you call random from various triggers in the map that happen at un-predictable times. But if you call random a lot on map load its going to be repeatable and quite un-random.

Cheers
Title: Re: Random non-encounters?
Post by: solarsplace on November 06, 2014, 10:39:11 AM
Hi

Sorry to keep going on about this. But I wanted to fully understand what was happening here as I was quite interested in putting something like this in the Arx mod too.

These findings demonstrate the repeatability of calling random from scripts and code during map load when the seed is initalised to 0. This means that the same monsters will always either show or get removed every time!

Without the SDK fix We would need to find some other way of making this more random.

Run 1 of 2
Load D3, run test map, dump results:

rndNumber = 0.546204
rndNumber = 0.220947
rndNumber = 0.074280
rndNumber = 0.997070
rndNumber = 0.625793
rndNumber = 0.734131
rndNumber = 0.950745
rndNumber = 0.182129
rndNumber = 0.799133
rndNumber = 0.091064
rndNumber = 0.920959

Quite D3 entirely.

Run 2 of 2
Load D3, run test map, dump results:

rndNumber = 0.546204
rndNumber = 0.220947
rndNumber = 0.074280
rndNumber = 0.997070
rndNumber = 0.625793
rndNumber = 0.734131
rndNumber = 0.950745
rndNumber = 0.182129
rndNumber = 0.799133
rndNumber = 0.091064
rndNumber = 0.920959

Numbers exactly the same.

Implement SDK fix and repeat the above:

Run 1 of 2

rndNumber = 0.915375
rndNumber = 0.278839
rndNumber = 0.678802
rndNumber = 0.204376
rndNumber = 0.496918
rndNumber = 0.372101
rndNumber = 0.119720
rndNumber = 0.532013
rndNumber = 0.297211
rndNumber = 0.434113

Run 2 of 2

rndNumber = 0.172577
rndNumber = 0.386627
rndNumber = 0.728973
rndNumber = 0.823883
rndNumber = 0.715057
rndNumber = 0.878326
rndNumber = 0.880829
rndNumber = 0.299957
rndNumber = 0.976288
rndNumber = 0.838776

Numbers totally different this time!

Hope this helps someone out in the future.

Thanks
Title: Re: Random non-encounters?
Post by: The Happy Friar on November 06, 2014, 11:15:11 AM
Try using my time adding idea and see what the spread is on those random numbers.
Title: Re: Random non-encounters?
Post by: calan on November 06, 2014, 11:29:25 AM
First, thanks so much for the SDK fix Solar.  ;)

Second...  when I load a map using this in my script:


...
...
rndNumber = int(sys.random(100));
sys.warning( "random: " + rndNumber);
...
...


I now get mostly decreasing integers. The first half of the monsters get a random value above 50, the second half below. :wtf:
Title: Re: Random non-encounters?
Post by: solarsplace on November 06, 2014, 11:47:24 AM
Hi

Try using this to get a cleaner log:

rndNumber = int( sys.random( 100 ) );
sys.print( "random: " + rndNumber + "\n");


Not sure what is going on for you as I'm getting a pretty random spread:

random: 31
random: 25
random: 91
random: 6
random: 97
random: 13
random: 76
random: 32
random: 64
random: 71

Have you misplaced a = when it should be a == somewhere in the script?

Post your script as you have it, thanks.
Title: Re: Random non-encounters?
Post by: calan on November 06, 2014, 11:52:15 AM
This is the script as it sits now:



/*
=====================
monster_base::monster_begin
=====================
*/
void monster_base::monster_begin() {

// ***************************************  CAS random non-encounters begin  **********************************
float spawnControl = 0;
float rndNumber = 0;
spawnControl = getFloatKey( "spawn_control" );

if (spawnControl == 0 ) {
// No chance of spawning, just remove.
self.remove();
sys.print( "spawnControl = 0; monster removed\n");
return;
} else if (spawnControl == 1) {
// always spawn
sys.print( "spawnControl = 1; monster spawned\n");
} else if (spawnControl == 2) {
// spawn, then kill
self.hide();
self.kill();
sys.print( "spawnControl = 2; monster spawned and killed\n");
return;
} else if (spawnControl == 3) {
// randomized.appearances
rndNumber = int(sys.random(100));
if (rndNumber >= 50 ) {
// spawn
sys.print( "spawnControl = 3; monster spawned (random: " + rndNumber + ")\n");
} else {
// spawn, then kill
self.hide();
self.kill();
sys.print( "spawnControl = 3; monster spawned and killed (random: " + rndNumber + ")\n");
return;
}
}
// ***************************************  CAS random non-encounters  end  ***********************************

float teleportType;
string triggerAnim;
        ...
        ...
        ...



"spawn_control" is always "3", as set in the monster_default.def file.

I'm not sure the "spawn, then kill" approach is working. I believe it should finish the begin procedure and then kill it, but not sure. I've tried it both ways and haven't noticed any difference other than the visibility of the monster. (it stays visible and then commits suicide if moved to the end of the function.  :)  )

Regardless, the sikkmod random encounters doesn't seem to be getting triggered by the monster deaths as I had hoped.




EDIT: It does appear to be pretty random now. I dunno... maybe something wasn't saved or refreshed.

(thanks for the sys.print tip BTW.  ;) )

Now if I could just get my suicidal monsters to spawn new random ones....
Title: Re: Random non-encounters?
Post by: solarsplace on November 06, 2014, 12:17:45 PM
Hi

Glad you are getting more random results now  ;D

I just tried the .DLL I sent you with your code in this D3 test map testmaps/test_lotsaimps and got pretty random results indeed!

spawnControl = 3; monster spawned (random: 98)
spawnControl = 3; monster spawned (random: 66)
spawnControl = 3; monster spawned and killed (random: 9)
spawnControl = 3; monster spawned and killed (random: 18)
spawnControl = 3; monster spawned and killed (random: 17)
spawnControl = 3; monster spawned and killed (random: 39)
spawnControl = 3; monster spawned and killed (random: 13)
spawnControl = 3; monster spawned and killed (random: 40)
spawnControl = 3; monster spawned (random: 68)
spawnControl = 3; monster spawned (random: 80)
spawnControl = 3; monster spawned and killed (random: 17)
spawnControl = 3; monster spawned (random: 92)
spawnControl = 3; monster spawned (random: 98)
spawnControl = 3; monster spawned and killed (random: 25)
spawnControl = 3; monster spawned (random: 66)
spawnControl = 3; monster spawned (random: 99)
spawnControl = 3; monster spawned and killed (random: 38)
spawnControl = 3; monster spawned (random: 64)
spawnControl = 3; monster spawned (random: 59)
spawnControl = 3; monster spawned and killed (random: 31)
spawnControl = 3; monster spawned (random: 61)
spawnControl = 3; monster spawned (random: 53)
spawnControl = 3; monster spawned (random: 80)
spawnControl = 3; monster spawned (random: 79)
spawnControl = 3; monster spawned (random: 82)
spawnControl = 3; monster spawned (random: 64)
spawnControl = 3; monster spawned (random: 59)
spawnControl = 3; monster spawned (random: 92)
spawnControl = 3; monster spawned (random: 99)
spawnControl = 3; monster spawned (random: 85)
spawnControl = 3; monster spawned and killed (random: 10)
spawnControl = 3; monster spawned and killed (random: 43)
spawnControl = 3; monster spawned and killed (random: 34)
spawnControl = 3; monster spawned (random: 50)
spawnControl = 3; monster spawned (random: 61)
spawnControl = 3; monster spawned (random: 96)
spawnControl = 3; monster spawned and killed (random: 29)
spawnControl = 3; monster spawned (random: 80)
spawnControl = 3; monster spawned and killed (random: 39)
spawnControl = 3; monster spawned and killed (random: 20)
spawnControl = 3; monster spawned and killed (random: 5)
spawnControl = 3; monster spawned (random: 74)
spawnControl = 3; monster spawned and killed (random: 11)
spawnControl = 3; monster spawned (random: 99)
spawnControl = 3; monster spawned (random: 52)
spawnControl = 3; monster spawned (random: 77)
spawnControl = 3; monster spawned (random: 82)
spawnControl = 3; monster spawned (random: 92)
spawnControl = 3; monster spawned and killed (random: 35)
spawnControl = 3; monster spawned and killed (random: 37)

I have no idea how the Sikkmod random monsters thing works. I will have a look tomorrow and see if we can do something to get it to work.

By the way, you cannot put the kill code at the end of the monster_begin method because there are a number of wait states and loops that the AI sits in before it gets to the end of the method. So it may well sit there waiting to see you or be triggered before it ends itself.

Cheers for now.
Title: Re: Random non-encounters?
Post by: calan on November 06, 2014, 01:26:56 PM
That is awesome!  Thanks much for your help with this (and everyone else also).


*****

I think part of the problem with no monsters spawning is that they don't "exist" yet as far as the random encounters code is concerned, since a lot of them are set to hide, sleep, or whatever until the player interacts with them. I haven't seen the RE code, but I think it will only re-spawn monsters that are active in the level...so maybe there just aren't enough monsters around to respawn?

I dunno....  just speculation.