/* * Written by: Xeon * * Crafting Assist Script * * Version 0.4 -- Feb 4th, 2007 * Version 0.5 -- Feb 6th, 2007 * -- Added some more intelligent checks for Quality and Progress * * * Special Thanks to: ** Amadeus ** * * -- Great work on ISXVG and thanks for the coding help as well! -- * */ /* * This is a Crafting Assistant script * * To USE: * * In the ISX console type: runscript vgcraft.iss * 1) Get a few work orders, * 2) Make sure you have all the correct Ingredients * 3) Use a crafting station * The script will start once you select a recipe * * To stop the script: endscript vgcraft.iss * */ /* CHANGE THIS if you want a higher/lower Quality */ variable int TargetQuality = 350 /* * 0-250 D * 251-500 C * 501-750 B * 751-1000 A */ /* Global Variable Declarations */ variable bool debug = TRUE variable bool doComplications = FALSE variable bool isRunning = TRUE variable bool isPaused = FALSE variable string OutputFile = "${Script.CurrentDirectory}/vgcraft-output.log" variable string UIFile = "${Script.CurrentDirectory}/vgcraft/VGCraftUI.xml" variable int64 cStationID variable int64 cOrderVendorID variable int64 cSellVendorID variable index:int CompletedSteps variable int cState #define LOWCOST 1 #define MAXPROG 2 #define MAXQUAL 3 /* * Possible Values of cState: */ #define CS_WAIT 0 /* Waiting for something to finish */ #define CS_STATION 10 /* Using Crafting Station */ #define CS_STATION_RECIPE 11 /* Waiting for Recipe selection */ #define CS_STATION_INGRED 12 /* Selecting Ingredients/Materials needed */ #define CS_STATION_SETUP 13 /* Setup the workbench with Ingredients */ #define CS_STATION_BEGIN 14 /* Waiting to begin recipe */ #define CS_ACTION 20 /* Using Recipe actions */ #define CS_ACTION_FIND 21 /* Select Available Action */ #define CS_ACTION_WAIT 22 /* Waiting for Action to finish */ #define CS_ACTION_MANUAL 23 /* Requires User Input (manual typing) */ #define CS_ACTION_OOAP 24 /* Out Of Action Points */ #define CS_ACTION_OOM 25 /* Out Of Material (ingredients) */ #define CS_COMPLICATE 30 /* Checking Complication */ #define CS_COMPLICATE_FIND 31 /* Selecting Complication Action */ #define CS_COMPLICATE_WAIT 32 /* Waiting for Complication Action to finish */ #define CS_LOOT 40 /* Looting */ #define CS_MOVE 50 /* Moving to Target */ #define CS_MOVE_TARGET 51 /* Selecting Correct Target */ #define CS_MOVE_WAIT 52 /* Waiting for movement to finish */ #define CS_ORDER 60 /* Talking to Order Giver/Taker */ #define CS_ORDER_NEW 61 /* Getting new Orders */ #define CS_ORDER_DONE 62 /* Completing Finished Orders */ #define CS_SUPPLY 70 /* Talking to Item/Resupply Vendor */ #define CS_SUPPLY_BUY 71 /* Buying supplies */ #define CS_SUPPLY_SORT 72 /* Moving supplies around inventory */ #define CS_SUPPLY_SELL 73 /* Sell any loot */ atom(script) VG_OnIncomingText(string Text, string ChannelNumber, string ChannelName) { ; This event is fired every time that text get's sent to the client ;echo "IncomingText ${ChannelNumber} : ${ChannelName} :Text: ${Text}" call MyOutput "VG: (${ChannelNumber}):(${ChannelName}) :: ${Text}" if ( ${Text.Find[Select the recipe you wish to use]} ) { ;DebugOut "VG:State: ${Refining.State}" ;call MyOutput "VG:Text: Select the recipe you wish to use" cState:Set[CS_STATION] CompletedSteps:Clear } elseif ( ${Text.Find[Crafting recipe selected]} ) { ;DebugOut "VG:Refining:DoSetup" ;call MyOutput "VG:Text: ${Text}" cState:Set[CS_STATION_RECIPE] } elseif ( ${Text.Find[You may now set up your workbench]} ) { cState:Set[CS_STATION_BEGIN] } elseif ( ${Text.Find[You may not choose a crafting action]} ) { ; We are currently busy! if ( ${cState} == CS_ACTION_WAIT ) { call MyOutput "ACTION_WAIT: Trying to kickstart Action Sequence" cState:Set[CS_ACTION] } } elseif ( ${Text.Find[has been completed]} ) { ; This Could be an AvailAction finish ; Or it could be a Correction finish if ( ${cState} == CS_COMPLICATE_WAIT ) { ; Complication Fixed ; Check to see if we have to hit it again cState:Set[CS_COMPLICATE] } else { ;;;;;;elseif ( ${cState} == CS_ACTION_WAIT ) ; make sure to set the state so we can find another action to do cState:Set[CS_ACTION] } } elseif ( ${Text.Find[New complication:]} ) { if ( ${doComplications} ) { DebugOut "VG: Found a Complication" cState:Set[CS_COMPLICATE] } else { DebugOut "VG: Ignoring Complication" } } elseif ( ${Text.Find[Missing tool of type:]} ) { ; Missing a tool for Corrections if ( ${cState} == CS_COMPLICATE_WAIT ) { ; Tried a Correction, but missing the tools DebugOut "VG: Missing TOOL!" ; ok, back to the action! cState:Set[CS_ACTION] } } elseif ( ${Text.Find[Missing item of type:]} ) { if ( ${cState} == CS_COMPLICATE_WAIT ) { ; Can't use this Correction because we are missing something ; ok, back to the action! DebugOut "VG: missing ITEM!" cState:Set[CS_ACTION] } else { VGEcho "VG: Out Of Materials, switching to manual" > screen cState:Set[CS_ACTION_OOM] ;Refining:Cancel } } elseif ( ${Text.Find[You do not have enough action points]} ) { if ( ${Refining.Stage.Index} < 4 ) { VGEcho "VG: Arg! Ran out of Action Points" > screen Refining:Cancel cState:Set[CS_ACTION_OOAP] } else { VGEcho "VG: Arg! You do it manualy!" > screen cState:Set[CS_ACTION_MANUAL] } } elseif ( ${Text.Find[Recipe section 1 complete]} ) { ;Stage 1 done } elseif ( ${Text.Find[Recipe section 2 complete]} ) { ;Stage 2 done } elseif ( ${Text.Find[Recipe section 3 complete]} ) { ;Stage 3 done } elseif ( ${Text.Find[Your crafting session ends]} ) { ; All Done! ; Set the next action to Loot! cState:Set[CS_LOOT] ; Clear out the variables for the next run through CompletedSteps:Clear } } atom(script) VG_onCraftingStepComplete(string StepTypeID) { ; This Step is done! CompletedSteps:Insert[${StepTypeID}] ;echo Step Complete! (StepID: ${StepTypeID}) [${CompletedSteps.Used} steps now completed.] } atom(script) VG_OnCraftingAlert(string Text) { ;This event is fired upon every instance that the ; Vanguard client sends a 'crafting alert' call MyOutput "CA: ${Text}" call MyOutput "State: ${Refining.State}" call MyOutput "Progress: ${Refining.CurrentRecipe.ProgressBarPct}" call MyOutput "Quality: ${Refining.Quality}" } function CheckState() { if ( ${Refining.CurrentRecipe(exists)} && ${Refining.InRecovery} ) { call MyOutput "InRecovery is TRUE" wait 10 return } ;DebugOut "VG:CheckState called == ${cState}" ;call MyOutput "CheckState called == ${cState}" Switch ${cState} { case CS_WAIT /* We are waiting for previous action/command/etc to finish */ break case CS_STATION /* Using Crafting Station */ break case CS_STATION_RECIPE /* Waiting for Recipe selection */ cState:Set[CS_WAIT] if ( ${Refining.CurrentRecipe(exists)} ) { cState:Set[CS_STATION_INGRED] } else { ; Still waiting for them to select a recipe cState:Set[CS_STATION] } break case CS_STATION_INGRED /* Selecting Ingredients/Materials needed */ cState:Set[CS_WAIT] ; Check to see if we have all the required Ingredients call CheckIngredients if ( ${Return} ) { ;DebugOut "VG:You have all the required Ingredients" cState:Set[CS_STATION_SETUP] } else { DebugOut "VG:You don't have required Ingredients for that Recipe" DebugOut "VG:Try a different one" cState:Set[CS_STATION] } break case CS_STATION_SETUP /* Setup workbench with Ingredients */ cState:Set[CS_WAIT] call MyOutput "Refining:DoSetup -- Table Setup started" Refining:DoSetup ;call DumpRefining break case CS_STATION_BEGIN /* Waiting to begin recipe */ cState:Set[CS_WAIT] DebugOut "VG:Refining:Start" call MyOutput " === Refining:Start ===" Refining:Start wait 15 cState:Set[CS_ACTION] break case CS_ACTION /* Using Recipe actions */ cState:Set[CS_ACTION_FIND] break case CS_ACTION_FIND /* Select Available Action */ cState:Set[CS_WAIT] call FindAction cState:Set[CS_ACTION_WAIT] break case CS_ACTION_WAIT /* Waiting for Action to finish */ ; Don't do anything here as this state will be changed ; by an Event from VG_OnIncomingText() break case CS_ACTION_MANUAL /* Requires User Input (manual typing) */ break case CS_ACTION_OOAP /* Out Of Action Points */ break case CS_ACTION_OOM /* Out Of Material (ingredients) */ break case CS_COMPLICATE /* Checking Complication */ call CheckComplication break case CS_COMPLICATE_FIND /* Selecting Complication Action */ call FindCorrection if ( ${Return} ) { ; Wait for Correction to finish cState:Set[CS_COMPLICATE_WAIT] } else { ; No corrections selected, so return to Action! cState:Set[CS_ACTION] } break case CS_COMPLICATE_WAIT /* Waiting for Complication Action to finish */ ; Don't do anything here as this state will be changed ; by an Event from VG_OnIncomingText() break case CS_LOOT /* Looting */ cState:Set[CS_WAIT] call DoLoot break case CS_MOVE /* Moving to Target */ break case CS_MOVE_TARGET /* Selecting Correct Target */ break case CS_MOVE_WAIT /* Waiting for movement to finish */ break case CS_ORDER /* Talking to Order Giver/Taker */ break case CS_ORDER_NEW /* Getting new Orders */ break case CS_ORDER_DONE /* Completing Finished Orders */ break case CS_SUPPLY /* Talking to Item/Resupply Vendor */ break case CS_SUPPLY_BUY /* Buying supplies */ break case CS_SUPPLY_SORT /* Moving supplies around inventory */ break case CS_SUPPLY_SELL /* Sell any loot */ break default /* Hmm, how did we get here? */ } } /* See if we need to look for some Correction Actions */ function CheckComplication() { ; ComplicationsCount ; CorrectionsCount call MyOutput "CheckComplications() called" call MyOutput "Complictions Found: ${Refining.ComplicationsCount}" call MyOutput "Corrections Found: ${Refining.CorrectionsCount}" if ( ${Refining.CorrectionsCount} > 0 ) { cState:Set[CS_COMPLICATE_FIND] } } /* Find and Execute a Correction */ function:bool FindCorrection() { variable int tstep variable int substep ; Start with the highest (latest one to appear) Correction tstep:Set[${Refining.CorrectionsCount}] ;DebugOut "VG: Find Corrections" call MyOutput "Corrections Found: ${Refining.CorrectionsCount}" do { if ( ${Refining.Correction[${tstep}].AvailActionsCount} > 0 ) { substep:Set[1] call MyOutput "AvailActionsCount: ${Refining.Correction[${tstep}].AvailActionsCount}" do { if ( ${Refining.Correction[${tstep}].AvailAction[${substep}].ActionPointCost} < 40 ) { call MyOutput "VG:Correction: ${Refining.Correction[${tstep}].AvailAction[${substep}].Name}" DebugOut "VG:Correction: ${Refining.Correction[${tstep}].AvailAction[${substep}].Name}" Refining.Correction[${tstep}].AvailAction[${substep}]:Use return TRUE } } while ( ${substep:Inc} <= ${Refining.Correction[${tstep}].AvailActionsCount} ) } } while ( ${tstep:Dec} >= 1 ) return FALSE } function DoLoot() { ; Should probably check to see if we have a Loot window open Loot:LootAll } function:bool CheckIngredients() { ;Check our UsableItemCount to see if we have enough ; Hack for now if ( ${Refining.UsableItemCount} > 1 ) return TRUE variable int tstep tstep:Set[1] call MyOutput "CheckIngredients() called" call MyOutput "Igredients Found: ${Refining.UsableItemCount}" do { call MyOutput "Igredients Found: ${Refining.UsableItem[${tstep}].Quantity}" if ( ${Refining.UsableItem[${tstep}].Quantity} > 15 ) { ;DebugOut "VG:Igred Count: ${Refining.UsableItem[${tstep}].Quantity} " return TRUE } } while ( ${tstep:Inc} <= ${Refining.UsableItemCount} ) VGEcho "VG:Not enough STUFF -- get more!" > screen return FALSE } function:bool StepUsed(int StepTypeID) { variable iterator i CompletedSteps:GetIterator[i] i:First if (!${i.IsValid}) { return FALSE } do { if (${i.Value} == ${StepTypeID}) { return TRUE } i:Next } while ${i.IsValid} return FALSE } function FindAction() { variable int tstep variable int substep variable int count ;DebugOut "VG:State: ${Refining.State}" ;DebugOut "VG:StepCount: ${Refining.CurrentRecipe.StepCount}" if ( ${Refining.Stage.Index} == 1 ) { ;DebugOut "VG:Stage: (${Refining.Stage.Name}:${Refining.Stage.Index}) StepCount: ${Refining.Stage.StepCount} " call MyOutput "Stage: (${Refining.Stage.Name}:${Refining.Stage.Index}) StepCount: ${Refining.Stage.StepCount}" ; If this is stage 1 of a WorkOrder then just always select the first AvailAction ; if ( ${Refining.CurrentRecipe.IsWorkOrder} ) Refining.Stage.Step[1].AvailAction[1]:Use } elseif ( ${Refining.Stage.Index} == 4 ) { ;DebugOut "VG:Stage: (${Refining.Stage.Name}:${Refining.Stage.Index}) StepCount: ${Refining.Stage.StepCount} " call MyOutput "Stage: (${Refining.Stage.Name}:${Refining.Stage.Index}) StepCount: ${Refining.Stage.StepCount}" ; If this is stage 4 of a WorkOrder then choose between two actions ; ${Refining.OrigActionPointsAvail} - ${Refining.ActionPointsUsed} if ( ${Refining.Stage.Step[1].AvailAction[1].ActionPointCost} <= (${Refining.OrigActionPointsAvail} - ${Refining.ActionPointsUsed}) ) { Refining.Stage.Step[1].AvailAction[1]:Use } else { Refining.Stage.Step[1].AvailAction[2]:Use } } elseif ( ${Refining.Stage.Index} > 1 ) { ;DebugOut "VG:Stage: (${Refining.Stage.Name}:${Refining.Stage.Index}) StepCount: ${Refining.Stage.StepCount} " call MyOutput "Stage: (${Refining.Stage.Name}:${Refining.Stage.Index}) StepCount: ${Refining.Stage.StepCount}" if ( ${Refining.Stage.Index} == 3 ) { variable int apLeft apLeft:Set[${Refining.OrigActionPointsAvail} - ${Refining.ActionPointsUsed}] ; If we are at Stage 3 and we have less than 500 AP's left, don't care about quality, do Progress! if ( ${apLeft} < 500 ) { DebugOut "VG: AP low, finish fast!" call TryProgressAction LOWCOST return } ; If we are at Stage 3, have most of the progress done and have lots of action points, pump Quality! ;call MyOutput "Progress: ${Refining.CurrentRecipe.ProgressBarPct}" ;call MyOutput "Quality: ${Refining.Quality}" if ( (${apLeft} > 500) && (${Refining.Quality} < 850) && (${Refining.CurrentRecipe.ProgressBarPct} > 70) ) { DebugOut "VG: Pumping EXTRA quality!" call TryQualityAction if ( ${Return} ) return } } ; ; As long as Quality is low, try to find and use a Quality increasing action ; call MyOutput "Quality: ${Refining.Quality} vs ${TargetQuality}" if ( ${Refining.Quality} < ${TargetQuality} ) { call TryQualityAction if ( ${Return} ) return } ; Sometimes ${Refining.Stage.StepCount} = 0, but we still have two AvailActions if ( ${Refining.Stage.StepCount} == 0 ) { DebugOut "VG:Bah! StepCount == 0" DebugOut "VG:You will have to do this Stage manualy" return } ; Ok, no Quality increase, so let's try to Progress the recipe call TryProgressAction MAXPROG } } /* Try to find an Action in the current Stage that will increase Progress */ /* Argument is maximize Progress or find lowest action point cost */ function:bool TryProgressAction(int iPump) { variable int tstep variable int substep variable int useStep variable int useSubStep variable int highProg variable int highCost useStep:Set[0] useSubStep:Set[0] highProg:Set[0] highCost:Set[0] call MyOutput "TryProgressAction called: ${iPump}" tstep:Set[1] ; Cycle through all the possible AvailActions and find one to use do { substep:Set[1] call StepUsed ${Refining.Stage.Step[${tstep}].TypeID} if ( ${Return} ) { ; This Step has been greyed out, so continue call MyOutput "STEP GRAYED OUT -- ${tstep}" continue } ;call MyOutput "AvailActionsCount: ${Refining.Stage.Step[${tstep}].AvailActionsCount}" do { if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Progress:]} ) { if ( ${iPump} == LOWCOST ) { if ( ${highCost} < ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost} ) { highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${iPump} == MAXPROG ) { ;Progress: Very High ;Progress: High ;Progress: Moderate ;Progress: Low ;call MyOutput "Desc: ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description}" if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Progress: Very]} ) { if ( ${highProg} < 4 ) { call MyOutput "Progress: Very High :: ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Name} " highProg:Set[4] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } elseif ( ${highCost} > ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost} ) { highProg:Set[4] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Progress: High]} ) { if ( ${highProg} < 3 ) { call MyOutput "Progress: High :: ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Name} " highProg:Set[3] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } elseif ( ${highCost} > ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost} ) { highProg:Set[3] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Progress: Moderate]} ) { if ( ${highProg} < 2 ) { call MyOutput "Progress: Moderate :: ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Name} " highProg:Set[2] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Progress: Low]} ) { if ( ${highProg} < 1 ) { call MyOutput "Progress: Low :: ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Name} " highProg:Set[1] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } } } } while ( ${substep:Inc} <= ${Refining.Stage.Step[${tstep}].AvailActionsCount} ) } while ( ${tstep:Inc} <= ${Refining.Stage.StepCount} ) if ( (${useStep} > 0) && (${useSubStep} > 0) ) { call MyOutput "Using: (${useStep})(${useSubStep}) :Name: ${Refining.Stage.Step[${useStep}].AvailAction[${useSubStep}].Name}" DebugOut "VG:Using: ${Refining.Stage.Step[${useStep}].AvailAction[${useSubStep}].Name}" Refining.Stage.Step[${useStep}].AvailAction[${useSubStep}]:Use return TRUE } else { DebugOut "VG:No Progress increasing action found" call MyOutput "NOTICE: No Progress increasing action found" return FALSE } } /* Try to find an Action in the current Stage that will increase quality */ function:bool TryQualityAction() { variable int tstep variable int substep variable int count variable int useStep variable int useSubStep variable int highProg variable int highCost useStep:Set[0] useSubStep:Set[0] highProg:Set[0] highCost:Set[0 ; Find any Quality enhancing steps and use them! call MyOutput "TryQualityAction called" tstep:Set[1] do { ;call MyOutput "Step ${tstep}:Name: ${Refining.Stage.Step[${tstep}].Name}" ;call MyOutput "Step ${tstep}:Description: ${Refining.Stage.Step[${tstep}].Description}" ;call MyOutput "Step ${tstep}:AvailActionsCount: ${Refining.Stage.Step[${tstep}].AvailActionsCount}" call StepUsed ${Refining.Stage.Step[${tstep}].TypeID} if ( ${Return} ) { ; This Step has been greyed out, so continue continue } substep:Set[1] do { if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Quality:]} ) { ;Progress: Very High ;Progress: High ;Progress: Moderate ;Progress: Low ;call MyOutput "Desc: ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description}" if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Quality: Very]} ) { if ( ${highProg} < 4 ) { highProg:Set[4] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } elseif ( ${highCost} > ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost} ) { highProg:Set[4] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Quality: High]} ) { if ( ${highProg} < 3 ) { highProg:Set[3] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } elseif ( ${highCost} > ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost} ) { highProg:Set[3] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Quality: Moderate]} ) { if ( ${highProg} < 2 ) { highProg:Set[2] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } if ( ${Refining.Stage.Step[${tstep}].AvailAction[${substep}].Description.Find[Quality: Low]} ) { if ( ${highProg} < 1 ) { highProg:Set[1] highCost:Set[${Refining.Stage.Step[${tstep}].AvailAction[${substep}].ActionPointCost}] useStep:Set[${tstep}] useSubStep:Set[${substep}] } } } } while ( ${substep:Inc} <= ${Refining.Stage.Step[${tstep}].AvailActionsCount} ) } while ( ${tstep:Inc} <= ${Refining.Stage.StepCount} ) if ( (${useStep} > 0) && (${useSubStep} > 0) ) { call MyOutput "Using: (${useStep})(${useSubStep}) :Name: ${Refining.Stage.Step[${useStep}].AvailAction[${useSubStep}].Name}" ;DebugOut "VG:Trying to improve Quality!" DebugOut "VG:Using: ${Refining.Stage.Step[${useStep}].AvailAction[${useSubStep}].Name}" Refining.Stage.Step[${useStep}].AvailAction[${useSubStep}]:Use return TRUE } else { DebugOut "VG:No Quality increasing action found" call MyOutput "NOTICE: No Quality increasing action found" return FALSE } return FALSE } /* This code snippet was written by Amadeus */ function MoveCraftSupplies() { variable int i = 1 variable int UtilityPouchIndex = 0 variable int ContainerCurrentlyInIndex = 0 ; The name of the "Utility Pouch" is hard coded here. UtilityPouchIndex:Set[${Me.Inventory[Utility Pouch].Index}] do { if ( ${Me.Inventory[${i}].MiscDescription.Find[Small crafting utilities]} > 0 ) { if (${Me.Inventory[${i}].InContainer(exists)}) { ContainerCurrentlyInIndex:Set[${Me.Inventory[${i}].InContainer.Index}] ;echo ${Me.Inventory[${i}]} is currently in Index: ${ContainerCurrentlyInIndex} } else { ContainerCurrentlyInIndex:Set[0] ;echo ${Me.Inventory[${i}]} is not in a container! } if (${ContainerCurrentlyInIndex} != ${UtilityPouchIndex}) { ;echo MOVING ${Me.Inventory[${i}]} to Container Index: ${UtilityPouchIndex} Me.Inventory[${i}]:PutInContainer[${UtilityPouchIndex}] wait 2 } } } while (${i:Inc} <= ${Me.Inventory}) } function DumpRefining() { if ( ${Refining.CurrentRecipe.StepCount} > 0 ) { ;DebugOut "VG:State: ${Refining.State}" call MyOutput "Refining.State: ${Refining.State}" ;UsableItemCount call MyOutput "UsableItemCount: ${Refining.UsableItemCount}" ;OrigActionPointsAvail call MyOutput "OrigActionPointsAvail: ${Refining.OrigActionPointsAvail}" ;ActionPointsUsed call MyOutput "ActionPointsUsed: ${Refining.ActionPointsUsed}" call MyOutput "Quality: ${Refining.Quality}" call MyOutput " ==== CurrentRecipe Data ==== " call MyOutput "ID: ${Refining.CurrentRecipe.ID}" call MyOutput "Name: ${Refining.CurrentRecipe.Name}" call MyOutput "Description: ${Refining.CurrentRecipe.Description}" call MyOutput "Stage1Name: ${Refining.CurrentRecipe.Stage1Name}" call MyOutput "Stage2Name: ${Refining.CurrentRecipe.Stage2Name}" call MyOutput "Stage3Name: ${Refining.CurrentRecipe.Stage3Name}" call MyOutput "Stage4Name: ${Refining.CurrentRecipe.Stage4Name}" call MyOutput "ActionPointsTotal: ${Refining.CurrentRecipe.ActionPointsTotal}" call MyOutput "ProgressBarPct: ${Refining.CurrentRecipe.ProgressBarPct}" call MyOutput "NumUses: ${Refining.CurrentRecipe.NumUses}" call MyOutput "IsWorkOrder: ${Refining.CurrentRecipe.IsWorkOrder}" call MyOutput "IsRefining: ${Refining.CurrentRecipe.IsRefining}" call MyOutput "IsFinishing: ${Refining.CurrentRecipe.IsFinishing}" call MyOutput "StepCount: ${Refining.CurrentRecipe.StepCount}" call MyOutput " ============================================================= " call MyOutput "Stage: ${Refining.Stage.Name}" call MyOutput "Stage: ${Refining.Stage.Index}" call MyOutput "Stage: ${Refining.Stage.StepCount}" call MyOutput " ============================================================= " variable int tstep = 1 tstep:Set[1] do { ;call MyOutput " ============================================================= " ;call MyOutput "Step ${tstep}:InStage.Name: ${Refining.CurrentRecipe.Step[${tstep}].InStage.Name}" ;call MyOutput "Step ${tstep}:InStage.Index: ${Refining.CurrentRecipe.Step[${tstep}].InStage.Index}" ;call MyOutput "Step ${tstep}:InStage.StepCount: ${Refining.CurrentRecipe.Step[${tstep}].InStage.StepCount}" call MyOutput "Step ${tstep}:Name: ${Refining.CurrentRecipe.Step[${tstep}].Name}" call MyOutput "Step ${tstep}:Description: ${Refining.CurrentRecipe.Step[${tstep}].Description}" call MyOutput "Step ${tstep}:AvailActionsCount: ${Refining.CurrentRecipe.Step[${tstep}].AvailActionsCount}" variable int substep = 1 substep:Set[1] do { call MyOutput "Step ${tstep}:AvailAction ${substep}:Name: ${Refining.CurrentRecipe.Step[${tstep}].AvailAction[${substep}].Name}" call MyOutput "Step ${tstep}:AvailAction ${substep}:ActionPointCost: ${Refining.CurrentRecipe.Step[${tstep}].AvailAction[${substep}].ActionPointCost}" call MyOutput "Step ${tstep}:AvailAction ${substep}:Description: ${Refining.CurrentRecipe.Step[${tstep}].AvailAction[${substep}].Description}" } while ( ${substep:Inc} <= ${Refining.CurrentRecipe.Step[${tstep}].AvailActionsCount} ) } while ( ${tstep:Inc} <= ${Refining.CurrentRecipe.StepCount} ) call MyOutput " ============================================================= " call MyOutput " ============= Dump Done ===================== " call MyOutput " ============================================================= " } } function DebugOut(string Message) { if ( ${debug} ) { VGEcho "${Message}" > screen } } function SetOutputFile(string Filename) { ;OutputFile:Set[${Filename}] redirect "${OutputFile}" echo "============ ${Time} VGCraft Output started ==================" redirect -append "${OutputFile}" echo "=============================================" } function MyOutput(string Message) { ;echo "${Time}::${Message}" redirect -append "${OutputFile}" echo "${Time}::${Message}" } function Pause() { isPaused:Set[TRUE] } function unPause() { isPaused:Set[FALSE] } function Start() { isRunning:Set[TRUE] } function Stop() { isRunning:Set[FALSE] } ;/* ;addtrigger damage "Your @Spell@ hits @Mob@ for @Damage@ damage" ;atom damage(string Line, string Spell, string Mob, int Damage) ;*/ function main() { declare startXP int script startXP = 0 declare lastXP int script lastXP = 0 variable int tempXP = 0 declare startCraftXP int script startCraftXP = 0 variable int lastCraftXP = 0 ; If ISXEVG isn't loaded, then no reason to run this script. if (!${ISXVG(exists)}) { return } call SetOutputFile "${OutputFile}" isRunning:Set[TRUE] isPaused:Set[FALSE] ;Tell the user that the script has initialized and is running! DebugOut "VG:Crafting Assistant started" ; Load up the UI panel ui -load ${UIFile} ; Get player data and log to output file: call MyOutput "=================================================" call MyOutput "Name: ${Me.FName}" call MyOutput "Class: ${Me.Class}" call MyOutput "Level: ${Me.Level}" call MyOutput "XP: ${Me.XP} XP%: ${Me.XPPct}" call MyOutput "=================================================" startXP:Set[${Me.CraftXP}] startCraftXP:Set[${Me.CraftXP}] lastCraftXP:Set[${Me.CraftXP}] ;Initialize/Attach the event Atoms that we defined previously Event[VG_OnIncomingText]:AttachAtom[VG_OnIncomingText] Event[VG_OnCraftingAlert]:AttachAtom[VG_OnCraftingAlert] Event[VG_onCraftingStepComplete]:AttachAtom[VG_onCraftingStepComplete] do { if ( ${isPaused} ) { wait 5 continue } ; Check what state of crafting we are in if ( ${cState} == CS_WAIT ) { wait 1 } else { call CheckState } ;if ${QueuedCommands} ; ProcessQueued ;else ; WaitFrame if (${lastCraftXP} < ${Me.CraftXP}) { tempXP:Set[${Me.CraftXP} - ${lastCraftXP}] lastCraftXP:Set[${Me.CraftXP}] VGEcho "VG:You gained ${tempXP} Crafting XP" > screen } } while ( ${isRunning} ) } function atexit() { ; If ISXEVG isn't loaded, then no reason to run this script. if (!${ISXVG(exists)}) { return } variable int totalXP=0 totalXP:Set[${Me.CraftXP} - ${startXP}] VGEcho "VG:Total Crafting XP gained: ${totalXP}" > screen call MyOutput "=================================================" call MyOutput "CraftingLevel : ${Me.CraftingLevel}" call MyOutput "XP: ${Me.CraftXP} XP%: ${Me.CraftXPPct}" call MyOutput "Crafting XP gained: ${totalXP}" call MyOutput "=================================================" ;Remove the event listeners Event[VG_OnIncomingText]:DetachAtom[VG_OnIncomingText] Event[VG_OnCraftingAlert]:DetachAtom[VG_OnCraftingAlert] Event[VG_onCraftingStepComplete]:DetachAtom[VG_onCraftingStepComplete] ui -unload ${UIFile} ;Send a final message telling the user that the script has ended DebugOut "VG:Craft Assist has stopped" }