Is it possible to get opponent's level in weapon specials?

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
wuxiangjinxing
Posts: 53
Joined: December 23rd, 2008, 5:01 am

Is it possible to get opponent's level in weapon specials?

Post by wuxiangjinxing » October 10th, 2019, 11:33 pm

I'm thinking of making a weapon special that does more damage to higher-level enemies. But I cannot figure out an easy way to do it. Certainly I can use an event to give the unit damage modifier when attacking while removing the modifier after the attack finishes. But the code looks ugly. Is there some better way to do it? For instance:

Code: Select all

[damage]
	id=more_damage_to_stronger_enemies
	apply_to=self
	add="a formula that gets the opponent's level"
[damage]
Is it doable?

gfgtdf
Developer
Posts: 1190
Joined: February 10th, 2013, 2:25 pm

Re: Is it possible to get opponent's level in weapon specials?

Post by gfgtdf » October 11th, 2019, 1:54 am

yes im quite sure that would work. It it doesn't maybe you could tell what exact syntax you have tried?
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

wuxiangjinxing
Posts: 53
Joined: December 23rd, 2008, 5:01 am

Re: Is it possible to get opponent's level in weapon specials?

Post by wuxiangjinxing » October 11th, 2019, 2:15 am

gfgtdf wrote:
October 11th, 2019, 1:54 am
yes im quite sure that would work. It it doesn't maybe you could tell what exact syntax you have tried?
I tried something like add="other.level" but this does not work correctly. It seems that it always add the level of current unit, instead of opponent.

gfgtdf
Developer
Posts: 1190
Joined: February 10th, 2013, 2:25 pm

Re: Is it possible to get opponent's level in weapon specials?

Post by gfgtdf » October 11th, 2019, 2:41 am

did you try putting it in parentesis like add="(other.level)"
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

wuxiangjinxing
Posts: 53
Joined: December 23rd, 2008, 5:01 am

Re: Is it possible to get opponent's level in weapon specials?

Post by wuxiangjinxing » October 11th, 2019, 3:25 am

gfgtdf wrote:
October 11th, 2019, 2:41 am
did you try putting it in parentesis like add="(other.level)"
Yes I did but still it only adds the level of the current unit instead of the opponent's level.

gfgtdf
Developer
Posts: 1190
Joined: February 10th, 2013, 2:25 pm

Re: Is it possible to get opponent's level in weapon specials?

Post by gfgtdf » October 11th, 2019, 11:41 am

ohh hmm it seems like this was written mostly with the leadership ability in mind where one unit has the ability and the 'other' unit it the unit that 'received' the ability.

So it seems that is itnot possibel that way maybe we can add this possiblity to wesnoth 1.15 in time.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
lhybrideur
Posts: 70
Joined: July 9th, 2019, 1:46 pm

Re: Is it possible to get opponent's level in weapon specials?

Post by lhybrideur » October 14th, 2019, 3:09 pm

do you create your "other" with a

Code: Select all

[store_unit]
    [filter]
        x,y=$x2,$y2
    [/filter]
    variable=other
[/store_unit]
?
If yes, other.level should normally work.

User avatar
Celtic_Minstrel
Developer
Posts: 1532
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Is it possible to get opponent's level in weapon specials?

Post by Celtic_Minstrel » October 20th, 2019, 11:54 pm

ihybrideur – That's not how this works. Your code creates a WML variable, but the formulas in a weapon special use WFL variables, which are not the same thing (I know, it's a little confusing to have three types of variables, but that's how it is).

The other WFL variable is created by the engine in the weapon special filters, but I guess it's not included when calculating values in the weapon special itself.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply