Jump to content

Tokumei

Members
  • Posts

    32
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Tokumei

  1. 5 hours ago, vesteras said:

    Hi,

     

    I'm new to this bot, so apologies if this question has been answered already.

     

    is there an Auto Eat function? I'm struggling to see it. I've found the auto spell / heal function etc but not the auto eat one? (im planning on AFK training a sorc on a server I'm starting)

     

    Kind Regards

    Vesteras

     

    local foodID = 3725		-- ID of the food you want to use. (Brown Mushroom = 3725)
    local waitTime = 300000	-- Time you want to wait after eating before allowing the script to run again. (1000 = 1 second)
    
    
    if g_game.getLocalPlayer():getItemsCount(foodID) > 0 then
    	g_game.useInventoryItem(foodID)
    end
    sleep(waitTime)
    
    auto(200,400)


     

  2. Is there currently a function to execute a script on kill? 

    If not, is there another method I could use?

    For some context:

    - OT server (WAD) 

    - I'm trying to make a script that functions as a looter by using corpses, but I've run into the problem of already looted corpse co-ordinates being added back to the table each time it runs as a persistent script.

    - I am aware that if the creature is skinnable, I can just skin the creature after looting and that would solve the issue. Unfortunately not all creatures are skinnable.

    - I would like to avoid just adding a longer period for the auto() funtion.

     

    -- Variables --
    local corpseIds = {4286, 4062}      -- Corpse ID's
    
    
    -- Functions --
    function table.find(t, value)
      for k,v in pairs(t) do
        if v == value then return k end
      end
    end
    
    -- Conditions --
    local tiles = g_map.getTiles()
    local corpses = {}
    for _, tile in pairs(tiles) do
        if tile:getPosition():getDistance(g_game.getLocalPlayer():getPosition()) <= 7 then
            local topItem = tile:getTopItem()
            if topItem and table.find(corpseIds, topItem:getId()) then
                table.insert(corpses, topItem)
            end
        end
    end
    
    if #corpses > 0 then
        for _, corpse in pairs(corpses) do
            setOption("Cavebot/Enabled", "false")
            g_game.stop()
            g_game.useMapItem(corpse:getPosition())
            table.remove(corpses,1)
            sleep(2000)
            setOption("Cavebot/Enabled", "true")
            sleep(500)
        end
    end
    
    
    auto(100)

     

    EDIT: Sorry if I posted this in the wrong thread.

    ~ Tokumei

  3. You can cycle through the items on the ground checking for corpse ID's then use a combo of these two.

    g_game.useMapItem(x = 123, y = 456, z = 7)

    and the

    *** : getPosition()

    functions.

  4. 3 hours ago, shz0r said:

    Hey, I'd like to have a script that shoot runes on target, the server has hotkeys for runes..

    Also if someone has an avoidance script (ex: dodge dragon waves) since its not working for this server.

     

    Thanks in advance!

     

    I don't have the time to mess around making a stay diagonal script atm, but here's the shoot Hotkey rune if you are attacking.

    auto(100)
    if not g_game.isOnline() then return end
    if  g_game.isAttacking() then
    	g_game.sendKey("F1")
    	sleep(2000)
    end

    The 2000 sleep at the end is a 2second wait, you can change that to whatever the cooldown is on your server.

    • Like 1
  5. Why do you have the health to Cast % at 100%?

    Seems unnecessary, but if you wanted to have it so you only shoot at over 80%hp or something you should change that "<" sign to ">" otherwise you will only shoot the rune when you are below that HP%.

     

    local healthToCast = 80
    local player = g_game.getLocalPlayer()
    if g_game.isAttacking() and player:getHealthPercent() >= healthToCast then
      g_game.useInventoryItemOnCreature(3198, g_game.getAttackingCreature())
      sleep(900, 1100)
    end
    auto(100)

     

    • Like 1
  6. 7 hours ago, oualid64966 said:

    Do you mean after the labels at the cavebot part? Because that would never reach it right if you disabled the cavebot.

    Correct. And again I haven't tested it. I only just got the bot again yesterday and haven't had a chance to play around with it.

    Alternatively you could add some delays in your script. 

  7. For example:

     

    local playerPos = g_game.getLocalPlayer():getPosition()
    local templeX = 32727
    local templeY = 31627
    
    setOption("Cavebot/Enabled", "false")
    
    if playerPos.x >= templeX and playerPos.y => templeY then
        gotolabel("Temple", "Training")
    else
        gotolabel("Start", "Training")
    end

     

    And then have an action script after your other labels that enables it again.

     

    setOption("Cavebot/Enabled", "true")

     

    Let me know if it works or not.

  8. playername should not be in " ". 

    If it needs a string you can use    tostring(playername)

     

    NOTE: I haven't tested this it's just off the top of my head looking at what you posted. Let me know if this fixes your issue. 

     

     

    EDIT: Here's the script I used to use, haven't used it in a while, but I assume it still works.

    --------------------------------------------
    -- 			Heal Friend with Spell
    --				 by Tokumei
    --------------------------------------------
    -- 		  Version 1.0 (21/10/2021)
    --		  Version 1.1 (22/10/2021)
    --		    - Minor Syntax Update
    --------------------------------------------
    
    
    -- Edit this part --
    local friendName = "Tokumei"  	-- insert your friends name here
    local healPercent = 70			-- the % of HP you want to heal your friend at (eg 70%)
    local spell = 'Exura sio "'		-- Spell to use for healing your friend
    local spellCD = 1000			-- what is the internal cooldown of the spell (1000 = 1second)
    
    -- Don't edit this unless you know what you're doing --
    local friend  
    local friendHP
    local creatures = g_game.getCreatures()
    
    friendHeal = function(s, f)
    	g_game.talk(s..f)
    end
    
    friendCheck = function(fN, m)
    	for v,k in pairs(m) do
    		if k:getName() == fN and k:isPlayer() then
    			friend = k:getName()
    			friendHP = k:getHealthPercent()
    			friend = true
    			break
    		else
    			friend = false
    		end
    	end
    	return friend 
    end
    
    if friendCheck(friendName, creatures) then 
    	if friendHP <= healPercent then 
    		friendHeal(spell, friendName)
    		sleep(spellCD, spellCD+100)
    	end
    end
    
    auto(100,150)

     

    - Tokumei

    • Like 1
  9. On 11/20/2021 at 5:00 AM, Eixim said:

    There is no direct function to equip, you can however move an item to the slots position.

    g_game.moveItem(item, Position.new(65535, slotID, 0), count)

     O.o Thanks! Was that in the docs and I'm just blind?

     

    - Tokumei

  10. 20 hours ago, Rikos1 said:

    Hi, i need script for drop items, like toput on waypoint action and then drop ID item on this sqm, anyone?

     

     

    The search function is a wonderful thing.

     

     

    Just remove the Auto part at the bottom and put it in an action waypoint.

    I haven't used it personally, but I assume it works.

     

    - Tokumei

  11. 21 hours ago, Ruchacz said:

    Can i have script for ene ring ?

     

    Unfortunately I don't think it's currently possible to equip items. 

    I could be wrong, hopefully I am, and someone else could show us how to do that.

     

    - Tokumei 

  12. On 11/14/2021 at 9:18 PM, wasiex said:

    Could you edit this script so the values are set more randomly not only 2 values?

    I mean a range lets say for example from 25-50 and from 100-250

    
    if g_game.isAttacking() then
      setOption("Cavebot/WalkDelay", "180")
    else
      setOption("Cavebot/WalkDelay", "25")
    end
    auto(100)

     

     

    I don't think it's necessary to use here, but you could probably use the math.random() function.

     

    local randomizer01 = tostring(math.random(150,200))		-- returns a random number between 150 and 200
    local randomizer02 = tostring(math.random(20,50))		-- returns a random number between 20 and 50
    
    if g_game.isAttacking() then
      setOption("Cavebot/WalkDelay", randomizer01)
    else
      setOption("Cavebot/WalkDelay", randomizer02)
    end
    auto(100)

     

    I haven't tested it at all though. Let me know if it works.

     

    - Tokumei

    • Thanks 1
  13. 1 hour ago, Eixim said:

    +1 I've noticed this as well but I wasn't sure if it was just me since I'm not playing a real map so the normal looter doesn't seem to work well in general.

     

    I've opted to make my own script handle the looting instead. If you want a quick fix in the meantime, make a script that simply iterates through open containers and checks if the containers name includes "slain" (or w.e other keywords indicate a corpse for you) and then just make an array of food ids that you want it to try and eat.

    Oh that's a nice way to do it. I made one just looking for the corpse ID on floor tiles, but haven't really tested it much, but I like the sound of your approach. 

     

    - Tokumei

  14. Just a thought, but I've noticed the bot not looting sometimes as it get's stuck trying to eat from the corpse.

    My suggestion would be to limit the amount of tries to eat, or significantly lower it's priority.

     

    - Tokumei

  15. I'm not sure if this was intended or not but using the function "g_game.getLocalPlayer():getItemsCount(****)" now returns the stacks of items instead of the total count. 

    For example, if I had 423 UH's on my character it would return 5. 

     

    As a side note, I did find an itemCounting script on the forums, but that only returned the count of the first stack. 

    Using the same example as above it would return 23.

     

    EDIT: I've made my own function that works, but yeah just thought I'd post this as I'm not sure if that was how the "getItemsCount()" function was intended to work.

     

    - Tokumei

  16. Not sure if this is what you're after.

    I have NOT tested it, so please let me know how it goes.

    local distance = 1				-- Distance from player to count mobs in
    local mobCount = 1				-- Minimum amount of mobs inside distance
    local spell = "exeta res"		-- Spell to cast if conditions are true
    local globalCD = 2000			-- Global cooldown of spells/actions (1000 = 1 second)
    
    if #g_game.getMonstersAround(distance) >= mobCount then
      g_game.talk(spell)
      sleep(globalCD,globalCD+200)
    end
    
    auto(100,200)

    - Tokumei

  17. You're going to have to tell us more than just that.

    I've never played NarutoStory, do you want a script that just right-clicks on a stack of 100 rins (like changing gold coins to plats etc.)? 

    - Tokumei

×
×
  • Create New...