Adding a +20% Withdraw Rate to ALL units?

James009

Warlord
Joined
Nov 13, 2002
Messages
278
I was wondering how I could go about adding a +20% withdraw rate to all units to simulate more realistic combat. I've never been a huge fan of the "winner takes all" system and kinda like what I've seen from Civ V videos. I think it might be worth messing with.

Is there a global define or a quick way to add this. The best way I can think of is to add it to the Combat I promotion.

Thanks!
 
I have made extensive use of the Withdrawal bonus. But what I did was add it to the Civ4Unitinfos file

Change
Code:
<iWithdrawalProb>0</iWithdrawalProb>
to
Code:
<iWithdrawalProb>20</iWithdrawalProb>

NOTE: Do not raise this number too high as the total bonus can not exceed Maximum Value is in GlobalDefines.xml, else the unit will not be able to get any more promotions or the ability to add a General.
 
In VIM it can be done with a series of probably 9 commands:

%s/iWithdrawalProb>8/iWithdrawalProb>10
%s/iWithdrawalProb>7/iWithdrawalProb>9
%s/iWithdrawalProb>6/iWithdrawalProb>8
..
%s/iWithdrawalProb>0/iWithdrawalProb>2

There's is a one-liner too, but is too late.. Probably 9 because if a unit has a withdrawal prob of 5%, this would only change it to 7% since we're assuming the 2nd digit will be there.
 
Personally, I'd make the palace to add a unique building, like 'Town Hall' or something, to every city you have . Then make the 'Town Hall' grant that promotion to all units you build. Seems like the least work and least problems to me.
 
I started doing the Civ4UnitInfos fix but there are over 350 units. That's certainly possible to do but it'd take me quite some time.

Or just change the Palace to give the promotion.

That'd only work in the capital :crazyeye:
 
Just get Notepad ++, open the file, and search and replace
<iWithdrawalProb>0</iWithdrawalProb>
with
<iWithdrawalProb>20</iWithdrawalProb>
 
Just get Notepad ++, open the file, and search and replace
<iWithdrawalProb>0</iWithdrawalProb>
with
<iWithdrawalProb>20</iWithdrawalProb>
Nice, didn't know there was a "Search and Replace" feature. That made it much easier.

The reason I'd like this to be a globally defined thing is because of two things: 1) Barbarians and 2) cavalry units (should be >20%). The Palace, for example, wouldn't apply to the barbarians. However, that might be worth it if combined with other options.

Thanks for the ideas :)
 
Just get Notepad ++, open the file, and search and replace
<iWithdrawalProb>0</iWithdrawalProb>
with
<iWithdrawalProb>20</iWithdrawalProb>
Agree Notepad++ is one of the best tools - and search and replace function in many editors is brilliant.

As to changing 350 units. That is nothing in comparison to over 5,000 units in my Worldbuilder file.
 
You should adjust the ones that already have withdraw chances first so you don't end up with things like chariots having a 10% withdraw, which is now below the baseline that every other unit has.

How do you find all of them without just doing a find on "<iWithdrawalProb>" and looking at them all? Probably the easiest way is to use a basic regular expression search. No, really. Notepadd++, and many other editors, allow you to set the find function to use a thing called a "regular expression" (also known as a "regex") in the search field. The details might vary a little, but in general this should work (it certainly does in Notepad++):
search for "<iWithdrawalProb>[^0]" (without the quotes).
That means "find the text string '<iWithdrawalProb>' followed by a character that is not a 0".

If you can't find the "^" character on your keyboard (or it causes it to accent some other character instead of producing a standalone character, or you just feel like it) then you can use "<iWithdrawalProb>[123456789]" which means "find the text string '<iWithdrawalProb>' followed by one character that is in the set of 1,2,3,4,5,6,7,8,9". Or you can simplify the set specification to "[1-9]" since a "-" in this context indicates a range.

Even if you don't know anything else about regular expressions, that one thing can save you a truckload of time. So remember: "[set]" means that you are looking for a character that is in the set you specified and "[^set]" means that you are looking for a character that is not in the set you specified (the "^" only means this when it is the first thing inside the bracket).

Well, you might also want to know that there are other characters that have special meanings and can't appear as plain text for the search without prefixing a "\" on it - the list is something like \.()[]^$*+ (I may have missed one or two). If any of these are in the text you are specifying (outside of a set specification), then you need to put a "\" in front of it.
 
You should adjust the ones that already have withdraw chances first so you don't end up with things like chariots having a 10% withdraw, which is now below the baseline that every other unit has.

How do you find all of them without just doing a find on "<iWithdrawalProb>" and looking at them all? Probably the easiest way is to use a basic regular expression search. No, really. Notepadd++, and many other editors, allow you to set the find function to use a thing called a "regular expression" (also known as a "regex") in the search field. The details might vary a little, but in general this should work (it certainly does in Notepad++):
search for "<iWithdrawalProb>[^0]" (without the quotes).
That means "find the text string '<iWithdrawalProb>' followed by a character that is not a 0".

If you can't find the "^" character on your keyboard (or it causes it to accent some other character instead of producing a standalone character, or you just feel like it) then you can use "<iWithdrawalProb>[123456789]" which means "find the text string '<iWithdrawalProb>' followed by one character that is in the set of 1,2,3,4,5,6,7,8,9". Or you can simplify the set specification to "[1-9]" since a "-" in this context indicates a range.

Even if you don't know anything else about regular expressions, that one thing can save you a truckload of time. So remember: "[set]" means that you are looking for a character that is in the set you specified and "[^set]" means that you are looking for a character that is not in the set you specified (the "^" only means this when it is the first thing inside the bracket).

Well, you might also want to know that there are other characters that have special meanings and can't appear as plain text for the search without prefixing a "\" on it - the list is something like \.()[]^$*+ (I may have missed one or two). If any of these are in the text you are specifying (outside of a set specification), then you need to put a "\" in front of it.
Good tips! Thanks for the help. This should make it a lot easier.

When I initially started the modification, I did start from the bottom up and noticed what you said as a problem. Then went from the highest number down. I could have saved ten or fifteen minutes if I'd read your tip first :lol:
 
Thanks God-Emperor, I just learned something new.
 
Then make the capital like stonehenge, but instead of monuments it gives dummy buildings that give the trait.
Don't get me wrong, that is a possibility. The only problem with that would be that it couldn't apply to barbarian or rebellion units (or anyone without capitals). That's a minor problem but given the amount of work it'd be to add in something that grand (ie. a building) it'd be easier, for me, just to do a mix of combat modifications and individual unit editing using God-Emperor's trick.

Actually, a combination of all of the above propositions may lead to some interesting results where trained national units are more survivable then barbarians and untrained units. Probably a little more realism too.

I've modified all the unit withdraw rates using the find and replace function (thanks for that) and I like the results. Units don't die as often so you won't always lose that highly trained commando going on suicide missions, units retreat and withdraw from combat, and fights last a little longer. I'm enjoying it!
 
Don't get me wrong, that is a possibility. The only problem with that would be that it couldn't apply to barbarian or rebellion units (or anyone without capitals). That's a minor problem but given the amount of work it'd be to add in something that grand (ie. a building) it'd be easier, for me, just to do a mix of combat modifications and individual unit editing using God-Emperor's trick.

Actually, a combination of all of the above propositions may lead to some interesting results where trained national units are more survivable then barbarians and untrained units. Probably a little more realism too.

I've modified all the unit withdraw rates using the find and replace function (thanks for that) and I like the results. Units don't die as often so you won't always lose that highly trained commando going on suicide missions, units retreat and withdraw from combat, and fights last a little longer. I'm enjoying it!

Just copy another building and set all its fields blank (civilopedia and those are />'d) and make the description a ' ' (Space). Ta-daa! And create a new artdefinesbuilding entry that has nothing.
 
What is VIM? :confused: This has something to do with Regular Expressions, right?
 
When many people start modding they use Notepad, since that is what comes with Windows. It's fine for editing a few numbers, but is very limited. Next up is Notepad++ which adds more capability and is able to handle edits like in this thread, although it takes many search+replace operations to get the task done. These are both really easy to use. Now, lets say you are creating a scenario by editing a WBS file and it's crashing. One check is to delete all of the units, and try it again. In Notepad* one method would be to save the file, and then plod through it searching for each BeginUnit, then using the mouse to select the right lines, and hitting delete. Repeat for every unit in the file.... whereas in vim this can be accomplished with 1 command.

An illustrative example comes from creating the 400AD scenario for RFRE. This is just after the WRE/ERE split, so the task is to give ownership of all units and cities in "the west" to the WRE, while leaving the rest as it. This is primarily accomplished using search+replace, but is applied using marks to set the range over which the s+r will happen. The WRE needs to take ownership of 64 cities and 147 units. This took me about 5 minutes to complete (the line of the split isn't straight, so while 2 s+r did 98%, there was some individual cleanup to do).

Text editing is not new. If you find yourself mindlessly repeating operations, rest assured that someone has already created a suitable tool.
 
Top Bottom