Home   Help Search Login Register  

Author Topic: Limiting a players speed  (Read 2282 times)

0 Members and 1 Guest are viewing this topic.

Offline burga

  • Members
  • *
Limiting a players speed
« on: 02 Apr 2010, 18:57:42 »
I've looked everywhere, and still haven't found a way to limit the speed of a human player.

I'm making a mission whereby the player speed needs to be limited while he is captive, but the speed limit needs to be removed once he has escaped captivity.

How it's supposed to work:
Captivity is maintained by be within a certain range of blufor players, and is in their group - to allow him to enter vehicles, but i want to limit that he cannot drive. Once he is a certain distance away from blufor he is no longer captive and returns to opfor group and can once more move faster than a walk, and drive a vehicle.

Another aspect I want to include is whereby neither side wins if the player dies while captive(in blufor group), blufor wins once they and the captive have reached a certain location, or if the player dies once escaping captivity. Opfor wins by eliminating blufor, or simply rescuing the player and taking him to a different location for a win condition.

I know this is all done via triggers and scripting, I know how the scripting and triggers for captive and not captive works, I just need to limit his speed now, and the usable vehicle seats.

Any chance of some help with this coding?

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Limiting a players speed
« Reply #1 on: 02 Apr 2010, 20:15:54 »
Constant use of setVelocity might work:
http://community.bistudio.com/wiki/setVelocity

But I think you won't get happy with the effort and results.  :(

Offline burga

  • Members
  • *
Re: Limiting a players speed
« Reply #2 on: 03 Apr 2010, 10:35:24 »
Yeah I looked at that, and doesn't quite give the desired result. The player is human controlled and all I want to do is force move no faster than a walk.

Offline Loyalguard

  • Former Staff
  • ****
Re: Limiting a players speed
« Reply #3 on: 03 Apr 2010, 17:32:42 »
Here's a possible solution for the vehicle part,  This code checks to see if the player is in a vehicle and the driver of the vehicle,  If he is, it forces him out (untested)

Code: [Select]
if (((vehicle player) != player) and (driver (vehicle player)) == player)) then
{
player action ["getOut",(vehicle player)]
};

For the speed issue, is this to simulate he has leg irons or something like that?  If so, maybe you can use the speed command to monitor his speed and if he goes to fast (about running speed) then play a falling down animation on him to simulate tripping.

Good luck!

Offline burga

  • Members
  • *
Re: Limiting a players speed
« Reply #4 on: 04 Apr 2010, 18:53:01 »
That could work, now I have to figure out how to implement the tripping part. thanx  :D . The mission is almost done, only obstacle right now is the captive's movement speed.

I suppose one way is to cripple his legs - too many mafia movies. then all he can do is crawl around.

Offline Mostly

  • Members
  • *
Re: Limiting a players speed
« Reply #5 on: 13 Apr 2010, 21:52:21 »
Just wondering if you've managed to solve the limit players speed problem? I'm trying to achieve something similar with a script that lets you carry a wounded soldier but as a result slows the player down. Haven't had any luck yet though.
They mostly come out at night. Mostly!

Offline Loyalguard

  • Former Staff
  • ****
Re: Limiting a players speed
« Reply #6 on: 13 Apr 2010, 23:02:32 »
After during some more research on this one, limitSpeed command might work.  Here is a link to a post on the BIF that our fine staff member JamesFI posted on how to get it to work (you need to loop it).  It was meant for a helicopter but should be easily adapted to a person unit:

http://forums.bistudio.com/showpost.php?p=1538255&postcount=2

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Limiting a players speed
« Reply #7 on: 13 Apr 2010, 23:19:29 »
I very much doubt that'll work on a player unit, but I'm prepared to be proven wrong :D

Offline Loyalguard

  • Former Staff
  • ****
Re: Limiting a players speed
« Reply #8 on: 14 Apr 2010, 01:29:00 »
Well, I did say adapted ;)  ...I will fire it up tonight and see if I can make it work.

Update 1:
Ok, I failed...I think the problem is that player speed is controlled by the animation so any attempts to limitSpeed are ignored...but I might have another solution in the works...I need another day or so.

Update 2:
I did have some limited success with "limiting speed" by forcing different animations on the player.  I did this mosly using displayAddEventHandler and inputAction in a loop monitoring key presses.  So that if a player pressed W,A,S,D, it would force the slow walk animation for that direction using playMove or switchMove, but it is hard to get the timing right of when to transition out of the forced move when the player stops pressing the button.  So, I think using a "anim" event handler to prompt the force move would be best but it is going to be more complicated.  I am willing to help work on it but need to know how much real interest there is.
« Last Edit: 14 Apr 2010, 18:47:09 by Loyalguard »

Offline Mostly

  • Members
  • *
Re: Limiting a players speed
« Reply #9 on: 18 Apr 2010, 11:54:37 »
Thanks for your efforts Loyalguard. I think there would be some real interest in it. It would have loads of applications in the game, from carrying a wounded soldier to being a POW yourself. Would definitely add to the realism in some missions.

Sounds like your onto something with the monitoring key presses and using animations. Good thinking. :good:
They mostly come out at night. Mostly!

Offline burga

  • Members
  • *
Re: Limiting a players speed
« Reply #10 on: 19 Apr 2010, 23:02:48 »
Awesome, I was reading up about how they were adjusting the speeds of zombies in the zombie mod by using anims, and I honestly don't know how to do it.

So if you could work something out that would be awesome, that is the only obstacle I have in my mission currently - simulating limited movement speed of a POW.

Offline Loyalguard

  • Former Staff
  • ****
Re: Limiting a players speed
« Reply #11 on: 19 Apr 2010, 23:38:06 »
I will do some more work on it over the next couple of days with a couple of techniques and report back.