fishing.iss
Code: Select all
#include Packs.inc
#macro ProcessQueue()
while ${QueuedCommands}
ExecuteQueued
#endmac
variable string xmlSettingsFile = ${LavishScript.HomeDirectory}/Scripts/fishing/fishing.xml
variable collection:int items
variable collection:int maxItemsToKeep
variable collection:int poles
variable collection:int itemsCaught
variable bool doDisplayStats = TRUE
variable Inventory inventory
variable int poleSlot = 0
; Statistics variables
variable int landSharks = 0
variable int timesCast = 0
variable int timesNoCatch = 0
variable int timesCatch = 0
variable int timesDestroyed = 0
variable int timesKept = 0
variable int abilityIncreases = 0
variable int spilledBeer = 0
variable int lostBait = 0
function main()
{
ext -require ISXEQ
echo Let's go fishin'!!!
call init
if (${Me.Ability[Fishing]} == 0)
{
echo Fishing is not created as an ability button
call StopMe
}
call checkPole
while (TRUE)
{
if (${Me.AbilityReady[Fishing]})
{
EQExecute /doability ${Me.Ability[Fishing]}
}
ProcessQueue()
waitframe
}
}
function init()
{
SettingXML[${xmlSettingsFile}]:Unload
variable string globalSet = SettingXML[${xmlSettingsFile}].Set["Global"]
variable string zoneSet = SettingXML[${xmlSettingsFile}].Set["Zones"]
variable string poleSet = SettingXML[${xmlSettingsFile}].Set["Fishing Poles"]
variable byte x = 0
variable string myZone
variable string myPole
variable string tempString
variable int tempCount = 0
/* Load up global items */
while (${x:Inc} <= ${${globalSet}.Keys})
{
tempString:Set[${${globalSet}.GetString[${${globalSet}.Key[${x}]}]}]
tempCount:Set[${tempString.Count[:]}]
if (${tempCount} != 0)
{
maxItemsToKeep:Set[${${globalSet}.Key[${x}]}, ${tempString.Token[2,:]}]
}
items:Set[${${globalSet}.Key[${x}]}, ${${globalSet}.GetInt[${${globalSet}.Key[${x}]}]}]
}
/* Load up specific zone items */
x:Set[0]
while (${x:Inc} <= ${${zoneSet}.Sets})
{
myZone:Set[${${zoneSet}.Set[${x}]}]
if (${myZone.Equal[${Zone}]})
{
echo Found fishing data for <${myZone}>
x:Set[0]
while (${x:Inc} <= ${${zoneSet}.Set[${myZone}].Keys})
{
items:Erase[${${zoneSet}.Set[${myZone}].Key[${x}]}]
tempString:Set[${${zoneSet}.Set[${myZone}].GetString[${${zoneSet}.Set[${myZone}].Key[${x}]}]}]
tempCount:Set[${tempString.Count[:]}]
if (${tempCount} != 0)
{
maxItemsToKeep:Erase[${${zoneSet}.Set[${myZone}].Key[${x}]}]
maxItemsToKeep:Set[${${zoneSet}.Set[${myZone}].Key[${x}]}, ${tempString.Token[2,:]}]
}
items:Set[${${zoneSet}.Set[${myZone}].Key[${x}]}, ${${zoneSet}.Set[${myZone}].GetInt[${${zoneSet}.Set[${myZone}].Key[${x}]}]}]
}
Break
}
}
/* DEBUG CODE
if (${maxItemsToKeep.FirstKey(exists)})
{
do
{
echo ${maxItemsToKeep.CurrentKey}, ${maxItemsToKeep.CurrentValue}
}
while (${maxItemsToKeep.NextKey(exists)})
}
echo -------------------------------------------
if (${items.FirstKey(exists)})
{
do
{
echo ${items.CurrentKey}, ${items.CurrentValue}
}
while (${items.NextKey(exists)})
}
END DEBUG CODE */
/* Gather up all fishing pole data */
x:Set[0]
while (${x:Inc} <= ${${poleSet}.Keys})
{
poles:Set[${${poleSet}.Key[${x}]}, ${x}]
}
call addTriggers
}
function addTriggers()
{
AddTrigger Event_EquipPole "You need to put your fishing pole in your primary hand."
AddTrigger Event_AttackIsOn "You can't start fishing while attacking!"
AddTrigger Event_CaughtItem "You caught @OBJECT@!"
AddTrigger Event_CaughtSomething "You caught, something@*@"
AddTrigger Event_CaughtNothing "You didn't catch anything."
AddTrigger Event_CastLine "You cast your line."
AddTrigger Event_SkillUp "You have become better at @TRADE@! (@LVL@)"
AddTrigger Event_LandSharks "Trying to catch land sharks perhaps?"
AddTrigger Event_SpillBeer "You spill your beer@*@"
AddTrigger Event_NoBait "You can't fish without fishing bait@*@"
AddTrigger Event_LostBait "You lost your bait!"
AddTrigger Event_PoleBroke "Your fishing pole broke!"
AddTrigger Event_AlreadyFishing "You are already fishing!"
AddTrigger Event_HoldingSomething "You can't fish while holding something."
}
function checkPole()
{
if (!${inventory.MainHand.Item.Type(exists)} || ${inventory.MainHand.Item.Type.NotEqual[Fishing Pole]})
{
if (${poles.FirstKey(exists)})
{
do
{
poleSlot:Set[${inventory.FindItem[${poles.CurrentKey}]}]
if (${poleSlot} > 0)
{
call inventory.Swap ${poleSlot} ${inventory.MainHand.ID}
Break
}
}
while (${poles.NextKey(exists)})
}
}
if (${inventory.MainHand.Item.Type.NotEqual[Fishing Pole]})
{
call StopMe
}
}
function StopMe()
{
call inventory.Swap ${poleSlot} ${inventory.MainHand.ID}
endscript fishing
}
function atexit()
{
SettingXML[${xmlSettingsFile}]:Unload
RemoveTrigger Event_EquipPole
RemoveTrigger Event_AttackIsOn
RemoveTrigger Event_CaughtItem
RemoveTrigger Event_CaughtSomething
RemoveTrigger Event_CaughtNothing
RemoveTrigger Event_CastLine
RemoveTrigger Event_SkillUp
RemoveTrigger Event_LandSharks
RemoveTrigger Event_SpillBeer
RemoveTrigger Event_NoBait
RemoveTrigger Event_LostBait
RemoveTrigger Event_PoleBroke
RemoveTrigger Event_AlreadyFishing
RemoveTrigger Event_HoldingSomething
echo Fishing trip over
echo on
echo on
if (${doDisplayStats})
{
call displayStats
}
}
function displayStats()
{
variable float caughtPercent
variable float noCaughtPercent
variable float spilledBeerPercent
variable float lostBaitPercent
variable float keptPercent
variable float destroyedPercent
if (${timesCast} > 0)
{
caughtPercent:Set[${Math.Calc[(${timesCatch}/${timesCast})*100]}]
noCaughtPercent:Set[${Math.Calc[(${timesNoCatch}/${timesCast})*100]}]
spilledBeerPercent:Set[${Math.Calc[(${spilledBeer}/${timesCast})*100]}]
lostBaitPercent:Set[${Math.Calc[(${lostBait}/${timesCast})*100]}]
}
if (${timesCatch} > 0)
{
keptPercent:Set[${Math.Calc[(${timesKept}/${timesCatch})*100]}]
destroyedPercent:Set[${Math.Calc[(${timesDestroyed}/${timesCatch})*100]}]
}
echo --------------- FISHING STATISTICS ---------------
echo Ability Ups........................ ${abilityIncreases}
echo Cast............................... ${timesCast} (100%)
echo Caught............................. ${timesCatch} (${caughtPercent}%)
echo Kept................................. ${timesKept} (${keptPercent}%)
echo Destroyed............................ ${timesDestroyed} (${destroyedPercent}%)
echo No Caught.......................... ${timesNoCatch} (${noCaughtPercent}%)
echo Land Sharks........................ ${landSharks}
echo Spilled Beer....................... ${spilledBeer} (${spilledBeerPercent}%)
echo Lost Bait.......................... ${lostBait} (${lostBaitPercent}%)
if (${timesCatch} > 0 && ${itemsCaught.FirstKey(exists)})
{
variable float temp = 0.0
echo -------
echo DETAILS
echo -------
do
{
temp:Set[${Math.Calc[(${itemsCaught.CurrentValue}/${timesCatch})*100]}]
echo ${itemsCaught.CurrentKey}........................ ${itemsCaught.CurrentValue} (${temp}%)
}
while (${itemsCaught.NextKey(exists)})
}
}
function handleCursor()
{
timesCatch:Inc
if (${itemsCaught.Element[${Cursor.Name}](exists)})
{
itemsCaught.Element[${Cursor.Name}]:Inc
}
else
{
itemsCaught:Set[${Cursor.Name}, 1]
}
if (${maxItemsToKeep[${Cursor.Name}](exists)})
{
if (${itemsCaught.Element[${Cursor.Name}]} > ${maxItemsToKeep.Element[${Cursor.Name}]})
{
items:Erase[${Cursor.Name}]
maxItemsToKeep:Erase[${Cursor.Name}]
}
}
if (${items.Element[${Cursor.Name}]} == 0)
{
timesDestroyed:Inc
echo Destroying ${Cursor.Name}
destroy
}
else
{
timesKept:Inc
echo Keeping ${Cursor.Name}
EQExecute /autoinventory
}
}
function Event_AlreadyFishing()
{
}
function Event_HoldingSomething()
{
EQExecute /autoinventory
}
function Event_EquipPole()
{
call checkPole
}
function Event_CaughtItem(Line, Object)
{
wait 4
while (${Cursor.Name.NotEqual[NULL]})
{
call handleCursor
}
}
function Event_CaughtSomething()
{
wait 4
while (${Cursor.Name.NotEqual[NULL]})
{
call handleCursor
}
}
function Event_SkillUp(Line, Trade, Lvl)
{
abilityIncreases:Inc
echo ${Trade} is at ${Lvl}
}
function Event_PoleBroke()
{
call checkPole
}
function Event_NoBait()
{
echo You need bait to fish!
call StopMe
}
function Event_AttackIsOn()
{
EQExecute /attack off
}
function Event_LostBait()
{
lostBait:Inc
}
function Event_LandSharks()
{
landSharks:Inc
if (${landSharks} >= 3)
{
echo Got too many land sharks... exiting
call StopMe
}
}
function Event_CastLine()
{
timesCast:Inc
}
function Event_SpillBeer()
{
spilledBeer:Inc
}
function Event_CaughtNothing()
{
timesNoCatch:Inc
}
fishing.xml (This goes in the directory Scripts/fishing)
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<InnerSpaceSettings>
<!-- Items are destroyed by default so you only need to add
items you want to keep -->
<!-- These settings affect all zones. They are loaded
first and then zone data will overwrite them -->
<Set name="Global">
<Setting name="Fresh Fish">1:4</Setting>
<Setting name="Fish Scales">1:2</Setting>
</Set>
<Set name="Zones">
<!-- Settings for this section override the Global settings by zone -->
<Set name="The Plane of Knowledge">
<!--<Setting name="Fresh Fish">0</Setting>-->
</Set>
</Set>
<Set name="Fishing Poles">
<!-- Settings in this section indicate the possible fishing
poles one might have around. The order of these determines
which will be used first if found -->
<Setting name="Collapsible Fishing Pole"></Setting>
<Setting name="Blessed Fishing Rod"></Setting>
<Setting name="Brell's Fishing Pole"></Setting>
<Setting name="Ancient Fishing Pole"></Setting>
<Setting name="Uliorn's Fishing Pole"></Setting>
<Setting name="Agilthin's Fishing Pole"></Setting>
<Setting name="Hintol's Fishing Pole"></Setting>
<Setting name="Fishing Pole"></Setting>
</Set>
</InnerSpaceSettings>
Packs.inc is in the next post.


