Simplified concentration code
This commit is contained in:
parent
2707e9ad9d
commit
e5f8cd19ab
1 changed files with 10 additions and 15 deletions
|
@ -347,7 +347,8 @@
|
|||
# The revealing of the path is much easier done in lua. Thanks mattsc for the code!
|
||||
|
||||
[lua]
|
||||
code= <<
|
||||
code= <<
|
||||
local ai_helper = wesnoth.require "ai/lua/ai_helper.lua"
|
||||
local H = wesnoth.require "lua/helper.lua"
|
||||
local W = H.set_wml_action_metatable {}
|
||||
local delf = wesnoth.get_units { id = 'Delfador' }[1]
|
||||
|
@ -355,24 +356,18 @@
|
|||
local path = wesnoth.find_path(delf, sceptre_x, sceptre_y, {ignore_units = true, viewing_side = 0})
|
||||
_ = wesnoth.textdomain 'wesnoth-httt'
|
||||
|
||||
local dirs = { _"I sense the path to the sceptre is to the west of me.",
|
||||
_"I sense the path to the sceptre is to the north-west of me.",
|
||||
_"I sense the path to the sceptre is to the north of me.",
|
||||
_"I sense the path to the sceptre is to the north-east of me.",
|
||||
_"I sense the path to the sceptre is to the east of me.",
|
||||
local dirs = { _"I sense the path to the sceptre is to the east of me.",
|
||||
_"I sense the path to the sceptre is to the south-east of me.",
|
||||
_"I sense the path to the sceptre is to the south of me.",
|
||||
_"I sense the path to the sceptre is to the south-west of me." }
|
||||
_"I sense the path to the sceptre is to the south-west of me.",
|
||||
_"I sense the path to the sceptre is to the west of me.",
|
||||
_"I sense the path to the sceptre is to the north-west of me.",
|
||||
_"I sense the path to the sceptre is to the north of me.",
|
||||
_"I sense the path to the sceptre is to the north-east of me." }
|
||||
|
||||
local goal = { x = path[6][1], y = path[6][2] }
|
||||
|
||||
-- Go to square geometry
|
||||
local delf_y_sq = (delf.y * 2 - (delf.x % 2)) / 2.
|
||||
local goal_y_sq = (goal.y * 2 - (goal.x % 2)) / 2.
|
||||
|
||||
local angle = math.atan2( (goal_y_sq - delf_y_sq), (goal.x - delf.x) )
|
||||
angle = math.floor((angle / math.pi * 4 + 4.5) % 8 ) + 1
|
||||
|
||||
W.message{ speaker = 'Delfador', message= dirs[angle]}
|
||||
W.message{ speaker = 'Delfador', message= dirs[ai_helper.get_direction_index(delf, goal, 8, true)]}
|
||||
>>
|
||||
[/lua]
|
||||
[/event]
|
||||
|
|
Loading…
Add table
Reference in a new issue