Jump to content
Sign in to follow this  
egwal

Forcing a player crawl

Recommended Posts

So Im making this mp mission where I want a certain player to be injured on the legs so that he cant run/walk and is forced to crawl. Like when you get shot in the legs. The unit will be human controlled.

How to do this?

Share this post


Link to post
Share on other sites

Easy, hit him in the legs.

This will damage his legs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[player, 0.2, 180, 1, 200, "BulletSniperW", 0.1, true]exec"hitunit.sqs"

Try this if you want to vaporize him tounge2.gif :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[player, 10, 0, 180, 200, "LaserGuidedBomb", 3, false]exec"hitunit.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; hitunit.sqs by Mandoble

; Shoots a projectile against a unit at the indicated speed and height.

; Will keep shooting until target gets damaged

;

; Arguments:

; target

; altitude of the projectile

; angle relative to target direction from where the projectiles will come

; distance from target from where the projectiles will be fired

; speed of the projectile in m/s

; type of projectile ("BulletSingleW", "BulletSniperW", "Bullet30E", "Bullet4x23", "Bullet7_6W", etc.)

; delay between shots in seconds

; if the projectile should be deleted after the indicated delay

; Example:

; Player will be hit in the legs

; [player, 0.2, 180, 1, 200, "BulletSniperW", 0.1, true]exec"hitunit.sqs"

;

_target = _this select 0

_alt = _this select 1

_ang = _this select 2

_dist = _This select 3

_spd = _this select 4

_type = _this select 5

_delay = _this select 6

_delete = _this select 7

#shoot

_dir = _ang + getDir _target

_pos = [(getPos _target select 0)+sin(_dir)*_dist, (getPos _target select 1)+cos(_dir)*_dist, _alt]

_vel = [sin(_dir+180)*_spd,cos(_dir+180)*_spd,0]

_bullet = _type camCreate _pos

_bullet setDir (_ang+180)

_bullet setVelocity _vel

~_delay

?_delete: deleteVehicle _bullet

? damage _target == 0: goto "shoot"

exit

Share this post


Link to post
Share on other sites

You can force the player to crawl by adding damage points when he tries to stand up. But how can you check a crawling unit?

You can combine these three usefull commands...

- The canstand command

- A "dammaged" eventhandler to check the players injuries,

- speed command

So when

- the player is hit in the legs (the eventhandler "dammaged") and...

- He can't stand anymore (canstand command) and...

- his speed is lower then 8.2km/h (running speed AFAIK) and...

- he's not in a vehicle (the vehicle command)...

He must be crawling!

Ok, In scripting language...It's been a while I did this, but hell I give it a try...

Not tested and written out of the hand, here we go... whistle.gif

Run the script in the init of the player :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

this AddEventHandler ["dammaged", {_this exec "checkhit.sqs"}]

this is the EH script "checkhit.sqs"...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_who = _this select 0

_where = _this select 1

? _where == "nohy" || !canstand _who: [_who] exec "adddam.sqs";player removeeventhandler ["dammaged",0]

exit

A second script to check the player's speed and add damage points when he tries to stand up.

adddam.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_you = _this select 0

_Maxspd = 8.2

#checkloop

?!alive _you : exit

?((_you == vehicle you) && (speed _you > _maxspd)): _You setdammage (getdammage _you + 0.3)

~2

goto "checkloop"

*Edit* : sorry I misunderstood your question...I'm too tired /old for this crazy_o.gif

Use Mandoble's method, looks like a nice script, does it work on a running unit as well?

Share this post


Link to post
Share on other sites

Yes, it works on running or walking units/vehicles as long as you select 0 or 180 as firing angle relative to unit's direction. With any other angle you add a miss probability, being maximum at 90 and 270 degrees relative to the moving unit. Of course, if the range is very short, 1m for example, that missing probability would be minimal whatever the angle you choose.

Share this post


Link to post
Share on other sites

Just throw him into the ground so he breaks his legs. Player setpos [getpos player select 0,getpos player select 1,0.1];player setvelocity [0,0,-10] or something. Dunno the exact velocity needed to break his legs without killing him. Far simpler than creating bullets with scripts anyhow.

Share this post


Link to post
Share on other sites

Is he injured from the begining? if he is you can just place the unit with minimal health

Share this post


Link to post
Share on other sites
Is he injured from the begining? if he is you can just place the unit with minimal health

I tried experimenting this, but I was unable to make the player have his legs injured.

Share this post


Link to post
Share on other sites

just use "this setdammage 0.91". You need to have the number set higher then .9 for the legs to be damaged.

Share this post


Link to post
Share on other sites
Easy, hit him in the legs.

This will damage his legs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[player, 0.2, 180, 1, 200, "BulletSniperW", 0.1, true]exec"hitunit.sqs"

Try this if you want to vaporize him tounge2.gif :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[player, 10, 0, 180, 200, "LaserGuidedBomb", 3, false]exec"hitunit.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; hitunit.sqs by Mandoble

; Shoots a projectile against a unit at the indicated speed and height.

; Will keep shooting until target gets damaged

;

; Arguments:

; target

; altitude of the projectile

; angle relative to target direction from where the projectiles will come

; distance from target from where the projectiles will be fired

; speed of the projectile in m/s

; type of projectile ("BulletSingleW", "BulletSniperW", "Bullet30E", "Bullet4x23", "Bullet7_6W", etc.)

; delay between shots in seconds

; if the projectile should be deleted after the indicated delay

; Example:

; Player will be hit in the legs

; [player, 0.2, 180, 1, 200, "BulletSniperW", 0.1, true]exec"hitunit.sqs"

;

_target = _this select 0

_alt = _this select 1

_ang = _this select 2

_dist = _This select 3

_spd = _this select 4

_type = _this select 5

_delay = _this select 6

_delete = _this select 7

#shoot

_dir = _ang + getDir _target

_pos = [(getPos _target select 0)+sin(_dir)*_dist, (getPos _target select 1)+cos(_dir)*_dist, _alt]

_vel = [sin(_dir+180)*_spd,cos(_dir+180)*_spd,0]

_bullet = _type camCreate _pos

_bullet setDir (_ang+180)

_bullet setVelocity _vel

~_delay

?_delete: deleteVehicle _bullet

? damage _target == 0: goto "shoot"

exit

This script seems to work, but the victim has to move for the script to start, even though i put the exec into init.sqs. And the unit starts inside a car so its kinda sketchy: he gets out= nothing, he moves a bit=bam and argh. Whats the bullet name for the silenced HK?

Share this post


Link to post
Share on other sites

EgWal, the victim does not need to walk. The problem is the following, bullets are being fired since the script starts, but bullets are not spread from their initial position, so, depending on the placement of the unit legs, there is a chance to fail the shots. If you walk, and moving the legs, the chance to hit the unit increases a lot.

Try executing the script with 90 degrees instead of 180:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[player, 0.2, 90, 1, 200, "BulletSniperW", 0.1, true]exec"hitunit.sqs"

To prevent the script to start firing bullets with the soldier inside a vehicle, add the following line just above '#shoot':

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;Wait till _target is outside any vehicle

@vehicle _target == _target

EDIT:

If he gets out of the vehicle, may be the bullets keep hitting the vehicle instead the unit. The bullets, as you execute the script, are being fired from a position 2 meters away of the unit and from his back (180 degrees). You may try also to decrease the range to 1m or 0.5m or even less.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×