Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Limping Player
AKZEL Offline
Junior Member

Posts: 3
Threads: 3
Joined: Jan 2013
Reputation: 0
#1
Limping Player

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.

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
(This post was last modified: 01-15-2013, 05:00 PM by AKZEL.)
01-15-2013, 04:59 PM
Website Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#2
RE: Limping Player

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: (Select All)
// 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); 
(This post was last modified: 01-15-2013, 05:22 PM by TheGreatCthulhu.)
01-15-2013, 05:19 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Limping Player

Also FadePlayerRollTo can be used

Trying is the first step to success.
01-15-2013, 05:27 PM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#4
RE: Limping Player

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);

[Image: Tv0YgQb.gif]
Image by BandyGrass
(This post was last modified: 01-15-2013, 05:29 PM by Kreekakon.)
01-15-2013, 05:28 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#5
RE: Limping Player

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).
01-15-2013, 08:31 PM
Find
AKZEL Offline
Junior Member

Posts: 3
Threads: 3
Joined: Jan 2013
Reputation: 0
#6
RE: Limping Player

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!
(This post was last modified: 01-16-2013, 12:39 AM by AKZEL.)
01-16-2013, 12:38 AM
Website Find




Users browsing this thread: 2 Guest(s)