def commandGriff(griff):
if enemy:
hero.command(griff, "attack", enemy)
else:
hero.command(griff, "move", {'x': 78, 'y': 40})
keep getting error Hero Placeholder need something to command
when run code
i would help, but i do not understand this
@enPointe77 @Eric_Tang?
Show full code please
oh okks (20charss____)
here @Rabbit
coors1 = [0, 0]
coors2 = [0, 0]
def moveTo(position, fast = True):
if(self.isReady("jump") and fast):
self.jumpTo(position)
else:
self.move(position)
summonTypes = ['griffin-rider']
def summonTroops():
type = summonTypes[len(self.built)%len(summonTypes)]
if self.gold > self.costOf(type):
self.summon(type)
def commandGriff(griff):
if enemy:
hero.command(griff, "attack", enemy)
else:
hero.command(griff, "move", {'x': 78, 'y': 40})
def commandTroops():
for index, friend in enumerate(self.findFriends()):
if chieftain and friend.type != 'paladin':
continue
if witch and friend.type != 'paladin':
continue
if chieftain and chieftain.pos.x<57 and chieftain.pos.x>43:
self.command(friend, "move", {'x':25, 'y':48})
elif not chieftain and friend.pos.x<40:
self.command(friend, "move", {'x':51, 'y':51})
elif friend.type == 'paladin':
CommandPaladin(friend)
elif friend.type == 'soldier':
if friend.pos.y>30:
CommandSoldier(friend)
else:
KillRobots(friend)
else:
CommandArcher(friend)
def CommandPaladin(paladin):
if(paladin.canCast("heal") and not chieftain):
target = lowestHealthFriend()
if target:
self.command(paladin, "cast", "heal", target)
elif(paladin.health<100):
self.command(paladin, "shield")
else:
if witch:
self.command(paladin, "attack", witch)
elif(chieftain):
self.command(paladin, "attack", chieftain)
else:
self.command(paladin, "move", {'x':78, 'y':40})
def CommandSoldier(soldier):
if witch:
self.command(soldier, "attack", witch)
else:
self.command(soldier, "move", {'x':78, 'y':40})
def CommandArcher(soldier):
if witch:
self.command(soldier, "attack", witch)
else:
self.command(soldier, "move", {'x':78, 'y':40})
def KillRobots(soldier):
robot = self.findNearest(self.findEnemies())
if robot:
self.command(soldier, "attack", robot)
def lowestHealthFriend():
lowestHealth = 99999
lowestFriend = None
friends = self.findFriends()
for friend in friends:
if friend.health < lowestHealth and friend.health < friend.maxHealth:
lowestHealth = friend.health
lowestFriend = friend
return lowestFriend
def RunFrom():
missiles = self.findEnemyMissiles()
missle = self.findNearest(missiles)
if len(missiles)>0:
coors1[0] = missle.pos.x
coors1[1] = missle.pos.y
y = findTheY(coors1[0], coors2[0], coors1[1], coors2[1], self.pos.x)
if y >15:
moveTo({'x':self.pos.x, 'y':10}, False)
else:
moveTo({'x':self.pos.x, 'y':20}, False)
coors2[0] = coors1[0]
coors2[1] = coors1[1]
def findTheY(x1, x2, y1, y2, x):
if(y2!=y1):
y = (x - x1)/(x2 - x1)*(y2 - y1) + y1
else:
y = y1
return y
def findTheMiddle(pos1, pos2):
return {'x':(pos1.x+pos2.x)/2,'y':(pos1.y+pos2.y)/2}
while True:
#self.say(self.findEnemies()[0].type)
witch = self.findNearest(self.findByType('witch'))
chieftain = self.findNearest(self.findByType('chieftain'))
griff = hero.findByType("griffin-rider")
enemy = hero.findNearest(hero.findByType("robot-walker"))
if witch or chieftain:
RunFrom()
summonTroops()
commandGriff(griff)
commandTroops()
You didn’t define griff.
look at the bottom of the code
i already define it
Define in in your griff function.
oh ok _____(20chars)
ah thankyou i finnaly not gettin any error
sorry! i get one more error after that
here i send my code again, i get error and it said ArgumentError: Target a unit.
and Hero Placeholder need something to command
coors1 = [0, 0]
coors2 = [0, 0]
def moveTo(position, fast = True):
if(self.isReady("jump") and fast):
self.jumpTo(position)
else:
self.move(position)
summonTypes = ['griffin-rider']
def summonTroops():
type = summonTypes[len(self.built)%len(summonTypes)]
if self.gold > self.costOf(type):
self.summon(type)
def commandGriff(enemy):
griff = hero.findNearest(hero.findByType("griffin-rider"))
enemy = hero.findByType("robot-walker")
if enemy:
hero.command(griff, "attack", enemy)
else:
hero.command(griff, "move", {'x': 78, 'y': 40})
def commandTroops():
for index, friend in enumerate(self.findFriends()):
if chieftain and friend.type != 'paladin':
continue
if witch and friend.type != 'paladin':
continue
if chieftain and chieftain.pos.x<57 and chieftain.pos.x>43:
self.command(friend, "move", {'x':25, 'y':48})
elif not chieftain and friend.pos.x<40:
self.command(friend, "move", {'x':51, 'y':51})
elif friend.type == 'paladin':
CommandPaladin(friend)
elif friend.type == 'soldier':
if friend.pos.y>30:
CommandSoldier(friend)
else:
KillRobots(friend)
else:
CommandArcher(friend)
def CommandPaladin(paladin):
if(paladin.canCast("heal") and not chieftain):
target = lowestHealthFriend()
if target:
self.command(paladin, "cast", "heal", target)
elif(paladin.health<100):
self.command(paladin, "shield")
else:
if witch:
self.command(paladin, "attack", witch)
elif(chieftain):
self.command(paladin, "attack", chieftain)
else:
self.command(paladin, "move", {'x':78, 'y':40})
def CommandSoldier(soldier):
if witch:
self.command(soldier, "attack", witch)
else:
self.command(soldier, "move", {'x':78, 'y':40})
def CommandArcher(soldier):
if witch:
self.command(soldier, "attack", witch)
else:
self.command(soldier, "move", {'x':78, 'y':40})
def KillRobots(soldier):
robot = self.findNearest(self.findEnemies())
if robot:
self.command(soldier, "attack", robot)
def lowestHealthFriend():
lowestHealth = 99999
lowestFriend = None
friends = self.findFriends()
for friend in friends:
if friend.health < lowestHealth and friend.health < friend.maxHealth:
lowestHealth = friend.health
lowestFriend = friend
return lowestFriend
def RunFrom():
missiles = self.findEnemyMissiles()
missle = self.findNearest(missiles)
if len(missiles)>0:
coors1[0] = missle.pos.x
coors1[1] = missle.pos.y
y = findTheY(coors1[0], coors2[0], coors1[1], coors2[1], self.pos.x)
if y >15:
moveTo({'x':self.pos.x, 'y':10}, False)
else:
moveTo({'x':self.pos.x, 'y':20}, False)
coors2[0] = coors1[0]
coors2[1] = coors1[1]
def findTheY(x1, x2, y1, y2, x):
if(y2!=y1):
y = (x - x1)/(x2 - x1)*(y2 - y1) + y1
else:
y = y1
return y
def findTheMiddle(pos1, pos2):
return {'x':(pos1.x+pos2.x)/2,'y':(pos1.y+pos2.y)/2}
while True:
#self.say(self.findEnemies()[0].type)
witch = self.findNearest(self.findByType('witch'))
chieftain = self.findNearest(self.findByType('chieftain'))
enemy = hero.findByType("robot-walker")
if witch or chieftain:
RunFrom()
summonTroops()
commandGriff(enemy)
commandTroops()
I’m at the very beginning of mountain. Certainly not at this level of coding, yet. lol
Try putting the function of this line before as a first step.
oh, i wasn’t sure
i just thought you were
How do i fix this error?
Still, get the error.
Try adding and griff
and making this elif griffin:
Get same error…(20chars)