Page 1 of 1

Userfunction - addon_attackspeedzero

Posted: Sat Apr 27, 2013 1:19 pm
by attackspeedzero
I thought I would share the compilation of user functions that I'm building. Most of these are to make coding faster and easier, and some are quite helpful for code readability. Put this file into /userfunctions/ folder.

New/modified functions in bold.

v1.1 changes:
  • Rewrite function sort_daily_log(folder) to sort_log(folder,_breakafterlines)
  • Add function fast_targetNPC(npcname)
Function list:
  • Lua file/table manipulation functions from this thread: http://www.solarstrike.net/phpBB3/viewt ... =27&t=4768
  • comma_value(n)
    • From a log file by lisa (sorry, forgot which thread)
    • Will commify a number greater than 999
  • cprintn(color,string)
    • Ends a colored console print line with "\n" because I got tired of adding this to every cprintf()
  • goto_wp(waypointTag)
    • More "English" and readable, replaces "__WPL:setWaypointIndex(__WPL:findWaypointTag(waypointTag))"
  • reload_wp_file()
    • More "English" and readable, replaces "loadPaths(__WPL:getFileName())"
  • kill_stupid_newbie_pet()
    • From my version of ElfDaily
    • Check vicinity for newbie pet, use newbie pet egg to unsummon, then delete newbie pet egg from inventory
  • save_daily_log(folder)
    • From my version of ElfDaily
    • Save info into log file for character name and daily token count
  • sort_log(folder,_breakafterlines)
    • Inspired by my version of ElfDaily
    • Sort the info in log file alphabetically
    • _breakafterlines argument (optional) insert a blank line after this number of rows in the sorted file
  • take_snoop(snoopname,destination,_colon,_next)
    • If standing next to snoop or ailic's aide, will pay to travel to the destination.
    • destination argument example: "Jinners Camp"
    • _colon argument (optional) - set this to 1 for cases where the option text is "Transport to: " instead of "Transport to "
    • _next argument (optional) - set this to 1 for cases where there's more than one page of destinations
  • set_options(options,optionDescriptions)
    • Idea came from DoD script by Solembum05
    • Allow players to choose options during runtime instead of having to hardcode everything
  • quest_check(quest,questCompleteWaypoint,_questWaypoint)
    • From my version of Sea of Snow Package
    • Allow for keeping waypoints in a loop until quest complete
    • questCompleteWaypoint argument - choose waypoint to go to after quest is completed
    • _questWaypoint argument (optional) - will recycle a section of waypoints
  • quest_skip_if_complete(quest,nextWaypoint)
    • From my version of Sea of Snow Package
    • Skip to "nextWaypoint" if the quest is already completed
  • fast_targetNPC(npcname)
    • Target NPC without all the yrests found in player:target_NPC()
    • Built for speed, especially with EoJ farming in mind

Re: Userfunction - addon_attackspeedzero

Posted: Sat Apr 27, 2013 7:34 pm
by kkulesza
Thanks for sharing Your work.
Some of this functions seem interesting.
But I find Your addon hard to read since there is almost no documentation.

Could You add some usage examples?

Thanks in advance :)

Re: Userfunction - addon_attackspeedzero

Posted: Mon Apr 29, 2013 12:08 pm
by attackspeedzero
I tried pretty well to explain everything, at least in the way things are called. Is there something specific you're running into an issue with?

Re: Userfunction - addon_attackspeedzero

Posted: Mon Dec 02, 2013 5:18 am
by rido_knight
Gives error :(

Image

Re: Userfunction - addon_attackspeedzero

Posted: Tue Dec 24, 2013 10:08 am
by rock5
Just to let you know, you shouldn't call GetIdName outside of a function because it runs at load time. This causes an error if the addresses need updating because the userfunctions are loaded before the addresses check happens.

Code: Select all

Installing userfunctions. 2:0am - scripts\645/bot.lua:86: ...les (x86)/micromacr
o/scripts/645/classes/memorytable.lua:7: bad argument #2 to 'memoryReadUIntPtr'
(number expected, got nil)

Re: Userfunction - addon_attackspeedzero

Posted: Sat Feb 08, 2014 1:27 am
by rock5
Here is my version of kill_stupid_newbie_pet, if you want to use it.

Code: Select all

function kill_stupid_newbie_pet()
	local function evalfunc(address)
		local obj = CPawn.new(address)
		obj:updateIsPet()
		return obj.IsPet == player.Address
	end
	
	if player:findNearestNameOrId(113199,nil,evalfunc ) then  -- search vicinity for your Newbie Pet
		local newbEgg = inventory:findItem(207051); -- Newbie Pet Egg
		if newbEgg then
			newbEgg:use()
			newbEgg:delete()
		end
	end
end
It checks if the newbie pet is your pet before recalling and tidys up the code that uses and deletes the egg.

Re: Userfunction - addon_attackspeedzero

Posted: Tue Jul 14, 2015 12:34 pm
by beanybabe
sorry that did not seem to work either. it will get rid of pet 1 on 1 char but any relogs it does not seem to it only deletes the egg after first.
---------------------------------
Rock I tried your newbie pet code and it would not get rid of the pet if char started moving and interrupt it.

Code: Select all

-- function kill_stupid_newbie_pet()
   local function evalfunc(address)
      local obj = CPawn.new(address)
      obj:updateIsPet()
      return obj.IsPet == player.Address
   end
   
  if player:findNearestNameOrId(113199,nil,evalfunc ) then  -- search vicinity for your Newbie Pet
      local newbEgg = inventory:findItem(207051); -- Newbie Pet Egg
      if newbEgg then
         newbEgg:use()
		 yrest(500);    -- I added this to prevent interrupting pet recall
         newbEgg:delete()
      end
   end

Re: Userfunction - addon_attackspeedzero

Posted: Wed Jul 15, 2015 2:28 am
by kenzu38
beanybabe wrote:sorry that did not seem to work either. it will get rid of pet 1 on 1 char but any relogs it does not seem to it only deletes the egg after first.
I always put these lines at the top of all my wp's onload section.

Code: Select all

player:update()
inventory:update()
loadProfile()
And then followed by gm detect if the area is risky. Haven't botted in years so I vaguely remember the commands, it's probably loadprofile() will small letter p.

I know some functions already do the updates for you but I think it's still best to update at the very start of the script. So try that if you haven't already. Good luck.

Re: Userfunction - addon_attackspeedzero

Posted: Wed Jul 15, 2015 2:28 pm
by rock5
It's possible the problem is with how long it takes for the pet to appear. If it hasn't appeared yet when that code runes then it won't see the pet but will still drop the egg. Maybe a yrest would help.

Re: Userfunction - addon_attackspeedzero

Posted: Tue Oct 13, 2015 11:07 am
by beanybabe
I added a wait in the function so it did not need be added elsewhere.

Code: Select all

function kill_stupid_newbie_pet()
	yrest(4500)  -- wait for pet to appear 
   local function evalfunc(address)
      local obj = CPawn.new(address)
      obj:updateIsPet()
      return obj.IsPet == player.Address
   end
    if player:findNearestNameOrId(113199,nil,evalfunc ) then  -- search vicinity for your Newbie Pet
      local newbEgg = inventory:findItem(207051); -- Newbie Pet Egg
      if newbEgg then
         newbEgg:use()
         newbEgg:delete()
      end
   end
end