Adjusting Unit Movement

Rock on! That cut the time spent down to 1/1000! Now, and I know I may be pushing it with this one: I want to cut production costs by 50% all across the board; however, I cannot take the time to create a script for every possible input for this one. Is it possible to creat a script that will manipulate numbers symbolically like variables and then round the decimals up?
 
Yeah, good tools are far better than mindless repetition ;)

That may be possible in vim, but I don't know how. This sort of thing is best done in a scripting language like Perl.

Code:
#!/usr/bin/perl
while(<>){
   if ( /iCost>(\d+)/ ){
     $OrigCost = $1;
     $fhalf = $OrigCost * .5;
     $fhalf =~m/(\d+)\.?/; 
     $half = $1;
     $_ =~s/$OrigCost/$half/;
   }
   print;
}

Note that it's iCost, so it needs to be an integer. Also this is assuming human readable XML, that is there are newlines between tags (perl's default is reading to the next newline to get a line). As for running perl.. there are a number of ways. I use cgywin since it's provides many tools I use (ie those available on unix systems). In cgywin, cd to the ...mod..Assets/XML/Units directory. Paste the above text into a file named "half.pl", and then at the prompt type: perl half.pl CIV4UnitInfos.xml > boo.txt. The changes only go into boo.txt. Now you can use your favorite diff program to look over the changes (eg at the cgywin prompt: diff CIV4UnitInfos.xml boo.txt | less). If it looks good then rename the original file, and then rename boo.txt to CIV4UnitInfos.xml.

If that's too complex then upload the file and I'll make the changes. An advantage of you learning how though is maybe 70% would be better, and once you have it it is easy to make such changes.
 
primordial stew, there has got to be a syntax meltdown somewhere there.
"Bash: perl: command not found"

EDIT: Just remembered that Perl isn't installed on non-unix systems, I got Vista.
 
Just use:
type CIV4TechInfos.xml | gawk -f civHalfProd.awk >> CIV4TechInfos.xml.new

create a file civHalfProd.awk that contains ::
Code:
{ 
      if ( match($0, /iCost/) ) {
         num = substr($0, match($0, /[0-9]+/), RLENGTH)
         sz = length(num) 
         num = num / 2
         $0 = substr($0, 1, RSTART - 1)  num  substr($0, sz + RSTART + RLENGTH - 1)
      }
   print $0
}

Requires GNU UnxUtils for gawk

I can't stand perl ;-) gawk rules :king:
 
EDIT: Scratch everything I previously said in this post. Handicap doesn't take direct effect for some reason. I don't know what to do from here.

My mistake. In handicapinfo, you can affect the *AI* development speed only, not what you meant. To make a dramatic change which you could not miss, copy file Program Files/...BTS/Assets/XML/GameInfo/CIV4GameSpeedInfo.xml to ...My Games/BTS/CustomAssets/XML/GameInfo. (Spell out "BTS" in both places :) Then in the copy of the file, find the handicap level you are playing at, such as GAMESPEED_QUICK. Under that are a few percentage values, numbers like 67 or 100. The 67 means that at this speed, the costs of that action are 67% of normal. (Compare to marathon, where the percentages are 300, ie 3x slower than normal.)

Change the numbers in this section from 67 to 10. This means things will go 10x faster. This is probably unplayable but it will be immediately obvious whether your change worked.
 
@primordial
*GRIN* Oh come on now, which one is easier to read ? ;-)

If we just assumed there are 3 tabs before <iCost>, could make it even more legible.
But this way takes in and spits out the same format w/o making assumptions.

I read a quote somewhere, must of been related to slashdot. The creator of perl, made perl cuz "awk" intimidated him.
And yet when I try and read perl script my eyes glaze over.
 
Top Bottom