Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Environment Class Reference
Inheritance diagram for Environment:

Public Member Functions

def toonear
 
def nearflag
 
def TwoDdis
 
def tweakHeight
 
def scoreFlag
 
def checkUn
 
def randomFlagLocation
 
def randomLocation
 
def CreateFlag
 
def CreateObstacle
 
def CreateSub
 
def CreateUnit
 
def __init__
 
def Execute
 
def EventualExecture
 
def AlwaysExecute
 
def ApplyEventualEnvironment
 

Data Fields

 unitheight
 
 arenasize
 
 flags
 
 obstacles
 
 subs
 
 iter
 
 num_un
 

Detailed Description

Definition at line 9 of file spectre.py.

Constructor & Destructor Documentation

def __init__ (   self,
  numobst,
  numflag,
  numspec,
  numseek,
  numsubs 
)

Definition at line 99 of file spectre.py.

References Environment.unitheight.

99 
100  def __init__ (self,numobst, numflag,numspec,numseek, numsubs):
101  Director.Mission.__init__(self)
102  self.unitheight=0
103  self.arenasize=1000
104  self.flags=[]
105  self.obstacles=[]
106  self.subs=[]
107  print 'initing'
108  self.iter=0
109  self.num_un=0
110  for i in range(numobst):
111  self.CreateObstacle("box")
112  for i in range(numflag):
113  self.CreateFlag("flag")
114  import vsrandom
115  for i in range(numspec):
116  self.CreateUnit ("spectre",vsrandom.randrange(0,2))
117  for i in range(numseek):
118  self.CreateUnit ("skart",0)
119  for i in range (numsubs):
self.CreateSubs("subs");

Member Function Documentation

def AlwaysExecute (   self)

Definition at line 130 of file spectre.py.

References spectre.isCar().

131  def AlwaysExecute(self):
132  self.EventualExecute()
133  iter = VS.getUnitList ()
134  un = iter.current()
135  playa = VS.getPlayer()
136  while (un):
137  if (isCar(un)):
138  self.ApplyPerFrameEnvironment (un,playa)
139  iter.advance()
un = iter.current()
def ApplyEventualEnvironment (   self,
  un,
  playa 
)

Definition at line 140 of file spectre.py.

References Environment.unitheight.

141  def ApplyEventualEnvironment(self,un,playa):
142  unheight=0
143  if (un.getName()=='skart' or un.isPlayerStarship()!=-1):
144  unheight= self.unitheight
145  pos=(un.Position()[0],unheight,un.Position()[2])
146  un.SetCurPosition (pos)
147 # def ApplyPerFrameEnvironment (self,un,playa):
148 # pos = un.Position()
149  vel = un.GetVelocity()
150 # if (pos[1]!=0):
151 # pos=(pos[0],0,pos[2])
152 # un.SetCurPosition(pos)
153  if (vel[1]!=0):
154  vel = (vel[0],0,vel[2])
155  un.SetVelocity(vel)
156 # if (vel[0]!=0):
157 # vel = (0,vel[1],vel[2])
158 # un.SetVelocity(vel)
def checkUn (   self)

Definition at line 27 of file spectre.py.

References Pattern.flags, Environment.flags, Compile.flags, RegexObject.flags, Environment.subs, Environment.tweakHeight(), and Environment.TwoDdis().

27 
28  def checkUn (self):
29  for X in range (getNumPlayers()):
30  un=getPlayerX (X)
31  uvec=un.Position()
32  rad = un.rSize()
33  rad=rad*rad
34  isnull=False
35  for f in self.flags:
36  if (not f):
37  isNull=True
38  else:
39  if (TwoDdis(uvec,f)<rad):
40  scoreFlag (un,f)
41  for u in self.subs:
42  if (not f):
43  isNull=True
44  else:
45  if (TwoDdis(uvec,u)<rad):
46  tweakHeight(un,u)
47  if (isNull):
48  for i in range(len(self.subs)):
49  if (not self.subs[i]):
50  del self.subs[i]
51  return
52  for j in range(len(self.flags)):
53  if (not self.flags[j]):
54  del self.flags[j]
55  return
def CreateFlag (   self,
  name 
)

Definition at line 77 of file spectre.py.

References Environment.randomLocation().

77 
78  def CreateFlag (self,name):
79  un = VS.launch("flags",name,"neutral","unit","default",1,1,self.randomLocation(),'')
80  self.flags.append(un)
def CreateObstacle (   self,
  name 
)

Definition at line 81 of file spectre.py.

References Environment.randomLocation().

81 
82  def CreateObstacle(self,name):
83  un = VS.launch("flags",name,"neutral","unit","default",1,1,self.randomLocation(),'')
self.obstacles.append(un)
def CreateSub (   self,
  name 
)

Definition at line 84 of file spectre.py.

References Environment.randomLocation().

84 
85  def CreateSub(self,name):
86  un = VS.launch("flags",name,"neutral","unit","default",1,1,self.randomLocation(),'')
87  self.subs.append(un)
def CreateUnit (   self,
  name,
  defend 
)

Definition at line 88 of file spectre.py.

References Environment.num_un, Environment.randomFlagLocation(), and Environment.randomLocation().

88 
89  def CreateUnit (self, name, defend):
90  evenodd= (2*(self.num_un %2) - 1)
91  if defend:
92  mod='defend'
93  vec=self.randomFlagLocation()
94  else:
95  mod='macho'
96  vec=self.randomLocation()
97  un = VS.launch ("cybernet",name,"unknown", "unit",mod,1,1,vec,'')
98  un.SetOrientation ((0,1,0),(0,0,evenodd))
self.num_un+=1
def EventualExecture (   self)

Definition at line 128 of file spectre.py.

References MyAI.Execute(), bounty_leader.Execute(), hideProgress.Execute(), quest_surplus.Execute(), go_none.Execute(), balancer.Execute(), TrafficAI.Execute(), Environment.Execute(), waitjump.Execute(), spawner.Execute(), quest_racene.Execute(), jump_privateer.Execute(), privateer.Execute(), cleansweep.Execute(), rescue.Execute(), total_war.Execute(), bounty_troop.Execute(), ai_escortpatrol.Execute(), quest_explore.Execute(), quest_rogue_militia.Execute(), ambush_scan.Execute(), faceoff.Execute(), quest_rlaan_spy.Execute(), wc1_mis0.Execute(), quest_drone.Execute(), quest_shipyardbomb.Execute(), cleansweep_escort.Execute(), quest_slaver.Execute(), quest_blockade.Execute(), wc1_mis1.Execute(), dantestmission.Execute(), quest_teleport.Execute(), wc1.Execute(), quest_introduction.Execute(), plunder.Execute(), quest_dispute.Execute(), go_to_adjacent_systems.Execute(), quest.Execute(), escort_mission.Execute(), bounty.Execute(), quest_debug.Execute(), quest_disappear.Execute(), difficulty.Execute(), patrol_ambush.Execute(), directions_mission.Execute(), server.Execute(), patrol.Execute(), ambush.Execute(), Executor.Execute(), test_quest.Execute(), player.Execute(), defend.Execute(), quest_isowing.Execute(), quest_contraband_truck.Execute(), cargo_mission.Execute(), escort_local.Execute(), DJ.Execute(), random_encounters.Execute(), and quest_tutorial.Execute().

129  def EventualExecture (self):
self.Execute()
def Execute (   self)

Definition at line 120 of file spectre.py.

References Environment.ApplyEventualEnvironment(), spectre.isCar(), and Environment.iter.

121  def Execute(self):
122  un = VS.getUnit (self.iter)
123  if (un):
124  if (isCar(un)):
125  self.ApplyEventualEnvironment (un,VS.getPlayer())
126  self.iter+=1
127  else:
self.iter=0
def nearflag (   self,
  un,
  flag 
)

Definition at line 15 of file spectre.py.

15 
16  def nearflag(self,un,flag):
return un.getDistance(flag)<0
def randomFlagLocation (   self)

Definition at line 56 of file spectre.py.

References Vector.Add(), Pattern.flags, Environment.flags, Compile.flags, RegexObject.flags, vsrandom.randrange(), and vsrandom.uniform().

56 
57  def randomFlagLocation(self):
58  import vsrandom
59  if (len(self.flags)):
60  i = vsrandom.randrange(0,len(self.flags))
61  return Vector.Add((vsrandom.uniform(-20,20),vsrandom.uniform(-20,20),vsrandom.uniform(-20,20)),self.flags[i].Position())
62  return (0,0,0)
def randomLocation (   self)

Definition at line 63 of file spectre.py.

References Environment.arenasize, Pattern.flags, Environment.flags, Compile.flags, RegexObject.flags, Environment.obstacles, Environment.toonear(), and vsrandom.uniform().

63 
64  def randomLocation(self):
65  import vsrandom
66  for i in range (50):
67  vec=(vsrandom.uniform(-self.arenasize,self.arenasize),
68  0,
70  for i in self.flags:
71  if (self.toonear (vec,i)):
72  continue
73  for i in self.obstacles:
74  if (self.toonear (vec,i)):
75  continue
76  return vec
return vec
def scoreFlag (   self,
  un,
  f 
)

Definition at line 24 of file spectre.py.

24 
25  def scoreFlag(self,un,f):
26  f.Kill()
VS.IOmessage(0,"game","all","Got a flag")
def toonear (   self,
  vec,
  un 
)

Definition at line 10 of file spectre.py.

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

10 
11  def toonear (self,vec,un):
12  vec= Vector.Sub(un.Position(),vec)
13  if (Vector.Dot(vec,vec)<1000):
14  return True
return False
def tweakHeight (   playa,
  sub 
)

Definition at line 22 of file spectre.py.

22 
23  def tweakHeight (playa,sub):
self.unitheight= sub.Position()[1]
def TwoDdis (   self,
  uvec,
  f 
)

Definition at line 17 of file spectre.py.

17 
18  def TwoDdis (self,uvec,f):
19  fvec=f.Position()
20  x=fvec[0]-uvec[0];
21  y=fvec[2]-uvec[2];
return x*x+y*y

Field Documentation

arenasize

Definition at line 102 of file spectre.py.

flags

Definition at line 103 of file spectre.py.

iter

Definition at line 107 of file spectre.py.

num_un

Definition at line 108 of file spectre.py.

obstacles

Definition at line 104 of file spectre.py.

subs

Definition at line 105 of file spectre.py.

unitheight

Definition at line 23 of file spectre.py.


The documentation for this class was generated from the following file: