//@unloadnpc VIP
//@loadnpc npc/amatsuro/features/buff.txt

-	script	VIP	-1,{
end;

OnPCLoginEvent:
	if(!#VIP) end;
	// check if the player is currently a VIP
	if (#VIP > gettimetick(2)) {
		// move the player to the VIP group until logout
		sc_end SC_BLESSING;
		skilleffect AL_BLESSING,0;
		sc_start SC_BLESSING,1800000,10;

		if(Hp>15) {
			sc_end SC_INC_AGI;
			skilleffect AL_INCAGI,0;
			sc_start SC_INC_AGI,1800000,10;
			heal -15,0;
		}

		// schedule a timer to revert the group on expiration
		addtimer((#VIP - gettimetick(2)) * 1000, strnpcinfo(0) + "::OnExpire");

		set .@days,((#VIP - gettimetick(2))/60/60)/24;
		set .@hours,((#VIP - gettimetick(2))/60)%24;
		set .@mins,((#VIP - gettimetick(2))/60)%60;
		// notify the player
		dispbottom("AGI/BLESS buff is active until "+ ((.@days) ? .@days +":Days " : "") +""+ ((.@hours) ? .@hours +":Hours " : "") +""+ ((.@mins) ? .@mins +":Minutes " : "") +" ");
	
	}
			
	// check if the player was a VIP but it expired while away
	else if (#VIP > 1) {
		goto OnExpire;
	}
	end;	
OnExpire:
	if (#VIP <= gettimetick(2)) {
		// revert to the original group
		sc_end SC_INC_AGI;
		sc_end SC_BLESSING;
		// notify the player
		dispbottom("AGI/BLESS buff has expired.");

		// update the variable
		#VIP = 0;
	}
end;
}

