casterbot

Macro depository for macros written before the user variable changes that broke all of them.

Moderator: MacroQuest Developers

eqaddict
a lesser mummy
a lesser mummy
Posts: 74
Joined: Sun Sep 15, 2002 10:05 pm

casterbot

Post by eqaddict » Wed Dec 18, 2002 2:07 pm

[edited]

Ops, somehow things got screwed up when I tried to make it prettier ! dont think about using this until I fix it :oops: have to fix it for myself anyway.

T
This is what I use for my casterbots!

fixed: to work with multiple chars requesting bufs.
bug: multiple chars requesting same group buf recasts for each request

-EqA

Code: Select all

|castbot.mac
|written by EqAddict

#turbo

#include Spellcast.mac 
#include spellbook.mac
#include bots.mac

#chat tell 
#chat group

|----------------------------------------------------------
|Main loop is here, you need to add your own specific bot code (ie shamanbot found in bots.mac)
Sub Main 	
	/echo Starting
	/call cleanup
:mainloop	
	/varset l1 $a(castList,0)
	/doevents
	/if n $l1!=$a(castList,0) /goto :mainloop

	|/if $char(class)=="Shaman" /call shamanBot
	|/if $char(class)=="Enchanter" /call chanterBot
	|/if $char(class)=="Druid" /call druidBot 
	
	/call castSpellList 3

	/delay 2
	/goto :mainloop

/return 
|----------------------------------------------------------

Sub Event_Chat 
	/if n $instr("<$p1>","AUTHLIST")==-1 {
		/mqlog UNAUTHORIZED ACCESS --->>> $p0 $p1 $p2
		/return
	}

	/varset l1 "$p2"
	/if "$arg(1,"$l1")"==KEYWORD {
		/echo caught keyword from $p1
		/varcalc l4 $strlen(KEYWORD)+1
		/varcalc l3 $int($strlen("$l1")-$l4-1)
		/varset l5 "$mid($l4,$l3,"$l1")"
		/if "$char(book,"$l5")"=="NULL" {
			/echo "$l5" - not my spell
		} else {
			/call putSpellOntoList "$l5" $p1 

	}
	/if "$arg(1,"$l1")"==ATTACK {
		/varset v92 1
	}
/return 

|----------------------------------------------------------

|Debug routine
sub showSpellList
	/varset l1 $a(castList,0)
	/for l2 $l1 downto 1
		/echo $l2 --> $a(castList,$l2)
	/next l2
/return

|----------------------------------------------------------
|Place a spell onto a LIFO (Last In First Out) stack
| usage: putSpellOntoList target spell
sub putSpellOntoList

	/varset l1 $a(castList,0)
	/varset a(castList,$l1) "$p1"
	/varadd l1 1
	/varset a(castList,$l1) "$p0"
	/varadd l1 1	
	/varset a(castList,0) $l1

/return
|----------------------------------------------------------
|Process spells on list
|if a parameter is given it process only that many spells before returning
|ie castSpellList 2 will cast only 2 spells and return (uncast spells stay on stack)
| usage: castSpellList SlotToUse (ie 3)
sub castSpellList
	/varset l1 $a(castList,0)
	/if n $l1<=2 /return
	/varset l3 0
	/varsub l1 1
	/for l2 $l1 downto 1
		/varset l5 "$a(castList,$l2)" |spell 
		/varsub a(castList,0) 1
		/varsub l2 1
		/varset l4  "$a(castList,$l2)" |target
		/echo casting $l5 on $l4
		|only try to cast if we have it in book
		/if "$char(book,"$l5")"!="NULL" {
			/target $l4
		:waitforprevspellcast
			/varset l6 "$char(gem,$p0)"
			/delay 2
			/if n $char(gem,"$l6")<0 /goto :waitforprevspellcast
			/call memorizespell "$l5" "$p0"
			/stand
			/delay 2	
			/call cast "$l5"
			/varadd l3 1
			/if $p0!="" /if n $l3>=$p0 /return
		} else /echo "$l5" not my spell
		/varset a(castList,$l2) "NULL"
		/varsub a(castList,0) 1
	/next l2	
/return 
Last edited by eqaddict on Wed Dec 18, 2002 11:59 pm, edited 2 times in total.

eqaddict
a lesser mummy
a lesser mummy
Posts: 74
Joined: Sun Sep 15, 2002 10:05 pm

Post by eqaddict » Wed Dec 18, 2002 5:25 pm

This is an example of how I use the auto cast feature of the castbot.

Run this on your melee character (or another caster)

Code: Select all

#include bots.mac

sub Main
	:mainLoop
	/call initBufs
	/echo delay (delete a buf to see it reappear)
	/delay 50
	/call checkBufs recastTime
/return


sub initBufs
	|init bufs
	/varset l2 1
	/for l1 0 to maxBuffs
		/if "$char(buff,$l1)"!~"NULL" {
			/varset a(aBuff,$l2) "$char(buff,$l1)"
			/echo added $a(aBuff,$l2)
			/varadd l2 1	
		} else 	{
			/varset  a(aBuff,$l2) "NULL"
		}
	/next l1
/return

sub checkBufs
	|examine bufs
	/for l1 1 to maxBuffs
		|l2=slot #, l3=duration, $l4=name	
		/varset l4  "$a(aBuff,$l1)"
		/varset l2 $char(buff,"$l4")
		/varset l3 $char(buff,$l2,duration)	
		|/echo Checking $l4, $l3, $l2
		/if "$l4"~~"NULL" {
			/echo done checking
			/return
		} 
		|/echo $l4 in slot $l2  has $l3 ticks left
		/if n $l3<=$p0 {
			/g losing $l4 .
		}
	/next l1
/return

eqaddict
a lesser mummy
a lesser mummy
Posts: 74
Joined: Sun Sep 15, 2002 10:05 pm

Post by eqaddict » Wed Dec 18, 2002 5:25 pm

This is my bots.mac stripped a bit.

Code: Select all

#define AUTHLIST "<player1> <player2>"

#define KEYWORD "Losing"
#define ATTACK  "Attack"

#event fightDone "gain party experience"
#event fightDone "faction"

#define castList 1	|on spell  list element 0 holds last used position
#define aBuff 0		
#define recastTime 60
#define maxBuffs 16
|------------------------------------------
#define shamanHeal "Tnarg`s Mending"


|------------------------------------------


sub genericBOt
	/if n $v92==1 {
		/varset v92 0
		/echo Responding to Request to ATTACK
	}

	/if "$combat"~~"TRUE" {
		/echo COMBAT MODE is ACTIVE
	}
/return 


sub druidBot
/return

sub chanterBot
/return

sub ShamanBot
	/doevents

	|respond to attack requested flag
	/if n $v92==1 {
		/varset v92 0
		/call doDuck
		/assist $p1
		/delay 2
		/pet attack
		/call cast "$char(gem,8)"
		/call cast "$char(gem,7)"
		/call cast "$char(gem,6)"
		/call cast "$char(gem,5)"
		/press 3
		/delay 20
	}

	|store current target and check peeps health
	/varset l1 $target(id)
	/target pc class monk
	/delay 2
	/if n $target(hp,pct)<=60 {
		/call doDuck
		/g healing %t
		/call cast "shamanHeal"
	}

	/if n $char(hp,pct)<=60 {
		/target myself
		/delay 2
		/g healing %t
		/call cast "shamanHeal"
	}

	|restore current target
	|/echo combat is $combat
	/if "$combat"~~"TRUE" {
		|check root status and then nuke
		/echo COMBAT
		/varset l1 $target(speed)
		/if n $l1><0 {
			/g ROOTING <%t>
			/call cast "$char(gem,8)"
		}
		/press 4
		/delay 30
	}
	/if n $char(hp,pct)==100 /if n $char(mana,pct)><100 /call cast "$char(gem,2)"
	/if n $char(hp,pct)>=60 /if n $char(mana,pct)<=70 /call cast "$char(gem,2)"
/return

sub event_fightDone
	/pet follow me
/return

sub cleanup
	/press ESC
	/press ESC
	/attack off
	/stand
	/press shift
	/press alt
	/press ctrl
	/varset a(castList,0) 1
/return

sub doDuck
	/press d
	/delay 1
	/press d
	/delay 1
/return