#include move.inc
#include spell_routines.inc
#Event ALCantLoot "#*#may not loot this corpse#*#"
#Event Exp "#*#You gain party experience#*#"
Sub Main
/call SetupAdvLootVars
/declare ReportExp bool outer TRUE
/declare LDExp float outer ${Me.PctGroupLeaderExp}
/declare AAExp float outer ${Me.PctAAExp}
/declare Exp float outer ${Me.PctExp}
/declare StartZone int outer ${Zone.ID}
/declare loottimer timer outer
/stealth on
:Main_Loop
/if (${SpawnCount[corpse noalert 25]}) {
/if (${Zone.ID}!=${StartZone}) /endmacro
/target corpse noalert 25
/delay 1s !${Target.ID}
/if (${Target.Deity.ID}) {
/if (${Target.ID}) /squelch /alert add 25 id ${Target.ID}
/if (${Target.ID}) /squelch /alert add 25 corpse ${Target.CleanName}
/varset CorpseRotTimer ${CorpseRotTime}
/squelch /target clear
/goto :Main_Loop
}
/if (!${Target.Deity.ID}) {
/warp t
/delay 1s
/call LootMobs
/delay 1
/stealth return
/doevents
}
}
/doevents
/goto :Main_Loop
/return
|==============================================================================
Sub Event_Exp(string Line)
|- Experience calculation and reporting
/if (${ReportExp}) /echo ** XP-Delta: REG (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%)
/varset LDExp ${Me.PctGroupLeaderExp}
/varset AAExp ${Me.PctAAExp}
/varset Exp ${Me.PctExp}
/return
Sub SetupAdvLootVars
/declare ALDontLoot int outer
/declare CorpseRotTimer timer outer
/declare LootMobs TRUE bool
/declare CorpseRadius 100000 int
/declare MobsTooClose 1 int
/declare CorpseRotTime 440s string
/declare ReportLoot FALSE bool
/declare LootChannel echo string
/if (!${Defined[${AlertList}]}) /declare AlertList int outer 1
/squelch /alert clear 25
/return
Sub ALLoadVar(IniSection,IniVar,IniValue,VarType)
/if (!${Defined[${IniVar}]} && ${Defined[VarType]}) /declare ${IniVar} ${VarType} outer
/declare IniString string local ${Ini[Loot.ini,${IniSection},${IniVar},NOTFOUND]}
/varset ${IniVar} ${IniString}
/if (${IniString.Equal["NOTFOUND"]}) {
/if (${IniString.Equal["NOTFOUND"]}) /varset ${IniVar} ${IniValue}
/ini "Loot.ini" "${IniSection}" "${IniVar}" "${${IniVar}}"
}
/return
Sub LootCorpse
/declare i int local
/declare LootList string local
/call CheckCursor
/loot
/delay 3s ${Corpse.Open}
/doevents CantLoot
/if (${Target.ID}==${ALDontLoot} && ${Spawn[${ALDontLoot}].ID}) /squelch /alert add 25 id ${ALDontLoot}
/delay 3s ${Corpse.Items} || ${Target.ID}==${ALDontLoot}
/if (${Corpse.Open} && ${Corpse.Items}) {
/declare loottotal int local
:ALlootlag
/varset loottotal ${Corpse.Items}
/delay 1s ${loottotal}!=${Corpse.Items}
/if (${loottotal}!=${Corpse.Items}) /goto :ALlootlag
/for i 1 to ${loottotal}
/if (${Corpse.Item[${i}].ID} && !${Select[${Ini[Loot.ini,"${Corpse.Item[${i}].Name.Left[1]}","${Corpse.Item[${i}]}"]},Ignore,Keep,Destroy]}) {
/if (${Corpse.Item[${i}].NoDrop}) /ini "loot.ini" "${Corpse.Item[${i}].Name.Left[1]}" "${Corpse.Item[${i}]}" Ignore
/if (!${Corpse.Item[${i}].NoDrop}) /ini "loot.ini" "${Corpse.Item[${i}].Name.Left[1]}" "${Corpse.Item[${i}]}" Keep
}
/if (${Ini[Loot.ini,"${Corpse.Item[${i}].Name.Left[1]}","${Corpse.Item[${i}]}"].NotEqual[Destroy]} && !${Me.FreeInventory} && (!${FindItemCount[=${Corpse.Item[${i}].Name}]} || (${FindItemCount[=${Corpse.Item[${i}].Name}]} && ${Corpse.Item[${i}].Stackable} && !${Corpse.Item[${i}].FreeStack})) || (${Corpse.Item[${i}].Lore} && ${FindItem[${Corpse.Item[${i}]}].ID}) || ${Ini[Loot.ini,"${Corpse.Item[${i}].Name.Left[1]}","${Corpse.Item[${i}]}"].Equal[Ignore]}) /varset LootList ${LootList}${Corpse.Item[${i}]},
/if (${Ini[Loot.ini,"${Corpse.Item[${i}].Name.Left[1]}","${Corpse.Item[${i}]}"].Equal[Keep]} && (!${Corpse.Item[${i}].Lore} || !${FindItem[${Corpse.Item[${i}]}].ID}) && (${Me.FreeInventory} || (${FindItemCount[=${Corpse.Item[${i}].Name}]} && ${Corpse.Item[${i}].Stackable} && ${Corpse.Item[${i}].FreeStack}))) /call LootItem ${i} Keep Right
/if (${Ini[Loot.ini,"${Corpse.Item[${i}].Name.Left[1]}","${Corpse.Item[${i}]}"].Equal[Destroy]}) /call LootItem ${i} Destroy left
/next i
/if (${Corpse.Items}) {
/if (${ReportLoot} && ${LootList.Length}) /${LootChannel} ${LootList} left on corpse.
/if (${Target.ID}) /squelch /alert add 25 id ${Target.ID}
/varset CorpseRotTimer ${CorpseRotTime}
}
}
:clickdoneffs
/nomodkey /notify LootWnd LW_DoneButton leftmouseup
/delay 5s !${Corpse.Open}
/if (${Corpse.Open}) /goto :clickdoneffs
/return
Sub LootItem(int i,DoWhat,WhichButton)
/declare CorpseItemID int local ${Corpse.Item[${i}].ID}
/nomodkey /itemnotify loot${i} ${WhichButton}mouseup
/delay 5s ${Window[ConfirmationDialogBox].Open} || !${Corpse.Item[${i}].NoDrop}
/if (${Window[ConfirmationDialogBox].Open}) /nomodkey /notify ConfirmationDialogBox Yes_Button leftmouseup
/delay 5s ${Cursor.ID} || ${WhichButton.NotEqual[left]}
/if (${DoWhat.Equal[Destroy]} && ${Cursor.ID}==${CorpseItemID}) /destroy
/delay 3s !${Corpse.Item[${i}].ID}
/if (${Cursor.ID}) /call CheckCursor
/return
Sub LootMobs
/if (!${LootMobs} || ${SpawnCount[npc radius ${MobsTooClose} zradius 1 noalert ${AlertList}]} || !${SpawnCount[corpse radius ${CorpseRadius} zradius 100 noalert 25]} || ${Me.Combat} || (${Cursor.NoDrop} && !${Me.FreeInventory})) /return
/if (!${CorpseRotTimer}) /squelch /alert clear 25
/declare i int local
/declare CorpseList string local |
/for i 1 to ${SpawnCount[corpse radius ${CorpseRadius} zradius 100 noalert 25]}
/varset CorpseList ${CorpseList}${NearestSpawn[${i},corpse radius ${CorpseRadius} noalert 25].ID}|
/next i
/declare DeadCount int local ${SpawnCount[corpse radius ${CorpseRadius} zradius 100 noalert 25]}
/if (${Me.Mount.ID}) /dismount
/for i 1 to ${DeadCount}
/if (${Spawn[${CorpseList.Arg[${i},|]}].Deity.ID} && ${Spawn[${CorpseList.Arg[${i},|]}].ID}) /squelch /alert add 25 id ${Spawn[${CorpseList.Arg[${i},|]}].Deity.ID}
/if (${Spawn[${CorpseList.Arg[${i},|]}].ID} && ${Spawn[${CorpseList.Arg[${i},|]}].LineOfSight} && !${Spawn[${CorpseList.Arg[${i},|]}].Deity.ID}) {
/if (${Target.ID}!=${Spawn[${CorpseList.Arg[${i},|]}].ID}) /target id ${Spawn[${CorpseList.Arg[${i},|]}].ID}
/if (!${Me.Standing}) /stand
/delay 2s ${Target.ID}==${Spawn[${CorpseList.Arg[${i},|]}].ID} && ${Me.Standing}
/if (${Spawn[${CorpseList.Arg[${i},|]}].Distance}>10) /warp t loc ${Spawn[${CorpseList.Arg[${i},|]}].Y} ${Spawn[${CorpseList.Arg[${i},|]}].X}
/delay 10s ${Spawn[${CorpseList.Arg[${i},|]}].Distance}<10
/if (${Spawn[${CorpseList.Arg[${i},|]}].Distance}<15) /call LootCorpse
}
/doevents
/next i
/return
Sub Event_ALCantLoot
/varset ALDontLoot ${Target.ID}
/return
Sub CheckCursor
:ALauto_inv
/if (${Cursor.ID}) {
/if (${Cursor.NoDrop} && !${Me.FreeInventory}) /return
/timed 5 /autoinventory
/delay 2s !${Cursor.ID}
/goto :ALauto_inv
}
/return