Home   Help Search Login Register  

Author Topic: All the objects in game  (Read 581 times)

0 Members and 1 Guest are viewing this topic.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
All the objects in game
« on: 23 Nov 2004, 11:46:19 »
Is there a way to get a complete list of ALL the objects in game? That would include: units, ammo, buildings, as well as trees and other ambient game objects.

Triggers set to activation "anybody" only return lists with units and vehicles, as far as i can tell. Its possible to add "init" eventhandlers to objects in the config, which could then add the object to a global array AllObjects or something, but this does really solve the problem.

The 'nearestobject' function doesnt have any problems finding ammo or static objects, so is there any way to get hold of the complete list it uses?

Apologies if theres a thread on this already, but i searched and couldn't find :)



Unnamed

  • Guest
Re:All the objects in game
« Reply #1 on: 23 Nov 2004, 13:50:10 »
Hi,

It would be easier to answer, if you can explain what you want to do. You can get some info on just about everything in OFP, but it depends when and where you want to use it.

For example:

Do you want a list of objects placed during a mission?

Do you want a list of objects placed in the mission editor?

Do you want a list of all the objects contained within a map?

Cheers

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:All the objects in game
« Reply #2 on: 23 Nov 2004, 23:16:33 »
Thanks for the reply!

I gues it was more of a curiosity really, but i know that other programs have statements like "foreach AllActors(class C,nameN)" (to use UnrealScript as an example), which checks each object in the game and does the relevant code.

In Opflash, you would have to say something like "foreach units thislist", and then create a large trigger set to activation anybody to supply the list, as you know. The list would also only contain units and vehicles, not for example ammo, buildings, trees.

An example would be: say you wanted to make a napalm script (not an original idea, i know :)) that set fire to everything, not just people and buildings, but ammocrates, tents, user-placed buildings as well.

Or a script that ckecked each missile and rpg fired, and caused a random failure/explosion or something

Those are just 2 not very good ideas off the top of my head, but there are heaps of places where an equivalent of an allactors statement would be extremely useful. I realise there are ways to solve the 2 problems above, but they would be way more complex than they need to be.

The BIS  function "nearestobject" shows that the game has access to some such list of all game objects, as it can pick up anything.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:All the objects in game
« Reply #3 on: 24 Nov 2004, 02:19:27 »
Well, unfortunately OFP script isn't as easy to work with as it should be. So, really, there IS a way to do this, but in most cases (like your examples), it is easier/better to work things some other way.

But if you wanted every object on the map to be in an array, you could make a loop through every object placed on the island, with the "object" command:

Code: [Select]
_id = 1
ObjArray = []
#loop
ObjArray = ObjArray + [object _id]
_id = _id + 1
? _id < 3000 : goto "loop"

I'm not sure how many objects are on every island, but it would look something like that. Editor placed objects would have to be added into this array manually by the editor.

If you messed with the game config, you could use an eventhandler to add every object into a global array, but many addons have their own EHs and wouldn't support this.

So, basically, it kinda is possible, but it isn't very practical. For most scripts, there is surely a better way to do it.
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 Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:All the objects in game
« Reply #4 on: 24 Nov 2004, 03:30:25 »
Additionally I would point out that object ID's on islands start with 0.


Planck
I know a little about a lot, and a lot about a little.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:All the objects in game
« Reply #5 on: 24 Nov 2004, 09:29:15 »
Hmmm...
That certainly solves that aspect of my problem, thanks.

Thinking back to pervious versions of ofp, the limiting factor in scripting anyway has always been the number of funcs that Ofp supplied.

Back in 1.46, adding custom effects like napalm etc to ammo (e.g. a rocket) was tricky because there were no EH's, and the nearestobject function only took one arguement (position). Shogun's napalm script for e.g. worked by waiting until a LAW soldier's ammo decreased by 1, then telepoting him to position [0,0,0], running the nearestobject function on the position he just occupied, then teleporting him back to his original pos.
9 times out of 10 it worked OK, but every so often failed to pick up the LAW and set fire to the player instead.
With the event, aha, of eventhandlers, and the nearestobject syntax being changed to [object/postion,"type"], adding custom effects to ammo became easier and more reliable.

OK, thats a bit off topic. I guess what trying to say is, how to get BIS to release a whole bunch more functions, or allow more access to game code?