How to remove an attack ?

The place to post your WML questions and answers.

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.
Post Reply
michel
Posts: 15
Joined: September 5th, 2005, 8:31 am

How to remove an attack ?

Post by michel »

My units can take a barrel and throw it :

[event]
name=moveto
first_time_only=no
[filter]
x=16
y=17
[/filter]
[object]
id=b1
name= _ "barrel"
image=items/barrel.png
duration=forever
[filter]
x=16
y=17
[/filter]
[then]
[removeitem]
x,y=16,17
[/removeitem]
[unit_overlay]
x,y=16,17
image=items/barrel.png
[/unit_overlay]
[/then]
[effect]
apply_to=new_attack
name= _ "barrel"
type=impact
range=long
damage=20
number=1
[/effect]
[/object]
[/event]

Ok, after, I can remove the barrel, like this :

[event]
name=attack
first_time_only=no
[filter]
side=1
name=barrel
[/filter]
[remove_unit_overlay]
side=1
image=items/barrel.png
[/remove_unit_overlay]
[/event]

But, the attacks "barrel" is still here ! How to remove it ? please...
Thank you.
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

hmm. That's rather complex.

If you have no other objects than barrels that a unit can take, this code will suffice in the attack event:

Code: Select all

[store_unit]
[filter]
x=$x1
y=$y1
[/filter]
variable=loser
[/store_unit]
{VARIABLE loser.modifications.object[0].effect[0].apply_to nothing}
[unstore_unit]
variable=loser
[/unstore_unit]
However, this only removes it when it is thrown on the attack. You will also need a second event, where the "filter" is replaced with "filter_second" and the $x1 and $y1 in my code are replaced with $x2 and $y2.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

You could try to modify the attack to do 0-0 damage with the [effect] tag.
Hope springs eternal.
Wesnoth acronym guide.
michel
Posts: 15
Joined: September 5th, 2005, 8:31 am

Post by michel »

ok, thank you, i try it
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

scott wrote:You could try to modify the attack to do 0-0 damage with the [effect] tag.
My way is better. It makes the attack not even be there anymore.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

bueno
Hope springs eternal.
Wesnoth acronym guide.
michel
Posts: 15
Joined: September 5th, 2005, 8:31 am

Post by michel »

Thanks Elvish, but I don't understand....
see my code (a unit can take a barrel and throw it)

[event]
name=moveto
first_time_only=no
[filter]
x=5
y=17
[/filter]
[object]
id=e1
name= _ "tonneau"
image=items/barrel.png
[filter]
x=5
y=17
[/filter]
[then]
[removeitem]
x,y=5,17
[/removeitem]
[unit_overlay]
x,y=5,17
image=items/barrel.png
[/unit_overlay]
[/then]
[effect]
apply_to=new_attack
name= _ "Barrel"
type=impact
range=long
damage=20
number=1
[/effect]
[/object]
[/event]

So, can you explain me with this example ? Thank you very much.
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

What is it that you're asking me to explain?
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
michel
Posts: 15
Joined: September 5th, 2005, 8:31 am

Post by michel »

Elvish Pillager wrote:What is it that you're asking me to explain?
ok, i'm going to try.
First, excuse my english because i'm french and so...
i'm asking you to explain how remove the attack "barrel" that I create when an unit take a barrel to throw it.
the code i posted explain how unit can take it and throw it by the creation of a new attack. But... now, i want to remove this attack after this one throw the barrel. I can't do that. I try this :

[event]
name=attack
[filter]
name=Barrel
[/filter]
[effect]
apply_to=attack
[filter]
name=Barrel
[/filter]
increase_attacks=-1
[/effect]
[/event]

this code doesn't remove the attack but I thought that it will reduce the number of attacks at 0... it doesn't work !
And the probleme is that there's another barrel on the map (in fact it's a pub).
So i hope you understand my problem and that you can help me...
Thaks a lot
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Try this.

Code: Select all

[event]
name=attack
[filter]
has_weapon= _ "barrel"
[/filter]
[store_unit]
[filter]
x=$x1
y=$y1
[/filter]
variable=loser
[/store_unit]
{VARIABLE complete no}
{VARIABLE modification_counter 0}
[while]
[variable]
name=complete
equals=no
[/variable]
[do]
[if]
{VARIABLE_OP varname format loser.modifications.object[$modification_counter|].effect[0].apply_to}
{VARIABLE_OP varvalue to_variable $varname}
[variable]
name=varvalue
equals=attack
[/variable]
[then]
{VARIABLE $varname nothing}
{VARIABLE complete yes}
[/then]
[else]
{VARIABLE_OP count add 1}
[/else]
[/if]
[/do]
[/while]
[unstore_unit]
variable=loser
[/unstore_unit]
[/event]
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Minor_Joey
Posts: 20
Joined: January 2nd, 2006, 1:59 am
Location: Pennsylvania, United States

Post by Minor_Joey »

lol, can someone tell me what this is. Like what is it called? Encoding or something. I'm getting interested with all the talk about it :)
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

It's Wesnoth Markup Language, a scripting language by which you exercise complete control over what happens during a scenario. It's a lot of fun.
Hope springs eternal.
Wesnoth acronym guide.
Minor_Joey
Posts: 20
Joined: January 2nd, 2006, 1:59 am
Location: Pennsylvania, United States

Post by Minor_Joey »

Yea I'm trying to read the directions on the site but its not really making a lot of sense to me...
Post Reply