Class scripting/routines

disturbedm86

Active Member
I've read all i can on this site about do it yourself scripting but haven't seen anything extensive on how to do the class scripts properly. The swash script that comes with eq2bot isn't set up properly to maximise dps (which is fine i didn't expect it too) however i've edited the spell list and added the new 81-90 spells correctly.

Im now at the point where im editing the class routines and i've swapped out numbers to the order that will yield more dps, however after spending the last two days comparing the edited swash script to the original im still at a lost of what to do next.

for example

function Combat_Init()
{

Action[1]:Set[Melee_Attack1]
SpellRange[1,1]:Set[150]

Action[2]:Set[Flank_Attack1]
SpellRange[2,1]:Set[111]

Action[3]:Set[Debuff1]
Power[3,1]:Set[20]
Power[3,2]:Set[100]
SpellRange[3,1]:Set[191]

Action[4]:Set[AA_Theiving_Essence]
SpellRange[4,1]:Set[389]

Action[5]:Set[Flank_Attack2]
SpellRange[5,1]:Set[110]

Action[6]:Set[Melee_Attack2]
SpellRange[6,1]:Set[150]

Action[7]:Set[Melee_Attack3]
SpellRange[7,1]:Set[154]

Action[8]:Set[AA_WalkthePlank]
SpellRange[8,1]:Set[385]

Action[9]:Set[AoE1]
SpellRange[9,1]:Set[95]

Action[10]:Set[AoE2]
SpellRange[10,1]:Set[96]

Action[11]:Set[Rear_Attack1]
SpellRange[11,1]:Set[100]

Action[12]:Set[Rear_Attack2]
SpellRange[12,1]:Set[101]

Action[13]:Set[Debuff2]
Power[13,1]:Set[20]
Power[13,2]:Set[100]
SpellRange[13,1]:Set[190]

Action[14]:Set[Mastery]

Action[15]:Set[Flank_Attack3]
SpellRange[15,1]:Set[110]

Action[16]:Set[Flank_Attack4]
SpellRange[16,1]:Set[111]

Action[17]:Set[Melee_Attack6]
SpellRange[17,1]:Set[150]

Action[18]:Set[Front_Attack]
SpellRange[18,1]:Set[120]

Action[19]:Set[Melee_Attack7]
SpellRange[19,1]:Set[153]

Action[20]:Set[Melee_Attack8]
SpellRange[20,1]:Set[151]

Action[21]:Set[Melee_Attack9]
SpellRange[21,1]:Set[152]

Action[22]:Set[Melee_Attack10]
SpellRange[22,1]:Set[153]

Action[23]:Set[Melee_Attack11]
SpellRange[23,1]:Set[149]

Action[24]:Set[Melee_Attack12]
SpellRange[24,1]:Set[154]

Action[25]:Set[Snare]
Power[25,1]:Set[60]
Power[25,2]:Set[100]
SpellRange[19,1]:Set[235]

Action[26]:Set[AA_Torporous]
SpellRange[26,1]:Set[381]

Action[27]:Set[AA_Traumatic]
SpellRange[27,1]:Set[382]

Action[28]:Set[AA_BootDagger]
SpellRange[28,1]:Set[386]

Action[29]:Set[Rear_Attack3]
SpellRange[29,1]:Set[130]
}


First thing is there something wrong with the above? Someone asked about the spellrange thing in another thread and looking at other script files im prosuming im using that correctly but, again im not sure.
Looking further down that file i notice the function combat routine bit and im wondering if i have to "mess" around with that aswell to get it working better/at all.

Atm with what i've edited in the file (above segment only) it casts some ( flash of steel which is number 150 - but pretty much nothing else. )

Also the class_key files will i need to update them manually so all the names are upto date or does that not really matter since the script goes of a coded number anyway? (im guessing it doesnt matter since flash of steel [150] is known as "swipe" in the key file and it casts fine.

Hopefully that all makes sense i just wouldnt mind some rough guidance so atleast i know what to mess around with and what not too. If a wiki page or anything exists that goes into detail that would also be great.


Thanks once again for any replys.
 

bob_the_builder

Well-Known Member
This is just the sequence and spell numbers that will be called during the SWITCH routine in the combat_routine.

Search one of the other class files for "switch ${Action[${xAction}]}" and see how they are being used. You might also want to look at the Coercer and Wizard scripts that use spell casting priorities.

What you posted "seems" correct but without seeing the SWITCH routine it is hard to tell.

Have you looked at the new OGREBOT? This might be a better solution for you since you don't have to know anything about scripting.
 

disturbedm86

Active Member
This is just the sequence and spell numbers that will be called during the SWITCH routine in the combat_routine.

Search one of the other class files for "switch ${Action[${xAction}]}" and see how they are being used. You might also want to look at the Coercer and Wizard scripts that use spell casting priorities.

What you posted "seems" correct but without seeing the SWITCH routine it is hard to tell.

Have you looked at the new OGREBOT? This might be a better solution for you since you don't have to know anything about scripting.

Thanks for the reply, i've looked in other class files, mainly melee since its the swash script i was playing with and the reason i posted was because i didn't know what i had to look at besides what i've previously posted, and as much as i've stared at it, nothing changed. I was talking to Kannkor the other day about Ogre but tbh for what i need it for i don't need something that extensive. At the same time though i have no issues learning how to do something and quite frankly i'd sooner learn how to do these scripts myself.

Tbh i prosumed it was a case of me moving the numbers (ones that refer to a spell/ca) to make the better casting order, clearly from what you've said its not that black and white. In which case can you atleast tell me what matters when it comes to combat. Like you said above i need to look at the part with the switch routine, is there other parts i need to alter aswell as that then?

Looking at the file right now and i was thinking does combat routine have anything to do with my problem and although i dont understand scripting most of it makes sense and everything looks in place but yet it only casts the one CA and not the rest. Im also not recieving any debug msgs in the isx window.


This is the switch from the file

switch ${Action[${xAction}]}
{
case Melee_Attack1
case Melee_Attack2
case Melee_Attack3
case Melee_Attack4
case Melee_Attack5
case Melee_Attack6
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
break
case AoE1
case AoE2
if ${AoEMode} && ${Mob.Count}>=2
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
break
case Snare
if ${SnareMode}
{
call CheckCondition Power ${Power[${xAction},1]} ${Power[${xAction},2]}
if ${Return.Equal[OK]}
call CastSpellRange ${SpellRange[${xAction},1]} 0 0 0 ${KillTarget} 0 0 0 0 1
}
break
case Rear_Attack1
case Rear_Attack2
if (${Math.Calc[${Target.Heading}-${Me.Heading}]}>-25 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<25) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}>335 || ${Math.Calc[${Target.Heading}-${Me.Heading}]}<-335
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif ${Target.Target.ID}!=${Me.ID}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 1 ${KillTarget} 0 0 0 0 1
break
case Mastery
if !${MainTank} && ${Target.Target.ID}!=${Me.ID}
{
if ${Me.Ability[Sinister Strike].IsReady} && ${Actor[${KillTarget}](exists)}
{
Target ${KillTarget}
call CheckPosition 1 1 ${KillTarget}
Me.Ability[Sinister Strike]:Use
wait 4
}
}
break
case AA_WalkthePlank
if ${Me.Ability[${SpellType[${SpellRange[${xAction},1]}]}].IsReady}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
break
case AA_Torporous
case AA_Traumatic
if ${Me.Ability[${SpellType[${SpellRange[${xAction},1]}]}].IsReady}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
break
case AA_BootDagger
if ${Me.Ability[${SpellType[${SpellRange[${xAction},1]}]}].IsReady}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
break

case Flank_Attack1
case Flank_Attack2
if (${Math.Calc[${Target.Heading}-${Me.Heading}]}>-25 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<25) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}>335 || ${Math.Calc[${Target.Heading}-${Me.Heading}]}<-335
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif (${Math.Calc[${Target.Heading}-${Me.Heading}]}>65 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<145) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}<-215 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}>-295)
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif (${Math.Calc[${Target.Heading}-${Me.Heading}]}<-65 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}>-145) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}>215 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<295)
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif ${Target.Target.ID}!=${Me.ID}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 3 ${KillTarget} 0 0 0 0 1
case Debuff1
case Debuff2
case Taunt
if ${TankMode}
call CastSpellRange ${SpellRange[${xAction},1]} 0 0 0 ${KillTarget} 0 0 0 0 1
break
case Front_Attack
if (${Math.Calc[${Target.Heading}-${Me.Heading}]}>65 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<145) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}<-215 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}>-295)
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif (${Math.Calc[${Target.Heading}-${Me.Heading}]}<-65 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}>-145) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}>215 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<295)
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif (${Math.Calc[${Target.Heading}-${Me.Heading}]}>125 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<235) || (${Math.Calc[${Target.Heading}-${Me.Heading}]}>-235 && ${Math.Calc[${Target.Heading}-${Me.Heading}]}<-125)
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
elseif ${Target.Target.ID}!=${Me.ID}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 3 ${KillTarget} 0 0 0 0 1
else
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 2 ${KillTarget} 0 0 0 0 1
break

case Stun
if !${Target.IsEpic}
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1
break
default
return CombatComplete
break
}
}


I have no issue messing around and learning how to do this through repetition, repetition, repetition, but i'd atleast like to know what im looking at, something to confer to of some sorts. Like the above certain parts make sense but then the

0 0 0 0 1 bits etc just dont at all.

Also why does everything in the switch bit say "case" when it looks like it should be " cast", its these little things i want to understand.

Don't suppose you have any known sites that go into the basics of scripting i can read up on do you please?

Also just to point out the script im playing with was the original swash script that came with Eq2bot and ive only changed stuff that i know for a fact refers to an ability/ca etc. Haven't touched a single other thing that would "break" a script - as in i havent randomly added a letter/number somewhere or deleted anything.

Thanks again
 
Last edited:

Hendrix

Well-Known Member
For starters, we don't need code highlighted in red. a simple code tag would work fine.

Secondly you should probably start by reading around the lavishscript wiki (http://www.lavishsoft.com/wiki/index.php/LavishScript) since you seem to not know how a switch statement works. Let me break it down for you.

Code:
switch ${SomeVariable}
{
       case Action1
       case Action2
               Perform some code
       break
       case Action3
               Perform other code
        break
        default
               Perform default action
        break
}
in this case we are going to branch to different pieces of code based on what value ${SomeVariable} holds. If it hold the value of Action1 or Action2, "Perform some code" will be ran (any case statements without a break will fall through each line of the switch until it hits a break). if ${SomeVariable} is Action3 then "Perform other code" is ran. If ${SomeVariable} doesn't match with any case statement then the default portion is ran (in this case, "Perform default action").

SO, when you are doing something like, "Action[1]:Set[Melee_Attack1]" in your combat init, the Melee_Attack1 is matching to a case statement. In this case, Melee_Attack1 through Melee_Attack6 all call the same function.

Now lets look at
call CastSpellRange ${SpellRange[${xAction},1]} 0 1 0 ${KillTarget} 0 0 0 0 1

CastSpellRange is a function that is within EQ2bot proper. It can take 11 parameters, please don't ask me what all of these variables to since I have not coded for eq2bot in a LONG time, but this was taken from the cast spell range code.

Code:
;; This format still works.
	;; function CastSpellRange(int start, int finish, int xvar1, int xvar2, uint TargetID, int notall, int refreshtimer, bool castwhilemoving, bool IgnoreMaintained, int CastSpellWhen, bool IgnoreIsReady)

	;; Notes:
	;; - IgnoreMaintained:  If TRUE, then the bot will cast the spell regardless of whether or not it is already being maintained (ie, DoTs)
	;; - If the parameters of this function are altered, then the corresponding function needs to be altered in: Illusionist.iss
	;;
	;;	CastSpellNow changed to CastSpellWhen
	;;	CastSpellWhen:
	;;		0 = Queue Spell
	;;		1 = Cast Immediately
	;;		2 = Cast When Current Queue Complete
	;;;;;;;

I hope I have given you a little insight on how class routines work.
 

disturbedm86

Active Member
Actually that makes a big difference, very helpful, thank you for taking the time to respond.

About the code being red, lol i actually did that to break it up and not have a block of text to read but i suppose in hindsight i should have realised scripters would be reading it and in that case they are used to looking at much worse, ah well. :dazed:

Thanks all
 
Top Bottom