Frictional Games Forum (read-only)
AddBodyForce Cabinet Doors Script Problem - 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: AddBodyForce Cabinet Doors Script Problem (/thread-21817.html)

Pages: 1 2


AddBodyForce Cabinet Doors Script Problem - Mazl - 06-13-2013

Hello guys,

i want to get the two nice cabinet doors fast open with the BodyForce-Command. I dont know, whats the problem in this script Sad

Code:
SetSwingDoorDisableAutoClose("cabinet_nice_2", true);
  SetSwingDoorLocked("cabinet_nice_2",false,true);
  StartPlayerLookAt("lookatentitycabinet", 2, 2, "");
  SetMessage("Intro", "Intro11", 2.0f);
  AddEntityCollideCallback("Player", "Furniture_Shock_Area", "cabinetscare", true, 1);
}

void cabinetscare (string &in asParent, string &in asChild, int alState)
{  
  PlaySoundAtEntity("cabinetopensound","break_wood.snt","Player",0.1f,false);
  AddBodyForce("cabinet_nice_2_Body_1",0,0,-2000,"world");
  AddBodyForce("cabinet_nice_2_Body_2",0,0,-2000,"world");
  AddPlayerBodyForce(0, 0, -30000, false);          
  SetEntityActive("servant_grunt_1", true);
  SetPlayerSanity(0.4f);
  FadeOut(1.0f);
  ChangeMap("map_1", "PlayerStartArea_1","","");
}

I want to open it in the same direction like "AddPlayerBodyForce", which works correctly, but by the cabinet nothing happens, just a little bugging...

PS: sry for my bad english, i am german ^.^
PPS: its not the whole code, i just copied that, which is important ^-^


RE: AddBodyForce Cabinet Doors Script Problem - Tomato Cat - 06-13-2013

I *think* that only works for the player.

Try using AddPropForce.

PHP Code:
void AddPropForce(stringasNamefloat afXfloat afYfloat afZstringasCoordSystem);
//Name of the prop etc, force along X, Y, Z axes, and the coordinate system. "world" I think. 



RE: AddBodyForce Cabinet Doors Script Problem - Mazl - 06-13-2013

No, i tried it already Sad

for Player its the AddPlayerBodyForce


I also tried Prop- and BodyImpulse. SetSwingDoorClosed is too low for my CS.


RE: AddBodyForce Cabinet Doors Script Problem - DeAngelo - 06-13-2013

Perhaps you're doing it from the wrong direction. Also check if the cabinet is locked.


RE: AddBodyForce Cabinet Doors Script Problem - PutraenusAlivius - 06-13-2013

The door and the body is actually two different models put together by the Body. You need to direct it to the door, not the body, which is impossible (I think).


RE: AddBodyForce Cabinet Doors Script Problem - Mazl - 06-13-2013

Quote: Perhaps you're doing it from the wrong direction. Also check if the cabinet is locked.
PHP Code:
SetSwingDoorDisableAutoClose("cabinet_nice_2"true);
SetSwingDoorLocked("cabinet_nice_2",false,true); 

I already unlocked it Wink

and:

PHP Code:
AddPropForce("cabinet_nice_2_Body_1",0,0,-2000,"world");  AddPropForce("cabinet_nice_2_Body_2",0,0,-2000,"world");  
AddPlayerBodyForce(00, -30000false); 


the AddPlayerBodyForce goes to the right direction, and i think this is the direction, were the cabinetdoors have to go (the player goes backwards)

Quote: The door and the body is actually two different models put together by the Body. You need to direct it to the door, not the body, which is impossible (I think).
the 2 doors are two bodies (Body_1 and Body_2). Because that i think AddBodyForce, and when i take the value to 30000, the doors are bugging around -> something happens, but not that, what i want Big Grin


RE: AddBodyForce Cabinet Doors Script Problem - DeAngelo - 06-13-2013

This would be a bit roundabout, but you could try this: Make a new entity that is a move object, but is invisible. (You could just modify the blockbox and save it as a new entity)

Then place them in the level at the right angles so that when you move them (and move them rather fast but a short distance) they will "smack" the doors.

As I said, a bit roundabout but it should achieve what you want.


RE: AddBodyForce Cabinet Doors Script Problem - Mazl - 06-13-2013

Sorry, i dont understand much about entitys, modeleditor etc. Big Grin

I used this tutorial:

http://wiki.frictionalgames.com/hpl2/tutorials/script/pushdoorsopen

Edit: Really no one know whats the problem ?? The Tutorials says, its going, but... I need it so much Sad


RE: AddBodyForce Cabinet Doors Script Problem - Daemian - 06-15-2013

(06-13-2013, 02:30 PM)DeAngelo Wrote: This would be a bit roundabout, but you could try this: Make a new entity that is a move object, but is invisible. (You could just modify the blockbox and save it as a new entity)

Then place them in the level at the right angles so that when you move them (and move them rather fast but a short distance) they will "smack" the doors.

As I said, a bit roundabout but it should achieve what you want.
Actually that's an awesome idea.
I don't know if applying it here it's the best solution but it's great for more complex stuff. So i'll keep it in mind in case i ever need it. +rep DeAngelo.

Mazl,

I always use BodyImpulse and is working for me.
I just put the cabinet in my map, wrote this line and it opened one door as it should.


AddBodyImpulse( "cabinet_nice_1_Body_1", 5, 0, 5, "" );







RE: AddBodyForce Cabinet Doors Script Problem - DeAngelo - 06-15-2013

(06-15-2013, 03:41 AM)Amn Wrote: Actually that's an awesome idea.
I don't know if applying it here it's the best solution but it's great for more complex stuff. So i'll keep it in mind in case i ever need it. +rep DeAngelo.

Mazl,

I always use BodyImpulse and is working for me.
I just put the cabinet in my map, wrote this line and it opened one door as it should.


AddBodyImpulse( "cabinet_nice_1_Body_1", 5, 0, 5, "" );





I've only been working with HPL for a few months and in that time I've had to learn the editor from scratch, scripting from scratch, and model editor from scratch (I was thinking about learning blender, but that's a can of worms I'm not gonna open till my first CS is done)

and the one thing I've learned about HPL, is no matter the scope of your custom story, you WILL run into a situation where the engine just can't do what you want. In these instances, you either cut your losses and move on, or you improvise.

For instance, I have a wedding flashback in my story, where I force the player to "walk down the aisle" but the normal "force player to walk" script I didn't like because of the head bobble. I could've cut my losses, but I had already spent about 4 hours building the church (4 hours on something the player will see for a 3 second flashback, story of the Amnesia CS creators life, am I right?) so what I did was took a painting, modified it to be a move object, turned it sideways and plopped the player on it. Now they glide beautifully during the scene. In essence I turned a work of art into a surf board. Amazing what you can do in HPL with some improvising. Smile