Code: Select all
python SpringRS.py; spring script.txt
- Map
Sides
Colors
AI Difficulty
Please keep in mind that this is VERY beta, and is probably not for total noobs.
Code: Select all
#~Change this to the script file to alter
scri= './script.txt'
#~Change this to where your Map files are at
mapdir= '/shared/Games/SpringData/maps'
#This imports the needed libs
import random
import os
#Open and Read the script
def ReadScript(sloc):
fil=open(sloc,'r')
return fil.readlines()
fil.close()
#Open the Script File, and copy it to the internal array.
filar=ReadScript(scri)
map = os.listdir(mapdir)
map = map[random.randint(0,len(map))]
if map=="paths":
map = map[random.randint(0,len(map))]
map = map.replace('.sd7','.smf')
map = map.replace('.sdz','.smf')
rmap='Mapname='+map
rmap=rmap+';\n' #Bugfix!
#Write the new map
#Also, randomize the sides! (New Feature)
#Just for kicks, randomize the colors too!
i=0
while i<len(filar):
line=filar[i]
if 'Mapname=' in line:
print 'Changing mapname on line ' + str(i)
filar[i]=rmap
print filar[i]
if 'Side=' in line:
print 'Changing a side on line ' + str(i)
filar[i]='Side=Arm;\n'
if random.randint(0,1)==1:
filar[i]='Side=Core;\n'
if 'RgbColor=' in line:
print 'Changing a color on line ' + str(i)
rgbl = 'RgbColor='
rgbl=rgbl+str(float(random.randint(0,9))/10)
rgbl=rgbl+' '
rgbl=rgbl+str(float(random.randint(0,9))/10)
rgbl=rgbl+' '
rgbl=rgbl+str(float(random.randint(0,9))/10)
rgbl=rgbl+';\n'
filar[i]=rgbl
print filar[i]
if 'Handicap=' in line:
print 'Changing Handicap on line ' + str(i)
filar[i]='Handicap='+str(random.randint(5,55))+';\n'
print filar[i]
i=i+1
fil=open('script.txt','w')
fil.writelines(filar)
fil.close()
Code: Select all
[GAME]
{
Mapname=TornIslands_V2.smf;
StartMetal=2000;
StartEnergy=2000;
MaxUnits=5000;
GameType=xtape.sd7;
GameMode=0;
StartPosType=1;
MyPlayerNum=0;
NumPlayers=1;
NumTeams=2;
NumAllyTeams=2;
HostIP=localhost;
HostPort=8452; // usually 8452
[PLAYER0]
{
name=Flabbergaster;
Spectator=0;
team=0;
}
[TEAM0]
{
TeamLeader=0;
RgbColor=0.6 0.2 0.5;
AllyTeam=0;
Side=Arm;
}
[TEAM1]
{
TeamLeader=0;
RgbColor=0.4 0.1 0.6;
Handicap=42;
AllyTeam=1;
Side=Core;
AiDLL=/shared/Games/SpringData/AI/Bot-libs/QAI-2.45.so;
}
[ALLYTEAM0]
{
NumAllies=0;
}
[ALLYTEAM1]
{
NumAllies=0;
}
}