Exemple #1
0
    def set_next_waypoint(self):
        # get the waypoint direction
        b = self.waypoints[0].position
        d = (b - self.position).normalized

        a = self.position + (d * 10)

        # check for collisions between the current position and the waypoint
        if not Physics.Linecast(a, b):
            self.current_waypoint = self.waypoints.pop(0)
            return True

        # if there's a collision, try to find a clear path above the obstacle
        a2 = Vector3(a[0], a[1], a[2])
        b2 = Vector3(b[0], b[1], b[2])

        for y in xrange(0, 1000, 10):
            a2 = Vector3(a[0], a[1] + y, a[2])
            b2 = Vector3(b[0], a[1] + y, b[2])

            segs = [Physics.Linecast(a, a2), Physics.Linecast(a2, b2), Physics.Linecast(b2, b)]

            if any(segs):
                continue

            self.waypoints.insert(0, Waypoint(b2))
            self.current_waypoint = Waypoint(a2)
            return True

        Besiege.Watch("panic", "set next waypoint")
Exemple #2
0
    def OnEntityDeath(self, victim, hitinfo):

        ini = hitinfo.Initiator if hitinfo else None
        att_ent = ini if ini and ini.ToPlayer() else None

        if victim and victim.ToPlayer():

            dmg = str(victim.lastDamage).upper()
            vic_sid = self.playerid(victim)
            vic_dic = self.db[vic_sid]

            if dmg == 'SUICIDE':

                vic_dic['SUICIDES'] += 1
                if vic_dic['DEATHS']:
                    vic_dic['SUICIDE RATIO'] = self.sfloat(float(vic_dic['SUICIDES']) / vic_dic['DEATHS'])

            elif att_ent and dmg in ('SLASH', 'BLUNT', 'STAB', 'BULLET', 'BITE'):

                att_sid = self.playerid(att_ent)
                att_dic = self.db[att_sid]

                if victim.IsSleeping():
                    att_dic['SLEEPERS'] += 1
                else:
                    att_dic['KILLS'] += 1

                if att_dic['DEATHS']:
                    att_dic['KDR'] = self.sfloat(float(att_dic['KILLS']) / att_dic['DEATHS'])

                d = float('%2f' % Vector3.Distance(victim.transform.position, att_ent.transform.position))
                if d > att_dic['RANGE']:
                    att_dic['RANGE'] = d

                self.db[att_sid].update(att_dic)

            vic_dic['DEATHS'] += 1
            if vic_dic['DEATHS']:
                vic_dic['KDR'] = self.sfloat(float(vic_dic['KILLS']) / vic_dic['DEATHS'])

            self.db[vic_sid].update(vic_dic)

        elif victim and 'animals' in str(victim) and att_ent:

            att_sid = self.playerid(att_ent)
            att_dic = self.db[att_sid]

            att_dic['ANIMALS'] += 1
            d = float('%.2f' % Vector3.Distance(victim.transform.position, att_ent.transform.position))
            if d > att_dic['RANGE']:
                att_dic['RANGE'] = d

            self.db[att_sid].update(att_dic)
Exemple #3
0
 def move(self, pos=None, rot=None):
     if not self.stChara: return False
     
     from UnityEngine import Vector3
     if pos:
         if isinstance(pos, tuple) and len(pos) == 3:
             pos = Vector3(pos[0], pos[1], pos[2])
         self.stChara.objCtrl.transform.localPosition = pos
         
     if rot:
         if isinstance(rot, tuple) and len(rot) == 3:
             rot = Vector3(rot[0], rot[1], rot[2])
         self.stChara.objCtrl.transform.localEulerAngles = rot
     return True
Exemple #4
0
 def delta_rot(self, x=None, y=None, z=None):
     from Manager import Studio
     camera = Studio.Instance.CameraCtrl
     v = camera.CameraAngle
     v = v + Vector3(x if x else 0, y if y else 0, z if z else 0)
     camera.CameraAngle = v
     return camera.CameraAngle
Exemple #5
0
 def Check(self, Player, plloc):
     config = self.HomeConfig()
     homesystemname = config.GetSetting("Settings", "homesystemname")
     ini = self.Homes()
     checkdist = ini.EnumSection("HomeNames")
     counted = len(checkdist)
     i = 0
     maxdist = int(config.GetSetting("Settings", "Distance"))
     if counted > 0 and checkdist:
         for idof in checkdist:
             i += 1
             homes = ini.GetSetting("HomeNames", idof)
             if homes:
                 homes = homes.replace(",", "")
                 check = self.HomeOfID(idof, homes)
                 if not self.IsFloat(check[0]) or not self.IsFloat(check[1]) or not self.IsFloat(check[2]):
                     Plugin.Log("HomeSystemError", "Something is wrong at: " + str(check) + " | " + str(homes))
                     continue
                 vector = Vector3(float(check[0]), float(check[1]), float(check[2]))
                 dist = Util.GetVectorsDistance(vector, plloc)
                 if dist <= maxdist and not self.FriendOf(idof, id) and idof != id:
                     Player.MessageFrom(homesystemname, "There is a home within: " + str(maxdist) + "m!")
                     return True
                 if i == counted:
                     return False
     return False
Exemple #6
0
 def On_PluginInit(self):
     DataStore.Flush('Duty')
     ini = self.AdminCmdConfig()
     password = ini.GetSetting("Settings", "OwnerPassword")
     password2 = ini.GetSetting("Settings", "ModeratorPassword")
     self.Disconnect = self.bool(
         ini.GetSetting("Settings", "DisconnectMessage"))
     self.Join = self.bool(ini.GetSetting("Settings", "JoinMessage"))
     self.DutyFirst = self.bool(ini.GetSetting("Settings", "DutyFirst"))
     self.Owners = self.bool(
         ini.GetSetting("Settings", "CanOwnersByPassDuty"))
     self.DefaultVector = Vector3(0, 0, 0)
     self.LogGive = self.bool(ini.GetSetting("Settings", "LogGive"))
     self.LogAirdropCalls = self.bool(
         ini.GetSetting("Settings", "LogAirdropCalls"))
     self.LogDuty = self.bool(ini.GetSetting("Settings", "LogDuty"))
     self.Friends = self.bool(ini.GetSetting("Settings", "Friends"))
     self.Sysname = ini.GetSetting("Settings", "Sysname")
     res = Plugin.GetIni("Resources")
     for x in res.EnumSection("Resources"):
         Resources[x] = res.GetSetting("Resources", x)
     if password != "SetThisToSomethingElse":
         if bool(re.findall(r"([a-fA-F\d]{32})", password)):
             return
         hashed = hashlib.md5(password).hexdigest()
         ini.SetSetting("Settings", "OwnerPassword", hashed)
         ini.Save()
         self.ohash = hashed
     if password2 != "SetThisToSomethingElse":
         if bool(re.findall(r"([a-fA-F\d]{32})", password2)):
             return
         hashed = hashlib.md5(password2).hexdigest()
         ini.SetSetting("Settings", "ModeratorPassword", hashed)
         ini.Save()
         self.mhash = hashed
Exemple #7
0
def Update():
    global lastT
    global copied
    global iterations
    currentT = int(Time.time * 10)
    if currentT > 20:
        transform.Rotate(
            0,
            UnityEngine.Mathf.Sin(
                (Time.time * 10 - 21) / 100) * 18 * Time.deltaTime, 0)
        rot = transform.localEulerAngles
        rot[2] = 0
        transform.localEulerAngles = rot

    # pos = transform.position
    # pos[1] = Mathf.Sin(Time.time * 3) * float(1.6)
    # transform.position = pos
    if not currentT == lastT and not copied and iterations > 0:
        lastT = currentT
        copied = True
        clone = UnityEngine.GameObject.Instantiate(
            gameObject, transform.position + Vector3(1, 0, 0),
            UnityEngine.Quaternion.identity)
        clone.name = gameObject.name
        clone.transform.parent = transform
        clone.GetComponent[Renderer]().material.color = Color.HSVToRGB(
            Mathf.Repeat(
                (clone.transform.position.x - iterations) / float(16.0), 1.0),
            1, 1)
        clone.GetComponent[PythonBehaviour]().scope.iterations = iterations - 1
Exemple #8
0
 def HomeDelayCallback(self, timer):
     timer.Kill()
     config = self.HomeConfig()
     homesystemname = config.GetSetting("Settings", "homesystemname")
     safetp = int(config.GetSetting("Settings", "safetpcheck"))
     HomeSystem = timer.Args
     Player = Server.FindPlayer(HomeSystem["Player"])
     if Player is None:
         return
     PLX = HomeSystem["LocationX"]
     PLX = re.sub('[)\(\[\'\]\,]', '', str(PLX))
     PLZ = HomeSystem["LocationZ"]
     PLZ = re.sub('[)\(\[\'\]\,]', '', str(PLZ))
     HLoc = HomeSystem["HomeLocation"]
     #HLoc = re.sub('[)\(\[\'\]\,]', '', str(HLoc)) old
     HLoc = re.sub('[)\(\[\'\]]', '', str(HLoc))
     HLoc = HLoc.split(',')
     movec = int(config.GetSetting("Settings", "movecheck"))
     if movec == 1:
         if int(float(PLX)) != int(float(Player.X)) or int(float(PLZ)) != int(float(Player.Z)):
             Player.MessageFrom(homesystemname, "You moved before teleporting!")
             return
     if not self.IsFloat(HLoc[0]) or not self.IsFloat(HLoc[1]) or not self.IsFloat(HLoc[2]):
         Plugin.Log("HomeSystemError", "Something is wrong at: " + str(HLoc) + " | " + Player.Name
                    + " | " + Player.SteamID)
         Player.MessageFrom("HomeSystem", "Something is wrong at: " + str(HLoc) + " | " + Player.Name
                            + " | " + Player.SteamID)
         Player.MessageFrom("HomeSystem", "Teleportation cancelled, please tell the admin's to check HomeSystem's directory for logs.")
         DataStore.Add("home_cooldown", Player.SteamID, 7)
         return
     loc = Vector3(float(HLoc[0]),float(HLoc[1]) + 5.5, float(HLoc[2]))
     Player.Teleport(loc)
     #if safetp > 0:
         #Plugin.CreateParallelTimer("HomeSafeTy", safetp * 1000, HomeSystem).Start()
     Player.MessageFrom(homesystemname, "Teleported to Home!")
Exemple #9
0
    def goto_position(self, throttle, pitch, yaw, roll):

        h, v, t = self.position_sp_distance

        self.auto_pid[0].gain_f = 0.8
        self.auto_pid[1].gain_f = 0.8
        self.auto_pid[2].gain_f = 0.8

        # TODO: have to find a dynamic p value that gives a smooth
        # ascent and descent curve.
        p = 0.2

        # if below target, prioritize climbing, so lower xz gain
        if h > 10 and v > 10:
            self.auto_pid[0].gain_f = p
            self.auto_pid[2].gain_f = p

        # if above target, prioritize moving, so lower y gain
        if h > 10 and v < -10:
            self.auto_pid[1].gain_f = p

        auto_error = Vector3(self.auto_pid[0].last_error,
                             self.auto_pid[1].last_error,
                             self.auto_pid[2].last_error)

        Besiege.Watch('auto_error', auto_error)

        roll_adj = self.auto_pid[0].update(self.position_sp_local[0], self.dt)
        throttle_adj = self.auto_pid[1].update(-self.position_sp_local[1], self.dt)
        pitch_adj = self.auto_pid[2].update(-self.position_sp_local[2], self.dt)

        return self.velocity_mode(throttle_adj, pitch_adj, yaw, roll_adj)
Exemple #10
0
 def delta_pos(self, x=None, y=None, z=None):
     from Manager import Studio
     camera = Studio.Instance.CameraCtrl
     v = camera.TargetPos
     v = v + Vector3(x if x else 0, y if y else 0, z if z else 0)
     camera.TargetPos = v
     return camera.TargetPos
Exemple #11
0
    def get_collisions(self):
        radius = self.config['collision_vehicle_radius']
        range_ = self.config['collision_range']

        vel = self.velocity
        # get velocity relative to our y rotation
        d = self.quat_ry * vel
        dn = d.normalized

        # the nearest point is fixed relative to the vehicle
        a = self.position + (dn * radius)
        b = self.position + (d * range_)

        if any(self._colmarks):
            self._colmarks[0].Move(a)
            self._colmarks[1].Move(b)
        else:
            self._colmarks[0] = Besiege.CreateMark(a)
            self._colmarks[1] = Besiege.CreateMark(b)

        hit = Physics.Linecast(a, b)

        c = Color.red if hit else Color.yellow

        self._colmarks[0].SetColor(c)
        self._colmarks[1].SetColor(c)

        # if there's a collision, find the y velocity change that clears us out of it
        if hit:
            for dv in xrange(10):
                tvel = Vector3(vel[0], vel[1] + dv, vel[2])
                dg = self.quat_ry * tvel
                dng = dg.normalized

                ag = self.position + (dng * radius)
                bg = self.position + (dg * range_)

                # if there's a hit, continue
                if Physics.Linecast(ag, bg):
                    continue

                if any(self._avdmarks):
                    self._avdmarks[0].Move(ag)
                    self._avdmarks[1].Move(bg)
                else:
                    self._avdmarks[0] = Besiege.CreateMark(ag)
                    self._avdmarks[1] = Besiege.CreateMark(b)

                    self._avdmarks[0].SetColor(Color.green)
                    self._avdmarks[1].SetColor(Color.green)

        else:
            if any(self._avdmarks):
                self._avdmarks[0].Clear()
                self._avdmarks[1].Clear()

                self._avdmarks = [None, None]
 def on_update(self, delta: float):
     if self.target is None or not self.should_follow:
         return
     sqr_distance: float = (self.target.position -
                            self.owner.position).sqrMagnitude
     if sqr_distance < 0.01:
         self.owner.position = Vector3.Lerp(self.owner.position,
                                            self.target.position,
                                            self.follow_speed * delta)
Exemple #13
0
 def On_CombatEntityHurt(self, EntityHurtEvent):
     if EntityHurtEvent.Attacker.ToPlayer() is None:
         return
     attacker = EntityHurtEvent.Attacker.ToPlayer()
     if DataStore.ContainsKey("HomeHit", attacker.SteamID):
         if "foundation" in EntityHurtEvent.Victim.Name:
             loc = Vector3(EntityHurtEvent.Victim.X, EntityHurtEvent.Victim.Y + 4, EntityHurtEvent.Victim.Z)
             self.SaveHome(attacker, DataStore.Get("HomeHit", attacker.SteamID), loc)
         else:
             attacker.Message("Hit a foundation.")
 def on_update(self, delta: float):
     if not self.should_walk:
         return
     sqr_distance: float = (self.next_target -
                            self.owner.position).sqrMagnitude
     if sqr_distance < 0.5:
         return
     self.owner.position = Vector3.MoveTowards(self.owner.position,
                                               self.next_target,
                                               self.move_speed * delta)
Exemple #15
0
    def terrain(self):
        # raycast straight down and get the real altitude
        p = Vector3(self.position[0], self.position[1] - self.core_height,
                    self.position[2])

        try:
            hit = Besiege.GetRaycastHit(p, Vector3.down)
        except Exception:
            return 0

        return hit.y
Exemple #16
0
def move_camera(pos=None, dir=None, angle=None, fov=None):
    from UnityEngine import Vector3
    from Manager import Studio
    studio = Studio.Instance
    if pos:
        if isinstance(pos, tuple) and len(pos) == 3:
            pos = Vector3(pos[0], pos[1], pos[2])
        if isinstance(pos, Vector3):
            studio.CameraCtrl.TargetPos = pos
    if dir:
        if isinstance(dir, tuple) and len(dir) == 3:
            dir = Vector3(dir[0], dir[1], dir[2])
        if isinstance(dir, Vector3):
            studio.CameraCtrl.CameraDir = dir
    if angle:
        if isinstance(angle, tuple) and len(angle) == 3:
            angle = Vector3(angle[0], angle[1], angle[2])
        if isinstance(angle, Vector3):
            studio.CameraCtrl.CameraAngle = angle
    if fov != None:
        studio.CameraCtrl.CameraFov = fov
Exemple #17
0
    def position_sp_distance(self):
        # vertical distance must be signed
        v = (Vector3(0, self.position_sp.y, 0) - Vector3(0, self.position.y, 0)).y

        h = Vector3.Distance(
            Vector3(self.position.x, 0, self.position.z),
            Vector3(self.position_sp.x, 0, self.position_sp.z))

        d = Vector3.Distance(self.position_sp, self.position)

        return Vector3(h, v, d)
 def teleportto(self, args, Player):
     args = Util.GetQuotedArgs(args)
     if not Player.Admin:
         Player.MessageFrom(self.Sysname, "You aren't a moderator!")
         return
     text = str.join(' ', args)
     if not ',' in text:
         Player.MessageFrom(self.Sysname, "Usage: /teleportto x,y,z")
         return
     sp = text.split(',')
     if len(sp) < 2:
         Player.MessageFrom(self.Sysname, "Usage: /teleportto x,y,z")
         return
     loc = Vector3(float(sp[0]), float(sp[1]), float(sp[2]))
     Player.Teleport(loc)
     Player.MessageFrom(self.Sysname, "Teleported!")
 def tpto(self, args, Player):
     args = Util.GetQuotedArgs(args)
     if not Player.Admin:
         Player.MessageFrom(self.Sysname, "You aren't an admin!")
         return
     if len(args) == 0:
         Player.MessageFrom(self.Sysname, "Usage: /tpto name")
         return
     if not self.IsonDuty(Player):
         Player.MessageFrom(self.Sysname, "You aren't on duty!")
         return
     pl = self.CheckV(Player, args)
     if pl is not None:
         if "offlineplayer" in str(pl).lower():
             loc = Vector3(pl.X, pl.Y, pl.Z)
             Player.Teleport(loc)
         else:
             Player.Teleport(pl.Location)
Exemple #20
0
    def stabilize_mode(self, throttle, pitch, yaw, roll):
        """In stabilize mode, the pitch and roll axes control the current
        angle in the respective axes, with the vehicle self-levelling
        when they are released. The yaw axis works as if in rate mode,
        and holds the current yaw when released. Throttle works as if
        in rate mode.

        """

        maxp = self.config['stabilize_max_pitch']
        maxr = self.config['stabilize_max_roll']

        pitch = pid.clip(pitch * self.config['stabilize_cf_pitch'], -maxp,
                         maxp)
        roll = pid.clip(roll * self.config['stabilize_cf_roll'], -maxr, maxr)

        self.rotation_sp.Set(pitch, self.rotation_sp[1], roll)

        self.stabilize_pid[0].setpoint = self.rotation_sp[0]
        self.stabilize_pid[2].setpoint = self.rotation_sp[2]

        pitch_adj = self.stabilize_pid[0].update(self.rotation[0], self.dt)
        roll_adj = self.stabilize_pid[2].update(self.rotation[2], self.dt)

        # yaw input controls the rate as if in rate mode, but if
        # the yaw stick is released, the quad holds the current yaw
        if yaw:
            yaw_adj = yaw
            self._hold_yaw = None

        else:
            if self._hold_yaw is None:
                self._hold_yaw = self.rotation[1]
                self.rotation_sp[1] = self.rotation[1]
                self.stabilize_pid[1].reset()

            self.stabilize_pid[1].setpoint = self.rotation_sp[1]
            yaw_adj = self.stabilize_pid[1].update(self.rotation[1], self.dt)

        self.rotation_sp = Vector3(self.stabilize_pid[0].setpoint,
                                   self.stabilize_pid[1].setpoint,
                                   self.stabilize_pid[2].setpoint)

        return self.rate_mode(throttle, pitch_adj, yaw_adj, roll_adj)
 def On_PluginInit(self):
     self.DefaultVector = Vector3(0, 0, 0)
     self.Quat = Quaternion(0, 0, 0, 1)
     Commands.Register("attach")\
         .setCallback("attach")\
         .setDescription("your description here")\
         .setUsage("The usage here")
     Commands.Register("attanimal")\
         .setCallback("attanimal")\
         .setDescription("your description here")\
         .setUsage("The usage here")
     Commands.Register("detach")\
         .setCallback("detach")\
         .setDescription("your description here")\
         .setUsage("The usage here")
     Commands.Register("test")\
         .setCallback("test")\
         .setDescription("your description here")\
         .setUsage("The usage here")
Exemple #22
0
    def poshold_mode(self, throttle, pitch, yaw, roll):
        """In Position Hold mode, the vehicle holds the current horizontal
        position and altitude. Throttle adjusts altitude as if in
        Altitude Hold mode. Pitch and roll adjust the horizontal
        position. Yaw works as if in stabilize mode.

        """
        if roll or pitch:
            delta = Vector3(-roll * self.dt * self.config['poshold_cf_x'],
                            0,
                            pitch * self.dt * self.config['poshold_cf_z'],
                            )

            delta = self.quat_ry * delta

            self.position_sp += delta

        pitch_adj = self.poshold_pid[2].update(-self.position_sp_local[2], self.dt)
        roll_adj = self.poshold_pid[0].update(self.position_sp_local[0], self.dt)

        return self.althold_mode(throttle, pitch_adj, yaw, roll_adj)
Exemple #23
0
 def HomeSafeTyCallback(self, timer):
     timer.Kill()
     config = self.HomeConfig()
     homesystemname = config.GetSetting("Settings", "homesystemname")
     HomeSystem = timer.Args
     Player = Server.FindPlayer(HomeSystem["Player"])
     if Player is None:
         return
     HLoc = HomeSystem["HomeLocation"]
     HLoc = re.sub('[)\(\[\'\]]', '', str(HLoc))
     HLoc = HLoc.split(',')
     if not self.IsFloat(HLoc[0]) or not self.IsFloat(HLoc[1]) or not self.IsFloat(HLoc[2]):
         Plugin.Log("HomeSystemError", "Something is wrong at: " + str(HLoc) + " | " + Player.Name
                    + " | " + Player.SteamID)
         Player.MessageFrom("HomeSystem", "Something is wrong at: " + str(HLoc) + " | " + Player.Name
                            + " | " + Player.SteamID)
         Player.MessageFrom("HomeSystem",
                            "Teleportation cancelled, please tell the admin's to check HomeSystem's directory for logs.")
         DataStore.Add("home_cooldown", Player.SteamID, 7)
         return
     Home = Vector3(float(HLoc[0]), float(HLoc[1]) + 5.5, float(HLoc[2]))
     Player.Teleport(Home)
     Player.MessageFrom(homesystemname, "Teleported Again!")
 def On_PluginInit(self):
     DataStore.Flush('Duty')
     ini = self.AdminCmdConfig()
     password = ini.GetSetting("Settings", "OwnerPassword")
     password2 = ini.GetSetting("Settings", "ModeratorPassword")
     self.Disconnect = self.bool(
         ini.GetSetting("Settings", "DisconnectMessage"))
     self.Join = self.bool(ini.GetSetting("Settings", "JoinMessage"))
     self.DutyFirst = self.bool(ini.GetSetting("Settings", "DutyFirst"))
     self.Owners = self.bool(
         ini.GetSetting("Settings", "CanOwnersByPassDuty"))
     self.DefaultVector = Vector3(0, 0, 0)
     self.LogGive = self.bool(ini.GetSetting("Settings", "LogGive"))
     self.LogAirdropCalls = self.bool(
         ini.GetSetting("Settings", "LogAirdropCalls"))
     self.LogDuty = self.bool(ini.GetSetting("Settings", "LogDuty"))
     self.Friends = self.bool(ini.GetSetting("Settings", "Friends"))
     self.BuildingPrivlidge = Util.TryFindReturnType("BuildingPrivlidge")
     self.Sysname = ini.GetSetting("Settings", "Sysname")
     res = Plugin.GetIni("Resources")
     for x in res.EnumSection("Resources"):
         Resources[x] = res.GetSetting("Resources", x)
     if password != "SetThisToSomethingElse":
         if bool(re.findall(r"([a-fA-F\d]{32})", password)):
             return
         hashed = hashlib.md5(password).hexdigest()
         ini.SetSetting("Settings", "OwnerPassword", hashed)
         ini.Save()
         self.ohash = hashed
     if password2 != "SetThisToSomethingElse":
         if bool(re.findall(r"([a-fA-F\d]{32})", password2)):
             return
         hashed = hashlib.md5(password2).hexdigest()
         ini.SetSetting("Settings", "ModeratorPassword", hashed)
         ini.Save()
         self.mhash = hashed
     Commands.Register("tpto")\
         .setCallback("tpto")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("tphere")\
         .setCallback("tphere")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("duty")\
         .setCallback("duty")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("god")\
         .setCallback("god")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("mute")\
         .setCallback("mute")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("unmute")\
         .setCallback("unmute")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("instako")\
         .setCallback("instako")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("kick")\
         .setCallback("kick")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("say")\
         .setCallback("say")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("clear")\
         .setCallback("clear")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("/permission add username permission")
     Commands.Register("repairall")\
         .setCallback("repairall")\
         .setDescription("Repairs all the items in your inventory")\
         .setUsage("repairall")
     Commands.Register("give")\
         .setCallback("give")\
         .setDescription("Allow admin to add and remove permissions")\
         .setUsage("give playername itemname quantity (Items having space in their names probably require quotes")
     Commands.Register("i")\
         .setCallback("i")\
         .setDescription("receive items")\
         .setUsage("i itemname quantity")
     Commands.Register("addowner")\
         .setCallback("addowner")\
         .setDescription("Gives owner rights to the player")\
         .setUsage("addowner playername")
     Commands.Register("addmoderator")\
         .setCallback("addmoderator")\
         .setDescription("gives moderator rights")\
         .setUsage("addmoderator playername")
     Commands.Register("removerights")\
         .setCallback("removerights")\
         .setDescription("Remove the rights of a player")\
         .setUsage("removerights playername")
     Commands.Register("settime")\
         .setCallback("settime")\
         .setDescription("Change ingame time.")\
         .setUsage("settime number")
     Commands.Register("players")\
         .setCallback("players")\
         .setDescription("Playerlist")\
         .setUsage("/Playerlist")
     Commands.Register("getmoderator")\
         .setCallback("getmoderator")\
         .setDescription("Gives you moderator")\
         .setUsage("getmoderator password")
     Commands.Register("getowner")\
         .setCallback("getowner")\
         .setDescription("Gives you owner")\
         .setUsage("getowner password")
     Commands.Register("airdropr")\
         .setCallback("airdropr")\
         .setDescription("Request an airdrop to a random place")\
         .setUsage("airdropr")
     Commands.Register("airdrop")\
         .setCallback("airdrop")\
         .setDescription("Request airdrop to you")\
         .setUsage("airdrop")
     Commands.Register("freezetime")\
         .setCallback("freezetime")\
         .setDescription("Freezes the time")\
         .setUsage("freezetime")
     Commands.Register("unfreezetime")\
         .setCallback("unfreezetime")\
         .setDescription("UnFreezes the time")\
         .setUsage("unfreezetime")
     Commands.Register("kill")\
         .setCallback("kill")\
         .setDescription("Kills player")\
         .setUsage("kill name")
     Commands.Register("vectortp")\
         .setCallback("vectortp")\
         .setDescription("Teleports where you are looking at")\
         .setUsage("vectortp")
     Commands.Register("teleportto")\
         .setCallback("teleportto")\
         .setDescription("Teleports you to the given coordinates.")\
         .setUsage("teleportto x,y,z")
     Commands.Register("addfriend")\
         .setCallback("addfriend")\
         .setDescription("Adds Player as a friend")\
         .setUsage("addfriend name")
     Commands.Register("delfriend")\
         .setCallback("delfriend")\
         .setDescription("Removes Player from the list")\
         .setUsage("delfriend friend")
     Commands.Register("friends")\
         .setCallback("friends")\
         .setDescription("Lists friends")\
         .setUsage("friends")
     Commands.Register("spawn")\
         .setCallback("spawn")\
         .setDescription("Spawn animals/resources!")\
         .setUsage("spawn")
     Commands.Register("boardusers")\
         .setCallback("boardusers")\
         .setDescription("Tells you every playername and playerid in a Tool Cupboard, if It's closer than 6m.")\
         .setUsage("boardusers")
     Commands.Register("rename")\
         .setCallback("rename")\
         .setDescription("Renames your name")\
         .setUsage("rename")
Exemple #25
0
 def quat_ry(self):
     return Quaternion.Euler(Vector3(0, self.rotation.y, 0))
Exemple #26
0
    def __init__(self, **config):
        clear_marks()

        self.core = config['core_block']
        self.core_height = None

        self.collision_radius = (config['collision_min_radius'],
                                 config['collision_med_radius'],
                                 config['collision_max_radius'])

        self.collision_points = (Vector3(), Vector3(), Vector3())

        self.motors = {
            k: v
            for (k, v) in config.iteritems() if k.startswith('motor_')
        }

        self.axes = {
            'throttle': config['axis_throttle'],
            'pitch': config['axis_pitch'],
            'yaw': config['axis_yaw'],
            'roll': config['axis_roll'],
        }

        self.keys = {
            k.split('_', 1)[1]: v
            for (k, v) in config.iteritems() if k.startswith('key_')
        }

        self.mode = self.rate_mode

        self.position = Vector3()
        self.position_sp = Vector3()

        self.rotation = Vector3()
        self.rotation_sp = Vector3()

        self.rate_sp = Vector3()
        self.velocity_sp = Vector3()

        self.rate_pid = (
            pid.PID(config['rate_gain_pitch']),
            pid.PID(config['rate_gain_yaw']),
            pid.PID(config['rate_gain_roll']),
        )

        self.stabilize_pid = (pid.AngularPID(config['stabilize_gain_pitch'],
                                             limit_i=(-1, 1)),
                              pid.AngularPID(config['stabilize_gain_yaw'],
                                             limit_i=(-1, 1)),
                              pid.AngularPID(config['stabilize_gain_roll'],
                                             limit_i=(-1, 1)))

        self.velocity_pid = (
            pid.PID(config['velocity_gain_x'],
                    limit=mm(1),
                    limit_i=mm(config['velocity_cf_x'])),
            pid.PID(config['velocity_gain_y'],
                    limit=mm(1),
                    limit_i=mm(config['velocity_cf_y'])),
            pid.PID(config['velocity_gain_z'],
                    limit=mm(1),
                    limit_i=mm(config['velocity_cf_z'])),
        )

        self.althold_pid = pid.PID(config['althold_gain'], limit=mm(1))

        self.poshold_pid = (
            pid.PID(config['poshold_gain_x'], limit=mm(1)),
            None,
            pid.PID(config['poshold_gain_z'], limit=(-1, 1)),
        )

        self.auto_pid = (
            pid.PID(config['auto_gain_x'], limit=(-1, 1)),
            pid.PID(config['auto_gain_y'], limit=(-1, 1)),
            pid.PID(config['auto_gain_z'], limit=(-1, 1)),
        )

        self.plane_mode_pid = pid.PID(config['plane_gain'], limit=(-1, 1))

        self.home = None

        self._hold_yaw = None

        self.colmarks = [None, None, None]

        clear_marks()

        self.waypoints = []

        self.waypoints = [
            Waypoint(Vector3(-252.1, 76, 78.4)),
            Waypoint(Vector3(-353.5, 123.4, 405.6)),
            Waypoint(Vector3(233.6, 269.0, 84.7)),
            Waypoint(Vector3(176.9, 243.2, 314.7)),
            Waypoint(Vector3(0, 2, 0))
        ]

        self.current_waypoint = None
        self.config = config

        self._first_update = True
Exemple #27
0
from UnityEngine import GameObject, Vector3, PrimitiveType, Mathf

sphere.transform.position = Vector3(Mathf.Sin(timer), Mathf.Cos(timer), 0)
 def __init__(self, position: Optional[Vector3] = None, scale: Optional[Vector3] = None, euler_angles: Optional[Vector3] = None):
     self.position: Vector3 = Vector3(0, 0, 0) if position is None else position
     self.scale: Vector3 = Vector3(1, 1, 1) if scale is None else scale
     self.euler_angles: Vector3 = Vector3(0, 0, 0) if euler_angles is None else euler_angles
Exemple #29
0
 def delta_rot(self, x=None, y=None, z=None):
     from UnityEngine import Vector3
     self.set_rot( self.rot + Vector3(x if x else 0, y if y else 0, z if z else 0) )
Exemple #30
0
    def __init__(self, **kwargs):
        clear_marks()

        config = CONFIG_DEFAULTS.copy()
        config.update(kwargs)

        self.hover = config['hovering_speed']
        self.core = Besiege.GetBlock(config['core_block'])
        self.core_height = config['core_height']

        self.motors = {}
        for k, v in config['motors'].items():
            self.motors[k] = [Besiege.GetBlock(b) for b in v]

        self.axes = {k: AdvancedControls.GetAxis(v) for (k, v) in config['axes'].items()}

        self.keys = {k.split('_', 1)[1]: v for (k, v) in config.iteritems() if k.startswith('key_')}

        self.mode = [self.rate_mode]
        self.yaw_mode = None

        self.position = Vector3()
        self.position_sp = Vector3()

        self.rotation = Vector3()
        self.rotation_sp = Vector3()

        self.rate_sp = Vector3()
        self.velocity_sp = Vector3()

        self.rate_pid = (
            pid.PID(config['rate_gain_pitch'], limit_i=mm(1)),
            pid.PID(config['rate_gain_yaw'], limit_i=mm(1)),
            pid.PID(config['rate_gain_roll'], limit_i=mm(1)),
            )

        self.yaw_pid = pid.PID(config['yaw_gain'], limit=mm(1))

        self.stabilize_pid = (
            pid.AngularPID(config['stabilize_gain_pitch']),
            pid.AngularPID(config['stabilize_gain_yaw']),
            pid.AngularPID(config['stabilize_gain_roll']),
            )

        self.velocity_pid = (
            pid.PID(config['velocity_gain_x'], limit=mm(2.0 / 3), limit_i=mm(config['velocity_cf_x'])),
            pid.PID(config['velocity_gain_y'], limit=mm(1), limit_i=mm(config['velocity_cf_y'])),
            pid.PID(config['velocity_gain_z'], limit=mm(2.0 / 3), limit_i=mm(config['velocity_cf_z'])),
            )

        self.althold_pid = pid.PID(config['althold_gain'], limit=mm(1))

        self.poshold_pid = (
            pid.PID(config['poshold_gain_x'], limit=mm(1)),
            None,
            pid.PID(config['poshold_gain_z'], limit=mm(1)),
            )

        self.auto_pid = (
            pid.PID(config['auto_gain_x'], limit=mm(1)),
            pid.PID(config['auto_gain_y'], limit=mm(1)),
            pid.PID(config['auto_gain_z'], limit=mm(1)),
            )

        self.home = None

        self._hold_yaw = None

        self.waypoints = []

        self.waypoints = [
            Waypoint(Vector3(200, 100, -1500)),
            Waypoint(Vector3(100, 60, -1900)),
            Waypoint(Vector3(1900, 60, -1900)),
            Waypoint(Vector3(1900, 60, 1900)),
            Waypoint(Vector3(-1900, 60, 1900)),
            Waypoint(Vector3(-1900, 60, -1900)),
            ]

        self.current_waypoint = None
        self.config = config

        self._first_update = True

        self._colmarks = [None, None]
        self._avdmarks = [None, None]