------------------------------------------------------------------------------------------------------------------------------------
function beginChapterOne()
    
    local CannonMerchantID = GetEntityId("CannonMerchant")
    Logic.AddMercenaryOffer(CannonMerchantID, Entities.PV_Cannon4, 4, ResourceType.Sulfur, 500, ResourceType.Iron, 400, ResourceType.Gold, 700)
	Logic.AddMercenaryOffer(CannonMerchantID, Entities.PU_LeaderHeavyCavalry2, 2, ResourceType.Iron, 1500, ResourceType.Sulfur, 2000, ResourceType.Gold, 5000)

    StartCutscene(Cutscenes[INTROCUTSCENE],createBriefingPrelude)
    createBriefingCrossroads()    

    createQuestDefeat()

    createFortifyVillageQuest()

    -- sub quest

    end
------------------------------------------------------------------------------------------------------------------------------------
function endChapterOne()

    ResolveBriefing(preludeBriefing[preludeBriefingCommander])

    createBriefingFortifyVillageDone()

    --destroyBriefingCrossroads()

    beginChapterTwo()

    end
------------------------------------------------------------------------------------------------------------------------------------
function beginChapterTwo()

    createBriefingOpenBridge()

    end
------------------------------------------------------------------------------------------------------------------------------------
function endChapterTwo()

    ResolveBriefing(briefingFortifyVillageDone[briefingFortifyVillageDonePage])

     --DestroyNPC(npcOpenBridge)

    ReplaceEntity("bridge",Entities.PB_DrawBridgeClosed1)
	
	bridgeopen = true
	bridgeflag = 2
	table.insert(availableCaves,5)

    beginChapterThree()

    createArmyWayDefenders()

    end
------------------------------------------------------------------------------------------------------------------------------------
function beginChapterThree()

    createQuestDestroyCamp()

    end
------------------------------------------------------------------------------------------------------------------------------------
function endChapterThree()

    ResolveBriefing(briefingOpenBridge[briefingOpenBridgeDestroyCamp])

    for i = 1,6,1 do
        local name = "b"..i
        ChangePlayer(name,1)
        end

    for i = 1,4,1 do
        local name = "scout"..i
        ChangePlayer(name,1)
        end

    beginChapterFour()

    end
------------------------------------------------------------------------------------------------------------------------------------
function beginChapterFour()

    createBriefingLab()

    createQuestWeather()

    end
------------------------------------------------------------------------------------------------------------------------------------
function endChapterFour()

    ResolveBriefing(briefingLab[briefingChangeWeather])

    beginChapterFive()

    end
------------------------------------------------------------------------------------------------------------------------------------
function beginChapterFive()

    createArmyCamps()

    createQuestRescueGateKeeper()
	
	createBriefingKeyKeeper()

    createBriefingGuards()

    createBriefingHelias()

    --createQuestHelias()

    createBriefingVictory()

    end
------------------------------------------------------------------------------------------------------------------------------------
function endChapterFive()

--    ResolveBriefing(briefingHelias[briefingHeliasPage])
	StartCutscene(Cutscenes[MISSIONCOMPLETECUTSCENE],Victory)


    end
	
GameCallback_NPCInteraction = function(_heroId,_npcId)
	if IsBriefingActive() then
		return
	end
	if Logic.IsHero(_heroId) then
		if _npcId == GetEntityId("scharfiTyp") then
			if _heroId ~= GetID("Salim") then	
				Message("Ich möchte gerne mit Salim sprechen.")
				return
			end
			if IsNear(_heroId,_npcId,BRIEFING_TALK_DISTANCE) then
				createBriefingScharfi()
			end
			
		end
		if _npcId == GetEntityId("crossroads") then
			if IsNear(_heroId,_npcId,BRIEFING_TALK_DISTANCE) then
				if fortifyVillageQuestDone == true then
					StartBriefing(briefingOpenBridge)
				else
					StartBriefing(briefingCrossroads)
				end
				
			end
		end
		if _npcId == GetEntityId("guard1") then
			if IsNear(_heroId,_npcId,BRIEFING_TALK_DISTANCE) then
				StartBriefing(briefingGuard1)
			end
		end
		if _npcId == GetEntityId("guard2") then
			if IsNear(_heroId,_npcId,BRIEFING_TALK_DISTANCE) then
				StartBriefing(briefingGuard2)
			end
		end
		if _npcId == GetEntityId("keyKeeper") then
			if IsNear(_heroId,_npcId,BRIEFING_TALK_DISTANCE) then
				briefingKeyKeeper[1].position 	    = 	GetPosition("keyKeeper")
				briefingKeyKeeper[2].position 	    = 	GetPosition("gateKeeper")
				if NPCKeyKapperSwap then
					StartBriefing(briefingKeyKeeper2)
				else
					StartBriefing(briefingKeyKeeper)
				end
			end
		end
		local id = Logic.GetMerchantBuildingId(_npcId)

		if id ~= 0 then
			GUIAction_MerchantCallback(id, _heroId)
		end
	end
end