Added a Interrupt feature, for you to cast a different song while you are twisting, this is good for those charm/mezz situations, where you need to do an add control. It will run the song and then continue with the twisting from where you left off.
The second is a weapon to instrument swap, and a instrument to weapon swap.
As off now, it runs with Event triggers, so you need to /echo a command to make it run. It would be to troublesome to end the macro if it was autoswitching instruments all the time, cause of the movement of your mousepointer. So when you swap don't move your mouse like hell or you won't end up with the right effect .. :)
Another problem was the $item(type) most of the time it would return the right instrument type, but i got a hold on a Bloodstained Flute, and $type(type) would return armor instead. So I added some code to the MQ2parms.cpp for it to work with those kinda instruments as well.. .
This only works with instruments and not items with other slot reqs than primary or secondary.
You need to switch back to weapons before switching from an instrument to another... And you have to remember not to move your Equipment around, as the script starts by finding your current isntruments you have in your inv.
The instrument it will swap to, is the instrument the song your are curently casting is modified by.. So if it's singing you won't swap..
So to intterupt use
/echo Sing this song - <songname>
from a action button, and it will sing the song if you have it memed.
I used Songname instead of Gem #, to prevent from casting the wrong spell in the heat of the battle, if you had memed the wrong song.
To swap your weapons with instrument use
/echo Switch to instrument
To swap your weapons back use
/echo Switch to Weapons
OK Now for the code..
----------------------------------------------------------------------------------
EDIT:
I've updated the code after i've been using it in live action for some time..
I was trying to make yet another upgrade to it, so it would be more clean to look at, but had some problems with subs, so it is as is for now..
Now you can swap between Instruments as well, no need to swap back to weapons, just hit the key when you are casting and you will switch to the instrument if you had it in your bag when you started the macro.
Again, do comment on it, and say if you might need something else.
I've done the things I found i needed from the Twist macro, there might be things later on i think is worth a shot, but as of now, you are welcome with any input.
----------------------------------------------------------------------------------
Code: Select all
| Twist2.mac Flexible bard song twister using timers by BrainDozer.
| Updated by Drax.
| Assist feature added by wilso132.
| Interrupt Song feature added by ztilleto - Updated 28/01-2004 00:28
|
| Syntax: /macro Twist2.mac [block 1] [block 2] [block 3]
|
| Parameter block 1 indicates non-combat songs
| Parameter block 2 indicates combat songs
| Parameter block 3 indicates target to assist
|
| Choose any combination of songs in any sequence to twist for each mode.
|
| Example: /macro Twist2.mac 256 1234234 wilso132
|
| This would repeat songs 2, 5 and 6 durring non-combat and songs 1, 2, 3
| and 4 in the above sequence while in combat. In this instance, song 1
| is only twisted 1 for 7, which comes in handy for long duration songs
| like amplification.
|
| Other Examples: /macro Twist2.mac 0 123 | Twists on attack only
| /macro Twist2.mac 12345 0 | non-attack twisting only
| /macro Twist2.mac 12345 | same as above
| /macro Twist2.mac 9804 11 | twists 84 and 1
| /macro Twist2.mac 9804 11 wilso132 | same as above but assists “wilso132”
|
| The Interrupt song, is based on an string filter.
| I use a action button ingame with the following perform
| /echo Sing this song - Solon's Song of the Sirens
| So when i use the action, it will echo this to the MQ2 window.
| And it will cast the Solon's Song of the Sirens. If i've got it memed
|
| The swap instrument is the same as Interrupt, you
| /echo Switch to instrument
| To switch to the instrument for the current song you are trying to cast
| /echo Switch to Weapons
| To switch back to your starting weapons.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#turbo 10
#event MissedNote "You miss a note, bringing your song to a close!"
||||||||||||||||||||||||||||||||Interrupt|||||||||||||||||||||||||||||||||||||
#event Interrupt "Sing this song - "
||||||||||||||||||||||||||||||||Swap Instrument|||||||||||||||||||||||||||||||||
#event SwapInstrument "Switch to instrument"
#event SwapBack "Switch to Weapons"
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| To make it easier to costumize for own use.
|| Holderbag is location of your bag you want to store
|| your deafault items for Primary and Secondary
|| remember to have some space for it..
#define HolderBag "2"
#define PrimaryBagClick "left pack HolderBag 8"
#define SecondaryBagClick "left pack HolderBag 9"
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub Main
/zapvars
/declare CSong global | keeps track of current song number 1-max
/declare CSongf global | break and play song toggle (break=0 play=1)
/declare attack global | debug: @combat glitch work-around
/declare CSongt timer | break and play song timer
/declare attackct timer | debug: @combat glitch work-around check timer
/declare v90 global
/declare v91 global
/declare l0 global
/declare l1 global
/declare l2 global
/declare l3 global
/declare a array2
/declare person_to_assist global
/declare need_to_assist global
||||||||||||||||||||||||||||interrupt variables|||||||||||||||||||||||||||||||||
/declare bInterrupt global | Tells if there is a Interrupt spell in progress.
/declare sSpellName global
||||||||||||||||||||||||||||Swap Instrument vars|||||||||||||||||||||||||||||||
/declare aItem array2
/declare aLocation array2
/declare x0 global
/declare y0 global
/declare z0 global
/declare iItemIndex global
/declare sInstrumentType global
/declare iCurrentInstrument global |Holds array ID of current instrument
/declare sPrimaryItem global
/declare sSecondaryItem global
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/stopsong
/if @Param2~~"Param2" {
/varset need_to_assist 0
/echo Not assisting anyone, just twisting.
} else {
/varset person_to_assist @Param2
/echo You will now be assisting @person_to_assist
/varset need_to_assist 1
}
/call initVars @Param0 @Param1
:Mainloop
/if @need_to_assist==1 /if $target(type)=="NPC" /assist @person_to_assist
/if n $target(hp,pct)<=95 /if n $target(distance)<100 {/attack on}
} else {
/attack off
}
/if @attackct==0 /if $combat==TRUE /if @attack==0 /call AttackOn
/if @attackct==0 /if $combat==FALSE /if @attack==1 /call AttackOff
/if @attackct==0 /varset attackct 10 | adjustable attack check delay
| Debug: work-around
/if n @v9@attack!=-1 /if $char(state)==STAND /call TwistSong @attack
/doevents
/goto :Mainloop
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub TwistSong
/if @CSong>@v9@Param0 /varset CSong 0 | Restart twist when end of list
/if (@CSongf==0 && @CSongt==0) /call TS2 @Param0 | Start next song in list
/if (@CSongf==1 && @CSongt==0) /call TS3 | Stop song and advance index
/return | Debug: conditionals wern't playing nice with brackets
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub TS2
/if n @bInterrupt==1 {
/cast "@sSpellName"
} else {
/cast @a(@Param0,@CSong)
}
/varset CSongf 1
/varset CSongt 33 | adjustable play delay
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub TS3
/stopsong
/if n @bInterrupt==1 {
/echo Song has been played, Twisting from where we left.
/varset bInterrupt 0
} else {
/varset CSong $int($calc(@CSong+1)) | Debug: Force integer
}
/varset CSongf 0
/varset CSongt 1 | adjustable break delay
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub initVars
/if @Param1=="" /varset Param1 "0"
/varset v90 0 | v90,v91 max song index lengths
/varset v91 0 | l0 combat mode index
/for l0 0 to 1 | l1 parameter index
/for l1 0 to $int($calc($strlen(@Param@l0)-1)) | l2 hold
/varset l2 $mid(@l1,1,@Param@l0)
/varset l3 @v9@l0 | Debug: array didn't like the fancy stuff
/if (@l2>=1 && @l2<=8) /varset a(@l0,@l3) @l2 | Debug: Bracket trouble
/if (@l2>=1 && @l2<=8) /varset v9@l0 $int($calc(@v9@l0+1))
/next l1 | Debug: it thinks it's a float-forcing
/next l0
/varset v90 $int($calc(@v90-1)) | over increment fix
/varset v91 $int($calc(@v91-1)) |
/varset CSong 0
/varset CSongt 0
/varset CSongf 0
/if $combat==TRUE /varset attack 1 | debug: inital combat values
/if $combat==FALSE /varset attack 0 |
||||||||||||||||||||||||||||||Interupt||||||||||||||||||||||||||||||||||||||||||
/varset bInterrupt 0
/varset sSpellName ""
||||||||||||||||||||||||||||||Swapinstrument||||||||||||||||||||||||||||||||||||
|| This varset makes the instrument dynamic on startup
|| But need to save location on instruments so dont move em around after start
/varset iItemIndex 0
/for x0 0 to 7
/if $pack(@x0,empty)==FALSE {
/for y0 0 to 10 $pack($x0,slots)
/if "$right(10,"($item(@x0,@y0,instrumenttype))")"=="instrument" {
/varset aItem(@iItemIndex,0) "$item(@x0,@y0,name)"
/varset aItem(@iItemIndex,1) "$item(@x0,@y0,instrumenttype)"
||| To store the location where you have the instruments located.
/varset aLocation(@iItemIndex,0) @x0
/varset aLocation(@iItemIndex,1) @y0
/varadd iItemIndex 1
}
/next y0
} else /if $pack(@x0,empty)==NULL {
/if "$right(10,"($item(inv,@x0,instrumenttype))")"=="instrument" {
/varset aItem(@iItemIndex,0) "$item(inv,@x0,name)"
/varset aItem(@iItemIndex,1) "$item(inv,@x0,instrumenttype)"
||| To store the location where you have the instruments located.
/varset aLocation(@iItemIndex,0) @x0
/varset aLocation(@iItemIndex,1) @y0
/varadd iItemIndex 1
}
}
/next x0
/varset sPrimaryItem $equip(primary,name)
/varset sSecondaryItem $equip(secondary,name)
/if "@sPrimaryItem"=="$equip(primary,name)" /varset sPrimaryItem NULL
/if "@sSecondaryItem"=="$equip(secondary,name)" /varset sSecondaryItem NULL
| /echo iItemIndex - @iItemIndex
/for z0 0 to $calc(@iItemIndex-1)
/echo @z0 - Instruments Found : "@aItem(@z0,0)" - "@aItem(@z0,1)"
/next z0
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub AttackOn
/stopsong
/varset attack 1
/varset CSong 0 | reset sequence
/varset CSongt 0 | attack mode twist start delay
/varset CSongf 0 | force play mode
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub AttackOff
/stopsong
/varset attack 0
/varset CSong 0 | reset sequence
/varset CSongt 0 | attack off mode twist start delay
/varset CSongf 0 | force play mode
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub Event_MissedNote
/varset CSongt 0 | missed note try again delay
/varset CSongf 0 | switch back to play mode
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| IF you rewrite the string filter "Sing this song - " for Interrupt
|| You need to alter the -23 to fit with the length of the string plus 6 "[MQ2] "
Sub Event_Interrupt(Type)
/stopsong
/varset sSpellName "$right($int($calc($strlen("@Type")-23)),"@Type")"
/varset bInterrupt 1
/varset CSongt 0
/varset CSongf 0
/return
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sub Event_SwapInstrument
/if "$char(casting)"=="TRUE" { | Only switch if you are casting
/varset sInstrumentType "$spell($char(castingspellid),skill)"
} else /return
/if "@sInstrumentType"=="Sing" /return
|| Do you have the instrument Equiped already.. ??
/if "$equip(primary,instrumenttype)"s"=="@sInstrumentType" /return
/if "$equip(secondary,instrumenttype)"s"=="@sInstrumentType" /return
|| Do i have something in my primary
/if "$equip(primary)"=="TRUE" {
|| Is it an Instrument put it back from where it came
/if $invpanel==FALSE /windowstate inventory open
/if "$right(10,"($equip(primary,instrumenttype))")"=="instrument" {
/if "$pack(@aLocation(@iCurrentInstrument,0),open)"=="true" {
/goto :primaryswap
} else { || The bag is closed.
/click right inv @aLocation(@iCurrentInstrument,0)
}
:primaryswap
/click left primary
/if "@aLocation"=="inv" {
/click left inv @aLocation(@iCurrentInstrument,1)
} else {
/click left pack @aLocation(@iCurrentInstrument,0) @aLocation(@iCurrentInstrument,1)
}
} else { || Then it must be the starting item in primary
/if $pack(HolderBag,open)==FALSE {
/if $invpanel==FALSE /windowstate inventory open
/click right inv HolderBag
}
/click left primary
/click PrimaryBagClick
}
}
|| Do i have something in my secondary
/if "$equip(secondary)"=="TRUE" {
|| Is it an Instrument put it back from where it came
/if $invpanel==FALSE /windowstate inventory open
/if "$right(10,"($equip(secondary,instrumenttype))")"=="instrument" {
/if "$pack(@aLocation(@iCurrentInstrument,0),open)"=="true" {
/goto :secondaryswap
} else { || The bag is closed.
/click right inv @aLocation(@iCurrentInstrument,0)
}
:secondaryswap
/click left secondary
/if "@aLocation"=="inv" {
/click left inv @aLocation(@iCurrentInstrument,1)
} else {
/click left pack @aLocation(@iCurrentInstrument,0) @aLocation(@iCurrentInstrument,1)
}
} else { || Then it must be the starting item in primary
/if $pack(HolderBag,open)==FALSE {
/if $invpanel==FALSE /windowstate inventory open
/click right inv HolderBag
}
/click left secondary
/click SecondaryBagClick
}
}
/for x0 0 to $calc(@iItemIndex-1) || Run through the list of instruments to find one to use.
/if "@aItem(@x0,1)s"=="@sInstrumentType" {
/varset iCurrentInstrument @x0
|| Opens backpack with instrument in it..
/if $invpanel==FALSE /windowstate inventory open
/if $pack(@aLocation(@x0,0),open)==FALSE {
/click right inv @aLocation(@x0,0)
}
/click left pack @aLocation(@x0,0) @aLocation(@x0,1)
|| Couldn't find what slot this item is used in, so just dobbelt checkin.
/click left primary
/click left secondary
/cleanup
/return
}
/next x0
/return
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| This is the swapback your primary items back event
||
Sub Event_SwapBack
/if $invpanel==FALSE /windowstate inventory open
/if "$equip(primary)"=="TRUE" {
/click left primary
} else /click left secondary
/if $pack(HolderBag,open)==FALSE {
/if $invpanel==FALSE /windowstate inventory open
/click right inv HolderBag
}
|| Only if there was an item on the cursor
|| should it be placed in the bag from where it came
/if "$cursor()"=="TRUE" /click left pack @aLocation(@iCurrentInstrument,0) @aLocation(@iCurrentInstrument,1)
/click PrimaryBagClick
/click left primary
/click SecondaryBagClick
/click left secondary
/cleanup
/return
Code: Select all
else if (!strncmp("instrumenttype)",szVar+Offset,15)) {
i+=Offset+15;
strcat(szOutput,szItemTypes[pItem->Item->InstrumentType]);
// $item(type)
}Code: Select all
else if (!strncmp("instrumenttype)",szVar+Offset,15)) {
i+=Offset+15;
strcat(szOutput,szItemTypes[pItem->Item->InstrumentType]);
// $equip(type)
}Comments and so forth is most welcome..
It's my first attempt to write some Macro code for MQ2, but i found that it was a hazzle not to be able to do the mezzin and charming without stopping the macro from time to time..
