Conversion trouble..

For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!

Moderator: MacroQuest Developers

Servitore
decaying skeleton
decaying skeleton
Posts: 1
Joined: Fri Jun 18, 2004 10:55 pm

Conversion trouble..

Post by Servitore » Sat Jun 19, 2004 12:01 am

Hello everyone. Recently I have tried to convert an old bard chant kitting macro by IceIsFun but i ran into a little trouble. I don't get any syntax errors when I run my conversion of the macro but it doesnt seem to work as it originally did... It now gets hung up on one of the corners of the diamond.


The original Code by IceIsFun is:

Code: Select all

#turbo 
#chat tell 

Sub Main 
/zapvars 

| These variables are related to movement and AI control. 
/declare RubberX global 
/declare RubberY global 
/varset RubberX @Param1 
/varset RubberY @Param0 

| These variables are related to song-twisting. 
/declare SongTimer timer 
/declare Songs array 
/declare CurSong global 
/declare PrevSong global 
/declare nSongs global 
/declare EachSong local 



| This block of code checks for proper arguments and echos error or initialization messages. 
/if $defined(Param6)==false { 
/echo Usage: /mac Diamond <Y> <X> <North> <South> <East> <West> <Song list> 
/echo <Y> -- Y-coordinate of the center point. 
/echo <X> -- X-coordinate of the center point. 
/echo <North> -- Maximum distance north of the center point to travel. 
/echo <South> -- Maximum distance south of the center point to travel. 
/echo <East> -- Maximum distance east of the center point to travel. 
/echo <West> -- Maximum distance west of the center point to travel. 
/echo <Song list> -- List of songs to be sung, include Selo's if needed. 
/endm 
} 



| This block of code sorts out the list of songs to be twisted while running. 
/varset nSongs $strlen(@Param6) 
/for EachSong 1 to @nSongs 
/varset Songs(@EachSong) $mid($calc(@EachSong-1),1,@Param6) 
/echo Song @EachSong: $char(gem,@Songs(@EachSong)) 
/next EachSong 
/varset CurSong 1 
/call Event_Timer 
/echo Running a diamond path with center at @RubberY, @RubberX and chant-kiting mobs. 



| The main loop, this iterates unless some AI warning is reached. 
/sendkey down up 
:ChantLoop 

| Face the correct corner of the diamond, given character's current position. 
/if (n $char(x)<@RubberX && n $char(y)>@RubberY) /face fast loc @RubberY,$calc(@RubberX-@Param4) 
/look -90 
/if (n $char(x)<@RubberX && n $char(y)<@RubberY) /face fast loc $calc(@RubberY-@Param3),@RubberX 
/look -90 
/if (n $char(x)>@RubberX && n $char(y)<@RubberY) /face fast loc @RubberY,$calc(@RubberX+@Param5) 
/look -90 
/if (n $char(x)>@RubberX && n $char(y)>@RubberY) /face fast loc $calc(@RubberY+@Param2),@RubberX 
/look -90 

| Sing songs. 
/doevents 
/if $char(casting)==FALSE { 
/varset CurSong @PrevSong 
/call Event_Timer 
} 

| Get a new target if the current one is no good. 
/if n $target(id)==0 /call GetTarget 
/if $target(name)~~"corpse" /call GetTarget 
/if $target(type)=="PC" /call GetTarget 

/goto :ChantLoop 

/return 

Sub Event_Timer(TimerName) 
/delay 2 
/stopsong 
/cast @Songs(@CurSong) 
/varset PrevSong @CurSong 
/varset SongTimer 30 
/varadd CurSong 1 
/if n @CurSong>@nSongs /varset CurSong 1 
/return 

Sub GetTarget 
/if n $searchspawn(npc,radius:200)>0 /target npc radius 200 
/if n $target(level)>66 /press esc 
/if n $target(range)>200 /press esc 
/return 



My attempt at converting it:

Code: Select all

#turbo 
#chat tell 

Sub Main(int Yctr,int Xctr,int North,int South,int East,int West,string DOTs)

| These variables are related to movement and AI control. 
/declare RubberX int outer
/declare RubberY int outer
/varset RubberX ${Xctr} 
/varset RubberY ${Yctr} 

| These variables are related to song-twisting. 
/declare SongTimer timer outer 
/declare Songs[10] int outer 
/declare CurSong int outer 
/declare PrevSong int outer
/declare nSongs int outer 
/declare EachSong int local 



| This block of code checks for proper arguments and echos error or initialization messages. 
/if (!${DOTs}) { 
/echo Usage: /mac Diamond <Y> <X> <North> <South> <East> <West> <Song list> 
/echo <Y> -- Y-coordinate of the center point. 
/echo <X> -- X-coordinate of the center point. 
/echo <North> -- Maximum distance north of the center point to travel. 
/echo <South> -- Maximum distance south of the center point to travel. 
/echo <East> -- Maximum distance east of the center point to travel. 
/echo <West> -- Maximum distance west of the center point to travel. 
/echo <Song list> -- List of songs to be sung, include Selo's if needed. 
/endm 
} 



| This block of code sorts out the list of songs to be twisted while running. 
/varset nSongs ${DOTs.Length}
/for EachSong 1 to ${nSongs} 
    /varset Songs[${EachSong}] ${DOTs.Mid[${EachSong},1]} 
    /echo Song ${EachSong}: ${Me.Gem[${Songs[${EachSong}]}].Name} 
/next EachSong 
/varset CurSong 1 
/call Event_Timer 
/echo Running a diamond path with center at ${RubberY},${RubberX} and chant-kiting mobs. 



| The main loop, this iterates unless some AI warning is reached. 
/keypress forward hold
:ChantLoop 

| Face the correct corner of the diamond, given character's current position. 
/if (${Me.X}<${RubberX} && ${Me.Y}>${RubberY}) /face loc ${RubberY},${Math.Calc[${RubberX}-${East}]}
/if (${Me.X}<${RubberX} && ${Me.Y}<${RubberY}) /face loc ${Math.Calc[${RubberY}-${South}]},${RubberX}
/if (${Me.X}>${RubberX} && ${Me.Y}<${RubberY}) /face loc ${RubberY},${Math.Calc[${RubberX}+${West}]} 
/if (${Me.X}>${RubberX} && ${Me.Y}>${RubberY}) /face loc ${Math.Calc[${RubberY}+${North]},${RubberX}


| Sing songs. 
/doevents 
/if (!${Me.Casting.ID}) /varset CurSong ${PrevSong} /call Event_Timer 

| Get a new target if the current one is no good. 
/if (!${target.id}) /call GetTarget 
/if (!${target.npc}) /call GetTarget 

/goto :ChantLoop 

/return 

Sub Event_Timer(string TimerName)
/delay 2 
/stopsong 
/cast ${Songs[${CurSong}]} 
/varset PrevSong ${CurSong}
/varset SongTimer 30 
/varcalc CurSong ${CurSong}+1 
/if (${CurSong}>${nSongs}) /varset CurSong 1
/return 

Sub GetTarget 
/target npc radius 200
/return 
If anyone could help get the diamond running to work as intended i would really appreciate it. Thank you very much.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Sat Jun 19, 2004 1:22 am

/if (!${Me.Casting.ID}) /varset CurSong ${PrevSong} /call Event_Timer
Can have 1 command without brackets, as for 2, change it to this:

Code: Select all

/if (!${Me.Casting.ID}) {
   /varset CurSong ${PrevSong}
   /call Event_Timer
}
Anyone correct me if I'm wrong.

-------------------------------------------------------
/if (!${target.id}) /call GetTarget
/if (!${target.npc}) /call GetTarget
Nother thing with MQ is case-sensitive variables (as far as I know)

Meaning if the variables you have are correct, they should be:

Code: Select all

/if (!${Target.ID}) /call GetTarget 
/if (!${Target.NPC}) /call GetTarget 
-------------------------------------------------------
Sub GetTarget
/target npc radius 200
/return
Outta the manual:
/target id ${NearestSpawn[1,pc].ID}

Target the nearest PC
and
/target ${Spawn[npc radius 500 trakanon]}



Targets the npc with the name Trakanon only if within a radius of 500
Just for other ideas of searching radius