cyther
Lord of the Dance
I was using the scenario counter earlier but I think it isn't active outside of Scenarios.
I was using the scenario counter earlier but I think it isn't active outside of Scenarios.
def getGoalTag(self, pPlayer):
szBuffer = u"<font=2>"
if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_AGAINST_THE_WALL):
if gc.getGame().getScenarioCounter() == 0:
szBuffer = szBuffer + CyTranslator().getColorText("TXT_KEY_WB_AGAINST_THE_WALL_GOAL_1", (), gc.getInfoTypeForString("COLOR_RED"))
OK while looking for capture code I found it was part of CvUnit::combatWon, which is all this:Yes. That should lead you through everything you need. Mostly all in CvInfos and CvUnit (actually, relatively certain COMPLETELY within those two, and some Cy files)
void CvUnit::combatWon(CvUnit* pLoser, bool bAttacking)
{
PromotionTypes ePromotion;
bool bConvert = false;
int iUnit = NO_UNIT;
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
CvPlot* pPlot;
CvUnit* pUnit;
for (int iI = 0; iI < GC.getNumPromotionInfos(); iI++)
{
if (isHasPromotion((PromotionTypes)iI))
{
if (GC.getPromotionInfo((PromotionTypes)iI).getFreeXPFromCombat() != 0)
{
changeExperience(GC.getPromotionInfo((PromotionTypes)iI).getFreeXPFromCombat(), -1, false, false, false);
}
if (GC.getPromotionInfo((PromotionTypes)iI).getModifyGlobalCounterOnCombat() != 0)
{
if (pLoser->isAlive())
{
GC.getGameINLINE().changeGlobalCounter(GC.getPromotionInfo((PromotionTypes)iI).getModifyGlobalCounterOnCombat());
}
}
if (GC.getPromotionInfo((PromotionTypes)iI).isRemovedByCombat())
{
setHasPromotion(((PromotionTypes)iI), false);
}
if (GC.getPromotionInfo((PromotionTypes)iI).getPromotionCombatApply() != NO_PROMOTION)
{
ePromotion = (PromotionTypes)GC.getPromotionInfo((PromotionTypes)iI).getPromotionCombatApply();
pPlot = pLoser->plot();
pUnitNode = pPlot->headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = pPlot->nextUnitNode(pUnitNode);
if (pLoopUnit->isHasPromotion(ePromotion) == false)
{
if (pLoopUnit->isAlive() || !GC.getPromotionInfo(ePromotion).isPrereqAlive())
{
if (isEnemy(pLoopUnit->getTeam()))
{
if (pLoopUnit->canAcquirePromotion(ePromotion))
{
if (GC.getGameINLINE().getSorenRandNum(100, "Combat Apply") <= GC.getDefineINT("COMBAT_APPLY_CHANCE"))
{
pLoopUnit->setHasPromotion(ePromotion, true);
gDLL->getInterfaceIFace()->addMessage((PlayerTypes)pLoopUnit->getOwner(), true, GC.getEVENT_MESSAGE_TIME(), GC.getPromotionInfo(ePromotion).getDescription(), "", MESSAGE_TYPE_INFO, GC.getPromotionInfo(ePromotion).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), getX_INLINE(), getY_INLINE(), true, true);
gDLL->getInterfaceIFace()->addMessage((PlayerTypes)getOwner(), true, GC.getEVENT_MESSAGE_TIME(), GC.getPromotionInfo(ePromotion).getDescription(), "", MESSAGE_TYPE_INFO, GC.getPromotionInfo(ePromotion).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), getX_INLINE(), getY_INLINE(), true, true);
}
}
}
}
}
}
}
if (GC.getPromotionInfo((PromotionTypes)iI).getCombatCapturePercent() != 0)
{
if (iUnit == NO_UNIT && pLoser->isAlive())
{
if (GC.getGameINLINE().getSorenRandNum(100, "Combat Capture") <= GC.getPromotionInfo((PromotionTypes)iI).getCombatCapturePercent())
{
iUnit = pLoser->getUnitType();
bConvert = true;
}
}
}
if (GC.getPromotionInfo((PromotionTypes)iI).getCaptureUnitCombat() != NO_UNITCOMBAT)
{
if (iUnit == NO_UNIT && pLoser->getUnitCombatType() == GC.getPromotionInfo((PromotionTypes)iI).getCaptureUnitCombat())
{
iUnit = pLoser->getUnitType();
bConvert = true;
}
}
}
if (pLoser->isHasPromotion((PromotionTypes)iI))
{
if (GC.getPromotionInfo((PromotionTypes)iI).getPromotionCombatApply() != NO_PROMOTION)
{
ePromotion = (PromotionTypes)GC.getPromotionInfo((PromotionTypes)iI).getPromotionCombatApply();
if (isHasPromotion(ePromotion) == false)
{
if (isAlive() || !GC.getPromotionInfo(ePromotion).isPrereqAlive())
{
if (pLoser->isEnemy(getTeam()))
{
if (GC.getGameINLINE().getSorenRandNum(100, "Combat Apply") <= GC.getDefineINT("COMBAT_APPLY_CHANCE"))
{
setHasPromotion(ePromotion, true);
gDLL->getInterfaceIFace()->addMessage((PlayerTypes)getOwner(), true, GC.getEVENT_MESSAGE_TIME(), GC.getPromotionInfo(ePromotion).getDescription(), "", MESSAGE_TYPE_INFO, GC.getPromotionInfo(ePromotion).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), getX_INLINE(), getY_INLINE(), true, true);
gDLL->getInterfaceIFace()->addMessage((PlayerTypes)pLoser->getOwner(), true, GC.getEVENT_MESSAGE_TIME(), GC.getPromotionInfo(ePromotion).getDescription(), "", MESSAGE_TYPE_INFO, GC.getPromotionInfo(ePromotion).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), getX_INLINE(), getY_INLINE(), true, true);
}
}
}
}
}
}
}
if (GET_PLAYER(getOwnerINLINE()).getFreeXPFromCombat() != 0)
{
changeExperience(GET_PLAYER(getOwnerINLINE()).getFreeXPFromCombat(), -1, false, false, false);
}
if (getCombatHealPercent() != 0)
{
if (pLoser->isAlive())
{
int i = getCombatHealPercent();
if (i > getDamage())
{
i = getDamage();
}
if (i != 0)
{
changeDamage(-1 * i, NO_PLAYER);
}
}
}
if (m_pUnitInfo->isExplodeInCombat() && m_pUnitInfo->isSuicide())
{
if (bAttacking)
{
pPlot = pLoser->plot();
}
else
{
pPlot = plot();
}
if (plot()->isVisibleToWatchingHuman())
{
gDLL->getEngineIFace()->TriggerEffect((EffectTypes)GC.getInfoTypeForString("EFFECT_ARTILLERY_SHELL_EXPLODE"), pPlot->getPoint(), (float)(GC.getASyncRand().get(360)));
gDLL->getInterfaceIFace()->playGeneralSound("AS3D_UN_GRENADE_EXPLODE", pPlot->getPoint());
}
}
if (GC.getUnitInfo(pLoser->getUnitType()).isExplodeInCombat())
{
if (plot()->isVisibleToWatchingHuman())
{
gDLL->getEngineIFace()->TriggerEffect((EffectTypes)GC.getInfoTypeForString("EFFECT_ARTILLERY_SHELL_EXPLODE"), plot()->getPoint(), (float)(GC.getASyncRand().get(360)));
gDLL->getInterfaceIFace()->playGeneralSound("AS3D_UN_GRENADE_EXPLODE", plot()->getPoint());
}
}
if ((m_pUnitInfo->getEnslavementChance() + GET_PLAYER(getOwnerINLINE()).getEnslavementChance()) > 0)
{
if (getDuration() == 0 && pLoser->isAlive() && !pLoser->isAnimal() && iUnit == NO_UNIT)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Enslavement") <= (m_pUnitInfo->getEnslavementChance() + GET_PLAYER(getOwnerINLINE()).getEnslavementChance()))
{
iUnit = GC.getDefineINT("SLAVE_UNIT");
}
}
}
if (m_pUnitInfo->getPromotionFromCombat() != NO_PROMOTION)
{
if (pLoser->isAlive())
{
setHasPromotion((PromotionTypes)m_pUnitInfo->getPromotionFromCombat(), true);
}
}
if (getGoldFromCombat() != 0)
{
if (!pLoser->isAnimal())
{
GET_PLAYER(getOwnerINLINE()).changeGold(getGoldFromCombat());
CvWString szBuffer = gDLL->getText("TXT_KEY_MESSAGE_GOLD_FROM_COMBAT", getGoldFromCombat()).GetCString();
gDLL->getInterfaceIFace()->addMessage((PlayerTypes)getOwner(), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_GOODY_GOLD", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), getX_INLINE(), getY_INLINE(), true, true);
}
}
if (getDuration() > 0)
{
changeDuration(m_pUnitInfo->getDurationFromCombat());
}
if (pLoser->getDamageTypeCombat(DAMAGE_POISON) > 0 && GC.getDefineINT("POISONED_PROMOTION") != -1)
{
if (isAlive() && getDamage() > 0)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Poisoned") >= getDamageTypeResist(DAMAGE_POISON))
{
setHasPromotion((PromotionTypes)GC.getDefineINT("POISONED_PROMOTION"), true);
}
}
}
if (m_pUnitInfo->getUnitCreateFromCombat() != NO_UNIT)
{
if (!pLoser->isImmuneToCapture() && pLoser->isAlive() && GC.getUnitInfo((UnitTypes)pLoser->getUnitType()).getEquipmentPromotion() == NO_PROMOTION)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Create Unit from Combat") <= m_pUnitInfo->getUnitCreateFromCombatChance())
{
pUnit = GET_PLAYER(getOwnerINLINE()).initUnit((UnitTypes)m_pUnitInfo->getUnitCreateFromCombat(), plot()->getX_INLINE(), plot()->getY_INLINE());
pUnit->setDuration(getDuration());
if (isHiddenNationality())
{
pUnit->setHasPromotion((PromotionTypes)GC.getDefineINT("HIDDEN_NATIONALITY_PROMOTION"), true);
}
iUnit = NO_UNIT;
}
}
}
if (iUnit != NO_UNIT)
{
if ((!pLoser->isImmuneToCapture() && !isNoCapture() && !pLoser->isImmortal())
|| GC.getUnitInfo((UnitTypes)pLoser->getUnitType()).getEquipmentPromotion() != NO_PROMOTION)
{
pUnit = GET_PLAYER(getOwnerINLINE()).initUnit((UnitTypes)iUnit, plot()->getX_INLINE(), plot()->getY_INLINE());
if (getDuration() != 0)
{
pUnit->setDuration(getDuration());
}
if (iUnit == GC.getDefineINT("SLAVE_UNIT"))
{
if (pLoser->getRace() != NO_PROMOTION)
{
pUnit->setHasPromotion((PromotionTypes)pLoser->getRace(), true);
}
}
if (bConvert)
{
pLoser->setDamage(75, NO_PLAYER, false);
pUnit->convert(pLoser);
}
}
}
if (!isEmpty(GC.getUnitInfo(getUnitType()).getPyPostCombatWon()))
{
CyUnit* pyCaster = new CyUnit(this);
CyUnit* pyOpponent = new CyUnit(pLoser);
CyArgsList argsList;
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCaster)); // pass in unit class
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyOpponent)); // pass in unit class
gDLL->getPythonIFace()->callFunction(PYSpellModule, "postCombatWon", argsList.makeFunctionArgs()); //, &lResult
delete pyCaster; // python fxn must not hold on to this pointer
delete pyOpponent; // python fxn must not hold on to this pointer
}
if (!isEmpty(GC.getUnitInfo(pLoser->getUnitType()).getPyPostCombatLost()))
{
CyUnit* pyCaster = new CyUnit(pLoser);
CyUnit* pyOpponent = new CyUnit(this);
CyArgsList argsList;
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCaster)); // pass in unit class
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyOpponent)); // pass in unit class
gDLL->getPythonIFace()->callFunction(PYSpellModule, "postCombatLost", argsList.makeFunctionArgs()); //, &lResult
delete pyCaster; // python fxn must not hold on to this pointer
delete pyOpponent; // python fxn must not hold on to this pointer
}
if (m_pUnitInfo->getUnitConvertFromCombat() != NO_UNIT)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Convert Unit from Combat") <= m_pUnitInfo->getUnitConvertFromCombatChance())
{
pUnit = GET_PLAYER(getOwnerINLINE()).initUnit((UnitTypes)m_pUnitInfo->getUnitConvertFromCombat(), getX_INLINE(), getY_INLINE(), AI_getUnitAIType());
pUnit->convert(this);
}
}
}
void CvUnit::combatWon(CvUnit* pLoser, bool bAttacking)
{
PromotionTypes ePromotion;
bool bConvert = false;
int iUnit = NO_UNIT;
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
CvPlot* pPlot;
CvUnit* pUnit;
for (int iI = 0; iI < GC.getNumPromotionInfos(); iI++)
{
if (isHasPromotion((PromotionTypes)iI))
{
if (GC.getPromotionInfo((PromotionTypes)iI).getCombatCapturePercent() != 0)
{
if (iUnit == NO_UNIT && pLoser->isAlive())
{
if (GC.getGameINLINE().getSorenRandNum(100, "Combat Capture") <= GC.getPromotionInfo((PromotionTypes)iI).getCombatCapturePercent())
{
iUnit = pLoser->getUnitType();
bConvert = true;
}
}
}
}
}
if (m_pUnitInfo->getUnitConvertFromCombat() != NO_UNIT)
{
if (GC.getGameINLINE().getSorenRandNum(100, "Convert Unit from Combat") <= m_pUnitInfo->getUnitConvertFromCombatChance())
{
pUnit = GET_PLAYER(getOwnerINLINE()).initUnit((UnitTypes)m_pUnitInfo->getUnitConvertFromCombat(), getX_INLINE(), getY_INLINE(), AI_getUnitAIType());
pUnit->convert(this);
}
}
}
I thought that was something different but I couldn't find what it did.Took out too much.
The last chunk (getUnitConvertFromCombat()) is baby spiders upgrading to giant spiders, and wolves/lions upgrading to wolf packs/lion prides.
The first chunk (getCombatCapturePercent()) is Command Promotions. Moving the same unit into your control.
I think I remember you asking about enslavement (generating slaves) originally...