Scripting Basics!

mmoaddict

Original Script Author: VGA
So you want to write a script but you have no idea where to start....

lesson 1

create a plain text file with the extension iss.. so test.iss is ok. Use notepad. Make sure to save as all file types or you might end up with test.iss.txt as the name of your file. That wont work

Then you need the first and most basic thing. The format of the main function
Code:
function Main()
{
}
That is a complete script. Just go into your innerspace blue bar and run this script. Type in run test

Bamb it was so fast you didnt even see it.. but you did it!
 

mmoaddict

Original Script Author: VGA
Lesson 2

I bet you want your script to do something like double click on a christmas tree for ya and get the goods off it.

Code:
function Main()
{  
    do
    {
      wait 2
      MouseClick -hold left
      wait 1
      MouseClick -release left
      wait 2
      MouseClick -hold left
      wait 1
      MouseClick -release left
     }
   While ${Me(exists)}
}
A simple do - while statement can cause the script to loop and do it until the while statement is false. Just by haveing isxvg extention installed and being logged into the game ${Me} does exists and will be true. Once you log out.. this statment is fase and the script will finish .

In fact this code could be used to make without the need of isxvg. Just cange the last line to this.
Code:
function Main()
{  
    do
    {
      wait 2
      MouseClick -hold left
      wait 1
      MouseClick -release left
      wait 2
      MouseClick -hold left
      wait 1
      MouseClick -release left
     }
   While ${Script(exists)}
}
 
Last edited:

mmoaddict

Original Script Author: VGA
Pressing Keys

There are a whole bunch of little scripts that can be very useful. How about a simple macro that just presses the keys you care about over and over again.

Code:
function main()
{
 do
  {
    Press 2
    wait 10
  }
  While ${Script(exists)}
}
better than a G15 baby
 
Last edited:

mmoaddict

Original Script Author: VGA
Lets kills something,, Lets say you are out playing and you figures get tired but you need to unload on the mob... keep your hotkeys the same in the game and make a script like this for sorcerses.

Simple and direct If i am targeted on a mob, and i push myself to be in combat with the mob. and i am within 25 to kill it.. blow the bastard up!

I got hotkerys on the keyboard to use my epid staff, then i ahve amply acuity, celerity, descrutions and starsparkcs in the next macro.. QUICKINGING JOLT CAN BE IN THAT MACRO AS WELL, Bam the hit em with sleeves boost... the spame the crap out of the dps macho.. Probably looks like /cast seradons fallign comet /cast mimic, cast inferno, cast char, superior chaos. Need to cool the script down.. just change macro bars.. you can have differnt macros made in vg and instead of wriing crazy script for everything yuo wnat to do.. you make the macro make the game part easy.. then make the script press teh macros for you.
Code:
function main()
{
   do     
   {
    if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
    {
           if ${Me.Inventory[Zaseh's Talon].IsReady}
               press 4
           if ${Me.Ability[Seradon's Falling Comet].IsReady}
               {
                if ${Me.Ability[Amplify Acuity].IsReady}
                Press 3
                if ${Me.Inventory[Sleeves].IsReady}
                Press 5
                if ${Me.Inventory[Lesser Damage Potion].IsReady}
                Press 6
                waitframe
                 }
           Press 2
           waitframe
    }
    While ${Script(exists)}
 }
 
Last edited:

mmoaddict

Original Script Author: VGA
a bit about pawns

Dealing With Pawns... Basically pawns are objects like, mobs, npcs, harvesting nodes.. They show as dots on your radar. Say your in the group where you are supposed to loot everything. Lets make a loop routine to look for all the pawns around us.. and loot if there is loot for us.
Code:
function main()
{
   do     
   {
	; If i am not in combat or (or is the ||)  the group has no encounters 
	if (!${Me.InCombat} || ${Me.Encounter} == 0)
		{
			variable int iCount
			iCount:Set[1]
			; Cycle through all the Pawns and find some corpses to Loot 
			do
			{
				;If the Pawn is a corpse and it is within looting distance and contains loot for me.. LOOT IT ALL
				if ${Pawn[${iCount}].Type.Equal[Corpse]} && ${Pawn[${iCount}].Distance} < 5 && ${Pawn[${iCount}].ContainsLoot}
				{
					Pawn[${iCount}]:Target
					wait 3
					VGExecute /Lootall
					waitframe
					VGExecute "/cleartargets"	
				}
			}	
			while ${iCount:Inc} <= ${VG.PawnCount}
		}
    }
    While ${Script(exists)}
 }
 
Last edited:

mmoaddict

Original Script Author: VGA
Scripts getting too big

So when your script starts getting too big.. you will want to split up the "Functions" so that it is easier to find what area does what.. here lets combine a couple of the scripts.. The DPS spam button script and the loot all script
Code:
function main()
{
   do     
   {
      ; So here we ask the main questions.. then run the function when the conditions are true.  Once it looks around for stuff.. it waits half a second before it does it again (if you dont wait it can use up your processor running this 1000 times a second}
      if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
           {
           call KillIt
           }
      if (!${Me.InCombat} || ${Me.Encounter} == 0)
           {
           call LootIt
           }
    wait 5
    }
    While ${Script(exists)}
 }
;***********************
function KillIt()
{
    if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
    {
           if ${Me.Inventory[Zaseh's Talon].IsReady}
               press 4
           if ${Me.Ability[Seradon's Falling Comet].IsReady}
               {
                if ${Me.Ability[Amplify Acuity].IsReady}
                Press 3
                if ${Me.Inventory[Sleeves].IsReady}
                Press 5
                if ${Me.Inventory[Lesser Damage Potion].IsReady}
                Press 6
                waitframe
                 }
           Press 2
           waitframe
     }
}
;***********************
function LootIt()
{
	; If i am not in combat or (or is the ||)  the group has no encounters 
	if (!${Me.InCombat} || ${Me.Encounter} == 0)
		{
			variable int iCount
			iCount:Set[1]
			; Cycle through all the Pawns and find some corpses to Loot 
			do
			{
				;If the Pawn is a corpse and it is within looting distance and contains loot for me.. LOOT IT ALL
				if ${Pawn[${iCount}].Type.Equal[Corpse]} && ${Pawn[${iCount}].Distance} < 5 && ${Pawn[${iCount}].ContainsLoot}
				{
					Pawn[${iCount}]:Target
					wait 3
					VGExecute /Lootall
					waitframe
					VGExecute "/cleartargets"	
				}
			}	
			while ${iCount:Inc} <= ${VG.PawnCount}
		}
}
 

mmoaddict

Original Script Author: VGA
A Second way

Like anything there are a few different ways to doing the same thing. Here we are going to write 2 scripts and add one script to the other. So when you type out "run mainvg" The first thing mainvg does is load the Myfunctions script just the same as if you had typed it out in the top of the mainvg code... then it simply runs its main function like normal.

MainVG.iss
Code:
#include "${Script.CurrentDirectory}/MyFunctions.iss"
function main()
{
   do     
   {
      ; So here we ask the main questions.. then run the function when the conditions are true.  Once it looks around for stuff.. it waits half a second before it does it again (if you dont wait it can use up your processor running this 1000 times a second}
      if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
           {
           call KillIt
           }
      if (!${Me.InCombat} || ${Me.Encounter} == 0)
           {
           call LootIt
           }
    wait 5
    }
    While ${Script(exists)}
 }
MyFunctions.iss
Code:
;***********************
function KillIt()
{
    if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
    {
           if ${Me.Inventory[Zaseh's Talon].IsReady}
               press 4
           if ${Me.Ability[Seradon's Falling Comet].IsReady}
               {
                if ${Me.Ability[Amplify Acuity].IsReady}
                Press 3
                if ${Me.Inventory[Sleeves].IsReady}
                Press 5
                if ${Me.Inventory[Lesser Damage Potion].IsReady}
                Press 6
                waitframe
                 }
           Press 2
           waitframe
     }
}
;***********************
function LootIt()
{
	; If i am not in combat or (or is the ||)  the group has no encounters 
	if (!${Me.InCombat} || ${Me.Encounter} == 0)
		{
			variable int iCount
			iCount:Set[1]
			; Cycle through all the Pawns and find some corpses to Loot 
			do
			{
				;If the Pawn is a corpse and it is within looting distance and contains loot for me.. LOOT IT ALL
				if ${Pawn[${iCount}].Type.Equal[Corpse]} && ${Pawn[${iCount}].Distance} < 5 && ${Pawn[${iCount}].ContainsLoot}
				{
					Pawn[${iCount}]:Target
					wait 3
					VGExecute /Lootall
					waitframe
					VGExecute "/cleartargets"	
				}
			}	
			while ${iCount:Inc} <= ${VG.PawnCount}
		}
}
 

mmoaddict

Original Script Author: VGA
switching gears a bit

Sometimes you will want to do the same thing over and over and over again. When i first learned to program. I used to write things like
Code:
function main()
{
do
{
if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
{
    If ${Me.Ability[Call Lightening IV].IsReady}
    {
    Me.Ability:Use[Call Lightening IV]
    wait 25
    echo "Casted Call Lightening IV ${Time}"
    }
    If ${Me.Ability[Lightening Strike V].IsReady}
    {
    Me.Ability:Use[Lightening Strike V]
    wait 25
    echo "Casted Lightening Strike V ${Time}" 
    }
    If ${Me.Ability[Solar Flare VI].IsReady}
    {
    Me.Ability:Use[Solar Flare VI]
    wait 25
    echo "Casted Solar Flare VI ${Time}" 
    }
}
}
while ${Me(exists)}
}
 

mmoaddict

Original Script Author: VGA
That is a lot of typing over and over again..

Lets try to elimate some of the typing we are doing over and over again... We will start with the simple.. lets get the use statement and the echo statement together. And we are going to pass a variable to them
Code:
function main()
{
do
{
if ${Me.Target(exists)} && ${Me.InCombat} && !${Me.Target.IsDead} && ${Me.Target.Distance} < 25
{
    ;Notice i call the function and pass the value between the quotes.. also after the if statements i dont need {} when i only have 1 line of code below it to do.  Makes the script much shorter
    If ${Me.Ability[Call Lightening IV].IsReady}
      call ExecuteAbility "Casted Call Lightening IV"
    If ${Me.Ability[Lightening Strike V].IsReady}
      call ExecuteAbility "Casted Lightening Strike V" 
    If ${Me.Ability[Solar Flare VI].IsReady}
      call ExecuteAbility "Solar Flare VI"
}
}
while ${Me(exists)}
}
function ExecuteAbility(string TheAbility)
{
    Me.Ability:Use[${TheAbility}]
    wait 25
    echo "Casted ${TheAbility} ${Time}" 
}
 

mmoaddict

Original Script Author: VGA
Waiting 2.5 seconds after casting to account for global and such like that.. is not exactly accurate. So lets use some more VGISX commands to tell it what to do.. While loops make it possible to wait .1 second while casting or in global cooldown. Because i have this function separate.. i only need to modify it once to affect every ability I use.

the question many ask is why the .2 second wait before checking for iscasting and inglobalrecovery? It is because scripts run so fast, if you dont wait a little after telling the client to do the ability, it will blow through the casting and global before the client can even respond with those values.

Code:
function ExecuteAbility(string TheAbility)
{
    Me.Ability:Use[${TheAbility}]

    wait 2
    while ${Me.IsCasting}
       wait 1
    while ${VG.InGlobalRecovery}
       {
       wait 1
       }
    echo "Casted ${TheAbility} ${Time}" 
}
 

mmoaddict

Original Script Author: VGA
Well all this begs the question: Why should you be writing your own script? There are already scripts for fishing, crafting, diploing, and adventuring.

Not only is writing your own scripts fun but it is yet another challenege of the game and the more complicated and crazy the game gets, the more challenging scripting becomes.

Watch the game intently when exactly do you want to assist the tank and kill a mob. Is it really at 96% all the time? No, I depends on the mob! It also depends on your opening moves and your ramp up. Wouldn't it be cool to actually parse what damage the tank has done and assist accordingly, and possibly put a timer on it so if the tank is sucking you start in and push agro for a bit. So many variables, so impossible for VGA to account for it all.

The best scripts are going to written by you, for your char, for your play style.

play hard
mmo
 
Top Bottom