How to use vector, I’m trying to let my paladin to stay in front of me and shield
do dis:
palaVec=Vector.subtract(hero.pos,enemyHero.pos)
if friend.type=="paladin":
hero.command(friend, "move", palaVec)
find enemyHero using a function or smthn
code
def onSpawn():
while True:
pet.moveXY(49, 33)
pet.shapeShift()
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
if enemy and enemy.type != 'sand-yak':
hero.scattershot(enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.gold >= hero.costOf('paladin'):
hero.summon('paladin')
paladins = hero.findByType("paladin",hero.findFriends())
for paladin in paladins:
if paladin.canCast('heal'):
hero.command(paladin, "cast", 'heal',hero)
else:
enemyHero = findStrongestEnemy()
palaVec = Vector.subtract(hero.pos, enemyHero.pos)
hero.command(paladin, "move", palaVec.pos)
hero.command(paladin, "shield")
for friend in hero.findFriends():
if friend.type != 'fake-peasant' and friend.type != 'paladin':
hero.command(friend, "defend", hero)
if hero.isReady("heal"):
hero.heal(hero)
hero.command(paladin, “move”, palaVec.pos)
do
if paladin.pos=palaVec: hero.command(paladin, "shield")
if that doesnt work, check ur enemy hero thing or smthnn idk
as peter’s wise words say, “i dont recommend putting 2 lines next to each other” or smthn like that
She don’t shield!
help
In which line there is an error?
Actually, the paladin doesn’t shield because the position can’t be exactly the vector.
It can be like 1 more or less.
Well, you need to check if there’s enemyHero
What if he died or he just casts invisibility/hide/phase-shift?
Nor errors now but can’t shield
Maybe just need a dir function or hero.dir ?
Help me!!!
with vector
If you use the vector without limit, it will move and move until it moves to the wall.
I don’t think you need that.
Hint: try using Vector.limit.
instead of subtract?