cloning units

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
Post Reply
deoxy
Posts: 208
Joined: May 16th, 2007, 5:22 pm
Location: Texas

cloning units

Post by deoxy »

I've done a couple of experiments to test this, and it SEEMS to work; I hereby suggest a small change to the format of all units in the future:

Instead of this:

[unit]
id=Blahblahblah
cost=74
race=Blahsomemore
...
...
[/unit]

I suggest this:

#def UNIT_BLAH_BASE
cost=74
race=Blahsomemore
...
...
#enddef

[unit]
id=Blahblahblah
{UNIT_BLAH_BASE}
[/unit]

Reason: cloning.

I had a thought about mercenaries (that is, being able to recruit from other factions at a cost increase), but changing the cost of units seems to be impossible - "clone the unit, and make the changes you want" is the way to go.

Well, this would make cloning MUCH easier, and it would be self-updating as well (that is, you wouldn't have to make changes in more than one place).

In the above example, if I wanted to change the cost of the unit, it would look like this:

[unit]
id=BlahblahblahCheap
{UNIT_BLAH_BASE}
cost=27
[/unit]

The last entry for cost takes precedence (I tried it). There are several possible uses for this (I'll be posting one later in the Factions forum).

The graphics might need to be added as it's own macro - haven't played enough with graphics yet to know.

Just a thought from a noob.
Insert nifty witticism here... if only I had one.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Uh, if someone needs duplicate units for their own devices, why would we ever want to mess with all mainline units for that? :?
User avatar
Chris NS
Posts: 540
Joined: May 6th, 2006, 3:22 pm
Location: Where the Queen lives

Post by Chris NS »

Here's possibly a better idea: make it possible to modify a unit definition for the duration of a campaign/scenario. If you want to create a unit that is identical in every way but one (e.g. higher gold cost, additional advancement option), currently you have to create a custom unit, and remember to update it every time the original unit changes, which is a bit of a pain.

Or, alternatively, could WML be shaped to allow defining a custom unit with "As [unit name] except [modifications]"?

Or can this be done already?
User avatar
TL
Posts: 511
Joined: March 3rd, 2007, 3:02 am

Post by TL »

zookeeper wrote:Uh, if someone needs duplicate units for their own devices, why would we ever want to mess with all mainline units for that? :?
To make it easier for people to make duplicates of mainline units for their own devices?

The idea itself isn't much of a work saver (since it takes 2 seconds to copy + paste a unit definition and change whatever you need to change) but it would have the advantage that changes to mainline units would be reflected in your duplicates without having to update them manually. I don't know how much mainline units will actually be changing after the next few dev versions anyhow though...

Although Chris's ideas would probably be even more useful than the original post's idea.
deoxy
Posts: 208
Joined: May 16th, 2007, 5:22 pm
Location: Texas

Post by deoxy »

zookeeper wrote:Uh, if someone needs duplicate units for their own devices, why would we ever want to mess with all mainline units for that? :?
I wouldn't call it "messing with" them - they would be (in terms of gameplay and balance) identical. In fact, I'd even volunteer to the do the modifications - it really wouldn't take all that long.

It could also be done on a "going forward" basis - the next time you modify a unit CFG file, make the change.

Also, I would highly recommend this format for personal usage as well - as I mentioned, I've got an example of something I've already used it for.

Example: Level 0 unit with loyalty. Remember, I asked about it in the WML Workshop forum, and you helped me out? This solution worked better for me - I cloned the unit and changed the race to one that included the trait of Loyalty.

(I cloned it to make the same level 0 unit available as regular and "noble" varieties, where the regular one is, well, regular, and the "noble" one is loyal and has a custom trait that is noticeably stronger than a normal one as well... for a substantial cost increase, of course. By using the method above, the "normal" unit took 3 extra lines of code, and the "noble" unit took a total of 6 lines instead of another whole unit entry... which REALLY helps when it comes time to balance those units, since all changes that affect them both will only have to be made in ONE place instead of two. Movement, attacks, graphics, etc, etc. Very helpful! I hop to get some feedback on this concept in the Factions & Era forums when I get around to posting the examples... which will hopefully be soon.)

Answer to Chris NS - this could already be done with the method I just described (I don't think you could easily take attacks away, though - that's the only weakness I can think of). Of course, it might be doable other ways, too (zookeeper would know MUCH better than I, of course!).
Insert nifty witticism here... if only I had one.
deoxy
Posts: 208
Joined: May 16th, 2007, 5:22 pm
Location: Texas

Post by deoxy »

I found another weakness of this method: you can't add abilities. You can certainly GIVE abilities, but any abilities you give replace all existing abilities, which means that for trolls (as an example), if you added an ability, you'd have to remember to also add regeneration again.

Of course, now that I think about it, otherwise you wouldn't be able to remove abilities, either, so I guess it's not so bad.

Still liking the way this works.
Insert nifty witticism here... if only I had one.
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

Something similar is already done for the Walking corpse, see Undead_Corpse_Walking.cfg
The difference is that it is used to define different variations of the same unit, not different units. I don't think that it would work well for units in general. I have for some time thought about adding a tag like:

Code: Select all

inherit = Goblin Rouser
that would allow you to define units in terms of existing units + modifications. There are several issues that need to be resolved before doing that, and it is pretty low on the list of things for me to do. Here are some things that would need to be done to make it practical (well, some can already be done, but they would need to be done in the context of the inheritance) :

1) easily add/remove abilities
2) easily add/remove attacks.
3) easily change graphics names/paths.

So, in short, I don't like the idea of using macros for every unit. In the long haul, the correct way to do this is to add a new WML tag or two that will allow you to directly define unit types from another unit type.
deoxy
Posts: 208
Joined: May 16th, 2007, 5:22 pm
Location: Texas

Post by deoxy »

Darth Fool wrote:Something similar is already done for the Walking corpse, see Undead_Corpse_Walking.cfg
The difference is that it is used to define different variations of the same unit, not different units. I don't think that it would work well for units in general. I have for some time thought about adding a tag like:

Code: Select all

inherit = Goblin Rouser
that would allow you to define units in terms of existing units + modifications. There are several issues that need to be resolved before doing that, and it is pretty low on the list of things for me to do. Here are some things that would need to be done to make it practical (well, some can already be done, but they would need to be done in the context of the inheritance) :

1) easily add/remove abilities
2) easily add/remove attacks.
3) easily change graphics names/paths.

So, in short, I don't like the idea of using macros for every unit. In the long haul, the correct way to do this is to add a new WML tag or two that will allow you to directly define unit types from another unit type.
In the long haul, you are correct. In the short term, a macro allows easy adding of attacks, easy over-ride of all abilities, easy change of most named stuff, and I *think* (but haven't tried) that you could modify an attack by adding another attack with the same ID. The graphics part is a problem, of course, but attacks could be modified/removed by effects that are built into the unit.

Question: would having too many macros cause any performance problems?
Insert nifty witticism here... if only I had one.
Post Reply