WML problem weapon special - disable ZOC
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
WML problem weapon special - disable ZOC
I think there has been an ability like this somewhere, but I'm not sure and so I just decided to try and make on myself. Here's what I got pieced together so far, it almost works. (I got it to disable the ZOC at some point, but then restoring it didn't work out). Now it doesn't disable the ZOC, so I think the 2nd event is where the problem is at the moment.
Code: Select all
#define WEAPON_SPECIAL_DRACONIAN_STUN TYPE
[dummy]
id="draconian_stun_{TYPE}"
name= _ "Stun"
description= _ "Stun:
This attack disables ZOC with a succesful hit."
[/dummy]
[/specials]
[/attack]
[event]
id=draconian_stun_{TYPE}
name=attacker_hits
[filter_attack]
special=draconian_stun_{TYPE}
[/filter_attack]
[filter_second]
[not]
race=undead
[/not]
[not]
race=draconian_undead_spirit
[/not]
[not]
race=draconian_undead
[/not]
[not]
race=draconian_golem
[/not]
[/filter_second]
{STORE_UNIT_VAR x,y=$x2,$y2 zoc has_zoc}
{MODIFY_UNIT x,y=$x2,$y2 variables.real_zoc $has_zoc}
{MODIFY_UNIT x,y=$x2,$y2 variables.stunned yes}
{MODIFY_UNIT x,y=$x2,$y2 zoc no}
{CLEAR_VARIABLE has_zoc}
[/event]
[event]
name=side_turn
[store_unit]
[filter]
[filter_WML]
[variables]
stunned=yes
[/variables]
[/filter_WML]
[/filter]
variable=stunneds
kill=no
[/store_unit]
{FOREACH stunneds i}
{CLEAR_VARIABLE stunneds[$i].zoc}
{VARIABLE stunneds[$i].zoc stunneds[$i].variables.realzoc}
{CLEAR_VARIABLE stunneds[$i].variables.realzoc}
{CLEAR_VARIABLE stunneds[$i].variables.stunned}
{NEXT i}
{CLEAR_VARIABLE stunneds}
[/event]
[+attack]
[+specials]
#enddef
Re: WML problem weapon special - disable ZOC
mainline campaign Dead Water has units with a stun weapon special.
Re: WML problem weapon special - disable ZOC
Both your events will only trigger once.
Re: WML problem weapon special - disable ZOC
Oops I fixed that, but it still doesn't work. Well gotta go to sleep and figure this out tomorrow or something
Re: WML problem weapon special - disable ZOC
it is cooler to do this with a custom status effect.
Put this in your era or campaign file
this is the weapon special, put {EVENT_STUNNED} in an era or campaign file
Put this in your era or campaign file
Code: Select all
[event]
name=preload
first_time_only=no
[lua]
code=<<
local _ = wesnoth.textdomain "mydomain"
local old_unit_status = wesnoth.theme_items.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.stunned then
table.insert(s, { "element", {
image = "path for custom image",
tooltip = "Stunned: This unit has no ZOC until it's next turn."
} })
end
return s
end
>>
[/lua]
[/event]
Code: Select all
#define WEAPON_SPECIAL_DRACONIAN_STUN
[dummy]
id=draconian_stun
name= _ "Stun"
description= _ "Stun:
This attack disables ZOC with a succesful hit."
[/dummy]
#enddef
#define EVENT_STUNNED
[event]
name=attacker_hits
first_time_only=no
[filter_attack]
special=draconian_stun
[/filter_attack]
[filter_second]
[not]
race=undead
[/not]
[not]
race=draconian_undead_spirit
[/not]
[not]
race=draconian_undead
[/not]
[not]
race=draconian_golem
[/not]
[/filter_second]
[if]
###given that zoc can only equal 1 or 0 this is easier than storing variables
[variable]
name=second_unit.zoc
equals=1
[/variable]
[then]
{VARIABLE_OP second_unit.zoc value 0}
[unstore_unit]
variable=second_unit
text=_ "stunned" # wmllint: ignore
red,green,blue=150,80,50
[/unstore_unit]
{MODIFY_UNIT x,y=$x2,$y2 status.stunned yes}
[/then]
[/if]
[/event]
#side turn refresh is better for modifying units, sometimes side_turn modifications will be overridden after refresh.
[event]
name=side_turn_refresh
first_time_only=no
[store_unit]
[filter]
###if you want units to regain their ZOC on their own turn put side=$side_number
###as it stands they will regain their ZOC as soon as the damaging parties turn is over.
[filter_WML]
[status]
stunned=yes
[/status]
[/filter_WML]
[/filter]
variable=stunned_units
kill=no
[/store_unit]
{FOREACH stunned_units i}
{VARIABLE_OP stunned_units[$i].zoc value 1}
{VARIABLE_OP stunned_units[$i].status.stunned value no}
[unstore_unit]
variable=stunned_units[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stunned_units}
[/event]
#enddef
Re: WML problem weapon special - disable ZOC
Cool thanks. I tried this via copy pasting but couldn't get it to work, I think it's probably a bit too much for now to add any graphical overlays: D I mean the units don't have graphics either, but it would be very cool Really they're stored as 1 or 0? I thought it's "yes" "no" or *blank* like on the unit wml page? That does simplify things considerably
Re: WML problem weapon special - disable ZOC
It's a boolean value, so it should be stored as "yes" or "no".siddh wrote:Really they're stored as 1 or 0? I thought it's "yes" "no" or *blank* like on the unit wml page?
Why would it? (It's just replacing one symbol for another.)siddh wrote:That does simplify things considerably
Re: WML problem weapon special - disable ZOC
Because then there would be no *blank*JaMiT wrote:Why would it? (It's just replacing one symbol for another.)
Re: WML problem weapon special - disable ZOC
that must be new, I'm positive it used to be 0 means no ZOC and anything else means it does.JaMiT wrote:It's a boolean value, so it should be stored as "yes" or "no".siddh wrote:Really they're stored as 1 or 0? I thought it's "yes" "no" or *blank* like on the unit wml page?
Re: WML problem weapon special - disable ZOC
Baring that in mind try this.
Code: Select all
#define WEAPON_SPECIAL_DRACONIAN_STUN
[dummy]
id=draconian_stun
name= _ "Stun"
description= _ "Stun:
This attack disables ZOC with a succesful hit."
[/dummy]
#enddef
#define EVENT_STUNNED
[event]
name=attacker_hits
first_time_only=no
[filter_attack]
special=draconian_stun
[/filter_attack]
[filter_second]
[not]
race=undead
[/not]
[not]
race=draconian_undead_spirit
[/not]
[not]
race=draconian_undead
[/not]
[not]
race=draconian_golem
[/not]
[/filter_second]
[if]
[variable]
name=second_unit.zoc
not_equals=no
[/variable]
[then]
{VARIABLE_OP second_unit.zoc value no}
[unstore_unit]
variable=second_unit
text=_ "stunned" # wmllint: ignore
red,green,blue=150,80,50
[/unstore_unit]
{MODIFY_UNIT x,y=$x2,$y2 status.stunned yes}
[/then]
[/if]
[/event]
[event]
name=side_turn_refresh
first_time_only=no
[store_unit]
[filter]
[filter_WML]
[status]
stunned=yes
[/status]
[/filter_WML]
[/filter]
variable=stunned_units
kill=no
[/store_unit]
{FOREACH stunned_units i}
{VARIABLE_OP stunned_units[$i].zoc value yes}
{CLEAR_VARIABLE stunned_units[$i].status.stunned}
[unstore_unit]
variable=stunned_units[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stunned_units}
[/event]
#enddef
Last edited by Azeal on June 3rd, 2013, 11:19 am, edited 1 time in total.
Re: WML problem weapon special - disable ZOC
What I meant was that I just assumed it was like it's stored in the [unit_type] in which you can write zoc=no, zoc=yes or leave it blank, as in not write in zoc at all. And I didn't know the unit has either 0 or 1, which made it simpler than I thought it would be, but that of course was a change in my awareness of how this wml bit works, not a change in the way the WML actually works
Re: WML problem weapon special - disable ZOC
Well, even if that was a possibility, often phrasing your conditions in a good way prevents complications from slipping in. Let's see where the complications are in your code....siddh wrote:Because then there would be no *blank*JaMiT wrote:Why would it? (It's just replacing one symbol for another.)
Well, it's kind of tough to read because many lines are not indented. Focusing on just the lines that mention "zoc", you seem to have more complications arising from your approach, rather than whether or not a value can be blank. Specifically, I think (again, not carefully checked) your lines:
Code: Select all
{STORE_UNIT_VAR x,y=$x2,$y2 zoc has_zoc}
{MODIFY_UNIT x,y=$x2,$y2 variables.real_zoc $has_zoc}
{MODIFY_UNIT x,y=$x2,$y2 variables.stunned yes}
{MODIFY_UNIT x,y=$x2,$y2 zoc no}
{CLEAR_VARIABLE has_zoc}
{CLEAR_VARIABLE zoc} # This line is missing. You should clear this variable as well since it is not used elsewhere.
Code: Select all
{VARIABLE second_unit.variables.real_zoc $second_unit.has_zoc}
{VARIABLE second_unit.variables.stunned yes}
{VARIABLE second_unit.zoc no}
[unstore_unit]
variable=second_unit
[/unstore_unit]
text=
attribute to the [unstore_unit]
tag so the player gets some feedback as to what happened.One difference when storing the old value of
zoc
is that you could have the status apply to units without a zone of control, even though it would have no effect. I won't say "better" or "worse", but it is a different way to go. (Speaking of which -- do you have a filter to prevent stunned units from being stunned? If not, then hitting the unit twice with a stunning weapon could permanently remove the zone of control. With "permanent" meaning "until death or advancing".)__
Based on the changelog, it looks like the key has been a boolean value since (at least) version 1.5.2. Although, it may be that it was possible to get away with using "0" and "1" instead of "no"/"false" and "yes"/"true" until around version 1.9.0.Azeal wrote:that must be new, I'm positive it used to be 0 means no ZOC and anything else means it does.