Frictional Games Forum (read-only)
[SCRIPT] Furniture - messing up and random filling - 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 Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Furniture - messing up and random filling (/thread-18891.html)



Furniture - messing up and random filling - craven7 - 10-23-2012

Hi

I tried to mess up furniture like in 10_daniels_room, but nothing happens when using this script:

Code:
AddBodyImpulse("chest_of_drawers_simple_1_Body_1",0,0,-3,"world");
    AddBodyImpulse("chest_of_drawers_simple_1_Body_2",0,0,-3,"world");
    
    AddBodyImpulse("chest_of_drawers_nice_1_Body_1",0,0,30,"world");
    AddBodyImpulse("chest_of_drawers_nice_1_Body_2",0,0,30,"world");
I tried other values and axes but the result is the same; nothing.

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.


Thx


RE: Furniture - messing up and random filling - FlawlessHappiness - 10-23-2012

I would you AddPropImpulse, since they are all props... And 30 is very much, when you use impulse Smile


RE: Furniture - messing up and random filling - craven7 - 10-23-2012

But in daniels_room by FG these functions are used too...
Code:
//----ROOM MESS SETUP----//
    AddBodyImpulse("chest_of_drawers_simple_2_Body_1", 0.25, 0, 0, "world");
    AddBodyImpulse("chest_of_drawers_simple_2_Body_2", 0.75, 0, 0, "world");
    AddBodyImpulse("chest_of_drawers_simple_2_Body_3", 0.5, 0, 0, "world");
    AddBodyImpulse("chest_of_drawers_simple_1_Body_1", -0.5, 0, 0, "world");
    AddBodyImpulse("chest_of_drawers_simple_1_Body_2", -1, 0, 0, "world");
    
    AddBodyImpulse("work_desk_1_Body1", 0, 0, -2, "world");
    AddBodyImpulse("work_desk_1_Body2", 0, 0, -3, "world");
    AddBodyImpulse("work_desk_1_Body3", 0, 0, -1, "world");
    AddBodyImpulse("work_desk_2_Body3", 0, 0, -0.5, "world");
    AddBodyImpulse("work_desk_2_Body1", 0, 0, -0.7, "world");
in OnStart()


RE: Furniture - messing up and random filling - FlawlessHappiness - 10-23-2012

FG did a lot of stuff that i don't understand either.

F.x. All of their scripts areas has PlayerLookAtAutoRemoveCallback checked...

Anyway: Give it a try with AddPropImpulse


RE: Furniture - messing up and random filling - Mackiiboy - 10-23-2012

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:

Code:
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.



RE: Furniture - messing up and random filling - craven7 - 10-23-2012

Hi, thanks for your solution, but I was looking for a more automatic way to do this... I mean if I have to place scriptAreas in every furniture in my map I can as well place the items instead.

It would be nice if there was a way to do this only with scripthing and without having to use the leveleditor.
As it seems possible to address each part of a furniture (drawers) I thought there may be a way to spawn items inside these.


RE: Furniture - messing up and random filling - Mackiiboy - 10-23-2012

You do just have to place script-areas inside one drawer. After that, you could just combine and create a compound of the drawer and the script-areas and duplicate the compound and place it somewhere else. It will not take much time after you have created the first compound. (int afSpawnAmount will then be X*Y where X is the amount of areas inside one drawer, and Y the amount of drawers).

It is still a bit time-consuming, but it takes much less time than placing random entities by hand in all drawers Smile
.
(10-23-2012, 07:09 PM)craven7 Wrote: Hi, thanks for your solution, but I was looking for a more automatic way to do this... I mean if I have to place scriptAreas in every furniture in my map I can as well place the items instead.

It would be nice if there was a way to do this only with scripthing and without having to use the leveleditor.
As it seems possible to address each part of a furniture (drawers) I thought there may be a way to spawn items inside these.



RE: Furniture - messing up and random filling - craven7 - 10-23-2012

Yeah you're right with this, I didn't think about this method. It's jstu because I already placed many drawers etc and now I'd have to replace them^^