Home   Help Search Login Register  

Author Topic: Count ammo crates  (Read 1017 times)

0 Members and 2 Guests are viewing this topic.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Count ammo crates
« on: 24 Sep 2006, 22:44:17 »
I am trying to count the number of ammocrates in a mission............Easy one would say, but no, not that easy.
Ammocrates can be created during the mission, if the mission maker allows it. This means a mission can have 1 ammo box at start but 1000 at the end (created with a spawn script).

For this I need to know how many ammocrates a mission starts with, and I have to be able to count how many ammocrates there are during the mission. My script will than compare the original ammount of boxes to the new ammount of boxes.
If the new ammount of boxes is out of order I want the mission to end.

So what have I got:

I know you cant "counttype" ammocrates, or at least I tried for a few hours and nothing work.

I made the following script:

Code: [Select]
_instrcheck = list unit_check
_oldammocounter = 0
_i = 0
_b = 1

_ammo = ["all possible ammocrates config names are added to this array. I play with the same people all the times so I know what addons will be used"]

_zcount = count _ammo
#check
_z = _ammo select _i
{if ((typeOf _x) == _z) then {_oldammocounter = _oldammocounter + 1 }} forEach _instrcheck
_i = _i + 1
_b = _b + 1
?(_b == _zcount) : goto "loop"
goto "check"

#loop
_i = 0
_b = 0
_ammocounter = 0
~0.2
#innerammo
_z = _ammo select _i
{if ((typeOf _x) == _z) then {_ammocounter = _ammocounter + 1 }} forEach _instrcheck
_i = _i + 1
_b = _b + 1
?_oldammocounter > _ammocounter : _oldammocounter = _ammocounter
?_ammocounter > _oldammocounter : goto "cheater"
?(_b == _zcount) : goto "loop"
goto "innerammo"
#cheater
blablablablaba
exit

In the script above the loop runs without pause, thats correct. But the full version has a random delay of min 3 max 5 seconds.

Now the problem is, ammocrates wont show up in the "list". So the script will always return 0. Even if you create 10000000 crates.
So, how on earth can I count how many crates are present? Anyone has an idea?

Thanks for your help  :thumbsup:

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: Count ammo crates
« Reply #1 on: 25 Sep 2006, 02:53:21 »
If I would break my head on this, I would start by counting all the units/objects added to the map by the mapdesigner including them in a list/array on mission start;
everything that would come after that, that is not (how you said it, you can't count ammocrates?) a groundunit, armor, airunit (which can be counted?) wouldn't seem normal...
So there's my  :2c: for an idea
Hope this can help

Greetz

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: Count ammo crates
« Reply #2 on: 25 Sep 2006, 10:22:39 »
Thanks for your reply.

Well, the problem is I cant figure out how to count objects placed in the editor. Even if the missionmaker gives them a name and adds them to an array I still cant make the script check if there are more objects (in this case ammocrates) created since I still cant count them. I can count all units present in the list but that list will not see any objects in the list. :(

So I was thinking of counting magazines and weapons. But than, if a unit dies his weapons and magazines will be deducted from the total, if you than pick the weapons from a dead body the script will mistaken this for having created an ammocrate. Same goes if the player respwans.

Anyone got any idea how I can make sure one can not create ammocrates or any other thinge you can add weapons to, to replenish himself with new ammo?
I manually did go thrue the entire COMREF and saw weaponpool, originally for campaign (to save players weapons etc)g weapons and magazines? Could I maybe use this to check the player weapon and ammo stats?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Count ammo crates
« Reply #3 on: 25 Sep 2006, 18:59:38 »
i confess i couldn't see the problem with this until i read the bit about ammocrates at the beginning of the mission.

counting ammocrates added during the mission is (i would think) pretty easy - depending on the method you're using to create them (radio trigger, eventhandler, action, etc.) you set up a global variable, and each time the create_ammocrate script is run, you add one to the global variable.

as for how many ammocrates the mission begins with, you just have to ask the designer to start the global variable at the number of crates s/he put in the mission.

i may be oversimplifying this, but it looks pretty straightforward to me.  :confused:

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: Count ammo crates
« Reply #4 on: 25 Sep 2006, 20:42:16 »
Thanks bedges.  :)

Well you hit the nail, it is as simply as that.................but............I dont have controle of the spawning script. Its an extra addon used by those who have it to create whatever they want. The scripts for this are only accassible by them (local computer) and the addon runs on the server aswell. Not all clients need to have it.
I am just another client trying to make a mission with a script running in the background to prevent them from spawning stuff.
Asking them to edit their script just so everytime they spawn a crate (or whatever) they add 1 to the global variable is a nono since they like the fact they have so much spawnpowers :)........and I think they demolish the original idea of certain missions  :angel:

That is why I try to make my script to be able to "see" created stuff. I got all creations covered (units/vehicles/land/air/water) except for ammocrates.

Also I was thinking, one they see I prevent ammocrates spwaning they might spawn empty ammo trucks with new ammo in them. Thats why I tried to count all available ammo in a mission which is carried by the all units and inside ammocrates and vehicles. Is that possible? I can get ammocount out of units, but still not out of crates and ammotrucks.

I hope I make sense here.........otherwise I will just give up on this and allow crates to be spawned :(