极客战记-滑走
1、角色

2、装备

3、目标

4、默认代码

5、提示



6、翻译


7、代码
# Move to the red X mark while avoiding the yaks.
# use Vector.normalize(vector1) to create a vector in the same direction as vector1, but with a distance of 1
# use Vector.multiply(vector1, X) to create a vector in the same direction as vector1, but with its distance multiplied by X
# The point you want to get to.
goalPoint = Vector(78, 34)
while True:
# 这会创建一个向量,将您移动10米到达目标点
# 首先,创建一个矢量从你的英雄向目标点。
goal = Vector.subtract(goalPoint, hero.pos)
# 然后,将其归一化为1m距离向量。
goal = Vector.normalize(goal)
# 最后,将1m矢量乘以10,得到一个10m长的矢量。
goal = Vector.multiply(goal, 10)
# 为了避免牦牛,如果你距离牦牛10米以内,你应该远离它。
yak = hero.findNearest(hero.findEnemies())
distance = hero.distanceTo(yak)
if distance < 10:
# 首先,创建一个从耗牛向你的矢量
goal1 = Vector.subtract(hero.pos, yak.pos)
# 现在使用Vector.normalize和Vector.multiply使它长10米
goal1 = Vector.normalize(goal1)
goal1 = Vector.multiply(goal1, 10)
# 一旦你有了距离牦牛10米的矢量,使用Vector.add将它添加到你的目标矢量!
goal = Vector.add(goal,goal1)
pass
# 最后,通过将目标向量添加到当前位置来确定移动的位置。
moveToPos = Vector.add(hero.pos, goal)
hero.move(moveToPos)

8、运行
