Trying to create a new weapon special.
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.
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Trying to create a new weapon special.
1. The special weapon's name is Parry.
2. The basis is, when the unit is attacked, and reacts with the weapon with this attribute, it has a 15% chance of deflecting the attack, reducing its damage by 25%, in which case the text "Parry" will appear, and 15% of Chances to parry more effectively, reducing attack damage by 50%, in this case the text "P. Parry" appears.
3. By dodging, do not mean dodging, it is dodging as a defense in martial arts.
4. This only applies if the attack is going to hit you, and is calculated for each hit.
5. So of course, he still has a 70% chance of not getting anything lol.
6. We're not going to appeal, are we?
7. In this case, an ability applied only to defensive combat.
It's complex to do for me, I couldn't do it, I've even managed other things, but this one got me.
2. The basis is, when the unit is attacked, and reacts with the weapon with this attribute, it has a 15% chance of deflecting the attack, reducing its damage by 25%, in which case the text "Parry" will appear, and 15% of Chances to parry more effectively, reducing attack damage by 50%, in this case the text "P. Parry" appears.
3. By dodging, do not mean dodging, it is dodging as a defense in martial arts.
4. This only applies if the attack is going to hit you, and is calculated for each hit.
5. So of course, he still has a 70% chance of not getting anything lol.
6. We're not going to appeal, are we?
7. In this case, an ability applied only to defensive combat.
It's complex to do for me, I couldn't do it, I've even managed other things, but this one got me.
-
- Posts: 1257
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Trying to create a new weapon special.
Not sure where you're stuck.
I'm guessing you'll use an attacker_hits event, check $second_weapon to see if the defender's weapon has the parry special, and then either adjust the $damage_inflicted (if you can, I don't know) or reverse the damage (assuming attacker_hits allows you to intercept the attack before a kill occurs).
https://wiki.wesnoth.org/EventWML#attacker_hits
I'm guessing you'll use an attacker_hits event, check $second_weapon to see if the defender's weapon has the parry special, and then either adjust the $damage_inflicted (if you can, I don't know) or reverse the damage (assuming attacker_hits allows you to intercept the attack before a kill occurs).
https://wiki.wesnoth.org/EventWML#attacker_hits
Speak softly, and carry Doombringer.
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Re: Trying to create a new weapon special.
So, after 48 hours without sleep, the code looked like this, but I can't test it now, because I'm already dead... At least tell me if you think it will work like this. So I can sleep in peace hahaha. I tried other syntheses, but they weren't activating, I hope this one works.
I tried as you suggested with attacker_hits event, $second_weapon, $damage_inflicted, but I'm not sure if I didn't know how to synthesize it, it just didn't activate even once in several attempts.
AAAAHHHH crap! Coffee spilled on the PC, sleep from the plague... lol Thanks, we'll talk more later.
Code: Select all
#define WEAPON_SPECIAL_PARRY
[dummy]
id=Parry
name=Parry
description= _ "When the unit is attacked, and reacts with the weapon with this attribute, it has a 15% chance of deflecting the attack, reducing its damage by 25%, and 15% of Chances to parry more effectively, reducing attack damage by 50%. This ability will not work if the defending unit with Parry has the following negative statuses: Paralyzed, Slowed or Petrified."
description_inactive= _ "When the unit is attacked, and reacts with the weapon with this attribute, it has a 15% chance of deflecting the attack, reducing its damage by 25%, and 15% of Chances to parry more effectively, reducing attack damage by 50%. This ability will not work if the defending unit with Parry has the following negative statuses: Paralyzed, Slowed or Petrified."
[/dummy]
[/specials]
[/attack]
[event]
name=defense
first_time_only=no
{CLEAR_VARIABLE
unit_with_parry
}
{VARIABLE
chance
random(100)
}
[if]
[have_unit]
x,y,$target_x,$target_y
[filter]
has_ability=parry
[not]
status=paralyzed
status=slow
status=petrified
[/not]
[/filter]
[/have_unit]
[then]
{VARIABLE
eligible_for_parry
yes
}
[else]
{VARIABLE
eligible_for_parry
no
}
[/if]
[switch]
value=$chance
[multiplier]
value=0.15
[then]
[if]
test_variable
name=eligible_for_parry
equals=yes
[then]
{VARIABLE_UNIT(unit_with_parry)
[store_unit]
[filter]
x,y,$target_x,$target_y
has_ability=parry
[/filter]
}
{MESSAGE "Parry Successfully" color=green}
{VARIABLE
damage_reduction
25
}
{VARIABLE
final_damage_reduction
multiply
$damage_reduction
damage,max
}
{modify_unit
x,y,$target_x,$target_y
damage=-$final_damage_reduction
}
[/then]
[/if]
[/then]
[multiplier]
value=0.15
[then]
[if]
test_variable
name=eligible_for_parry
equals=yes
[then]
{VARIABLE_UNIT(unit_with_parry)
[store_unit]
[filter]
x,y,$target_x,$target_y
has_ability=parry
[/filter]
}
{MESSAGE "P.Parry Successfully" color=green}
{VARIABLE
damage_reduction
50
}
{VARIABLE
final_damage_reduction
multiply
$damage_reduction
damage,max
}
{modify_unit
x,y,$target_x,$target_y
damage=-$final_damage_reduction
}
[/then]
[/if]
[/then]
[/switch]
[/event]
#enddef
AAAAHHHH crap! Coffee spilled on the PC, sleep from the plague... lol Thanks, we'll talk more later.
Last edited by Lythosagin on March 22nd, 2024, 4:14 pm, edited 1 time in total.
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Re: Trying to create a new weapon special.
All my respect to whoever programs this game, it's too difficult. I'm animating some LV.4 and LV.5 units that only have the stand pose, or little else, as soon as I test it in the game, I'll post it as a contribution for everyone, to try to return at least a little of the kindness and dedication of the community, which I've been playing since version 1.10.
-
- Posts: 1257
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Trying to create a new weapon special.
It's very hard to read that without code tags, but it looks like a lot of your tags are mismatched (opened not closed, or closed but not open) and I suspect "x,y,$target_x,$target_y" is supposed to be "x,y=$target_x,$target_y". And I'm not aware of a defense event.
Speak softly, and carry Doombringer.
- Pentarctagon
- Project Manager
- Posts: 5586
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Trying to create a new weapon special.
Was this written by ChatGPT or another AI model? There's so many things that are wrong or made up here that all I can say is you really really need to read the documentation on the wiki first.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Re: Trying to create a new weapon special.
Code: Select all
#define WEAPON_SPECIAL_PARRY
[attack]
[specials]
[dummy]
id=Parry
name=Parry
description= _ "When the unit is attacked, and reacts with the weapon with this attribute, it has a 15% chance of deflecting the attack, reducing its damage by 25%, and 15% of Chances to parry more effectively, reducing attack damage by 50%. This ability will not work if the defending unit with Parry has the following negative statuses: Paralyzed, Slowed or Petrified."
description_inactive= _ "When the unit is attacked, and reacts with the weapon with this attribute, it has a 15% chance of deflecting the attack, reducing its damage by 25%, and 15% of Chances to parry more effectively, reducing attack damage by 50%. This ability will not work if the defending unit with Parry has the following negative statuses: Paralyzed, Slowed or Petrified."
[/dummy]
[/specials]
[/attack]
[event]
name=defender_hits
first_time_only=no
{CLEAR_VARIABLE unit_with_parry}
{VARIABLE chance random(100)}
[if]
[have_unit]
x,y,$target_x,$target_y
[filter]
has_ability=parry & (not status=paralyzed) & (not status=slowed) & (not status=petrified)
[/filter]
[/have_unit]
[then]
{VARIABLE eligible_for_parry yes}
[else]
{VARIABLE eligible_for_parry no}
[/if]
[if]
test_variable
name=eligible_for_parry
equals=yes
[then]
[switch]
value=$chance
[multiplier]
value=0.15
[then]
{VARIABLE_UNIT(unit_with_parry)}
[store_unit]
[filter]
x,y,$target_x,$target_y
has_ability=parry
[/filter]
{MESSAGE "Parry Sucessfully!" color=green}
{VARIABLE damage_reduction=25%}
{VARIABLE final_damage_reduction multiply=$damage_reduction * max_damage}
{modify_unit x,y,$target_x,$target_y damage=-$final_damage_reduction}
[/then]
[/multiplier]
[multiplier]
value=0.15
[then]
{VARIABLE_UNIT(unit_with_parry)}
[store_unit]
[filter]
x,y,$target_x,$target_y
has_ability=parry
[/filter]
{MESSAGE "P. Parry Sucessfully!" color=green}
{VARIABLE damage_reduction=50%}
{VARIABLE final_damage_reduction multiply=$damage_reduction * max_damage}
{modify_unit x,y,$target_x,$target_y damage=-$final_damage_reduction}
[/then]
[/multiplier]
[/switch]
[/if]
[/event]
#enddef
- Pentarctagon
- Project Manager
- Posts: 5586
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Trying to create a new weapon special.
I think you should start with something much simpler - start with just an ability that displays a message on the defender getting hit.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Re: Trying to create a new weapon special.
I'm very excited, I animated two units that only had the stand, and I'm dying to give the last one a unique ability. The units are the Drake Conqueror and the Drake High Champion respectively, which are the Lv.4 and Lv.5 of the Drake Enforcer.
- Attachments
-
- High-Champion.png (12.75 KiB) Viewed 1683 times
-
- conqueror.png (11.68 KiB) Viewed 1683 times
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Re: Trying to create a new weapon special.
The following add-on had errors and could not be loaded:
C:\Users\ar046\OneDrive\Documentos\My Games\Wesnoth1.16/data/add-ons/Reign_of_the_Lords/_main.cfg
Please report this to the author or maintainer of this add-on.
Details:
Preprocessor symbol 'MESSAGE' defined at languages/el_GR.cfg:82 expects 4 arguments, but has 2 arguments
at ~add-ons/Reign_of_the_Lords/macros/Parry_Special.cfg:16
included from ~add-ons/Reign_of_the_Lords/_main.cfg:39
included from ~add-ons/Reign_of_the_Lords/units/drakes/High_Champion.cfg:36
included from ~add-ons/Reign_of_the_Lords/_main.cfg:53
I'm getting this argument error, which I don't understand the cause of, I've made other codes work perfectly with this mod, but this one is getting me, miserable code lol.
C:\Users\ar046\OneDrive\Documentos\My Games\Wesnoth1.16/data/add-ons/Reign_of_the_Lords/_main.cfg
Please report this to the author or maintainer of this add-on.
Details:
Preprocessor symbol 'MESSAGE' defined at languages/el_GR.cfg:82 expects 4 arguments, but has 2 arguments
at ~add-ons/Reign_of_the_Lords/macros/Parry_Special.cfg:16
included from ~add-ons/Reign_of_the_Lords/_main.cfg:39
included from ~add-ons/Reign_of_the_Lords/units/drakes/High_Champion.cfg:36
included from ~add-ons/Reign_of_the_Lords/_main.cfg:53
I'm getting this argument error, which I don't understand the cause of, I've made other codes work perfectly with this mod, but this one is getting me, miserable code lol.
-
- Posts: 7
- Joined: March 22nd, 2024, 4:14 am
Re: Trying to create a new weapon special.
How the hell can such a simple concept be so difficult to apply... Or maybe I'm just too foolish...
Re: Trying to create a new weapon special.
You are not able to use anything that is not documented. Even if it does not show immediate error it does nothing. So to guide you towards solution, link where is MESSAGE documented.
Maintainer of Ageless Era. Ravana's Multiplayer Works
- beetlenaut
- Developer
- Posts: 2828
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Trying to create a new weapon special.
I think because you just barely know WML at this point. Most things are hard at the beginning.Lythosagin wrote: ↑March 23rd, 2024, 12:44 am How the hell can such a simple concept be so difficult to apply
The code you have posted is not something you can "fix". Almost every line needs to be erased and rewritten. Just start over, and make the simple ability Pentarctagon told you to. It probably won't work on the first try either, but it's something small we can actually help you with. When that very simple version of the ability works in the game, that's when you go back to the code and add the next feature. You make it closer to what you want one piece at a time, testing each piece as you go. (This is how I would write it myself.)
Do not use an AI anymore. Apparently, they write complete nonsense when you ask for WML.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- unterwassermann
- Posts: 28
- Joined: August 2nd, 2023, 12:50 pm
- Location: Mars
Re: Trying to create a new weapon special.
You should download eras with more complex abilities/specials like EoMa and take them apart to see how they did it.