/* CONTENTS */
/* Dream timer */
/* PC talk timer */
/* Shar-PC talks */
///* female low rep a male in the party */
///* female med rep a male in the party (6 to 12 inclusive) */
///* female pc high rep male in the party */
///* Male with high rep */
/* morning after */
/* Fighting with the PC */
///* Initiate Fight: */
///* Fighting - shar wins */
///* Fighting shar loses */
/* timer for quitting */
/* Scripted NPC banter */

/* Dream timer */
IF %BGT_VAR%
InParty(Myself)
Global("X#DreamTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
SetGlobal("X#DreamTimerStarted","GLOBAL",1)
END

/* PC talk timer */
IF %BGT_VAR%
InParty(Myself)
Global("X#ShLowReputation","GLOBAL",0)
Global("X#ShMedReputation","GLOBAL",0)
Global("X#ShHighReputation","GLOBAL",0)
Global("X#ShHighMale","GLOBAL",0)
Global("X#SharPCTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#SharPCTalks","GLOBAL",5)
SetGlobal("X#SharPCTimerStarted","GLOBAL",1)
END

/* Shar-PC talks */
///* female low rep a male in the party */
IF %BGT_VAR%
RealGlobalTimerExpired("X#SharPCTalks","GLOBAL")
ReputationLT(Player1,6)
Gender(Player1,FEMALE)
Global("X#ShLowReputation","GLOBAL",0)
!Global("X#ShMedReputation","GLOBAL",2)
!Global("X#ShHighReputation","GLOBAL",2)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
OR(5)
Gender(Player2,MALE)
Gender(Player3,MALE)
Gender(Player4,MALE)
Gender(Player5,MALE)
Gender(Player6,MALE)
Global("X#ShLowReputation","GLOBAL",0)
!Global("X#ShMedReputation","GLOBAL",2)
!Global("X#ShHighReputation","GLOBAL",2)
THEN
RESPONSE #100
IncrementGlobal("X#ShLowReputation","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#ShLowReputation","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END

///* female med rep a male in the party (6 to 12 inclusive) */
IF %BGT_VAR%
RealGlobalTimerExpired("X#SharPCTalks","GLOBAL")
ReputationGT(Player1,5)
!ReputationLT(Player1,13)
Gender(Player1,FEMALE)
Global("X#ShMedReputation","GLOBAL",0)
!Global("X#ShLowReputation","GLOBAL",2)
!Global("X#ShHighReputation","GLOBAL",2)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
OR(5)
Gender(Player2,MALE)
Gender(Player3,MALE)
Gender(Player4,MALE)
Gender(Player5,MALE)
Gender(Player6,MALE)
THEN
RESPONSE #100
IncrementGlobal("X#ShMedReputation","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#ShMedReputation","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END

///* female pc high rep male in the party */
IF %BGT_VAR%
RealGlobalTimerExpired("X#SharPCTalks","GLOBAL")
ReputationGT(Player1,12)
Gender(Player1,FEMALE)
!Global("X#ShLowReputation","GLOBAL",2)
!Global("X#ShMedReputation","GLOBAL",2)
Global("X#ShHighReputation","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
OR(5)
Gender(Player2,MALE)
Gender(Player3,MALE)
Gender(Player4,MALE)
Gender(Player5,MALE)
Gender(Player6,MALE)
THEN
RESPONSE #100
IncrementGlobal("X#ShHighReputation","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#ShHighReputation","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END

///* Male with high rep */
IF %BGT_VAR%
RealGlobalTimerExpired("X#SharPCTalks","GLOBAL")
Gender(Player1,MALE)
ReputationGT(Player1,12)
!Global("X#ShMale","GLOBAL",2)
Global("X#ShHighMale","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
IncrementGlobal("X#ShHighMale","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#ShHighMale","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END

/* morning after */
IF %BGT_VAR%
Global("X#ShartSex","GLOBAL",1)
Global("X#SharMorning1","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#SharMorning1","GLOBAL",1)
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
END

IF %BGT_VAR%
Global("X#SharMorning1","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END

/* Fighting with the PC */
///* Initiate Fight: */
IF %BGT_VAR%
Global("X#SharLoveFight","GLOBAL",1)
InParty(Myself)
HPPercentGT(Player1,80)
HPPercentGT("sharteel",80)
THEN
RESPONSE #100
AttackOneRound(Player1)
Continue()
END

///* Fighting - shar wins */
IF %BGT_VAR%
Global("X#SharLoveFight","GLOBAL",1)
HPPercentLT(Player1,96)
THEN
RESPONSE #100
SetGlobal("X#SharLoveFight","GLOBAL",2)
ActionOverride("sharteel",ChangeEnemyAlly("sharteel",ALLY))
ActionOverride("sharteel",StartDialogueNoSet(Player1))
END

///* Fighting shar loses */
IF %BGT_VAR%
Global("X#SharLoveFight","GLOBAL",1)
HPPercentGT(Player1,95)
HPPercentLT("sharteel",96)
THEN
RESPONSE #100
SetGlobal("X#SharLoveFight","GLOBAL",4)
ActionOverride("sharteel",ChangeEnemyAlly("sharteel",ALLY))
ActionOverride("sharteel",StartDialogueNoSet(Player1))
END

/* timer for quitting */
IF %BGT_VAR%
ReputationGT(Player1,15)
Global("X#SharPissed","GLOBAL",1)
Global("X#PissedTimerStarted","GLOBAL",0)
InParty(Myself)
THEN
RESPONSE #100
SetGlobalTimer("X#SHAR63","GLOBAL",14000)
SetGlobal("X#PissedTimerStarted","GLOBAL",1)
END

IF %BGT_VAR%
GlobalTimerExpired("X#SHAR63","GLOBAL")
Global("X#SharPissed","GLOBAL",1)
ReputationGT(Player1,15)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
IncrementGlobal("X#SharPissed","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#SharPissed","GLOBAL",2)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END

/* Scripted NPC banter */
IF %BGT_VAR%
PartyRested()
InParty("kivan")
Global("X#SHKI1","LOCALS",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
RealGlobalTimerExpired("X#DreamTalk","GLOBAL")
See("kivan")
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("kivan",CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#SHKI1","LOCALS",1)
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
END

IF %BGT_VAR%
InParty("kivan")
Global("X#SHKI1","LOCALS",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See("kivan")
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("kivan",CD_STATE_NOTVALID)
THEN
RESPONSE #100
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
StartDialogueNoSet("kivan")
END


IF %BGT_VAR%
Global("X#SHSK1","GLOBAL",0)
InParty("skie")
InParty("eldoth")
InParty(Myself)
THEN
RESPONSE #100
RealSetGlobalTimer("X#SharSk","GLOBAL",2000)
SetGlobal("X#SHSK1","GLOBAL",1)
END

IF %BGT_VAR%
RealGlobalTimerExpired("X#SharSk","GLOBAL")
Global("X#SHSK1","GLOBAL",1)
Global("X#SKSH1","GLOBAL",1)
Global("X#ELSH1","GLOBAL",1)
InParty("skie")
InParty("eldoth")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("skie",CD_STATE_NOTVALID)
!StateCheck("eldoth",CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#SHSK1","GLOBAL",2)
END

IF %BGT_VAR%
Global("X#SHSK1","GLOBAL",2)
InParty("skie")
InParty("eldoth")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("skie",CD_STATE_NOTVALID)
!StateCheck("eldoth",CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("shart99")
StartDialogueNoSet(Player1)
END
