Frictional Games Forum (read-only)
[SCRIPT] Get entity speed - 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] Get entity speed (/thread-20217.html)

Pages: 1 2


Get entity speed - FlawlessHappiness - 02-06-2013

Hi.
I would really like to know how to get the speed of an object, held by the player.
I read a thread where Palistov said it wasn't possible, but it has been proven wrong, because I played a CS (Which I of course has forgotten the name of), where you had to break a door with a rock.
If you didn't hit hard enough, a message would say, "It needs greater force".

I'm trying to achieve the same thing, and i remember looking at the script when i had the CS, because i was fascinated by that script.

It was pretty advanced, and something with dividing time and something else, to get the speed. You know, pure math.


Either way if you could help me remember the story name, i can tell you what i remember of the story.


A man (The player) and a woman has come to a castle to look at archeology. There is some trembling. The woman takes the lantern and explores the building while the man rests. He wakes up by another trembling through the castle. He starts exploring the different rooms in the main hall, where he fx. has to break a door with a rock. Later on he finds the lady burried in rocks, with only her hand sticking out. Here he obtains the lantern.

That is how much i remember. Does any of you know it? Or know the script?

I hope you do! Smile


RE: Get entity speed - NaxEla - 02-06-2013

That was from The Great Work. Try contacting Damascus. Maybe he can help you?


RE: Get entity speed - FlawlessHappiness - 02-06-2013

I'll see! Thank you very much!


RE: Get entity speed - Adny - 02-06-2013

Paul's right, you cannot check an entities speed in a literal sense, but you can gimmick your way around it. You set up 2 areas to collide with the thrown object. When colliding with the first area (closest to the player), start a timer; when the object collides with the 2nd area (destination), use an if/else statement to check the total time that has elapsed, and whether or not it should be faster.

If it was fast enough (/the time was short enough), then you could trigger the script. If not, you could have the object stop/reset the timer when you next interact with it.

Idk, something like that. Good luck.


RE: Get entity speed - FlawlessHappiness - 02-06-2013

Thank you.

I was more looking for something where you hold the object, and then hit it on the door...

Well, if it's like your described it, then it doesn't sound like any problem at all Wink

Thank you guys!


RE: Get entity speed - Apjjm - 02-06-2013

The only way to, in a general sense, track an object's speed is to track the position of the object at a set interval. Position tracking of objects is a tricky thing - and there are multiple ways to go about it:

  1. Octtree search - This involves having an object hidden off the map to which you attach special block-box entities. You then determine which of the boxes the tracked object is in and subdivide them. You repeatedly do this until you reach the boxes of a small enough resolution, where you can average the coordinates to obtain a reasonable COM for the object. This search has to be done each time you poll the position, and AddAttachedPropToProp is very slow.
  2. Script-area grid - This is like the above approach except you generate (automatically) a huge array of script areas and just add a bunch of collision callbacks. This makes the map editor lag and isn't suitable for large maps.
  3. Trilateration - You need 4 objects placed outside the map. You then attach a bunch of spheres of different radii which let you poll the distance to each of the objects outside the map. Given that you know the distances from your object to the external object, and you know the positions of these objects you can implement trilateration to calculate the position. The downside here is that the maths is tricky!

When you have the position of the object, you can store it and calculate the change in position to get the speed. However, there is a simpler method for the door problem: you can always just set up the toughness & health values on the entities to bypass the whole speed check and let the game handle breaking the door.


RE: Get entity speed - FlawlessHappiness - 02-07-2013

Ah..

I got a little off, when you came to the script about stuff outside the map...
I'll see what they did in The Great Work, i think the timer-thing from AndyRocking is enough Wink


What i want to do is to have the pipe from the Cistern Entrance that breaks, to block a hole in the wall, and you have to smash it with a rock...
I'll figure it out.

Really thank you for the help guys!


RE: Get entity speed - Your Computer - 02-07-2013

You don't need a script for one object to break another object. If you remember, entities allow you to specify the force required to be applied to the object in order for them to break. It should be no different than breaking glass or plates with a crate. You should be able to have some kind of collision detection mechanism (e.g. with a sticky area that denies all objects) that checks the health of the object to be broken and if the health is not at a broken level, display the message.


RE: Get entity speed - FlawlessHappiness - 02-07-2013

How would the sticky area call any function, if it denies all objects?


RE: Get entity speed - Your Computer - 02-07-2013

(02-07-2013, 07:53 AM)BeeKayK Wrote: How would the sticky area call any function, if it denies all objects?

By "deny" i meant preventing objects from getting stuck by passing false to SetAllowStickyAreaAttachment.