Jump to content
Undeceived

Weapon Pool duplicates itself in campaign progress

Recommended Posts

Well, this is what was shown on the screen at least.

Not exactly in that line you mentioned

if (_gearsel in _template)

but in that if then-part, yes.

Check the exact location in my post on the previous page.

Share this post


Link to post
Share on other sites

Oh I see the error now. I thought the if-check failed but it's failing when trying to subtract. Just put brackets around _gearsel in the assignment, then it should work.

Share this post


Link to post
Share on other sites

Ok, step by step we're getting closer. :D

With the following code, no error appers anymore:

I took out the _template part and went straight with POOL_MAGAZINES for testing purposes.

MAGAZINES_PLAYER = magazines player; // ["30Rnd_556x45_Stanag","30Rnd_556x45_Stanag"]
// POOL_MAGAZINES looks like this in this test (4 mags, 2 grenades):
// ["30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","HandGrenade","HandGrenade"]

for "_w" from 0 to ((count MAGAZINES_PLAYER) -1) do {

_gearsel = MAGAZINES_PLAYER select _w; 

   if (_gearsel in POOL_MAGAZINES) then {
       POOL_MAGAZINES = POOL_MAGAZINES - [_gearsel];
   };


};

saveVar "POOL_MAGAZINES";

The problem now is that by using this substraction command POOL_MAGAZINES = POOL_MAGAZINES - [_gearsel];, every string that looks like _gearsel will be deleted from POOL_MAGAZINES. Only the grenades will remain in the array.

The info on the BIKI (Arrays) confirms this too

The result will be a

new array that contains all of the items in the first array that were not in the second array.

The example on Substraction on the BIKI page shows it quite well.

Now the question is: How can we remove ONLY _gearsel, not all strings that look like _gearsel?

Edited by Undeceived

Share this post


Link to post
Share on other sites
[color="#FF8040"][color="#8B3E2F"][b]{[/b][/color]
[color="#1874CD"]_ind[/color] [color="#8B3E2F"][b]=[/b][/color] POOL_MAGAZINES [color="#191970"][b]find[/b][/color] [color="#000000"]_x[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_ind[/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	POOL_MAGAZINES [color="#191970"][b]set[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#1874CD"]_ind[/color][color="#8B3E2F"][b],[/b][/color] [color="#7A7A7A"]"DEL"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]forEach[/b][/color] [color="#191970"][b]magazines[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b];[/b][/color]
POOL_MAGAZINES [color="#8B3E2F"][b]=[/b][/color] POOL_MAGAZINES [color="#8B3E2F"][b]-[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"DEL"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]saveVar[/b][/color] [color="#7A7A7A"]"POOL_MAGAZINES"[/color][color="#8B3E2F"][b];[/b][/color] [/color]

Share this post


Link to post
Share on other sites

Thanks, KK, that works! And tryteyker for your time!

It's annoying, but I already have the next problem in line. :rolleyes: FPDR

The player can already have some magazines of those in MAGAZINE_POOL. I use aeroson's GET/SET loadout scripts, which passes the player's gear to the next mission and he has it already in the briefing inventory screen (where the weapon pool is).

A quick example of the problem:

  • There are 5 magazines "30Rnd_556x45_Stanag" in the weapon pool in the briefing (aka. in MAGAZINE_POOL).
  • The player has 3 magazines "30Rnd_556x45_Stanag" left from the last mission.
  • The player decides that he won't need anymore mags from the WP and starts the mission without taking a mag from it.
  • Killzone_Kid's script is launched after the briefing and sees 3 magazines in the player's inventory and deletes those 3 from MAGAZINE_POOL. :butbut:

Is there a way to prevent this or to check if the player has taken something from the WP?

Damn, this whole weapon pool workaround is so complicated....

Thanks guys! Your help is great!

Edited by Undeceived

Share this post


Link to post
Share on other sites

Why don't you return all player magazines back to the pool after mission completed so that he has no choice but gear up for new mission from pool.

[color="#FF8040"][color="#006400"][i]//end mission[/i][/color]
POOL_MAGAZINES [color="#8B3E2F"][b]=[/b][/color] POOL_MAGAZINES [color="#8B3E2F"][b]+[/b][/color] [color="#191970"][b]magazines[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]while[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#191970"][b]count[/b][/color] [color="#191970"][b]magazines[/b][/color] [color="#000000"]player[/color] [color="#8B3E2F"][b]>[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color] 
[color="#000000"]player[/color] [color="#191970"][b]removeMagazines[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]magazines[/b][/color] [color="#000000"]player[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Share this post


Link to post
Share on other sites

Well, that would solve it, but then the GET/SET scripts would be kind of redundant. Ideally the player should keep his equipment on him after finishing a mission and only take some more gear from the WP, if he's running out of ammo.

But if there's no other idea (anyone?), I think I will have to do it that way...

A completely different approach would be only to collect what belongs in the WP at the end of a mission and then (in the beginning of the next one) simply ignore what the player has taken from the WP. :j:

Does anyone have another sudden inspiration?

Edited by Undeceived

Share this post


Link to post
Share on other sites

I recently was solving SAVING gear from container and sync it with other containers. For example as when you pick up something from one hideout ammo box, it will remove/add it from all hideout ammo boxes at once. Here is little snippet to showcase functionality. Pretty useful when you share same gear with different locations.

 

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×