OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: RolsRois on 07 May 2009, 22:14:01

Title: I have just a tiny problem with setcaptive command...
Post by: RolsRois on 07 May 2009, 22:14:01
well in my mission the player is suppose to be captive until he holds a weapon, so i wish that if he holds a gun, handgun, or a grenade, he wont be a captive anymore.

anyone?
Title: Re: I have just a tiny problem with setcaptive command...
Post by: savedbygrace on 08 May 2009, 00:40:13
Hmmm, maybe I am overstepping my bounds a bit, but perhaps the hasweapon command could help you?
Create a Trigger and in it's COndition field put this...
Code: [Select]
(player hasweapon "m16")Then in the OnActivation field put this...
Code: [Select]
player setcaptive false
Of course the player will have to be captive first.
Weapon models can be found in the COMREF here (http://ofpec.com/COMREF/index.php?action=read&id=67)


To check for multiple weapons, you will have to add them to the condition field by using the OR / || command between checks for example...
Code: [Select]
(player hasweapon "m16") OR (player hasweapon "pipebomb") || (player hasweapon "uzi")
and so when the player picks up any of the listed models, he instantly becomes a wanted man by all enemies present

It's that simple.
Title: Re: I have just a tiny problem with setcaptive command...
Post by: THobson on 08 May 2009, 09:50:09
Or maybe something along the lines of :
Code: [Select]
@ weapons player != []
player setCaptive false

Just a thought.  Not tested it.  The instruction:
Code: [Select]
weapons playerReturns an array of the weapons the player is carrying so as soon as the array is not empty the player should stop being a captive.

Edit:
The above assumes this change is done in a script.  If you want to use a trigger the Condition field should be:
weapons player != []
and the Activation field should be:
player setCaptive false
Title: Re: I have just a tiny problem with setcaptive command...
Post by: dr. seltsam on 08 May 2009, 13:58:28
OFP cannot compare arrays by default...

You can write a function for it, or...
... let's say your player has the name p1... then we use this script:

Code: [Select]
@ count weapons p1 > 0
p1 setCaptive false
exit

 :)
Title: Re: I have just a tiny problem with setcaptive command...
Post by: THobson on 08 May 2009, 15:24:03
That just shows how rusty I am  :D

The count method should work well.  Good catch.   :good:

By the way you can refer to the player as player without giving that unit a name.

Just for completeness in case RolsRols wants to use a trigger:
Condition field should be:  count weapons player > 0
Activation field should be: player setCaptive false