Shqype
Shqyptar
Sounds good to me, hopefully he is successful!
Kael said:Just a simple example of a change that can be made in CvUnit::maxCombatStr(). This applies a combat modifier based on the existence of the "Elf" promotion on the defender and the "Elf Slaying" promotion on the attacker. maxCombatStr is called from the perspective of the defender and I have the 2 checks in so that the bonus is applied on attack and defense.
Changes are in bold.
CvUnit::maxCombatStr()
Code:if (getUnitCombatType() != NO_UNITCOMBAT) { iModifier -= pAttacker->unitCombatModifier(getUnitCombatType()); if (pCombatDetails != NULL) { pCombatDetails->iCombatModifierT = -(pAttacker->unitCombatModifier(getUnitCombatType())); } } [b] if (isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_ELF"))) { if (pAttacker->isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_ELF_SLAYING"))) { iModifier = iModifier - 40; } } if (isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_ELF_SLAYING"))) { if (pAttacker->isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_ELF"))) { iModifier = iModifier + 40; } }[/b] iModifier += domainModifier(pAttacker->getDomainType()); if (pCombatDetails != NULL) { pCombatDetails->iDomainModifierA = domainModifier(pAttacker->getDomainType()); }
Why use this? It provides the ability to specify anti-unit combat bonuses without having to make new unit combats or declare specific unitclasses. Also since its easy to add and remove promotions as you play it can allow you to create pretty dynamic bonuses.
Outside of that just being familiar with the effect of changing maxCombatStr can be very helpful to anyone who wants to effect the combat odds. Changes made here are reflect both in the actual combat odds as well as the display.
jenks said:I know these will seem like very basic questions, but i only started with XML this week and im in at the deep end
1 - Im not sure where the file is that this set of instructions needs to be added to, anyone? (i did a search for .cpp files on my HD but couldnt find a single one, and browsing around the vanilla files as well as a few mods i can only see .py files)
2 - Anyone know where i can download a FREE c++ editor/compiler to load and edit the .cpp file? (when i find it)
3 - Can I just copy the code into the place shown in the example, with my own promotions replacing PROMOTION_ELF (to PROMOTION_BORG) and PROMOTION_ELFSLAYING (PROMOTION_RUSE1), or do i need to declare the variables somewhere else?
bool CvUnit::upgradeAvailable(UnitTypes eFromUnit, UnitClassTypes eToUnitClass, int iCount) const
{
UnitTypes eLoopUnit;
int iI;
[b]/* Modifed by Gerikes to disable recursive upgrade*/[/b]
[b]//[/b]if (iCount > GC.getNumUnitClassInfos())
[b]if (iCount > 0)[/b]
[b]/* End Modifed by Gerikes to disable recursive upgrade*/[/b]
{
return false;
}
if (GC.getUnitInfo(eFromUnit).getUpgradeUnitClass(eToUnitClass))
{
return true;
}
for (iI = 0; iI < GC.getNumUnitClassInfos(); iI++)
{
if (GC.getUnitInfo(eFromUnit).getUpgradeUnitClass(iI))
{
eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(iI)));
if (eLoopUnit != NO_UNIT)
{
if (upgradeAvailable(eLoopUnit, eToUnitClass, (iCount + 1))) [b]// Recursive call[/b]
{
return true;
}
}
}
}
return false;
}
[b]/* Modifed by Gerikes to change recursive upgrade max depth*/[/b]
[b]//[/b]if (iCount > GC.getNumUnitClassInfos())
[b]if (iCount >= GC.getDefineINT("MAX_UPGRADE_DEPTH"))[/b]
[b]/* End Modifed by Gerikes to change recursive upgrade max depth*/[/b]
//FfH: Added by Kael 07/19/2006
bool CvPlayer::hasBonus(BonusTypes eIndex)
{
CvCity* pLoopCity;
int iLoop;
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
if (pLoopCity->hasBonus(eIndex))
{
return true;
}
}
return false;
}
//FfH: End Add
//FfH: Added by Kael 07/19/2006
bool hasBonus(BonusTypes eIndex);
//FfH: End Add
if (pPlayer.hasBonus(eBonus))
LittleRedPoint said:How to make civics to suport negative religion hapiness?
For example I want to make theocracy to give +3 happy with state religion and 3 unhappy with non state religion. If I insert -3 in xml the game gives me value of 246583. I saw this suport in several mods. Kael you did it in your mod too. How to do this?
//FfH: Added by Kael 08/08/2006
if ((pDefender->getDamage() + iDamage) >= pDefender->maxHitPoints())
{
CvUnit* pLoopUnit;
int iLoop;
for (iLoop=0; iLoop <= pPlot->getNumUnits(); iLoop++)
{
pLoopUnit = pPlot->getUnit(iLoop);
if (pLoopUnit != NULL && pLoopUnit->getUnitClassType() == (UnitClassTypes)GC.getInfoTypeForString("UNITCLASS_LIFESPARK"))
{
pDefender->changeDamage(-40);
szBuffer = gDLL->getText("TXT_KEY_MESSAGE_LIFESPARK_USED", pDefender->getNameKey());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getDefineINT("EVENT_MESSAGE_TIME"), szBuffer, GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(), MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), pPlot->getX_INLINE(), pPlot->getY_INLINE());
pLoopUnit->kill(false);
break;
}
}
}
//FfH: End Add
Grey Fox said:Modern programming languages often Copy syntax from C/C++. *I think* that C or C++ was the first object-oriented language aswell, which another reason its copied. The first being its probably one of the most popular programming languages.
Kael said:Replyed in PM.
if (hasMoved())
{
if (isAlwaysHeal())
{
doHeal();
}
}
else
{
if (isHurt())
{
doHeal();
}
changeFortifyTurns(1);
//FfH: Added by Kael 10/05/2006
if (isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_FATIGUED")))
{
setHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_FATIGUED"), false);
}
//FfH: End Add
}
Aussie_Lurker said:Hey Kael, this could prove useful to people like myself and Dom Pedro in the future. What I am wondering, though, is what would you replace the if (hasmoved()) line with if you wanted to represent units being 'out of supply'. I am guessing it would probably have to be some kind of if (isPlot()) routine, am I right?
Aussie_Lurker.
Aussie_Lurker said:Well its effects would be identical to the Fatigue function you describe. The only difference is that, rather than being based on whether the unit moved, it would be based on how far the plot said unit is on is from a friendly/home plot.
Does that make sense?
Aussie_Lurker.