Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Phantom Errors
#19
Look at this code.......


	def MyGetEnemyName (self):
		me=Bladex.GetEntity(self.Name)
		char=Bladex.GetEntity("Player1")
		if not self.AttackOnSight:
    	return None
	  if not self.NameOfEnemy or Bladex.GetEntity(self.NameOfEnemy).Life <=0:
      pjp = me.Position
			enemyList=[]
		  pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
			
			for ename in Bladex.GetEnemiesVisibleFrom(pjp,30000,pj_dir,0.0):
				ene=Bladex.GetEntity(ename)
				if ene.Person:
					if self.IsValidEnemy(ene):
            enemyList.append(ene.Name)
          if me.CanISee(char):	
            enemyList.append("Player1")
        if len(enemyList) == 0:
          return None
        enemyList.sort(self.ChooseCanISeeNearest)
        self.NameOfEnemy=enemyList[0]
                   	
		enemy=Bladex.GetEntity(self.NameOfEnemy)
    me.SetEnemy(enemy)
    self.ChaseCount=0
		return self.NameOfEnemy			
					
It's all over the place. Cry Trouble is, in the editor it appears correct. Huh

This is how it should look......


	def MyGetEnemyName (self):
		me=Bladex.GetEntity(self.Name)
		char=Bladex.GetEntity("Player1")
		if not self.AttackOnSight:
			return None
		if not self.NameOfEnemy or Bladex.GetEntity(self.NameOfEnemy).Life <=0:
			pjp = me.Position
			enemyList=[]
			pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
			
			for ename in Bladex.GetEnemiesVisibleFrom(pjp,30000,pj_dir,0.0):
				ene=Bladex.GetEntity(ename)
				if ene.Person:
					if self.IsValidEnemy(ene):
						enemyList.append(ene.Name)
					if me.CanISee(char):	
						enemyList.append("Player1")
				if len(enemyList) == 0:
					return None
				enemyList.sort(self.ChooseCanISeeNearest)
				self.NameOfEnemy=enemyList[0]
		enemy=Bladex.GetEntity(self.NameOfEnemy)           
		me.SetEnemy(enemy)
		self.ChaseCount=0
		return self.NameOfEnemy			
I cut each line in turn and set the cursor to the left margin. Did the required number of tabs and pasted
it back in. It works fine now. This process could get a wee bit tedious though. Sick

And I might write code and it may be that it raises no errors, but how can I be sure it hasn't shifted a
clause sideways and upset my logic???????? I can't keep checking it on this page.
Reply


Messages In This Thread
Phantom Errors - by prospero - Oct-29-2019, 12:59 AM
RE: Phantom Errors - by buran - Oct-29-2019, 02:18 AM
RE: Phantom Errors - by prospero - Oct-29-2019, 04:02 AM
RE: Phantom Errors - by buran - Oct-29-2019, 04:50 AM
RE: Phantom Errors - by prospero - Oct-29-2019, 05:20 PM
RE: Phantom Errors - by prospero - Oct-30-2019, 05:16 PM
RE: Phantom Errors - by snippsat - Oct-30-2019, 05:42 PM
RE: Phantom Errors - by nilamo - Oct-30-2019, 06:55 PM
RE: Phantom Errors - by prospero - Oct-31-2019, 08:34 PM
RE: Phantom Errors - by ichabod801 - Oct-31-2019, 08:44 PM
RE: Phantom Errors - by prospero - Oct-31-2019, 09:40 PM
RE: Phantom Errors - by ichabod801 - Oct-31-2019, 10:01 PM
RE: Phantom Errors - by prospero - Oct-31-2019, 11:59 PM
RE: Phantom Errors - by prospero - Nov-01-2019, 02:27 AM
RE: Phantom Errors - by nilamo - Nov-01-2019, 03:24 PM
RE: Phantom Errors - by prospero - Nov-02-2019, 02:23 AM
RE: Phantom Errors - by newbieAuggie2019 - Nov-02-2019, 03:18 AM
RE: Phantom Errors - by prospero - Nov-02-2019, 05:32 PM
RE: Phantom Errors - by prospero - Nov-02-2019, 06:42 PM
RE: Phantom Errors - by ichabod801 - Nov-02-2019, 09:40 PM
RE: Phantom Errors - by prospero - Nov-03-2019, 03:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Attibute Error: Two methods in a class, one I can reach, the other not (phantom file? GaryKuipers 4 3,210 Aug-28-2018, 02:32 PM
Last Post: GaryKuipers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020