Jump to content

R&D Inventory, Items & Weapons Overhaul


anUser

Recommended Posts

My suggestion is to remove the item from storage when it is equipped to the soldier. The current system keeps the item in storage, but marks it as _claimed_. This is what requires the garbage collection later, causing problems if the item is removed from the soldier's inventory in the tactical game (since as you say, then you don't know what items to remove).

 

However, if when you add the item to soldier inventory you then immediately remove the item from storage, this garbage collection issue goes away.

 

This would also require:

1) UnloadSoldier would now remove the item from soldier inventory and add the item to storage

2) Unequipping an item from a soldier's inventory in XGFacility_Barracks would add the item to storage

3) MIA soldiers would simply not add their items back to storage

 

It does require some coordination between the tactical and strategy games, but making consumable items is going to require that anyhow.

 

I'm guessing that Firaxis didn't implement it this way in the first place because this type of implementation is more susceptible to item-duplication bugs (or the reverse, incorrect item-loss).

Link to comment
Share on other sites

  • Replies 129
  • Created
  • Last Reply

Top Posters In This Topic

Exploring now this approach of removing items from storage once equipped. If I stand correct it can be achieved with minor changes to 4 functions plus re-writting a big one to still empty the inventory slots "on the fly" as the abilities are used.

 

The idea is to make it simple and consistent, so it doesn't need a special code to run on mission end (that was an issue I had with previous version, because when cancelling a mission before taking it, just stepping back to barracks or so would trigger the code for the skyranger returning to base, to that's something to avoid). Whatever, my plan now is:

- during tactical game, in XGAbilityTree.ApplyActionCost, still reduce the m_iFragGrenades variables (ie num charges available), and call that TInventorySmallItemsSteItem(0) that empties the inventory slot.

- then on the strategy game, in XGFacility_Lockers, edit EquipSmallItem so it removes it from storage, and UnequipSmallItem adds it back. I guess this functions are called when equipping the soldiers in the barracks view and mission select.

 

This would decopensate the number of "claimed items" and those actually present in the inventory, but as far as I can tell I haven't noticed if this could have any impact on the game, since inventory slots would be empty and ready to be filled, and item charges depend on the number of items in inventory, as per the UpdateItemCharges edit. In any case that difference would be corrected once the unit were injured and sent to infirmary after a battle, in which case the ReleaseLoadout function would be called and that one would call in turn a helper function ReleaseSmallItems that in conjunction would clean wipe the inventory and claimed items array, and only add back to storage those items really presents in the inventory.

 

Here's the intended code:

 

XGFacility_Lockers.EquipSmallItem

    UnequipSmallItem(kSoldier, iSlot);
    STORAGE().ClaimItem(iItem, kSoldier);
    TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, iSlot, iItem);

--------
    if((iItem == 80) && !HQ().HasFacility(13))
    {
        m_bNarrArcWarning = true;
    }

replace for:

    STORAGE().RemoveItem(iItem);
--------
====================================================
function bool UnequipSmallItem(XGStrategySoldier kSoldier, int iSlot)
{
    // End:0x17A
    if((iSlot < kSoldier.m_kChar.kInventory.iNumSmallItems) && kSoldier.m_kChar.kInventory.arrSmallItems[iSlot] != 0)
    {
        STORAGE().ReleaseItem(kSoldier.m_kChar.kInventory.arrSmallItems[iSlot], kSoldier);
        TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, iSlot, 0);
    }
    return true;
    //return ReturnValue;    
}
------------

if((iSlot < kSoldier.m_kChar.kInventory.iNumSmallItems) && kSoldier.m_kChar.kInventory.arrSmallItems[iSlot] != 0)

replace whole condition for:

    STORAGE().AddItem(kSoldier.m_kChar.kInventory.arrSmallItems[iSlot]);

** if possible, keep iSlot < iNumSmallItems check !!!

-------------
=====================================================

function ReleaseLoadout(XGStrategySoldier kSoldier)
{
    local int I, iItem;

    ReleaseItem(kSoldier.m_kChar.kInventory.iArmor, kSoldier);
    kSoldier.m_kChar.kInventory.iArmor = 0;
    ReleaseItem(kSoldier.m_kChar.kInventory.iPistol, kSoldier);
    kSoldier.m_kChar.kInventory.iPistol = 0;
    I = 0;
    J0x145:
    // End:0x261 [Loop If]
    if(I < kSoldier.m_kChar.kInventory.iNumLargeItems)
    {
        ReleaseItem(kSoldier.m_kChar.kInventory.arrLargeItems[i], kSoldier);
        TACTICAL().TInventoryLargeItemsSetItem(kSoldier.m_kChar.kInventory, I, 0);
        ++ I;
        // [Loop Continue]
        goto J0x145;
    }
    I = 0;
    J0x26C:
    // End:0x39B [Loop If]
    if(I < kSoldier.m_kChar.kInventory.iNumSmallItems)
    {
        iItem = kSoldier.m_kChar.kInventory.arrSmallItems[i];
        ReleaseItem(iItem, kSoldier);
        TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, I, 0);
        ++ I;
        // [Loop Continue]
        goto J0x26C;
    }
    //return;    
}

-----------
replace 2nd loop:
    if(I < kSoldier.m_kChar.kInventory.iNumSmallItems)
    {
        iItem = kSoldier.m_kChar.kInventory.arrSmallItems[i];
        ReleaseItem(iItem, kSoldier);
        TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, I, 0);
        ++ I;
        // [Loop Continue]
    }
for:
    ReleaseSmallItems(kSoldier);

    if(I < kSoldier.m_kChar.kInventory.iNumSmallItems)
    {
        TACTICAL().TInventorySmallItemsSetItem(kSoldier.m_kChar.kInventory, I, 0);
        ++ I;
        // [Loop Continue]
    }
-----------------
==================================================
function ReleaseSmallItems(XGStrategySoldier kSoldier)
{
    local int I;
    local XComGame.XGGameData.EItemType eItem;

    I = 0;
    J0x0B:
    // End:0x152 [Loop If]
    if(I < kSoldier.m_kChar.kInventory.iNumSmallItems)
    {
        eItem = byte(kSoldier.m_kChar.kInventory.arrSmallItems[i]);
        ReleaseItem(eItem, kSoldier);
        RemoveItem(eItem, 1);                        
        TACTICAL().TInventorySmallItemsRemove(kSoldier.m_kChar.kInventory, 85);                                
        ++ I;
        // [Loop Continue]
        goto J0x0B;
    }
    //return;    
}
--------------
replace loop for:

if(I < kSoldier.m_kChar.kInventory.iNumSmallItems)
{
    eItem = byte(kSoldier.m_kChar.kInventory.arrSmallItems[i]);
    if (eItem) {
        ReleaseItem(eItem, kSoldier);
        AddItem(eItem);
    }
    ++I;
}

 

... now that I think of it... maybe the claimed items issue isn't solved this way ... I'll keep working on the ApplyActionCost function by now, any idea is welcome.

Link to comment
Share on other sites

I hope your quest to make consumable items pays off! :)

 

I had another idea that got tossed up from the deep recesses of my brain.

 

What about if we changed up heavy so that the class could no longer equip both an LMG and Rocket Launcher. What I mean is that the Rocket Launcher would now be an OPTION as a weapon to equip instead of the LMG.

 

The possible loadout options for Heavy:

1) LMG + Pistol

2) Rocket Launcher + Pistol

 

Rocket Launcher would remain as a move-or-fire weapon. However, it could now be reloaded, but would still get only one charge to start off, and one charge given back upon reload. Only Heavies would be given the option to equip a Rocket Launcher. This could automatically be an option upon promotion, or could be granted as a result of selecting the perk "Fire Rocket" (i.e. "Fire Rocket" gives the Heavy the ability to equip the Rocket Launcher instead of the LMG).

 

This would open up the possibility of making pistols available to Heavies (allowing Gunslinger perk as an option). Also those mods that put the Arc Thrower into the pistol slot could take advantage of a pistol slot on the Heavy.


Thoughts?

Link to comment
Share on other sites

This reminds me of many old shooter games where there's a kind of soldier that's the one able to carry big weapons, ... probably the developers had similar thoughts when creating that flamethrower weapon. Honestly I like rockets being one-use items, it seems to me it'd be too much to have unlimmited rockets, although just for fun I'd love to get on overwatch with the rocket launcher loaded ready for anything that pops out

 

I've taken a completely different approach here in trying to balance weapons, but it's all tangled and correlated. I've always considered a machinegun was such a key element in a squad that it cannot allow himself not using the mg in his turn, ... and I really like the concept of a support class, but a medic class in a 4 wo/men squad seems excessive to me, so what I've done is making that support class gets the machinegun, so it becomes machinegunner, heavies now become the "tools guy", explosives, rockets, smoke grenade, etc, and assault and sniper remains more or less the same ... and NO MEDIC (ie no Savior or Field medic perk). It's a bit rough, but it's pretty challenging. I'm expecting that in a more evolved scenario with consumible items and more inventory slots available, it'd be pretty fair if by the last missions you equip each unit with as many medikits as possible. But again this relates to my weapon config, where pistols and rifles have long range aim penalty just like shotguns, so the chances of taking a hit are lower but the consequences are higher. And btw, re-assigning classes this way I could give the eWP_Heavy tag to rifles and not machineguns, that now only have the Support tag, so now machineguns have to reload after 4 shots, and rifles and pistols after 3 shots, as it should have been from the beginning.

 

You see I may be using weapons in a different manner than you do, for me the machinegun is essential to pin down targets and hold the line with covering fire, while other tools suchs as explosives are used to ease the way, or as a last resource/special move. Well I'm sry I've rambled and I haven't been very supportive towards your suggestion, I just don't see it quite fitting my taste :P I think there's ppl that have already played with rocket launchers as main weapon, I assume it's just a matter of ini settings and maybe some check in isWeapon or some other place of the sort, and as for giving the heavies a pistol slot, I think you're already familiar with the code... so you'll tell us if it works and it's fun.

 

happy modding!

Link to comment
Share on other sites

I really, really like the idea of separating the machinegunner from the rocketeer -- there's some realism to it, for one thing, in that an antiarmor specialist is not the guy with the automatic rifle laying down suppressing fire. With the perk mod this might be a more feasible way to set things up, although I would worry about whether there are enough perks for meaningful choices to be left for the 'heavy' (the antiarmor guy).

 

If a soldier was able to carry unlimited rockets, I would encourage lowering the to-hit of the rocket launcher from 90 percent.

 

Question: If the heavy doesn't have the fire rocket perk, does the rocket tube still appear as part of his pawn?

Edited by johnnylump
Link to comment
Share on other sites

I really, really like the idea of separating the machinegunner from the rocketeer -- there's some realism to it, for one thing, in that an antiarmor specialist is not the guy with the automatic rifle laying down suppressing fire. With the perk mod this might be a more feasible way to set things up, although I would worry about whether there are enough perks for meaningful choices to be left for the 'heavy' (the antiarmor guy).

 

If a soldier was able to carry unlimited rockets, I would encourage lowering the to-hit of the rocket launcher from 90 percent.

 

Question: If the heavy doesn't have the fire rocket perk, does the rocket tube still appear as part of his pawn?

 

I tested this out, and yes, the game is currently swapping out the pistol, removing the pistol slot and adding a second large item slot when the soldier becomes a Heavy class. So with just the perk tree change you end up with a Heavy soldier without Fire Rocket ability but also without a pistol, and carrying a rocket tube on his back.

 

In terms of perk choices .. well, since the decision as to which weapon is a battle-by-battle choice it's still possible to have perks that affect both, but you wouldn't be able to use them all on any particular mission.

 

Perks that are effective for Rocket + Pistol: (15 choices .. more than enough)

Fire Rocket -- maybe modified to improve aim chances, or required in order to equip the rocket launcher

Rocketeer -- Adds 1 charge to Rockets so that he doesn't have to spend a turn reloading after each shot

HEAT Ammo

Shredder Rocket -- not sure how to make this work with the idea of having to reload

Grenadier

Mayhem

Danger Zone

Gunslinger

Will to Survive

Squadsight ---- O_O --- imagine the mayhem of being able to shoot rockets out of line of sight ! this would be SERIOUS heavy support

Low Profile

Sprinter

Deep Pockets

Battlescanner

Damn Good Ground

 

 

Perks effective with LMG + Pistol: (17 that I've counted so far)

Bullet Swarm

Suppression

Holo Targeting

HEAT Ammo

Rapid Reaction

Sentinel

Aggression

 

Grenadier

Mayhem

Danger Zone

Gunslinger

Will to Survive

Low Profile

Sprinter

Deep Pockets

Battlescanner

Damn Good Ground

 

---------------------

 

To make the perk tree easier to parse, it could be arranged with rocket abilities on the right side, LMG abilities on the left side, and "shared" abilities in the middle. Maybe start off with the Bullet Swarm or Fire Rocket choice, which basically defines what type of Heavy weapon the soldier is specializing to.

Link to comment
Share on other sites

snap shot works with rockets too, in their face! bear in mind that danger zone and mayhem affect both rockets and machineguns, I like them more for machineguns though, on rockets it's kinda overpowered, that's the good thing about using different classes. For some time I played with machineguns on heavies, and without rockets, and leaving the second slot empty kind of feels right, since I assume a machinegunner must carry tons of ammo, so no backup choice for heavies, is fair enough to me. If keeping this idea of assigning roles to heavies, rocket+pistol vs machine gun + nothing else would seem a fair trade to me. The problem I had is that when using the rocket launcher from any slot that is not it's proper heavy slot, animations get messed and the tubes aren't in the back but hanging from the belt, so they seem to impale the soldiers, and equipping more than one would display them all... in the end the best place for it seemed to me it's original heavy 'special' slot... just FYI

In the Zone should belong to mg and/or units with low mobility imo. That's also a reason to separate rockets and mg in different classes or roles, one can blow up cover and the other provide massive fire

 

@Amineri, you could make that firing both regular or shredder rocket consumes both charges, and reloading gives again 1 of each, depending on the perks the unit's got it'll be able to fire regular or shredder rockets.

Edited by anUser
Link to comment
Share on other sites

@anUser


I think I know where to fix that the Rocket Launcher would be hanging from the belt instead of strapped to the back.

 

The soldier's TInventory structure is converted into a loadout in:

 

XGLoadoutMgr.ConvertTInventoryToSoldierLoadout

 

The Loadout.Items[##] assignment seems to determine where the item mesh is attached to the soldier

 

kInventory.arrLargeItems[0] goes into Loadout.Items[0] -- this puts the main weapon into slot 0

kInventory.arrLargeItems[1] goes into Loadout.Items[1] -- this puts the Rocket Launcher into slot 1

 

Any additional large items go into Loadout.Backpack

 

I think if we can simply force the rocket launcher into Loadout.Items[1] it would appear normally on the back. Ideally the soldier would start out with the pistol equipped/ready, and switch to Rocket Launcher when firing. I highly suspect that there isn't a move animation for the Rocket Launcher (especially since it is supposed to be move or fire only)

 

--------------------------------------------------------

 

 

Other loadout locations, if you are interested:

 

Loadout.Items[4] is reserved for the Grapple

Loadout.Items[6] is for the first small item (guessing this is the pistol)

Loadout.Items[11] is for the second small item

Loadout.Items[7] is for the third small item

 

Loadout.Items[15] is for eItem_PsiAmp

Loadout.Items[16] is for eItem_Plague

Loadout.Items[3] is for eItem_SectopodArm

 

 

Looking at the body meshes in umodel I see the following attachment points:

Inven_R_Knife (RigRArmHand)

Inven_R_Leg (RigRThigh)

Inven_R_Boot (RigRCalf)

Inven_L_Boot (RigLCalf)

Inven_L_Hand (Inven_L_Hand)

Inven_Grapple (RigLArmForearm)

Inven_R_Hand (Inven_R_Hand)

Inven_L_Back (RigSpine3)

Inven_L_Belt (RigPelvis)

Inven_RearBackPack (RigSpine1)

Inven_RightSling (RigPelvis)

Inven_B_Chest (RigRibcage)

Inven_Head (RigHead) -- interestingly, the head is modeled as a separate 'item' and attached like any other piece of gear :)

Link to comment
Share on other sites

new psi power... swap heads with an alien!

Thanks for the info, I'm fine by now with heavies carrying the rocket tube and regular rifle

 

Oh, that's another option I hadn't thought of. Assault Rifle + Rocket Launcher. That would probably work better in terms of models and animations than Rocket Launcher + Pistol.

 

I guess I was just thinking that the Rocket Launcher is a pretty heavy weapon so it would be all a soldier could carry. With the gunslinger perk a pistol can be basically as good as an assault rifle in terms of stats. Is it more of an aesthetic-type thing, or a balance thing you're thinking of?

 

Of course there's no 'right' answer -- that's what I love about this kind of thing :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...