Fist, some explanations: this piece of macro assumes that there is a mysql db with two tables (mobs and combat). Also, it assumes the connection is already up (using /sqlconnect) and that it is using the right db (/sql usedb). The macro start with the pressing of an hotbutton in eq that have this command:
Code: Select all
/varset myattack 1Code: Select all
/if n @myattack==1 /call chkPullingCode: Select all
Sub chkPulling
/if n @Debug==1 /echo Status: sub chkPulling
/declare locv1 local
/declare locv2 local
/declare tmpSpawn local
/declare tmpMaster local
/declare MNmbMobs local
/varset myattack 0
/varset tmpSpawn 0
/varset tmpMaster 0
/varset locv2 1
/varset MNmbMobs 10
/alert clear 1
/delay 3
/sql delete combat;
/if n @myradius==0 /varset myradius 150
/if $target(id)==$char(id) /keypress clear_target
/if $target(id)==$char(pet) /keypress clear_target
/delay 3
/if $target()==TRUE {
/if @Debug==1 /echo Status: sub chkPulling first target $target(class), $target(type), $target(hp,pct)
/if "$target(class)"=="Merchant" /goto :ExitTgLoop
/if "$target(type)"=="PC" /goto :ExitTgLoop
/if "$target(type)"=="player" /goto :ExitTgLoop
/if "$target(type)"=="Corpse" /goto :ExitTgLoop
/if n $target(master)!=0 {
/if ("$spawn($target(master),type)"=="PC" || "$spawn($target(master),type)"=="player") /goto :ExitTgLoop
}
/if n $target(hp,pct)<=0 /goto :ExitTgLoop
/varset locv2 2
/alert add 1 id $target(id)
/call PullingOrder $target(id) $target(level)
:ExitTgLoop
}
/for locv1 @locv2 to @MNmbMobs
/if $alert(1)==FALSE {
/if n @myzradius==0 {
/varset tmpSpawn $searchspawn(npc,radius:@myradius)
} else {
/varset tmpSpawn $searchspawn(npc,zradius:@myzradius,radius:@myradius)
}
} else {
/if n @myzradius==0 {
/varset tmpSpawn $searchspawn(npc,noalert:1,radius:@myradius)
} else {
/varset tmpSpawn $searchspawn(npc,noalert:1,zradius:@myzradius,radius:@myradius)
}
}
/if n @Debug==1 /echo Status: sub chkPulling @tmpSpawn, $spawn(@tmpSpawn,class), $spawn(@tmpSpawn,type), @myzradius, @myradius
/if n @tmpSpawn==0 /goto :ExitPulling
/if "$spawn(@tmpSpawn,class)"=="Merchant" {
/if @Debug==1 /echo Status: sub chkPulling "Merchant"
/alert add 1 id @tmpSpawn
/varcalc locv1 @locv1-1
/goto :NextMez
}
/if ("$spawn(@tmpSpawn,type)"=="PC" || "$spawn(@tmpSpawn,type)"=="player") {
/if @Debug==1 /echo Status: sub chkPulling "PC"
/alert add 1 id @tmpSpawn
/varcalc locv1 @locv1-1
/goto :NextMez
}
/if "$spawn(@tmpSpawn,type)"=="Corpse" {
/if @Debug==1 /echo Status: sub chkPulling "Corpse"
/alert add 1 id @tmpSpawn
/varcalc locv1 @locv1-1
/goto :NextMez
}
/if n $spawn(@tmpSpawn,master)!=0 {
/varset tmpMaster $spawn(@tmpSpawn,master)
/if ("$spawn(@tmpMaster,type)"=="PC" || "$spawn(@tmpMaster,type)"=="player") {
/if @Debug==1 /echo Status: sub chkPulling "pet"
/alert add 1 id @tmpSpawn
/varcalc locv1 @locv1-1
/goto :NextMez
}
}
/if n $spawn(@tmpSpawn,hp,pct)>=1 {
/if @Debug==1 /echo Status: sub chkPulling "MOB" OK
/alert add 1 id @tmpSpawn
/call PullingOrder @tmpSpawn $spawn(@tmpSpawn,level)
} else {
/if @Debug==1 /echo Status: sub chkPulling "other"
/alert add 1 id @tmpSpawn
/varcalc locv1 @locv1-1
}
:NextMez
/next locv1
:ExitPulling
/sqlquery select * from combat order by combat.level desc, combat.id desc;
/varset tmpSpawn $sqlfield(1,0)
/if n @tmpSpawn!=$target(id) {
/keypress clear_target
/delay 3
/target id @tmpSpawn
/delay 3
}
/if n @Debug!=1 /attack on
/gsay What ever sentence you want
/return
Sub PullingOrder(MezSpawnID,MezSpawnLvl)
/if n @Debug==1 /echo Status: sub PullingOrder, @MezSpawnID, @MezSpawnLvl
/declare tmp_Zone local
/declare tmp_Name local
/declare tmp_isCaster local
/declare tmp_Class local
/declare tmp_HPs local
/declare tmp_notSlowable local
/declare tmp_doMitigate local
/declare tmp_notSnareable local
/declare tmp_notMezzable local
/declare tmp_doSummon local
/declare tmp_Danger local
/declare tmp_Attackpct local
/varset tmp_Zone "$zone()"
/varset tmp_Name "$spawn(@MezSpawnID,name,clean)"
/varset tmp_Class "$spawn(@MezSpawnID,class)"
/call CmbtCheckClass "@tmp_Class"
/varset tmp_isCaster "$return"
/varset tmp_HPs 0
/varset tmp_notSlowable 0
/varset tmp_doMitigate 0
/varset tmp_notSnareable 0
/varset tmp_notMezzable 0
/varset tmp_doSummon 0
/call Danger "@MezSpawnLvl"
/varset tmp_Danger "$return"
/varset tmp_Attackpct 95
/sqlquery select * from mobs where mobs.name="@tmp_Name" and mobs.zone="@tmp_Zone";
/if n $sqlfield(rows)>0 {
/varset tmp_HPs $sqlfield(3,0)
/varset tmp_notSlowable $sqlfield(4,0)
/varset tmp_doMitigate $sqlfield(5,0)
/varset tmp_notSnareable $sqlfield(6,0)
/varset tmp_notMezzable $sqlfield(7,0)
/varset tmp_doSummon $sqlfield(9,0)
/varset tmp_Attackpct $sqlfield(8,0)
} else {
/sql insert mobs name="@tmp_Name" zone="@tmp_Zone" iscaster=@tmp_isCaster hp=@tmp_HPs notslowable=@tmp_notSlowable domitigate=@tmp_doMitigate notsnarable=@tmp_notSnareable notmezzable=@tmp_notMezzable dosummon=@tmp_doSummon attackpct=@tmp_Attackpct;
}
/sql insert combat name="@tmp_Name" id=@MezSpawnID level=@MezSpawnLvl iscaster=@tmp_isCaster hp=@tmp_HPs notslowable=@tmp_notSlowable domitigate=@tmp_doMitigate notsnarable=@tmp_notSnareable notmezzable=@tmp_notMezzable dosummon=@tmp_doSummon danger=@tmp_Danger attackpct=@tmp_Attackpct;
/return
Sub Danger(dngLvl)
/if n @Debug==1 /echo Status: sub Danger @dngLvl
/varset DangerLvl 0
/if n @dngLvl<=20 {
} else /if n @dngLvl<=30 {
/varset DangerLvl 0.1
} else /if n @dngLvl<=40 {
/varset DangerLvl 0.67
} else /if n @dngLvl<=45 {
/varset DangerLvl 0.8
} else /if n @dngLvl<=50 {
/varset DangerLvl 0.9
} else /if n @dngLvl<=55 {
/varset DangerLvl 1
} else /if n @dngLvl<=57 {
/varset DangerLvl 1
} else /if n @dngLvl<60 {
/varset DangerLvl 1
} else /if n @dngLvl<=62 {
/varset DangerLvl 1
} else /if n @dngLvl<=65 {
/varset DangerLvl 5
} else /if n @dngLvl<=68 {
/varset DangerLvl 5
} else /if n @dngLvl>68 {
/varset DangerLvl 5
}
/return "@DangerLvl"
Sub CmbtCheckClass(CCClass)
/if n @Debug==1 /echo Status: sub CmbtCheckClass @CCClass
/if "@CCClass"=="druid" {
/return "1"
} else /if "@CCClass"=="cleric" {
/return "1"
} else /if "@CCClass"=="shaman" {
/return "1"
} else /if "@CCClass"=="enchanter" {
/return "1"
} else /if "@CCClass"=="magician" {
/return "1"
} else /if "@CCClass"=="necromancer" {
/return "1"
} else /if "@CCClass"=="wizard" {
/return "1"
}
/return "0"One more explanation, I use the sub Dunger to give a value to each mob I am pulling, so that over a specified value (for example 8) one of my bot will cast an evacuate/succor spell automatically (for a pull went very bad).
Hope it can be of some interest to you.
