New ability doesn't trigger properly

ITcore

Warlord
Joined
Dec 25, 2016
Messages
248
Location
127.0.0.1
I'm trying to give the Legion unit the Hoplites ability of extra strength when next to another Legion. However, with the code below, it always triggers, regardless of having a unit next to it. I'm adding that ability on top of the Anti-melee ability created by isau for his Combined Tweaks mod. So the end result should be +10 against melee units (works) and +10 when next to another Legion.

Code:
INSERT INTO Tags
(    Tag,             Vocabulary        )    VALUES
(    'CLASS_LEGION',    'ABILITY_CLASS'    );

INSERT INTO TypeTags
(    Type,                    Tag                )    VALUES
(    'UNIT_ROMAN_LEGION',    'CLASS_LEGION'    );

INSERT INTO TypeTags
(    Type,                        Tag                )    VALUES
(    'QUO_ABI_ANTI_MELEE',        'CLASS_LEGION'    ),
(    'ABILITY_LEGION_PHALANX',     'CLASS_LEGION'    );

-- Create a new ability that grants the Roman Legion an adjacency bonus to other Legions
-- Adjacent to another Legion?
INSERT INTO Requirements
(    RequirementId,                     RequirementType,                                         Likeliness,    Inverse,     Triggered    )    VALUES
(    'REQ_LEGION_PHALANX_ABILITY',     'REQUIREMENT_PLOT_ADJACENT_FRIENDLY_UNIT_TYPE_MATCHES',    0,            0,            0            );

INSERT INTO RequirementArguments
(    RequirementId,                    Name,             Type,                 Value,                         Extra,     SecondExtra    )    VALUES
(    'REQ_LEGION_PHALANX_ABILITY',    'UnitType',        'ARGTYPE_IDENTITY',    'UNIT_ROMAN_LEGION',        NULL,    NULL         );

INSERT INTO RequirementSets
(    RequirementSetId,                     RequirementSetType            )    VALUES
(    'REQSET_LEGION_PHALANX_ABILITY',     'REQUIREMENTSET_TEST_ALL'    );

INSERT INTO RequirementSetRequirements
(    RequirementSetId,                    RequirementId                    )    VALUES
(    'REQSET_LEGION_PHALANX_ABILITY',     'REQ_LEGION_PHALANX_ABILITY'    );

-- The modifier
INSERT INTO Modifiers
(    ModifierId,                 ModifierType,                             RunOnce,     Permanent,    OwnerRequirementSetId,    SubjectRequirementSetId            )    VALUES
(    'LEGION_PHALANX_ABILITY',     'MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH', 0,             0,            NULL,                     'REQSET_LEGION_PHALANX_ABILITY'    );

INSERT INTO ModifierArguments
(    ModifierId,                 Name,         Type,                     Value,         Extra,     SecondExtra    )    VALUES
(    'LEGION_PHALANX_ABILITY',     'Amount',     'ARGTYPE_IDENTITY',     '10',        NULL,     NULL        );

-- Create the ability
INSERT INTO Types
(    Type,                         Kind            )    VALUES
(    'ABILITY_LEGION_PHALANX',    'KIND_ABILITY'    );

INSERT INTO UnitAbilities
(    UnitAbilityType,             Name,                                 Description,                                 Inactive    )    VALUES
(    'ABILITY_LEGION_PHALANX',     'LOC_ABILITY_LEGION_PHALANX_NAME',    'LOC_ABILITY_LEGION_PHALANX_DESCRIPTION',     0            );

INSERT INTO UnitAbilityModifiers
(    UnitAbilityType,             ModifierId                    )    VALUES
(    'ABILITY_LEGION_PHALANX',    'LEGION_PHALANX_ABILITY'    );     

-- Add a string to describe the ability in combat previews
INSERT INTO ModifierStrings
(    ModifierId,                 Context,     Text                                                )    VALUES
(    'LEGION_PHALANX_ABILITY',     'Preview',     'LOC_ABILITY_LEGION_PHALANX_MODIFIER_DESCRIPTION'    );
 
First of all, I really like that idea. I had a similar idea for a historical legion ability. I tried to figure out how to add the "ranged attack then melee" ability the Zulu's unit had in Civ V to legions for their pilum strike, but I couldn't figure it out. Anyways, to (hopefully) answer your question, the hoplites ability seems to be broken regardless. It always has the "+10 adjacent to hoplite" bonus even when its 10 tiles away from any unit. Thats probably why you're running into trouble, because it doesn't work in the first place.
 
First of all, I really like that idea. I had a similar idea for a historical legion ability. I tried to figure out how to add the "ranged attack then melee" ability the Zulu's unit had in Civ V to legions for their pilum strike, but I couldn't figure it out. Anyways, to (hopefully) answer your question, the hoplites ability seems to be broken regardless. It always has the "+10 adjacent to hoplite" bonus even when its 10 tiles away from any unit. Thats probably why you're running into trouble, because it doesn't work in the first place.

Thanks! And that makes a lot of sense now. I never played as Greece so I had no idea the ability was broken. Good to know though.

As for your idea, the only way I could think of that working is if you added a ranged attack capability to the Legion and then gave them the Elite Guard promotion allowing a second attack in a turn. The modifier is MODIFIER_UNIT_ADJUST_NUM_ATTACKS. As of now, I don't think you can make each attack an exclusive ranged or melee attack.
 
Back
Top Bottom