craven7
Member
Posts: 50
Threads: 8
Joined: Aug 2012
Reputation:
1
|
Furniture - messing up and random filling
Hi
I tried to mess up furniture like in 10_daniels_room, but nothing happens when using this script:
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
|
|
10-23-2012, 12:45 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Furniture - messing up and random filling
I would you AddPropImpulse, since they are all props... And 30 is very much, when you use impulse
Trying is the first step to success.
|
|
10-23-2012, 01:24 PM |
|
craven7
Member
Posts: 50
Threads: 8
Joined: Aug 2012
Reputation:
1
|
RE: Furniture - messing up and random filling
But in daniels_room by FG these functions are used too...
//----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()
|
|
10-23-2012, 03:37 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Furniture - messing up and random filling
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
Trying is the first step to success.
|
|
10-23-2012, 04:34 PM |
|
Mackiiboy
Member
Posts: 101
Threads: 7
Joined: Jan 2012
Reputation:
11
|
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:
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
. (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 |
|
craven7
Member
Posts: 50
Threads: 8
Joined: Aug 2012
Reputation:
1
|
RE: Furniture - messing up and random filling
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.
|
|
10-23-2012, 07:09 PM |
|
Mackiiboy
Member
Posts: 101
Threads: 7
Joined: Jan 2012
Reputation:
11
|
RE: Furniture - messing up and random filling
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
. (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.
|
|
10-23-2012, 07:26 PM |
|
craven7
Member
Posts: 50
Threads: 8
Joined: Aug 2012
Reputation:
1
|
RE: Furniture - messing up and random filling
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^^
|
|
10-23-2012, 09:53 PM |
|
|