//find if merch will allow char to trade, based on char's RMRel with merch's
//nation, and char's rep.
bool TradeCheck(ref char, ref merch, bool first)
{
if (LAi_IsCapturedLocation) return true; // KK
int mNation = sti(merch.nation);
int rep = sti(char.reputation);
float rel = 0.0;
// KK -->
if (ENABLE_FLAGS == 0)
rel = GetRMRelation(char, mNation);
else
rel = GetActualRMRelation(mNation); // PB: was GetFlagRMRelation
// <-- KK
//find loc
bool strengthcomp;
int locIdx = FindLoadedLocation();
if(locIdx<0) return true;
if( !CheckAttribute(&Locations[locIdx],"townsack") ) return true;
// PB: Recoded Checks -->
// -- Town fight strength vs. squadron fight strength --
// Store/shipyard owner can be intimidated if player has three times more crew than the town has troops
int ttroops = GetTownNumTroops(Locations[locIdx].townsack);
int ptroops = GetSquadronCrewQuantity(char);
if(ptroops > ttroops * 3) strengthcomp = true;
// -- Actual Checks --
// If you are Hostile with their nation, but you are a Hero
if(rel <= REL_WAR && rep > TRADEREP_ALL ) return true ;
// If their nation is Wary of you, but you are Neutral or better
if(rel <= REL_AFTERATTACK && rep > TRADEREP_NEUTRAL ) return true ;
// If their nation is Neutral and you are a Swindler or better
if(rel < REL_NEUTRAL && rep >= TRADEREP_STRENGTH ) return true ;
// If their nation is Neutral, you are worse than a Swindler, but you can intimidate them
if(rel < REL_NEUTRAL && rep < TRADEREP_STRENGTH && strengthcomp) return true ;
// You have a Letter of Marque with the nation and have been promoted at least once
if(GetRank(GetMainCharacter(), mNation) > 0 ) return true ;
// Pirates will not talk to you if you are too much of a nice guy
if(mNation == PIRATE && rep > TRADEREP_NEUTRAL ) return false;
// PB: Recoded Checks <--
//MAXIMUS -[we are here already, why we can't complete our mission?]->
if(first && CheckQuestAttribute("generate_trade_quest_progress", "begin") || CheckQuestAttribute("generate_trade_quest_progress", "failed"))
{
if(CheckQuestAttribute("generate_trade_quest.iTradeNation", GetCurrentLocationNation()) && char.quest.generate_trade_quest.iTradeColony == GetCurrentTownID()) return true;
}
//MAXIMUS <-[we are here already, why we can't complete our mission?]-
return false;
}