Home   Help Search Login Register  

Author Topic: nearestObject problem - command not working  (Read 727 times)

0 Members and 1 Guest are viewing this topic.

Offline Roni

  • Members
  • *
  • Play the Game !
nearestObject problem - command not working
« on: 12 Feb 2005, 00:45:38 »
Hello All

I have been battling for a week now with a script that is supposed to simulate an RDF unit.  The script uses the radio calls Alpha to Foxtrot to work out the bearing and rough distance between the caller and the nearest unit of the target type.

For instance - Radio Alpha (should !) return the bearing and rough distance to the nearest friendly base (reammoBoxWest).  The problem is - the nearestObject command appears not to be working !   >:(

I isolated the problem by renaming variables, substituting literals for variables and even rewriting the entire script from scratch.  I finally wrote a mini script using just the nearestObject command and a hint format to return what it found and in all cases the anser is the same - object-null.

HELP !!

I am using commercial copies of OFP and OFP-R patched to 1.96 on a laptop with a 2 gig processor, 708 meg of RAM and 64 meg shared graphics.  Everything else works fine, just this command.

I have tried checking for just a building object, including a "Streetlamp" (per the manual example) but still no luck.

Has anyone else had this problem or does anyone have any ideas ?

Thanks in advance



roni

PS - FWIW, attached is the offending script

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:nearestObject problem - command not working
« Reply #1 on: 12 Feb 2005, 02:48:08 »
The problem: The nearestobject command has a distance limitation of 50 metres...

I think you'd have to work it based on an array with predefined co-ordinates, and use some trig to determine the player's position in relation to your target...

Nearestobject isn't going to cut it in this situation I'm afraid ;)

Offline Roni

  • Members
  • *
  • Play the Game !
Re:nearestObject problem - command not working
« Reply #2 on: 12 Feb 2005, 08:50:55 »
Hi Sui

Thanks for that - I figured that it had to be something like that.  :(

Makes you wonder what use such a command is with only a 50m range . . .


Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:nearestObject problem - command not working
« Reply #3 on: 12 Feb 2005, 09:29:02 »
Yeah, it sucks, but I imagine it could really lag the game if it searched the entire island. However, an alternative solution would be to add every ammobox to an array, and when the time comes, use a function to find the closest object in that array. You could have different arrays for each object type, but you could use the same function for them all.
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 Roni

  • Members
  • *
  • Play the Game !
Re:nearestObject problem - command not working
« Reply #4 on: 12 Feb 2005, 10:23:16 »
Actually, I've already started work on creating the necessary arrays.  At the moment I'm tossing up between using defined object arrays or dynamic arrays with the members created using triggers.  Considering the time this taken me already I'm leaning toward whatever will take the least time to implement !

Yeah, I reckon a full function nearestObject command could cause all sorts of problems but I would have thought that that would have been the scripter's problem, not the designers.  They provide the tools (whether limited or costly or whatever), we decide if and when to use them.

Ultimately, if I can mimic the effect using arrays then you would have thought that BIS would have implemented a command that did just that but using just the one command.

Who am I to gripe though ?  They gave us manna and here am I demanding nectar !



Roni

Every grateful, oh lords of OFP, despite what I say !