Scriptname BaboFollowerMasterScript extends Quest  

Quest Property BaboEvent Auto

Actor Property PlayerRef auto

Actorbase property Foe00 auto
Actorbase property Foe01 auto
Actorbase property Foe02 auto
Actorbase property Foe03 auto
Actorbase property Foe04 auto
Actorbase property Foe05 auto
Actorbase property Foe06 auto
Actorbase property Foe07 auto
Actorbase property Foe08 auto
Actorbase property Foe09 auto
Actorbase property Foe10 auto

ReferenceAlias Property BaboFollowerRef01 Auto
ReferenceAlias Property BaboFollowerRef02 Auto
ReferenceAlias Property BaboFollowerRef03 Auto
ReferenceAlias Property BaboFollowerRef04 Auto
ReferenceAlias Property BaboFollowerRef05 Auto

Actorbase property BaboFollowerBase01 auto
Actorbase property BaboFollowerBase02 auto
Actorbase property BaboFollowerBase03 auto
Actorbase property BaboFollowerBase04 auto
Actorbase property BaboFollowerBase05 auto

ReferenceAlias Property BanditBoss Auto
ReferenceAlias Property Bandit01 Auto
ReferenceAlias Property Bandit02 Auto
ReferenceAlias Property Bandit03 Auto
ReferenceAlias Property Bandit04 Auto
ReferenceAlias Property Bandit05 Auto
ReferenceAlias Property Bandit06 Auto
ReferenceAlias Property Bandit07 Auto
ReferenceAlias Property Bandit08 Auto
ReferenceAlias Property Bandit09 Auto
ReferenceAlias Property Bandit10 Auto


Faction Property PotentialFollowerFaction Auto
Faction Property CurrentFollowerFaction Auto
Faction Property BaboSlaveFaction Auto
Faction Property BaboReleasedFaction Auto
Faction Property BaboRunawayFaction Auto
Faction Property BaboSoulmate Auto

Outfit Property NakedOutfit Auto
Outfit Property NakedOutfit02 Auto
Outfit Property NakedOutfit03 Auto
Outfit Property BasicOutfit Auto
Outfit Property BasicOutfit02 Auto
Outfit Property BasicOutfit03 Auto
Outfit Property BasicOutfit04 Auto
Outfit Property BasicOutfit05 Auto

Scene Property CustomScene Auto

Int Property CustomStage Auto

Int Property CustomStage01a Auto
Int Property CustomStage01b Auto
Int Property CustomStage02a Auto
Int Property CustomStage02b Auto

Int Property CustomNextStage01 Auto
Int Property CustomNextStage02 Auto

Idle Property BaboKnockOut01Start Auto
Idle Property BaboWomanPanting01 Auto
Idle Property BaboDefeatedCollapseLoop01 Auto

Keyword Property SLA_ArmorHalfNaked Auto
Keyword Property SLA_ArmorHalfNakedBikini Auto
Keyword Property SLA_ArmorPretty Auto
Keyword Property SLA_ArmorSpendex Auto
Keyword Property eroticarmor Auto

Int property BFFaintCountNum = 0 auto hidden conditional
Int Property BFFaintCountGoalNum Auto
Int Property nextstage Auto


ReferenceAlias property PlayerEssential auto

Function GoStateFirst()
	GotoState("FirstFollower")
EndFunction

Function GoAfterStory()
	GotoState("AfterStory")
EndFunction

Function SpawnFolloweratPlace(ObjectReference SpawnPlace, int Num)
	If Num == 1
		Actor BaboFollower01 = SpawnPlace.PlaceActorAtMe(BaboFollowerBase01, 4)
		BaboFollowerRef01.ForceRefTo(BaboFollower01)
	ElseIf Num == 2
		Actor BaboFollower02 = SpawnPlace.PlaceActorAtMe(BaboFollowerBase02, 4)
		BaboFollowerRef02.ForceRefTo(BaboFollower02)
	ElseIf Num == 3
		Actor BaboFollower03 = SpawnPlace.PlaceActorAtMe(BaboFollowerBase03, 4)
		BaboFollowerRef03.ForceRefTo(BaboFollower03)
	ElseIf Num == 4
		Actor BaboFollower04 = SpawnPlace.PlaceActorAtMe(BaboFollowerBase04, 4)
		BaboFollowerRef04.ForceRefTo(BaboFollower04)
	ElseIf Num == 5
		Actor BaboFollower05 = SpawnPlace.PlaceActorAtMe(BaboFollowerBase05, 4)
		BaboFollowerRef05.ForceRefTo(BaboFollower05)
	Else
		;WTF
	EndIf
EndFunction

Function SpawnFoesatPlace(ObjectReference SpawnPlace, int Num) ; Necessary?
	If Num == 0
		Actor FoeRef00 = SpawnPlace.PlaceActorAtMe(Foe00, 4)
		BanditBoss.ForceRefTo(FoeRef00)
	ElseIf Num == 1
		Actor FoeRef01 = SpawnPlace.PlaceActorAtMe(Foe01, 4)
		Bandit01.ForceRefTo(FoeRef01)
	ElseIf Num == 2
		Actor FoeRef02 = SpawnPlace.PlaceActorAtMe(Foe02, 4)
		Bandit02.ForceRefTo(FoeRef02)
	ElseIf Num == 3
		Actor FoeRef03 = SpawnPlace.PlaceActorAtMe(Foe03, 4)
		Bandit03.ForceRefTo(FoeRef03)
	ElseIf Num == 4
		Actor FoeRef04 = SpawnPlace.PlaceActorAtMe(Foe04, 4)
		Bandit04.ForceRefTo(FoeRef04)
	ElseIf Num == 5
		Actor FoeRef05 = SpawnPlace.PlaceActorAtMe(Foe05, 4)
		Bandit05.ForceRefTo(FoeRef05)
	ElseIf Num == 6
		Actor FoeRef06 = SpawnPlace.PlaceActorAtMe(Foe06, 4)
		Bandit06.ForceRefTo(FoeRef06)
	ElseIf Num == 7
		Actor FoeRef07 = SpawnPlace.PlaceActorAtMe(Foe07, 4)
		Bandit07.ForceRefTo(FoeRef07)
	ElseIf Num == 8
		Actor FoeRef08 = SpawnPlace.PlaceActorAtMe(Foe08, 4)
		Bandit08.ForceRefTo(FoeRef08)
	ElseIf Num == 9
		Actor FoeRef09 = SpawnPlace.PlaceActorAtMe(Foe09, 4)
		Bandit09.ForceRefTo(FoeRef09)
	ElseIf Num == 10
		Actor FoeRef10 = SpawnPlace.PlaceActorAtMe(Foe10, 4)
		Bandit10.ForceRefTo(FoeRef10)
	Else
		;WTF
	EndIf
EndFunction

Function SceneToStart()
	CustomScene.start()
EndFunction

Function SceneToStop()
	CustomScene.stop()
EndFunction

Function MovetoSpot(Actor Victim, ObjectReference SpotPlace)
	Victim.moveto(SpotPlace)
EndFunction

Function SpawnEnemies(ActorBase Enemy, ObjectReference SpawnMarker, int LVL, ReferenceAlias EnemyRef)
	Actor Enemy01 = SpawnMarker.PlaceActorAtMe(Enemy, LVL)
	EnemyRef.ForceRefTo(Enemy01)
EndFunction

Function DSlaveFaction(actor Victim)
	Victim.addtofaction(BaboSlaveFaction)
	Victim.Removefromfaction(BaboReleasedFaction)
	Victim.Removefromfaction(PotentialFollowerFaction)
	Victim.Removefromfaction(CurrentFollowerFaction)
	;Victim.Removefromfaction(BaboSoulmate)
EndFunction

Function DReleasedFaction(actor Victim)
	Victim.addtofaction(BaboReleasedFaction)
	Victim.Removefromfaction(BaboSlaveFaction)
EndFunction

Function DRunawayFaction(actor Victim)
	Victim.addtofaction(BaboRunawayFaction)
EndFunction

Function DFollowerFaction(actor Victim)
	Victim.setfactionrank(CurrentFollowerFaction, -1)
	Victim.addtofaction(PotentialFollowerFaction)
	Victim.addtofaction(BaboSoulmate)
	Victim.Removefromfaction(BaboSlaveFaction)
	Victim.Removefromfaction(BaboReleasedFaction)
	Victim.Removefromfaction(BaboRunawayFaction)
	Victim.setrelationshipRank(Game.getplayer(), 3)
EndFunction

Function ResetFollowerFaction(actor Victim)
	Victim.removefromfaction(CurrentFollowerFaction)
	Victim.removefromfaction(PotentialFollowerFaction)
	Victim.removefromfaction(BaboSoulmate)
	Victim.Removefromfaction(BaboSlaveFaction)
	Victim.Removefromfaction(BaboReleasedFaction)
	Victim.Removefromfaction(BaboRunawayFaction)
	Victim.setrelationshipRank(Game.getplayer(), 1)
EndFunction

Function NPCChallengeStart(ReferenceAlias Alias01, ReferenceAlias Alias02, Faction NPCAlias01Faction, Faction NPCAlias02Faction, Faction NPCRemoveFaction01, Faction NPCRemoveFaction02)
	Actor ActorRef01 = Alias01.GetActorReference()
	Actor ActorRef02 = Alias02.GetActorReference()
	NPCFactionSwap(ActorRef01, ActorRef02, NPCAlias01Faction, NPCAlias02Faction, NPCRemoveFaction01, NPCRemoveFaction02)
	if actorRef01.GetActorValue("Confidence") < 4
		actorRef01.SetActorValue("Confidence", 4) 
	EndIf
	if actorRef02.GetActorValue("Confidence") < 4
		actorRef02.SetActorValue("Confidence", 4) 
	EndIf
	actorRef01.startCombat(actorRef02)
	actorRef02.startCombat(actorRef01)
EndFunction

Function NPCFactionSwap(Actor akactor01, Actor akaactor02, Faction AddFaction01, Faction AddFaction02, Faction RemoveFaction01, Faction RemoveFaction02)

	akactor01.addtoFaction(AddFaction01)
	akaactor02.addtoFaction(AddFaction02)
	akactor01.RemoveFromFaction(RemoveFaction01)
	akaactor02.RemoveFromFaction(RemoveFaction02)

EndFunction

Function SwitchXmarker(ObjectReference EMarker, ObjectReference DMarker)
	Emarker.Disable()
	Dmarker.Enable()
EndFunction

Function Getnaked(actor Victim, Int Num)
	If Num == 1
		Victim.SetOutfit(NakedOutfit)
	ElseIf Num == 2
		Victim.SetOutfit(NakedOutfit02)
	ElseIf Num == 3
		Victim.SetOutfit(NakedOutfit03)
	EndIf
EndFunction

Function GetBasic(actor Victim, Int Num)
	If Num == 1
		Victim.SetOutfit(BasicOutfit)
	ElseIf Num == 2
		Victim.SetOutfit(BasicOutfit02)
	ElseIf Num == 3
		Victim.SetOutfit(BasicOutfit03)
	ElseIf Num == 4
		Victim.SetOutfit(BasicOutfit04)
	ElseIf Num == 5
		Victim.SetOutfit(BasicOutfit05)
	EndIf
EndFunction

Function RegisterUpdate(Int TimeLimit)
	;Debug.notification("RegisterUpdate")
	RegisterForSingleUpdateGameTime(TimeLimit); this is Customizable
EndFunction

Function UnRegisterUpdate()
	;Debug.notification("UnregisterUpdate")
	UnregisterForUpdate()
EndFunction

Function PlayerControl(Bool Control)

If Control
	Game.EnablePlayerControls()
	Game.SetPlayerAIDriven(false)
	Game.ForceThirdPerson()
Else
	Game.DisablePlayerControls( true, true, false, false, true, true, false, false )
	Game.SetPlayerAIDriven( true )
	if Game.GetCameraState() == 0
		Game.ForceThirdPerson()
	endIf
Endif
	
EndFunction

Function MakingOneInvincible(actor theone, int option);1 protected 2 essential 3 invincible 4 disable them all

actorbase theonebase = theone.getactorbase()

if option == 1
	theonebase.setprotected()
elseif option == 2
	theonebase.setessential()
elseif option == 3
	theonebase.setinvulnerable()
elseif option == 4
	theonebase.setprotected(false)
	theonebase.setessential(false)
	theonebase.setinvulnerable(false)
endif

EndFunction

Function FaintMotionPlay(actor akactor)

if akactor == game.getplayer()
	Game.DisablePlayerControls(abmenu = true)
else
	akactor.SetUnconscious(true)
	akactor.SetRestrained()
	akactor.SetDontMove(True)
endif

int roulette = Utility.randomint(1,3)

if roulette == 1
	akactor.playidle(BaboKnockOut01Start)
elseif roulette == 2
	akactor.playidle(BaboWomanPanting01)
elseif roulette == 3
	akactor.playidle(BaboDefeatedCollapseLoop01)
endif

EndFunction

Function WakeupActor(actor akactor)

if akactor == game.getplayer()
	Game.EnablePlayerControls(abmenu =true)
else
	akactor.SetUnconscious(false)
	akactor.SetRestrained(false)
	akactor.SetDontMove(false)
endif

EndFunction

Int Function BFFaintCount()
	BFFaintCountNum = BFFaintCountNum + 1
	Debug.Trace(BFFaintCountNum + " + 1")
		If BFFaintCountNum >= BFFaintCountGoalNum
			BaboEvent.setstage(nextstage)
		EndIf
	Return BFFaintCountNum
EndFunction

Function PlayerTurntoEssential(Bool Switch)
If Switch
	PlayerEssential.forcerefto(PlayerRef)
Else
	PlayerEssential.clear()
Endif
EndFunction

Auto State FirstFollower
Event OnUpdateGameTime()
	If GetStage() == 5 || 6 || CustomStage
		SetStage(10)
	ElseIf Getstage() == 15
		Setstage(16)
	Endif
EndEvent
EndState

State AfterStory
Event OnUpdateGameTime()
	If GetStage() == CustomStage01a || CustomStage01b
		SetStage(CustomNextStage01);9
	ElseIf GetStage() == CustomStage02a || CustomStage02b
		Setstage(CustomNextStage02);13
	Endif
EndEvent
EndState

State SecondFollower
EndState
