void GenerateQuestShip(string captain_id, int maxclass, int minclass, int iNation) // KK
{
//This function will generate a ship and generate the captain on the given captain_id character
//You should provide a min and max class for the ship. It doesn't matter if these are reverted by accident, it will be caught.
//Check if the character is an enemy
bool isEnemy = false;
if(captain_id == "Quest pirate" ) isEnemy = true;
if(captain_id == "Convoy pirate") isEnemy = true;
//Get the captain which is only half setup
ref rCaptain = characterFromID(captain_id);
//Determine the nation of the ship etc
if(isEnemy) iNation = LotHostileNation(iNation);
else iNation = iNation;
//Extract the nation and fantomtype from it
string sFantomType = "war";
if( iNation >= NATIONS_QUANTITY) iNation = PIRATE;
if( iNation == PIRATE) sFantomType = "pirate";
//Determine the max and minclass of the ship
int iShipType;
if(sti(rCaptain.nation) == PIRATE && maxclass < MAXPIRATECLASS) maxclass = MAXPIRATECLASS;
if(HasSubStr(captain_id,"Coastal_Captain") && maxclass < MAXCOASTGUARDCLASS) maxclass = MAXCOASTGUARDCLASS;
if(GetCurrentPeriod() <= PERIOD_EARLY_EXPLORERS || GetCurrentPeriod() >= PERIOD_NAPOLEONIC)
{
if(iNation == HOLLAND && maxclass < 3) maxclass = 3;
if(iNation == PORTUGAL && maxclass < 3) maxclass = 3;
}
if(minclass > 8) minclass = 8;
//Make the ship
iShipType = Force_GetShipType(maxclass, minclass, sFantomType, iNation); //Levis: Also make sure the right fantomtype is set for the ship
//Generate the captain
if(DEBUG_CAPTAIN_CREATION>1) Trace("CAPTAIN CREATION: In function GenerateQuestShip");
rCaptain = LAi_Create_Captain(rCaptain, sFantomType, iShipType, iNation); //Levis new function to create a captain
// PB: Have these ships always hostile, regardless of flag
rCaptain.recognized = true;
if(captain_id == "Quest pirate") // PB: For Governor Quest Ships only
{
//NK edit trademoney
ref Shiptype = GetShipByType(iShipType);
aref arship; makearef(arship, rCaptain.ship);
ref pchar = GetMainCharacter();
float shipmult = 5.0 * sqrt(intRet(sti(Shiptype.CannonsQuantity),sti(Shiptype.CannonsQuantity),1) * sti(GetLocalShipAttrib(arship, Shiptype, "HP")) * stf(GetLocalShipAttrib(arship, Shiptype, "SpeedRate"))); // PRS3
float commult = 1.0 + makeint(CalcCharacterSkill(pchar, SKILL_COMMERCE))/20.0;
int iTradeMoney = makeint(sqrt(sti(rCaptain.rank)) * shipmult * commult/25)*25;
if(iTradeMoney < 100) iTradeMoney = 100;
pchar.quest.generate_kill_quest = "begin";
pchar.quest.generate_kill_quest.money = iTradeMoney;
pchar.quest.generate_kill_quest.town = GetCurrentTownID();//MAXIMUS
pchar.quest.generate_kill_quest.destination = Islands[GetCharacterCurrentIsland(Pchar)].id;
pchar.quest.generate_kill_quest.nation = iNation; // KK // MAXIMUS
pchar.quest.generate_kill_quest.shipname = rCaptain.Ship.Name;
}
}