Writing Custom Functions menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  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)

    Writing Custom Functions

    Hey everyone.

    So far, I've written a healing profile that will get to gold in proving grounds. I will also heal all heroics, and is doing alright in the first few raid bosses.

    However, it's still weak in two main areas, and that is riptide and chain heal.

    So, given that I don't know much, if anything, about lua, I was hoping someone might be able to give me a head start, or point me to a resource where I could learn to create some custom functions.

    Namely:

    1. Find a way to rank damaged units with / without riptide. (eg, cast chain heal on lowest riptide in party, or cast riptide on lowest unit without riptide).

    2. Create white lists for dispelling / interrupts.

    Also, how to then load them in PE. If it is possible to copy old PQR functions into PE, that would help a lot too, given that the nova/Sheuron/Vach healing engines were pretty strong

    Thanks a lot
    Last edited by boxo; 12-03-2014 at 10:05 AM.

    Writing Custom Functions
  2. #2
    aeo's Avatar Contributor
    Reputation
    127
    Join Date
    Apr 2007
    Posts
    270
    Thanks G/R
    84/62
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    First let me say I dont use PE, I have my own lua unlocker, engine that I use however Im hoping I can help you as LUA is LUA.
    as far as functions go you have a few options right now what i do is loop through my party/raid members and filter out the ones out of range, LoS ect. Once you have a list of valid players you can then sort them with a custom function;

    Table.sort(list,sortfunction)
    function sortfunction(x,y)
    you can use the sort function to check conditions and return if x should go before y by returning true
    else if X dosnt have riptide return true( meaning x with be bfore y in the list.
    else x and y both have rip tide then check their HP and return true if X.hp < y.hp

    end

    this should give you targets without riptide before targets with riptide and once everyone has riptide it should give you the lowest hp targets

    You could also do 2 list one that checks everyone has riptide and one that checks HP. Only use the lowest in the second list if the first is empty. Ie everyone has riptide.

  3. #3
    StinkyTwitch's Avatar Active Member
    Reputation
    40
    Join Date
    Nov 2014
    Posts
    172
    Thanks G/R
    19/13
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How to use a Library Call in PE.

    File structure for example:

    Probably_Example/Libs/Lib.lua
    Probably_Example/Rotations/Rotation.lua

    For the sake of the example just assume that Rotation.lua is your profiles rotation and it is formatted correctly with the right spec number and all that jazz. Lets just do something easy in Lib.lua as the example, like verify our current "target" exists.

    Lib.lua
    Code:
    function Probably_Example.DoesUnitExist(unit)
        local unit_exists = UnitExists(unit)
    
        if unit_exists then
            return true
        else
            return false
        end
    end
    
    ProbablyEngine.library.register('Probably_Example', Probably_Example)
    Now in the Rotation.lua code on an example PE conditional element we use it like this:

    Rotation.lua
    Code:
    { "Spell", { "@Probably_Example.DoesUnitExist('target')", }, "target", },
    The KEY ingredients here are registering your library in the Lib.lua so that your rotation can use it in Rotation.lua. Second calling the library you use the "@" symbol in a conditional check. If none of this works I blame the beer.
    Last edited by StinkyTwitch; 12-05-2014 at 03:53 AM. Reason: Was a long day when I wrote this. Updated the "unit" and 'target' sections.

  4. #4
    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)
    Stahhhp, dang it. I have to finish work before doing this stuff. *huffs*

    The above are both correct! Depending on your preference you can either have your lib inside your rotation.lua, or in a separate file. You can have as many files as you want, just make sure to have the proper includer.
    ProbablyEngine - Developer and Lead Support
    A Powerful Rotation Bot: ProbablyEngine

  5. #5
    Greymalkin's Avatar Corporal
    Reputation
    13
    Join Date
    May 2014
    Posts
    28
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ImogenOC View Post
    Stahhhp, dang it. I have to finish work before doing this stuff. *huffs*
    HA, this actually made me chuckle. But on topic, I suspect that the ideas and info in this thread could end up being pure gold!

  6. #6
    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)
    Thanks for the help people, checking to see if this makes sense. to be fair, i took much of it from the stuff that was there, and tried to edit it for my purposes. If you could take a look at this, and let me know what you think...

    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
    
    -- riptide logic
    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
    
    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
    
    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
    	target = lowestRiptide()
    		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)
    Would be the library for creating the logics, and then something like:

    { "Riptide", "focus.buff(Riptide).duration > 6", "@Boxo_Healing.shouldRiptide" },

    Does this look even close to right?

  7. #7
    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)
    Looks spot on.
    ProbablyEngine - Developer and Lead Support
    A Powerful Rotation Bot: ProbablyEngine

  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)
    ok, awesome.

    last question (hopefully!). Is there a way that I can compare two of these.

    Basically, call the health of has riptide and the health of needs riptide and see if there is a difference of 10 or less

  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)
    Would need a function. Use the two functions to make a new func that returns true/false. Include in PE.
    ProbablyEngine - Developer and Lead Support
    A Powerful Rotation Bot: ProbablyEngine

  10. #10
    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)
    so if lowestRiptide and needsRiptide are already units, can i do lowestRiptide.health? something like:

    if lowestRiptide.heath - needsRiptide.health > 10 then
    target = needsRiptide else
    target = lowestRiptide
    end

  11. #11
    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)
    Like I said, do the math within a function. The function needs to return true or false, and then call it inside the target section of a spell sequence.

    E.g.
    { "Spell", nil, "target" },
    ProbablyEngine - Developer and Lead Support
    A Powerful Rotation Bot: ProbablyEngine

  12. #12
    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)
    welp, it doesn't work. oh well.

  13. #13
    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)
    Is there a way to check to see if your lib has registered? At the moment, it doesn't seem to work, and I have no idea how to trouble-shoot it. the full CR is here (i hope. i've never used google drive):

    https://drive.google.com/folderview?...lE&usp=sharing

  14. #14
    Tiger23078001's Avatar Member
    Reputation
    1
    Join Date
    Mar 2014
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm looking for the same exact functionality, but for Holy Paladin, and don't have enough LUA knowledge to make it happen Let me know if you can get it working.

  15. #15
    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)
    can someone give me a clue as to how to debug the lua part of this? is there a simple print function i can use to see if the lib is registering, or to figure out which part doesn't work?

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 01-18-2015, 07:33 AM
  2. PQR Custom Functions problems
    By Alkafir in forum WoW Bots Questions & Requests
    Replies: 3
    Last Post: 07-15-2013, 06:01 AM
  3. [Injection] Selecting/customizing functionality to inject
    By Bananenbrot in forum WoW Memory Editing
    Replies: 9
    Last Post: 06-05-2010, 07:37 AM
  4. [C++ and LUA Patch] 6 Custom Player Functions
    By Gastricpenguin in forum WoW EMU General Releases
    Replies: 10
    Last Post: 03-02-2009, 08:06 AM
  5. Writing Guides: for Dummies
    By Krazzee in forum World of Warcraft Guides
    Replies: 3
    Last Post: 06-11-2006, 01:05 PM
All times are GMT -5. The time now is 03:14 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