Twist.iss

Moderator: MacroQuest Developers

bardomatic
a ghoul
a ghoul
Posts: 131
Joined: Thu Apr 29, 2004 12:09 am

Twist.iss

Post by bardomatic » Sun May 21, 2006 12:41 am

Code: Select all

;***************************************************************************
;twist.iss
;
;optional files:
;  isxeqmoveit.dll
;
;currently isxeqmoveit is still in development and can cause crashes if misused
;it adds the functionality of being able to exchange items without opening packs
;
;to start:
;  extension isxeqmoveit  (optional)
;  run twist
;
;commands:
;  /twist <songlist> (sets songlist and starts singing)
;  /twist -set <songlist> (sets the songlist but does not sing yet)
;  /twist -toggle <songlist> (if twisting it stops, if not it starts)
;  /twist -start (restarts a paused twist)
;  /twist -pause|-stop (pauses twist)
;  /twist -now|-once <songlist> (sings once and resumes twist or stops)
;  /twist -sing <songlist>  (sings once but does not stopsong at end)
;  /twist -quit
;
;example songlists:
;  /twist gem# "effect" "item"
;  /twist 3 4 5 6
;  /twist 3 4 5 "composers greaves" "skeleton"
;
;
;note: I am working on long duration recast timers, they are not active yet
;***************************************************************************
objectdef twiststuff
{
	variable string Cmd
	variable string SongType
	variable string Name
	variable int Recast

	method Initialize(... Params)
	{
		Cmd:Set[${Params[1]}]
		SongType:Set[${Params[2]}]
		Name:Set[${Params[3]}]
		Recast:Set[${Params[4]}]
	}
}


	variable bool Twist_KeepRunning=1
	variable string Bardomatic_FileName="Bardomatic_${Me.CleanName}.xml"

	variable(global) queue:string Twist_Cmd
	variable(global) int Twist_Twisting=2
	variable(global) string Twist_Songs[16]
	variable bool Twist_Once=0
	variable queue:twiststuff Twist_Queue
	variable int Twist_MasterLagDelay=400
	variable int Twist_MasterTimer=34
	variable int Twist_StopSongDelay=5
	variable int Twist_Timer=0
	variable int Twist_Restart=0
 	variable string Twist_FromSlot
 	variable string Twist_CastSlot
	variable bool Twist_PutItemsBack=0

	variable queue:int Exchange_Packopen

function main()
{
	call init

	do
	{
		call processtwist
		if ${Twist_Cmd.Size}
		{
			if ${Twist_Cmd.Peek.Equal[-quit]}
				Twist_KeepRunning:Set[0]
			else
				call dotwist
			Twist_Cmd:Clear
		}
		if ${QueuedCommands}
			ExecuteQueued
		else
			WaitFrame
	}
	while ${Twist_KeepRunning}


}

function atexit()
{
	deleteatom twist

	deletevariable Twist_Cmd
	deletevariable Twist_Once
	deletevariable Twist_Songs
	deletevariable Twist_Queue
	deletevariable Twist_Twisting


	EQExecute /stopsong
	echo [Bard-o-Matic] Twist Disengaged
}

function init()
{
	AddTrigger twistfailedresume "You must first select a target for this spell!"
	AddTrigger twistfailedresume "You haven't recovered yet..."
	AddTrigger twistfailedresume "Spell recast time not yet met."
	AddTrigger twistfailedretry "Your spell is interrupted."
;	AddTrigger twistfailedretry "You miss a note, bringing your song to a close!"
	AddTrigger twistfailedretry "You can't cast spells while stunned!"
	AddTrigger twistfailremove "Format: /cast 1 - 9"

	echo [Bard-o-Matic] Twist Engaged
}


atom(globalkeep) twist(... param)
{
	variable int i=1
	
	if ${param.Size}==0
		return
	Twist_Cmd:Clear

	if !${param[1].Mid[1,1].Equal[-]}
		Twist_Cmd:Queue["-set"]

	while ${i}<=${param.Size}
	{
		Twist_Cmd:Queue[${param[${i}]}]
		i:Inc
	}

}


;***************************************************************
;
;  Twist functions
;
;***************************************************************


function processtwist()
{
	variable int i
	if !${MacroQuest.GameState.Equal[INGAME]}
		Twist_Twisting:Set[2]

	if ${Twist_Twisting}==1 && !${Me.Stunned} && !${Me.Sitting} && !${Me.Ducking} && !${Window[lootwnd].Open} && ${MacroQuest.GameState.Equal[INGAME]} && ${Twist_Queue.Size}>0
	{
		if (!${Me.Casting(exists)} && ${Twist_Timer}>0) && ${Twist_Queue.Peek.SongType.Equal[spellgem]}
		{
			Twist_Restart:Set[1]
		}
		if ${Twist_Timer}<${MacroQuest.Running} || ${Twist_Restart}
		{
			Twist_Timer:Set[0]
		}
		if ${Twist_Timer}==0
		{
			if ${Twist_PutItemsBack}
			{
				NoModKey EQItemNotify ${Twist_CastSlot} leftmouseup
				Wait 1
				if ${Extension[isxeqmoveit](exists)}==TRUE
					moveitem 30 ${Twist_FromSlot}
				else
					NoModKey EQItemNotify ${Twist_FromSlot} leftmouseup
				Wait 1
				Twist_PutItemsBack:Set[0]
				call closepack
			}
			if ${Twist_Restart}
			{
				Twist_Restart:Dec
			}
			else
			{
				if ${Twist_Queue.Peek.Cmd.Equal[-now]} || ${Twist_Queue.Peek.Cmd.Equal[-once]} || ${Twist_Queue.Peek.Cmd.Equal[-sing]}
				{
					if ${Twist_Queue.Peek.Cmd.Equal[-once]} && ${Twist_Queue.Size}==1
						EQExecute /stopsong
					Twist_Queue:Dequeue
					call setsonglist
				}
				else
				{
					Twist_Queue:Queue["${Twist_Queue.Peek.Cmd}","${Twist_Queue.Peek.SongType}","${Twist_Queue.Peek.Name}","${Twist_Queue.Peek.Recast}"]
					Twist_Queue:Dequeue
				}
			}
			if ${Twist_Queue.Peek.Name.Find[aura of]}
			{
				i:Set[1]
				do
				{
					;echo ${i} = ${Me.Song[${i}]}~~${Twist_Queue.Peek.Name}
					if ${Me.Song[${i}].Name.Find[${Twist_Queue.Peek.Name}]}
						break
				}
				while ${i:Inc}<=12
				if ${i}<13
				{
					;echo skipped aura
					if ${Twist_Queue.Peek.Cmd.Equal[-now]} || ${Twist_Queue.Peek.Cmd.Equal[-once]} || ${Twist_Queue.Peek.Cmd.Equal[-sing]}
					{
						Twist_Queue:Dequeue
					}
					else
					{
						Twist_Queue:Queue["${Twist_Queue.Peek.Cmd}","${Twist_Queue.Peek.SongType}","${Twist_Queue.Peek.Name}","${Twist_Queue.Peek.Recast}"]
						Twist_Queue:Dequeue
					}
					;call setsonglist
				}
			}
			if ${Twist_Queue.Size}==0
			{
				Twist_Twisting:Set[2]
			}
			if ${Twist_Queue.Peek.Cmd.Equal[-sing]} && ${Me.Casting(exists)} && ${Twist_Queue.Size}==1
			{
				return
			}				
			if ${Twist_Twisting}==1
			{
				EQExecute /stopsong
				wait 100 ${Twist_StopSongDelay} !${Me.Casting(exists)}
			}
			switch ${Twist_Queue.Peek.SongType}
			{
				case spellgem
					EQExecute /cast ${Me.Gem[${Twist_Queue.Peek.Name}]}
					Twist_Timer:Set[${Math.Calc[${Spell[${Twist_Queue.Peek.Name}].CastTime}*1000+${MacroQuest.Running}+${Twist_MasterLagDelay}].Int}]
					break
				case equipeditem
					NoModKey EQItemNotify ${FindItem[${Twist_Queue.Peek.Name}].InvSlot} rightmouseup
					Twist_Timer:Set[${Math.Calc[${FindItem[${Twist_Queue.Peek.Name}].CastTime}*1000+${MacroQuest.Running}+${Twist_MasterLagDelay}].Int}]
					break
				case packeditem
					Twist_CastSlot:Set["none"]
					if ${FindItem[${Twist_Queue.Peek.Name}].EffectType.Find["Click Inventory"]}
						Twist_CastSlot:Set[22]
					else
						if ${FindItem[${Twist_Queue.Peek.Name}].WornSlots}>0
							Twist_CastSlot:Set[${FindItem[${Twist_Queue.Peek.Name}].WornSlot[1]}]
					if !${Twist_CastSlot.Equal["none"]}
					{
					 	Twist_FromSlot:Set[${FindItem[${Twist_Queue.Peek.Name}].InvSlot}]
						if ${Extension[isxeqmoveit](exists)}==FALSE
							call openpack ${Math.Calc[((${Twist_FromSlot}-251)/10)+22].Int}
						Wait 1
						if ${Extension[isxeqmoveit](exists)}==TRUE
							moveitem ${Twist_FromSlot} 30
						else
							NoModKey EQItemNotify ${Twist_FromSlot} leftmouseup
						Wait 1
						NoModKey EQItemNotify ${Twist_CastSlot} leftmouseup
						Wait 1
						NoModKey EQItemNotify ${Twist_CastSlot} rightmouseup
						wait 5
						Twist_Timer:Set[${Math.Calc[${InvSlot[${Twist_CastSlot}].Item.CastTime}*1000+${MacroQuest.Running}+${Twist_MasterLagDelay}].Int}]
						Twist_PutItemsBack:Set[1]
					}
					break
			}
		}
	}
	else
	{
		if ${Twist_PutItemsBack}
		{
			NoModKey EQItemNotify ${Twist_CastSlot} leftmouseup
			Wait 1
			if ${Extension[isxeqmoveit](exists)}==TRUE
				moveitem 30 ${Twist_FromSlot}
			else
				NoModKey EQItemNotify ${Twist_FromSlot} leftmouseup
			Wait 1
			Twist_PutItemsBack:Set[0]
			call closepack
		}
	}
}

function dotwist()
{
	variable int i=1
	variable int j=1
	variable int recast
	variable string Cmd=${Twist_Cmd.Peek}
	variable string temptype
	variable string tempname

	Twist_Cmd:Dequeue


	if ${Cmd.Equal[-quit]}
	{
		Bardomatic_KeepRunning:Set[0]
	}
	if ${Cmd.Equal[-set]} || ${Cmd.Equal[-toggle]}
	{
		i:Set[1]
		Twist_Queue:Clear
		while ${Twist_Cmd.Size}
		{
;			echo song - ${Twist_Cmd.Peek}
			call getname "${Twist_Cmd.Peek}"
			if ${Return.Length}>0
			{
;				echo is - ${Cmd}|${Return}
				recast:Set[${SettingXML[${bafilename}].Set["twist"].GetString["${Return.Token[2,|]}",0]}]
				SettingXML[${bafilename}].Set["twist"]:Set["${Return.Token[2,|]}",${recast}]
				SettingXML[${Bardomatic_FileName}]:Save
				temptype:Set[${Return.Token[1,|]}]
				tempname:Set[${Return.Token[2,|]}]
				Twist_Queue:Queue["${Cmd}","${temptype}","${tempname}","${recast}"]
;	echo Twist_Queue = ${Twist_Queue.Peek.Cmd},${Twist_Queue.Peek.SongType},${Twist_Queue.Peek.Name},${Twist_Queue.Peek.Recast}
			}
			Twist_Cmd:Dequeue
		}
		call setsonglist
		Twist_Once:Set[0]
	}
	if ${Cmd.Equal[-set]}
	{
		Twist_Twisting:Set[1]
		Twist_Restart:Set[1]
	}
	if ${Cmd.Equal[-start]}
	{
		Twist_Twisting:Set[1]
		Twist_Timer:Set[0]
		Twist_Restart:Set[1]
		Twist_Once:Set[0]
	}
	if ${Cmd.Equal[-toggle]}
	{
		if ${Twist_Twisting}==1
		{
			Twist_Twisting:Set[2]
			Twist_Timer:Set[0]
			EQExecute /stopsong
		}
		else
		{
			Twist_Twisting:Set[1]
			Twist_Restart:Set[1]
		}
	}
	if ${Cmd.Equal[-pause]} || ${Cmd.Equal[-stop]}
	{
		Twist_Twisting:Set[2]
		EQExecute /stopsong
	}
	if ${Cmd.Equal[-now]} || ${Cmd.Equal[-once]} || ${Cmd.Equal[-sing]}
	{
		if ${Twist_Twisting}==2
			Twist_Queue:Clear
		j:Set[${Twist_Queue.Size}]
		i:Set[1]
		while ${Twist_Cmd.Size}
		{
			call getname "${Twist_Cmd.Peek}"
			if ${Return.Length}>0
			{
				recast:Set[${SettingXML[${bafilename}].Set["twist"].GetString["${Return.Token[2,|]}",0]}]
				SettingXML[${bafilename}].Set["twist"]:Set["${Return.Token[2,|]}",${recast}]
				SettingXML[${Bardomatic_FileName}]:Save
				temptype:Set[${Return.Token[1,|]}]
				tempname:Set[${Return.Token[2,|]}]
				Twist_Queue:Queue["${Cmd}","${temptype}","${tempname}","${recast}"]
			}
			Twist_Cmd:Dequeue
		}
		i:Set[1]
		while ${i}<=${j}
		{
			if ${Twist_Queue.Peek.Cmd.Find[-once]} || ${Twist_Queue.Peek.Cmd.Find[-now]} || ${Twist_Queue.Peek.Cmd.Find[-sing]}
			{
				Twist_Queue:Dequeue
			}
			else
			{
				Twist_Queue:Queue["${Twist_Queue.Peek.Cmd}","${Twist_Queue.Peek.SongType}","${Twist_Queue.Peek.Name}","${Twist_Queue.Peek.Recast}"]
				Twist_Queue:Dequeue
			}
			i:Inc
		}
		if ${Twist_Twisting}==2
			Twist_Once:Set[1]
		else
			Twist_Once:Set[0]
		Twist_Twisting:Set[1]
		Twist_Timer:Set[0]
		Twist_Restart:Set[1]
		call setsonglist
		Twist_Once:Set[0]
	}
	if ${Cmd.Equal[-sing]}
	{
	;	Twist_Twisting:Set[3]
	}
	if ${Cmd.Equal[-list]}
	{
		echo [Bard-o-Matic] Twist::Song List
		i:Set[1]
		while ${i}<=${Twist_Queue.Size}
		{
			echo \ \ \ ${i} == ${Twist_Queue.Peek}
			Twist_Queue:Queue["${Twist_Queue.Peek.Cmd}","${Twist_Queue.Peek.SongType}","${Twist_Queue.Peek.Name}","${Twist_Queue.Peek.Recast}"]
			Twist_Queue:Dequeue
			i:Inc
		}
		call setsonglist
	}
}

function getname(string arg)
{
	variable string spelltype
	variable string spellitem
	variable string spellname
	variable int i=0
	variable bool itemfound=0

	if ${arg.Equal[${Int[${arg}]}]}
	{
		if ${Me.Gem[${arg}](exists)}
		{
;;			echo Found Gem from gemnumber ${Me.Gem[${arg}]}
			spelltype:Set[spellgem]
			spellitem:Set[${Me.Gem[${arg}]}]
		}
		else
		{
;;			echo Song not found by number
			return ""
		}
	}
	else
	{
		do
		{
			if ${Me.Gem[${i}].Name.Find[${arg}]}
			{
;;				echo Found Gem from songname ${Me.Gem[${i}].Name}
				spelltype:Set[spellgem]
				spellitem:Set[${Me.Gem[${i}].Name}]
				break
			}
		}
		while ${i:Inc}<=9
		if ${spelltype.Length}==0
		{
			if ${InvSlot[${arg}](exists)}
			{
;;				echo Found Item from slotname ${InvSlot[${arg}].Item.Name}
				spelltype:Set[equipeditem]
				spellitem:Set[${InvSlot[${arg}].Item.Name}]
			}
			else
			{
				if ${FindItem[${arg}](exists)}
				{
;;					echo Found Item from itemname ${FindItem[${arg}].Name}
					if ${FindItem[${arg}].InvSlot}<30
					{
						spelltype:Set[equipeditem]
					}
					else
					{
						spelltype:Set[packeditem]
					}
					spellitem:Set[${FindItem[${arg}].Name}]
				}
				else
				{
					i:Set[0]
					do
					{
						if ${InvSlot[${i}].Item.Spell.Name.Find[${arg}]}
						{
;;							echo Found Item Equipped from effectname ${InvSlot[${i}].Item.Name}
							spelltype:Set[equipeditem]
							spellitem:Set[${InvSlot[${i}].Item.Name}]
							itemfound:Set[1]
							break
						}
					}
					while ${i:Inc}<22
					i:Set[251]
					if !${itemfound}
					{
						do
						{
								if ${InvSlot[${i}].Item.Spell.Name.Find[${arg}]}
							{
;;								echo Found Item in packs from effectname == ${InvSlot[${i}].Item.Name}
								spelltype:Set[packeditem]
								spellitem:Set[${InvSlot[${i}].Item.Name}]
								itemfound:Set[1]
								break
							}
						}
						while ${i:Inc}<330
					}
					if !${itemfound}
					{
;;						echo Nothing found for ${arg}
						return ""
					}
				}
			}
		}
	}
	if ${spelltype.Length}>0
	{
;;		echo I found ${spelltype} :: ${spellitem}
		return "${spelltype}|${spellitem}"
	}
	else
	{
;;		echo Nothing found for "${arg}"
		return ""
	}
}

function setsonglist()
{
	variable int i=1
	while ${i}<=${Twist_Queue.Size}
	{
;		echo \ \ \ ${i} == ${Twist_Queue.Peek}
		if ${i}<11
			Twist_Songs[${i}]:Set[${Twist_Queue.Peek.Name}]
		Twist_Queue:Queue["${Twist_Queue.Peek.Cmd}","${Twist_Queue.Peek.SongType}","${Twist_Queue.Peek.Name}","${Twist_Queue.Peek.Recast}"]
		Twist_Queue:Dequeue
		i:Inc
	}
	while ${i}<11
	{
		Twist_Songs[${i}]:Set[""]
		i:Inc
	}
}

	
function twistfailedresume()
{
	eqecho ${debugcounter}::${Math.Calc[${MacroQuest.Running}/1000]}::resume
	Twist_Timer:Set[0]
}

function twistfailedretry()
{
	Twist_Timer:Set[0]
	Twist_Restart:Set[1]
}

function twistfailremove()
{
	Twist_Queue:Dequeue
	Twist_Timer:Set[0]
	Twist_Restart:Set[1]
}

;***************************************************************
;
;  Exchange functions
;
;***************************************************************

function dounequip(fromslotpassed, direction=-1)
{
	variable int packcount=29
	variable int bagslot=1
	variable int putslot=-1
	variable bool slotfound=0
	variable string validslots="charmleftearheadfacerightearneckshoulderarmsbackleftwristrightwristrangedhandsmainhandoffhandleftfingerrightfingerchestlegsfeetwaistammopack1pack2pack3pack4pack5pack6pack7pack8"
	variable bool validate=0
	variable string fromslot
	variable int i=1
	variable bool isnum=0

	
	
	isnum:Set[${fromslotpassed.Equal[${Int[${fromslotpassed}]}]}]

	fromslot:Set[${fromslotpassed}]

	if ${validslots.Find[${fromslot}]} && ${fromslot.Length}>3
	{
		validate:Set[1]
	}
	
	if ${isnum}
		if ${fromslot}<21
		{
			validate:Set[1]
		}

	if ${validate}==0
	{
		if ${FindItem[${fromslot}].InvSlot}<22
		{
			fromslot:Set[${FindItem[${fromslot}].InvSlot}]
			validate:Set[1]
		}
	}
	if !${InvSlot[${fromslot}].Item.Name(exists)} || ${validate}==0
	{
		if ${Bandolier_Cmd.Size}==0
			echo [Bard-o-Matic] Unequip::Nothing to unequip!
		return
	}
	if ${putslot}==-1
	{
		call findopenbagslot "${InvSlot[${fromslot}].Item.Name}" ${direction}
		if ${Return}>0
		{
			putslot:Set[${Return}]
			slotfound:Set[1]
		}
	}
	if ${slotfound}
	{
		if ${Bandolier_Cmd.Size}==0
			echo [Bard-o-Matic] Exchange::Unequipping ${InvSlot[${fromslot}].Item.Name}
		if ${Extension[isxeqmoveit](exists)}==FALSE
			call openpack ${packcount}
		if ${Extension[isxeqmoveit](exists)}==FALSE
			call openpack ${Math.Calc[((${putslot}-251)/10)+22].Int}
		variable string tempstring
		tempstring:Set[${InvSlot[${fromslot}]}]
		fromslot:Set[${tempstring}]
		call swapit ${fromslot} ${putslot}
		if ${Extension[isxeqmoveit](exists)}==FALSE && ${Bandolier_Active}==0
			call closepack ${packcount}
	}
	else
	{
		echo [Bard-o-Matic] Unequip::No bag slots available!
	}

}

function doexchange(string item, string passedtoslot, direction=-1)
{
	variable int inventoryslot
	variable string pack
	variable int packslot
	variable int packnumber=0
	variable string toslot=${InvSlot[${passedtoslot}]}

;	echo [Exchange] ${item},${passedtoslot},${toslot}

;find item and set pack and packslot or inventoryslot
	inventoryslot:Set[${FindItem[${item}].InvSlot}]
	if !(${inventoryslot}>0)
	{
		return
	}
	if ${inventoryslot}>250 && ${inventoryslot}<331
	{
		packnumber:Set[${Math.Calc[((${inventoryslot}-251)/10)+1].Int}]
		packslot:Set[${Math.Calc[(${inventoryslot}-251)%10].Int}]
	}
	else
	{	
		if ${Bandolier_Cmd.Size}==0
			echo [Bard-o-Matic] Exchange::Item already equipped!
		return
	}

;verify toslot is set
	if ${toslot.Equal[""]}
		if ${FindItem[${item}].WornSlots}>0
			toslot:Set[${FindItem[${item}].WornSlot[1].Name}]
		else
		{
			echo [Bard-o-Matic] Exchange::No valid destination!
			return
		}

	variable int packcount=29
	variable int bagslot=1
	variable int putslot=-1
	variable bool slotfound=0


	if ${Extension[isxeqmoveit](exists)}==FALSE
		call openpack ${Math.Calc[${packnumber}+21]}


	if ${InvSlot[${Math.Calc[${packnumber}+21]}].Item.SizeCapacity}>=${InvSlot[${toslot}].Item.Size}
	{
		putslot:Set[${inventoryslot}]
		slotfound:Set[1]
	}
	if ${putslot}==-1
	{
		do
		{
			if !${InvSlot[${packcount}].Item.Name(exists)}
			{
				putslot:Set[${packcount}]
				slotfound:Set[1]
				break
			}
			
		}
		while ${packcount:Dec}>21
	}
	if ${putslot}==-1
	{
		call findopenbagslot "${InvSlot[${toslot}].Item.Name}" ${direction}
		if ${Return}>0
		{
			putslot:Set[${Return}]
			slotfound:Set[1]
		}
	}
	if ${slotfound}
	{
		if ${Bandolier_Cmd.Size}==0
			echo [Bard-o-Matic] Exchange::Equipping ${InvSlot[${inventoryslot}].Item.Name} to ${InvSlot[${toslot}].Name}
		variable string tempstring
		tempstring:Set[${InvSlot[${inventoryslot}]}]
		inventoryslot:Set[${tempstring}]
		tempstring:Set[${InvSlot["${fromslot}"]}]
		fromslot:Set[${tempstring}]
		call swapit ${inventoryslot} ${toslot} ${putslot}
	}
	else
	{
		if ${Bandolier_Cmd.Size}==0
			echo [Bard-o-Matic] Exchange::No bag slots available!
	}
	if ${Extension[isxeqmoveit](exists)}==FALSE && ${Bandolier_Active}==0
		call closepack
}

function findopenbagslot(searchitem, direction=-1)
{
	variable int packcount
	variable int finalcount
	variable int putslot=-1
	variable int bagslot
	variable bool slotfound=0

	packcount:Set[29]
	do
	{
		if !${InvSlot[${packcount}].Item.Name(exists)}
		{
			putslot:Set[${packcount}]
			slotfound:Set[1]
			return ${putslot}
		}
		
	}
	while ${packcount:Dec}>21
	if ${direction}==1
	{
		packcount:Set[22]
		finalcount:Set[30]
	}
	else
	{
		packcount:Set[29]
		finalcount:Set[21]
	}
	do
	{
		if ${InvSlot[${packcount}].Item.Container}>0
		{
			if ${InvSlot[${packcount}].Item.SizeCapacity}>=0${FindItem[${searchitem}].Size}
			{
				if ${InvSlot[${packcount}].Item.Items}<${InvSlot[${packcount}].Item.Container}
				{
					bagslot:Set[1]
					do
					{
					
						putslot:Set[${Math.Calc[250+(${packcount}-22)*10+${bagslot}].Int}]
						if !${InvSlot[${putslot}].Item.Name(exists)}
						{
							slotfound:Set[1]
							return ${putslot}
						}
					}
					while ${bagslot:Inc}<${InvSlot[${packcount}].Item.Container}
				}
			}
		}
		if ${direction}==1
			packcount:Inc
		else
			packcount:Dec
	}
	while ${packcount}!=${finalcount}
	return ${putslot}
}

function openpack(packslot)
{
	variable int timeout=15
	
	if !${Window[pack${Math.Calc[${packslot}-21].Int}].Open}
		Exchange_Packopen:Queue[${packslot}]
	while !${Window[pack${Math.Calc[${packslot}-21].Int}].Open} && ${timeout}>0
	{
		NoModKey EQItemNotify ${packslot} rightmouseup
		WaitFrame
	}
}


function closepack()
{
	variable int packslot
	variable int timeout=15
	
	while ${Exchange_Packopen.Size}
	{
		packslot:Set[${Exchange_Packopen.Peek}]
		while ${Window[pack${Math.Calc[${packslot}-21].Int}].Open} && ${timeout}>0
		{
			NoModKey EQItemNotify ${packslot} rightmouseup
			WaitFrame
		}
		Exchange_Packopen:Dequeue
	}
}

function swapit(fromslot, toslot, lastslot)
{
	variable string item
	variable int timeout=15
;	echo [SwapIt] ${fromslot}, ${toslot}, ${lastslot}
	
	item:Set[${Cursor.ID}]
	do
	{
		if ${fromslot}>250 && ${Extension[isxeqmoveit](exists)}==TRUE
			moveitem ${fromslot} 30
		else
			NoModKey EQItemNotify ${fromslot} leftmouseup
		WaitFrame
	}
	while ${item}==${Cursor.ID} && ${timeout}>0
	timeout:Set[15]
	item:Set[${Cursor.ID}]
	do
	{
		if ${toslot}>250 && ${Extension[isxeqmoveit](exists)}==TRUE
			moveitem 30 ${toslot}
		else
		NoModKey EQItemNotify ${toslot} leftmouseup
		WaitFrame
	}
	while ${item}==${Cursor.ID} && ${timeout}>0
	if ${lastslot.Length}>0
	{
		timeout:Set[15]
		item:Set[${Cursor.ID}]
		do
		{
			if !${Cursor.ID(exists)}
				break
			if ${lastslot}>250 && ${Extension[isxeqmoveit](exists)}==TRUE
				moveitem 30 ${lastslot}
			else
				NoModKey EQItemNotify ${lastslot} leftmouseup
			WaitFrame
		}
		while ${item}==${Cursor.ID} && ${timeout}>0
	}
}
Last edited by bardomatic on Fri Aug 25, 2006 11:35 pm, edited 3 times in total.

bardomatic
a ghoul
a ghoul
Posts: 131
Joined: Thu Apr 29, 2004 12:09 am

Post by bardomatic » Sun May 21, 2006 12:55 am

blank

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Sun May 21, 2006 10:49 am

If I ask, it is to learn.

But I personally thank you for all the work on these. I'm going to be going through them to learn from them.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!