OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Jh62 on 04 Aug 2012, 01:05:15
-
Hi, this is annoying me...
I have this code:
_zombie = _this select 0
_man = _this select 1
_zombie setUnitPos "UP"
_zombie setBehaviour "CARELESS"
_zombie setSpeedMode "FULL"
removeAllWeapons _zombie
_zombie addMagazine "StrokeFist"
_zombie addWeapon "StrokeFist"
#loop
? (_zombie distance _man) > 5 : goto "move"
~1
goto "loop"
#move
_zombie GlobalChat "Moving..."
_zombie doMove getpos _man
goto "loop"
The _zombie moves to _man and stops when it's above him (touching him).
Now, if I change the distance check to any other number than five in ? (_zombie distance _man) > 5 : goto "move", the _zombie will move until its like 5 meters away from unit and I don't know why!
I need the _zombie to "touch" the other unit, and "distance > 5" is not useful because if i move a few steps away, _zombie stops moving...
And I have another issue:
I give _zombie "StrokeFist" weapon and make it Fire when it's near _man, but it won't stop doing the stroking animation even when I issued "doStop" or " _zombie switchMove "" ".
Any help???
-
[EDIT]
Close combat is a very... problematic topic in OFP/CWA.
If you want the zombie to move closer to the unit and actually attack, you should do something like
? (_zombie distance _man) < 5.5: _zombie switchMove "CivilRunF"; goto "next"
goto "loop"
#next
_pos = getpos _zombie
_zombie setdir ((getpos _man select 0) - (_pos select 0)+.001) atan2 ((getpos _man select 1) - (_pos select 1))
~0.6
_zombie playmove "StandStrokeFist"
~0.2
?_zombie distance _man < 2: goto "damage"
~1
goto "loop"
#damage
_man setDammage ((damage _man) + 0.25)
;;(maybe also some soundeffect, etc...)
~1
goto "loop"
It's pretty much a workaround... the problem is that units don't use the Strokefist or Strokegun weapon...
-
Yeah, thanks.
I've done that to get the results i've wanted and now it works perfectly.
I've manage to make a pretty good zombie script that targets closest unit (civilian, animal, etc...) and chase it as long as he knows where it is.
-
Glad it works. I wasn't too sure if I made any mistakes.