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


Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Furniture - messing up and random filling
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#5
RE: Furniture - messing up and random filling

Yea, there is probably many different ways to generate random entities. I have figured out one way to make it possible with a short, simple script:

void OnStart()
{
    RandomEntityGenerator();
}

void RandomEntityGenerator()
{
    SetLocalVarString("entity_1", "butcher_knife.ent");  
    // entity type #1
    
    SetLocalVarString("entity_2", "book01.ent");              
    // entity type #2
    
    SetLocalVarString("entity_3", "tinderbox.ent");          
    // entity type #3
    
    int afEntTypeAmount = 3;      
    // amount of different entities
    
    int afSpawnAmount = 5;        
    // amount of entities to be spawned (should be same as amount of script areas)

    for(int i=1;i<=afSpawnAmount;i++)
    {
        int entType = RandInt(1, afEntTypeAmount);
        CreateEntityAtArea("entity_"+i, GetLocalVarString("entity_"+entType), "SpawnArea_"+i, false);  
        // spawns an entity type at SpawnArea_i
        
        string message = "Entity has spawned! Type: "+entType;
        AddDebugMessage(message, false);
    }
}

Image of script areas:

Spoiler below!

[Image: EIROB.png]


You can simply add more entity types by adding more LocalVarStrings, remember to name the strings with the correct name and update the integer for the amount of different entities.
You can also add more script areas in your map, they should be named: (SpawnArea_i), where i is the index. Do not forget to update the integer for the amount of entities to be spawned. You can rotate the script areas if you want the entities to spawn with different angles.

There is probably better ways to spawn random entities, but this is one, simple and possible way to do it Smile
.
(10-23-2012, 12:45 PM)craven7 Wrote: Also I wonder if there's a way to generate random stuff like books, clothes, bottles etc inside the drawers, desktop's and cabinets by script.
10-23-2012, 06:47 PM
Website Find


Messages In This Thread
RE: Furniture - messing up and random filling - by Mackiiboy - 10-23-2012, 06:47 PM



Users browsing this thread: 1 Guest(s)