Frictional Games Forum (read-only)
Force to trigger function. - 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: Force to trigger function. (/thread-14816.html)



Force to trigger function. - AnthonyTrix - 04-15-2012

Hi,

I was just wondering how I trigger a function when a certain force is applied.

Example: The wall in the archives with the holes in it. If you throw a rock on it hard enough it breaks. How do I do that?

EDIT: In my case I want the player to slam a sledgehammer into a wall in order for it to break.


RE: Force to trigger function. - Acies - 04-15-2012

I am no scripting guru, but I think the "destroy on certain force" can be assigned in the ModelEditor. You can also assign a "deathentity" created when the wall is destroyed. Perhaps some rocks?

As for what force you should specify, no idea :>


RE: Force to trigger function. - Homicide13 - 04-15-2012

You can either use the model editor to set the health of the prop you want to destroy, or you can put an area in front of the wall and have it set to destroy the wall when the hammer enters the area.

Both solutions have their benefits, but the first solution is more realistic.



RE: Force to trigger function. - AnthonyTrix - 04-15-2012

Thanks for the quick replies.

I will try both now Smile



RE: Force to trigger function. - DRedshot - 04-15-2012

You place two areas a certain distance from one another.
Place the first area a few inches away from the wall, and put the second on the wall.

Measure the distance between these areas, and declare it in your script as a constant, ie:
float Distance = 0.25f;

Now when the hammer passes through the first area, start a timer, and when it passes through the second timer, call "GetTimerTimeLeft" and use this value to work out the time taken for the collision.

Now divide the Distance by this number to calculate the speed, and have an if statement to check if the speed is larger than a certain value! Smile


Edit: already answered Tongue



RE: Force to trigger function. - AnthonyTrix - 04-15-2012

Thanks it worked when I used the way Acies and Homicide suggested (Model editor)



RE: Force to trigger function. - Damascus - 04-16-2012

(04-15-2012, 05:29 PM)DRedshot Wrote: You place two areas a certain distance from one another.
Place the first area a few inches away from the wall, and put the second on the wall.

Measure the distance between these areas, and declare it in your script as a constant, ie:
float Distance = 0.25f;

Now when the hammer passes through the first area, start a timer, and when it passes through the second timer, call "GetTimerTimeLeft" and use this value to work out the time taken for the collision.

Now divide the Distance by this number to calculate the speed, and have an if statement to check if the speed is larger than a certain value! Smile


Edit: already answered Tongue
Could I get some more info on this method? I'd like to use this method to break down a door with any of several large rocks laying around. I don't know how to declare constants, start running timers and calculating speed...

This is how I'm planning to start the callbacks (given that there are ten large rocks scattered about the level):

void OnStart
{
for(int i=1;i<=10;i++)

{
AddEntityCollideCallback("rock_debris_01_"+i, "ImpactArea1", "Impact1", false, 1);
}
for(int i=1;i<=10;i++)

{
AddEntityCollideCallback("rock_debris_01_"+i, "ImpactArea2", "Impact2", false, 1);
}
}



RE: Force to trigger function. - zombiehacker595 - 04-16-2012

(04-16-2012, 12:41 AM)Damascus Wrote:
(04-15-2012, 05:29 PM)DRedshot Wrote: You place two areas a certain distance from one another.
Place the first area a few inches away from the wall, and put the second on the wall.

Measure the distance between these areas, and declare it in your script as a constant, ie:
float Distance = 0.25f;

Now when the hammer passes through the first area, start a timer, and when it passes through the second timer, call "GetTimerTimeLeft" and use this value to work out the time taken for the collision.

Now divide the Distance by this number to calculate the speed, and have an if statement to check if the speed is larger than a certain value! Smile


Edit: already answered Tongue
Could I get some more info on this method? I'd like to use this method to break down a door with any of several large rocks laying around. I don't know how to declare constants, start running timers and calculating speed...

This is how I'm planning to start the callbacks (given that there are ten large rocks scattered about the level):

void OnStart
{
for(int i=1;i<=10;i++)

{
AddEntityCollideCallback("rock_debris_01_"+i, "ImpactArea1", "Impact1", false, 1);
}
for(int i=1;i<=10;i++)

{
AddEntityCollideCallback("rock_debris_01_"+i, "ImpactArea2", "Impact2", false, 1);
}
}


here is a much easier way of doing it

{

AddEntityCollideCallback("ScriptArea_1", "sledge_1", "DestroyDoor", true, 1);

}

void DestroyDoor(string &in asParent, string &in asChild, int alState)


{
SetEntityActive("cellar_wood01_2", false);
SetEntityActive("cellar_wood01_broken_1", true);
PlaySoundAtEntity("", "break_wood.snt", "ScriptArea_1", 0, false);
}

Place a script area at the door then sledge_1 can be changed to the rocks name, place two doors one working one broken when the rock or whatever youre using collides with the area the door will turn into a broken door with the sound as added effect much more simple and easy