Frictional Games Forum (read-only)
Limping Player - 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: Limping Player (/thread-19944.html)



Limping Player - AKZEL - 01-15-2013

So I'm trying to imitate a limp player in the beginning of my CS.
(will get healthy later, don't worry Big Grin)

The problem is that the bodyforce I'm applying is always negative Z (backward force), no matter if the player is walking forwards, backwards or strafing.

Code:
void OnStart()

{
    SetPlayerRunSpeedMul(0);    //Damaged player can't run
    SetPlayerMoveSpeedMul(0.8f);    //Damaged player moves slow
    AddTimer("T1", 0.1f, "BodyForce");

//===========LIMP=========================//
void BodyForce(string &in asTimer)
{
    
if ( GetPlayerSpeed() > 1 ){
    AddPlayerBodyForce(0, 0, -10000, true); //Pushes player backwards, resulting in a slight deceleration.
    AddDebugMessage("LIMP!", false);
    AddTimer("T3", 1.0f, "BodyForce");
}
else{
    AddTimer("T2", 0.1f, "BodyForce");
    AddDebugMessage("NO LIMP!", false);
}
}

Is there a way to get information about which direction the player is moving, or has someone else managed to script this effect without going full conversion..?

//AKZEL


RE: Limping Player - TheGreatCthulhu - 01-15-2013

I don't think there's a function which will give you the player's velocity vector, but, you can probably simulate limping without using AddPlayerBodyForce() - you could use these (together with timers) instead:
PHP Code:
// use this to modify the height of the "eyes" - some trial and error will be required
// (simulates head bobbing caused by dragging a leg)
void MovePlayerHeadPos(float afXfloat afYfloat afZfloat afSpeedfloat afSlowDownDist);

//use these to make the player slow (1.0f = 100%, 0.5f = 50%, 2.0f = 200%, etc.):
void SetPlayerMoveSpeedMul(float afMul);
void SetPlayerRunSpeedMul(float afMul); 



RE: Limping Player - FlawlessHappiness - 01-15-2013

Also FadePlayerRollTo can be used


RE: Limping Player - Kreekakon - 01-15-2013

If you want to simulate limping by using periodical deceleration, you can use this to alter the speed of the player without pushing him (The default speed is 1):

SetPlayerMoveSpeedMul(float afMul);


RE: Limping Player - TheGreatCthulhu - 01-15-2013

You can also use that function that gets the speed of the player to modulate the intensity of the head bobbing (you don't want it going up and down if you're standing still).


RE: Limping Player - AKZEL - 01-16-2013

Hey, thanks for the replies!

Yeah I managed to get a decent effect using only two SetPlayerSpeedMul and a couple of timers.
(switching between two values if the player was moving).
Adding a slight FadePlayerRollTo also made it more authentic, so thanks for that tip!

I initially thought that it would create a rather jerky effect doing like this, and that I would have to
use some kind of for-loop that would add or subtract the value gradually (like +/-0.1speedmul every 0.1sec or so). Stupid me for not trying the second-most easy method. (the PlayerBodyForce was just... um... dumb of me).

Thanks again from a happy noob!