45°38'N-13°47'E
Deity
Well, I've worked a bit on this promotion. I've been able to add that promotion, to add some new needed tags in PromotionInfos.xml (bPirate and PrereqOrCivics/PrereqAndCivics, which I've more or less copied from Afforess' ZoC code and Civics Buildings code, which I've used as a template to write new code for Piracy promotion). I've also been able to solve a lovely problem Afforess solved a long ago.
Yet, I'm having strange issues with missing inteface and CTD. I still have things to try before I give up, I think I can do it. Until now, I've been able to introduce that new piracy promotion, which can be selected as intended under certain civics. So that PrereqOrCivics/PrereqAndCivics is working. Now I'm trying to make the promotion to work as intended, i.e. granting HiddenNationality and AlwaysHostile. What I've done (and it doesnt' work for now) is scanning where HiddenNationality and AlwaysHostile are being used in the code and trying to apply that part of the code even when Piracy Promotion comes into play.
For example in CvPlayerAI.cpp, I've added that part in red:
Of course in order to do this, I had to add isHasPromotion to CvUnitInfo.cpp
and of course this means I have to add it to CvInfo.h too:
bool isHasPromotion(PromotionTypes eIndex) const;
and
bool* m_pabHasPromotion;
This because I had to use UnitInfo files and not Unit files in order to write that part of the code in red above. If I can use a workaround to check that promotion in Unit instead of in UnitInfo, I might be able to solve the CTD but I'm not sure.
Afforess or anyone else, do you have any suggestion?
Thank you.
Yet, I'm having strange issues with missing inteface and CTD. I still have things to try before I give up, I think I can do it. Until now, I've been able to introduce that new piracy promotion, which can be selected as intended under certain civics. So that PrereqOrCivics/PrereqAndCivics is working. Now I'm trying to make the promotion to work as intended, i.e. granting HiddenNationality and AlwaysHostile. What I've done (and it doesnt' work for now) is scanning where HiddenNationality and AlwaysHostile are being used in the code and trying to apply that part of the code even when Piracy Promotion comes into play.
For example in CvPlayerAI.cpp, I've added that part in red:
Code:
case UNITAI_PIRATE_SEA:
[COLOR="Red"] for (int iI = 0; iI < GC.getNumPromotionInfos(); iI++)
{
if (GC.getUnitInfo(eUnit).isHasPromotion((PromotionTypes)iI))
{
if (GC.getPromotionInfo((PromotionTypes)iI).isPirate())
{
bValid = true;
}
break;
}
} [/COLOR]
if (GC.getUnitInfo(eUnit).isAlwaysHostile() && GC.getUnitInfo(eUnit).isHiddenNationality())
{
bValid = true;
}
break;
Of course in order to do this, I had to add isHasPromotion to CvUnitInfo.cpp
Code:
bool CvUnitInfo::isHasPromotion(PromotionTypes eIndex) const
{
FAssertMsg(eIndex >= 0 || eIndex == NO_PROMOTION, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < GC.getNumPromotionInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");
return eIndex == NO_PROMOTION ? false : m_pabHasPromotion[eIndex];
}
and of course this means I have to add it to CvInfo.h too:
bool isHasPromotion(PromotionTypes eIndex) const;
and
bool* m_pabHasPromotion;
This because I had to use UnitInfo files and not Unit files in order to write that part of the code in red above. If I can use a workaround to check that promotion in Unit instead of in UnitInfo, I might be able to solve the CTD but I'm not sure.
Afforess or anyone else, do you have any suggestion?
Thank you.