[go: up one dir, main page]

Menu

[r11]: / modules / dj_lib.py  Maximize  Restore  History

Download this file

97 lines (91 with data), 3.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import VS
import vsrandom
BATTLELIST=0
PEACELIST=1
PANICLIST=2
VICTORYLIST=3
LOSSLIST=4
HOSTILE_AUTODIST=2000
HOSTILE_NEWLAUNCH_DISTANCE=2500
peacelist={"aera":VS.musicAddList('peace.m3u'),
"confed":VS.musicAddList('peace.m3u'),
"iso":VS.musicAddList('peace.m3u'),
"AWACS":VS.musicAddList('peace.m3u'),
None:PEACELIST
}
battlelist={"confed":VS.musicAddList('battle.m3u'),
"kilrathi":VS.musicAddList('battle.m3u'),
"neutral":VS.musicAddList('battle.m3u'),
"merchant":VS.musicAddList('battle.m3u'),
None:BATTLELIST
}
paniclist={"confed":VS.musicAddList('panic.m3u'),
"kilrathi":VS.musicAddList('panic.m3u'),
"neutral":VS.musicAddList('panic.m3u'),
"merchant":VS.musicAddList('panic.m3u'),
None:PANICLIST
}
asteroidmisic=VS.musicAddList('peace.m3u')
def LookupTable(list,faction):
if faction in list:
if (list[faction]!=-1):
return list[faction]
else:
return list[None]
else:
return list[None]
situation=PEACELIST
def mpl (list,newsituation,forcechange):
global situation
print "SITUATION IS "+str( situation)+"force change "+str(forcechange) + " bool "+ str(forcechange or newsituation!=situation)
if (forcechange or newsituation!=situation):
print "SITUATION IS RESET TO "+str( newsituation)
situation=newsituation
VS.musicPlayList(list)
def PlayMusik(forcechange=1,hostile_dist=0):
un = VS.getPlayer()
if (not un):
mpl (PEACELIST,PEACELIST,forcechange)
print "Ppeace"
else:
perfect=1
iter = VS.getUnitList()
target = iter.current()
unlist=[]
asteroid=0
while (iter.notDone()):
if (target):
ftmp = 2*target.getRelation(un)
nam=target.getName().lower()
if un.getSignificantDistance(target)<=2*target.rSize() and ('afield'==nam[:6] or 'asteroid'==nam[:8]):
asteroid=1
hdis = HOSTILE_AUTODIST
if (hostile_dist!=0):
hdis = hostile_dist
if (target.GetTarget()==un or (ftmp<0 and un.getDistance(target)<hdis)):
unlist.append(target.getFactionName())
perfect=0
iter.advance()
target=iter.current()
if (perfect):
if asteroid and asteroidmisic!=-1 and vsrandom.random()<.7:
mpl(asteroidmisic,PEACELIST,forcechange)
return
sys=VS.getSystemFile()
fact=VS.GetGalaxyFaction(sys)
if vsrandom.random()<.5:
fact=None
mpl(LookupTable(peacelist,fact),PEACELIST,forcechange)
print "peaCce"
else:
ftmp = (un.FShieldData()+2*un.GetHullPercent()+un.RShieldData()-2.8)*2
fact=None
if len(unlist) and vsrandom.random()<.5:
fact=unlist[vsrandom.randrange(0,len(unlist))]
print fact
if (ftmp<-.5):
mpl(LookupTable(paniclist,fact),BATTLELIST,forcechange)
print "paAnic"
else:
mpl(LookupTable(battlelist,fact),BATTLELIST,forcechange)
print "bSattle"