Skip to content

Commit

Permalink
4.19.1 fixes (#11661)
Browse files Browse the repository at this point in the history
* fix CP concert tour not working since 2.7
and an assert that's probably never going to be hit anyway
also fixed concert tour mission tooltip
- CP has changed the tourism amount to be static, but the Lua function is still using the dynamic number
removed redundant tourism reduction against players with the NoOpenTrade trait
- it's already included in tourism modifiers

* fix great merchant trade tooltip
- currently the gold amount is dynamic
- this affects VP too
  • Loading branch information
azum4roll authored Feb 19, 2025
1 parent fcaa3b4 commit 961af31
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 70 deletions.
38 changes: 17 additions & 21 deletions CvGameCoreDLL_Expansion2/CvCultureClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3866,28 +3866,24 @@ void CvPlayerCulture::ChangeInfluenceOn(PlayerTypes ePlayer, int iValue)

int CvPlayerCulture::ChangeInfluenceOn(PlayerTypes eOtherPlayer, int iBaseInfluence, bool bApplyModifiers /* = false */, bool bModifyForGameSpeed /* = true */)
{
int iInfluence = iBaseInfluence;

if (bModifyForGameSpeed) {
iInfluence = iInfluence * GC.getGame().getGameSpeedInfo().getCulturePercent() / 100;
}

if (bApplyModifiers && m_pPlayer->getCapitalCity()) {
int iModifier = m_pPlayer->getCapitalCity()->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false);
if (iModifier != 0) {
iInfluence = iInfluence * (100 + iModifier) / 100;
}
}

if (eOtherPlayer != m_pPlayer->GetID() && GET_PLAYER(eOtherPlayer).isMajorCiv() && GET_PLAYER(eOtherPlayer).GetPlayerTraits()->IsNoOpenTrade())
{
if (!GC.getGame().GetGameTrade()->IsPlayerConnectedToPlayer(eOtherPlayer, m_pPlayer->GetID(), true))
iInfluence /= 2;
}

if (iInfluence != 0) {
int iInfluence = iBaseInfluence;

if (bModifyForGameSpeed)
{
iInfluence = iInfluence * GC.getGame().getGameSpeedInfo().getCulturePercent() / 100;
}

CvCity* pCapital = m_pPlayer->getCapitalCity();
if (bApplyModifiers && pCapital)
{
int iModifier = pCapital->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false);
iInfluence = iInfluence * (100 + iModifier) / 100;
}

if (iInfluence != 0)
{
ChangeInfluenceOn(eOtherPlayer, iInfluence);
}
}

return iInfluence;
}
Expand Down
8 changes: 2 additions & 6 deletions CvGameCoreDLL_Expansion2/CvUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13103,14 +13103,10 @@ bool CvUnit::canBlastTourism(const CvPlot* pPlot, bool bTestVisible) const
// --------------------------------------------------------------------------------
int CvUnit::getBlastTourism()
{
CvPlayer* pPlayer = &GET_PLAYER(getOwner());
if (!pPlayer)
if (getOwner() == NO_PLAYER)
return 0;

if (!canBlastTourism(plot()))
{
return 0;
}
CvPlayer* pPlayer = &GET_PLAYER(getOwner());

// Get base multiplier from unit
int iMultiplier = getUnitInfo().GetOneShotTourism();
Expand Down
57 changes: 14 additions & 43 deletions CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2014,11 +2014,7 @@ int CvLuaUnit::lGetHurryProduction(lua_State* L)
//int GetTradeGold();
int CvLuaUnit::lGetTradeGold(lua_State* L)
{
CvUnit* pkUnit = GetInstance(L);

const int iResult = pkUnit->getTradeGold();
lua_pushinteger(L, iResult);
return 1;
return BasicLuaMethod(L, &CvUnit::GetGoldBlastStrength);
}
//------------------------------------------------------------------------------
//int GetTradeInfluence(CyPlot* pPlot);
Expand Down Expand Up @@ -2161,49 +2157,24 @@ int CvLuaUnit::lGetGivePoliciesCulture(lua_State* L)
//int GetBlastTourism()
int CvLuaUnit::lGetBlastTourism(lua_State* L)
{
CvUnit* pkUnit = GetInstance(L);
int iResult = 0;
if (pkUnit)
{
iResult = pkUnit->getBlastTourism();
CvUnit* pUnit = GetInstance(L);
int iResult = pUnit->GetTourismBlastStrength();

#if defined(MOD_BALANCE_CORE)
if (MOD_BALANCE_CORE_NEW_GP_ATTRIBUTES && pkUnit && pkUnit->getBlastTourism() > 0)
if (MOD_BALANCE_CORE_NEW_GP_ATTRIBUTES && iResult > 0)
{
CvPlot* pPlot = pUnit->plot();
if (pPlot && pUnit->canBlastTourism(pPlot))
{
CvPlot* pPlot = pkUnit->plot();
if (pPlot && pkUnit->canBlastTourism(pPlot))
{
CvPlayer& kUnitOwner = GET_PLAYER(pkUnit->getOwner());
PlayerTypes eOtherPlayer = pPlot->getOwner();

CvCity* pCapital = GET_PLAYER(pUnit->getOwner()).getCapitalCity();
PlayerTypes eOtherPlayer = pPlot->getOwner();

// below logic based on CvPlayerCulture::ChangeInfluenceOn()
if (eOtherPlayer != NO_PLAYER)
{
// gamespeed modifier
iResult = iResult * GC.getGame().getGameSpeedInfo().getCulturePercent() / 100;

// player to player modifier (eg religion, open borders, ideology)
if (kUnitOwner.getCapitalCity())
{
int iModifier = kUnitOwner.getCapitalCity()->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false);
if (iModifier != 0)
{
iResult = iResult * (100 + iModifier) / 100;
}
}

// IsNoOpenTrade trait modifier (half tourism if trait owner does not send a trade route to the unit owner)
CvPlayer& kOtherPlayer = GET_PLAYER(eOtherPlayer);
if (eOtherPlayer != pkUnit->getOwner() && kOtherPlayer.isMajorCiv() && kOtherPlayer.GetPlayerTraits()->IsNoOpenTrade())
{
if (!GC.getGame().GetGameTrade()->IsPlayerConnectedToPlayer(eOtherPlayer, pkUnit->getOwner(), true))
iResult /= 2;
}
}
// Player to player modifier
if (pCapital)
{
int iModifier = pCapital->GetCityCulture()->GetTourismMultiplier(eOtherPlayer, false, false, false, false, false);
iResult = iResult * (100 + iModifier) / 100;
}
}
#endif
}

lua_pushinteger(L, iResult);
Expand Down

0 comments on commit 961af31

Please sign in to comment.