CaptainMidnight
Warlord
- Joined
- Apr 16, 2006
- Messages
- 141
Hi, I'm new to modding the SDK and C++ so please forgive my ignorance and lack of understanding. (I am working through a C++ beginners book I swear.)
I successfully copied tags <SpecialistYieldChanges> from buildinginfos to civicinfos so civics can grant a specific specialist extra yield types (like angkor wat does with priests).
Tried to do the same for commerce types, however the CvPlayer::changeSpecialistExtraCommerce function that already exist cannot take 3 arguments. I *think* I need to write a new function that includes specialisttypes index argument.
I am wondering if I should model off of:
CvPlayer::changeSpecialistExtraYield in player.cpp
or
Not sure if either makes any difference but I tried it with yields creating a "ppaaiSpecialistCivicExtraYield" but that led to more problems about re-declaring functions that I couldn't solve. I'd be really grateful for someone to point me in the right direction on this!
I successfully copied tags <SpecialistYieldChanges> from buildinginfos to civicinfos so civics can grant a specific specialist extra yield types (like angkor wat does with priests).
Tried to do the same for commerce types, however the CvPlayer::changeSpecialistExtraCommerce function that already exist cannot take 3 arguments. I *think* I need to write a new function that includes specialisttypes index argument.
I am wondering if I should model off of:
CvPlayer::changeSpecialistExtraYield in player.cpp
Code:
int CvPlayer::getSpecialistExtraYield(SpecialistTypes eIndex1, YieldTypes eIndex2) const
{
FAssertMsg(eIndex1 >= 0, "eIndex1 expected to be >= 0");
FAssertMsg(eIndex1 < GC.getNumSpecialistInfos(), "eIndex1 expected to be < GC.getNumSpecialistInfos()");
FAssertMsg(eIndex2 >= 0, "eIndex2 expected to be >= 0");
FAssertMsg(eIndex2 < NUM_YIELD_TYPES, "eIndex2 expected to be < NUM_YIELD_TYPES");
return m_ppaaiSpecialistExtraYield[eIndex1][eIndex2];
}
void CvPlayer::changeSpecialistExtraYield(SpecialistTypes eIndex1, YieldTypes eIndex2, int iChange)
{
FAssertMsg(eIndex1 >= 0, "eIndex1 expected to be >= 0");
FAssertMsg(eIndex1 < GC.getNumSpecialistInfos(), "eIndex1 expected to be < GC.getNumSpecialistInfos()");
FAssertMsg(eIndex2 >= 0, "eIndex2 expected to be >= 0");
FAssertMsg(eIndex2 < NUM_YIELD_TYPES, "eIndex2 expected to be < NUM_YIELD_TYPES");
if (iChange != 0)
{
m_ppaaiSpecialistExtraYield[eIndex1][eIndex2] = (m_ppaaiSpecialistExtraYield[eIndex1][eIndex2] + iChange);
FAssert(getSpecialistExtraYield(eIndex1, eIndex2) >= 0);
updateExtraSpecialistYield();
AI_makeAssignWorkDirty();
}
}
or
Code:
int CvPlayer::getSpecialistExtraCommerce(CommerceTypes eIndex) const
{
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < NUM_COMMERCE_TYPES, "eIndex is expected to be within maximum bounds (invalid Index)");
return m_aiSpecialistExtraCommerce[eIndex];
}
void CvPlayer::changeSpecialistExtraCommerce(CommerceTypes eIndex, int iChange)
{
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < NUM_COMMERCE_TYPES, "eIndex is expected to be within maximum bounds (invalid Index)");
if (iChange != 0)
{
m_aiSpecialistExtraCommerce[eIndex] = (m_aiSpecialistExtraCommerce[eIndex] + iChange);
FAssert(getSpecialistExtraCommerce(eIndex) >= 0);
updateCommerce(eIndex);
AI_makeAssignWorkDirty();
}
}
Not sure if either makes any difference but I tried it with yields creating a "ppaaiSpecialistCivicExtraYield" but that led to more problems about re-declaring functions that I couldn't solve. I'd be really grateful for someone to point me in the right direction on this!