Jump to content

Grenade slot/grenadier test - grenade slot & unexpected behavior


BadgerBrownCoat

Recommended Posts

(from steam workshop thread)
testing complete - and... weird.. and interesting.

I did a mini-mod test:

  • Test 1:
    gave the Grenadier at squaddie promotion "Lightning Reflexes" ability, removed second weapon ( GL) :
    - received on promotion, no grenade launcher, no extra grenade ( and i got to watch the intro to grenadier movies - animation and no launcher - funny stuff )...
    * however, the placeholder ability was over-riden, on promotion he received BOTH corporal abilities : Blast Padding and Shredder
  • Test 2:
    gave the Grenadier at squaddie promotion " Launch Grenade" ability, removed 2nd weapon
    > upon promotion, the character was still unable to equip grenade launcher HOWEVER had the 3rd 'grenade' utility slot ( as per the 'Grenadier's Armory' mod )

SO - it is , in fact, apparently the 'launch grenade' ability that gives the third (grenade) slot -
expected behavior to be tested is that it will be consistent with as observed in the Grenadier's Armory mod : that the extra grenade slot, despite the ability name, only benefits from the extra range and and radius with the secondary weapon Grenade Launcher equipped ( as when equipping the flamethrower instead of the GL in the G's Armory mod ).

@ShadowDragon8685 : so, you could add that ability, "launch Grenade" to any character, despite the name it seem to really mean " open grenade-only slot" - pretty much what you were looking for, I believe - and surely ideal for my SMG-totin', grenade-packing Commando class...
I'm sure in the localization file, the name could be changing to 'chuck grenade' or whatever you like ...
@traenol27 - hope that helps, shines some light on some unexpected behaviors

Edited by BadgerBrownCoat
Link to comment
Share on other sites

Well ... bad coding practices aside ...

XComGameState_Unit.uc:

function bool HasGrenadePocket()
{
    return (!IsMPCharacter() && HasSoldierAbility('LaunchGrenade'));
} 

What?

 

A better option would be to use something like below(as this is the code that actually appears to give the unit the grenade, with the added bonus of not having a useless skill, I have not tested though)

X2Ability_GrenadierAbilitySet.uc:

function GrenadePocketPurchased(XComGameState NewGameState, XComGameState_Unit UnitState)
{
    local X2ItemTemplate FreeItem;
    local XComGameState_Item ItemState;

    if (!UnitState.HasGrenadePocket())
    {
        `RedScreen("GrenadePocketPurchased called but the unit doesn't have one? -jbouscher / @gameplay" @ UnitState.ToString());
        return;
    }
    FreeItem = class'X2ItemTemplateManager'.static.GetItemTemplateManager().FindItemTemplate(default.FreeGrenadeForPocket);
    if (FreeItem == none)
    {
        `RedScreen("Free grenade '" $ default.FreeGrenadeForPocket $ "' is not a valid item template.");
        return;
    }
    ItemState = FreeItem.CreateInstanceFromTemplate(NewGameState);
    NewGameState.AddStateObject(ItemState);
    if (!UnitState.AddItemToInventory(ItemState, eInvSlot_GrenadePocket, NewGameState))
    {
        `RedScreen("Unable to add free grenade to unit's inventory. Sadness." @ UnitState.ToString());
        return;
    }
}
Link to comment
Share on other sites

 

Well ... bad coding practices aside ...

XComGameState_Unit.uc:

function bool HasGrenadePocket()
{
    return (!IsMPCharacter() && HasSoldierAbility('LaunchGrenade'));
} 

What?

! IN DEED !

... as an aside \ update - it seems that when a soldier with the "Launch Grenade" ability merely throws a grenade, it crashes the game - clearly not meant to just sneak that in there -

seems to get the same crash in the Grenadier Armory mod - at least so it is claimed in the bug reports - if a "grenadier" with non-GrenadeLauncher 2ndary weapon (flamethrower) throws a grenade - seems using the grenadier as placeholder for heavy weapons specialist is rife with traps.

( nevermind the animation bug where it's still holding it's " not a grenade launcher" weapon - but firing from the cannon on it's belt - from the ankle-level barrel ).

Curiouser and curiouser.

 

Traenol, my thanks - i would have kept looking for the "adds a grenade pocket" in the ini files, and remain flummoxed.

Edited by BadgerBrownCoat
Link to comment
Share on other sites

 

Traenol, my thanks - i would have kept looking for the "adds a grenade pocket" in the ini files, and remain flummoxed.

 

No problem ... I am still trying to get this skill working the way I want it to so I know whether or not I can do what I plan on doing.

Link to comment
Share on other sites

Well, after much searching, debugging, trial and error, and hair pulling ... I finally found the bugger all of this.

case eInvSlot_GrenadePocket:
	if (!HasGrenadePocket())
		return false;
	if (GetItemInSlot(eInvSlot_GrenadePocket, CheckGameState) != none)
		return false;
	return (GrenadeTemplate != none); 

It all comes back to one function, every time, the aforementioned HasGrenadePocket, which is hard coded to check for the LaunchGrenade skill ... which apparently was written to save themselves 10 minutes of time coding it correctly.

 

If someone could perhaps poke Firaxis into fixing this code ... and maybe implementing HasAmmoPocket(which would be cool to have as well). I suppose an override to the gamestate unit class and correcting the code to not check for a specific skill but instead check that it has an appropriate flag would resolve the bugs being seen currently.

 

Another possibility would be someone taking on the enormous endeavor of doing a massive override job to build a framework mod that would allow modders to have a much better access point to things ... but I doubt that will happen soon, or be very easy. Not to mention the headache of incompatibilities, override conflicts, and other shenanigans.

Link to comment
Share on other sites

edit: i was typing this before I saw you'd just posted - my apologies -
and... well.. indeed. Just - indeed. AND GOOD GRIEF, I'm sorry now to have been a part of putting you through this.
my post was

Allright, it's been mentioned it's difficult to mod the default items - I can rarely find half their attributes - this gave me a real headache when trying to work with kevlar armor and the nanovest for my armor mod, but that's another story ( i just wanted "intermediate armor" that's made instead of the nanovest, and us ethe kevlar armor content for looks, until you get plated armor. sound so easy )...
ANYWAY:

I see how to add an entirely new weapon or armor - there's help with that-
what i don't get is how to apply that to an existing class, 'm sure it's simple and my not-having coded for half a lifetime is why i don't get it.

The next logical test is to make the grenade launcher have the ability- like this:

// Enhancements we're making to base
//=====================================================================
Template.BaseDamage.Damage += 2; //Boost damage
Template.CritChance += 5; //Boost crit
Template.Abilities.AddItem('Suppression'); //This weapon confers suppression
Template.GameArchetype = "WP_ModExampleWeapon_CV.WP_ModExampleWeapon_CV"; //Use a custom archetype
//===

i just need to know how to plug in "Template.Abilities.AddItem('Suppression'); //This weapon confers suppression"
so that it is Template.Abilities.AddItem('LaunchGrenade');

embarrassing, but i just don't get it- or I don't get how to do that with mod boddy, i should say.

Edited by BadgerBrownCoat
Link to comment
Share on other sites

i just need to know how to plug in "Template.Abilities.AddItem('Suppression'); //This weapon confers suppression"

so that it is Template.Abilities.AddItem('LaunchGrenade');

 

embarrassing, but i just don't get it- or I don't get how to do that with mod boddy, i should say.

I'd suggest taking a look at how other items add abilities, like Mimic Beacon and SkullJack ... x2Ability_ItemGrantedAbilitySet.uc

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...