Chance to hit

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
Assasin
Posts: 956
Joined: March 15th, 2005, 3:51 am
Location: Where ever my mind takes me
Contact:

Chance to hit

Post by Assasin »

Is there a way to modify the units chance to hit? Kinda like magical, but it only adds a boost and doesn't set it to 70%
I speak what's on my mind.

Which is why nothing I say makes sense.
User avatar
Elvish_Pillager
Posts: 8129
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

There is no way to do this inside a unit definition. However, you can, by complex and incredibly inconvenient WML, not to mention that it will not display properly, do it in a scenario.
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.
Assasin
Posts: 956
Joined: March 15th, 2005, 3:51 am
Location: Where ever my mind takes me
Contact:

Post by Assasin »

hmm..then how do I access the abilities? Are the instructions somewhere on wiki?
I speak what's on my mind.

Which is why nothing I say makes sense.
scott
Posts: 5242
Joined: May 12th, 2004, 12:35 am
Location: Alexandria, VA

Post by scott »

You can add specials to an existing attack:

http://wesnoth.slack.it/?EffectWML

Effects are granted through objects, so you can grant an invisible object to a unit that causes the effect:

http://wesnoth.slack.it/?DirectActionsWML

Let's see here...

Code: Select all

[event]
name=turn 2

[object]
	[filter]
	description=Jo Mama
	[/filter]
	[effect]
		apply_to=attack
		range=short
		set_special=magical
	[/effect]
	duration=level
	silent=yes
[/object]
[/event]
Not too sure if this would do the trick, but it's a starting point. I don't know under what conditions you want to change the CTH. There are examples in httt for giving objects to units.
Hope springs eternal.
Wesnoth acronym guide.
Assasin
Posts: 956
Joined: March 15th, 2005, 3:51 am
Location: Where ever my mind takes me
Contact:

Post by Assasin »

That's kinda like what I was talking about, except I wanted to add a 10% boost. A chance to hit modifier like I'm talking about would be a usefull tool to have in scenarios.
I speak what's on my mind.

Which is why nothing I say makes sense.
User avatar
Elvish_Pillager
Posts: 8129
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Code: Select all

[event]
name=attack
[store_unit]
[filter]
x=$x2
y=$y2
[/filter]
variable=victim
[/store_unit]
[if]
[variable]
name=victim.variables.old_type
not_equals=none
[/variable]
[then]
{VARIABLE_OP victim.type to_variable victim.variables.old_type}
{VARIABLE victim.variables.old_type none}
[unstore_unit]
variable=victim
[/unstore_unit]
[/then]
[/if]
[/event]

[event]
name=attack
[filter]
description=bonused_unit
[/filter]
[store_unit]
[filter]
x=$x2
y=$y2
[/filter]
variable=victim
[/store_unit]
{VARIABLE_OP victim.variables.old_type to_variable victim.type}
{VARIABLE_OP victim.type format ($victim.type| with less defense)}
[unstore_unit]
variable=victim
[/unstore_unit]
[/event]
There. Provided you have a copy of each and every unit definition with modified defense modifiers, that should work. :|
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.
Assasin
Posts: 956
Joined: March 15th, 2005, 3:51 am
Location: Where ever my mind takes me
Contact:

Post by Assasin »

thanks for the help guys, I really appreciate it.
I speak what's on my mind.

Which is why nothing I say makes sense.
Post Reply