Begin fw_werewolf_pelt

short button
short MessageOn
short messageOnce
short doOnce
short OnPCEquip
short reset
short usepelt
short isnight
short peltused
float timer
float hourcheck
float changetime

if ( OnPCEquip == 0 )
	set reset to 0
endif

if ( reset == 1 )
	return
endif

if ( PCWerewolf == 1 )
	return
endif

if ( OnPCEquip == 1 )
	if ( PCWerewolf == 0 )
		set isnight to 1 ;nighttime by default
		if ( GameHour < 21 ) ; daytime
			if ( GameHour > 6 )
				set isnight to 0
			endif
		endif
		if ( isnight == 1 )
			if ( reset == 0 )
				if ( messageOnce == 0 )
					;Set OnPCEquip to 0
					MessageBox "Would you like to wear the werewolf pelt?" "Yes" "No"
					set messageOn to 1
					set messageOnce to 1
				endif
			endif
		endif
	endif
endif

if ( messageOn == 1)

	set button to GetButtonPressed

	if ( button >= 0 )
		set messageOn to 0
	endif

	if ( button == 0 )
		set usepelt to 1
		set peltused to ( peltused + 1 )
		if ( peltused >= 13 )
			player->AddSpell "werewolf blood"
		endif
		;set reset to 1		
			
	elseif ( button == 1 )
		set reset to 1
		set messageOnce to 0
		return
	endif
endif

if ( usepelt == 1 )
	if ( OnPCEquip == 1 )
		if ( MenuMode == 0 )
			DisablePlayerControls
			FadeOut 5
			set usepelt to 2
			Set OnPCEquip to 0
			set messageOnce to 0
		endif
	else
		set usepelt to 0
		set messageOnce to 0
		return
	endif
endif

if ( usepelt == 2 )
	set timer to ( timer + GetSecondsPassed )
	if ( timer > 5 )
		PlayBink "bm_werewolf2.bik" 1
		set usepelt to 3
		set timer to 0
	endif
endif

if ( usepelt == 3 )
	Player->BecomeWereWolf
	Player->AddSpell "werewolf vision"
	Player->AddSpell "werewolf regeneration"
	Player->SetWereWolfAcrobatics
	FadeIn 5
	set usepelt to 4
	set timer to 0
endif

if ( usepelt == 4 )
	set timer to ( timer + GetSecondsPassed )
	if ( timer > 5 )
		EnablePlayerControls
		set usepelt to 5
		set hourcheck to ( GameHour + 6 )
		if ( hourcheck > 24 )
			set ChangeTime to 1
			set hourcheck to ( hourcheck - 24 )
		endif
		if ( hourcheck > 6)
			set hourcheck to 6
		endif
	endif
endif

if ( usepelt == 5 )
	if ( ChangeTime == 0 )
		if ( GameHour > hourcheck )
			set usepelt to 6
			set timer to 0
		endif
	elseif ( ChangeTime == 1 )
		if ( GameHour < 6 )
			if ( GameHour > hourcheck )
				set usepelt to 6
				set timer to 0
			endif
		endif
	endif
endif

if ( usepelt == 6 )
	DisablePlayerControls
	FadeOut 5
	set usepelt to 7
endif

if ( usepelt == 7 )
	set timer to ( timer + GetSecondsPassed )
	if ( timer > 5 )
		Player->UndoWerewolf
		Player->RemoveSpell "werewolf vision"
		Player->RemoveSpell "werewolf regeneration"
		set usepelt to 8
		set timer to 0
	endif
endif

if ( usepelt == 8 )
	FadeIn 5
	set usepelt to 9
endif

if ( usepelt == 9 )
	set timer to ( timer + GetSecondsPassed )
	if ( timer > 5 )
		EnablePlayerControls
		set reset to 1
		set usepelt to 0
		set timer to 0
		set ChangeTime to 0
	endif
endif


End fw_werewolf_pelt