Home   Help Search Login Register  

Author Topic: count nearestobject possible?  (Read 944 times)

0 Members and 1 Guest are viewing this topic.

PRiME

  • Guest
count nearestobject possible?
« on: 17 Jun 2003, 12:19:40 »
Just wondering if its possible to count all "men" objects (units) near a well object?

Just need this for a script to stop it infinite loop.

Iv'e been toying with

? (_i >= ({man} counttype nearestObject [_body]): Goto "nearest"

But obviously that won't work :/

ne1 able to help?

Komuna

  • Guest
Re:count nearestobject possible?
« Reply #1 on: 17 Jun 2003, 15:03:33 »
Just a hint: NearestObject does only return one object.

Try/find something about CountSide. [Unit CountSide West - only for alive units]

deaddog

  • Guest
Re:count nearestobject possible?
« Reply #2 on: 17 Jun 2003, 15:11:01 »
You could set a trigger with the appropriate size around the object.  Name the trigger what you want, like "welltrigger"

activation:anybody (or west/east etc)
condition:this
on activation:leave empty


now, in your script put:

?"man" counttype (list welltrigger) > 5 (or whatever is right):goto "whereever"

or you can use the wait statement

@("man" counttype (list welltrigger) > 5)


I believe the "counttype" command requires v1.9 or 1.91.

 :)

PRiME

  • Guest
Re:count nearestobject possible?
« Reply #3 on: 17 Jun 2003, 15:27:31 »
that complicates things more as the object moves around etc, and making a trigger for every object is difficult.


deaddog

  • Guest
Re:count nearestobject possible?
« Reply #4 on: 17 Jun 2003, 16:13:20 »
Your question was:
Quote
Just wondering if its possible to count all "men" objects (units) near a well object?
I assumed you meant you wanted to count how many "men" were around an object, like a water well.  You should be more clear in what you are asking. What do you mean by "well object"?

PRiME

  • Guest
Re:count nearestobject possible?
« Reply #5 on: 17 Jun 2003, 16:21:34 »
sorry mistype.. minus the well part :)

Tho now I wonder how I can check if a object is on "man" class, does typeof work with man, tank etc etc class names?

deaddog

  • Guest
Re:count nearestobject possible?
« Reply #6 on: 17 Jun 2003, 16:40:42 »
I don't know what all the types are but I do know counttype works with these:

man
tank (tanks and apcs)
car (jeeps, trucks)
air

"air" counttype thislist == 0

is usefull to use in a trigger if you only want ground units to activate the trigger (like a west present trigger).  This way, your patroling helicopter won't set off the trigger but a man or tank will.


I think "typeof" returns different values.  The best way to figure that out is to try it on different kinds of units like this:

hint format ["%1",typeof unitname]

I tried that on a Soviet officer once and it returned "OfficerE", not "man."

Now, as far as your original question, I'll have to think about that one a bit.  I think a trigger will have to be involved.  You can move a trigger by using the setpos command so you can constantly update its position around the moving object.

Exactly what are you trying to accomplish in your mission?

PRiME

  • Guest
Re:count nearestobject possible?
« Reply #7 on: 17 Jun 2003, 17:25:54 »
im just re-writing some respawn revive thing, so when a player dies it uses nearest object to get the name of the unit who is closest and passes it through a few checks etc etc..

Im trying to eliminate the need for classes cept just MAN class maybe, I think I got it figured out now.

Heres the OLD method SoldierType is a array set elsewere. The method below is flaky, hard to understand, and doesn't 100% work all the time.

#nearest
_i = 0
#Loop
~.1
? (_i >= (Count soldierType)): Goto "nearest"
_soldier = nearestObject [_body,soldierType select _i]
~.1
_i = _i + 1
?isNull _soldier : goto "loop"
~.1
?not alive _soldier : goto "loop"
?_ai != _soldier : _ai = _soldier; _ai doMove _pos
~.1
?_soldier distance _body > 5 : goto "nearest"
#Skip


PRiME

  • Guest
Re:count nearestobject possible?
« Reply #8 on: 18 Jun 2003, 03:51:56 »
there is one trigger on thats linked to the script, I would use that.