I need help for casting a shield when a enemy shoots a ball at me.
What do you mean??? You use Something like this
if hero.fire > 6:
hero.cast('fire-shield')
Hi Chicken Master! I want to know how to cast the right shield when my enemy casts a ball at me. Because there is 3 different mana types, i want to know how to check the ball’s mana type to summon the right shield.
Hmmm maybe something like
if fire
cast water
if water
cast earth
if earth
cast fire
I will try that. 20 chars
If it helps pls mark my post as solution!
Yeah, it should work…
hero.findEnemyMissiles()
opponent = hero.getEnemyHero()
if opponent.Mana.type == "earth":
hero.cast("fire-shield")
this is my code it says type is undefined.
Try this code:
enFire = 1
enWater = 1
enEarth = 1
def findBall():
enHero = hero.getEnemyHero()
fire = enHero.fire
water = enHero.water
earth = enHero.earth
if enHero:
if enFire-fire > 1:
return “water”
elif enWater-water > 1:
return “earth”
elif enEarth-earth > 1:
return “fire”
else:
return “no”
global enFire
enFire = fire
global enWater
enWater = water
global enEarth
enEarth = earth
while True:
enHero = hero.getEnemyHero()
hero.chooseItem = chooseMana
ball = findBall()
if not ball == “no”:
if hero.water >= 3 and ball == “water” :
hero.cast(“water-shield”)
elif hero.earth >= 3 and ball == “earth”:
hero.cast(“earth-shield”)
elif hero.fire >= 3 and ball == “fire”:
hero.cast(“fire-shield”)
Sooo i tried that and this popped up
thx for the help btw
Hmmm try this
oldfire = enemy.fire
oldwater = enemy.water
oldearth = enemy.earth
i = 0
while True:
if i == 5: break
i += 1
if oldfire>enemy.fire+5:
hero.cast("water-shield")
if oldwater>enemy.water+5:
hero.cast("earth-shield")
if oldearth>enemy.earth+5:
hero.cast("fire-sheild")
This one should show no error.
Does it work? If so pls mark as solution!
It sorta just stands there. But no bug.
Check this topic:
K. Should i close this topic?
Mark as my post as a solution if that topic helps, and once marked the topic will close.
The problem is that it’s for the other way around. its for casting the right type missile to counter the opponent’s shield.
Then change it around! It is not too hard. So if enemy fireblast hero.cast water shield
Thanks for your help! And this is my code. def collectHandler(data):
unit = data.target
while True:
if unit.item:
unit.bring()
else:
fruit = unit.findNearestFruit()
if fruit:
unit.pick(fruit)
hero.spawnCollector()
hero.spawnCollector()
enemy = hero.getEnemyHero()
while True:
shield = enemy.getActiveShield()
if shield and shield.mana == "water":
hero.cast("water-arrow")
elif shield and shield.mana == "earth":
hero.cast("fire-arrow")
elif shield and shield.mana == "fire":
hero.cast("water-arrow")
elif hero.getTotalMana("fire") >= 15 and hero.getTotalMana("water") >= 6:
hero.cast("fire-ball")
hero.cast("water-arrow")
hero.cast("water-arrow")
elif hero.getTotalMana("earth") >= 3:
hero.cast("earth-arrow")
missile = hero.findEnemyMissiles()
if missile and missile.mana == "water":
hero.cast("earth-shield")
if missile and missile.mana == "earth":
hero.cast("fire-shield")
if missile and missile.mana == "fire":
hero.cast("water-shield")
elif len(hero.findMyCollectors()) < 4 and hero.time < 90:
hero.spawnCollector()