Home   Help Search Login Register  

Author Topic: questions about arrays  (Read 724 times)

0 Members and 1 Guest are viewing this topic.

j-man

  • Guest
questions about arrays
« on: 01 May 2004, 21:05:49 »
I was wondering, what would I need to do to check if any unit from one array knows about any unit from another array? Also, would it be possible to detect if any unit from an array was dead ???

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:questions about arrays
« Reply #1 on: 02 May 2004, 02:40:45 »
I was wondering, what would I need to do to check if any unit from one array knows about any unit from another array?
Hmm... that's a tricky one. I can do one unit knowing about any in an array... or any in one array knowing about a specific unit:

? "_x knowsabout unit > 0" count Array > 0: activation code

or

? "unit knowsabout _x > 0" count Array > 0: activation code

I guess you could script a loop to go through checking every unit in your other array (yuck :P)...

_i = 0
#loop
~0.01
? "(Array1 select _i) knowsabout _x > 0" count Array2 > 0: HeKnows = true
_i = _i + 1
? _i < (count (Array1 - 1): goto "loop"

Not pretty, but it should do the job


Also, would it be possible to detect if any unit from an array was dead ???
This isn't too hard:

? "not (alive _x)" count Array > 0: Hesdead = true

Hopefully some smart cookie can come up with a better solution to your first question that I have... ;)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:questions about arrays
« Reply #2 on: 02 May 2004, 03:23:16 »
hmm - i'm not sure, but i think toadlife made a function
(threatmatrix or so), where i believe this stuff can be done

Check out the functions at the ed-depot

:edit

Quote
Hopefully some smart cookie can come up with a better solution to your first question that I have...

lol - soz for cummin tho, saw this sentence after my post  ;D

~S~ CD
« Last Edit: 02 May 2004, 03:25:27 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

j-man

  • Guest
Re:questions about arrays
« Reply #3 on: 02 May 2004, 05:59:19 »
Thank you  Sui and Chris D :)

EDIT
I wont solve this topic incase someone else has somethingto add
« Last Edit: 02 May 2004, 05:59:56 by j-man »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:questions about arrays
« Reply #4 on: 02 May 2004, 08:50:02 »
I made a function to do pretty much that. Check it out here:

http://www.ofpec.com/editors/funcref.php?filter_func=47

But my function is a little different than what you are looking for. Still, check out my function, but Sui is on the right track for what you need. Only, a couple errors in his script. Here is what you want:

Quote
_knows = false
_i = 0
#loop
? {(Array1 select _i) knowsabout _x > 0.105} count Array2 > 0.105 : _knows = true
_i = _i + 1
? _i < (count (Array1) && !(_knows) : goto "loop"

;rest of script here

The "magic" number for knowsabout is 0.105, according to Toadlife (see the commented com ref in the ed depot). That is the value where the AI can start to shoot you. Below that, they haven't detected you yet.

Now, you could also turn that into a function quite easily (using a 'while' loop instead of a goto), and then use it in a trigger or an @condition. Let me know if you need help doing that.


HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:questions about arrays
« Reply #5 on: 02 May 2004, 08:58:00 »
Yeah... I think it may change depending on conditions...

I found it to be about 0.75 when I did testing. That was a long while ago though, and at night.

I prefer to use 0 as it avoids confusion... also accounts for AI 'intuition'... eg. a soldier 'thinking' they saw something.

Kammak

  • Guest
Re:questions about arrays
« Reply #6 on: 02 May 2004, 09:05:04 »
Did you mean 1.0 instead of .105?

If anything happens around a group of bad guys (in my experience) the knowsAbout jumps to 1.5, even if no one has actually seen you.

I've seen that stated that 1.0 means they will shoot at you, but its misleading.

Personally I think the knowsAbout function is very broken, as it makes no sense.  I've been walking straight towards a bad guy, standing up, and he is shooting at me, yet the knowsAbout level continued to *decrease* as we did so (polling every .5 seconds).

Anytime someone gets shot in a squad, the rest of the squad goes to 1.5, even if they have no idea where the shooter is.

After playing around with it quite a bit, I finally settled on anything higher than 1.5 meaning they *really* knew where I was...though this is also not always accurate.  But it is unrealistic (and unfair to the player) to have guards triggered onto your pos based solely on a knowsAbout level of 1.0 - perhaps that was once true and it got changed in the many patches?

I would really enjoy having an "Engaged" event, which would indicate an individual had eyes-on-target (and confirmed as an enemy).  It would make scripting much cleaner.

All this is assuming I've not made a gross error in my scripting when monitoring this...always a possibility.  :)  But in this case I really think the function "knowsAbout" is just broken.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:questions about arrays
« Reply #7 on: 02 May 2004, 09:12:53 »
Yeah, knowsabout is very annoying to use. Basically, you can't trust it for anything other than a script version of the "detected" trigger, in my experience. Trying to use it to find "how well" somebody knows about somebody else, just doesn't really work. Like you said; broken.

The 'magic number' may be something else, but I've been using 0.105 for a while, and I've never seen that number make a script/event trigger when the enemy hasn't obviously detected someone.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Kammak

  • Guest
Re:questions about arrays
« Reply #8 on: 02 May 2004, 09:17:16 »
After seeing Sui's post with that same number (.105) I went to the online reference and read that entry (I was going off a printed version from several years ago).

I see that my remarks above were already stated before by others!

Very disappointing that after so many patches there is still no clean function that indicates whether an AI has eyeballs on an enemy...seems kind of vital for many aspects of mission making, which makes me think BIS has some better function that is not exposed to us (used in the hard-coded AI routines)?

So given the quirks of "knowsAbout", what is the consensus on the real "trigger level" for version 1.96?

Personally I'm sticking with >1.5 unless someone has a strong argument for making it lower, as regards directing non-engaged groups to the player/spotted unit's location.