Scriptname BIS_OnActivateSlave extends ObjectReference  

Event OnDeath(Actor akKiller)
	BISSlaveGlobal.setvalue(BISSlaveGlobal.getvalue() + 1)
	if akKiller == Game.getplayer()
		BISScript.KillCountAdding()
	endif
	if RescueTarget == BISSlaveGlobal.getvalue() as int
		BISScript.SoliloquyEnd(false)
	endif
EndEvent

Auto State StandingBy

Event Onload()
Actor selfActor = (self as ObjectReference) as Actor
if SilenceOnStart
	selfActor.AllowPCDialogue(false)
endif
EndEvent

Event onactivate(ObjectReference akActionRef)

Actor selfActor = (self as ObjectReference) as Actor
ActorBase selfActorB = self.GetBaseObject() as ActorBase
if DeadOnStart
	selfActor.Kill(selfActor)
	if selfActorB.getsex() == 1
		Debug.notification("It looks like it is too late for her.")
	else
		Debug.notification("It looks like it is too late for him.")
	endif
Return
else

BISSlaveGlobal.setvalue(BISSlaveGlobal.getvalue() + 1)
selfActor.AllowPCDialogue(true)
selfActor.say(BaboImmersiveSlavesForMBC_GoodbyeT01)
BISScript.FreeSlave(selfActor)

if RescueTarget == BISSlaveGlobal.getvalue() as int
	BISScript.SoliloquyEnd(true)
	BISRescueGlobal.setvalue(1)
endif

Gotostate("AfterRescue")
endif

EndEvent

EndState

State AfterRescue

Event Onload()
;Nothing
EndEvent

Event OnDeath(Actor akKiller)
	if akKiller == Game.getplayer()
		BISScript.KillCountAdding()
	endif
	GotoState("StandingBy")
EndEvent

Event onactivate(ObjectReference akActionRef)
;Nothing
EndEvent

EndState

GlobalVariable Property BISSlaveGlobal  Auto
GlobalVariable Property BISRescueGlobal  Auto
{Did you rescue them all?}
Int Property RescueTarget Auto
Bool Property SilenceOnStart Auto
Bool Property DeadOnStart Auto
Topic Property BaboImmersiveSlavesForMBC_GoodbyeT01  Auto  
BaboImmersiveSlave_Main Property BISScript  Auto