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

