void StartStoryLine()
{
	ref PChar = GetMainCharacter();

	bChangeNation = false;// MAXIMUS 7-8-06
	ALLOW_NATION_CHANGE = 0;

// KK -->
	aref arstart = GetStorylineStartParams(FindCurrentStoryline());
	string loadPort = arstart.port;
	string rldGroup = "reload";
	string rldLocator = "reload1";
	int iNation = 0;
	int loc = FindLocation(arstart.location);

	sTeleportLocName = arstart.location;

	// MainCharacter start parameters
	if (sti(GetStorylineVar(FindCurrentStoryline(), "EVIL_STORMY_START")) == true) {
		PChar.skill.Leadership = 1;
		PChar.skill.Fencing = 1;
		PChar.skill.Sailing = 1;
		PChar.skill.Accuracy = 1;
		PChar.skill.Cannons = 1;
		PChar.skill.Grappling = 1;
		PChar.skill.Repair = 1;
		PChar.skill.Defence = 1;
		PChar.skill.Commerce = 1;
		PChar.skill.Sneak = 1;
		PChar.skill.freeskill = 0;

		PChar.Ship.Name = "Leaky Bucket";
		PChar.Ship.Type = "Tartane2";

		PChar.money = 0;
		PChar.wealth = 0;
	}

	//NK -->
	if (CharLocation == 0) {
		PChar.Ship.HP = MakeInt(GetCharacterShipHP(PChar) * 3 / 5);
		PChar.Ship.crew.quantity = MakeInt(GetMaxCrewQuantity(PChar) * 3/5);

		if (sti(GetStorylineVar(FindCurrentStoryline(), "EVIL_STORMY_START")) == true)
		{
			PChar.Ship.SP = MakeInt(GetCharacterShipSP(PChar) * 3 / 5); // Evil Stormy Start further damages sails
		}
		else
		{
			PChar.Ship.SP = MakeInt(GetCharacterShipSP(PChar) * 4 / 5); // MAXIMUS interface MOD
		}
	}
	// to fix the good overup stuff 05-04-06 NK -->
	string goods_id;
	for(int n=0; n<GOODS_QUANTITY; n++)
	{
		if(!CheckAttribute(Goods[n],"name")) continue;
		goods_id = Goods[n].name;
		PChar.Ship.Cargo.Goods.(goods_id) = 0;
	}
	// NK <--
	int space = GetCargoMaxSpace(PChar); // MAXIMUS interface MOD // KK

// KK -->
// added by MAXIMUS [gunpowder mod] -->
	// fixed 05-04-06 to use makeint() -->
	int loadBalls = makeint(GetCannonQuantity(PChar)*BALLS_PER);
	int loadGrapes = makeint(GetCannonQuantity(PChar)*GRAPE_PER);
	int loadChain = makeint(GetCannonQuantity(PChar)*CHAIN_PER);
	int loadBombs = makeint(GetCannonQuantity(PChar)*BOMBS_PER*(!USE_REAL_CANNONS));
	int loadWheat = makeint(sti(PChar.ship.crew.quantity) * FOOD_PER_CREW * WHEAT_DAYS);
	int loadRum = makeint(sti(PChar.ship.crew.quantity) * FOOD_PER_CREW * RUM_DAYS);

	int loadGunpowder = makeint(GetCannonQuantity(PChar) * GetCannonChargesPerCannon(PChar)) * CANNONPOWDER_MOD;
	if (loadGunpowder < 0) loadGunpowder = 0;
	loadGunpowder *= (BALLS_PER + GRAPE_PER + CHAIN_PER + BOMBS_PER*(!USE_REAL_CANNONS));

	int loadCargo = GetGoodWeightByType(GOOD_BALLS, loadBalls) + GetGoodWeightByType(GOOD_GRAPES, loadGrapes) + GetGoodWeightByType(GOOD_KNIPPELS, loadChain) + GetGoodWeightByType(GOOD_BOMBS, loadBombs) + GetGoodWeightByType(GOOD_WHEAT, loadWheat) + GetGoodWeightByType(GOOD_RUM, loadRum) + GetGoodWeightByType(GOOD_GUNPOWDER, loadGunpowder);

	if (space < loadCargo) {
		int cargo_count = makeint((loadBalls > 0) + (loadGrapes > 0) + (loadChain > 0) + (loadBombs > 0) + (loadWheat > 0) + (loadRum > 0));
		if (cargo_count != 0) {
			loadBalls /= cargo_count;
			loadGrapes /= cargo_count;
			loadChain /= cargo_count;
			loadBombs /= cargo_count;
			loadWheat /= cargo_count;
			loadRum /= cargo_count;
			loadGunpowder /= cargo_count;
		}
	}
	SetCharacterGoods(&PChar, GOOD_BALLS, loadBalls);
	SetCharacterGoods(&PChar, GOOD_GRAPES, loadGrapes);
	SetCharacterGoods(&PChar, GOOD_KNIPPELS, loadChain);
	SetCharacterGoods(&PChar, GOOD_BOMBS, loadBombs);
	SetCharacterGoods(&PChar, GOOD_WHEAT, loadWheat);
	SetCharacterGoods(&PChar, GOOD_RUM, loadRum);
	SetCharacterGoods(&PChar, GOOD_GUNPOWDER, loadGunpowder);

	if (CharGood1 == GOOD_SAILCLOTH || CharGood1 == GOOD_PLANKS) 	CharGood1 = GOOD_LEATHER;
	if (CharGood1 == GOOD_WHEAT || CharGood1 == GOOD_RUM) 			CharGood1 = GOOD_LEATHER;
	if (CharGood2 == GOOD_SAILCLOTH || CharGood2 == GOOD_PLANKS) 	CharGood2 = GOOD_CHOCOLATE;
	if (CharGood2 == GOOD_WHEAT || CharGood2 == GOOD_RUM) 			CharGood2 = GOOD_CHOCOLATE;

	space -= loadCargo;
	float cargo_div = Rand(100)/100.0;
	loadCargo = makeint(cargo_div*space);
	if (loadCargo > 100) loadCargo = 100;
	SetCharacterGoods(&PChar, CharGood1, loadCargo);
	space -= loadCargo;
	loadCargo = makeint((1.0-cargo_div)*space);
	if (loadCargo > 100) loadCargo = 100;
	SetCharacterGoods(&PChar, CharGood2, loadCargo);


// by this section we are adding money to character (if he has a unsufficiently sum for ship's repair and crew's hiring) -->
	ref sto; makeref(sto, Stores[CharStore]);
	int cargoPrice1 = GetGoodPriceByType(sto, PChar, CharGood1, GetCargoGoods(PChar,CharGood1),PRICE_TYPE_SELL);
	int cargoPrice2 = GetGoodPriceByType(sto, PChar, CharGood2, GetCargoGoods(PChar,CharGood2),PRICE_TYPE_SELL);
	if (CharGood1 == CharGood2) cargoPrice2 = 0; // KK
    float qty = 1;
	switch(Rand(5))
    {
		case 0: qty = 1.356; break;
		case 1: qty = 1.890; break;
		case 2: qty = 1.674; break;
		case 3: qty = 1.724; break;
		case 4: qty = 1.057; break;
		case 5: qty = 1.532; break;
    }

	int sailCostPercent = 10;
	int hullCostPercent = 20;
	aref arCurShip; makearef(arCurShip, PChar.ship);
	int shipPrice = sti(GetLocalShipAttrib(arCurShip, GetCharacterShipType(PChar), "Price"));
	int hireQty = makeint(GetMaxCrewQuantity(PChar) - GetCrewQuantity(PChar));

	int hireCost = sti(GetCrewHireCost(PChar) * hireQty);
	int repCost = MakeInt(makeint((((shipPrice*hullCostPercent+99)/100)*makeint(100 - MakeInt(GetHullPercent(PChar)))+99)/100)) + MakeInt((makeint((shipPrice*sailCostPercent+99)/100)*makeint(100 - MakeInt(GetSailPercent(PChar)))+99)/100);

	int avPrice = makeint(cargoPrice1 + cargoPrice2)*qty;
	if (sti(GetStorylineVar(FindCurrentStoryline(), "EVIL_STORMY_START")) == false) {
		if (makeint(cargoPrice1 + cargoPrice2) < sti(hireCost+repCost)) {
			int addMoney = makeint(sti(hireCost+repCost)-avPrice);
			if (addMoney > 0)
				AddMoneyToCharacter(PChar, addMoney);
			else
				AddMoneyToCharacter(PChar, sti(hireCost+repCost));
		} else {
			PChar.money = makeint(START_MONEY*qty);// TIH fixed decimal gold on start new game
		}
	}
// by this section we are adding money to character (if he has a unsufficiently sum for ship's repair and crew's hiring) <--

// added by MAXIMUS [gunpowder mod] <--

	// NK new location tags 04-08-29
	Characters[GetMainCharacterIndex()].newloctags = true;

	Characters[GetCharacterIndex("Danielle")].model.animation = "woman";

	string cabinID;
	if (sti(GetStorylineVar(FindCurrentStoryline(), "USE_PROPER_TUTORIAL_DECK")) == true)
		cabinID = GetCharacterShipCabin(PChar);
	else
		cabinID = "Tutorial_Deck";

	rldGroup = "rld";
	rldLocator = "startloc";
	if (cabinID != "Cabin_none") {
		SetUpCabin(PChar);
		if (cabinID != "Tutorial_Deck") Locations[FindLocation("Tutorial_Deck")].items.randitem1 = "";
	} else {
		SetModelFromID(CharacterFromID("Malcolm Hatcher"), "Corsair5");
		SetUpCabin(CharacterFromID("Malcolm Hatcher"));
		rldGroup = "reload";
		rldLocator = "reload1";
	}

	string rldLocator_Port = "";
	iNation = sti(PChar.nation);

// changed by MAXIMUS [choose character mod] -->
	switch(iNation)
	{
		case ENGLAND:
			loadPort = "Oxbay_port";
			rldLocator_Port = "reload2";
		break;
		case FRANCE:
			loadPort = "Falaise_de_fleur_port_01";
			rldLocator_Port = "sea";
		break;
		case SPAIN:
			loadPort = "Muelle_port";
			rldLocator_Port = "reload3";
		break;
		case PIRATE:
			loadPort = "QC_port";
			rldLocator_Port = "reload1";
		break;
		case HOLLAND:
			loadPort = "Douwesen_port";
			rldLocator_Port = "reload2";
		break;
		case PORTUGAL:
			loadPort = "Conceicao_port";
			rldLocator_Port = "reload2";
		break;
		case PERSONAL_NATION:
			rldGroup = "reload";
			switch (CharLocation) {
				case 0:
					if (cabinID != "Cabin_none") rldGroup = "rld";
					loadPort = "Oxbay_port";
					rldLocator_Port = "reload2";
				break;
				case 1:
					sTeleportLocName = "Charlestown_Port";
					loadPort = sTeleportLocName;
					rldLocator = "reload1_back";
					iNation = ENGLAND;
				break;
				case 2:
					sTeleportLocName = "Conceicao_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = PORTUGAL;
				break;
				case 3:
					sTeleportLocName = "Douwesen_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = HOLLAND;
				break;
				case 4:
					sTeleportLocName = "Falaise_de_fleur_port_01";
					loadPort = sTeleportLocName;
					rldLocator = "sea";
					iNation = FRANCE;
				break;
				case 5:
					sTeleportLocName = "Cayman_port";
					loadPort = sTeleportLocName;
					rldLocator = "sea";
					iNation = ENGLAND;
				break;
				case 6:
					sTeleportLocName = "Turks_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload1";
					iNation = PIRATE;
				break;
				case 7:
					sTeleportLocName = "Greenford_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload1";
					iNation = ENGLAND;
				break;
				case 8:
					sTeleportLocName = "Cuba_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = SPAIN;
				break;
				case 9:
					sTeleportLocName = "Muelle_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload3";
					iNation = SPAIN;
				break;
				case 10:
					sTeleportLocName = "Marigot_port";
					loadPort = sTeleportLocName;
					rldLocator = "sea";
					iNation = FRANCE;
				break;
				case 11:
					sTeleportLocName = "Oxbay_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = FRANCE;
				break;
				case 12:
					sTeleportLocName = "Philipsburg_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload1";
					iNation = HOLLAND;
				break;
				case 13:
					sTeleportLocName = "Guadeloupe_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2_back";
					iNation = FRANCE;
				break;
				case 14:
					sTeleportLocName = "Hispaniola_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = FRANCE;
				break;
				case 15:
					sTeleportLocName = "QC_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload1";
					iNation = PIRATE;
				break;
				case 16:
					sTeleportLocName = "Redmond_port";
					loadPort = "Redmond_port";
					rldLocator = "sea_1";
					iNation = ENGLAND;
				break;
				case 17:
					sTeleportLocName = "Santiago_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = SPAIN;
				break;
				case 18:
					sTeleportLocName = "Santo_Domingo_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload1";
					iNation = SPAIN;
				break;
				case 19:
					sTeleportLocName = "Antigua_port";
					loadPort = sTeleportLocName;
					rldLocator = "sea_2";
					iNation = ENGLAND;
				break;
				case 20:
					sTeleportLocName = "Tortuga_port";
					loadPort = sTeleportLocName;
					rldLocator = "reload2";
					iNation = PIRATE;
				break;
			}
		break;
	}

	if (sti(PChar.nation) != PERSONAL_NATION || CharLocation == 0) {
		string ship_deck = "";
		if (cabinID != "Cabin_none")
			ship_deck = GetCharacterShipQDeck(PChar);
		else
			ship_deck = GetCharacterShipQDeck(CharacterFromID("Malcolm Hatcher"));
		Locations[loc].reload.l1.go = ship_deck;
		Locations[loc].reload.l1.emerge = "reload1";
		Locations[FindLocation(ship_deck)].reload.l4.go = loadPort;
		Locations[FindLocation(ship_deck)].reload.l4.emerge = rldLocator_Port;
		Locations[FindLocation(ship_deck)].reload.l4.disable = 1;
		Locations[FindLocation(ship_deck)].reload.l5.go = loadPort;
		Locations[FindLocation(ship_deck)].reload.l5.emerge = rldLocator_Port;
		Locations[FindLocation(ship_deck)].reload.l5.disable = 1;
	}

	trace("Made change of cabin and deck parameters for "+CharShipType);
// <-- KK
//================================| BEGINNING QUESTS |================================//
	PChar.quest.StartAdventure.win_condition.l1 = "Timer";
	PChar.quest.StartAdventure.win_condition.l1.date.day = GetAddingDataDay(0, 0, 0);
	PChar.quest.StartAdventure.win_condition.l1.date.month = GetAddingDataMonth(0, 0, 0);
	PChar.quest.StartAdventure.win_condition.l1.date.year = GetAddingDataYear(0, 0, 0);
	PChar.quest.StartAdventure.win_condition = "StartAdventure";

	PChar.quest.Tut_start.win_condition.l1 = "location";
	PChar.quest.Tut_start.win_condition.l1.character = PChar.id;
	PChar.quest.Tut_start.win_condition.l1.location = "Tutorial_Deck";
	PChar.quest.Tut_start.win_condition = "Tut_start";

	//Hitman
	PChar.quest.Hitman = "";
	PChar.quest.Hit_start.win_condition.l1 = "location";
	PChar.quest.Hit_start.win_condition.l1.character = PChar.id;
	PChar.quest.Hit_start.win_condition.l1.location = "Oxbay_port";
	PChar.quest.Hit_start.win_condition = "Hit_start";
	//Hitman

	//Lucas
	PChar.quest.Lucas = "";
	PChar.quest.Luc_start.win_condition.l1 = "location";
	PChar.quest.Luc_start.win_condition.l1.character = PChar.id;
	PChar.quest.Luc_start.win_condition.l1.location = "Muelle_Residence";
	PChar.quest.Luc_start.win_condition = "Luc_start";
	//Lucas

	//Bartolomeu
	PChar.quest.Bartolomeu = "";
	PChar.quest.Bart_start.win_condition.l1 = "location";
	PChar.quest.Bart_start.win_condition.l1.character = PChar.id;
	PChar.quest.Bart_start.win_condition.l1.location = "Grand_Cayman_Tavern";
	PChar.quest.Bart_start.win_condition = "Bart_start";
	//Bartolomeu

	//Turks quest
	PChar.quest.Turkshelp = "";
	PChar.quest.Turks_start.win_condition.l1 = "location";
	PChar.quest.Turks_start.win_condition.l1.character = PChar.id;
	PChar.quest.Turks_start.win_condition.l1.location = "Turks_Tavern";
	PChar.quest.Turks_start.win_condition = "Turks_start";
	//Turks quest

	//Missing Man quest
	PChar.quest.Missingman = "";
	PChar.quest.Missing_start.win_condition.l1 = "location";
	PChar.quest.Missing_start.win_condition.l1.character = PChar.id;
	PChar.quest.Missing_start.win_condition.l1.location = "Port_au_Prince_town";
	PChar.quest.Missing_start.win_condition = "Missing_start";
	//Missing Man quest

	//Tortuga Atmosphere
	PChar.quest.Tortuga = "";
	PChar.quest.Tortuga_start.win_condition.l1 = "location";
	PChar.quest.Tortuga_start.win_condition.l1.character = PChar.id;
	PChar.quest.Tortuga_start.win_condition.l1.location = "Tortuga_port";
	PChar.quest.Tortuga_start.win_condition = "Tortuga_start";
	//Tortuga Atmosphere

	//Santiago quest
	PChar.quest.Santiago = "";
	PChar.quest.Santiago_start.win_condition.l1 = "location";
	PChar.quest.Santiago_start.win_condition.l1.character = "Bartolomeu o Portugues";
	PChar.quest.Santiago_start.win_condition.l1.location = "Guadeloupe_Port";
	PChar.quest.Santiago_start.win_condition = "Santiago_start";
	//Santiago quest

	//First Contact quest
	PChar.quest.Firstcontact = "";
	PChar.quest.Contact_start.win_condition.l1 = "location";
	PChar.quest.Contact_start.win_condition.l1.character = PChar.id;
	PChar.quest.Contact_start.win_condition.l1.location = "Grand_Cayman_townhall";
	PChar.quest.Contact_start.win_condition = "Contact_start";
	//First Contact quest

	//Cutler Beckett Quest
	PChar.quest.Beckett = "";
	PChar.quest.Beckett_start.win_condition.l1 = "location";
	PChar.quest.Beckett_start.win_condition.l1.character = PChar.id;
	PChar.quest.Beckett_start.win_condition.l1.location = "Oxbay_port";
	PChar.quest.Beckett_start.win_condition = "Beckett_start";
	//Cutler Beckett Quest
//===============================| QUESTS SECTION END |===============================//

	ReloadProgressUpdate();

// KK -->
	if(GetActualRMRelation(iNation)<=REL_WAR)
	{
		PChar.nation = iNation;
		HoistFlag(iNation);
		SafePortLeave();
	}
// <-- KK

	AllDaysCount = 1;//MAXIMUS: calculates days amount (updating in calendar.c)
	PChar.newGameStart = true;//MAXIMUS: for adding new locators
	PChar.location.first = true;
	if (iNation != PERSONAL_NATION || CharLocation == 0) SetNextWeather("Day Storm");//MAXIMUS: we came to this port with storm, right? // KK: yes, but not always

	LoadMainCharacterInFirstLocation(sTeleportLocName, rldGroup, rldLocator, loadPort); // KK
// changed by MAXIMUS [choose character mod] <--
}
