Opened 11 years ago
Last modified 11 years ago
#1757 new enhancement
[PATCH] Script to automatically change unit stats
Reported by: | alpha123 | Owned by: | |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Backlog |
Component: | Non-game systems | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
I wrote a command-line script to automatically bulk-adjust unit stats.
Synopsis:
./changestats.pl --key Armour/Pierce --change 1 Melee Cavalry
Options:
--key, -k: This is the XML element to modify. Can be arbitrarily deep, i.e. Cost/Resources/food works as expected.
--change, -c: How much to modify the key by. For negative numbers, you'll need an equals sign: ./changestats.pl --Key Cost/BuildTime -c=-10 Domestic
--mod, -m: The mod to use. Defaults to "public".
--print, -p: If this is specified, changestats will only print matching templates and not do any modification.
Warnings:
USE WITH CAUTION! THIS THING IS EXPERIMENTAL AND HASN'T BEEN THOROUGHLY TESTED!
You probably ought to double-check that it made all the modifications correctly. That said, it has worked quite well for me so far.
It's also kind of slow. There's probably a much more efficient way to do what it does. Now, before you complain too much, it searches through hundreds of templates... anyway it is still much faster than adjusting stats by hand. I'm just warning you in case it seems like it's taking a while. That's normal.
Attachments (1)
Change History (12)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Description: | modified (diff) |
---|---|
Keywords: | patch added |
Milestone: | Backlog → Alpha 13 |
Summary: | Script to automatically change unit stats → [PATCH] Script to automatically change unit stats |
by , 11 years ago
Attachment: | changestats.pl added |
---|
follow-up: 5 comment:3 by , 11 years ago
I just used the script, it was very helpful but there were a couple of issues.
When modifying walk speed it stuck \n (those two characters, not a new line) after the number.
It made the change:
# - <History></History>
# + <History/>
comment:4 by , 11 years ago
Another issue is that it added a whole load of .0 onto the end of numbers. This is bad because many of them were integers.
follow-up: 6 comment:5 by , 11 years ago
Replying to quantumstate:
I just used the script, it was very helpful but there were a couple of issues.
When modifying walk speed it stuck \n (those two characters, not a new line) after the number.
That's... odd. I'll see what I can do.
It made the change:
# - <History></History>
# + <History/>
Oh. :-/ That could be kind of hard to fix, but is it really much of a problem? (The XML parser we use [libxml2?] should handle this, right?)
Another issue is that it added a whole load of .0 onto the end of numbers. This is bad > because many of them were integers.
That's actually an undocumented feature. This is because I only tested it with Attack and Armor stats, which always end in .0. That's pretty easy to fix.
follow-up: 7 comment:6 by , 11 years ago
# - <History></History>
# + <History/>
Oh. :-/ That could be kind of hard to fix, but is it really much of a problem? (The XML parser we use [libxml2?] should handle this, right?)
Yes, it shouldn't cause issues, it would be nice if it didn't change unrelated sections of the xml though. I guess this isn't a big issue.
comment:7 by , 11 years ago
Replying to quantumstate:
Yes, it shouldn't cause issues, it would be nice if it didn't change unrelated sections of the xml though. I guess this isn't a big issue.
I'd prefer if it didn't change unrelated sections of XML either, but there really isn't any way around that. I might have to modify XML::DOM to have it output <History></History> instead, and that could get messy, because then I'd have to bundle my modified module with the script or something.
Thanks for the reports. I'll fix them soon.
comment:8 by , 11 years ago
Milestone: | Alpha 13 → Alpha 14 |
---|
follow-up: 11 comment:9 by , 11 years ago
I think this should be attached to a Trac page or something with corresponding documentation, until it is sufficiently tested and there's a demonstrated need for it in SVN (rather than having it linger here as a reviewable patch that's not necessarily needed).
comment:10 by , 11 years ago
Keywords: | review removed |
---|---|
Milestone: | Alpha 14 → Backlog |
comment:11 by , 11 years ago
Replying to historic_bruno:
I think this should be attached to a Trac page or something with corresponding documentation, until it is sufficiently tested and there's a demonstrated need for it in SVN (rather than having it linger here as a reviewable patch that's not necessarily needed).
I agree. I'll get around to making a wiki page, sometime (no guarantees on when).
Oh, and it requires the XML::DOM module. I've since learned this might be somewhat outdated, though it works perfectly well. Anyway, it came with my installation, but I don't think it's standard. Sorry about that.