Thalassicus / cep-bnw

Civ V Communitas Expansion Pack
32 stars 22 forks source link

Swedish Allotment #253

Open GrantSP opened 10 years ago

GrantSP commented 10 years ago

First time I have actually played as Sweden, and I am examining the trait to see how it plays. Possible updates may occur after each new unit line is researched.

Upon researching The Wheel I was expecting to receive a Chariot Archer and didn't.

Is this because no Horses were yet connected? If so perhaps it would be better to grant it and take the penalty for no resources in the same manner of City-State gifts. EDIT: On this turn the logs show an error in CEL_Events.lua, MT_Events.lua & MT_Player.lua related to a missing UnitID

Runtime Error: ...\Tools\ClassMethods\MT_Player.lua:486: attempt to index field '?' (a nil value) stack traceback: ...\Tools\ClassMethods\MT_Player.lua:486: in function 'GetUniqueUnitID' ...\Leaders/CEL_Events.lua:171: in function <...)\Leaders/CEL_Events.lua:141> =[C]: ? =[C]: in function 'NewTech' ...\Tools\Core\MT_Events.lua:411: in function <...\Tools\Core\MT_Events.lua:408>

Perhaps a check for resource based units needs another error check?

Thalassicus commented 10 years ago

Those functions don't check resource requirements. My guess would be a misspelled chariot class in the data. I'd check that. If that's not the issue, well the unit reference is nil, so I'd add this debug message to GetUniqueUnitID:

        for itemInfo in GameInfo.Civilization_UnitClassOverrides(query) do
            if GameInfo.Units[itemInfo.UnitType] then
                itemType = itemInfo.UnitType
            else
                log:Error("GetUniqueUnitID: %s is not a valid unit type!", itemType)
            end
            break
        end

When I debug Fatal bugs like this, I also turn nearby LuaEvent calls into a SafeCall so errors like this don't crash the whole system.

I changed this:

LuaEvents.NewTech.Add(FreeUnitWithTech)

to this:

LuaEvents.NewTech.Add(function(player, techID, changeID) return SafeCall(FreeUnitWithTech, player, techID, changeID) end)
Thalassicus commented 10 years ago

It appears there may be another bug with the Allotment trait. It seems to give a copy of every single new unit we research, not the first unit of each CombatClass (archer units, skirmish units, etc). This is probably my fault. I think I may have coded this ability.

INSERT INTO Trait_FreeUnitAtTech
        (TraitType, TechType, UnitClassType, PromotionType)
SELECT  DISTINCT 'TRAIT_ALLOTMENT', PrereqTech, Class, 'PROMOTION_ALLOTMENT'
FROM Units WHERE (Combat>0 OR RangedCombat>0) AND Cost>0 AND Suicide=0 AND PurchaseOnly=0;
```sql