Home   Help Search Login Register  

Author Topic: Unit move to Unit acting weird  (Read 1187 times)

0 Members and 1 Guest are viewing this topic.

Offline Jh62

  • Members
  • *
Unit move to Unit acting weird
« on: 04 Aug 2012, 01:05:15 »
Hi, this is annoying me...

I have this code:

Code: [Select]
_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???
« Last Edit: 04 Aug 2012, 01:06:48 by Jh62 »

Offline Lenyoga

  • Professor of Misanthropology
  • Members
  • *
Re: Unit move to Unit acting weird
« Reply #1 on: 08 Aug 2012, 21:46:55 »
[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

Code: [Select]
? (_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...
« Last Edit: 09 Aug 2012, 13:23:35 by Lenyoga »
As a grandmother I've got lots of gold.

Offline Jh62

  • Members
  • *
Re: Unit move to Unit acting weird
« Reply #2 on: 13 Aug 2012, 06:26:40 »
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.


Offline Lenyoga

  • Professor of Misanthropology
  • Members
  • *
Re: Unit move to Unit acting weird
« Reply #3 on: 14 Aug 2012, 01:20:07 »
Glad it works. I wasn't too sure if I made any mistakes.
As a grandmother I've got lots of gold.