LAST_UID = -1

def onReceiveEnemyHp(uid, hp_percent, name):
	global LAST_UID
	LAST_UID = uid
	
def onRemoveCreature(uid, name, looktype, entity_type, x, y, z):
	if uid != LAST_UID:
		return

	if not (entity_type == 2 or entity_type == 4): # check if creature is a monster/boss
		return

	if IsInLine(x, y, z, script.GetX(), script.GetY(), script.GetZ()):
		varname = 'killed_' + name
		mobs = script.GetVar(varname) + 1
		script.SetVar(varname, mobs)
		script.StatusMessage('Killed: ' + name + ' \nTotal: ~' + str(mobs))

def IsInLine(x, y, z, x2, y2, z2):
	xdif = abs(x - x2)
	ydif = abs(y - y2)
	return ((xdif == 1 and ydif == 0) or (xdif == 0 and ydif == 1)) and z == z2
