ArneHD
Just a little bit mad
I have been thinking about making a mod that allows special units to "prospect". That is, permanently place a random resource at a paticular spot. Now the unit itself i have under control, but I found that I couldn't find a value that gave a 50% chance or a 25%. So I went into the SDK and had a look at it, and found this code:
My question is, what does this acctualy do? I think it adds a random resource when an improvement is built, but how does it work?
Also, what do I have to change in order to make it give a 25% or 50% etc. chance?
Code:
if (getImprovementType() != NO_IMPROVEMENT)
{
if (getBonusType() == NO_BONUS)
{
FAssertMsg((0 < GC.getNumBonusInfos()), "GC.getNumBonusInfos() is not greater than zero but an array is being allocated in CvPlot::doImprovement");
for (iI = 0; iI < GC.getNumBonusInfos(); iI++)
{
if (GET_TEAM(getTeam()).isHasTech((TechTypes)(GC.getBonusInfo((BonusTypes) iI).getTechReveal())))
{
if (GC.getImprovementInfo(getImprovementType()).getImprovementBonusDiscoverRand(iI) > 0)
{
if (GC.getGameINLINE().getSorenRandNum(GC.getImprovementInfo(getImprovementType()).getImprovementBonusDiscoverRand(iI), "Bonus Discovery") == 0)
{
setBonusType((BonusTypes)iI);
pCity = GC.getMapINLINE().findCity(getX_INLINE(), getY_INLINE(), getOwnerINLINE(), NO_TEAM, false);
if (pCity != NULL)
{
swprintf(szBuffer, gDLL->getText("TXT_KEY_MISC_DISCOVERED_NEW_RESOURCE", GC.getBonusInfo((BonusTypes) iI).getTextKeyWide(), pCity->getNameKey()).GetCString());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false, GC.getDefineINT("EVENT_MESSAGE_TIME"), szBuffer, "AS2D_DISCOVERBONUS", MESSAGE_TYPE_MINOR_EVENT, GC.getBonusInfo((BonusTypes) iI).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), getX_INLINE(), getY_INLINE(), true, true);
}
break;
}
}
}
}
}
if (GC.getImprovementInfo(getImprovementType()).getImprovementUpgrade() != NO_IMPROVEMENT)
{
changeUpgradeProgress(GET_PLAYER(getOwnerINLINE()).getImprovementUpgradeRate());
if (getUpgradeProgress() >= GC.getGameINLINE().getImprovementUpgradeTime(getImprovementType()))
{
setImprovementType((ImprovementTypes)(GC.getImprovementInfo(getImprovementType()).getImprovementUpgrade()));
}
}
}
}
My question is, what does this acctualy do? I think it adds a random resource when an improvement is built, but how does it work?
Also, what do I have to change in order to make it give a 25% or 50% etc. chance?