import es
import playerlib

import wcs
from wcs import wcs

itemName = 'Orb of Frost'

wcs.Item(itemName).registerItem('attack', 3500, "You have a small chance of freezing an enemy.", True)
        
def player_hurt(ev):
    count   = wcs.Command(ev['attacker']).GetItemCount(itemName)
    while count:
        freezeTime = 0
        if random.randint(1, 100) <= 5:
            freezeTime += 3
        if freezeTime:
            wcs.Command(ev['userid']).Freeze(freezeTime)
            es.tell(ev['attacker'], '#multi', '#greenOrb of Frost #default- #lightgreenYou have frozen#green%s #ligtgreenfor #green%s #lightgreenseconds..' % (ev['es_username'], freezeTime) )
            es.tell(ev['userid'], '#multi', '#greenOrb of Frost #default- #lightgreenYou have been frozen by#green%s #ligtgreenfor #green%s #lightgreenseconds..' % (ev['es_attackername'], freezeTime) )
        count -= 1
        
def player_death(ev):
    wcs.Command(ev['userid']).RemoveItem(itemName)
