//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 pNation = sti(char.nation);
int mNation = sti(merch.nation);
int rep = sti(char.reputation);
float rel = 0.0;
// PURSEON -->
if(first)
{
rel = GetRMRelation(GetMainCharacter(), mNation);
if(GetNationRelation(pNation, mNation) < RELATION_ENEMY && pNation != PERSONAL_NATION) // your flag is NOT hostile to the merchant
{
if(rel <= REL_WAR) // but you are flying a false flag!
{
if (frnd() < GetChanceDetectFalseFlag() || CheckAttribute(merch,"FalseFlagDetect")) // checks if the merchant will believe you
{
merch.FalseFlagDetect = true; // you have been caught and the merchant won't be so trusting next time
}
else
{
rel = REL_AFTERATTACK; // believes you, but... still takes into account your reputation!
}
}
else
{
DeleteAttribute(merch, "FalseFlagDetect"); // you are actually friendly
}
}
else
{
if(rel <= REL_WAR) // are you at war or not?
{
merch.FalseFlagDetect = true; // merchant KNOWS you are an enemy and remembers this
}
else
{
DeleteAttribute(merch, "FalseFlagDetect"); // you are actually friendly
}
}
merch.traderelation = rel;
}
else
{
rel = sti(merch.traderelation); // PB: Use the SAME relation for the WHOLE dialog
}
// <--PURSEON
//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(mNation == PIRATE)
{
// Pirates don't do business with the navy
if(ProfessionalNavyNation() == UNKNOWN_NATION)
{
// If you aren't hostile with the pirates, they'll always accept you
if(rel > REL_WAR) return true;
// If you have no loyalties to any one nation, they'll accept you too
if(GetLetterOfMarqueQuantity() == 0) return true;
}
}
else
{
// 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 less than Hostile to you and you are Matey or better
if(rel > REL_WAR && rep >= TRADEREP_WAR ) return true;
// If their nation is better than Wary and you are Neutral or better
if(rel >= REL_AFTERATTACK && rep >= TRADEREP_NEUTRAL ) return true;
// If their nation is better than Neutral, you are Swindler or better and can intimidate them
if(rel >= REL_AMNESTY && 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;
// You are friendly to the pirates, flying a pirate flag and the town is tolerant of pirates
if(CheckForPirateException(merch) ) return true;
}
// 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(char.quest.generate_trade_quest_progress.iTradeColony == GetCurrentTownID()) return true;
}
//MAXIMUS <-[we are here already, why we can't complete our mission?]-
return false;
}