Jump to content

Modding XCOM under Linux


wghost81

Recommended Posts

Hmmmm... interesting. its good to know its possible. technically with current setup you need to buy only 1 medikit for entie game if you use 1 medic per mission which is a big flaw. perks could be altered to function differently ie fiel medic heals 1 hp bar more, and grenadier can throw nades further.

 

however there would be a problem of only few items per mission. perhaps one grenadier perk coul remain the sme and if doable each time you use grenade one grenade item would be removed from storage. same with medic. could actions be altered in such a way to change item number in storage when performed?

Edited by Amphibious
Link to comment
Share on other sites

  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

The XGStorage class which holds all the items is in XComStrategyGame.upk, which is inaccessible during tactical gameplay, as the active "thread" is in XComGame.upk. For example we can't directly access the date/time info in XComStrategyGame, so for the time-based upgrades we have to pack info into the StrategyGameTransport class. The way this works is that the transport class data is filled out while the strategy game has control. StrategyGameTransport is actually defined in XComGame, and has most objects defined as import objects in XComStrategyGame ... hence the strategy game can fill out the data, which persists and is accessible within the tactical game.

 

The StrategyGameTransport holds quite a lot of info, including the TCharacter and TSoldier structures for each soldier (which are also maintained in the strategy side in XGStrategySoldier). The TCharacter structure contains a TInventory structure which contains the basic inventory information for each soldier. TInventory is pretty basic, just containing some arrays of EItem enum values. It allows a unit to have 1 armor item, 1 pistol item, 16 large items, 16 small items, and 16 custom items. However when the tactical game starts up there is a "loadout" process because the necessary machinery to maintain/display items requires more than just an enum for the weapon. Most of this is handled in the XGLoadoutMgr class, which converts the enum values to appropriate XGWeapon and XComWeapon classes, all of which is stored within an instance of the XGInventory class. Each XGUnit has it's own instance of XGInventory.

 

XGInventory has a quite different storage system than TInventory -- it's indexed by the attachments points on the unit pawn. There is a sort of "backpack" attachment point which is invisible and can store multiple items in an array. From what I've seen, regular soldiers only support loading out 2 large items -- the 1st goes into the right-back slot, and the 2nd goes into the left-back slot. Any additional go into the backpack slot. The small items put those items explicitly marked with the eWP_Backpack property into the backpack slot. Other items (e.g grenades) go into three different slots progressively -- any non-backpack item after the 3rd one is discarded (which is the source of the problem with mods that allow for more than 3 small item slots). It also seems that the structure used to save/restore XGInventory only saves up to 4 backpack items, which could also cause issues. MEC secondary weapon systems (which are large items also) use a different system, as each MEC secondary system has a new custom attachment point defined, which is only valid for MEC pawns.

 

Soo... as you can see, it's a bit of a mess with the translation between the strategy and tactical inventory systems. Strategy only uses the TInventory structure, and inventory information is transported to the tactical game using this structure via the StrategyGameTransport class. Once in the tactical game, the TInventory data is mapped into an XGInventory structure using the XGLoadoutMgr class. After the tactical mission is completed, the TCharacter and TSoldier structures attached to the XGUnit are copied back to the StrategyGameTransport which then updates the XGStrategySoldier versions back in the strategy game. In Long War I make use of this to set an upper bit of the Mind Control perk when a soldier successfully mind controls an Ethereal, which in Long War unlocks the ability to train Rift prior to entering the Gollop chamber.

 

So what has to happen would be writing new code in the locations where the items are used that would go through and decrement and repack the TInventory structure for the soldier (for example, if soldier had small items 1 and 2, and used item 1, item 2 has to be repacked into item slot 1 -- I think. Once the XGUnit's TCharacter structure (with it's embedded TInventory structure) is modified, it should automatically update back to the strategy game. This is why I recommend removing items from XGStorage.m_arrItems when equipping them if you want consumable items, as the item is removed from storage when equipped. If the item isn't used, it is unloaded from the soldier back into storage after the mission. If it is used, it simply isn't put back into storage, effectively decrementing the item count correctly.

 

Sorry for the rather long post, but it's the whole process is a little bit complex.

Link to comment
Share on other sites

Thanks for explaining Amineri. It's seems a lot of work.

 

Do you know perhaps how SW total loss option works? It only removes items equipped on soldier who die, right? Then the function is probably something like "if soldierstatus = dead then remove soldierinventory". Could it be enable as vanilla option and then reworked in a way to make you lose only equipment on dead soldiers if mission result is fail - function would have to be something like "if soldierstatus = dead and missionstatus = fail then remove soldierinventory". Could it be done without messing up the original total loss function?

 

My problem is I+m on Linux so UE explorer won't work natively to search for right part of the code. If someone could post the part of the code that enables and makes tl function i'd be very grateful.

 

This would make you lose equipment of dead soldiers if missiom has failed.

Link to comment
Share on other sites

The vanilla Total Loss is enabled in the XGFacility_Barracks.MoveToMorgue function. There is an m_bMIA flag potentially set for each soldier returning from a mission, although I feel the vanilla implementation is a bit messed up. In vanilla m_bMIA is set from m_bLeftBehind, which is only set when aborting a mission, and the soldier is outside the dropzone volume. In vanilla if the mission is a complete squadwipe then no gear is lost.

 

Mechanically how it is implemented in vanilla is that XGStorage has two different functions, ReleaseLoadout and RemoveLoadout. ReleaseLoadoud simply decrements the m_arrClaims counter, allowing the item to be claimed by another soldier. RemoveLoadout both decrements m_arrClaims and m_arrItems. If only m_arrItems were updated, the count of claimed items would be off.

Link to comment
Share on other sites

Each armor has it's number of small item slots configured individually in the DefaultGameCore.ini, so giving extra small item slots to particular armors is easy.

 

The tricky part is making particular slots only have particular item types available. This is possible though, as the large item code allows only non-rocket launcher large items in large item slot 0, and only rocket-launcher large items in large item slot 1. The function that has to be modded is XGFacility_Lockers.GetLockerItems. This function returns a list of all possible equippable items based on the item slot type and index (type = armor, large item, pistol, or small item, while index is the slot position within that category). This will basically require a rewrite of the hex code in the function to make it happen.

 

As an example, I'm putting the UPKmodder code below that we use in Long War to handle the MEC and SHIV item equipping. Note that we had to resize the function to fit in all of our goodies.

 

 

  Reveal hidden contents

 

 

If nothing else, at least having access to all of the vanilla hex broken down line-by-line might be useful.

 

The particular part of the vanilla code that handles rocket launchers is in case 2 :

//if(TACTICAL().GetTWeapon(iItem).iSize == 1)
07 1F 07 9A 35 BC FA FF FF A2 F9 FF FF 01 00 19 1B CB 2F 00 00 00 00 00 00 16 13 00 BF F8 FF FF 00 1B 92 13 00 00 00 00 00 00 00 00 39 00 00 16 26 16 

	//if((iSlotIndex == 0) && TACTICAL().WeaponHasAbility(iItem, 19))
	07 53 06 82 9A 00 07 39 00 00 25 16 18 2C 00 19 1B CB 2F 00 00 00 00 00 00 16 15 00 2E FF FF FF 00 1B 24 35 00 00 00 00 00 00 00 00 39 00 00 2C 13 16 16 

	//else
	06 1F 07 

		//if((iSlotIndex == 1) && !TACTICAL().WeaponHasAbility(iItem, 19))
		07 97 06 82 9A 00 07 39 00 00 26 16 18 2E 00 81 19 1B CB 2F 00 00 00 00 00 00 16 15 00 2E FF FF FF 00 1B 24 35 00 00 00 00 00 00 00 00 39 00 00 2C 13 16 16 16 
//else
06 1F 07

 

The "WeaponHadAbility(iItem, 19), is checking to see if the weapon has 19=eAbility_RocketLauncher attached to it in the DGC.ini. So weapons with Fire Rocket are excluded from slot index 0, and only weapons with Fire Rocket are allowed in slot index 1.

Link to comment
Share on other sites

It'll take some time for me process all of this.

 

I have alreay added second small item slot to medium armors, however I would like to prevent exploits like equipping 2 sets of grenades since my original intention was to allow players to bolster their armor without having to sacrifice other equipment

 

p.s. also a quick question - is this mod compatible with EW? i can't find the codes mentioned there in my upk files

 

edit: also if I add second slot to medium armors will that interfere with tactical rigging upgrade? so I will end up with redundant bugged 3rd slot? or will the number of slots stil remain 2?

 

how many large item slots are there available? could one make 2nd large item slot visible and then relabel nanoarmor vest and similar items as large item?

Edited by Amphibious
Link to comment
Share on other sites

  Quote

 

I have alreay added second small item slot to medium armors, however I would like to prevent exploits like equipping 2 sets of grenades since my original intention was to allow players to bolster their armor without having to sacrifice other equipment

On a non-technical note, if you can only use the extra slot to increase HP, why not just give the armor extra HP instead of requiring the player to equip an extra HP item (which would be the only option) ?
  Quote

 

edit: also if I add second slot to medium armors will that interfere with tactical rigging upgrade? so I will end up with redundant bugged 3rd slot? or will the number of slots stil remain 2?

There are some bugs associated with adding a third item slot. Basically the vanilla tactical rigging code assumes the soldier had 1 item slot before, which can cause cause an existing item in item slot 2 to be lost. Honestly off the top of my head I don't remember all the vanilla bugs associated with increasing the number of item slots...
  Quote

 

how many large item slots are there available? could one make 2nd large item slot visible and then relabel nanoarmor vest and similar items as large item?

Unfortunately the DGC.ini setting for iNumLargeItemSlots doesn't work, and the variable isn't even imported into the XComStrategyGame package, so it's not easy to mod to get working.
In vanilla the trigger for a second large item slot is hard-coded to be only for Heavy class. For Long War I changed the trigger to "has Fire Rocket perk", as well as adding large item slots for MECs to equip their secondary weapon systems (e.g. KSM, Flamethrower). Long War MEC-3 suits have 4 displayed large item slots (1 for rifle, 3 for secondary systems), so there's not really a limit.

 

 

Link to comment
Share on other sites

  On 7/25/2014 at 8:52 PM, Amineri said:

 

On a non-technical note, if you can only use the extra slot to increase HP, why not just give the armor extra HP instead of requiring the player to equip an extra HP item (which would be the only option) ?
There are some bugs associated with adding a third item slot. Basically the vanilla tactical rigging code assumes the soldier had 1 item slot before, which can cause cause an existing item in item slot 2 to be lost. Honestly off the top of my head I don't remember all the vanilla bugs associated with increasing the number of item slots...

 

Well that's not the point since it's not my intention to boost up hp but I felt nf vest and chitine plate are a waste of space in current format.

 

yes there is a bug i just tested it out. second slot item is removed/lost and grenade is equipped instead. i don't understand how or why that happens tbh. new slot is (3rd one) empty and first one is not touched, so why does grenade gets equipped in 2nd one is unclear to me. is there a way to fix it?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...