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 »

I'm almost giving up on her...
But what a crap...
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
User avatar
beetlenaut
Developer
Posts: 2824
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

Put [+specials] in your definition code after the #enddef to fix this. Of course that might not be the last bug, but all programmers know this: You spend much more time fixing bugs than writing code.

You getting that error because you have [/specials] in the weapon special definition AND in the [unit_type]. There are too many closing tags, and the computer can't match them correctly. I told you the error messages don't always identify the correct location for your mistake, just the first time the computer notices something is wrong.

The [+specials] I mentioned reopens the specials tag in the definition so it can be closed in [unit_type]. I saw similar things in other code you posted, so I thought you knew about it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Ravana
Forum Moderator
Posts: 2997
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Help for New Abilities and Weapon Specials

Post by Ravana »

Your special code includes
[/specials]
[/attack].

Unit file already has
[/specials]
[/attack].

Common solution for that is +tag syntax.
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

I used this weapon special, which comes from the Golden Age Era:

Code: Select all

#define WEAPON_SPECIAL_SURPRISE ID
[dummy]
	id=surprise{ID}
	name= _ "surprise"
	description= _ "When an enemy moves adjacent to this unit it will be hit with a single melee strike before normal combat takes place."
[/dummy]
    [/specials]
    [/attack]
[event]
	name=moveto
	first_time_only=no
	[filter]
		[filter_adjacent]
			is_enemy=yes
			[filter_wml]
				[attack]
					[specials]
						[dummy]
							id=surprise{ID}
						[/dummy]
					[/specials]
				[/attack]
			[/filter_wml]
		[/filter_adjacent]
	[/filter]

	[store_unit]
		[filter]
			[filter_wml]
				[attack]
					[specials]
						[dummy]
							id=surprise{ID}
						[/dummy]
					[/specials]
				[/attack]
			[/filter_wml]
			[filter_adjacent]
				x,y=$x1,$y1
			[/filter_adjacent]
		[/filter]
		variable=attacker
	[/store_unit]
	{VARIABLE temp_damage $attacker.attack[0].damage}
	{VARIABLE temp_type $attacker.attack[0].type}
	[unstore_unit]
		variable=attacker
		text=_ "Surprise"
		{COLOR_HEAL}
	[/unstore_unit]
		
	[harm_unit]
		[filter]
			x,y=$x1,$y1
		[/filter]
		[filter_second]
			[filter_wml]
				[attack]
					[specials]
						[dummy]
							id=surprise{ID}
						[/dummy]
					[/specials]
				[/attack]
			[/filter_wml]
			[filter_adjacent]
				x,y=$x1,$y1
			[/filter_adjacent]
		[/filter_second]
		amount=$temp_damage
		damage_type=$temp_type
		fire_event=yes
		animate=yes
		experience=yes
	[/harm_unit]

	{CLEAR_VARIABLE temp_damage}
	{CLEAR_VARIABLE temp_type}
	{CLEAR_VARIABLE attacker}
[/event]
    [+attack]
    [+specials]
#enddef
As of Wesnoth 1.14.9, it is no longer active, and I don't understand why.
Can anyone tell me? :hmm:
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 »

Anybody here? It could be that angry guy...
Just kidding.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Help for New Abilities and Weapon Specials

Post by Pilauli »

I'm here, but *insert standard not an expert disclaimer*. Alright, does it give any sort of error message, or does the game just pretend it isn't there?

---

If it gives an error message, what does the error message say?

If it says something about unexpected closing tags, then it's because there are unbalanced tags in your macro there. For example, it doesn't open [specials] but it does have a closing [/specials] in there.

It might actually help to copy-and-paste the macro's contents into whichever places you call it from. I think it's easier to work that way, where you can see all the important parts at the same time, rather than looking back and forth between two files.

---

If the game just ignores it, make sure the [event] goes somewhere the game will notice it.

I believe that [event]s don't work when inside of [unit_type] or [abilities] tags (which would be where the [event] goes if you put that macro in a unit file), but that they do work inside [scenario] or the top-level [campaign] or [era] tags. (Top-level tags generally go inside your _main.cfg file.)
EDIT: They work inside [unit_type]? That's awesome! I'm definitely going to use this now!

I would personally recommend leaving the event where it is (if it's not breaking anything...), but also copying it into one of the tags (to test whether that makes it work); then depending on whether that works, decide which one to delete.

---

Hope some of this helps.
Last edited by Pilauli on September 9th, 2020, 11:47 pm, edited 1 time in total.
User avatar
beetlenaut
Developer
Posts: 2824
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

I don't see anything obviously wrong with this code, so there might be something wrong with where it is being called from. What is the {ID} you are using for instance?
Pilauli wrote: September 9th, 2020, 11:09 pm I believe that [event]s don't work when inside of [unit_type] or [abilities] tags (which would be where the [event] goes if you put that macro in a unit file)
No, you can put an [event] into [unit_type]. That will make the game automatically copy the event into any scenario where the unit appears.

Pilauli has the right idea though. Check for error messages, try moving the event to the main scenario file and make sure the event really still works, make the event post a [message] in different places and see which ones don't show up, make the event only print a message so you can make sure it is being called in the first place, cut out the {CLEAR_VARIABLE}s and check what is stored in them after an attack. You don't necessarily have to try them all, but these are the techniques I use to find out what part of the code has the error. I don't think it's in the part you posted this time.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Barbaros
Posts: 75
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Just to answer, the game pretends that the code is not there.
I will try to follow some of your suggestions.
I tried to modify it but it was a failure, until a few minutes ago.
Thanks my people!
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 »

What is the syntax error with my AMLA, because I am not getting the expected result.

Code: Select all

    [advancement]
        strict_amla=yes
        max_times=1
        id=Sword1
        require_amla="Resilience2"
        description= _ "Better with swordsmanship. (+1 attack damage and +1 flaming damage)."
        image=attacks/sword-flaming.png
	always_display=yes
           [effect]
              apply_to=attack
              name=sword_flame
              increase_damage=1
           [/effect]
        [effect]
            apply_to=attack
            name=sword_flame
                [set_specials]
                    mode=append
                    remove_special=Flaming_Sword 4
                    new_special=Flaming_Sword 5
#                       [specials]
#                          {WEAPON_SPECIAL_FLAMING_SWORD 5}
#                       [/specials]
                [/set_specials]
        [/effect]
           [effect]
              apply_to=hitpoints
              heal_full=yes
           [/effect]
           [effect]
              apply_to=max_experience
              increase=15%
           [/effect]
    [/advancement]
    [advancement]
        strict_amla=yes
        max_times=1
        id=Sword2
        require_amla="Sword1,Resilience3"
        description= _ "Even better with swordsmanship. (+1 attack damage and +1 flaming damage)."
        image=attacks/sword-flaming.png
	always_display=yes
           [effect]
              apply_to=attack
              name=sword_flame
              increase_damage=1
           [/effect]
        [effect]
            apply_to=attack
            name=sword_flame
                [set_specials]
                    mode=append
                    remove_special=Flaming_Sword 5
                    new_special=Flaming_Sword 6
#                       [specials]
#                          {WEAPON_SPECIAL_FLAMING_SWORD 6}
#                       [/specials]
                [/set_specials]
        [/effect]
           [effect]
              apply_to=hitpoints
              heal_full=yes
           [/effect]
           [effect]
              apply_to=max_experience
              increase=15%
           [/effect]
    [/advancement]
As you can see, the weapon special must progress with the advances of AMLA, but in practice, the unit is already starting with Flaming_Sword 6.

I spent the whole night in that damn dilemma, changed the syntax in several ways, and got a lot of errors, and I got here, with no errors in the game, but I didn't reach the purpose.

PS: The weapon special is working perfectly.
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 »

I'm trying to get this over with, so I can tinker with the WEAPON_SPECIAL_SURPRISE ID, but I couldn't, why does it have to be so difficult?...
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 »

Feeling like a [censored] [censored]...

About the SURPRISE ID Weapon Special, I had another weapon special that was causing some interference in it, although it had no message...

As soon as I removed it from the game, (I gave up on it anyway), then SURPRISE ID worked perfectly, Sorry for wasting your time.
About the ID, I'm not replacing it with anything, it works like that, weird not kkkkkkk
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 »

I would like to do something reverse to the backstab weapon special, where the unit gains more attack power when under pressure, surrounded by two opposite sides.
But I don't know how to establish the condition to work, it seemed it would be so easy in the beginning... kkkkkk
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Help for New Abilities and Weapon Specials

Post by Pilauli »

I don't know about the surprise and flaming sword specials.

For your backstab-like ability, you could look at the existing backstab ability, and you could also look at the new (1.15) "diversion" or "distraction" ability. I think this ought to work as a permanent link:
https://github.com/wesnoth/wesnoth/blob ... s.cfg#L112
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 WEAPON_SPECIAL_FLAMING_SWORD 4
    [dummy]
        id=Flaming_Sword 4
        name= _ "Flaming Sword 4"
        description=_"When struck by this weapon, for each successful hit, the target takes a residual 5 fire damage."
    [/dummy]
[/specials]
[/attack]

[event]
name=attacker hits
first_time_only=no
id=Burning
    [filter_attack]
        special=Flaming_Sword 4
    [/filter_attack]
    [filter_second]
      [not]
        race=drake
         [or]
           ability=fireborn
         [/or]
         [or]
           [filter_location]
               terrain=W*,W*^*,St,Sm
           [/filter_location]
         [/or]
         [or]
           type=Fire Dragon,Black Dragon
         [/or]
      [/not]
    [/filter_second]

    [harm_unit]
        [filter]
          x,y=$x2, $y2
        [/filter]
      amount=4
      damage_type=fire
      fire_event=yes
      kill=yes
      animate=no
      experience=yes
      alignment=lawful
    [/harm_unit]
  [/event]
[+attack]
[+specials]
#enddef
This is the Flaming Sword, very simple, so I made the versions with 4, 5, and 6 damage per effect, so I put it on the unit's AMLA, to progress when it leveled up.

Only, I don't know why, the unit is already starting with ability 6, including changing what is in the attack, which is 4.
The Weapon Special works perfectly.
So I want to know if I typed anything wrong with my AMLA.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Help for New Abilities and Weapon Specials

Post by Pilauli »

The 6-damage version is probably overriding the lower-damage versions. I don't know why.

I suspect the problem is in the amla-assigning code rather than the burning code, but can't be sure. (That's if the unit says it has Flaming Sword 6 right off the bat.) I won't be any use there.

If the unit claims to have Flaming_Sword 4, but it acts like Flaming_Sword 6, then I do have a couple of suggestions:
- Make sure you aren't testing it against a unit that's weak to fire.
- Try changing the event's ID, so that instead of Burning, Burning, and Burning, you have Burning4, Burning5, and Burning6. I think I may have read that there can only be one event with any given ID at any given time.
- Try putting the special's ID in quotes, just in case the space (before the number in "Flaming_Sword 4") is being interpreted as an end-of-argument thing. If doesn't seem likely, but might be worth trying.

Good luck!
Post Reply