Help for New Abilities and Weapon Specials

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
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

damn what a seven-headed bug!...
So where do I put this part in the code?
And when my unit is above the target level of the attack, will it work properly to decrease the damage?
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

gfgtdf wrote: July 20th, 2020, 1:28 am I think this should work to check whether there is an adjacent unit with a lower level adjacent. I didn ttest it though and im not an expert on wesnoth frmoula filte syntax so it might not work.

Code: Select all

formula = "def adjacent_occupied_locs(loc)
				filter(
					adjacent_locs(loc),
					'loc',
					unit_at(loc) != null()
				);
			size(filter(adjacent_occupied_locs(loc), 'loc', unit_at(loc).level > self.level)) > 0"
damn what a seven-headed bug!...
So where do I put this part in the code?
And when my unit is above the target level of the attack, will it work properly to decrease the damage?
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Code: Select all

            [filter]
                formula = "def adjacent_occupied_locs(loc)
				filter(
					adjacent_locs(loc),
					'loc',
					unit_at(loc) != null()
				);
			size(filter(adjacent_occupied_locs(loc), 'loc', unit_at(loc).level > self.level)) > 0"
            [/filter]
Do I use it like that?
Will it work together with these others?

Code: Select all

	    [filter_adjacent]
		level="$($this_unit - 1)"
		[or]
		level="$($this_unit - 2)"
		[/or]
		[or]
		level="$($this_unit - 3)"
		[/or]
		[or]
		level="$($this_unit - 4)"
		[/or]
	    [/filter_adjacent]

Code: Select all

	    [filter_adjacent]
		level="$($this_unit + 1)"
		[or]
		level="$($this_unit + 2)"
		[/or]
		[or]
		level="$($this_unit + 3)"
		[/or]
		[or]
		level="$($this_unit + 4)"
		[/or]
	    [/filter_adjacent]
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Maybe I should give up this ability I wanted so much...
The fighters will have to be cowards anyway...
Because it's very complicated to code... :cry:
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Some way for the unit to have an attack that is only available with low HP, another condition would be on specific terrain, or only during the day or night.

I have no idea how to establish these conditions for the attack to be available or not. :roll:
I start to think that this is too complex for me to learn on my own, since I have been trying for a long time. :hmm:
The worst part of the story is that I really didn't want to give up... :|
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: Help for New Abilities and Weapon Specials

Post by lhybrideur »

Concerning your fighter ability, could you use a formula or something to do value = -15*(unit.level-second_unit.level) or the other way around ?
Only wondering because I have no idea how this works.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

In this formula if "2" is for 50% of HP, then "4" is for 25% of HP?
damn mathematics that chases me kkkkk...

Code: Select all

formula="max_hitpoints / hitpoints > 2"

Code: Select all

formula="max_hitpoints / hitpoints > 4"
Last edited by Barbaros on July 20th, 2020, 4:24 pm, edited 1 time in total.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

lhybrideur wrote: July 20th, 2020, 12:04 pm Concerning your fighter ability, could you use a formula or something to do value = -15*(unit.level-second_unit.level) or the other way around ?
Only wondering because I have no idea how this works.
I'll see what I do with that too. Thank you.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Barbaros wrote: July 19th, 2020, 8:31 pm Tell me if Last Resort works like this:
I'm a little tired, just let me know if you have a problem with the code.
This frustrates me when it doesn't work, it's the tenth time I modified this code today, I stopped testing on the ninth kkkkkk.
Sorry for the code not being organized here on the forum, have a little patience to read.

Code: Select all

#define SECOND_ATTACK
    [set_variable]
        name=tmp_double_attack_unit_store.attacks_left
        add=1
    [/set_variable]

    [set_variables]
        name=tmp_double_attack_unit_store.variables
        mode=merge
        [value]
            double_attack_attacked=yes
            double_attack_turn=$turn_number
        [/value]
    [/set_variables]

    [unstore_unit]
        text= _ "double attack"
        {COLOR_HARM}
        variable=tmp_double_attack_unit_store
    [/unstore_unit]

#enddef

#define WEAPON_SPECIAL_LAST_RESORT
# wmlxgettext: [attack]
# wmlxgettext: [specials]

    [chance_to_hit]
    [dummy]
        id=double attack
        name= _ "Last Resort"
        description= _ "This unit can attack two enemies in one turn with a minimum of 50% accuracy, only if 25% or less of your HP or less remains, but cannot move from a hex, where the first enemy was attacked."
        name_inactive= _ "Last Resort"
        description_inactive="This unit can attack two enemies in one turnwith a minimum of 50% accuracy, only if 25% or less of your HP or less remains, but cannot move from a hex, where the first enemy was attacked."
    [/dummy]
        value=50
        cumulative=yes
    [/chance_to_hit]
[/specials]
[/attack]

[event]
    name=attack_end
    first_time_only=no
    [filter_self]
        formula="(($this_unit.max_hitpoints -1+1) / ($this_unit.hitpoints -1+1)) > 4"
    [/filter_self]
    [filter_attack]
        special=double attack
    [/filter_attack]

    [filter]
        type={TYPE}
    [/filter]

    [store_unit]
        [filter]
            id=$unit.id
        [/filter]
        variable=tmp_double_attack_unit_store
    [/store_unit]

    [if]
        [variable]
            name=tmp_double_attack_unit_store.variables.double_attack_attacked
            boolean_not_equals=yes
        [/variable]

        [then]
            {SECOND_ATTACK}
        [/then]

        [else]
            [if]
                [variable]
                    name=tmp_double_attack_unit_store.variables.double_attack_turn
                    not_equals=$turn_number
                [/variable]

                [then]
                    {SECOND_ATTACK}
                [/then]
            [/if]
        [/else]
    [/if]
[/event]

[event]
    name=side turn
    first_time_only=no

    [clear_variable]
        name=tmp_double_attack_unit_store
    [/clear_variable]
[/event]

[event]
    name=victory

    [clear_variable]
        name=tmp_double_attack_unit_store
    [/clear_variable]
[/event]
[+attack]
[+specials]
# wmlxgettext: [/specials]
# wmlxgettext: [/attack]
#enddef
This crappy filter doesn't work.

Code: Select all

    [filter_self]
        formula="(($this_unit.max_hitpoints -1+1) / ($this_unit.hitpoints -1+1)) > 4"
    [/filter_self]
And not like this:

Code: Select all

    [filter_attack]
        special=double attack
        [filter_self]
            formula="max_hitpoints / hitpoints > 4"
        [/filter_self]
    [/filter_attack]
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Code: Select all

#define ABILITY_STRENGTHENING VALUE
    [resistance]
        id=Strengthening
        add={VALUE}
        max_value=60
        apply_to=blade,pierce,impact
        name= _ "Strengthening"
        description="This units receive a +{VALUE}% bonus to physical resistances (up to a maximum of 60%) and heal itself 10% of max hp per turn, when your remaining HP is 50% or less."
        affect_self=yes
        affect_allies=no
        cumulative=yes
          [filter_self]
              formula="max_hitpoints / hitpoints > 2"
          [/filter_self]
    [/resistance]
[/abilities]
[event]
  id=regenerates_10%
  first_time_only=no
  name=side turn
  [store_unit]
    [filter]
      ability=regenerates 10%
      side=$side_number
          [filter_self]
              formula="max_hitpoints / hitpoints > 2"
          [/filter_self]
    [/filter]
    variable=unit_healed
    kill=no
  [/store_unit]
  {FOREACH unit_healed i}
    [if]
      [variable]
        name=unit_healed[$i].status.poisoned
        equals=yes
      [/variable]
      [then]
        [heal_unit]
          [filter]
            id=$unit_healed[$i].id
          [/filter]
          animate=yes
          amount=0
          restore_statuses=yes
        [/heal_unit]
      [/then]
      [else]
        [heal_unit]
          [filter]
            id=$unit_healed[$i].id
          [/filter]
          animate=yes
          amount=$($unit_healed[$i].max_hitpoints/10)
         [/heal_unit]
      [/else]
    [/if]
  {NEXT i}
  {CLEAR_VARIABLE unit_healed}
[/event]
[+abilities]
#enddef
If anyone understands why this code doesn't work at all, I'm all ears.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

The resistance does work. It just doesn't start where you might expect because the result of the division is automatically rounded off. If your unit has 16 hitpoints out of 36, the result of the division is 2, not 2.25 like you might expect. And 2 is not > 2. Use >= instead to fix this problem.

The other part doesn't work because you filter on an ability called "regenerates 10%", but the ability is not called that. It is called "Strengthening". If you change it to filter on the correct name, it will work.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: Help for New Abilities and Weapon Specials

Post by lhybrideur »

Barbaros wrote: July 20th, 2020, 4:18 pm In this formula if "2" is for 50% of HP, then "4" is for 25% of HP?
damn mathematics that chases me kkkkk...

Code: Select all

formula="max_hitpoints / hitpoints > 2"

Code: Select all

formula="max_hitpoints / hitpoints > 4"
yes.
You might be able to do it the other way around for it to be clearer, if it accepts doubles.

Code: Select all

formula="hitpoints / max_hitpoints > 0.5"
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

lhybrideur wrote: July 21st, 2020, 11:00 am
Barbaros wrote: July 20th, 2020, 4:18 pm In this formula if "2" is for 50% of HP, then "4" is for 25% of HP?
damn mathematics that chases me kkkkk...

Code: Select all

formula="max_hitpoints / hitpoints > 2"

Code: Select all

formula="max_hitpoints / hitpoints > 4"
yes.
You might be able to do it the other way around for it to be clearer, if it accepts doubles.

Code: Select all

formula="hitpoints / max_hitpoints > 0.5"
Thanks for confirming this for me.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

beetlenaut wrote: July 20th, 2020, 11:02 pm The resistance does work. It just doesn't start where you might expect because the result of the division is automatically rounded off. If your unit has 16 hitpoints out of 36, the result of the division is 2, not 2.25 like you might expect. And 2 is not > 2. Use >= instead to fix this problem.

The other part doesn't work because you filter on an ability called "regenerates 10%", but the ability is not called that. It is called "Strengthening". If you change it to filter on the correct name, it will work.
Our unbelievable stupidity, putting the name of the event in the filter, but that was because my mind was tired, trying to program several things that didn't work. Thank you for correcting this great imbecility kkkkkkkk. :lol: :lol: :lol: Very good to know that ">=" will always be better. :eng:
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Code: Select all

#define ABILITY_PURIFIED
    [regenerate]
        id=purified
        name= _ "purified"
        female_name= _ "female^purified"
        description=  _ "Allows the unit to cure itself from abnormal status at the beginning of its own turn."
        affect_self=yes
        affect_allies=no
        value=0
        poison=cured
        petrifies=cured
        slow=cured
        incinerate=cured
        maims=cured
        ROL_kick_stun=cured
        ROL_ensnare=cured
    [/regenerate]
#enddef
I would like to know if this ability will work properly like this, or would I have to use the status description: Example: slowed, petrified, incinerated, or otherwise?
Last edited by Barbaros on July 24th, 2020, 2:12 am, edited 1 time in total.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
Post Reply