Frictional Games Forum (read-only)
Activating a random monster - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Articles (https://www.frictionalgames.com/forum/forum-40.html)
+---- Thread: Activating a random monster (/thread-30490.html)



Activating a random monster - Slanderous - 09-01-2015

Hi there. I wrote a small and easy script that basically randomizes which enemy shall spawn. As I said, it's small and easy to use and modify, so it should suit your needs. There is no limit for randomizing the monsters that are spawned so you can achieve some pretty jolly effects.

The code:

Spoiler below!
PHP Code:
void OnStart()
{
 
        
AddEntityCollideCallback("Player""Activate_Monster""CollideAreaActivateMonster"true1);
 
}
 
void CollideAreaActivateMonster(string &in asParentstring &in asChildint alState)
{
        
int iRand RandInt(02);
        
string[] MonsterPick = {"servant_grunt_1""servant_brute_1""enemy_suitor_1"};
        {
       
            
SetEntityActive(MonsterPick[iRand], true);
            
AddDebugMessage("pick"true);
       
        }



Explanation:

Frist of all, we're creating a script area where the script shall be executed. Then, place any monsters you want, wherever you want. Un - tick "Active" in "General" entity tab. At this point, it should look similiar to this:

Spoiler below!
[Image: a5draHI.jpg]

You can notice a grunt, brute and suitor. Copy their names from "General" tab, and paste into following line in the script:

PHP Code:
string[] MonsterPick = {"servant_grunt_1""servant_brute_1""enemy_suitor_1"}; 

This is how it should look like for having three enemies. If you want more, you need to change this:

PHP Code:
int iRand RandInt(02); 

into this (example for having 5 random monsters)

PHP Code:
int iRand RandInt(04); 

The first entity to spawn using this iRand thing is always 0. Treat 0 as 1 in this case, so it basically looks for a monsters 0-4 (1-5)

You can of course use, modify and share this script. Again, it's nothing complicated, just thought it might be useful for some folks. No need to give me credits.

Hope it's useful in some sort of way!

Oh, almost forgot. There is a debug message in this script, you can of course remove it.