WML seems to work but game does not recognise change
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.
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
WML seems to work but game does not recognise change
Hello,
I'm developing a campaign and designed a trait that made units take more magical damage by reducing their arcane resistance.
The units are played by the AI. The traits are added by having the AI recruit "no trait" units then the traits are randomly added after.
This works for existing traits and my custom ones ... except this one!
The trait adds 40 to arcane resistance. Debug->Inspect confirms that the unit does indeed have the modified arcane resistance.
However the unit description still reports the default (i.e. [unit_type]) value and combat reflects this.
I've seen other campaigns modify other [resistance] parameters and my code looks similar.
Any ideas what I'm doing wrong or missing?
I'm happy to post code if that helps...
Thanks in advance for your time and trouble, much appreciated!
I'm developing a campaign and designed a trait that made units take more magical damage by reducing their arcane resistance.
The units are played by the AI. The traits are added by having the AI recruit "no trait" units then the traits are randomly added after.
This works for existing traits and my custom ones ... except this one!
The trait adds 40 to arcane resistance. Debug->Inspect confirms that the unit does indeed have the modified arcane resistance.
However the unit description still reports the default (i.e. [unit_type]) value and combat reflects this.
I've seen other campaigns modify other [resistance] parameters and my code looks similar.
Any ideas what I'm doing wrong or missing?
I'm happy to post code if that helps...
Thanks in advance for your time and trouble, much appreciated!
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: WML seems to work but game does not recognise change
you clearly should. Otherwise it would be extremely difficult to try figuring out what's wrong.Spannerbag wrote:I'm happy to post code if that helps...
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Re: WML seems to work but game does not recognise change
If by "unit description" you mean the help page for the unit, then yes that will always only show the unit type stats, not stats of individual units.
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: WML seems to work but game does not recognise change
Righty-ho.ForestDragon wrote:you clearly should. Otherwise it would be extremely difficult to try figuring out what's wrong.Spannerbag wrote:I'm happy to post code if that helps...
First, the trait code:
Code: Select all
#define TRAIT_MAGIC_PRONE PRONENESS
[trait]
id=magic_prone{PRONENESS}
male_name= _ "magic prone"
female_name= _ "female^magic prone"
description= _ "Reduced resistance to magic ({PRONENESS}%)"
[effect]
apply_to=resistance
replace=no
[resistance]
arcane={PRONENESS}
[/resistance]
[/effect]
[/trait]
#enddef
The AI recruits a unit with no traits such as:
Code: Select all
[unit_type]
id=Spearman_nt
[base_unit]
id=Spearman
[/base_unit]
num_traits=0
[/unit_type]
Code: Select all
# Ledhed's recruits have traits DIM, MAGIC_PRONE or FLATFOOT and are SOBER, HUNGOVER or DRUNK
[event]
name=prerecruit
first_time_only=no
[filter]
side=3
[/filter]
[set_variable]
name=random_split
rand=0,1,2
[/set_variable]
[switch]
variable=random_split
[case]
value=1
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{TRAIT_DIM}
[/modify_unit]
[/case]
[case]
value=2
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{TRAIT_MAGIC_PRONE 40}
[/modify_unit]
[/case]
[else]
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{TRAIT_FLATFOOT_SMALLFOOT}
[/modify_unit]
[/else]
[/switch]
[clear_variable]
name=random_split
[/clear_variable]
[set_variable]
name=random_split
rand=0,1,2
[/set_variable]
[switch]
variable=random_split
[case]
value=1
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{TRAIT_SOBER}
[/modify_unit]
[/case]
[case]
value=2
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{TRAIT_HUNGOVER}
[/modify_unit]
[/case]
[else]
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{TRAIT_DRUNK}
[/modify_unit]
[/else]
[/switch]
[clear_variable]
name=random_split
[/clear_variable]
[heal_unit]
amount=full # Fix any hit point changes
[/heal_unit]
[/event]
Yet when the unit is attacked magically, damage is the same as for other units and not more.
The only other wrinkle is that the attacking Mages have a slight chance of suffering something unpleasant if they miss but that doesn't interfere with attacks that hit so I suspect that's a red herring.
Any help gratefully received!
- James_The_Invisible
- Posts: 536
- Joined: October 28th, 2012, 1:58 pm
- Location: Somewhere in the Northlands, fighting dark forces
- Contact:
Re: WML seems to work but game does not recognise change
I have a feeling that you are mixing up 2 things. Magical is a weapon special which modifies the chance to hit (sets it to 70%) while arcane is one damage type. Mages do not always use arcane attacks, some human mages cast fire spells while others have arcane or cold attacks. Elvish shamans even use a spell that deals impact damage.
So your trait should probably also modify resistance to fire and cold.
So your trait should probably also modify resistance to fire and cold.
My content: For Power series
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
Ports: Danse Macabre Story of the Wose
Guides: How to translate your UMC
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: WML seems to work but game does not recognise change
James_The_Invisible wrote:I have a feeling that you are mixing up 2 things. Magical is a weapon special which modifies the chance to hit (sets it to 70%) while arcane is one damage type. Mages do not always use arcane attacks, some human mages cast fire spells while others have arcane or cold attacks. Elvish shamans even use a spell that deals impact damage.
So your trait should probably also modify resistance to fire and cold.
Ah. The light shineth. Many thank, James.
What I want to do which is increase the damage suffered by a unit when it's attacked by a spell, regardless of damage type.
I don't want to affect other damage, just spell damage or, failing that, all magical damage.
So ... what I need to do is somehow filter out the relevant attacks (Magical/ranged/unittype?) then manually multiply the damage ... or change [resistance] on the fly.
I'll do some thinking.
Thanks again for taking the time. Much appreciated.
PS - If I do ever get this working I'll have to come up with a snappier name than "Magic Prone". Suggestions very welcome!
Re: WML seems to work but game does not recognise change
There's no simple way to do that.Spannerbag wrote:What I want to do which is increase the damage suffered by a unit when it's attacked by a spell, regardless of damage type.
I don't want to affect other damage, just spell damage or, failing that, all magical damage.
So ... what I need to do is somehow filter out the relevant attacks (Magical/ranged/unittype?) then manually multiply the damage ... or change [resistance] on the fly.
What I think you basically need is a recruit,recall,side turn,attack event which finds all units for which this hasn't already been done, and gives all of their attacks which match your filtering criteria (has magical, or has one of the listed names, or is ranged+arcane, or whatever) an invisible [damage] weapon special which multiplies the damage if the enemy unit has the trait.
In 1.13, it'll be a bit simpler to do with the unit placed event, but the above works pretty well too. Although without some extra cleverness you won't be able to undo recruits with no random traits (such as undead), and units that the scenario places mid-turn might not correctly show the damage multiplication in the attack dialog. But maybe those are insignificant details.
Anyway, as said, it's not exactly simple to do.
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: WML seems to work but game does not recognise change
Thanks for the advice, much appreciated. This trait would be nice to have but isn't essential.zookeeper wrote:There's no simple way to do that. ... [snip] ... Anyway, as said, it's not exactly simple to do.Spannerbag wrote:What I want to do which is increase the damage suffered by a unit when it's attacked by a spell, regardless of damage type.
I don't want to affect other damage, just spell damage or, failing that, all magical damage.
So ... what I need to do is somehow filter out the relevant attacks (Magical/ranged/unittype?) then manually multiply the damage ... or change [resistance] on the fly.
Being a lazy so-and-so, I'll just modify my approach.
Thanks again to all who took the trouble to reply.