Save Editing: How to edit unit defense?

General feedback and discussion of the game.

Moderator: Forum Moderators

Post Reply
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Save Editing: How to edit unit defense?

Post by anl93 »

Can you tell me how to edit units movement cost or terrain defense.
Editing directly on the [defense] is work but is lost on level up so i need to add permanent code to the units traits.
only problem i don't know how but i know basics. so if you can give me a hand i would be grateful.
User avatar
EarthCake
Posts: 377
Joined: March 29th, 2019, 1:57 pm
Location: The Wall

Re: Save Editing: How to edit unit defense?

Post by EarthCake »

It is lost on level up because their level ups don't have that defense. So there are two things you can do:
1) You can code level ups to have same defense / movement cost, so that defense won't be lost on level up
2) You can edit defense in units.cfg in core, so all units with that movement type will have the same defense on the same type of terrain.
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

2) no its not what i have asked for.

[trait]
.
.
.
.
[effect]
apply_to="defense"
replace=yes
[defense]
forest=20
[/defense]
[/effect]
[/trait]

should have work but is not working
User avatar
Ravana
Forum Moderator
Posts: 3009
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Save Editing: How to edit unit defense?

Post by Ravana »

You mean if you change both directly, and add trait too? I expect that some tags are only used when rebuilding unit, while current stats are stored in transient fields.
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

Ravana wrote: July 17th, 2019, 10:10 pm You mean if you change both directly, and add trait too? I expect that some tags are only used when rebuilding unit, while current stats are stored in transient fields.
Changing directly works but the change is lost upon level up
Adding trait( modifying one) is permanent but i cant get it to work.
It should have work but it didnt.
User avatar
Ravana
Forum Moderator
Posts: 3009
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Save Editing: How to edit unit defense?

Post by Ravana »

Is there any reason you want to edit it by save file rather than debug mode?
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

Ravana wrote: July 17th, 2019, 11:03 pm Is there any reason you want to edit it by save file rather than debug mode?
How can i make this possible with the debug mode can you give me the command?
For example i want the selected unit to have 70 forest defense.

Thank you again i willalso try this

Edit: I now realised even if you add trait via save editing you still have to manually change units core stats to make change effective.
SO RESULTS:;
1) adding trait:
only visual on units trait description so no actual change
2) editing unit directly:
only actual change, you can't see the change on units trait bar on the right also effect is lost on level up.
3) adding trait and editing unit:
both visual and real value change on unit but i will test stats after level up (i think they will keep it).

tweaking with files is so much fun.
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

I confirm 3. is working on level ups also i was right i managed to get it worked about defense.

[effect]
apply_to="defense"
replace=yes
[defense]
forest=20
[/defense]
[/effect]
[/trait]

was correct now i will test for modifying unit movement costs.
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Save Editing: How to edit unit defense?

Post by josteph »

You don't need traits. You can just give the unit a [modifications] tag. If you need an example, go to HttT S4, pick up the storm trident, and then do :inspect and look at the unit's WML in the inspect window. Here's an example from the test scenario:

Code: Select all

        [unit]
            x,y=18,12
            type="Ghost"
            name="Steadfast tester"
            [modifications]
                [object]
                    [effect]
                        apply_to=new_ability
                        [abilities]
                            {ABILITY_STEADFAST}
                        [/abilities]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

josteph wrote: July 18th, 2019, 1:19 pm You don't need traits. You can just give the unit a [modifications] tag. If you need an example, go to HttT S4, pick up the storm trident, and then do :inspect and look at the unit's WML in the inspect window. Here's an example from the test scenario:

Code: Select all

        [unit]
            x,y=18,12
            type="Ghost"
            name="Steadfast tester"
            [modifications]
                [object]
                    [effect]
                        apply_to=new_ability
                        [abilities]
                            {ABILITY_STEADFAST}
                        [/abilities]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
wow, do i need to add these lines;
x,y=18,12
type="Ghost"
name="Steadfast tester"

can i just skip to the [modifications] ... [/modifications] part?
also do i need the [/object] part?

my idea:

Code: Select all

	[modifications]
		[effect]
			apply_to="defense"
			[defense]
				hills=-10
				mountains=-10
			[/defense]
		[/effect]
		[effect]
			apply_to="movement_costs"
			[movement_costs]
				hills=-1
				mountains=-1
			[/movement_costs]
		[/effect]
	[/modifications]
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Save Editing: How to edit unit defense?

Post by josteph »

Just copy the [modifications]..[/modifications] lines into the unit definition in the savefile. The other three lines are there because that example creates a unit with an object, you're asking how to add an object to an existing unit.

edit: I see your edit. Do add the [object] and [/object] lines, that sort of thing generally matters.
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

one last question how can make "-1" number to show in green color?

Code: Select all

		description= _ "hills & mountains defense +10"+_"
hills & mountains movement cost -1"

i want "+10" as green ?
Shiki
Developer
Posts: 349
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Save Editing: How to edit unit defense?

Post by Shiki »

description= _ "hills & mountains defense <span color='green'>+10</span>."
different example which does not include the color in the string for translators:
description= _ "hills & mountains defense" + " " + <span color='#6-digit-hexcode-here_including_hash sign'>+10</span> + "."
Note that your example code will leave no space between the +10 and the next word.
Try out the dark board theme.
anl93
Posts: 22
Joined: August 27th, 2012, 5:18 pm

Re: Save Editing: How to edit unit defense?

Post by anl93 »

Shiki wrote: July 18th, 2019, 5:34 pm description= _ "hills & mountains defense <span color='green'>+10</span>."
works like a charm thanks guys now i managed to add traits like:
forester, highlander, drill, amphitious and so on...
Post Reply