Can we increase range of Machine gun by 1?

IIRC: unit attributes are fixed when you build them, the game doesn't fish them out form the unit type it is every time.

So the solution is to delete your units and build new ones. Or start a new game. Generally changing what a mod does mid-game causes more headaches than it's worth.

You're right. I only had to load a save game about 8-turns earlier when I paid gold to upgrade all my Minutemen to Machine Guns, this time with the Units.xml file already changed to Range = "2" when I upgraded and they all ended up with a range of 2.
 
This is my first time seeing this thread.

My "Combined Tweaks" mod does have a kind-of enlarged large Zone of Control ability. Pike units (anti-calvary) receive an ability that reduces by 1 the movement of any Calvary unit within 2 tiles.

There are some caveats associated with this:
  • I used a method similar to the Indian Varu unit. Basically it broadcasts a debuff over every unit on the map and only turns it on if the unit is adjacent. I am unclear on whether this creates a performance hit due to all the debuffs everywhere.
  • Because there is no way I know of to set Movement to a specific value, I had to settle for subtracting move points. If a unit's Move points drop below 1, it literally can do nothing that turn. It can't attack, move, etc. I just went with it since Pikes are otherwise so underwhelming. But basically in my mod Horse units have around 5 move points, and if there are enough Pikes nearby they can halted in their tracks completely.

Here is how the code works. One modifier (QUO_MOD_PIKEMAN_DEBUFF) broadcasts the debuff, the second modifier (QUO_MOD_PIKEMAN_DEBUFF_2) applies it. Because 2 modifiers are used I can have a different requirement set for each. The broadcast modifier checks for adjacency, and the debuff modifier checks the unit's class.

Code:
INSERT INTO Requirements
    (RequirementId,         RequirementType,     Likeliness,    Inverse,     Triggered)
VALUES    ('QUO_REQ_PIKEMAN_ADJACENT',     'REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR',    0,0,0)  ,
    ('QUO_REQ_OWNER_HEAVY_CALVARY',     'REQUIREMENT_UNIT_PROMOTION_CLASS_MATCHES',    0,0,0) ,
    ('QUO_REQ_OWNER_LIGHT_CALVARY',     'REQUIREMENT_UNIT_PROMOTION_CLASS_MATCHES',    0,0,0) ;


INSERT INTO RequirementArguments
    (RequirementId,            Name,             Type,             Value,                 Extra,     SecondExtra)
VALUES     ('QUO_REQ_PIKEMAN_ADJACENT',    'MaxDistance',    'ARGTYPE_IDENTITY',    '1',    NULL,    NULL     ) ,
    ('QUO_REQ_PIKEMAN_ADJACENT',    'MinDistance',    'ARGTYPE_IDENTITY',    '2',    NULL,    NULL     ) ,
    ('QUO_REQ_OWNER_HEAVY_CALVARY',    'UnitPromotionClass',    'ARGTYPE_IDENTITY',    'PROMOTION_CLASS_HEAVY_CAVALRY',    NULL,    NULL     ) ,
    ('QUO_REQ_OWNER_LIGHT_CALVARY',    'UnitPromotionClass',    'ARGTYPE_IDENTITY',    'PROMOTION_CLASS_LIGHT_CAVALRY',    NULL,    NULL     );


INSERT INTO RequirementSets
    (RequirementSetId,         RequirementSetType)
VALUES     ('QUO_REQSET_PIKEMAN_ADJACENT',     'REQUIREMENTSET_TEST_ALL') ,
    ('QUO_REQSET_OWNER_IS_CALVARY',     'REQUIREMENTSET_TEST_ANY') ;
 

INSERT INTO RequirementSetRequirements
    (RequirementSetId,    RequirementId)
VALUES    ('QUO_REQSET_PIKEMAN_ADJACENT',     'QUO_REQ_PIKEMAN_ADJACENT') ,
    ('QUO_REQSET_OWNER_IS_CALVARY',     'QUO_REQ_OWNER_HEAVY_CALVARY') ,
    ('QUO_REQSET_OWNER_IS_CALVARY',     'QUO_REQ_OWNER_LIGHT_CALVARY') ;


INSERT INTO Modifiers
    (ModifierId, ModifierType, RunOnce, Permanent, OwnerRequirementSetId, SubjectRequirementSetId)
VALUES    ('QUO_MOD_PIKEMAN_DEBUFF', 'MODIFIER_ALL_UNITS_ATTACH_MODIFIER', 0, 0, NULL, 'QUO_REQSET_PIKEMAN_ADJACENT') ,
    ('QUO_MOD_PIKEMAN_DEBUFF_2', 'MODIFIER_PLAYER_UNIT_ADJUST_MOVEMENT', 0, 0, NULL, 'QUO_REQSET_OWNER_IS_CALVARY') ;


INSERT INTO ModifierArguments
    (ModifierId,             Name,         Type,             Value,         Extra,     SecondExtra)
VALUES    ('QUO_MOD_PIKEMAN_DEBUFF',     'ModifierId',     'ARGTYPE_IDENTITY',     'QUO_MOD_PIKEMAN_DEBUFF_2',        NULL,     NULL) ,
    ('QUO_MOD_PIKEMAN_DEBUFF_2',         'Amount',     'ARGTYPE_IDENTITY',     '-1',        NULL,     NULL) ;
INSERT INTO Types
    (Type,                 Kind)
VALUES     ('QUO_ABI_PIKEMAN_DEBUFF',    'KIND_ABILITY'    ) ;


-- Create the ability
INSERT INTO UnitAbilities
    (UnitAbilityType,         Name,                     Description,                     Inactive)
VALUES     ('QUO_ABI_PIKEMAN_DEBUFF',     'LOC_QUO_ABI_PIKEMAN_DEBUFF_NAME',    'LOC_QUO_ABI_PIKEMAN_DEBUFF_DESCRIPTION',     0) ;


INSERT INTO UnitAbilityModifiers
    (UnitAbilityType,     ModifierId)
VALUES     ('QUO_ABI_PIKEMAN_DEBUFF',    'QUO_MOD_PIKEMAN_DEBUFF') ;


INSERT INTO TypeTags
    (Type,                    Tag)
VALUES  ('QUO_ABI_PIKEMAN_DEBUFF',         'CLASS_ANTI_CAVALRY') ;
 
SQL
Code:
UPDATE Units SET Range = 2 WHERE UnitType = 'UNIT_MACHINE_GUN';
 
Top Bottom