[NFP] Code not taking effect

Venemar

Chieftain
Joined
Feb 21, 2021
Messages
8
I'm borrowing code from a mod I love called Better Recon. I'm trying to add it into a unique unit from the custom Taino Civ I like but I'm having issues making it work. I'm not getting a failed mod, just no implementation. Need some help getting this to work please.

Quick review:
The Taino unique unit Macana replaces both Warrior and Scout. Is a base warrior (CS etc) but uses Recon promotion class, then later upgrades into Swordsman while keeping any Recon promotions it acquired.

This unit falls behind significantly however while using Better Recon, as every other civ has scouts flying around the map twice my speed or more. My attempt is to bring movement to an equal position.

I considered the CLASS_RECON that I've bolded at the bottom of of code was an issue, as Macana is technically a warrior. I tried changing this to CLASS_MELEE but that didn't work either. I will post the unedited Macana UU code in a seperate reply, maybe that's where the issue lies?

Here's the code from Better Recon, I replaced BETTER_RECON in all situations with MACANA.

-- Ignore Terrain Cost & Sight Range from Observation
INSERT INTO Modifiers (ModifierId, ModifierType, Permanent) VALUES
('MACANA_IGNORE_TERRAIN', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST', 1),
('MACANA_IGNORE_RIVERS', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_RIVERS', 1),
('MACANA_IGNORE_EMBARK', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_SHORES', 1);
INSERT INTO Modifiers (ModifierId, ModifierType, Permanent, SubjectRequirementSetId) VALUES
('MACANA_RECEIVE_SIGHT_RANGE_BONUS', 'MODIFIER_PLAYER_UNIT_ADJUST_SIGHT', 0, 'RANGE_BONUS_REQUIREMENTS');
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES
('MACANA_IGNORE_TERRAIN', 'Ignore', 1),
('MACANA_IGNORE_TERRAIN', 'Type', 'ALL'),
('MACANA_IGNORE_RIVERS', 'Ignore', 1),
('MACANA_IGNORE_EMBARK', 'Ignore', 1),
('MACANA_RECEIVE_SIGHT_RANGE_BONUS', 'Amount', 1);
INSERT INTO UnitAbilities(UnitAbilityType, Name, Description, Inactive) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'LOC_ABILITY_MACANA_IGNORE_TC_NAME', 'LOC_ABILITY_MACANA_IGNORE_TC_DESC', 0),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'LOC_ABILITY_MACANA_GRANT_SIGHT_BONUS_NAME', 'LOC_ABILITY_MACANA_GRANT_SIGHT_BONUS_DESC', 0);
INSERT INTO UnitAbilityModifiers(UnitAbilityType, ModifierId) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_TERRAIN'),
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_RIVERS'),
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_EMBARK'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'MACANA_RECEIVE_SIGHT_RANGE_BONUS');
INSERT INTO Types (Type, Kind) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'KIND_ABILITY'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'KIND_ABILITY');
INSERT INTO TypeTags(Type, Tag) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'CLASS_RECON'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'CLASS_RECON');
);
 
/*
UU
Authors: ChimpanG
*/
-----------------------------------------------
-- Types
-----------------------------------------------

INSERT INTO Types
(Type, Kind )
VALUES ('TRAIT_CIVILIZATION_CVS_TAINO_UU', 'KIND_TRAIT' ),
('UNIT_CVS_TAINO_UU', 'KIND_UNIT' ),
('ABILITY_CVS_TAINO_UU', 'KIND_ABILITY' ),
('MODTYPE_CVS_TAINO_UU_GRANT_YIELD', 'KIND_MODIFIER' ),
('MODTYPE_CVS_TAINO_UU_DISABLE_UNIT', 'KIND_MODIFIER' );
-----------------------------------------------
-- Tags
-----------------------------------------------

INSERT INTO Tags
(Tag, Vocabulary )
VALUES ('CLASS_CVS_TAINO_UU', 'ABILITY_CLASS' );
-----------------------------------------------
-- TypeTags
-----------------------------------------------
INSERT INTO TypeTags
(Type, Tag )
VALUES ('UNIT_CVS_TAINO_UU', 'CLASS_CVS_TAINO_UU' ),
('ABILITY_CVS_TAINO_UU', 'CLASS_CVS_TAINO_UU' );
INSERT INTO TypeTags (Type, Tag)
SELECT 'UNIT_CVS_TAINO_UU', Tag
FROM TypeTags
WHERE Type = 'UNIT_WARRIOR';
-----------------------------------------------
-- Traits
-----------------------------------------------

INSERT INTO Traits
(TraitType, Name )
VALUES ('TRAIT_CIVILIZATION_CVS_TAINO_UU', 'LOC_UNIT_CVS_TAINO_UU_NAME' );
-----------------------------------------------
-- CivilizationTraits
-----------------------------------------------

INSERT INTO CivilizationTraits
(CivilizationType, TraitType )
VALUES ('CIVILIZATION_CVS_TAINO', 'TRAIT_CIVILIZATION_CVS_TAINO_UU' );
-----------------------------------------------
-- Units
-----------------------------------------------

INSERT INTO Units (
UnitType,
Name,
Description,
TraitType,
BaseMoves,
Cost,
PurchaseYield,
AdvisorType,
Combat,
BaseSightRange,
ZoneOfControl,
Domain,
FormationClass,
PromotionClass,
Maintenance,
MandatoryObsoleteTech,
PrereqTech,
PrereqCivic
)
SELECT 'UNIT_CVS_TAINO_UU', -- UnitType
'LOC_UNIT_CVS_TAINO_UU_NAME', -- Name
'LOC_UNIT_CVS_TAINO_UU_DESCRIPTION', -- Description
'TRAIT_CIVILIZATION_CVS_TAINO_UU', -- TraitType
BaseMoves,
Cost,
PurchaseYield,
AdvisorType,
Combat, -- Combat
BaseSightRange,
ZoneOfControl,
Domain,
FormationClass,
'PROMOTION_CLASS_RECON', -- PromotionClass
Maintenance,
MandatoryObsoleteTech,
PrereqTech,
PrereqCivic
FROM Units
WHERE UnitType = 'UNIT_WARRIOR';
-----------------------------------------------
-- UnitUpgrades
-----------------------------------------------

INSERT INTO UnitUpgrades (Unit, UpgradeUnit)
SELECT 'UNIT_CVS_TAINO_UU', UpgradeUnit
FROM UnitUpgrades
WHERE Unit = 'UNIT_WARRIOR';
-----------------------------------------------
-- UnitAiInfos
-----------------------------------------------

INSERT INTO UnitAiInfos (UnitType, AiType)
SELECT 'UNIT_CVS_TAINO_UU', AiType
FROM UnitAiInfos
WHERE UnitType = 'UNIT_WARRIOR';

-----------------------------------------------
-- UnitReplaces
-----------------------------------------------

INSERT INTO UnitReplaces
(CivUniqueUnitType, ReplacesUnitType )
VALUES ('UNIT_CVS_TAINO_UU', 'UNIT_WARRIOR' );
-----------------------------------------------
-- UnitAbilities
-----------------------------------------------
INSERT INTO UnitAbilities
(UnitAbilityType, Name, Description )
VALUES ('ABILITY_CVS_TAINO_UU', 'LOC_ABILITY_CVS_TAINO_UU_NAME', 'LOC_ABILITY_CVS_TAINO_UU_DESCRIPTION' ),
VALUES ('ABILITY_CVS_TAINO_UU', 'LOC_ABILITY_CVS_TAINO_UU_NAME', 'LOC_ABILITY_CVS_TAINO_UU_DESCRIPTION' );
-- Ignore Terrain Cost & Sight Range from Observation
INSERT INTO Modifiers (ModifierId, ModifierType, Permanent) VALUES
('MACANA_IGNORE_TERRAIN', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST', 1),
('MACANA_IGNORE_RIVERS', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_RIVERS', 1),
('MACANA_IGNORE_EMBARK', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_SHORES', 1);
INSERT INTO Modifiers (ModifierId, ModifierType, Permanent, SubjectRequirementSetId) VALUES
('MACANA_RECEIVE_SIGHT_RANGE_BONUS', 'MODIFIER_PLAYER_UNIT_ADJUST_SIGHT', 0, 'RANGE_BONUS_REQUIREMENTS');
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES
('MACANA_IGNORE_TERRAIN', 'Ignore', 1),
('MACANA_IGNORE_TERRAIN', 'Type', 'ALL'),
('MACANA_IGNORE_RIVERS', 'Ignore', 1),
('MACANA_IGNORE_EMBARK', 'Ignore', 1),
('MACANA_RECEIVE_SIGHT_RANGE_BONUS', 'Amount', 1);
INSERT INTO UnitAbilities(UnitAbilityType, Name, Description, Inactive) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'LOC_ABILITY_MACANA_IGNORE_TC_NAME', 'LOC_ABILITY_MACANA_IGNORE_TC_DESC', 0),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'LOC_ABILITY_MACANA_GRANT_SIGHT_BONUS_NAME', 'LOC_ABILITY_MACANA_GRANT_SIGHT_BONUS_DESC', 0);
INSERT INTO UnitAbilityModifiers(UnitAbilityType, ModifierId) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_TERRAIN'),
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_RIVERS'),
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_EMBARK'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'MACANA_RECEIVE_SIGHT_RANGE_BONUS');
INSERT INTO Types (Type, Kind) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'KIND_ABILITY'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'KIND_ABILITY');
INSERT INTO TypeTags(Type, Tag) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'CLASS_MELEE'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'CLASS_MELEE');
);
-- Reduce Movement Speed
UPDATE Units
SET BaseMoves = BaseMoves + 1
WHERE UnitType IN (
SELECT UnitType FROM Units WHERE UnitType IN ('UNIT_CVS_TAINO_UU')
UNION
SELECT CivUniqueUnitType FROM UnitReplaces WHERE ReplacesUnitType IN ('UNIT_CVS_TAINO_UU')
-----------------------------------------------
-- TraitModifiers
-----------------------------------------------
INSERT INTO TraitModifiers
(TraitType, ModifierId )
VALUES ('TRAIT_CIVILIZATION_CVS_TAINO_UU', 'MODIFIER_CVS_TAINO_UU_DISABLE_SCOUT' );
-----------------------------------------------
-- UnitAbilityModifiers
-----------------------------------------------

INSERT INTO UnitAbilityModifiers
(UnitAbilityType, ModifierId )
VALUES ('ABILITY_CVS_TAINO_UU', 'MODIFIER_CVS_TAINO_UU_POST_FAITH' );
-----------------------------------------------
-- DynamicModifiers
-----------------------------------------------
INSERT INTO DynamicModifiers
(ModifierType, CollectionType, EffectType )
VALUES ('MODTYPE_CVS_TAINO_UU_GRANT_YIELD', 'COLLECTION_UNIT_COMBAT', 'EFFECT_ADJUST_UNIT_POST_COMBAT_YIELD' ),
('MODTYPE_CVS_TAINO_UU_DISABLE_UNIT', 'COLLECTION_OWNER', 'EFFECT_ADJUST_PLAYER_UNIT_BUILD_DISABLED' );
-----------------------------------------------
-- Modifiers
-----------------------------------------------
INSERT INTO Modifiers
(ModifierId, ModifierType, SubjectRequirementSetId, Permanent, RunOnce )
VALUES ('MODIFIER_CVS_TAINO_UU_POST_FAITH', 'MODTYPE_CVS_TAINO_UU_GRANT_YIELD', NULL, 0, 0 ),
('MODIFIER_CVS_TAINO_UU_DISABLE_SCOUT', 'MODTYPE_CVS_TAINO_UU_DISABLE_UNIT', NULL, 0, 0 );
-----------------------------------------------
-- ModifierArguments
-----------------------------------------------
INSERT INTO ModifierArguments
(ModifierId, Name, Value )
VALUES ('MODIFIER_CVS_TAINO_UU_POST_FAITH', 'YieldType', 'YIELD_FAITH' ),
('MODIFIER_CVS_TAINO_UU_POST_FAITH', 'PercentDefeatedStrength', 50 ),
('MODIFIER_CVS_TAINO_UU_DISABLE_SCOUT', 'UnitType', 'UNIT_SCOUT' );
-----------------------------------------------
-- MomentIllustrations
-----------------------------------------------
INSERT INTO MomentIllustrations
(MomentIllustrationType, MomentDataType, GameDataType, Texture )
VALUES ('MOMENT_ILLUSTRATION_UNIQUE_UNIT', 'MOMENT_DATA_UNIT', 'UNIT_CVS_TAINO_UU', 'Moment_UniqueUnit_CVS_Macana' );
 
Well, this bit right here is a syntax error
Code:
INSERT INTO UnitAbilities
(UnitAbilityType, Name, Description )
VALUES ('ABILITY_CVS_TAINO_UU', 'LOC_ABILITY_CVS_TAINO_UU_NAME', 'LOC_ABILITY_CVS_TAINO_UU_DESCRIPTION' ),
VALUES ('ABILITY_CVS_TAINO_UU', 'LOC_ABILITY_CVS_TAINO_UU_NAME', 'LOC_ABILITY_CVS_TAINO_UU_DESCRIPTION' );
Because the database does not allow two rows within table UnitAbilities that have the same designation for UnitAbilityType. Nor can you structure an insert like that. The second "VALUES" command is in itself another fatal syntax error.

Nothing below that error will be implemented by the game.

If this is actually in the original mod code welp the mod author really did not do a thurough job of debugging the code.

This does not look right either
Code:
-- Reduce Movement Speed
UPDATE Units
SET BaseMoves = BaseMoves + 1
WHERE UnitType IN (
SELECT UnitType FROM Units WHERE UnitType IN ('UNIT_CVS_TAINO_UU')
UNION
SELECT CivUniqueUnitType FROM UnitReplaces WHERE ReplacesUnitType IN ('UNIT_CVS_TAINO_UU')
Three '(' but only two ')' and no terminating ';' Besides which even without the syntax issues in this second suspect code-chunk the logic does not make much sense to me on several levels.
 
Last edited:
Not sure what happened there with that syntax error. I'm guessing when I was copy/pasting I added it incorrectly. I also removed the movement section altogether to focus on the core element. Plugging it into SQLite to query still showing a FOREIGN KEY constraint failed. Here's what I'm working with now.

-----------------------------------------------
-- UnitAbilities
-----------------------------------------------
INSERT INTO UnitAbilities
(UnitAbilityType, Name, Description )
VALUES ('ABILITY_CVS_TAINO_UU', 'LOC_ABILITY_CVS_TAINO_UU_NAME', 'LOC_ABILITY_CVS_TAINO_UU_DESCRIPTION' );
-- Ignore Terrain Cost & Sight Range from Observation
INSERT INTO Modifiers (ModifierId, ModifierType, Permanent) VALUES
('MACANA_IGNORE_TERRAIN', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST', 1),
('MACANA_IGNORE_RIVERS', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_RIVERS', 1),
('MACANA_IGNORE_EMBARK', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_SHORES', 1);
INSERT INTO Modifiers (ModifierId, ModifierType, Permanent, SubjectRequirementSetId) VALUES
('MACANA_RECEIVE_SIGHT_RANGE_BONUS', 'MODIFIER_PLAYER_UNIT_ADJUST_SIGHT', 0, 'RANGE_BONUS_REQUIREMENTS');
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES
('MACANA_IGNORE_TERRAIN', 'Ignore', 1),
('MACANA_IGNORE_TERRAIN', 'Type', 'ALL'),
('MACANA_IGNORE_RIVERS', 'Ignore', 1),
('MACANA_IGNORE_EMBARK', 'Ignore', 1),
('MACANA_RECEIVE_SIGHT_RANGE_BONUS', 'Amount', 1);
INSERT INTO UnitAbilities(UnitAbilityType, Name, Description, Inactive) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'LOC_ABILITY_MACANA_IGNORE_TC_NAME', 'LOC_ABILITY_MACANA_IGNORE_TC_DESC', 0),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'LOC_ABILITY_MACANA_GRANT_SIGHT_BONUS_NAME', 'LOC_ABILITY_MACANA_GRANT_SIGHT_BONUS_DESC', 0);
INSERT INTO UnitAbilityModifiers(UnitAbilityType, ModifierId) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_TERRAIN'),
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_RIVERS'),
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'MACANA_IGNORE_EMBARK'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'MACANA_RECEIVE_SIGHT_RANGE_BONUS');
INSERT INTO Types (Type, Kind) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'KIND_ABILITY'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'KIND_ABILITY');
INSERT INTO TypeTags(Type, Tag) VALUES
('ABILITY_MACANA_IGNORE_TERRAIN_COST', 'CLASS_MELEE'),
('ABILITY_MACANA_GRANT_SIGHT_BONUS', 'CLASS_MELEE');
 
Back
Top Bottom