Jump to content

R&D Modding Ammo


Amineri

Recommended Posts

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

Only other poossible thing I can think of is how having an item equipped could help with ammo conservation, if possible with a new perk or hidden perk/variable, something to tie in with your extra item modlet.

Link to comment
Share on other sites

6 shots is another number with weird outcomes, 16*6 = 96. Might set Apply Ammo Cost to <=4, which will handle more remainders (such as 6, 7 and 12 round magazines, if my math is right.)

 

I was definitely going to change the ApplyAmmoCost to use a <= instead of an == test to ensure that negative ammo counts aren't possible.

 

If I can change the max ammo to 120 that will handle the six shot case (20 ammo used), and 8 shots would be 12 ammo used per shot, but 7 and 9 shots wouldn't divide evenly. To get an ammo count to handle 7 and 9 means increasing the number to 120*7*3 = 2520, which starts making you all do a bit more math, plus I'd have to expand the size of the modulo and divisor to cover up to 4 digits instead of 2.

 

Regarding the modulo and division operators... they are used with integers when selecting pod sizes in XGStrategyAI here:

 

    iMinPods = iNumAliens / 3;
    if((iNumAliens % 3) != 0)
    {
        iMinPods += 1;
    }

 

So, they should be pretty safe to use for the ammo as well.

Link to comment
Share on other sites

Only other poossible thing I can think of is how having an item equipped could help with ammo conservation, if possible with a new perk or hidden perk/variable, something to tie in with your extra item modlet.

 

I like the idea! An "Extra Ammo" item.

 

Any thought on how people would like the functionality to work, given that every weapon can have its own custom ammo usage defined?

 

I'd think that separate ammo types for ballistic / laser / plasma would be appropriate. Probably would want to limit to only one set of extra ammo carried as well?

Link to comment
Share on other sites

You're using isuppression as the % decrement per shot, right?

 

So you would set the value this way:

 

For 1 shot per mag: enter 99 (implies a remainder of 1)

2: 50

3: 33 (remainder 1)

4: 25

5: 20

6: 16 (rem 4)

7: 14 (rem 2)

8: 12 (rem 4)

9: 11 (rem 1)

10: 10

11: 9 (rem 1)

12: 8 (rem 4)

13: won't work

14: 7 (rem 2)

15: won't work

16: 6 (rem 4)

17: won't work

18: won't work

19: won't work

20: 5

 

If I'm understanding right, if you set the function to set any remainder of 4 or less to 0, you can get up to 12 shots per magazine with this system. IMO, any more than that and you might as well give the weapon unlimiited ammo.

 

I like the "high capacity magazines" small item proposal, as well.

Edited by johnnylump
Link to comment
Share on other sites

Excellent progress.

 

If I may suggest, ive gota couple of ideas regarding ammoitems

1. Soldiers have like 6 inventory items and they can equip as many ammo items they want, on reloadingan ammoitem is removed, if no ammo item is present, firing the weapon depletes its ammo, causing it to have to reload. It is an extreme option but I think it can be cool as it disencourage taking low percent shots and planning offensive actions more carefuly and not just returning fire

2. Only 1 ammo item is allowed. Depending on its price and tech needed to develop it, it grants certain bonus. Explosive ammo could have heat ammo bonus, tracer bullets, etc. Bigger magazines of regular bullets could be at the same level, forcing the player to choose between powerful ammo or the foundry bonus in the form of a bigger ammo item. There are 2 possible implementations i foresee with this option, 1 making ammo items consumible so its a financial choice, or with infinite items make them available through research. In the later case theres still the choice of equipping another item or ammo items that grant bonus

Link to comment
Share on other sites

If I'm understanding right, if you set the function to set any remainder of 4 or less to 0, you can get up to 12 shots per magazine with this system. IMO, any more than that and you might as well give the weapon unlimiited ammo.

 

I like the "high capacity magazines" small item proposal, as well.

I concur: Giving too much ammo to soldiers amounts to breaking a game dynamic (properly evaluate shooting v/s losing a turn reloading), and ends up giving a less stressful enviroment when in "close battles" (6+ aliens v/s 6 soldiers). Too much ammo = shoot until dead, we have reserves.

 

8-6(HVY) shots is good, perhaps 12-9(HVY) is kind of overkill.

Edited by osito2dancer
Link to comment
Share on other sites

@ JL ...

 

I like your system. It'll be a lot easier to implement (and update if a new patch comes out) then trying to rework to a base 120 system.

 

Since only certain ammo values are "valid" I'm thinking of internalizing the conversion from NumShots to %Ammo used into the GetAmmoCost function. That means that you'd set the number of shots for each weapon, with and without ammo conservation.

 

So, for a 3 shot LMG that gets 5 shots with Ammo Conservation, the setup would be:

 

iSuppression = 503,

 

Since the %ammo used is just the division of 100 / NumShots (with fraction discarded), it can be easily calculated in GetAmmoCost.

 

It's too bad I can't access the XGWeapon.Init function (it's a native function). Then I could just set the iAmmo value equal to the number of shots when the weapon was initialized, and subtract 1 each time it was fired (or 2 for Suppression). Alas, I shall muddle through regardless.

 

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

 

As to the extra ammo upgrade.... had another thought on this. Each extra ammo item would +1 the number of shots taken (regardless of weapon or ammo conservation).

 

If I use the above it would be easy to +1 the NumShots for each extra ammo item.

 

As to limiting the extra ammo based on weapon type ... I think that would have to be done separately in the strategy game loadout section (preventing wrong extra ammo from being loaded based on current weapon type).

 

I'm leaning toward implementing this as a perk. Reasoning for this:

1) SHIVs have no backpack loadout space -- making it a perk allows the perk to be granted as a side-effect of equipping the item, allowing SHIVs to partake of the extra ammo functionality

2) It would open up an additional option in the soldier perk trees

3) Soldiers can still have an extra ammo item by making the item grant the perk

 

Here is my first cut at code to allow perk / items for extra ammo:

	iAdjustment = 0;
	if(m_kWeapon.HasProperty(eWP_UnlimitedAmmo)) ((10))
	{
		return 0;
	}
	if(m_kWeapon.IsMelee())
	{
		return 0;
	}
	if(!bCantLose) // doesn't have bHasAmmoConservation
	{
		iFactor = m_kWeapon.m_kTWeapon.iSuppression % 100; // get NumShots -- no Ammo Conservation
	}
	else // has ammo conservation
	{
		iFactor = m_kWeapon.m_kTWeapon.iSuppression / 100; // get NumShots -- w/ Ammo Conservation
	}
	iSoldiers = m_kUnit.m_kCharacter.m_kChar.aUpgrades[12]; // store perk 12 (vanilla ButtonUp) for later checks
	if ((iSoldiers & 1) >  0) // explicitly test for perk 12 (vanilla ButtonUp) assigned through perk tree
	{
		iFactor += 2; // add 2 shots for perk -- can be customized separately from item count
	}
	if(iSoldiers & 254) >  0) // explicitly test for perk 12 (vanilla ButtonUp) assigned via items
	{
		iFactor += 1*(iSoldiers >> 1); // add shots equal to the number of equipped items
	
	iAdjustment = 100 / iFactor; // convert NumShots into Ammo Used -- valid for 12 or fewer shots
	}
	if (GetType() == eAbility_ShotSuppress) ((17))
	{
		iAdjustment = 2 * iAdjustment;
	}
	if (GetType() == eAbility_ShotFlush) ((12))
	{
		iAdjustment = 1 * iAdjustment;
	}
	return iAdjustment;

It allows for separate setting of extra ammo granted by the perk and via items (default above is +2 shots for perk, and +1 shot for each extra item). These extra shots are not increased by the Foundry project Ammo Conservation.

 

The perk ButtonUp (12) is built in the PerkManager, but my earlier testing and code-searching showed no functionality for it. It is currently defined in XComPerkManager.BuildPerkTables via the line:

    BuildPerk(12, 0, "ButtonUp");

Clearly it would need a new imageicon and localization text.

Link to comment
Share on other sites

My initial tests were partly successful.

 

Regular shots had modified ammo counts (I tested with 3 shots for Assault Rifle and 2 shots for pistol -- and accidentally 1 shot for Sniper Rifles <.<;) I made the default behavior 1 shot if the iSuppression field is left zero.

 

However, I'm getting a Crash-To-Desktop when the reaction fire check tests to see if there is sufficient ammo. I'm thinking that the ShotStandard ability doesn't have an attached weapon the way I'm calling it or something, so the mod still needs a bit more work.

 

My current testing is using the standard GetAmmoCost function for reaction fire and the new one for active shots and display in the TacticalHUD_WeaponPanel.

 

Getting close, though !

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...