Help Removing Embarkation From Certain Units using Lua

trystero49

Prince
Joined
Apr 30, 2012
Messages
515
I took some of Spatzimaus's code from this page: http://forums.civfanatics.com/archive/index.php/t-468234.html

and I tried to adapt it to make it work for my mod. I have a specific unit (UNIT_QAMUTIQ) that I'm trying to get to Ice Walk. Ice Walk and Embarkation go together like a balloon and a porcupine, so I've decided to just not award Embarkation to the Qamutiq. First I tried making a new combat class for the qamutiq and not awarding embarkation to that combat class (I made a thread about this). It works fine, but no combat animations play. I'm trying to get this to work and still have combat animations. Here's my modified code:

Spoiler :

function Remove_Embark_From_Qamutiq(iPlayer,iUnit,hexVec,unitType,cultureType,civID,primaryColor,secondaryColor,unitFlagIndex,fogState,selected,military,notInvisible)
if(iPlayer ~= -1) then
pPlayer = Players[iPlayer];
if(iUnit ~= -1) then
pUnit = pPlayer:GetUnitByID(iUnit);
pType = pUnit:GetUnitType();
if pType == "UNIT_QAMUTIQ" then
pUnit:SetHasPromotion(GameInfoTypes.PROMOTION_EMBARKATION,false);
end
end
end
end
Events.SerialEventUnitCreated.Add(Remove_Embark_From_Qamutiq)


VFS = False and I used InGameUIAddin, but it doesn't work. What have I done wrong?

I also want to ask how to use FireTuner to "unpack" these events, because I'm not sure how, and I want to look up the arguments for certain events.

Thanks
 
If you get it to work, can you make a mod that allows heli's to not have to embark?

Having them not be able to end on a water tile would be nice, too.
 
Spoiler :
<Row>
<PromotionType>PROMOTION_EMBARKATION</PromotionType>
<UnitCombatType>UNITCOMBAT_HELICOPTER</UnitCombatType>
</Row>


That code in <UnitPromotions_UnitCombats> specifies that the promotion "Embarkation" can be awarded to Helicopter type units. (I assume that Helicopters are the only units that are Helicopter type). It wouldn't take much to make a mod where helicopters can't embark; you just need to update the database to delete that row.

Would you want helicopters to be able to move on all water tiles without embarking? Give them the <CanMoveAllTerrain> promotion, and make sure to also remove Embarkation from their combat class. Of course, now helicopters can move over all terrain (because of CanMoveAllTerrain) at 1MP per Tile (because of HoveringUnit), so this might be a little unbalanced. You can make a custom promotion with CanMoveAllTerrain = true and some extra code that makes Oceans impassable, so you can make helicopters that can move on coast without embarking. However, you'll never be able to make it to another continent that way, unless you implement a separate system for doing so.

I don't know how to make it so that they can't end on water tiles. I'm not very good at lua. I can't imagine it'd be hard to make it so that helicopters take damage on deep ocean tiles; you'd just have to look at how Carthage takes damage from mountains?

Anyway, my problem is a little different in that the unit I want to remove the embarkation from is UnitClass_Archer, and I dont' want to remove embarkation from all Archer units.
 
Spoiler :
<Row>
<PromotionType>PROMOTION_EMBARKATION</PromotionType>
<UnitCombatType>UNITCOMBAT_HELICOPTER</UnitCombatType>
</Row>


That code in <UnitPromotions_UnitCombats> specifies that the promotion "Embarkation" can be awarded to Helicopter type units. (I assume that Helicopters are the only units that are Helicopter type). It wouldn't take much to make a mod where helicopters can't embark; you just need to update the database to delete that row.

Would you want helicopters to be able to move on all water tiles without embarking? Give them the <CanMoveAllTerrain> promotion, and make sure to also remove Embarkation from their combat class. Of course, now helicopters can move over all terrain (because of CanMoveAllTerrain) at 1MP per Tile (because of HoveringUnit), so this might be a little unbalanced. You can make a custom promotion with CanMoveAllTerrain = true and some extra code that makes Oceans impassable, so you can make helicopters that can move on coast without embarking. However, you'll never be able to make it to another continent that way, unless you implement a separate system for doing so.

I don't know how to make it so that they can't end on water tiles. I'm not very good at lua. I can't imagine it'd be hard to make it so that helicopters take damage on deep ocean tiles; you'd just have to look at how Carthage takes damage from mountains?

Anyway, my problem is a little different in that the unit I want to remove the embarkation from is UnitClass_Archer, and I dont' want to remove embarkation from all Archer units.

My goal is to have helli's able to move over any terrian whatso-ever, but they can't end their turn on a tile with water on it, kinda like how in civ rev if a air unit ended their turn in something other than a city, they lose fuel and crash after it happens X number of times.
 
Ahh, well, I'm not really sure how to do that, but I might give it a shot and see what happens.

Anyway, threadjack aside, does anyone have any advice for me regarding my non-functional lua code?
 
Back
Top Bottom