SpellEffectAPIMoveUnit.lua 510 B

12345678910111213141516171819202122
  1. local BattleStackMoved = require("netpacks.BattleStackMoved")
  2. apply = function(targets)
  3. local n = #targets;
  4. assert(n == 2, "2 destinations required ".. n .." provided")
  5. local unitId = targets[1][2]
  6. assert(type(unitId) == "number", "Invalid unit id")
  7. local dest = targets[2][1]
  8. assert(type(dest) == "number", "Invalid destination hex")
  9. local pack = BattleStackMoved.new()
  10. pack:setUnitId(unitId)
  11. pack:setDistance(0)
  12. pack:setTeleporting(true)
  13. pack:addTileToMove(dest)
  14. SERVER:moveUnit(pack)
  15. end