How to use Vector(Harrowland)

How to use vector, I’m trying to let my paladin to stay in front of me and shield

do dis:

if friend.type=="paladin":
    hero.command(friend, "move", palaVec)

find enemyHero using a function or smthn

Not working:

and error:

When I change into hero.command(paladin, "move", palaVec.pos) I thought it would be better but:


def onSpawn():
    while True:
        pet.moveXY(49, 33)
def findStrongestEnemy():
    strongest = None
    strongestHealth = 0
    enemies = hero.findEnemies()
    for enemy in enemies:
        if > strongestHealth:
            strongestHealth =
            strongest = enemy
    return strongest
pet.on("spawn", onSpawn)
while True:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type != 'sand-yak':
        if hero.isReady("chain-lightning"):
            hero.cast("chain-lightning", enemy)
    if >= hero.costOf('paladin'):
    paladins = hero.findByType("paladin",hero.findFriends())
    for paladin in paladins:
        if paladin.canCast('heal'):
            hero.command(paladin, "cast", 'heal',hero)
            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.command(paladin, “move”, palaVec.pos)
if paladin.pos=palaVec: hero.command(paladin, "shield")

1 Like

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

then :

She don’t shield! :sob:

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.

paladin just don’t shield and error:

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 ?

I’m amost there:

but my paladin move the wrong directon :laughing:

Help me!!! :pray:
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?