Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_teleport.py
Go to the documentation of this file.
1 import quest
2 import Vector
3 import VS
4 import unit
5 import universe
6 import vsrandom
7 import quest_explore
9  def __init__ (self):
10  self.sysfile = VS.getSystemFile()
11  self.timer = VS.GetGameTime()
13  self.explorequest.setsystem('gemini_sector/delta')
14  def teleportNPC (self,un):
15  pos=un.Position()
16  rsiz = un.rSize()
17  size=4*rsiz
18  sig = unit.getSignificant (vsrandom.randrange(0,50),0,0)
19  if (not sig):
20  return
21  nam = sig.getName()
22  if (nam.find ("lackhole")!=-1):
23  return
24  targetpos = sig.Position()
25  arad = sig.rSize()*2+size
26  targetpos = Vector.Add(targetpos,(vsrandom.uniform(arad,arad*1.5),
27  vsrandom.uniform(arad,arad*1.5),
28  vsrandom.uniform(arad,arad*1.5)))
29  targetpos = VS.SafeEntrancePoint (targetpos,rsiz)
30  if (size<1000):
31  size=1000
32  print "kill"
33  print un.getName()
34  un.SetCurPosition(targetpos)
35  VS.playAnimation("warp.ani",pos,size)
36  VS.playSound("cloak.wav",pos,(1,0,0))
37  VS.playAnimation("warp.ani",targetpos,size)
38  VS.playSound("cloak.wav",targetpos,(1,0,0))
39  def teleportPlayer(self,un):
40  if (un.DockedOrDocking()):
41  print "YOWWW"
42  else:
43  if (vsrandom.randrange(0,3)==0):
44  (adj,test) = universe.getAdjacentSystems(self.sysfile,1)
45  un.JumpTo(adj)
46  else:
47  self.teleportNPC (un)
48  def teleportUnit (self,un):
49  nam = un.getName()
50  if ((nam.find ("lackhole")!=-1) or un.isSun()):
51  return
52  if (un.isPlayerStarship()==-1):
53  self.teleportNPC(un)
54  else:
55  self.teleportPlayer(un)
56  def Execute (self):
57  self.explorequest.Execute()
58  if (VS.getSystemFile()==self.sysfile):
59  mytime = VS.GetGameTime();
60  if (mytime-self.timer>10):
61  self.timer=mytime
62  numunits=VS.getNumUnits()
63  if (numunits>0):
64  self.teleportUnit(VS.getUnit(vsrandom.randrange(0,numunits)))
65  return 1
66 
68  def __init__ (self):
69  quest.quest_factory.__init__ (self,"quest_teleport")
70  def create (self):
71  return quest_teleport()
72 
73 
74