OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ahmed117 on 01 Feb 2012, 09:43:35

Title: How to disable a Unit's target ability?
Post by: ahmed117 on 01 Feb 2012, 09:43:35
Hello Men,
             I have a very weird problem in making a cutscene, the problem is I wanna make my unit to sit on a chair straight, but it watches a man or something, although I have the azimut according to the chair, but still it is not sitting straight on that chair, check out the pic. I want to disable the unit's targeting ability, so that it can sit straight, please tell me if there is any command or any solution, for this...

I would be very thankful for any possible help.

Ahmed117 (A.rogers)
Title: Re: How to disable a Unit's target ability?
Post by: Doktor Headshot on 01 Feb 2012, 09:58:49
Hi pal, it is very simple thing to do but, this time, I would like to invite you to have a peek at COMREF (http://www.ofpec.com/COMREF/) for "disableAI" and "stop" commands ;)
Title: Re: How to disable a Unit's target ability?
Post by: Gruntage on 01 Feb 2012, 10:04:30
Although what Doktor said is true (the COMREF and the search feature are your best friends  :D) I will tell you that the way to disable a unit's targeting ability is through the use of:

Code: [Select]
unitname disableAI "autotarget"
You could also do this:

Code: [Select]
unitname disableAI "Move"
Both of these commands should work fine  :)

Next time though Ahmed, try using the search feature or the COMREF

Hope this helps

Gruntage
Title: Re: How to disable a Unit's target ability?
Post by: ahmed117 on 01 Feb 2012, 15:29:16
Roger That, Thank you very much by the way.
Title: Re: How to disable a Unit's target ability?
Post by: Raptorsaurus on 24 Mar 2012, 23:13:34
Ahmed,

Both of the above replies will work, but there is a disadvantage also. Once an AI ability is disabled it cannot be re-enabled without killing and resurrecting the unit (unit setDamage 1; unit setDamage 0). Killing and resurrecting the unit will then prevent that unit from ever being targeted by another AI unless you first set him to captive before killing him
Code: [Select]
unit setCaptive true
~ .1
;delay needed to let the game engine have time to acknowledge the unit is captive
unit setDamage 1
unit setDamage 0
unit setCaptive false
Another way to make him not look at other units is to set his behavior to careless and command him to look at the position in front of him
Code: [Select]
unit setBehaviour "careless"
unit doWatch [(getPos unit select 0) + (100 * sin (getDir unit), (getPos unit select 1) + (100 * sin (getDir unit), 0]
To undo him from watching this position and make him behave properly toward enemies you would command him to watch nothing and set his behavior to safe or aware.
Code: [Select]
unit setBehaviour "safe"
unit doWatch objNull