print function for lua testing. menu

User Tag List

Results 1 to 9 of 9
  1. #1
    boxo's Avatar Member
    Reputation
    2
    Join Date
    Jan 2012
    Posts
    92
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    print function for lua testing.

    So, I've been trying to create a few custom functions for healing, but they don't seem to work. I've asked some people for advice, and they've said use print functions.

    Excellent advice... but i'm not sure how.

    So, is there a way that I can create a print function that prints when a value for the function is registered, and then when the value changes? something like (and i'm totally making this up)

    function(something)
    if function(riptidetarget) = function(something) return false
    if function(riptidetarget) != function(something) then function(something) = function(riptidetarget)
    print function(something)

    or... something?

    print function for lua testing.
  2. #2
    MrTheSoulz's Avatar Contributor
    Reputation
    143
    Join Date
    Nov 2013
    Posts
    192
    Thanks G/R
    19/32
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by boxo View Post
    So, I've been trying to create a few custom functions for healing, but they don't seem to work. I've asked some people for advice, and they've said use print functions.

    Excellent advice... but i'm not sure how.

    So, is there a way that I can create a print function that prints when a value for the function is registered, and then when the value changes? something like (and i'm totally making this up)

    function(something)
    if function(riptidetarget) = function(something) return false
    if function(riptidetarget) != function(something) then function(something) = function(riptidetarget)
    print function(something)

    or... something?
    What exacly are you trying to do?
    Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.

  3. #3
    boxo's Avatar Member
    Reputation
    2
    Join Date
    Jan 2012
    Posts
    92
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to write a function to cast riptide on the lowest hp target without riptide, and then create some chain heal logic. Stealing from current PE code, I came up with this:
    Code:
    local max = math.max
    local GetSpellInfo = GetSpellInfo
    local GetNumGroupMembers = GetNumGroupMembers
    local IsInRaid = IsInRaid
    local UnitCanAssist = UnitCanAssist
    local UnitDebuff = UnitDebuff
    local UnitExists = UnitExists
    local UnitGetIncomingHeals = UnitGetIncomingHeals
    local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs
    local UnitGroupRolesAssigned = UnitGroupRolesAssigned
    local UnitHealth = UnitHealth
    local UnitHealthMax = UnitHealthMax
    local UnitInParty = UnitInParty
    local UnitInRange = UnitInRange
    local UnitIsConnected = UnitIsConnected
    local UnitIsDeadOrGhost = UnitIsDeadOrGhost
    local UnitIsFriend = UnitIsFriend
    local UnitUsingVehicle = UnitUsingVehicle
    local UnitBuff = UnitBuff
    
    -- riptide logic
    
    -- check whether units are able to be healed, and whether they have the riptide buff
    
    local function missingRiptide(unit)
      if UnitExists(unit)
         and UnitCanAssist('player', unit)
         and UnitIsFriend('player', unit)
         and UnitIsConnected(unit)
         and not UnitIsDeadOrGhost(unit)
         and not UnitUsingVehicle(unit) then
    
         if UnitInParty(unit) and not UnitInRange(unit) then
           return false
         end
    	 
    	if UnitBuff("unit", GetSpellInfo(61295)) then
    		return false
    	end
    
         return true
      end
    
      return false
    end
    
    -- check for the lowest unit in party that doesn't have the riptide buff
    needRiptide = function ()
      local lowestUnit = 'player'
      if missingRiptide('focus') then lowestUnit = 'focus' end
    
      local lowest = 100
    
      for _, unit in pairs(ProbablyEngine.raid.roster) do
        if missingRiptide(unit.unit) and unit.health and unit.health < lowest then
          lowest = unit.health
          lowestUnit = unit.unit
        end
      end
    
      return lowestUnit
    end
    
    -- allows PE to call the lowest unit in party without riptide as a target
    if target == "shouldRiptide" then
    	target = needRiptide()
    	if target == false then return end
    elseif target == "tank" then
    	if UnitExists("focus") then
    		target = "focus"
    	else
    		target = ProbablyEngine.raid.tank()
        end
    end
    
    -- chain heal
    
    local function hasRiptide(unit)
      if UnitExists(unit)
         and UnitCanAssist('player', unit)
         and UnitIsFriend('player', unit)
         and UnitIsConnected(unit)
         and not UnitIsDeadOrGhost(unit)
         and not UnitUsingVehicle(unit) then
    
         if UnitInParty(unit) and not UnitInRange(unit) then
           return false
         end
    	 
    	if not UnitBuff(unit, GetSpellInfo(61295)) then
    		return false
    	end
    
         return true
      end
    
      return false
    end
    
    lowestRiptide = function ()
      local lowestUnit = 'player'
      if hasRiptide('focus') then lowestUnit = 'focus' end
    
      local lowest = 100
    
      for _, unit in pairs(ProbablyEngine.raid.roster) do
        if hasRiptide(unit.unit) and unit.health and unit.health < lowest then
    	  lowest = unit.health
          lowestUnit = unit.unit
        end
      end
    
      return lowestUnit
    end
    
    
    
    if target == "shouldChain" then
    	if lowestRiptide().heath - needsRiptide().health > 10 then
    		target = needsRiptide() else
    		target = lowestRiptide()
    	end
    		if target == false then return end
    		elseif target == "tank" then
    			if UnitExists("focus") then
    				target = "focus"
    					else
    						target = ProbablyEngine.raid.tank()
          end
    end
    
    ProbablyEngine.library.register('Boxo_Healing', Boxo_Healing)
    but that doesn't do anything. it doesn't throw errors, but if you put something like:

    Code:
    	{ "Riptide", {
    		"@Boxo_Healing.shouldRiptide.health < 95",
    		"focus.buff(Riptide).duration > 5",
    	}, "@Boxo_Healing.shouldRiptide" },
    in a rotation it doesn't cast.

    So, I thought I might be able to identify whether or not, at different stages, the functions were registering targets, to find where the issue is

    Most of the above code is taken from how PE defines "lowest".

  4. #4
    MrTheSoulz's Avatar Contributor
    Reputation
    143
    Join Date
    Nov 2013
    Posts
    192
    Thanks G/R
    19/32
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I could help you more if you explained how exactly you want RipTide to work, but will leave you this:

    Code:
    ProbablyEngine.library.register('Boxo_Healing', {
    
          -- Loops thru party/Raid members and casts RipTide on whoever dosent have its buff and bellow 95% health
          RipTide = function()
    	    local prefix = (IsInRaid() and 'raid') or 'party'
    	        for i = 1, GetNumGroupMembers() do
    	            local target = prefix..i.."target"
    	            	if not UnitIsDeadOrGhost(unit) then
    		            	if not UnitBuff(target, GetSpellInfo(61295)) then
    		            		if not unitHealth(target) < 95 then
    		            			ProbablyEngine.dsl.parsedTarget = target
    		            			return true
    		            		end
    		            	end
    		            end
    		    end
    	end,
    
    })
    On top of the CR:
    Code:
    	{ "Riptide", "@Boxo_Healing.RipTide" },
    Should be pretty easy for you to expand on this now.
    Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.

  5. #5
    boxo's Avatar Member
    Reputation
    2
    Join Date
    Jan 2012
    Posts
    92
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    riptide can't really blanket like pw:s, so casts have to be a little more direct.

    I wanted to make it cast on the target with the lowest health that doesn't have riptide. so the idea was to make a second raid list, one that was made up of people without the riptide buff, by copying the PE function canHeal, but adding a check for the riptide buff:

    Code:
    local function missingRiptide(unit)
      if UnitExists(unit)
         and UnitCanAssist('player', unit)
         and UnitIsFriend('player', unit)
         and UnitIsConnected(unit)
         and not UnitIsDeadOrGhost(unit)
         and not UnitUsingVehicle(unit) then
    
         if UnitInParty(unit) and not UnitInRange(unit) then
           return false
         end
    	 
    	if UnitBuff("unit", GetSpellInfo(61295)) then
    		return false
    	end
    
         return true
      end
    
      return false
    end
    then, the theory was to isolate the lowest person on that list the same way as ProbablyEngine.raid.lowestHP, which targets the lowest person on the canHeal list:

    Code:
    needRiptide = function ()
      local lowestUnit = 'player'
      if missingRiptide('focus') then lowestUnit = 'focus' end
    
      local lowest = 100
    
      for _, unit in pairs(ProbablyEngine.raid.roster) do
        if missingRiptide(unit.unit) and unit.health and unit.health < lowest then
          lowest = unit.health
          lowestUnit = unit.unit
        end
      end
    
      return lowestUnit
    end
    Then, PE seems to create a "target" and creates "lowest" for use in rotations, which is what I copied here:

    Code:
    if target == "shouldRiptide" then
    	target = needRiptide()
    	if target == false then return end
    elseif target == "tank" then
    	if UnitExists("focus") then
    		target = "focus"
    	else
    		target = ProbablyEngine.raid.tank()
        end
    end
    that was the thought process i had, at least. I don't know if it's something I can put together, but I suppose there could be a number of functions at different health thresholds, to kind of mimic that process.
    Last edited by boxo; 01-03-2015 at 07:43 PM.

  6. #6
    Mackdaddy2887's Avatar Knight-Lieutenant
    Reputation
    43
    Join Date
    Mar 2011
    Posts
    265
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isnt basically the code I gave work the same?

    in a CR the bot starts at the top and goes down until it hits a spell returns true, casts that spell, and starts back over from the top.

    With that code, and using logic, you will see that the CR will always. ALWAYS chose to Riptide whoever the lowest is first, so if someone else takes damage, or if the previous 'lowest' gets healed, whoever meets that condition of 'lowest' will recieve riptide.

    Now secondly, IF that target is already riptide on it, itll chose the tank/focus. (using the code example i supplied, you can take this out if you want).
    Now, it casts riptide and starts back at the top. If there is a new 'lowest' it will choose them, if not, back down the list,

    now the first list is an array of raid members 1-20, all below 30% hp. So if anyone is below 30% hp, it will riptide that target. then start back at the top, which will then give yet another opportunity to riptide the 'lowest', and if not, continue to riptide anyone below 30%.

    Now you set similiar parameters for 60%, then 90%, as a fallthrough mechanic, setting prioirty to the 'lowest' first, then anyone under 30%, then 60%, then 90%.
    If that is not a strong enough decision matrix, use 10, 20 ,30, 40, 50, 60, 70, 80, 90. Doesnt matter, just copy/paste. Its all logic.

    Now for chain heal, do the same thing I did for swiftmend, and something very similiar to riptide:

    {"chain heal", {"lowest.buff(Riptide)", "lowest.range <= 40", "lowest.area(15).friends > 5"}, "lowest"},
    {"chain heal", {"tank.buff(Riptide)", "tank.range <= 40", "tank.area(15).friends > 5"}, "tank"},
    {"chain heal", {"raid1.buff(Riptide)", "raid1.range <= 40", "raid1.area(15).friends > 5"}, "raid1"},
    etc etc.

    set w/e health threshold, and the correct code for unit.area (i cant remember off the top of my head)

    Chain heal will ALWAYS chose lowest first if the have riptide, which riptide will almost always be on the lowest anyways. OR if the lowest doesnt meet w/e threshold, then possibly one of the other raid members with riptide will (one of them will, logically speaking)

  7. #7
    MrTheSoulz's Avatar Contributor
    Reputation
    143
    Join Date
    Nov 2013
    Posts
    192
    Thanks G/R
    19/32
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by boxo View Post
    riptide can't really blanket like pw:s, so casts have to be a little more direct.

    I wanted to make it cast on the target with the lowest health that doesn't have riptide. so the idea was to make a second raid list, one that was made up of people without the riptide buff, by copying the PE function canHeal, but adding a check for the riptide buff:

    Code:
    local function missingRiptide(unit)
      if UnitExists(unit)
         and UnitCanAssist('player', unit)
         and UnitIsFriend('player', unit)
         and UnitIsConnected(unit)
         and not UnitIsDeadOrGhost(unit)
         and not UnitUsingVehicle(unit) then
    
         if UnitInParty(unit) and not UnitInRange(unit) then
           return false
         end
    	 
    	if UnitBuff("unit", GetSpellInfo(61295)) then
    		return false
    	end
    
         return true
      end
    
      return false
    end
    then, the theory was to isolate the lowest person on that list the same way as ProbablyEngine.raid.lowestHP, which targets the lowest person on the canHeal list:

    Code:
    needRiptide = function ()
      local lowestUnit = 'player'
      if missingRiptide('focus') then lowestUnit = 'focus' end
    
      local lowest = 100
    
      for _, unit in pairs(ProbablyEngine.raid.roster) do
        if missingRiptide(unit.unit) and unit.health and unit.health < lowest then
          lowest = unit.health
          lowestUnit = unit.unit
        end
      end
    
      return lowestUnit
    end
    Then, PE seems to create a "target" and creates "lowest" for use in rotations, which is what I copied here:

    Code:
    if target == "shouldRiptide" then
    	target = needRiptide()
    	if target == false then return end
    elseif target == "tank" then
    	if UnitExists("focus") then
    		target = "focus"
    	else
    		target = ProbablyEngine.raid.tank()
        end
    end
    that was the thought process i had, at least. I don't know if it's something I can put together, but I suppose there could be a number of functions at different health thresholds, to kind of mimic that process.
    I guess you could loop thru the party/raid and add every unit that meets the conditions to a table then sort the table by missing health, if you look at my unit cache i already have what you need but im sorting it by distance.
    Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.

  8. #8
    boxo's Avatar Member
    Reputation
    2
    Join Date
    Jan 2012
    Posts
    92
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Mackdaddy2887 View Post
    Isnt basically the code I gave work the same?
    Not... really? I mean, you could, theoretically, copy and paste an insane amount steps for every health level, but there should be a much more logical and less verbose way to do the same thing, which can then be used for a number of other applications. Create a table of players that fit a certain parameter, sort them, and then do something on the highest priority.

    The chain heal priority would require even more steps. Check for not riptide, and check for riptide at different health levels. I appreciate there are other workarounds, but i can't help but think that there is an ideal solution out there somewhere.

  9. #9
    ImogenOC's Avatar Contributor ProbablyEngine Community Manager
    Reputation
    173
    Join Date
    Nov 2013
    Posts
    364
    Thanks G/R
    0/8
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by boxo View Post
    Not... really? I mean, you could, theoretically, copy and paste an insane amount steps for every health level, but there should be a much more logical and less verbose way to do the same thing, which can then be used for a number of other applications. Create a table of players that fit a certain parameter, sort them, and then do something on the highest priority.

    The chain heal priority would require even more steps. Check for not riptide, and check for riptide at different health levels. I appreciate there are other workarounds, but i can't help but think that there is an ideal solution out there somewhere.
    You've been around a long time; you know PE is very copypasta :3
    ProbablyEngine - Developer and Lead Support
    A Powerful Rotation Bot: ProbablyEngine

Similar Threads

  1. [Release] Scan Pixels function for VB.net
    By suicidity in forum World of Warcraft Bots and Programs
    Replies: 6
    Last Post: 07-09-2014, 02:12 PM
  2. [Lua Script] [Help] Script Problem. Rooted dummies and Looking for a lua testing program
    By BanzBoyz77 in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 08-06-2011, 11:39 AM
  3. [Release] Holiday Releases # 1.5 - Custom Boss Template For Lua
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 10
    Last Post: 02-14-2008, 07:14 AM
  4. [Release] Holiday Releases # 1.7 - Custom Aggro Template For Lua
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 02-12-2008, 10:44 AM
All times are GMT -5. The time now is 10:43 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search