1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Greetings Guest!!

    In order to combat SPAM on the forums, all users are required to have a minimum of 2 posts before they can submit links in any post or thread.

    Dismiss Notice

EC - Target lowest health pet, custom function

Discussion in 'UO Tamer' started by pgib, Dec 23, 2011.

  1. pgib

    pgib Guest

    Second time i look at LUA, so this might be the least elegant function ever seen: targets the pet that has the lowest health in you current set of followers.

    (in PetWindow.lua)
    Code:
    function PetWindow.GetPetHealth(petId)
    	local h = WindowData.MobileStatus[petId].CurrentHealth
    	return h
    end
    
    function PetWindow.TargetLowestHealthPet()
    	local targetId = nil
    	local lowestHealth = -1
    	local i
    	for i=1,PetWindow.totalPets do
    		local id = WindowData.Pets.PetId[i]
    		local health = PetWindow.GetPetHealth(id)
    		if((lowestHealth == -1) or (health < lowestHealth)) then
    			targetId = id
    			lowestHealth = health
    		end
    	end
    	if(targetId ~= nil) then
    		HandleSingleLeftClkTarget(targetId)
    	end
    end
    Then i use it in a macro like this:

    Slot 1: script PetWindow.TargetLowestHealthPet()
    Slot 2: bandage selected target

    I find it quite useful when i take my dogs out, I'm still testing it, works well so far.

    EDIT: of course it was fraught with problems (the table is used as reference didn't keep track of changes in the pet set, maybe). Now it works even after changing the pets. Sorry but coding for the EC is like moving blindfolded with a dark sky in a foggy night under heavy rain.
     
  2. Pinco

    Pinco UOEC Modder
    Stratics Veteran Stratics Legend

    Joined:
    Jul 25, 2005
    Messages:
    5,673
    Likes Received:
    865
    nice idea, I think I'm going to expand it :p