Jump to content
Sign in to follow this  
hellfish6

Script idea

Recommended Posts

I haven't come across anything like this in my searches here or at OFPEC, so I thought I'd ask -

Is it possible to create a script where wounded enemy soldiers will drop their weapon(s) and become captives of the player's unit?

I was thinking about using this for when enemy soldiers get their legs shot out so that instead of fighting to the bitter end, they'd give up and hope for some medical attention from the people trying to kill them.

Anyone know how to get started on or, better yet, make this entire script?

Share this post


Link to post
Share on other sites
I haven't come across anything like this in my searches here or at OFPEC, so I thought I'd ask -

Is it possible to create a script where wounded enemy soldiers will drop their weapon(s) and become captives of the player's unit?

I was thinking about using this for when enemy soldiers get their legs shot out so that instead of fighting to the bitter end, they'd give up and hope for some medical attention from the people trying to kill them.

Anyone know how to get started on or, better yet, make this entire script?

Hmmm... I'm not sure of any eventhandler or command that detects if somebody's legs are hit, but it would be easy enough.

1. first, detect if the AI's legs have been hit

2. if the legs have been hit, there is a random chance they will surrender (50%)

3. if they surrender, setdammage them up to enough health so they can walk, make them drop their weapon, set them as captive, and play the "captured" animation.

If you could play the capurted animation while they are kneeled, I think that would be better.

Well, atleast thats how I'd do it, but I'm not sure if there is a way to detect if someone's legs have been hit. If BIS released more commands for it's scripting engine, implemented more things, &c, they would be gods (they already are, what am I talking about?).

edit: you could also make the script more advanced, such has friendlies coming to rescue their captured friends, and you getting points for capturing them instead of utterly destroying them. And maybe the commander of the enemy squad raising a white flag somehow? biggrin_o.gif

Share this post


Link to post
Share on other sites

In Asmodeus mission Chemical Warfare the enemys of the counterattack have the possibility to surrender. If they they do it they stop fighting, stand up and play the captured animation.

But I can't remember if they do it because they are wounded or because the cassaulties of there squad reached a certain number.

Share this post


Link to post
Share on other sites

Hi Hellfish6

As mentioned the surrender of troops needs to be a function of:

1 wounds

2 Wound positions

3 number of allies in an area say 200m

4 number of enemy in an area say 200m

5 composition (tanks v rifle armed soldiers) of allied forces in an area say 500m

6 composition (tanks v rifle armed soldiers) of enemy forces in an area say 500m

7 experience of the unit High = low probability no matter what

EDIT 8 As mentioned by Tactician how much ammo you have END EDIT

I would suggest that you need to balance the weights of those to get the right effect. Decide which is the most important and then work down from it with the others being proportions of it.

When your near completion let me know it would be useful for large missions like the CE missions.

Kind Regards Walker

Share this post


Link to post
Share on other sites

Relevant functions:

unit handsHit (returns true/false, dead returns true?)

unit canStand (returns true/false, dead returns false)

someAmmo unit (returns true/false, false if unit has no ammo, good reason to give up)

fleeing unit (returns true/false, true if unit is disengaging)

skill unit (returns 0-1)

rating unit (returns integer)

Rating is generally the "score" you see at the end of the mission, it applies to all soldiers. Goes up when you kill the enemy and down when you kill a friendly/civilian. Based on rank I think. Decent measure of experience.

Event handlers:

"hit" [victim,shooter,damageAmount]

"dammaged" [victim,partOfBody,damageAmount]

Parts of body for dammaged EH:

"hlava" - head

"ruce" - arms and body

"nohy" - legs

Share this post


Link to post
Share on other sites

Looks like you have just been volunteered to make the script Hellfish, I look forward to it!!

200th POST, YAY!! smile_o.gif  sad_o.gif  biggrin_o.gif  tounge_o.gif  wink_o.gif  rock.gif  wow_o.gif  mad_o.gif  crazy_o.gif  blues.gif  unclesam.gif  ghostface.gif

Share this post


Link to post
Share on other sites

Update:

I'm immensely proud of myself. I feel like Dr. Frankenstein in elementary school - I pieced together bits of some other scripts and added my part here and there to come up with a very basic set of scripts.

Basically, what I can do now is shoot an enemy soldier who has

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this] exec "capture.sqs";

in his init. Once that unit sustains X amount of damage (default 60%) he will surrender and the player can then move up and secure the prisoner, who will then join the player's group.

Some issues:

1. Currently the prisoners have "RemoveAllWeapons" as their command to disarm. Is there a function to make them drop their weapons instead?

2. Also, I haven't quite figured out how to determine if the prisoner is prone or not. I'm using the "lyingtoPutdownlying" and "FXStandSurDown" animations for when the unit gets hit and surrenders. That looks fine when the unit is shot while prone, but if you hit and wound somebody while they're standing up, it looks kind of odd. How do I run a check so that it looks right when the unit is shot standing up, animates dropping his weapon and then standing back up to put his hands behind his back?

Email me or PM me with your email addy if you wanna take a look at the scripts and the sample mission I have.

Edit: OK, I tried to make the skill level work, but when I used this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?skill _hostage >=0.75 : exit it prevented the script from working entirely. rock.gif

Share this post


Link to post
Share on other sites

Note that the ingame editor's skill slider ranges from 0.2 to 1, not from 0 to 1.

Starting ratings follow:

Private = 0

Corporal = 500

Sergeant = 1500

Lieutenant = 2500

Captain = 3500

Major = 5000

Colonel = 7500

Rating increase for killing an enemy:

Most soldiers = 200

Sniper, Blackop, Spetz = 500

Officer = 1000

For further reference:

Most cars/trucks/light vehicles = 200

T72 = 1000

Rating penalty for teamkilling:

Most soldiers = -1400

Sniper, Blackop, Spetz, Officer = -3500

Share this post


Link to post
Share on other sites

Hi all

From that it looks like the slider is either a diferent input eg a modifier or a percentage of Colonel

Aplying that to Helfishes problem try settings of 501 rather than 0.75 then test with a private and a corporal disarm both to test.

If this is the case you need to take that given value as an input and then take rank as another input. You then divide its rank value by what is given. If the number is below 1 by a significant factor your surrender script runs.

On another note I think running multiple instances of your script off units init field is not a good idea in a large battle it will result in a big CPU Hit and significant stuttering in game.

Better to use as Tactician sugested

Quote[/b] ]Event handlers:

"hit" [victim,shooter,damageAmount]

"dammaged" [victim,partOfBody,damageAmount]

I suggest if hit above n damageAmount apply your script to victim.

Kind Regards Walker

Share this post


Link to post
Share on other sites

//edit:

script first crashed ofp. got it fixed now

my script should do this:

it´s activated via a trigger that checks the dammagelevel of the suspect (>0.3)

*suspect has 5seconds time to try defending himself

*the suspect drops his weapon

*he surrenders

Quote[/b] ]_suspect = _this select 0

~5

_suspect setCaptive true

_suspect action ["DROP WEAPON", unit, 0, 0, (primaryweapon _suspect)]

~3

_suspect switchmove "fxstandsurdown"

goto "arrest"

#arrest

@leader deltas distance (_suspect) <2

_suspect switchmove "stand"

_suspect setunitpos "up"

[_suspect] join deltas

goto "end"

#lifecheck

@!alive (_suspect)

_suspect switchmove "fxstandsurdead"

goto "end"

#end

exit

if you are an experienced scripted -unlike me  tounge_o.gif - you´ll see that the script should check 2 conditions.

it does check if the leader is close to the suspect to arrest him.

but it doesn´t check if the suspect is dead...

could someone please give me a clue how to check both conditions?

Share this post


Link to post
Share on other sites

*bump*

can´t anybody help?

otherwise i wont be able to finish my "SOAR/ DELTA: Search and Capture" coop mission and you won´t be able to play it aswell sad_o.gif

Share this post


Link to post
Share on other sites

Do you mean something like this?

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

_suspect = _this select 0

~5

_suspect setCaptive true

_suspect action ["DROP WEAPON", unit, 0, 0, (primaryweapon _suspect)]

~3

_suspect switchmove "fxstandsurdown"

goto "arrest"

#arrest

@leader deltas distance (_suspect) <2

goto "lifecheck"

#next

_suspect switchmove "stand"

_suspect setunitpos "up"

[_suspect] join deltas

goto "end"

#lifecheck

?!alive (_suspect):_suspect switchmove "fxstandsurdead";goto "end"

goto "next"

#end

exit

Out of interest, what did you do to the script to make it crash OFP?

RED

Share this post


Link to post
Share on other sites

Right now I have a trigger for when all East forces are not present, Objective 1 is accomplished. The only problem is that when I have captured East soldiers, they are still considered to be on the "East" side. Anyone know of a scripting tidbit I could use to change them to "West" or "Resistance" once they are secured?

Share this post


Link to post
Share on other sites

How about you group them to a west or Res side?

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

The group can be an empty group.

RED

Share this post


Link to post
Share on other sites

I did that already. When a POW is secured, he automatically is disarmed and joins the player's group. He's still considered an "East" unit, though. crazy_o.gif

Share this post


Link to post
Share on other sites

Why not create some dummy units which are east units with side WEST, then setpos these units into the place of the captured soldiers.

RED

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  

×