toadhunter
Chieftain
- Joined
- Dec 31, 2011
- Messages
- 3
Ok, I have read that people say that it is impossible to add canals to Civ5. But the discussion mainly goes around modifying XML and terrain.
As I looked around, it seemed to me that perhaps it still could be done somehow, but you would need to modify game behaviour on deeper level than XML: maybe not change terrain, but unit movement?
I was wondering if reimplementing forts like they were in Civ4 could possibly work: you could enter a fort with a naval unit, if the fort was next to water (basically providing a 2-tile max-length canals).
So, I tried to add a hook to the GameEvents.UnitSetXY, something like that:
I have made this into mod with modbuddy and it compiles OK, I have also added the
to the modinfo file (from within modbuddy too, no manual editing here, so i don't mess anything up).
The mod can be loaded, but appears to do nothing.
I added some print() statements to the function and attached Firetuner process, but the mod doesn't seem to activate at all. Am I doing something wrong?
Also, when trying to make a function by hand in Furetuner, I get confused:
I see in other mod LUA files references to "Players" and some other objects. I can't reference them directly from Firetuner LUA console, but have to use "GameCore.Players" instead? Same with some other LUA objects: I see "GameEvents" in FireTuner, but in some mod files I see "Events", are they the same?
And is there a way to write multiline functions in Firetuner's LUA console?
Any hints appreciated. While I have some programming experience, I haven't done any LUA before, nor done any Civ XML modding so far.
As I looked around, it seemed to me that perhaps it still could be done somehow, but you would need to modify game behaviour on deeper level than XML: maybe not change terrain, but unit movement?
I was wondering if reimplementing forts like they were in Civ4 could possibly work: you could enter a fort with a naval unit, if the fort was next to water (basically providing a 2-tile max-length canals).
So, I tried to add a hook to the GameEvents.UnitSetXY, something like that:
Code:
function NavalUnitsEnterForts(iPlayer, iUnitID, iX, iY)
local pUnit = Players[ iPlayer ]:GetUnitByID( iunitID );
if ( pUnit:GetDomainType() ~= DomainTypes.DOMAIN_SEA ) then
return false;
end;
local plot= Map.GetPlot(iX,iY);
if (plot:GetImprovementType() ~= GameInfo.Improvements.IMPROVEMENT_FORT.ID ) then
return false;
end;
if (plot:IsAdjacentToShallowWater()) then
return true;
end;
return false;
end
GameEvents.UnitSetXY.Add(NavalUnitsEnterForts)
I have made this into mod with modbuddy and it compiles OK, I have also added the
Code:
<OnModActivated>
<UpdateDatabase>NavalForts.lua</UpdateDatabase>
</OnModActivated>
to the modinfo file (from within modbuddy too, no manual editing here, so i don't mess anything up).
The mod can be loaded, but appears to do nothing.
I added some print() statements to the function and attached Firetuner process, but the mod doesn't seem to activate at all. Am I doing something wrong?
Also, when trying to make a function by hand in Furetuner, I get confused:
I see in other mod LUA files references to "Players" and some other objects. I can't reference them directly from Firetuner LUA console, but have to use "GameCore.Players" instead? Same with some other LUA objects: I see "GameEvents" in FireTuner, but in some mod files I see "Events", are they the same?
And is there a way to write multiline functions in Firetuner's LUA console?
Any hints appreciated. While I have some programming experience, I haven't done any LUA before, nor done any Civ XML modding so far.