Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
launch_recycle Namespace Reference

Functions

def NextPos
 
def move_to
 
def whereTo
 
def unOrTupleDistance
 
def look_for
 
def LaunchNext
 
def launch_dockable_around_unit
 
def launch_types_around
 
def launch_wave_around
 

Function Documentation

def launch_recycle.launch_dockable_around_unit (   fg,
  faction,
  ai,
  radius,
  myunit,
  garbage_collection_distance,
  logo = '',
  fgappend = '',
  skipdj = 0 
)

Definition at line 82 of file launch_recycle.py.

References faction_ships.getRandomCapitol(), faction_ships.isCapital(), fg_util.LandedShipsInFG(), and launch.launch_wave_around_unit().

82 
83 def launch_dockable_around_unit (fg,faction,ai,radius,myunit,garbage_collection_distance,logo='',fgappend='',skipdj=0):
84  import fg_util
85  for i in fg_util.LandedShipsInFG(fg,faction):
86  if (i[0]=='Mule.stock' or i[0]=='Mule' or faction_ships.isCapital(i[0])):
87  un=launch_types_around (fg,faction,[i],ai,radius,myunit,garbage_collection_distance,logo,fgappend,skipdj)
88  if (un.isDockableUnit()):
89  return un
90  if (fgappend=='Base'):
91  fg=fgappend
92  else:
93  fg=fg+fgappend
94  return launch.launch_wave_around_unit(fg,faction,faction_ships.getRandomCapitol(faction),ai,1,radius,radius*1.5,myunit,logo,1,skipdj)
def launch_recycle.launch_types_around (   fg,
  faction,
  typenumbers,
  ai,
  radius,
  myunit,
  garbage_collection_distance,
  logo,
  fgappend = '',
  skipdj = 0,
  FarApart = 1 
)

Definition at line 95 of file launch_recycle.py.

References debug.debug, dj_lib.PlayMusik(), locale.str(), and whereTo().

95 
96 def launch_types_around ( fg, faction, typenumbers, ai, radius, myunit, garbage_collection_distance,logo,fgappend='',skipdj=0,FarApart=1):
97  pos = whereTo(radius, myunit)
98  nr_ships=0
99  for t in typenumbers:
100  nr_ships+=t[1]
101  debug.debug("before"+str(nr_ships))
102  retcontainer=[None]
103  if (fgappend=='' and nr_ships>1):
104  (nr_ships,pos) = look_for (fg,faction,nr_ships-1,myunit,pos,garbage_collection_distance,retcontainer)
105  nr_ships+=1
106  debug.debug("after "+str(nr_ships)+ str(retcontainer))
107  count=0
108  ret=retcontainer[0]
109  found=0
110  for tn in typenumbers:
111  num = tn[1]
112  debug.debug("Python launched "+str(faction)+" "+str(tn[0])+" FG "+str(fg)+" with "+str(num)+" ships")
113  if num>nr_ships:
114  num=nr_ships
115  for i in range(num):
116  newship=[None]
117  debug.debug(pos)
118  pos = LaunchNext (fg,faction,tn[0], ai, pos,logo,newship,fgappend,FarApart)
119  if (i==0 and found==0):
120  ret=newship[0]
121  found=1
122  nr_ships-=num
123  if (nr_ships==0):
124  if (not skipdj):
125  dj_lib.PlayMusik(0,dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
126  return ret
127  if (not skipdj):
128  dj_lib.PlayMusik(0,dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
129  return ret
130 
def launch_recycle.launch_wave_around (   fg,
  faction,
  ai,
  nr_ships,
  capship,
  radius,
  myunit,
  garbage_collection_distance,
  logo,
  skipdj = 0 
)

Definition at line 131 of file launch_recycle.py.

References debug.debug, faction_ships.getRandomCapitol(), faction_ships.getRandomFighter(), dj_lib.PlayMusik(), locale.str(), and whereTo().

132 def launch_wave_around ( fg, faction, ai, nr_ships, capship, radius, myunit, garbage_collection_distance,logo,skipdj=0):
133  pos = whereTo(radius, myunit)
134  debug.debug("before"+str(nr_ships))
135  (nr_ships,pos) = look_for (fg,faction,nr_ships,myunit,pos,garbage_collection_distance)
136  debug.debug("after "+str(nr_ships))
137  while (nr_ships>0):
138  type=""
139  if (capship):
140  type = faction_ships.getRandomCapitol(faction)
141  else:
142  type = faction_ships.getRandomFighter(faction)
143  pos = LaunchNext (fg,faction,type, ai, pos,logo)
144  nr_ships-=1
145  if (not skipdj):
146  dj_lib.PlayMusik(0,dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
147 
def launch_recycle.LaunchNext (   fg,
  fac,
  type,
  ai,
  pos,
  logo,
  newshp = [None],
  fgappend = '',
  FarApart = 1 
)

Definition at line 69 of file launch_recycle.py.

References debug.debug, locale.str(), and dynamic_universe.TrackLaunchedShip().

69 
70 def LaunchNext (fg, fac, type, ai, pos, logo,newshp=[None],fgappend='',FarApart=1):
71  debug.debug("Launch nexting "+str(type))
72  combofg=fg+fgappend
73  if (fgappend=='Base'):
74  combofg=fgappend
75  newship = launch.launch (combofg,fac,type,ai,1,1,pos,logo,1,1)
76  import dynamic_universe
77  dynamic_universe.TrackLaunchedShip(fg,fac,type,newship)
78  rad=newship.rSize ()
79 #VS.playAnimation ("warp.ani",pos,(3.0*rad))
80  newshp[0]=newship
81  return NextPos (newship,pos,FarApart)
def launch_recycle.look_for (   fg,
  faction,
  numships,
  myunit,
  pos,
  gcd,
  newship = [None] 
)

Definition at line 51 of file launch_recycle.py.

References debug.debug, unit.getUnitSequenceBackwards(), vsrandom.random(), and unOrTupleDistance().

51 
52 def look_for (fg, faction, numships,myunit, pos, gcd,newship=[None]):
53  return (numships,pos)
55  for un in unl:
56  if (numships<=0):
57  break
58  if (unOrTupleDistance(un,myunit,1)>gcd ):
59  fac = un.getFactionName ()
60  fgname = un.getFlightgroupName ()
61  name = un.getName ()
62  if ((fg==fgname) and (fac==faction)):
63  if (vsrandom.random()<0.75):
64  pos=move_to (un,pos)
65  numships-=1
66  newship[0]=un
67  debug.debug("TTYmoving %s to current area" % (name))
68  return (numships,pos)
def launch_recycle.move_to (   un,
  where 
)

Definition at line 19 of file launch_recycle.py.

References unit.moveOutOfPlayerPath().

19 
20 def move_to (un, where):
21  un.SetPosition(where)
23  un.SetTarget (VS.Unit())
24  return NextPos (un,where)
def launch_recycle.NextPos (   un,
  pos,
  FarApart = 1 
)

Definition at line 9 of file launch_recycle.py.

References debug.debug, vsrandom.randrange(), locale.str(), and log_faction_ships.tuple.

9 
10 def NextPos (un, pos, FarApart=1):
11  rad=un.rSize ()
12  whichcoord = vsrandom.randrange(0,3)
13  x = pos[whichcoord]
14  pos = list(pos)
15  x=x+3.0*rad*FarApart
16  debug.debug("next coord is "+str(3.0*rad*FarApart)+" awa")
17  pos[whichcoord]=x
18  return tuple(pos)
def launch_recycle.unOrTupleDistance (   un,
  unortuple,
  significantp 
)

Definition at line 41 of file launch_recycle.py.

References Vector.Mag(), and Vector.Sub().

41 
42 def unOrTupleDistance(un,unortuple,significantp):
43  if (type(unortuple)==type((1,2,3))):
44  import Vector
45  return Vector.Mag(Vector.Sub(un.Position(),unortuple))-un.rSize()
46  else:
47  if (significantp):
48  return un.getSignificantDistance(unortuple)
49  else:
50  return un.getDistance(unortuple)
# THIS FUNCTION NO LONGER WORKS...because it's kinda silly to drag units around the system forcing them in front of a player
def launch_recycle.whereTo (   radius,
  launch_around 
)

Definition at line 25 of file launch_recycle.py.

References fg_util.randDirection().

25 
26 def whereTo (radius, launch_around):
27  if (type(launch_around)==type( (1,2,3))):
28  pos=launch_around
29  rsize = faction_ships.max_radius
30  else:
31  pos = launch_around.Position ()
32  rsize = ((launch_around.rSize())*5.0)
33  if (rsize > faction_ships.max_radius):
34  rsize=faction_ships.max_radius
35  rsize+=radius;
36  import fg_util
37  dir = fg_util.randDirection()
38  return (pos[0]+rsize*dir[0],
39  pos[1]+rsize*dir[1],
40  pos[2]+rsize*dir[2])