示例#1
0
def findOriginAndMove(carrier, carrierloc=(0000, 00, -10000)):
    origin = unit.getJumpPoint(vsrandom.randrange(0, 99))
    beg = Vector.Add(origin.Position(),
                     Vector.Add(carrierloc, (carrier.rSize(), 0, 0)))
    carrier.SetPosAndCumPos(beg)
    VS.getPlayer().SetPosAndCumPos(Vector.Add(beg, (00, 0, 100)))
    return origin
示例#2
0
    def OPQ(self):
        O = vctr.array2vec(self.array[0:3])
        OR0 = vctr.array2vec([0, 0, np.sqrt(0.75) * self.l])
        OR1 = qtrn.RotOper(self.Phi, vctr.Vector(0, 1, 0), OR0)
        OR2 = qtrn.RotOper(self.Theta, vctr.Vector(0, 0, 1), OR1.purify())

        R = vctr.Add(O, OR2)
        OR0.contents()
        OR1.purify().contents()
        OR2.purify().contents()
        R.contents()

        if self.Phi == 0:
            Pr = qtrn.RotOper(self.Theta, vctr.Vector(0, 0, 1),
                              vctr.Vector(0, 1, 0))
            PR0 = vctr.ScalarMul(0.5 * self.l, Pr.purify().unit())

        else:
            Pr = vctr.Cross(vctr.Vector(0, 0, 1), OR2.purify())
            PR0 = vctr.ScalarMul(0.5 * self.l, Pr.unit())

        PR = qtrn.RotOper(self.Psy, OR2.purify(), PR0)

        #PR0 = vctr.ScalarMul(0.5*self.l,Pr.unit())

        P = vctr.Add(R, PR.purify())
        Q = vctr.Subtract(R, PR.purify())

        p = np.round(P.array().reshape(1, 3), 8)
        o = np.round(O.array().reshape(1, 3), 8)
        q = np.round(Q.array().reshape(1, 3), 8)
        OP_Array = np.append(o, p, axis=0)
        OPQ_Array = np.append(OP_Array, q, axis=0)
        return OPQ_Array
示例#3
0
    def Actuate_Sim(self, Theta):
        AxesSim = self.Axes
        PosiSim = self.Position
        OPQ = self.OPQ

        O1 = OPQ[0]
        P1 = OPQ[1]
        Q1 = OPQ[2]

        #       Loop over each Joint
        for i in range(0, self.DOF):

            #Get Axis and Position Vector as Input
            Axi = AxesSim[i]
            Ri = PosiSim[i]

            #           Loop over the remaining Joints.
            for j in range(i + 1, self.DOF):

                #               Obtain 2nd loop Joint Axis and Position Vector.
                Axj = AxesSim[j]
                Rj = PosiSim[j]

                #               Obtain inputs for Rotation

                #               Perform Rotations

                Rjnew = vctr.Add(
                    Ri,
                    vctr.TransformVector(Theta[i], vctr.Subtract(Rj, Ri), Axi))
                Axnew = vctr.TransformVector(Theta[i], Axj, Axi)

                #               Update the new Axes
                AxesSim[j] = Axnew
                PosiSim[j] = Rjnew

            Oi = OPQ[0]
            Pi = OPQ[1]
            Qi = OPQ[2]

            Oinew = vctr.Add(
                Ri, vctr.TransformVector(Theta[i], vctr.Subtract(Oi, Ri), Axi))
            Pinew = vctr.Add(
                Ri, vctr.TransformVector(Theta[i], vctr.Subtract(Pi, Ri), Axi))
            Qinew = vctr.Add(
                Ri, vctr.TransformVector(Theta[i], vctr.Subtract(Qi, Ri), Axi))

            OPQ[0] = Oinew
            OPQ[1] = Pinew
            OPQ[2] = Qinew

        fO = vctr.Subtract(Oinew, O1).unit()
        fP = vctr.Subtract(Pinew, P1).unit()
        fQ = vctr.Subtract(Qinew, Q1).unit()

        f = [fO, fP, fQ]

        return OPQ, f
示例#4
0
def launchBaseOrbit(type,faction,loc,orbitradius,orbitspeed,unit):
    #orbitradius*=2
    import Vector
    import dynamic_universe
    R = Vector.Vector(vsrandom.uniform(1.25*orbitradius,orbitradius),
                                      vsrandom.uniform(1.25*orbitradius,orbitradius),
                                      vsrandom.uniform(1.25*orbitradius,orbitradius))
    RMag = Vector.Mag(R)
    T = Vector.Vector(vsrandom.uniform(.5*orbitradius,orbitradius),
                                      vsrandom.uniform(.75*orbitradius,.85*orbitradius),
                                      vsrandom.uniform(.5*orbitradius,orbitradius))
    S = Vector.Cross (T,R)
    
    S = Vector.Scale(S,
                                     vsrandom.uniform (1.5*orbitradius,orbitradius)
                                     /Vector.Mag(S))
    SMag = Vector.Mag(S)    
    bas=VS.launch("Base",type,faction,"unit","default",1,1,Vector.Add(loc,R),'')
    nam=GetRandomBaseName (1,faction);
    R = Vector.Scale (R,(RMag+2.0*bas.rSize())/RMag)
    S = Vector.Scale (S,(SMag+2.0*bas.rSize())/SMag)        
    bas.orbit (unit,orbitspeed,R,S,(0.0,0.0,0.0))
    #bas.SetPosition(Vector.Add(loc,R))
    dynamic_universe.TrackLaunchedShip (BaseFGInSystemName(VS.getSystemFile()),
                                                                            faction,
                                                                            type,
                                                                            bas)
 def teleportNPC(self, un):
     pos = un.Position()
     rsiz = un.rSize()
     size = 4 * rsiz
     sig = unit.getSignificant(vsrandom.randrange(0, 50), 0, 0)
     if (not sig):
         return
     nam = sig.getName()
     if (nam.find("lackhole") != -1):
         return
     targetpos = sig.Position()
     arad = sig.rSize() * 2 + size
     targetpos = Vector.Add(targetpos, (vsrandom.uniform(
         arad, arad * 1.5), vsrandom.uniform(
             arad, arad * 1.5), vsrandom.uniform(arad, arad * 1.5)))
     targetpos = VS.SafeEntrancePoint(targetpos, rsiz)
     if (size < 1000):
         size = 1000
     print("kill")
     print(un.getName())
     un.SetCurPosition(targetpos)
     VS.playAnimation("warp.ani", pos, size)
     VS.playSound("cloak.wav", pos, (1, 0, 0))
     VS.playAnimation("warp.ani", targetpos, size)
     VS.playSound("cloak.wav", targetpos, (1, 0, 0))
示例#6
0
 def randomFlagLocation(self):
     if (len(self.flags)):
         i = vsrandom.randrange(0, len(self.flags))
         return Vector.Add(
             (vsrandom.uniform(-20, 20), vsrandom.uniform(-20, 20),
              vsrandom.uniform(-20, 20)), self.flags[i].Position())
     return (0, 0, 0)
示例#7
0
 def initSuccess(self):
     if self.success == 2:
         if VS.GetGameTime() > self.tracking[0]:
             t = self.getJumpTo(self.directions[len(self.directions) - 2])
             self.setupFriendly(t)  #FIXME: open wormhole
             VS.IOmessage(0, "[Mission Command]", "all",
                          "Out of our way, let us finish the job!")
             VS.getPlayerX(self.cp).addCredits(self.creds)
             VS.terminateMission(1)
     else:
         t = self.getJumpTo(self.directions[len(self.directions) - 2])
         self.enemy.SetPosition(
             Vector.Add(Vector.Scale((1, 0, 0), 11063), t.Position()))
         VS.getPlayerX(self.cp).SetPosition(
             t.Position()
         )  #because self.enemy is at the jumpgate when I jump, so I get pushed off
         VS.setCompleteness(self.objref, 1.00)
         self.success = 2
         VS.IOmessage(0, "[Mission Computer]", "all",
                      "Broadcast intercepted.")
         for i in range(len(self.succeed1)):
             VS.IOmessage(i + 1, "[Mission Command]", "all",
                          self.succeed1[i])
         self.SetVar(1)
         self.tracking = (VS.GetGameTime() + self.DELAYTIME,
                          VS.getPlayerX(self.cp).getDistance(self.enemy))
     return
示例#8
0
 def LaunchedEnemies(self, significant):
     import VS
     bounty_leader.bounty_leader.LaunchedEnemies(self, significant)
     self.troopdidlaunch = True
     import unit
     self.istarget = 1
     capship_only = 1
     self.utdw = self.adjsys.SignificantUnit(
     )  #unit.getSignificant(0,1,capship_only)
     self.wastingtimestart = VS.GetGameTime() + self.wastingtime
     self.wastingtime = 0
     if (self.utdw == self.enemy):
         self.utdw = unit.getSignificant(1, 1, capship_only)
     if (self.utdw == self.enemy):
         self.utdw = unit.getSignificant(2, 1, capship_only)
     if (self.utdw == self.enemy):
         self.utdw = unit.getSignificant(3, 1, capship_only)
     pos = self.utdw.Position()
     if self.dockingdist > 0:
         import Vector
         diff = Vector.Sub(self.you.Position(), pos)
         ndiff = Vector.Norm(diff)
         self.enemy.SetPosition(
             Vector.Add(
                 Vector.Scale(
                     ndiff, self.dockingdist + self.enemy.rSize() +
                     self.utdw.rSize()), pos))
示例#9
0
    def Actuate(self, Theta, OPQ=[]):
        OPQstore = OPQ
        OPQ = self.OPQ

        #       Loop over each Joint
        for i in range(0, self.DOF):

            #           Get Axis and Position Vector as Input
            Axi = self.Axes[i]
            Ri = self.Position[i]

            #           Loop over the remaining Joints.
            for j in range(i + 1, self.DOF):

                #               Obtain 2nd loop Joint Axis and Position Vector.
                Axj = self.Axes[j]
                Rj = self.Position[j]

                #               Obtain inputs for Rotation

                #               Perform Rotations

                Rjnew = vctr.Add(
                    Ri,
                    vctr.TransformVector(Theta[i], vctr.Subtract(Rj, Ri), Axi))
                Axnew = vctr.TransformVector(Theta[i], Axj, Axi)

                #               Update the new Axes
                self.Change_Axes_Vector(j, Axnew)
                self.Change_Position_Vector(j, Rjnew)

            Oi = OPQ[0]
            Pi = OPQ[1]
            Qi = OPQ[2]

            Oinew = vctr.Add(
                Ri, vctr.TransformVector(Theta[i], vctr.Subtract(Oi, Ri), Axi))
            Pinew = vctr.Add(
                Ri, vctr.TransformVector(Theta[i], vctr.Subtract(Pi, Ri), Axi))
            Qinew = vctr.Add(
                Ri, vctr.TransformVector(Theta[i], vctr.Subtract(Qi, Ri), Axi))

            self.Change_OPQ_Vector(0, Oinew)
            self.Change_OPQ_Vector(1, Pinew)
            self.Change_OPQ_Vector(2, Qinew)

        return
示例#10
0
 def setDroneNear (self,playa):
     vec = playa.Position()
     vec = Vector.Add (vec,(vsrandom.uniform(-1000,1000),
                            vsrandom.uniform(-1000,1000),
                            vsrandom.uniform(-1000,1000)))
     if (not self.drone.isNull()):
         self.drone.SetCurPosition(vec)
         self.drone.SetTarget(playa)
示例#11
0
def Product(p, q):
    p0 = p.array()[0]
    q0 = q.array()[0]

    pbar = vctr.array2vec((p.array()[1:4]))
    qbar = vctr.array2vec((q.array()[1:4]))

    cros = vctr.Cross(pbar, qbar)
    #Scalar Part
    pq0 = p0 * q0 - vctr.Dot(pbar, qbar)

    #Vector Part
    pqbar1 = vctr.Add(vctr.ScalarMul(q0, pbar), vctr.ScalarMul(p0, qbar))
    pqbar = vctr.Add(pqbar1, cros)

    pq = array2quar(np.append(pq0, pqbar.array()))
    return pq
示例#12
0
 def reposition(un, playa, min_distance, vel):
     ex = (vsrandom.uniform(-1, 1), vsrandom.uniform(-1, 1),
           vsrandom.uniform(-1, 1))
     if vel[0] == 0 and vel[1] == 0 and vel[2] == 0:
         vel = (1, 0, 0)
     dir = Vector.Scale(Vector.ScaledCross(ex, vel), min_distance)
     debug.debug("offsetting you a few meters to the %s" % (str(dir)))
     un.SetPosition(Vector.Add(playa.Position(), dir))
示例#13
0
 def setDroneNear(self, playa):
     global drone
     vec = playa.Position()
     vec = Vector.Add(
         vec, (vsrandom.uniform(-1000, 1000), vsrandom.uniform(
             -1000, 1000), vsrandom.uniform(-1000, 1000)))
     drone.SetCurPosition(vec)
     drone.SetTarget(playa)
示例#14
0
def Parallel(v1,v2):
    if (vctr.Subtract(v1.unit(),v2.unit())).mag() <0.0001:
        Val = 1
    elif (vctr.Add(v1.unit(),v2.unit())).mag() < 0.0001:
        Val = -1
    else:
        Val = 0

    return Val
示例#15
0
 def reposition(un, playa, min_distance, vel):
     import Vector
     import vsrandom
     ex = (vsrandom.uniform(-1, 1), vsrandom.uniform(-1, 1),
           vsrandom.uniform(-1, 1))
     if vel[0] == 0 and vel[1] == 0 and vel[2] == 0:
         vel = (1, 0, 0)
     dir = Vector.Scale(Vector.ScaledCross(ex, vel), min_distance)
     print "offsetting you a few meters to the " + str(dir)
     un.SetPosition(Vector.Add(playa.Position(), dir))
示例#16
0
 def launchNewDrone (self):
     playa=VS.getPlayer()
     if (not playa.isNull()):
         if (self.drone.isNull()):
             vec = playa.Position()
             vec = Vector.Add(vec,(000,3000,0))
             self.drone=VS.launch("IO42","beholder","unknown","unit","default",1,1,vec,'')
             self.drone.SetTarget(playa)
             pos=self.drone.Position()
             size=10*self.drone.rSize()
             VS.playAnimation("explosion_wave.ani",pos,size)
             if (self.playlist != -1):
                 VS.musicPlayList(self.playlist)
                 VS.musicLoopList(2)
示例#17
0
 def launchNewDrone(self):
     global drone
     playa = VS.getPlayer()
     if (not playa.isNull()):
         self.makeQuestPersistent()
         vec = playa.Position()
         vec = Vector.Add(vec, (1000, 0, 0))
         drone = VS.launch("IO47", "drone", "unknown", "unit", "default", 1,
                           1, vec, "")
         VS.AdjustRelation("unknown", playa.getFactionName(), -1, 10)
         VS.AdjustRelation(playa.getFactionName(), "unknown", -1, 10)
         drone.SetTarget(playa)
         self.stage = 1
     else:
         drone = VS.Unit()
示例#18
0
def Generate_Normal_For_Locus_Plane(v1,v2):
    prop = 0
    if Parallel(v1,v2) == -1:
        Normal = v1
    elif Parallel(v1,v2) == 0:
        Ang_bis = vctr.Add(v1.unit(),v2.unit())
        Ang_bis = Ang_bis.unit()
        para = vctr.ScalarMul(vctr.Dot(v1,Ang_bis),Ang_bis)
        Perp = vctr.Subtract(v1,para)
        Normal = Perp

    elif Parallel(v1,v2) == 1:
        Normal = v1
        prop = 1

    return Normal,prop
示例#19
0
    def __init__(self):
        Director.Mission.__init__(self)

        self.fac = []
        self.facnames = [
            "random", "confed", "militia", "merchant", "hunter", "pirates",
            "retro", "kilrathi", "AWACS"
        ]
        self.facnames = self.facnames + self.facnames
        for i in range(len(self.facnames)):
            nam = self.facnames[i] + "_SPAWN"
            if (i >= len(self.facnames) / 2):
                nam += "_CAPSHIP"
            self.fac.append(
                VS.launchJumppoint(
                    nam, "neutral", "75 jump.texture %s (ONE ONE)" % nam,
                    "planet", "sitting_duck", 1, 1,
                    Vector.Add((0., -1000. + i * 200., 1000.),
                               VS.getPlayer().Position()), "", "Gemini/Troy"))
        self.delay = VS.GetGameTime()
示例#20
0
    def __init__(self):
        Director.Mission.__init__(self)

        self.fac = []
        self.facnames = [
            "ISO", "LIHW", "aera", "andolian", "confed", "forsaken",
            "highborn", "homeland-security", "hunter", "klkk", "luddites",
            "mechanist", "merchant", "pirates", "purist", "rlaan",
            "rlaan_briin", "shaper", "shmrn", "unadorned"
        ]
        self.facnames = self.facnames + self.facnames
        for i in range(len(self.facnames)):
            nam = self.facnames[i] + "_SPAWN"
            if (i >= len(self.facnames) / 2):
                nam += "_CAPSHIP"
            self.fac.append(
                VS.launchJumppoint(
                    nam, "neutral", "75 jump.png %s (ONE ONE)" % nam, "planet",
                    "sitting_duck", 1, 1,
                    Vector.Add((0., -1000. + i * 200., 1000.),
                               VS.getPlayer().Position()), "", ""))
        self.delay = VS.GetGameTime()
示例#21
0
    def OPQ_Coordinate(self):
        #Spatial
        array = np.zeros((1, 6))
        array[0, 0:3] = self.O.array()
        #Angular
        self.R = vctr.ScalarMul(0.5, vctr.Add(self.P, self.Q))
        OR_unit = vctr.Subtract(self.R, self.O).unit()
        ORarr = OR_unit.array()
        Phi = np.rad2deg(np.arccos(ORarr[2]))

        Thetar = np.arccos(ORarr[0] / np.sin(np.arccos(ORarr[2])))
        Theta = np.rad2deg(np.arccos(ORarr[0] / np.sin(np.arccos(ORarr[2]))))

        pq = vctr.Subtract(self.P, self.Q).unit()
        pqarr = pq.array()
        pq0 = vctr.Vector(-np.sin(Thetar), np.cos(Thetar), 0).unit()
        cosPsy = vctr.Dot(pq0, pq)

        if vctr.Distance(pq, pq0) > 0.0001:
            sinPsy = vctr.Dot(vctr.Cross(pq0, pq), OR_unit)

            if sinPsy >= 0:

                Psy = np.rad2deg(np.arccos(cosPsy))
            elif sinPsy < 0:
                Psy = 360 - np.rad2deg(np.arccos(cosPsy))

        else:
            Psy = 0

        array[0, 3] = Phi
        array[0, 4] = Theta
        array[0, 5] = Psy
        arrayo = np.append(self.O.array(), [Phi, Theta, Psy])

        self.Coordinate = Coordinates(arrayo, self.length())

        return self.Coordinate
示例#22
0
 def AdjLocation(self):
     debug.info("ADJUSTING LOCATION")
     self.enemy.SetPosition(Vector.Add(self.enemy.LocalPosition(),Vector.Scale(self.enemy.GetVelocity(),-40))) #eta 20 sec
示例#23
0
 def Execute(self):
     if (self.player):
         #print str(self.player.Position())
         # launch the actors
         if (self.stage <= self.groups and VS.GetGameTime() >= self.timer):
             #print "group: " +str(self.stage)
             self.names = fg_util.GetRandomFGNames(self.groups, "confed")
             shiptype = faction_ships.getRandomCapitolInt(
                 faction_ships.confed)
             #print "group/name: " + str(self.stage) + "/"+names[self.stage-1]
             # launch capital ships
             number = vsrandom.randrange(2, 4)
             #print ">capital/type: " +str(number)+"/"+shiptype
             location = Vector.Add(self.object.Position(),
                                   (vsrandom.uniform(-10000, 10000),
                                    vsrandom.uniform(-10000, 10000),
                                    vsrandom.uniform(-10000, 10000)))
             offset = (vsrandom.uniform(1000,
                                        2000), vsrandom.uniform(1000, 2000),
                       vsrandom.uniform(1000, 2000))
             for i in range(number):
                 #self.capital += [launch.launch_wave_around_unit(names[self.stage-1],'confed',shiptype,'sitting_duck',1,5000,20000,self.object)]
                 # launch(name,type,faction,unittype,ai,nr,nrwaves,pos,squadlogo)
                 pos = Vector.Add(location, Vector.Scale(offset, i))
                 self.capital += [
                     VS.launch(self.names[self.stage - 1], shiptype,
                               'confed', 'unit', 'sitting_duck', 1, 1, pos,
                               '')
                 ]
             # launch fighters
             number = number * vsrandom.randrange(3, 6)
             # test: Lancelot, Schroedinger, Quicksilver, Convolution
             shiptype = faction_ships.getRandomFighterInt(
                 faction_ships.confed)
             #print ">fighters/type: " + str(number) + "/" + shiptype
             ship = self.capital[0]
             for i in range(number):
                 self.fighter += [
                     launch.launch_wave_around_unit(
                         self.names[self.stage - 1], 'confed', shiptype,
                         'sitting_duck', 1, 1000, 2000, ship)
                 ]
             # change orders for capital ships
             for ship in self.capital:
                 ship.PrimeOrders()
                 unit.faceTaget(ship, self.object)
             # change orders for fighter ships
             for ship in self.fighter:
                 #unit.faceTaget(ship, self.capital[0])
                 ship.PrimeOrders()
                 #ship.SetTarget(self.capital[0])
                 ship.SetTarget(self.object)
                 #ship.UnFire()
                 #ship.setFgDirective("E.") # escort
                 ship.LoadAIScript("modules/ai_escortpatrol.py")
             # time between spawning the groups
             self.timer = VS.GetGameTime()  #+10
             self.stage += 1
         if (self.stage == self.groups + 1
                 and VS.GetGameTime() > self.timer):
             self.stage = 10
         # publish news
         if (self.stage == 10 and VS.GetGameTime() > self.timer):
             text = "JUMP POINT BLOCKADE IN " + self.system + " SYSTEM\\\Intelligence has uncovered Aeran plans to invade Confederation space."
             text += "As a preventive measure " + str(
                 self.groups
             ) + " flight groups were dispatched and stationed near the Nethuuleil jump point. "
             text += "Multiple capital vessels are guarding the jump point while a multitude of fighter escorts is patrolling nearby space."
             news.publishNews(text)
             self.timer = VS.GetGameTime() + 5
             self.stage = 11
         #make some random chatter
         if (self.stage == 11 and VS.GetGameTime() > self.timer):
             # select two pilots to chatter
             flightgroup = 1  #vsrandom.randrange(1,self.groups)
             numchatters = 0
             chatters = []
             while (numchatters < 2):
                 chatter = vsrandom.randrange(0, len(self.fighter) - 1)
                 if (self.fighter[chatter].getFlightgroupName() ==
                         self.names[flightgroup - 1]):
                     chatters += [chatter]
                     numchatters += 1
             VS.IOmessage(
                 0, unit.getUnitFullName(self.fighter[chatters[0]]), "all",
                 self.msgColor[0] + "... lousy bar on our mothership?")
             VS.IOmessage(
                 5, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "Yeah, bad lighting, and no bar company besides your dull face."
             )
             VS.IOmessage(
                 10, unit.getUnitFullName(self.fighter[chatters[0]]), "all",
                 self.msgColor[0] +
                 "The drinks selection is not the best I have seen.")
             VS.IOmessage(
                 15, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "And this bartender droid really gets on my nerves.")
             VS.IOmessage(
                 20, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "He never stops talking for an instant.")
             VS.IOmessage(
                 25, unit.getUnitFullName(self.fighter[chatters[0]]), "all",
                 self.msgColor[0] + "Guess, we've got to live with that.")
             VS.IOmessage(30,
                          unit.getUnitFullName(self.fighter[chatters[1]]),
                          "all", self.msgColor[1] + "Yeah.")
             self.timer = VS.GetGameTime() + 240
             self.stage = 12
         if (self.stage == 12 and VS.GetGameTime() > self.timer):
             # select two pilots to chatter
             flightgroup = 2  #vsrandom.randrange(1,self.groups)
             numchatters = 0
             chatters = []
             while (numchatters < 2):
                 chatter = vsrandom.randrange(0, len(self.fighter) - 1)
                 if (self.fighter[chatter].getFlightgroupName() ==
                         self.names[flightgroup - 1]):
                     chatters += [chatter]
                     numchatters += 1
             VS.IOmessage(0,
                          unit.getUnitFullName(self.fighter[chatters[0]]),
                          "all", self.msgColor[0] + "Phil?")
             VS.IOmessage(10,
                          unit.getUnitFullName(self.fighter[chatters[1]]),
                          "all", self.msgColor[1] + "What's up, buddy?")
             VS.IOmessage(
                 15, unit.getUnitFullName(self.fighter[chatters[0]]), "all",
                 self.msgColor[0] +
                 "The rumor is the Aera are planning an invasion.")
             VS.IOmessage(
                 25, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "Maybe no rumor anymore. Probably it's all over the news now."
             )
             VS.IOmessage(
                 35, unit.getUnitFullName(self.fighter[chatters[0]]), "all",
                 self.msgColor[0] +
                 "That's why we are here? Will we have to fight?")
             VS.IOmessage(40,
                          unit.getUnitFullName(self.fighter[chatters[1]]),
                          "all", self.msgColor[1] + "Calm down, youngling.")
             VS.IOmessage(
                 45, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] + "The war hasn't quite started yet.")
             VS.IOmessage(
                 50, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "I tell ya. This operation is to prepare the worlds for the war."
             )
             VS.IOmessage(55,
                          unit.getUnitFullName(self.fighter[chatters[1]]),
                          "all",
                          self.msgColor[1] + "All staged by the higherups.")
             VS.IOmessage(
                 65, unit.getUnitFullName(self.fighter[chatters[0]]), "all",
                 self.msgColor[0] +
                 "You think so? And what if you're not right? Will you take care of my 'lil sister if I die?"
             )
             VS.IOmessage(
                 75, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "Ho, ho. Now stop that blubber. Nobody's gonna die here.")
             VS.IOmessage(
                 80, unit.getUnitFullName(self.fighter[chatters[1]]), "all",
                 self.msgColor[1] +
                 "Just stick to your orders and by dinner time we'll have a big jar of Pilsner and a nice long talk."
             )
             self.timer = VS.GetGameTime() + 300
             self.stage = 13
         # just a temporary backup
         if (self.stage == 99):
             #for ship in self.fighter:
             #    ship = VS.getUnit(i)
             #    if (ship.getFlightgroupName()==names[flightgroup]):
             #        print "shipname: " + ship.getFullName()
             #        #ship.setFgDirective("E.") # escort
             #        #VS.PythonAI.XMLScript("++evade.xml")
             self.stage = 98
         #if (self.stage==99 and not VS.getSystemName()==self.system):
         if (not VS.getSystemName() == self.system):
             self.stage += 1  # don't enter this loop anymore
             self.playernum = -1
             self.name = "quest_capital"
             self.removeQuest()
             return 0
示例#24
0
class Triangle(Shape):
    def __init__(self, newPoint0, newPoint1, newPoint2, newMaterial, objNum):
        self.point0 = Vector(newPoint0.x, newPoint0.y, newPoint0.z)
        self.point1 = Vector(newPoint1.x, newPoint1.y, newPoint1.z)
        self.point2 = Vector(newPoint2.x, newPoint2.y, newPoint2.z)
        self.objNum = objNum
        self.vector = Vector(0, 0, 0)
        A = self.vector.Sub(self.point1, self.point0)
        B = self.vector.Sub(self.point2, self.point0)
        C = self.vector.Cross(A, B)
        C.Normalize()
        C = self.vector.Mult(C, -1)
        self.n = C
        self.material = newMaterial
        xy = self.getArea(Vector2D(self.point0.x, self.point0.y),
                          Vector2D(self.point1.x, self.point1.y),
                          Vector2D(self.point2.x, self.point2.y))
        yz = self.getArea(Vector2D(self.point0.y, self.point0.z),
                          Vector2D(self.point1.y, self.point1.z),
                          Vector2D(self.point2.y, self.point2.z))
        zx = self.getArea(Vector2D(self.point0.z, self.point0.x),
                          Vector2D(self.point1.z, self.point1.x),
                          Vector2D(self.point2.z, self.point2.x))
        if (xy > yz):
            if xy > zx:
                pointA = Vector2D(self.point0.x, self.point0.y)
                pointB = Vector2D(self.point1.x, self.point1.y)
                pointC = Vector2D(self.point2.x, self.point2.y)
                self.mode = 1
                self.Area = xy
            else:
                pointA = Vector2D(self.point0.z, self.point0.x)
                pointB = Vector2D(self.point1.z, self.point1.x)
                pointC = Vector2D(self.point2.z, self.point2.x)
                self.mode = 2
                self.Area = zx
        else:
            if (yz > zx):
                pointA = Vector2D(self.point0.y, self.point0.z)
                pointB = Vector2D(self.point1.y, self.point1.z)
                pointC = Vector2D(self.point2.y, self.point2.z)
                self.mode = 3
                self.Area = yz
            else:
                pointA = Vector2D(self.point0.z, self.point0.x)
                pointB = Vector2D(self.point1.z, self.point1.x)
                pointC = Vector2D(self.point2.z, self.point2.x)
                self.mode = 2
                self.Area = zx
        self.pA = pointA
        self.pB = pointB
        self.pC = pointC
        self.c = (pointC.x - pointA.x) * (pointB.y - pointA.y) - (
            pointC.y - pointA.y) * (pointB.x - pointA.x)
        self.a = (pointA.x - pointB.x) * (pointC.y - pointB.y) - (
            pointA.y - pointB.y) * (pointC.x - pointB.x)
        self.b = (pointB.x - pointC.x) * (pointA.y - pointC.y) - (
            pointB.y - pointC.y) * (pointA.x - pointC.x)

    #formula for plane: (n.x)*(point1.x - point0.x) + (n.y)*(point1.y - point0.y) + (n.z)*(point1.z - point0.z) - (n.x*point0.x + n.y*point0.y + n.z*point0.z) = 0
    #t = - ((n.x)*(point1.x - point0.x) + (n.y)*(point1.y - point0.y) + (n.z)*(point1.z - point0.z))/()
    #t = ((point0 - originRay)dot n)/(rayPoint dot n)
    #t = (PVector.dot(PVector.sub(point0 - originRay), n)/(PVector.dot(rayPoint, n)
    def getArea(self, p0, p1, p2):
        return abs(((p0.x) * (p1.y - p2.y) + (p1.x) * (p2.y - p0.y) + (p2.x) *
                    (p0.y - p1.y)) / 2)

    def checkHit(self, x0, y0, z0, x1, y1, z1):
        hitFound = False
        hitList = []
        originRay = Vector(x0, y0, z0)
        rayPoint = Vector(x1, y1, z1)
        check = self.vector.Dot(rayPoint, self.n)
        if (check != 0):
            # O = originRay
            # R = self.vector.Sub(rayPoint, originRay)
            # D = self.vector.Dot(self.n, self.point0)
            # aNum = self.vector.Dot(self.n, O)
            # bNum = D + aNum
            # cNum = self.vector.Dot(self.n, R)
            # t = -1 * bNum/cNum
            t = (self.vector.Dot(self.vector.Sub(self.point0, originRay),
                                 self.n) +
                 (self.vector.Dot(self.n, originRay))) / check
            if (t > 0):
                hitPoint = self.vector.Add(
                    originRay,
                    self.vector.Mult(self.vector.Sub(rayPoint, originRay), t))

                pointA = self.pA
                pointB = self.pB
                pointC = self.pC
                mode = self.mode
                if (mode == 1):
                    pointQ = Vector2D(hitPoint.x, hitPoint.y)
                elif (mode == 2):
                    pointQ = Vector2D(hitPoint.z, hitPoint.x)
                else:
                    pointQ = Vector2D(hitPoint.y, hitPoint.z)
                d = (pointQ.x - pointA.x) * (pointB.y - pointA.y) - (
                    pointQ.y - pointA.y) * (pointB.x - pointA.x)
                c = self.c
                if (c >= 0 and d >= 0) or (c <= 0 and d <= 0):
                    d = (pointQ.x - pointB.x) * (pointC.y - pointB.y) - (
                        pointQ.y - pointB.y) * (pointC.x - pointB.x)
                    a = self.a
                    if (a >= 0 and d >= 0) or (a <= 0 and d <= 0):
                        d = (pointQ.x - pointC.x) * (pointA.y - pointC.y) - (
                            pointQ.y - pointC.y) * (pointA.x - pointC.x)
                        b = self.b
                        if (b >= 0 and d >= 0) or (b <= 0 and d <= 0):
                            newHit = Hit(hitPoint, self.n, self.material,
                                         self.objNum, t)
                            self.hit = newHit
                            hitFound = True
        return hitFound
示例#25
0
 def AdjLocation(self):
     print "ADJUSTING LOC"
     self.enemy.SetPosition(
         Vector.Add(self.enemy.LocalPosition(),
                    Vector.Scale(self.enemy.GetVelocity(),
                                 -40)))  #eta 20 sec
示例#26
0
 def doPlacement(self, target):
     unitvec, vec = self.getPlacementVectors(target)
     self.enemy.SetPosition(
         Vector.Add(VS.getPlayerX(self.cp).Position(), vec))
     self.enemy.SetOrientation((1, 0, 0), vec)
     self.enemy.SetVelocity(Vector.Scale(unitvec, 1440.0))
示例#27
0
def Extreme_Rotater(u1,v1,u2,v2):
    va = vctr.Vector(0,0,0)
    na = vctr.Vector(0,0,0)
    vb = vctr.Vector(0,0,0)
    nb = vctr.Vector(0,0,0)
    Axis = vctr.Vector(0,0,0)

    #   A
    LocusA = Generate_Normal_For_Locus_Plane(u1,u2)
    if LocusA[1] == 1:
        va = u1
        casea = 1
    else:
        na = LocusA[0]
        casea = 0

    #   B
    LocusB = Generate_Normal_For_Locus_Plane(v1,v2)
    if LocusB[1] == 1:
        vb = v1
        caseb = 1
    else:
        nb = LocusB[0]
        caseb = 0

        #CATEGORISE
    Case = casea + caseb


    #PROCEED TO INTERSECTION OF LOCII
        #BOTH LOCII ARE UNIQUE VECTORS
    if Case == 2:
        Axis = vctr.Vector(0,0,1)
        Theta = 0
        #ONE OF THEM HAS VECTOR LOCUS
    elif Case == 1:
        v = vctr.Add(va,vb)
        n = vctr.Add(va,vb)
            #
        if vctr.Dot(v,n) == 0:
            Axis = v
        else:
            Axis = vctr.Vector(0,0,0)
        #BOTH LOCII ARE PLANES
    elif Case == 0:
        if np.abs(Parallel(na,nb)) == 1:
            w1 = vctr.Cross(u1.unit(),v1.unit()).unit()
            w2 = vctr.Cross(u2.unit(),v2.unit()).unit()
            SM = Sufficiency_Matrix(u1,v1,w1,u2,v2,w2)
            if SM[1] == 0:
                Axis = Extreme_Rotater(v1,w1,v2,w2)[0]
            elif SM[2] == 0:
                Axis = Extreme_Rotater(u1,w1,u2,w2)[0]
            else:
                Axis = vctr.Vector(0,0,0)
        else:
            Axis = AxisFromNormals(na,nb)






    #OUTLIER REPROACH

    #PROCEED TO GENERATE THETA
    if Axis == vctr.Vector(0,0,0):
        Theta = 0

    else:
        ThetaA = Delta_Theta(u1,u2,Axis)
        ThetaB = Delta_Theta(v1,v2,Axis)

        Theta = Optimum(ThetaA,ThetaB)

        return Axis,Theta
示例#28
0
OPQ1 = ral.OPQ(OPQ1_mat)
OPQ2 = ral.OPQ(OPQ2_mat)

#Spatial Reconstruction
Coordinate1 = OPQ1.O_Coord()
Coordinate2 = OPQ2.O_Coord()

l = OPQ1.length()
CoordinatePath = []
Coord_Matrix = np.zeros((N + 1, 3))
Coord_Matrix[0, :] = Coordinate1.array()

for i in range(0, N + 1):
    t = (i) / (N)
    Vector_i = vctr.Add(vctr.ScalarMul((1 - t), Coordinate1),
                        vctr.ScalarMul((t), Coordinate2))
    CoordinatePath.append(Vector_i)
    Coord_Matrix[i, :] = Vector_i.array()

Pos_Array = Coord_Matrix
'''
trace = go.Scatter3d(
x=Pos_Array[:,0], y=Pos_Array[:,1], z=Pos_Array[:,2],
marker=dict(
size=4,
color=1,
colorscale='Viridis',
),
line=dict(
color='#1f77b4',
width=1
示例#29
0
 def AdjLocation(self):
     debug.info("ADJUSTING LOC")
     quest_drone.drone.SetPosition(
         Vector.Add(quest_drone.drone.LocalPosition(),
                    Vector.Scale(quest_drone.drone.GetVelocity(),
                                 -40)))  #eta 20 sec