Trying to mod weather chances

Moderator: AlvaroSousa

Post Reply
aaminoff
Posts: 41
Joined: Mon Dec 11, 2006 12:23 am
Contact:

Trying to mod weather chances

Post by aaminoff »

The editor has a very nice UI where you can change the likelihood of each type of weather in each weather zone. That is fine, and I could sit and click my mouse many times to bump up/down the %ages as I want. However, doing that for 12 zones x 12 months will get tedious. I code in perl and other languages, I figured if I could just see the dump file I could possibly modify the values automatically in there then load it up again.

If I got to the "Data" button, and hit "Weather" under the Save column, it looks like it modifies the file UserSavedData/_weatherMap.dat Any hints as to what format this is in? It looks like it is not any sort of text file, that is to say, the bytes are not characters, but instead I'm guessing it is a string of bytes that is read in by something and turns into data.
- Alex
aaminoff
Posts: 41
Joined: Mon Dec 11, 2006 12:23 am
Contact:

Re: Trying to mod weather chances

Post by aaminoff »

I looked at the weatherMap.dat file, and the entire file has no byte values larger than 10, implying that it is just a big grid of what weather zone each hex is in.

So, I tried saving my scenario (the big .scn file), then modifying the weather in zone 1 in July to be 77% rain, and then saving it again. Doing a diff between the dumps of the 2 files, I find that byte 391276 changed from 0 to 77. Looking around that area I see sequences of bytes that look like we are repeating the chances of each type of weather in each zone. Conceivably I can work with this to change those byte values. If I did, and then loaded the scn file into the editor, I should see the values I changed.

I am pretty sure that there is no separate weather chance in zone file that can get dumped out into _someThing.dat the way there are with other things in the editor. That is unfortunate.
- Alex
aaminoff
Posts: 41
Joined: Mon Dec 11, 2006 12:23 am
Contact:

Re: Trying to mod weather chances

Post by aaminoff »

I was able to modify the byte values, write out a changed version of the scn file, and read it back into the editor and see my new values. The actual mod will have to wait for another day.

Code: Select all

my $f = shift @ARGV;
my $location = shift @ARGV || 0;
my $numbytes = shift @ARGV || 100100100;

open(IN,$f) or die "Could not open $f";

our $OFFSET=$location;
my @bytes = ();

our $buffer = undef;
sysread(IN,$buffer,100100100);
close(IN);

my $printcount = 0;
my $month = 0;
my $zone = 1;

my $i = 0;
while( $i++ < $numbytes ) {
    if ( (getb($i) == 221 || getb($i) == 220) &&
	 getb($i+1) == 254 &&
	 getb($i+2) == 255 &&
	 getb($i+3) == 121 &&
	 getb($i+4) == 221 &&
	 getb($i+5) == 254 &&
	 getb($i+6) == 255) {
	$printcount = 27;
	if ($month++ == 11) {
	    print "\n===== zone $zone =======";
	    $month = 0;
	    $zone++;
	    last if $zone > 10;
	}
	printf("\n%6d %3d ",$i,getb($i-1));
	
	$OFFSET = $OFFSET+$i+6;
	$i=1;
	my $maxj = 0;
	my $max = 0;
	my $sum = 0;
	foreach my $j (1..20) {
	    my $v = getb($j);
	    if ($v > 0) {
		$sum += $v;
		if ($v > $max) {
		    $max = $v;
		    $maxj= $j;
		}
		# clear this value
		vec($buffer,$OFFSET+$j,8)=0;
	    }
	}
	# got to the end. If we found a max, set that column to 100
	#vec($buffer,$OFFSET+$maxj)=100;
	print "maxj:$maxj max:$max sum:$sum";
	if ($max > 0 && $sum > 49) {
	    print " WOULD SET";
	    vec($buffer,$OFFSET+$maxj,8)=100;
	}
    }
		
	
}

print "\n";

my $fn = $f . ".new";
open(OUT,'>',$fn) or die "Could not open $fn";
syswrite(OUT,$buffer);

sub getb {
    my $loc = shift;
    my $realloc = $OFFSET + $loc;
    return vec($buffer,$realloc,8);
}

- Alex
Post Reply

Return to “MODS and Scenarios”