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

foreach(Creature aCreature in GetCreatures()) not looping through all

Status
Not open for further replies.

czzplnm

Member
Joined
Jun 18, 2012
Messages
88
Reaction score
0
foreach(Creature aCreature in GetCreatures()) not looping through all*SOLVED*

*SOLVED* SHOULD HAVE USED CONTINUE >_<


I am working on a monster targeting function. It is not looping through the entire
creaturesList is a List<creature> of getCreatures;
as I loop through all nearby mobs(there are 25) it gets stuck repeating here

PHP:
                    //no mob selected
                    if (selectedCreature == null)
                    {
                        if (isDebug)
                            Log("null SelectedCreateure " + totalNearbyMobs.ToString() + " Total " + creaturesList.Count.ToString());

                        selectedCreature = aCreature;
                        return;
                 
                    }


I am returning so it moves onto creature 2, but it never does. It is returning back to PluginRun infinite loop. WHY?

PHP:
foreach (Creature aCreature in creaturesList)
                {
                    //locate the closest character, skip others
                    totalNearbyMobs++;

                    //creature is in a fight, ignore
                    if (aCreature.inFight)
                    {
                        if (isDebug)
                            Log("Creature in fight, returning");
                        return;
                    }

                 
                    //no mob selected
                    if (selectedCreature == null)
                    {
                        if (isDebug)
                            Log("null SelectedCreateure " + totalNearbyMobs.ToString() + " Total " + creaturesList.Count.ToString());

                        selectedCreature = aCreature;
                        return;
                 
                    }

                    //check to see which two monsters is closer
                    if (!isCloserCreature(selectedCreature, aCreature))
                    {
                        if (isDebug)
                            Log("is not isCloserCreature");
                        return;
                    }

                    //set selected created
                    selectedCreature = aCreature;

                    if (isDebug)
                        Log("Selected a creature internally.");

                }
 
Last edited:
Status
Not open for further replies.
Back
Top