Added the concentration mechanic to SoF. Many thanks to mattsc and vultraz for helping me with the code.

This commit is contained in:
Bär Halberkamp 2013-11-30 14:31:12 +01:00
parent b6692d2471
commit 2dc2b0acfe
2 changed files with 134 additions and 15 deletions

View file

@ -83,6 +83,8 @@
bonus=yes
carryover_percentage=40
[/gold_carryover]
note= _ "If Delfador rests, he can concentrate on the location of the Sceptre of Fire."
[/objectives]
{SOF_TERRAIN_MASK}
@ -132,6 +134,8 @@
{NEXT i}
{CLEAR_VARIABLE adjacent_to_starting_loc}
{VARIABLE moved_too_close false}
[/event]
[event]
@ -235,20 +239,135 @@
terrain=Uu^Ii
[/terrain]
#
# Future capability, once I figure out how to access
# the scepter's random location and if this still
# sounds like a good idea.
#
# [message]
# id=Delfador
# message= _ "I think... I think if I were to concentrate a bit I could tell you where it is."
# [/message]
# [message]
# speaker=narrator
# image="wesnoth-icon.png"
# message= _ "If Delfador rests, he can concentrate on the location of the Sceptre of Fire."
# [/message]
[message]
speaker=Delfador
message= _ "I think... I think if I were to concentrate a bit I could tell you where it is."
[/message]
[message]
speaker=narrator
image="wesnoth-icon.png"
message= _ "If Delfador rests, he can concentrate on the location of the Sceptre of Fire."
[/message]
[/event]
[event]
name=side 1 turn end
first_time_only=no
[store_unit]
[filter]
id=Delfador
[/filter]
kill=no
variable=delfador_moves
[/store_unit]
[if]
{VARIABLE_CONDITIONAL delfador_moves.moves numerical_equals $delfador_moves.max_moves}
{VARIABLE_CONDITIONAL moved_too_close boolean_equals false}
[then]
[floating_text]
[filter]
id=Delfador
[/filter]
text= _ "Concentrating"
[/floating_text]
{VARIABLE concentrating true}
[/then]
[else]
{VARIABLE concentrating false}
[/else]
[/if]
{CLEAR_VARIABLE delfador_moves}
[/event]
[event]
name=moveto
[filter]
[filter_location]
x,y=$scepter_x,$scepter_y
radius=6
[/filter_location]
side=1
[/filter]
[message]
speaker=Delfador
message= _ "I sense we are quite near the Sceptre; in fact, we should be able to see it right about now..."
[/message]
[objectives]
side=1
[objective]
description= _ "Capture the Sceptre of Fire with Konrad or Lisar"
condition=win
[/objective]
[objective]
description= _ "Death of Konrad"
condition=lose
[/objective]
[objective]
description= _ "Death of Delfador"
condition=lose
[/objective]
[objective]
description= _ "Death of Lisar"
condition=lose
[/objective]
[objective]
description= _ "Death of Kalenz"
condition=lose
[/objective]
{TURNS_RUN_OUT}
[gold_carryover]
bonus=yes
carryover_percentage=40
[/gold_carryover]
[/objectives]
{VARIABLE moved_too_close true}
[/event]
[event]
name=victory
{CLEAR_VARIABLE concentrating,moved_too_close}
[/event]
[event]
name=side 1 turn refresh
first_time_only=no
[filter_condition]
{VARIABLE_CONDITIONAL concentrating boolean_equals true}
[/filter_condition]
# The revealing of the path is much easier done in lua. Thanks mattsc for the code!
[lua]
code= <<
local H = wesnoth.require "lua/helper.lua"
local W = H.set_wml_action_metatable {}
local delf = wesnoth.get_units { id = 'Delfador' }[1]
local sceptre_x, sceptre_y = wesnoth.get_variable('scepter_x'), wesnoth.get_variable('scepter_y')
local path = wesnoth.find_path(delf, sceptre_x, sceptre_y, {ignore_units = true, viewing_side = 0})
_ = wesnoth.textdomain 'wesnoth-httt'
local dirs = { _"west", _"north-west", _"north", _"north-east", _"east", _"south-east", _"south", _"south-west" }
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= "I sense the path to the sceptre is to the " .. dirs[angle] .. " of me."}
>>
[/lua]
[/event]
#

View file

@ -35,7 +35,7 @@
image="units/konrad-fighter.png:50"
[/frame]
[frame]
image="units/konrad-fighter-attack-[1~2].png[150,100]"
image="units/konrad-fighter-attack-[1~2].png:[150,100]"
[/frame]
[frame]
image="units/konrad-fighter.png:50"