Hi, this really shouldn't be returning 0, yet it is.
circumstance: GetPlayer() is the human here, eOtherPlayer is the AI.
Maybe I'm missing something there. Another pair of eyes could be useful.
Thank you.
circumstance: GetPlayer() is the human here, eOtherPlayer is the AI.
Code:
/// Added by Putmalk - Version Three
// How must is a technology worth?
int CvDealAI::GetTechValue(TechTypes eTech, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue)
{
int iItemValue = 0;
int iTheyResearchedLeft = GET_TEAM( GET_PLAYER(eOtherPlayer).getTeam() ).GetTeamTechs()->GetResearchLeft(eTech);
int iNumTechsTheyHave = GET_TEAM( GET_PLAYER(eOtherPlayer).getTeam() ).GetTeamTechs()->GetNumTechsKnown();
int iNumTechsWeHave = GET_TEAM( GetPlayer()->getTeam() ).GetTeamTechs()->GetNumTechsKnown();
int iEraModifier;
// don't divide by zero, please
if(iNumTechsWeHave == 0)
iNumTechsWeHave = 1;
if(iNumTechsTheyHave == 0)
iNumTechsTheyHave = 1;
iItemValue = iTheyResearchedLeft;
int iAdditionalValue = ((iNumTechsTheyHave * 100)/iNumTechsWeHave);
if(iAdditionalValue == 0)
iAdditionalValue = 1;
iItemValue *= iAdditionalValue;
iItemValue /= 100;
// Modify formula based on era of tech
EraTypes eMyEra = GET_TEAM(GetPlayer()->getTeam()).GetCurrentEra();
CvTechEntry* pkTechInfo = GC.getTechInfo(eTech);
int iTechEra = pkTechInfo->GetEra();
iAdditionalValue = iItemValue * max(0,(int)(eMyEra - iTechEra));
iItemValue += iAdditionalValue;
// If multiple people have this tech its value decreased
//fTechModifier *= ( (float) GC.getGame().countKnownTechNumTeams(eTech) / (float) GC.getGame().countCivPlayersEverAlive() );
//fTechModifier *= 100;
//if(fTechModifier = 0)
//{
// fTechModifier = 100;
//}
//iItemValue *= (int) fTechModifier;
//iItemValue /= 100;
if(bFromMe)
{
// Approach is important
switch(GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ true))
{
case MAJOR_CIV_APPROACH_HOSTILE:
iItemValue *= 250;
break;
case MAJOR_CIV_APPROACH_GUARDED:
iItemValue *= 130;
break;
case MAJOR_CIV_APPROACH_AFRAID:
iItemValue *= 80;
break;
case MAJOR_CIV_APPROACH_FRIENDLY:
iItemValue *= 100;
break;
case MAJOR_CIV_APPROACH_NEUTRAL:
iItemValue *= 100;
break;
default:
CvAssertMsg(false, "DEAL_AI: AI player has no valid Approach for Technology valuation. Please send Jon this with your last 5 autosaves and what changelist # you're playing.")
iItemValue *= 100;
break;
}
iItemValue /= 100;
}
// Are we trying to find the middle point between what we think this item is worth and what another player thinks it's worth?
if(bUseEvenValue)
{
iItemValue += GET_PLAYER(eOtherPlayer).GetDealAI()->GetTradeAgreementValue(!bFromMe, GetPlayer()->GetID(), /*bUseEvenValue*/ false);
iItemValue /= 2;
}
return iItemValue;
}
Maybe I'm missing something there. Another pair of eyes could be useful.
Thank you.