OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ziarrek on 02 Aug 2007, 02:05:47

Title: Moving npcs
Post by: ziarrek on 02 Aug 2007, 02:05:47
Hi, I'm new here and I have a question: is there any way to prevent npcs from being pushed around by the player?
(for example a man is sitting on a chair and when I run into him, he moves, so that he is still sitting but with no chair under him).
Please help.
Title: Re: Moving npcs
Post by: Mr.Peanut on 02 Aug 2007, 02:32:42
The only way to deal with this is a looping script. I used one once to keep a unit sitting on the toilet...
Code: [Select]
_toiletOfficer = _this select 0
_posTO = getPos _toiletOfficer
#loop
_pos = GetPos _toiletOfficer
_xp = (GetPos _toiletOfficer) Select 0
_yp = (GetPos _toiletOfficer) Select 1
If(Alive _toiletOfficer And (_xp != _posTO Select 0 Or _yp != _posTO Select 1)) Then {_toiletOfficer SetPos _posTO}
~0.5
If(Alive _toiletOfficer) Then {Goto "loop"}
Exit

Title: Re: Moving npcs
Post by: ziarrek on 02 Aug 2007, 13:35:32
Thanks a lot:D I thought about something like this, but I'm not goog at scripts so I had to ask.