Jump to content
Sign in to follow this  
Lt_Damage

Disarm and capture script required

Recommended Posts

I need a script that allows a MP player to sneak up behind another player and an AddAction adds an additional action "disarm & capture".

I would then like the person disarmed and captured.

I'm yet to define "captured" but i'm thinking SetPos to a POW camp. (Designated marker e.g GetMarkerPos "powcamp")

I would also like the possiblity of capture failing, so like a 70% chance of disarming and capturing.

Lastly, I want the option only to be available (seen in menu) when the player is directly behind the target. (Less than 1 away)

I cannot use KnowsAbout command as it does not work for human players, such a pitty as it makes it a hell of a lot easier. (I tested with AI).

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Lt_Damage @ Jan. 22 2003,22:55)</td></tr><tr><td id="QUOTE">I need a script that allows a MP player to sneak up behind another player and an AddAction adds an additional action "disarm & capture".

I would then like the person disarmed and captured.

I'm yet to define "captured" but i'm thinking SetPos to a POW camp. (Designated marker e.g GetMarkerPos "powcamp")

I would also like the possiblity of capture failing, so like a 70% chance of disarming and capturing.

Lastly, I want the option only to be available (seen in menu) when the player is directly behind the target. (Less than 1 away)

I cannot use KnowsAbout command as it does not work for human players, such a pitty as it makes it a hell of a lot easier. (I tested with AI).<span id='postcolor'>

To give a "70% chance" use:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (random 10 < 7) : {goto "capture"} else {goto "fail"}

#capture

...lots of code

#fail

...some message saying the capture failed

exit

<span id='postcolor'>

If you are willing to allow the capture command to be displayed at all times, the script should be something like this:

1. Find the victim closest to the player with the nearestobject command:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_guy = nearestobject [player, "whatever the obj type is"]<span id='postcolor'>

2. Check if this is someone that could be captured, e.g. not a tank:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _guy != "soldiertype" OR _guy != "soldiertype2" etc... goto "fail"<span id='postcolor'>

I don't know what the soldier object names are, but they exist somewhere. biggrin.gif I assume they are the names used in the mission.sqm, but maybe not.

3. Check if the victim is the enemy or the same side as the player with the side command:

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

? side _guy = side player : goto "sameteam"

#sameteam

...some message saying the guy is on the same team.

<span id='postcolor'>

4. Check the distance between the two using the distance command to make sure the player is in range:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">? player distance _guy > 1 : goto "fail"<span id='postcolor'>

This way should be much better for multiplayer because you won't need to have a script running the whole time for each client. If not, I guess you could take steps 1-4 and loop them in one script, to check if the action should be added, then have another script activated by the action which just has the setpos stuff and the removeaction command.

Share this post


Link to post
Share on other sites

It's pre-alpha version of script smile.gif. It shoud work only for 2 soldiers now. wguy-attacker and eguy-target.

master script :

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

;-attacker

_atck=wguy

?!local _atck:exit

;-target

_trgt=eguy

;-distance

_dist=1

_act=false

goto "check"

#remove

?_act:_atck removeAction _aID;act=false

#check

~0.1

?(_atck distance _trgt)>_dist:goto "remove"

?!_act:_aID=_atck addAction ["Capture","capture.sqs"];_act=true

goto "check"

<span id='postcolor'>

I doubt that distance 1 meter is enough when you are trying to capture crouching soldier.

capture.sqs :

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

_atck=wguy

_trgt=eguy

?(random 100)>70:goto "failure"

;-1/2 of angle

_angl=15

;-must be from back :

_ad=getDir _atck

_td=getDir _trgt

?abs(_ad-_td)>_angl:goto "failure"

_ap=position _atck

_ax=_ap select 0

_ay=_ap select 1

_tp=position _trgt

_tx=_tp select 0

_ty=_tp select 1

?_td<=180 and _ax>_tx:goto "failure"

?_td>180 and _ax<=_tx:goto "failure"

?(_td>=270 or _td<=90) and _ay>_ty:goto "failure"

?_td<270 and _td>90 and _ay<=_ty:goto "failure"

;-succes

removeAllWeapons _trgt

_trgt setPos getMarkerPos "powcamp"

exit

#failure

;- there can be something like target's self-defence (penalty for attacker):

;- _atck setDamage (0.1+damage _atck)

exit

<span id='postcolor'>

Tweak "1/2 of angle" value.

I have almost no oportunity to test MP scripts. You must test it yourself. I don't know if removeAllWeapons and setPos works even for nonlocal soldier.

If it works let me know and I can try to make more universal version.

Share this post


Link to post
Share on other sites

Only problem is, that will also work when the captive is behind the attacker. tounge.gif At least that's how I see it. You actually have to do cos and sin calculation to check who is behind whom.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (bn880 @ Jan. 23 2003,20: 02)</td></tr><tr><td id="QUOTE">Only problem is, that will also work when the captive is behind the attacker.  tounge.gif   At least that's how I see it.  You actually have to do cos and sin calculation to check who is behind whom.<span id='postcolor'>

Oops. That it's why it was so easy. tounge.gif  I'll try to solve this.

Edit:

Solved, I hope  tounge.gif . I don't like sinus-cosine orgy crazy.gifwink.gif

Share this post


Link to post
Share on other sites

Bloody hell, glad I did not try and do this myself..

Thanks for your help, I'm looking forward to see what you come up with.

smile.gif

Share this post


Link to post
Share on other sites

?_td<=180 and _ax>_dx:goto "failure"

?_td>180 and _ax<=_dx:goto "failure"

?(_td>=270 or _td<=90) and _ay>_ty:goto "failure"

?_td<270 and _td>90 and _ay<=_ty:goto "failure"

confused.gif

Share this post


Link to post
Share on other sites

Ok I just tried to test it, nothing happened.. his weapon didn't disappear, i tried several times, not sure where its failing as there is no error. :/

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Lt_Damage @ Jan. 24 2003,05:50)</td></tr><tr><td id="QUOTE">Ok I just tried to test it, nothing happened.. his weapon didn't disappear, i tried several times, not sure where its failing as there is no error. :/<span id='postcolor'>

This can be problem with nonlocal soldier  confused.gif . I tested it in SP and it works*.

Try to execute this script in MP mission with eguy and eguy :

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

?!local wguy:exit

hint "remove weapons"

removeallweapons eguy

~5

hint "move"

eguy setpos position wguy

~5

hint "death"

eguy setdamage 1

exit

<span id='postcolor'>

and let me know if it works or not.

*I made repaired another little mistake in master script.

edit : solved - There is problem with removeAction  confused.gif. It doesn't work that way as it shoud work. Sometimes Capture action remains in action menu and when you are near target again, another Capture action appears.  confused.gif

Next problem with

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

?abs(_ad-_td)>_angl:goto "failure"

<span id='postcolor'>

It doesn't work with direction range near 0.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (bn880 @ Jan. 24 2003,01:28)</td></tr><tr><td id="QUOTE">?_td<=180 and _ax>_dx:goto "failure"

?_td>180 and _ax<=_dx:goto "failure"

 confused.gif<span id='postcolor'>

Thanks smile.gif . Next mistake in capture script repaired.

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  

×