mrbot/utilities/NpcHelpers.iss

77 lines
2.2 KiB
Plaintext

#ifndef _mr_npc_helpers_
#define _mr_npc_helpers_
objectdef QuestHelpers
{
member:bool IsQuestPending()
{
return ${EQ2UIPage[PopUp,RewardPack].Child[button,RewardPack.ButtonComposite.Accept](exists)}
}
method AcceptQuest()
{
EQ2UIPage[PopUp,RewardPack].Child[button,RewardPack.ButtonComposite.Accept]:LeftClick
}
}
objectdef NpcHelpers
{
variable QuestHelpers QuestHelper
function GetQuestFromNpc(string npcName, string choices)
{
echo "NpcHelpers::GetQuestFromNpc[\"${npcName}\", \"${choices}\"]"
if ${npcName.Length} < 1
{
echo "Usage: GetQuestFromNpc <NPC Name> [comma separted string of dialog choices(optional)]"
return
}
Actor[Query, Name =- "${npcName}"]:DoubleClick
wait 5
variable int numChoices = 0
if ${choices.Length} > 0
{
numChoices:Set[${choices.Count[","]}]
numChoices:Inc
}
if ${numChoices} > 0
{
variable int idx
for (idx:Set[1]; ${idx} <= ${numChoices}; idx:Inc)
{
variable string choice
choice:Set[${choices.Token[${idx}, ","]}]
echo "choice: ${choice}"
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies]:SpewProperties
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies].Child[${choice}]:LeftClick
wait 5
}
}
else
{
variable int dialogOptionsTaken = 0;
do
{
echo "Clicking dialog option 1 for loop #${dialogOptionsTaken}"
dialogOptionsTaken:Inc
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies].Child[button,1]:LeftClick
wait 5
}
while !${RewardWindow(exists)} && ${dialogOptionsTaken} < 10
}
wait 5
if ${QuestHelper.IsQuestPending}
{
wait 5
QuestHelper:AcceptQuest
}
else
{
echo "Quest not offered"
return
}
}
}
#endif