Scriptname aaaKimachuuAGoodfriendNPCSexSCH Extends ActiveMagicEffect

Faction Property aaaKimachuuAGFNSfactionG1S Auto
Faction Property aaaKimachuuAGFNSfactionG2S Auto
Faction Property aaaKimachuuAGFNSfactionG3S Auto
Message Property aaaKimachuuAGFNSMESGs Auto
Message Property aaaKimachuuAGFNSnoti08 Auto ;ターゲットが存在しません
Message Property aaaKimachuuAGFNSnoti09 Auto ;グループ1から削除
Message Property aaaKimachuuAGFNSnoti10 Auto ;グループ1へ追加
Message Property aaaKimachuuAGFNSnoti11 Auto ;グループ2から削除
Message Property aaaKimachuuAGFNSnoti12 Auto ;グループ2へ追加
Message Property aaaKimachuuAGFNSnoti13 Auto ;グループ3から削除
Message Property aaaKimachuuAGFNSnoti14 Auto ;グループ3へ追加

Bool f1
Bool f2
Bool f3

Int ff1
Int ff2
Int ff3

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Actor TargetRef = Game.GetCurrentCrosshairRef() as Actor

	if !TargetRef
		aaaKimachuuAGFNSnoti08.Show()
	Else
		f1 = TargetRef.IsInFaction(aaaKimachuuAGFNSfactionG1S)
		f2 = TargetRef.IsInFaction(aaaKimachuuAGFNSfactionG2S)
		f3 = TargetRef.IsInFaction(aaaKimachuuAGFNSfactionG3S)

		if f1 == true
			ff1 = 1
		Else
			ff1 = 0
		endif

		if f2 == true
			ff2 = 1
		Else
			ff2 = 0
		endif

		if f3 == true
			ff3 = 1
		Else
			ff3 = 0
		endif

		Int intIndex
		intIndex = aaaKimachuuAGFNSMESGs.Show(ff1, ff2, ff3)

		If intIndex == 0 ;Group1
			if TargetRef.IsInFaction(aaaKimachuuAGFNSfactionG1S)
				TargetRef.RemoveFromFaction(aaaKimachuuAGFNSfactionG1S)
				aaaKimachuuAGFNSnoti09.Show()
			Else
				TargetRef.AddToFaction(aaaKimachuuAGFNSfactionG1S)
				aaaKimachuuAGFNSnoti10.Show()
			EndIf
		ElseIf intIndex == 1 ;Group2
			if TargetRef.IsInFaction(aaaKimachuuAGFNSfactionG2S)
				TargetRef.RemoveFromFaction(aaaKimachuuAGFNSfactionG2S)
				aaaKimachuuAGFNSnoti11.Show()
			Else
				TargetRef.AddToFaction(aaaKimachuuAGFNSfactionG2S)
				aaaKimachuuAGFNSnoti12.Show()
			EndIf
		ElseIf intIndex == 2 ;Group3
			if TargetRef.IsInFaction(aaaKimachuuAGFNSfactionG3S)
				TargetRef.RemoveFromFaction(aaaKimachuuAGFNSfactionG3S)
				aaaKimachuuAGFNSnoti13.Show()
			Else
				TargetRef.AddToFaction(aaaKimachuuAGFNSfactionG3S)
				aaaKimachuuAGFNSnoti14.Show()			
			EndIf
		Else ;Cancel
			;empty
		EndIf
	EndIf
EndEvent