;'PS - Windform' - skill script

;Pale Spectre only skill, goes invisible for longer periods of time,
;depending on the user's wisdom.

BloodCost = 25
TimeInvisible = 2000 + Floor(GetUserWisdomTotal(#USERID) * 500)

If GetUserAccess(#USERID) < 5
	;Only Pale Spectres can use this skill
	If GetUserClass(#USERID) <> 3
		Goto END
	EndIf
EndIf

;SendMessageToUser(#USERID,"Duration: "+Floor(TimeInvisible/1000)+" seconds. ("+TimeInvisible+"ms)",#MSG_SAY)

If GetUserFlag(#USERID, 35) > 0
	SendCombatMessage(#USERID,"You cannot use Windform again so soon. ")
	GoTo END
EndIf

Blood = GetUserMana(#USERID)
If Blood < BloodCost
	SendCombatMessage(#USERID,"You don't have enough blood for this skill! ")
	GoTo END
EndIf
Blood = Blood - BloodCost
SetUserMana(#USERID,Blood)


SendMessageToMap(#MAPID,"Wind swirlds around "+GetUserName(#USERID)+" majestically, and he disapears from sight.",#MSG_EMOTE)

Y = -1
While Y < 2
	X = -1
	While X < 2
		Target = GetUserAtXY(#MAPID, #XPOS+X, #YPOS+Y)
		
		If Target = 0
			GoTo SKIP
		ElseIf GetUserFlag(Target, 35) > 0
			GoTo SKIP
		EndIf
		
		SendMessageToUser(Target,"Your body takes the appearance of wind, and allows you to move about undiscovered.",#MSG_EMOTE)
		SetUserFlag(Target, 35, 1)
		SetUserSprite(Target, 0)
		SetUserDisplayName(Target, " ")
		SetUserAgilityBonus(Target, GetUserAgilityBonus(Target)+5)
		SetUserWisdomBonus(Target, GetUserWisdomBonus(Target)+5)
		Timer(581, TimeInvisible, Target, 0, 0)
		
		Label SKIP
		
		X=X+1
	Wend
	Y=Y+1
Wend

SetUserFlag(#USERID, 35, 2)

Label END

Continue = 1