;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 3
Scriptname QF_CWResetGarrison2_000548D5 Extends Quest Hidden

;BEGIN ALIAS PROPERTY Soldier46
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier46 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier28
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier28 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier26
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier26 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier48
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier48 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY CenterMarker
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_CenterMarker Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier23
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier23 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier43
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier43 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier63
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier63 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier27
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier27 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier49
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier49 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier47
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier47 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier29
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier29 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier62
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier62 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier42
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier42 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier22
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier22 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier41
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier41 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier61
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier61 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier21
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier21 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier24
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier24 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY EnableMarkerImperialExterior
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_EnableMarkerImperialExterior Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier64
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier64 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier44
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier44 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier20
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier20 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY EnableMarkerSons
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_EnableMarkerSons Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier60
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier60 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier40
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier40 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier45
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier45 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier25
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier25 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier18
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier18 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY EnableMarkerImperial
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_EnableMarkerImperial Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier5
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier5 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier56
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier56 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier58
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier58 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier36
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier36 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier16
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier16 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier13
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier13 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier33
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier33 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY EnableMarkerMonster
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_EnableMarkerMonster Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier53
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier53 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier17
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier17 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier59
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier59 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier37
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier37 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier4
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier4 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier57
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier57 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier19
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier19 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier52
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier52 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY EnableMarkerSonsExterior
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_EnableMarkerSonsExterior Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier32
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier32 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier12
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier12 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier51
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier51 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier2
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier2 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier11
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier11 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier31
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier31 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier9
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier9 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier14
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier14 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Garrison
;ALIAS PROPERTY TYPE LocationAlias
LocationAlias Property Alias_Garrison Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier7
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier7 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier54
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier54 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier30
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier30 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier10
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier10 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier8
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier8 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier50
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier50 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier3
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier3 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier6
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier6 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier55
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier55 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier1
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier1 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier39
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier39 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier34
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier34 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier15
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier15 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier38
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier38 Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY Soldier35
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_Soldier35 Auto
;END ALIAS PROPERTY

;BEGIN FRAGMENT Fragment_2
Function Fragment_2()
;BEGIN AUTOCAST TYPE CWResetGarrisonScript
Quest __temp = self as Quest
CWResetGarrisonScript kmyQuest = __temp as CWResetGarrisonScript
;END AUTOCAST
;BEGIN CODE
; ; debug.traceConditional(self + " shutdown stage 255 is setting CW WaitingForCWResetGarrisonQuest1 to false", kmyquest.CWs.debugOn.value)
kmyquest.CWs.WaitingForCWResetGarrisonQuest2 = false
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN AUTOCAST TYPE CWResetGarrisonScript
Quest __temp = self as Quest
CWResetGarrisonScript kmyQuest = __temp as CWResetGarrisonScript
;END AUTOCAST
;BEGIN CODE
;1 Toggles enable markers for soldiers based on the owner
;2 Disables the enable marker if the Garrison is a camp owned by the defender
;3 Resets any enabled soldier and kills any disabled ones so we can poll for any living CWSoldier without worrying about factions
;4 Makes the CWOwner keyword data positive value
;5 If Garrison is a capital, it starts a CWGovernment quest
;6 Stops quest

; ; debug.traceConditional(self + " stage 0. Garrison Location is " + Alias_Garrison.GetLocation(), kmyquest.CWs.debugOn.value)

location GarrisonLoc = Alias_Garrison.GetLocation()

if GarrisonLoc.HasKeyword(kmyquest.CWs.CWGarrison) && GarrisonLoc.GetKeywordData( kmyquest.CWs.CWGarrison) == -2

; ; 	debug.traceConditional(self + " stage 0. Garrison Location has CWGarrison Keyword Data of -1, this means DO NOT reset this place ", kmyquest.CWs.debugOn.value)

elseif GarrisonLoc.HasKeyword(kmyquest.CWs.CWFort) && GarrisonLoc.GetKeywordData( kmyquest.CWs.CWFort) == -2

; ; 	debug.traceConditional(self + " stage 0. Garrison Location has CWFort Keyword Data of -1, this means DO NOT reset this place ", kmyquest.CWs.debugOn.value)

else

	kmyquest.ToggleEnableMarkers(Alias_EnableMarkerImperial, Alias_EnableMarkerSons, Alias_EnableMarkerImperialExterior, Alias_EnableMarkerSonsExterior, Alias_EnableMarkerMonster)
	kmyquest.ProcessIfCamp(Alias_EnableMarkerImperial, Alias_EnableMarkerSons)

	;Process soldier aliases - Kill() if disabled, Reset() if enabled. Also sets the proper crime faction.
	kmyquest.ProcessSoldierAliases()

	kmyquest.StartCWGovernmentQuestIfCapital()

endif

	kmyquest.SetOwnershipKeywordData()

; ; debug.traceConditional(self + " stage 0 calling Stop() on itself.", kmyquest.CWs.debugOn.value)
Stop()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment
