Loading a CAWS with BUCKSHOTS results in a CAWS loaded with AP SLUGS

Issue #120 resolved
Misanthopos created an issue

But removing them it looks again like BUCKSHOTS -

I guess the solution lies within magazines.json - and it looks like the definitions ammoTypes are exchanged.

the attached diff works for me now - but I had not SLUGS - so I am not sure if they work as expected.

Comments (8)

  1. Misanthopos reporter

    The applied patch works as expected - SLUGS and BUCKSHOT ammo now gets loaded and unloaded correctly.

  2. Gennady Trafimenkov repo owner

    It is a little bit trickie, I am afraid. Before the data externalization items (from Item array in Items.cc) which represents magazines (clips) referenced magazine description in Weapons.cc in array Magazine. Here is an extract from Items.cc, the second item on every line is the reference to Magazine array.

        {   IC_AMMO,                    34,         INVALIDCURS,    1,      20,     9 , 4,       750,   9,      /* CLIP57_50_SAP */     0,      0,          IF_STANDARD_CLIP},
        {   IC_AMMO,                    35,         INVALIDCURS,    1,      21,     9,  4,       500,   9,      /* CLIP57_50_HP */      0,      0,          IF_STANDARD_CLIP},
        {   IC_AMMO,                    37,         INVALIDCURS,    2,      22,     5,  6,        20,   3,      /* CLIP12G_7 */             0,      0,          IF_STANDARD_CLIP},
        {   IC_AMMO,                    36,         INVALIDCURS,    2,       4,     5,  6,        20,   3,      /* CLIP12G_7_BUCKSHOT */    0,      0,  IF_STANDARD_CLIP},
        {   IC_AMMO,                    39,         INVALIDCURS,    1,       0,  10,    6,       300,   9,      /* CLIPCAWS_10_SAP */   0,      0,          IF_STANDARD_CLIP},
        {   IC_AMMO,                    38,         INVALIDCURS,    1,       1,  10,    6,       300,   9,      /* CLIPCAWS_10_FLECH */     0,      0,  IF_STANDARD_CLIP},
    
        {   IC_AMMO,                    40,         INVALIDCURS,    1,      110, 10,    4,       500,   9,      /* CLIPROCKET_AP */     0,      0,          IF_STANDARD_CLIP},
        {   IC_AMMO,                    41,         INVALIDCURS,    1,      115, 10,    4,       500,   9,      /* CLIPROCKET_HE */     0,      0,          IF_STANDARD_CLIP},
    

    Records in Magazine:

    { AMMO57,   50, AMMO_AP },        // 34
    { AMMO57,   50, AMMO_HP },        // 35
    { AMMO12G,  7,  AMMO_BUCKSHOT },  // 36
    { AMMO12G,  7,  AMMO_REGULAR },   // 37
    { AMMOCAWS, 10, AMMO_BUCKSHOT },  // 38
    { AMMOCAWS, 10, AMMO_SUPER_AP },  // 39
    { AMMOROCKET,   5,  AMMO_SUPER_AP },  // 40
    { AMMOROCKET,   5,  AMMO_HE },        // 41
    { AMMOROCKET,   5,  AMMO_HEAT },      // 42
    

    When I did the weapons externalization I joined information from two arrays (information from Item and Magazine) and put everything to magazines.json.

    I thought that references from Item to Magazine were all consequent and joined the records accordingly (first clip goes with first record from Mangazine and so forth), but as it turned out the references are were not consequent for items CLIP12G_7, CLIP12G_7_BUCKSHOT, CLIPCAWS_10_SAP, CLIPCAWS_10_FLECH (i.e. 37, 36, 39, 38) and the joining went wrong.

    Records in Magazine were organized in such a way that regular ammo always goes first. Because of this, function DefaultMagazine in Items.cc (which finds default magazine for a weapon) returned magazine with regular bullets, not armor-piercing for example.

    So references 37, 36, 39, 38 in Item was not a mistake but rather a fix for situation when CLIPCAWS_10_SAP goes before CLIPCAWS_10_FLECH in the items table, but AMMO_BUCKSHOT must be before AMMO_SUPER_AP in Magazine table.

    Well, that was before. Now there is only one list (magazines.json). If I apply your patch, it will fix the problem with unloading weapon but introduce new problem that function DefaultMagazine starts return clip with AMMO_SUPER_AP instead of CLIPCAWS_10_FLECH.

    So, solution I guess should be: 1) apply you patch 2) add a new flag like "dont-use-as-default-magazine" for items CLIPCAWS_10_SAP and CLIP12G_7 in magazines.json 3) check this flag in DefaultMagazine function

    It's not done yet because: a) I want to write unit tests to check how DefaultMagazine worked before weapon externalization and after, and this takes some time; b) I can work on JA2 Stracciatella only on weekends for a little bit.

    Sorry that work's is going slow on my part. I don't have much time to allocate to this project right now.

  3. Misanthopos reporter

    I see - maybe it was intended that Shotguns and CAWS are loaded by default with a different type of magazine. In that case you could just apply the patch and thats it.

  4. Log in to comment