Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » Stars! Extensions » Stars Movies
Stars Movies Tue, 12 June 2012 23:52 Go to next message
ricks03 is currently offline ricks03

 
Officer Cadet 1st Year
Creator of TotalHost and Stars! utilities
Created TotalHost and Stars! utilities

Messages: 221
Registered: January 2012
Location: NC
Years ago I used to put movies together at the end of games using the .map and .pla files and the starmap application

I decided to do that with a recent game, and went ahead and scripted the process out (based on a number of assumptions from how my hosting platform works, but I think it's generally applicable to anyone else).

Here's the code if anyone is interested. I've got a few more weaks to make probably, but this is functional.

# Stars Movie Creator
# 120611
# Rick Steeves
# th@corwyn.net
# version .01

# Creates all of the .map and .pla files to generate "movies" from starmap (or XtremeBorders)
# And then creates batch files to create the starmap .pcx files,
# convert the .pcx files to .jpg with ImageMagick, and then display the .jpg files
# with polyview

# Note starmap doesn't appear to work on modern machines without applying the fix
# from http://www.pcmicro.com/elebbs/faq/rte200.html

# Assumes that the stars turn files are available in some structure
# (currently <whatever>\<year>)
# tho modifying that within the code is fairly simple.

# Builds a number of batch files:
# starmap_<gamefile>.bat - to run starmap for each year and create the .pcx file
# image_<gamefile>.bat - to use imagemagick to convert the .pcx files to .jpg

# It also creates a <gamefile>.pvs file to use with polyview


# Name of the Game (the prefix for the .xy file)
$GameFile = "ACROSS";

# Stars EXE
$executable= "E:\\Stars!\\stars26j\\stars.exe";

# Location of ImageMagic convert applications
$image = "E:\\Program Files\\ImageMagick-6.4.1-Q16\\convert";

# Path of the game backups
# Assumes a structure of <path>\<turn year>
$path = "W:\\Games\\$GameFile";

# Location of the starmap executable
$starmap = "d:\\stars\\utils\\starmap\\starmap2\\starmap.exe" ;

# Where to output the .ini, .pcx, and .bat files
$outputpath = "c:\\temp\\";

# Determine the players to provide output
@numbers = (1,2,3,4);
@passwords = ('','','','g1p');
@names = ('Marshburian','Achutani','Humanoid','FCC');

# Get a listing of all of the backup directories
$BackupDir = $path;
opendir(DIRS, $BackupDir) || die("Cannot open $BackupDir\n");
@AllDirs = readdir(DIRS);
closedir(DIRS);

# Create the Starmap, Polyview, and Image command file
$DataOutFile = $outputpath . "starmap_" . $GameFile . ".bat";
open (MAPFILE, ">$DataOutFile");
$DataOutFile = $outputpath . "image_" . $GameFile . ".bat";
open (IMGFILE, ">$DataOutFile");
$DataOutFile = $outputpath . $GameFile . ".pvs";
open (POLYFILE, ">$DataOutFile");

foreach $name (@AllDirs) {
if ($name =~ /\./) { next; }
if ($name =~ /BACKUP/) { next; }

print MAPFILE $starmap . " -I " . $outputpath . "$name.ini\n";
print IMGFILE "\"" . $image . "\"" . " $outputpath$name.PCX $outputpath$name.jpg\n";
print POLYFILE "\"$name.jpg\" /t1\n";
}
close MAPFILE;
close IMGFILE;
close POLYFILE;

# Generate all the .map files
# Stars! -dm mygame.m1 <-- Dump the universe definition and exit
# Generate all of the .pla files
# Stars! -dp mygame.m1 <-- Dump player 1's planets and exit

foreach $name (@AllDirs) {
if ($name =~ /\./) { next; }
if ($name =~ /BACKUP/) { next; }

# generate the MAP file
$map = $executable;
if ($passwords[$count]) { $map .= ' -p ' . $passwords[$count]; }
$map .= ' -dm ' . $path . "\\" . $name . "\\" . $GameFile . ".m" . $numbers[0];
print "map: $map\n";
system ($map);

# Generate the PLA files
$count = 0;
foreach $number (@numbers) {
$pla = $executable;
if ($passwords[$count]) { $pla .= ' -p ' . $passwords[$count]; }
$pla .= ' -dp ' . $path . "\\" . $name . "\\" . $GameFile . ".m" . $number;
print "pla: $pla\n";
system ($pla);
$count++;
# Wait patiently, stars doesn't like to be launched over and over.
sleep 1;
}

# Generate the starmap2 ini files
$DataOutFile = $outputpath . "\\" . $name . ".ini";
open (INIFILE, ">$DataOutFile");
print INIFILE "[FILES]\n";
print INIFILE "Map " . $path . "\\" . $name . "\\" . $GameFile . ".MAP\n";
foreach $number (@numbers) {
print INIFILE "Pla " . $path . "\\" . $name . "\\" . $GameFile . ".P" . $number . "\n";
}
print INIFILE "Gfx " . $outputpath . $name . ".PCX\n";

# Print names to try to get the colors to stay consistent
# $ctr = 1;
# print INIFILE "\n";
# print INIFILE "[NAMES]\n";
# foreach $name (@names) {
# print INIFILE "$ctr \"$name\"\n";
# $ctr++;
# }

# Print color selection
print INIFILE "\n";
print INIFILE "[COLORS]\n";
foreach $number (@numbers) {
$color = $number * 4;
print INIFILE $number . " " . $color . "\n";
}

close INIFILE;

}



https://www.irelandbybicycle.com
http://totalhost.sinister.net:999
https://github.com/ricks03/TotalHost

Report message to a moderator

Re: Stars Movies Thu, 14 June 2012 02:29 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
+1 Thumbs Up Smile


So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars Movies Mon, 09 July 2012 11:28 Go to previous messageGo to next message
nmid

 
Commander

Messages: 1608
Registered: January 2011
Location: GMT +5.5

Wow, I'm going to definitely try this out at the end of my current game..
Can it take multiple player turn files?

edit - Ah, I see it can.


[Updated on: Mon, 09 July 2012 19:41]




I know my minefields.. but I'm a chaff sweeper.
I used to curse when I got stuck in traffic... till I realised I AM traffic.

Report message to a moderator

Re: Stars Movies Wed, 08 August 2012 01:36 Go to previous message
ricks03 is currently offline ricks03

 
Officer Cadet 1st Year
Creator of TotalHost and Stars! utilities
Created TotalHost and Stars! utilities

Messages: 221
Registered: January 2012
Location: NC
Here's the modified code to work with starmapper (which I think displays a little better)

# Stars Movie Creator
# For starmapper 1.21
# 120807
# Rick Steeves
# th@corwyn.net
# version .01

# Creates all of the .map and .pla files to generate "movies" from starmapper
# And then creates batch files to create the starmap .pcx files,
# convert the .pcx files to .jpg with ImageMagick, and then display the .jpg files
# with polyview

# Assumes that the stars turn files are available in some structure
# (currently <whatever>\<year>)
# tho modifying that within the code is fairly simple.

# Builds a number of batch files to be run in order:
# starmapper_<gamefile>.bat - to run starmapper for each year and create the .pcx file
# image_<gamefile>.bat - to use imagemagick to convert the .pcx files to .jpg

# It also creates a <gamefile>.pvs file to use with polyview. Copy of polyview required,
# available at http://www.polybytes.com/
# polyview <gamefile>.pvs

# NOTE: requires/expects starmapper and polyview in the same folder

use File::Copy;

# Name of the Game (the prefix for the .xy file)
$GameFile = "dark";

# Stars EXE
$executable= "E:\\Stars!\\stars26j\\stars.exe";

# Location of ImageMagic convert applications
$image = "E:\\Program Files\\ImageMagick-6.4.1-Q16\\convert";

# Path of the game backups
# Assumes a structure of <path>\<turn year>
$path = "W:\\Games\\$GameFile";

# Location of the starmap executable
$starmap = "d:\\stars\\utils\\starmapper\\starmapper121\\starmapper.bat ";

# Where to output the .ini, .pcx, and .bat files
$outputpath = "c:\\temp1\\";

# Determine the players to provide output
@numbers = (1,2,3,4);
@passwords = ('','','','quack');
@names = ('Eladrin','Poslene','Kobold','Mallard');

# Get a listing of all of the backup directories
$BackupDir = $path;
opendir(DIRS, $BackupDir) || die("Cannot open $BackupDir\n");
@AllDirs = readdir(DIRS);
closedir(DIRS);

# configure the Starmapper command file
$DataOutFile = $outputpath . $GameFile . "_starmapper" . ".bat";
open (MAPFILE, ">$DataOutFile");
$mapfile = $starmap . " $GameFile";
foreach $number (@numbers) { $mapfile .= " $number"; }
print MAPFILE $mapfile . "\n";
close MAPFILE;

# configure the Starmapper ini file
$DataOutFile = $outputpath . $GameFile . ".ini";
open (INIFILE, ">$DataOutFile");
print INIFILE "; Starmapper ini file for $GameFile\n";
print INIFILE "[players]\n";
# display all of the players in the starmapper format
$count = 0;
foreach $number (@numbers) { print INIFILE "player" . &fixlen($number) . "=" . $names[$count] . "\n"; $count++;}
print INIFILE "\n";
# Create the starmapper color template section
print INIFILE "[colors]\n";
print INIFILE ";here are the colors for players, overriding default colors, in rgb color space\n";
print INIFILE ";the same as with keys is with color components, but they must be >=0 and <=255\n";
print INIFILE ";grey\n";
print INIFILE "player01=192 192 192\n";
print INIFILE ";green\n";
print INIFILE "player02=034 139 034\n";
print INIFILE ";blue\n";
print INIFILE "player03=000 000 255\n";
print INIFILE ";orange\n";
print INIFILE "player04=255 140 000\n";
print INIFILE ";\n";
print INIFILE "player05=255 165 000\n";
print INIFILE "player06=168 168 168\n";
print INIFILE "player07=095 158 160\n";
print INIFILE "player08=000 000 215\n";
print INIFILE "player09=000 000 175\n";
print INIFILE "player10=225 225 000\n";
print INIFILE "player11=195 195 000\n";
print INIFILE "player12=165 165 000\n";
print INIFILE "player13=000 255 255\n";
print INIFILE "player14=000 225 225\n";
print INIFILE "player15=000 195 195\n";
print INIFILE "player16=000 195 195\n";
print INIFILE "\n";
close INIFILE;

# Initialize the Image command file
$DataOutFile = $outputpath . $GameFile . "_image" . ".bat";
open (IMGFILE, ">$DataOutFile");
# Initialize the polyview comand file
$DataOutFile = $outputpath . $GameFile . ".pvs";
open (POLYFILE, ">$DataOutFile");

foreach $name (@AllDirs) {
# skip the . directories
if ($name =~ /\./) { next; }
# Skip the default stars backup dir, if present
if ($name =~ /BACKUP/) { next; }
# Output the command to convert to jpg for imagemagik
print IMGFILE "\"" . $image . "\"" . " \"$outputpath$GameFile $name.PCX\" $outputpath$name.jpg\n";
# output the command for polyview to work
print POLYFILE "\"$name.jpg\" /t1\n";
}
close IMGFILE;
close POLYFILE;

# Generate all the .map files
# Stars! -dm mygame.m1 <-- Dump the universe definition and exit
# Generate all of the .pla files
# Stars! -dp mygame.m1 <-- Dump player 1's planets and exit

foreach $name (@AllDirs) {
# Skip all . directories
if ($name =~ /\./) { next; }
# Sjip the default stars Backup folder if present
if ($name =~ /BACKUP/) { next; }

# generate the MAP file
$map = $executable;
if ($passwords[$count]) { $map .= ' -p ' . $passwords[$count]; }
$map .= ' -dm ' . $path . "\\" . $name . "\\" . $GameFile . ".m" . $numbers[0];
print "map: $map\n";
system ($map);

# Generate the PLA files
$count = 0;
foreach $number (@numbers) {
$pla = $executable;
if ($passwords[$count]) { $pla .= ' -p ' . $passwords[$count]; }
$pla .= ' -dp ' . $path . "\\" . $name . "\\" . $GameFile . ".m" . $number;
print "pla: $pla\n";
system ($pla);
# and move/rename the file to the format for starmapper
$file1 = $path . "\\" . $name . "\\" . $GameFile . ".p" . $number;
$file2 = $outputpath . $GameFile . " " . $name . ".p" . $number;
print "$file1 > $file2\n";
copy("$file1","$file2") or die "Copy PLA failed: $!";
$count++;
# Wait patiently, stars doesn't like to be launched over and over.
sleep 1;
}
}

# copy out the map file. You need only one
$file1 = $path . "\\" . "2400\\" . $GameFile . ".map";
$file2 = $outputpath . $GameFile . ".map";
print "$file1 > $file2\n";
copy("$file1","$file2") or die "Copy MAP failed: $!";

##########################################
sub fixlen {
# If the player number is only one digit, make it two
my ($len) = @_;
if (length($len) == 1) { $len = "0" . $len; }
return $len;
}



https://www.irelandbybicycle.com
http://totalhost.sinister.net:999
https://github.com/ricks03/TotalHost

Report message to a moderator

Previous Topic: Detecting corrupt race files
Next Topic: Planet mover (remapping tool)
Goto Forum:
  


Current Time: Wed Feb 01 07:21:08 EST 2023