Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Gametee


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Activating a random monster
Author Message
Slanderous Offline
Posting Freak

Posts: 1,608
Joined: Dec 2012
Reputation: 62
Post: #1
Question Activating a random monster

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: (Select All)
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: (Select All)
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: (Select All)
int iRand RandInt(02); 

into this (example for having 5 random monsters)

PHP Code: (Select All)
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.
(This post was last modified: 09-01-2015 06:02 PM by Slanderous.)
09-01-2015 05:59 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)