What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Dev Help Needed

protopally

Member
Joined
Jan 15, 2010
Messages
391
Reaction score
8
ok my issue is simple i need to get the status of a quest for example when a quest is in you quests log with the (Complete) tag next to it have all sorts any ideas would be appreciated and much gratitude to anyone who can provide a working code sample.

Thanks in advance.
 
PHP:
//to make sure every header is expanded in quest log
Lua.DoString("ExpandQuestHeader(0)");

//number of values in quest log (includes headers like "Durator")
int QuestCount = Lua.GetReturnVal("return select(1, GetNumQuestLogEntries())", 0);

for (int i = 1; i <= QuestCount; i++)
{
    List<string> QuestInfo = Lua.LuaGetReturnValue("return GetQuestLogTitle(" + i + ")", "raphus.lua");
    
    //pass if the index isHeader or isCollapsed
    if (QuestInfo[4] == "1" || QuestInfo[5] == "1")
        continue;

    string QuestStatus = null;
    if (QuestInfo[6] == "1")
        QuestStatus = "completed";
    else if (QuestInfo[6] == "-1")
        QuestStatus = "failed";
    else 
        QuestStatus = "in progress";
        
    Log("Quest Name: {0} [index:{1}] [level:{2}] [tag: {3}] [quest id: {4}] is {5}", QuestInfo[0], i, QuestInfo[1], QuestInfo[2], QuestInfo[8], QuestStatus);                    
}
questTitle, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily, questID = GetQuestLogTitle(questLogID);</int>
 
Last edited:
Code:
var
 quests = ObjectManager.Me.QuestLog.GetAllQuests();
</playerquest>
 
Code:
private static bool IsQuestCompleted(uint questId)
{
    return StyxWoW.Me.QuestLog.GetAllQuests().FirstOrDefault(quest => quest.Id == questId && quest.IsCompleted) != null;
}
 
Last edited:
PHP:
//to make sure every header is expanded in quest log
Lua.DoString("ExpandQuestHeader(0)");

//number of values in quest log (includes headers like "Durator")
int QuestCount = Lua.GetReturnVal<int>("return select(1, GetNumQuestLogEntries())", 0);

for (int i = 1; i <= QuestCount; i++)
{
    List QuestInfo = Lua.LuaGetReturnValue("return GetQuestLogTitle(" + i + ")", "raphus.lua");
    
    //pass if the index isHeader or isCollapsed
    if (QuestInfo[4] == "1" || QuestInfo[5] == "1")
        continue;

    string QuestStatus = null;
    if (QuestInfo[6] == "1")
        QuestStatus = "completed";
    else if (QuestInfo[6] == "-1")
        QuestStatus = "failed";
    else 
        QuestStatus = "in progress";
        
    Log("Quest Name: {0} [index:{1}] [level:{2}] [tag: {3}] [quest id: {4}] is {5}", QuestInfo[0], i, QuestInfo[1], QuestInfo[2], QuestInfo[8], QuestStatus);                    
}
questTitle, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily, questID = GetQuestLogTitle(questLogID);</string>

thats what happens when you don't have enough info about the API and take the long way around :)
 
Hi thanks all nesox could you explain as fistordefault dont exist and yous looks like the easyest way to do it but thatnks to all i may have to fall back to the long way round if i cant get yous to work.
 
use System.Linq for FirstOfDefault()
 
clear your private messages. your inbox is full
 
PHP:
Dictionary<WoWUnit, double> mobList = new Dictionary<WoWUnit, double>();
List<KeyValuePair<WoWUnit, double>> sortedmobList = new List<KeyValuePair<WoWUnit, double>>();

// Adds <unit, unit.distance> to mobList dictionary
foreach (WoWUnit unit in ObjectManager.GetObjectsOfType<WoWUnit>(false))
{
    if (unit.Guid != Me.Guid && !unit.IsFriendly && unit.Attackable && unit.InLineOfSight)
    {
        mobList.Add(unit, unit.Distance);
    }
}

// Convert mobList dictionary to sortedmobList List
if (mobList.Count > 0)
{
    sortedmobList = new List<KeyValuePair<WoWUnit, double>>(mobList);
}

// This sorts the List by comparing pair.Values (which is the unit.Distance in <unit, unit.Distance>)
// Lowest value goes to index 0
if (sortedmobList.Count > 1)
{
    sortedmobList.Sort(delegate(KeyValuePair<WoWUnit, double> firstPair, KeyValuePair<WoWUnit, double> nextPair)
            { return firstPair.Value.CompareTo(nextPair.Value);});
}    

if (MeCheck && !Me.Combat && sortedmobList.Count > 0)
{
    if (Me.CurrentTarget == null)
    {
        // Target the closest by calling index 0 of sortedmobList
        sortedmobList[0].Key.Target();
        Thread.Sleep(100);
    }
    SequenceManager.CallSequenceExecutor(Sequence.Pull);
    return;
}
nesox will probably come up with a linq version of this code since he loves it :)
 
PHP:
Dictionary<WoWUnit, double> mobList = new Dictionary<WoWUnit, double>();
List<KeyValuePair<WoWUnit, double>> sortedmobList = new List<KeyValuePair<WoWUnit, double>>();

// Adds <unit, unit.distance> to mobList dictionary
foreach (WoWUnit unit in ObjectManager.GetObjectsOfType<WoWUnit>(false))
{
    if (unit.Guid != Me.Guid && !unit.IsFriendly && unit.Attackable && unit.InLineOfSight)
    {
        mobList.Add(unit, unit.Distance);
    }
}

// Convert mobList dictionary to sortedmobList List
if (mobList.Count > 0)
{
    sortedmobList = new List<KeyValuePair<WoWUnit, double>>(mobList);
}

// This sorts the List by comparing pair.Values (which is the unit.Distance in <unit, unit.Distance>)
// Lowest value goes to index 0
if (sortedmobList.Count > 1)
{
    sortedmobList.Sort(delegate(KeyValuePair<WoWUnit, double> firstPair, KeyValuePair<WoWUnit, double> nextPair)
            { return firstPair.Value.CompareTo(nextPair.Value);});
}    

if (MeCheck && !Me.Combat && sortedmobList.Count > 0)
{
    if (Me.CurrentTarget == null)
    {
        // Target the closest by calling index 0 of sortedmobList
        sortedmobList[0].Key.Target();
        Thread.Sleep(100);
    }
    SequenceManager.CallSequenceExecutor(Sequence.Pull);
    return;
}
nesox will probably come up with a linq version of this code since he loves it :)

That's just..
Code:
WoWUnit closest = null;
float closestDist = float.MaxValue;
foreach (WoWUnit u in ObjectManager.GetObjectsOfType<WoWUnit>())
{
  if (!u.Attackable || u.IsFriendly)
    continue;

  float dist = u.DistanceSqrd;
  if (dist < closestDist && u.InLineOfSight)
  {
    closestDist = dist;
    closest = u;
  }
}
 
thanks guys finally got some assistance and it feels great been asking and not getting answers now im glad i stuck with it :)
 
Congrats mate it way be long winded but it works nesox's didn't now i can figure out how to adapt it to give it an id and return a bool so i can use it for conditional checks :) my quest doer plugin wil be alot more streamlined now :).
 
Back
Top