Help Needed

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
allanate
Posts: 16
Joined: November 16th, 2010, 3:31 pm

Help Needed

Post by allanate »

I am trying to make a macro that does this effect. can someone help me?

This unit takes 50% less BLADE DAMAGE when attacked by a melee skill
User avatar
Kapoue_II
Posts: 203
Joined: October 11th, 2010, 9:41 am

Re: Help Needed

Post by Kapoue_II »

Code: Select all

#define ABILITY_BLADERESIST2
    [resistance]
        id=bladeresist
        multiply=2
        apply_to=blade
        [filter_base_value]
            greater_than=0
        [/filter_base_value]
        name= _ "steadfast"
        female_name= _ "female^steadfast"
        description= _ "Steadfast:
This unit’s blade resistance is doubled  when defending. Vulnerabilities are not affected."
        affect_self=yes
        active_on=defense
    [/resistance]
#enddef
allanate
Posts: 16
Joined: November 16th, 2010, 3:31 pm

Re: Help Needed

Post by allanate »

Thanks a lot!

is there a way it can be a weapon ability as well, that is what im aiming at mostly but if not ill accept what you have given me.

once again thank you.
monochromatic
Posts: 1549
Joined: June 18th, 2009, 1:45 am

Re: Help Needed

Post by monochromatic »

You can just place that in the [specials] when defining the weapon in the .cfg (and rename it, if you want).
User avatar
Kapoue_II
Posts: 203
Joined: October 11th, 2010, 9:41 am

Re: Help Needed

Post by Kapoue_II »

Warning: the code I gave will break your game, as I missplaced my #enddef. Use this instead:

Code: Select all

    #define ABILITY_BLADERESIST2
        [resistance]
            id=bladeresist
            multiply=2
            apply_to=blade
            [filter_base_value]
                greater_than=0
            [/filter_base_value]
            name= _ "steadfast"
            female_name= _ "female^steadfast"
            description= _ "Steadfast:
    This unit’s blade resistance is doubled  when defending. Vulnerabilities are not affected."
            affect_self=yes
            active_on=defense
        [/resistance]
#enddef
allanate
Posts: 16
Joined: November 16th, 2010, 3:31 pm

Help Needed.... Again

Post by allanate »

is there a macro that increases your damage as your HP goes down?
User avatar
StDrake
Posts: 996
Joined: July 21st, 2009, 6:50 am

Re: Help Needed

Post by StDrake »

in fact doing that as a weapon special will be more efficient, as kapoues code is more leaky than he thinks, simply use the [damage] tag with a multiply=0.5 applied to the opponent (see wiki for details)
Like cats? I've made a whole faction of them to kick ass with!
Don't like cats? I've made a whole faction of them to kick their asses! So everyone's happy :)
Felinian faction is part of the Beyond Southern Hells era
kitties need sprites! art topic here
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Help Needed.... Again

Post by zookeeper »

allanate wrote:is there a macro that increases your damage as your HP goes down?
Merged your two threads; please keep all your questions in one thread.
monochromatic
Posts: 1549
Joined: June 18th, 2009, 1:45 am

Re: Help Needed.... Again

Post by monochromatic »

allanate wrote:is there a macro that increases your damage as your HP goes down?
Not that I know of, but can be easily done.
myav
Posts: 85
Joined: August 23rd, 2008, 12:53 pm

Re: Help Needed

Post by myav »

Kapoue_II, your answer is wrong.

allanate wants that his unit received half blade damage, but after your code, unit will receive 0-100% blade damage.

Example: If basic blade resistance Will be 10%, then with your ability ABILITY_BLADERESIST2 blade damage will be not 50% but 80%.

Who can help with this question? It is interesting to me too. How to create ability which will decrease damage on 50%, and this abillity must to work when units resistance will be 0-40% too.
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Help Needed

Post by 8680 »

This should work. I haven't tested it though.

Code: Select all

#define RESIST_MELEE_BLADE_50
[dummy]
	id="resist_melee_blade_50"
	name="melee blade resistance"
	name_inactive="melee blade resistance"
	description="This unit takes 50% less damage from melee blade attacks."
	description_inactive="This unit takes 50% less damage from melee blade attacks."
[/dummy]
[/abilities]
[event]
	name="attack"
	first_time_only=false
	[filter]
		ability="resist_melee_blade_50"
	[/filter]
	[filter_attack]
		range="melee"
	[/filter_attack]
	[lua]
		code=<<
			local u = wesnoth.get_variable "unit"
			old_res = u.resistance.blade
			u.resistance.blade = math.max ( 0, old_res - 50 )
		>>
	[/lua]
[/event]
[event]
	name="attack"
	first_time_only=false
	[filter_second]
		ability="resist_melee_blade_50"
	[/filter_second]
	[filter_attack]
		range="melee"
	[/filter_attack]
	[lua]
		code=<<
			local u = wesnoth.get_variable "second_unit"
			old_res = u.resistance.blade
			u.resistance.blade = math.max ( 0, old_res - 50 )
		>>
	[/lua]
[/event]
[event]
	name="attack_end"
	first_time_only=false
	[filter]
		ability="resist_melee_blade_50"
	[/filter]
	[filter_attack]
		range="melee"
	[/filter_attack]
	[lua]
		code=<<
			local u = wesnoth.get_variable "unit"
			u.resistance.blade = old_res
			old_res = nil
		>>
	[/lua]
[/event]
[event]
	name="attack_end"
	first_time_only=false
	[filter_second]
		ability="resist_melee_blade_50"
	[/filter_second]
	[filter_attack]
		range="melee"
	[/filter_attack]
	[lua]
		code=<<
			local u = wesnoth.get_variable "second_unit"
			u.resistance.blade = old_res
			old_res = nil
		>>
	[/lua]
[/event]
[+abilities]
#enddef
Post Reply