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

isEnemy

theonn

Member
Joined
Nov 3, 2014
Messages
80
Reaction score
6
It seems this method is failing for me? always seems to return false now. any clues?
 
It seems this method is failing for me? always seems to return false now. any clues?

Here are 3 methods I wrote to find targets. I assume you are mob grinding.


Code:
            public Creature FindTarget(){
//Creature a temp null creature
                Creature temp = null;
//Get creatures only when they meet my requirements 
                foreach(var x in getCreatures().Where(x => validTarget(x)).ToList()){
//If this target is dead, not attackable or not an enemy continue to the next mob/
                    if(!isAttackable(x) || !isEnemy(x) || !x.isAlive()){
                        continue;
                    }
                    if(temp == null){        
                        temp = x;
//Find the closest
                        }else if(x.dist(me) < temp.dist(me)){
                            temp = x;
                        }
                    }
                    return temp;            
                }
I created a separate method to make things cleaner and easier to edit.
Also this "validation" can be used in other/future methods.
Code:
                    public bool validTarget(Creature x){     
//Creature is not a player
//I have first tag or no one has tag
//Other situational cases. IE Ignore "Bunker" Mobs or the flying mobs. 
                        if(x.type != BotTypes.Player && !x.name.Contains("Bunker") && !x.name.Contains("beak") && (x.firstHitter == null || x.firstHitter == me)){  
                            return true;
                        }
                        return false;
                    }

Lastly is just an override for out of sight error handling.

It ignore the creature you pass it.
Code:
public Creature FindTarget(Creature bad){
                    Creature temp = null;
                    foreach(var x in getCreatures().Where(x => validTarget(x)).ToList()){
                        if(!isAttackable(x) || !isEnemy(x) || !x.isAlive() || x == bad){
                            continue;
                        }
                        if(temp == null){        
                            temp = x;
                            }else if(x.dist(me) < temp.dist(me)){
                                temp = x;
                            }
                        }
                        return temp;            
                    }
 
Last edited:
i actually, did more testint and found out that isEnemy is working properly.... the problem was my code.

i did write my own isEnemy code and had the same issue.... it was a fault on my part.... (was overrithing the check)
 
i actually, did more testint and found out that isEnemy is working properly.... the problem was my code.

i did write my own isEnemy code and had the same issue.... it was a fault on my part.... (was overrithing the check)


Alright good to hear!
 
Back
Top