Write your own damn bot. Bot starter kit.

You may request or share scripts for MicroMacro in this forum.
Post Reply
Message
Author
zuel
Posts: 21
Joined: Mon Jan 10, 2011 12:49 am

Write your own damn bot. Bot starter kit.

#1 Post by zuel » Sat Jan 15, 2011 5:19 am

I have been working on a bot for Dragon Oath and as I have written this code I realize that everyone must be starting with something similar.

I have provided in the attached zip file a basic Skill configuration tool and the LUA to parse it and cast a skill based off of those configurations.

The skill cast accounts for Enemy, Player, Pet health, mana and rage. Gives you an option to specify mins and max's of when to cast the spells. Tracks Cooldown timers, GDC's, and a load of other information.

The XML skill structure:

Code: Select all

    
   <Skill name="NourishSphere"> -- Self explanitory.
        <Enabled>True</Enabled> -- Self explanitory.
        <CoolDownSecs>1800</CoolDownSecs>  -- Time in seconds to when this skill can be cast again.
        <CastTime>0</CastTime>  -- time in miliseconds to cast the skill.
        <Priority>0</Priority> -- Higher the number, the higher the priority.
        <Vkey>VK_6</Vkey>  -- Self explanitory.
        <KeyModifyer></KeyModifyer>  -- Self explanitory.
        <States>   -- There are 3 states a skill can be cast, Attack, Buf, Rest.  Specify what states you want this skill cast in.
          <State>Attack</State>
          <State>Buf</State>
        </States>
        <CastBelowHealth>1</CastBelowHealth>  -- Range 0 to 1
        <CastBelowMana>1</CastBelowMana>     -- Range 0 to 1
        <CastBelowRage>1</CastBelowRage>   -- Range 0 to 1
        <CastAboveHealth>0</CastAboveHealth>  -- Range 0 to 1
        <CastAboveMana>0</CastAboveMana>  -- Range 0 to 1
        <CastAboveRage>0</CastAboveRage>  -- Range 0 to 1
        <CastBelowTargetHealth>1</CastBelowTargetHealth>  -- Range 0 to 1
        <CastAboveTargetHealth>0</CastAboveTargetHealth>  -- Range 0 to 1
        <CausesGDC>1000</CausesGDC>  -- How much time does this skill add to the GDC?  in seconds.
        <ObeysGDC>True</ObeysGDC>  -- Can you cast this skill even during GDC, of so, ObeysGDC = false.
        <Channeled>False</Channeled>  -- Is this skill cast > 0 seconds and can it fail being cast.  If so, set this to true and CastTime > 0
        <CastBelowPetHealth>1</CastBelowPetHealth>  -- Range 0 to 1
        <CastAbovePetHealth>0</CastAbovePetHealth>  -- Range 0 to 1
        <SelfCast>False</SelfCast>  -- Does the bot need target himself.
        <TargetBuf hasnot="False"></TargetBuf>  -- NI - but, Cast if target has, or cast if target doesnt have this buf.
        <PlayerBuf hasnot="False"></PlayerBuf> -- NI - but, Cast if target has, or cast if target doesnt have this buf.
      </Skill>
The configuration tool is in C# with absolutely no comments. Each configuration can be toggled on and off VIA the app.config file with no code changes.

The configuration XML supports multiple players and skills.

I hope someone can make use of this. I'd upload my whole bot but I am struggling on some memory address's forcing me frequently CE them again.
Attachments
DoBotConfigv2.1.zip
(48.26 KiB) Downloaded 216 times

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Write your own damn bot. Bot starter kit.

#2 Post by Administrator » Sun Jan 16, 2011 12:30 pm

This could actually be quite useful, if only for educational purposes. Unfortunately, 99% of the users here aren't actually interested in making their own scripts (at least not yet).

zuel
Posts: 21
Joined: Mon Jan 10, 2011 12:49 am

Re: Write your own damn bot. Bot starter kit.

#3 Post by zuel » Sun Jan 16, 2011 1:57 pm

Aw.

Well this code is really pretty raw. Like I said, I imagine that everyone whom started a bot started from similar ideas. And the first part I guess in making any bot is, "Can I get it to intelligently kill a mob" So, the idea behind this code is to create a configuration that tracks cooldowns and timers outside of the game, then apply some basic logic like a player would, Should I use this spell if Mob has x health, should I us this spell if I have x health, mana, rage etc. More advanced bots would start cutting down this code by relying more heavily on memory address's of the game. IE, find location for skill x and get cooldown information.

I broke down skills into 3 types essentially. A rest skill, an Attack skill and a buf skill.

Therefore, my bot has 3 states (skill related) that in most cases I dumb through. Example a full cycle the bot performs runs through these states.

Rest - Cast any rest skills. -> buff
Buff - Cast any buff skills. -> Idle
Idle - Idly looking for a mob, select, target and.. -> Attack
Attack - Killed mob or lost target -> CheckArea
CheckArea - Check for loot and any mobs attaking me. If I am being attack, target and Set state to Attack -> Attack. If no mobs, set State to Rest and start over -> Rest.

A simple state diagram really.

These states are no different than a human player performs in their head. Prepare (rest Buf), Find Mob(Idle), Get me Loot and kill any Adds (CheckArea - Loot, CheckArea -> Attack), rinse and repeat.

I think it's clever the way I handled it and the code should be pretty reusable for anyone.

There are things that are required to make the skill fuction actualy work however. I suspect that a first draft of the following functions would likely be from pixel searching. Then progressing on to getting memory allocations.

Code: Select all


playerInfo = {
	["state"]  = "Rest",
		
		--return % health
		Health = function ()
		end,
		
		--return % mana
		Mana = function ()
		end,
		
		--return % rage
		Rage = function ()
		end,
		
		--return True if casting
		IsCasting = function ()		
		end,
}

petInfo = {
		--return % health
		Health = function () 
		end	,
}


targetInfo = {
  --return % health
	Health = function ()
	end,
}

function selectSelf()
		--I have to click on my portrait.  Maybe your game has a hot key or you know how to pull it off by hooking.
end

-- my invention of thread sleep to allow my other coroutine cpu time.
function threadSleep(t)
	local sleepStart = getTime();
	coroutine.yield();
	if(deltaTime(getTime(), sleepStart) < t)then
		yrest(t-deltaTime(getTime(), sleepStart));
	end	
end
  


Thanks for your reply.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests