Home   Help Search Login Register  

Author Topic: Count Static Objects  (Read 1208 times)

0 Members and 1 Guest are viewing this topic.

Offline Odin

  • Members
  • *
Count Static Objects
« on: 27 Jun 2008, 04:53:54 »
G'day,
 I have been trying to get a count on the number of static objects I have placed into my mission. I can count units no problems but can't figure out a way to count objects. I have searched forums Comref and the wiki but "Nada" can it be done?
Edit:
I am using an .SQS
Code: [Select]
trig1 = _this;
"Static" isKindOf "wirefence", "Fence", "Fortress1";
_count= hint format ["%1 object(s) left!", "Static" countType trig1];
Triggered with this line
Code: [Select]
[thislist] exec "can.sqs"
This allways returns "0 Objects left"

Cheers
Odin
« Last Edit: 27 Jun 2008, 06:18:46 by Odin »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Count Static Objects
« Reply #1 on: 27 Jun 2008, 15:08:28 »
Code: [Select]
"Static" countType trig1
Just counts how many objects are actually of type "Static", not how many are kinds of statics. Thus, this number will always be 0, since you can't actually make something of class "Static", only its derivatives.

You need to use a slightly different tack, as you suspected, using isKindOf:
Code: (can.sqs) [Select]
_objects = _this select 0;

_count = { _x isKindOf "Static" } count _objects;
hint format ["%1 object(s) left!", _count];
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Count Static Objects
« Reply #2 on: 27 Jun 2008, 17:37:16 »
I fear this will count all static objects in the trigger area, not just the ones placed by the mission author.


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

Offline Odin

  • Members
  • *
Re: Count Static Objects
« Reply #3 on: 28 Jun 2008, 01:03:44 »
Thanx guys, Unfortunatly That code returns 0 on static objects as well, but will count Men, logics and vehicles. May just have to dust off my abacus and count them via the SQM, The reason I wanted a code for this is I think I may have over loaded the mission with the Static Objects  :dunno: Anyway thx Spooner, and if anyone has any other sujestions I am all eyes

Cheers

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Count Static Objects
« Reply #4 on: 28 Jun 2008, 01:54:03 »
Yes, you are quite right! It seems triggers don't pick up "building-type" (non-physics) objects. Sorry, I didn't realise that.

Right, here is the solution (that I've actually tested this time). Name the trigger "trig" and put it somewhere in the centre of the map (Activation: ANYBODY PRESENT, condition: this).
Code: (on activation) [Select]
hint format ["%1 objects on the map", count (nearestObjects [trig, ["Static"], 50000])]
(You don't actually have to use a trigger for this, because you could actually just put the code into any object's init line as long as you are counting statics. If you want to count something other than statics, though, you'd need to use the trigger to wait until the objects spawned in at the start of the mission (Yes, I know there are other ways of waiting for this)).

As Planck said, this will now pick up all static objects on the map, including those that are placed by the map-maker (e.g. 30 on Rahmadi). Thus, open up the same map and put nothing but a man and that trigger in it. This will tell you the number of statics that the map-maker placed. Take this number from the number you get on your complete mission map. It is a bit like weighing yourself and the sack before you put the animal in the sack and stand on the scales. Er, yes. It is.

Sorry I mislead you earlier on...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Odin

  • Members
  • *
Re: Count Static Objects
« Reply #5 on: 28 Jun 2008, 06:08:43 »
Excellent! thanx Spooner, if your ever in Australia I owe you a beer mate. For intrest sake's for anyone who wants to know
Sarahni has 5094 preplaced Static objects

btw turns out I have 417 ontop of that :scratch:

Cheers
Odin