Пример #1
0
    def Activate(self, active):
        if active:
            if AI.SuperAI.debugging:
                self.debug = Gooey.Plain("watch", 0, 75, 200, 105)
                tbox = self.debug.addText("line0", 0, 0, 200, 15)
                tbox.setText("Throttle")
                tbox = self.debug.addText("line1", 0, 15, 200, 15)
                tbox.setText("Turning")
                tbox = self.debug.addText("line2", 0, 30, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line3", 0, 45, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line4", 0, 60, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line5", 0, 75, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line6", 0, 90, 200, 15)
                tbox.setText("")

            Me = self.GetID()
            for i in range(0, self.GetNumComponents()):
                max_HP = plus.getHitpoints(Me, i)
                plus.damage(Me, i, max_HP, plus.getLocation(Me))
                plus.damage(Me, i, max_HP, plus.getLocation(Me))

            plus.damage(Me, 0, 41, plus.getLocation(Me))
            plus.damage(Me, 0, 41, plus.getLocation(Me))
            plus.damage(Me, 0, 41, plus.getLocation(Me))

        return AI.SuperAI.Activate(self, active)
Пример #2
0
    def CanDriveUpsideDown(self, bot):
        MOVE_THRESHOLD = 3.0

        if bot in self.upTrack:
            t = self.upTrack[bot]
            if t.invertible: return True
            else:
                # check to see if he's moved recently
                position = plus.getLocation(bot)
                time = plus.getTimeElapsed()
                if time - t.last_time > 10:
                    # this record is too old to be reliable
                    t.last_time = time
                    t.last_position = position
                    return False
                v0 = vector3(t.last_position)
                v1 = vector3(position)
                if (v1 - v0).length() > MOVE_THRESHOLD: t.invertible = True
                return t.invertible
        else:
            t = UpsideDownTracker()
            t.last_position = plus.getLocation(bot)
            t.last_time = plus.getTimeElapsed()
            self.upTrack[bot] = t

            return False
Пример #3
0
 def Zap(self):
     if not plus.isMatchPaused() and not plus.isMatchOver():
         for bot, in_range in self.sensors.iteritems():
             x = abs(plus.getLocation(bot)[0])
             y = plus.getLocation(bot)[1]
             z = abs(plus.getLocation(bot)[2])
             if in_range and y<3 and y>-5 and ((x>11.5 and x<18) or (z>11.5 and z<18)):
                 plus.zap(bot, 10, 3.0)
                 self.zapping.append(bot)
                 plus.playSound(self.zapsound)
Пример #4
0
    def Tick(self):
        # fire weapon
        targets = []

        if self.weapons:
            targets = [x for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]


        bReturn = AI.SuperAI.Tick(self)
        # call this now so it takes place after other driving commands
        if self.whipFunction and self.ThisAI_bImmobile == 0: self.whipFunction(len(targets) > 0)

        if self.ThisAI_bImmobile == 1: # If Immobility is on:  -------------------------------------
            self.ImmobileCounter += 1  # Then start counting....

            if self.ImmobileCounter >= self.ReMobilizeRoutineTime*0.2:   # go backward for a designated time.
                self.Throttle(100)
                self.Input("LeftRight", 0, 0)
                self.Input("Forward", 0, -100)

            if self.ImmobileCounter >= self.ReMobilizeRoutineTime*0.6:  # go forward for a designated time.
                self.Input("LeftRight", 0, 0)
                self.Throttle(100)
                self.Input("Forward", 0, 100)

            if self.ImmobileCounter >= self.ReMobilizeRoutineTime:  # Reset everything:
                self.ThisAI_bImmobile = 0 # default Reset (if timer goes too long).
                self.ImmobileCounter = 1
        else:
            self.ThisAI_bImmobile = 0
            self.ImmobileCounter = 0



        # BackUp Immobile routine (continually running).... calculate difference of position between 2 calls
        self.BU_ImmobileTimer_A +=1
        if self.BU_ImmobileTimer_A >= 1:
            self.ThisAIBot_XFactorA =  plus.getLocation(self.GetID())[0] #
            self.ThisAIBot_ZFactorA =  plus.getLocation(self.GetID())[2]
        if self.BU_ImmobileTimer_A == 16:
            self.ThisAIBot_XFactorB =  plus.getLocation(self.GetID())[0]
            self.ThisAIBot_ZFactorB =  plus.getLocation(self.GetID())[2]
            self.BU_ImmobileTimer_A = 0 # Reset.

        if   self.ThisAIBot_XFactorA > self.ThisAIBot_XFactorB - .07 and   self.ThisAIBot_XFactorA < self.ThisAIBot_XFactorB + .07 and    self.ThisAIBot_ZFactorA > self.ThisAIBot_ZFactorB - .07 and   self.ThisAIBot_ZFactorA < self.ThisAIBot_ZFactorB + .07:
            self.BU_ImmobileTimer_B +=1
            if self.BU_ImmobileTimer_B ==50:
                self.ThisAI_bImmobile = 1
                self.BU_ImmobileTimer_B = 0
        else:
            self.BU_ImmobileTimer_B = 0 # Reset

        return bReturn
Пример #5
0
    def Execute(self):
        if self.target_id != None:
            self.ai.enemy_id = self.target_id

            # default turning & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(0)

            target = plus.getLocation(self.target_id)

            # slow down if we're coming in too fast
            if self.ai.RobotInRange(
                    self.target_id
            )[0] and self.ai.GetSpeed() > self.ai.top_speed / 2:
                self.ai.Throttle(-self.ai.max_throttle)

            # try to get within range of chassis...
            # Commented out original code telling AI not to move if enemy is in their radius.
            ##if self.ai.GetDistanceToID(self.target_id) > self.ai.fRadius \
            ##and not self.ai.RobotInRange(self.target_id)[1]:
            if not self.ai.RobotInRange(self.target_id)[1]:
                self.ai.DriveToLocation(target)
            else:
                # ... then aim for center of chassis
                h = self.ai.GetHeadingTo(target, False)
                self.ai.AimToHeading(h)

            return True
        else:
            return False
Пример #6
0
    def Tick(self):
        # check to see if anyone has been "eliminated" by falling off the tabletop
        for each in self.players:
            if plus.getLocation(each)[1] < -6:
                plus.eliminatePlayer(each)

        return Arenas.SuperArena.Tick(self)
Пример #7
0
    def Execute(self):
        if self.target_id != None:
            self.ai.enemy_id = self.target_id

            # default turning on & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(100)

            heading = self.ai.GetHeadingToID(self.target_id, False)
            target_loc = plus.getLocation(self.target_id)
            clear_path = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                     target_loc)

            distance = (vector3(target_loc) -
                        vector3(self.ai.GetLocation())).length()
            speed = self.ai.GetSpeed()

            # drive forward when we're aimed at the target
            if abs(heading + 0.5) < 1:
                self.ai.Throttle(100)
            else:
                self.ai.Throttle(0)

            return True
        else:
            return False
Пример #8
0
    def Execute(self):
        if self.target_id != None:
            self.ai.enemy_id = self.target_id

            # default turning & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(0)

            target = plus.getLocation(self.target_id)

            # slow down if we're coming in too fast
            if self.ai.RobotInRange(
                    self.target_id
            )[0] and self.ai.GetSpeed() > self.ai.top_speed / 2:
                self.ai.Throttle(-self.ai.max_throttle)

            # try to get within range of chassis...
            if not self.ai.RobotInRange(self.target_id)[1]:
                if self.ai.CanDriveUpsideDown(self.target_id):
                    self.ai.DriveToLocation(target)
                else:
                    self.ai.Throttle(0)
                    h = self.ai.GetHeadingTo(target, False)
                    self.ai.AimToHeading(h)
            else:
                # ... then aim for center of chassis
                h = self.ai.GetHeadingTo(target, False)
                self.ai.AimToHeading(h)

            return True
        else:
            return False
Пример #9
0
    def Charge(self, time, bots):
        self.chargetimer = time
        self.zaptimer = .5
        self.SetAllLightningVisible(False)

        n = 0
        for bot, in_range in bots.iteritems():
            if in_range:
                self.SetLightningStartEnd(n, (0, -2.2, 0),
                                          plus.getLocation(bot))
                self.SetLightningStartEnd(n + 1, plus.getLocation(bot),
                                          (0, -2.1, 0))
                self.SetLightningStartEnd(n + 2, (0, -2.0, 0),
                                          plus.getLocation(bot))
                self.SetLightningVisible(n, True)
                self.SetLightningVisible(n + 1, True)
                self.SetLightningVisible(n + 2, True)
                n += 3
Пример #10
0
    def Evaluate(self):
        self.priority = 0
        self.target_id, range = self.ai.GetNearestEnemy()

        if self.target_id != None:
            heading = self.ai.GetHeadingToID(self.target_id, False)

            clear_path = self.ai.IsStraightPathClear(
                self.ai.GetLocation(), plus.getLocation(self.target_id))
            if not clear_path: self.priority -= 75
Пример #11
0
    def CanDriveUpsideDown(self, bot):
        MOVE_THRESHOLD = self.move_thresh

        if bot in self.upTrack:
            t = self.upTrack[bot]
            # self.tauntbox.get("taunt1").setText(str(t.contact))

            # Check if we've made contact with the enemy
            if (self.flip == 1 or self.compinzone == 1) and t.contact == 0:
                t.contact = 1

            # check to see if he's moved recently
            position = plus.getLocation(bot)
            time = plus.getTimeElapsed()
            if time - t.last_time > self.move_time:
                # this record is too old to be reliable
                t.last_time = time
                t.last_position = position
                #return False
            v0 = vector3(t.last_position)
            v1 = vector3(position)
            # Don't assume the enemy is immobile if we haven't made contact
            if (v1 - v0).length() > MOVE_THRESHOLD or t.contact == 0:
                # Reality check: Is the enemy actually still mobile (after a cooldown period to let them settle) - if so, reset contact
                if t.contact == 2 and time - t.stoptime > self.cooldown:
                    t.contact = 0
                    return True
                else:
                    return True
            # Check if we've made contact and the enemy isn't moving
            if (v1 - v0).length() <= MOVE_THRESHOLD and t.contact > 0:
                if t.contact == 1:
                    t.contact = 2
                    t.stoptime = plus.getTimeElapsed()
                return False
        else:
            t = UpsideDownTracker()
            t.last_position = plus.getLocation(bot)
            t.last_time = plus.getTimeElapsed()
            t.contact = 0
            t.stoptime = plus.getTimeElapsed()
            self.upTrack[bot] = t
            return False
Пример #12
0
    def Tick(self):
        # do our stuff here
        if self.bHazardsOn:
            self.spikes1.Tick()
            self.spikes2.Tick()
            self.grate.Tick()

        # check to see if anyone has been "eliminated" by falling off the tabletop
        for each in self.players:
            if plus.getLocation(each)[1] < -2:
                plus.eliminatePlayer(each)

        return Arenas.SuperArena.Tick(self)
Пример #13
0
    def Activate(self, active):
        plus.damage(1, 0, 50000, plus.getLocation(1))
        plus.damage(1, 0, 50000, plus.getLocation(1))
        plus.damage(1, 0, 50000, plus.getLocation(1))
        if active:
            #if AI.SuperAI.debugging:
                self.debug = Gooey.Plain("watch", 0, 75, 200, 105)
                tbox = self.debug.addText("line0", 0, 0, 200, 15)
                tbox.setText("Throttle")
                tbox = self.debug.addText("line1", 0, 15, 200, 15)
                tbox.setText("Turning")
                tbox = self.debug.addText("line2", 0, 30, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line3", 0, 45, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line4", 0, 60, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line5", 0, 75, 200, 15)
                tbox.setText("")
                tbox = self.debug.addText("line6", 0, 90, 200, 15)
                tbox.setText("")


        return AI.SuperAI.Activate(self, active)
Пример #14
0
    def Activate(self, active):
        if active:
            if AI.SuperAI.debugging:
                self.debug = Gooey.Plain("watch", 10, 175, 250, 175)
                tbox = self.debug.addText("line0", 10, 0, 100, 15)
                tbox.setText("Throttle")
                tbox = self.debug.addText("line1", 10, 15, 100, 15)
                tbox.setText("Turning")
                tbox = self.debug.addText("line2", 10, 30, 100, 15)
                tbox.setText("")
                tbox = self.debug.addText("line3", 10, 45, 100, 15)
                tbox.setText("")
            self.tauntbox = Gooey.Plain("taunt", 10, 175, 640, 175)
            tbox = self.tauntbox.addText("taunt1", 10, 0, 640, 15)
            tbox.setText("")

            self.RegisterSmartZone(self.zone, 1)

            if self.exactingRevenge == 1:
                self.bids = list(plus.getPlayers())
                self.bids.remove(self.GetID())

                #list the number of components on each bot and get the maximum number
                self.complist = []
                for bot in self.bids:
                    self.complist.append(plus.describe(bot).count(" "))
                    self.arena.CreateLightning(bot, self.GetLocation(), plus.getLocation(bot))
                    self.arena.SetLightningVisible(bot, True)
                    #disable controls - just to make players even more helpless than they already are.
                    plus.disable(bot, 1)
                self.numComps = max(self.complist)

                self.yCenter = self.GetLocation()[1] + 6
                plus.playSound(self.psygrab)
                plus.loopSound(self.music)

                #torches for Epic Showdown arena
                plus.AddParticleEmitter((-10.25, 4, 0), (0, 3, 0), (2, 5, 2)).SetEmitting(True)
                plus.AddParticleEmitter((-5.125, 4, -8.88), (0, 3, 0), (2, 5, 2)).SetEmitting(True)
                plus.AddParticleEmitter((5.125, 4, -8.88), (0, 3, 0), (2, 5, 2)).SetEmitting(True)
                plus.AddParticleEmitter((10.25, 4, 0), (0, 3, 0), (2, 5, 2)).SetEmitting(True)
                plus.AddParticleEmitter((5.125, 4, 8.88), (0, 3, 0), (2, 5, 2)).SetEmitting(True)
                plus.AddParticleEmitter((-5.125, 4, 8.88), (0, 3, 0), (2, 5, 2)).SetEmitting(True)
        else:
            # get rid of reference to self
            self.secretFunction = None

        return AI.SuperAI.Activate(self, active)
Пример #15
0
    def Evaluate(self):
        self.priority = 0
        self.target_id, range = self.ai.GetNearestEnemy()

        if self.target_id != None:
            heading = self.ai.GetHeadingToID(self.target_id, False)

            # no turning = more desirable
            self.priority = 100 - (abs(heading) * 20)

            # too close to enemy = less desirable
            #if range < 3: self.priority -= 75 * (3 - range)

            clear_path = self.ai.IsStraightPathClear(
                self.ai.GetLocation(), plus.getLocation(self.target_id))
            if not clear_path: self.priority -= 75
Пример #16
0
    def Execute(self):
        if self.target_location and self.target_id != None:
            self.ai.enemy_id = self.target_id

            e = vector3(plus.getLocation(self.target_id))
            dest = vector3(self.target_location)

            dir = dest - e
            dir.y = 0

            # default turning & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(0)

            # end this action if enemy is close to destination
            if dir.length() < 1: return False

            dir.normalize()

            a = Arenas.currentArena

            # try to line up behind enemy (or to the sides as a last resort)
            target = e - dir * 3
            clear_path = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                     target.asTuple())
            if not clear_path:
                dir.x, dir.y, dir.z = dir.z, dir.y, dir.x
                target = e - dir * 3
                clear_path = self.ai.IsStraightPathClear(
                    self.ai.GetLocation(), target.asTuple())
                if not clear_path:
                    dir.x, dir.z = -dir.x, -dir.z
                    target = e - dir * 3

            if not self.ai.DriveToLocation(target.asTuple()):
                # TODO: head toward enemy or target location?!
                #h = self.ai.GetHeadingTo(e.asTuple(), False)
                h = self.ai.GetHeadingTo(self.target_location, False)
                if abs(h) > .25:
                    self.ai.AimToHeading(h)
                else:
                    # shove!
                    self.ai.Throttle(100)

            return True
        else:
            return False
Пример #17
0
    def Tick(self):
        # check to see if anyone has been "eliminated" by falling off the tabletop
        for each in self.players:
            if plus.getLocation(each)[1] < -4:
                plus.eliminatePlayer(each)

        if self.bHazardsOn:
            self.flame1a.Tick()
            self.flame1b.Tick()
            self.flame2a.Tick()
            self.flame2b.Tick()
            self.flame3a.Tick()
            self.flame3b.Tick()
            self.flame4a.Tick()
            self.flame4b.Tick()

        return Arenas.SuperArena.Tick(self)
Пример #18
0
    def Execute(self):
        "Try to reorient to a new attack position for a few seconds."

        if not self.ai.lastTactic or self.ai.lastTactic.name != "Reorient":
            # reorienting anew
            self.target_id, range = self.ai.GetNearestEnemy()
            self.timeStarted = plus.getTimeElapsed()
            self.destination = None

            self.bInReverse = False

            if self.target_id != None:
                # pick a location to one side of the target bot and drive to it, then attack again
                target = plus.getLocation(self.target_id)
                loc = self.ai.GetLocation()
                distance = (-5, 5)
                dir = vector3(target) - vector3(loc)
                dir.normalize()
                dir.x, dir.z = dir.z, dir.x

                for d in distance:
                    # drive toward the side of the enemy for about 5 seconds
                    dest = vector3(target) + dir * d

                    if self.ai.IsStraightPathClear(loc, dest.asTuple()):
                        self.destination = dest
                        break

                # if the sides are unavailable, try backing up or going forward
                if not self.destination:
                    distance = (-5, 5)
                    dir.x, dir.z = dir.z, dir.x
                    for d in distance:
                        dest = vector3(target) + dir * d
                        if self.ai.IsStraightPathClear(loc, dest.asTuple()):
                            self.destination = dest
                            if d < 0: self.bInReverse = True
                            else: self.bInReverse = False
                            break

        if self.destination != None:
            self.ai.DriveToLocation(self.destination.asTuple(),
                                    self.bInReverse)
            return True

        return False
Пример #19
0
    def Tick(self):
        # check to see if anyone has been "eliminated" by falling into a pit
        for each in self.players:
            if plus.getLocation(each)[1] < -1.5 and not plus.isEliminated(
                    each):
                plus.eliminatePlayer(each)

        if self.bHazardsOn:
            self.Hell1.Tick()
            self.Hell2.Tick()
            self.Hammer1.Tick()
            self.Hammer2.Tick()
            self.Pit1.Tick()
            self.Pit2.Tick()
            self.Pit3.Tick()
            self.Pit4.Tick()

        return Arenas.SuperArena.Tick(self)
Пример #20
0
    def Execute(self):
        a = Arenas.currentArena
        enemy = a.GetScoringPlayer()

        if enemy is None: return False

        target_loc = plus.getLocation(enemy)
        clear_path = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                 target_loc)
        heading = self.ai.GetHeadingToID(enemy, False)

        self.ai.AimToHeading(heading)

        if clear_path and abs(heading) < .35:
            self.ai.Throttle(100)
        else:
            self.ai.DriveToLocation(target_loc)

        return True
Пример #21
0
    def Activate(self, active):
        if active:
            if AI.SuperAI.debugging:
                self.debug = Gooey.Plain("watch", 0, 75, 100, 75)
                tbox = self.debug.addText("line0", 0, 0, 100, 15)
                tbox.setText("Throttle")
                tbox = self.debug.addText("line1", 0, 15, 100, 15)
                tbox.setText("Turning")
                tbox = self.debug.addText("line2", 0, 30, 100, 15)
                tbox.setText("")
                tbox = self.debug.addText("line3", 0, 45, 100, 15)
                tbox.setText("")
            if self.spin_range == math.pi*100:
                plus.emitSmoke(100, (plus.getLocation(self.GetID())), (0, 0, 0), (5, 5, 5))
                CompList = plus.describe(self.GetID())
                for comp in xrange(0,CompList.count(" ")): plus.show(self.GetID(),comp,0)

            self.RegisterSmartZone(self.zone, 1)

        return AI.SuperAI.Activate(self, active)
Пример #22
0
    def Tick(self):
        #self.announcetimer -= .25
        if self.chargetimer == 0.0 and self.NumBotsInRange() == 1:
            self.Zap()

        if self.zaptimer > 0.0:
            self.zaptimer -= .25
            if self.zaptimer <= 0.0:
                self.zaptimer = 0.0
                self.zapping = []
                plus.stopSound(self.zapsound)
            elif self.zaptimer > 0.0:
                for bot in self.zapping:
                    if not plus.isMatchPaused() and not plus.isMatchOver():
                        plus.damage(bot, 0, 25, plus.getLocation(bot))
                        if self.sensors[bot]:
                            plus.force(bot, 0, 115 * plus.getWeight(bot), 0)

        if self.chargetimer > 0.0:
            self.chargetimer -= .25
        elif self.chargetimer < 0.0:
            self.chargetimer = 0.0
Пример #23
0
    def Evaluate(self):
        # if we have a clean shot at an enemy near an edge, go for it
        self.priority = -1000

        enemies = self.ai.GetEnemies()
        a = Arenas.currentArena

        threshold = 5

        for enemy in enemies:
            self.target_id = enemy
            enemy_loc = plus.getLocation(enemy)
            dist, over, h = a.DistanceToEdge(enemy_loc)
            if dist < threshold:
                # if enemy is close to edge & we're heading toward the edge, push him
                push_loc = vector3(enemy_loc).move(self.ai.GetHeading(False),
                                                   threshold)
                dist, over, h = a.DistanceToEdge(push_loc.asTuple())
                if over and self.ai.IsStraightPathClear(
                        self.ai.GetLocation(), enemy_loc):
                    priority = 100 - 50 * abs(
                        self.ai.GetHeadingToID(enemy, False))
                    if priority > self.priority:
                        self.priority = priority
Пример #24
0
    def Evaluate(self):
        self.priority = 0
        self.target_id, range = self.ai.GetNearestEnemy()
        self.target_location = None

        if self.target_id != None:
            # get hazard nearest enemy
            a = Arenas.currentArena

            enemy_loc = plus.getLocation(self.target_id)

            hazard = a.GetNearestHazard(enemy_loc)
            if hazard != None:
                self.priority = 100

                self.target_location = hazard.location

                # target too close to hazard = less desirable
                distance = (vector3(self.target_location) -
                            vector3(enemy_loc)).length()
                if distance < 1: self.priority -= 75

                clear_path = self.ai.IsStraightPathClear(
                    enemy_loc, self.target_location)
                if not clear_path: self.priority -= 50

                #d1 = vector3(self.ai.GetLocation()) - vector3(enemy_loc)
                d2 = vector3(enemy_loc) - vector3(self.target_location)

                # penalties for distance to enemy & distance from enemy to hazard
                self.priority -= (range * 3)
                self.priority -= (d2.length() * 2)
            else:
                self.priority -= 100
        else:
            self.priority -= 100
Пример #25
0
    def Tick(self):
        for each in plus.getPlayers():
            if plus.getLocation(each)[1] < -5 or abs(plus.getLocation(each)[0]) > 18 or abs(plus.getLocation(each)[2]) > 18:
                p = 1
            else:
                p = 0

        if self.NumBotsInRange()>0:
            self.Zap()
            if not plus.isMatchPaused() and not plus.isMatchOver():
                for bot, in_range in self.sensors.iteritems():
                    x = abs(plus.getLocation(bot)[0])
                    y = plus.getLocation(bot)[1]
                    z = abs(plus.getLocation(bot)[2])
                    if in_range and p==0 and y<3 and y>-5 and ((x>11.5 and x<18) or (z>11.5 and z<18)):
                        plus.damage(bot, 0, 16, plus.getLocation(bot))
                        plus.addPoints(bot, -16)
        
        if self.NumBotsInRange()==0:
            self.zapping = []
            plus.stopSound(self.zapsound)
Пример #26
0
    def Tick(self):
        self.wallmaster += 1

        for each in self.players:
            if plus.getLocation(each)[1] < -0.6 and (
                    abs(plus.getLocation(each)[0]) > 11.3
                    or abs(plus.getLocation(each)[2]) > 11.3):
                plus.eliminatePlayer(each)
            if abs(plus.getLocation(each)[0]) < 1.8 and abs(
                    plus.getLocation(each)[2]) < 1.8 and plus.getLocation(
                        each)[1] < -0.5 and self.wallmaster < 370:
                self.wallmaster = 370

        if self.wallmaster == 370:
            self.retractsound = plus.createSound("Sounds/liftmotor.wav", False,
                                                 (0, 0, 0))
            plus.playSound(self.retractsound)
        if self.wallmaster > 370 and self.wallmaster < 390:
            self.SetPinned("bladewall", False)
            self.prism.Lock(False)
            self.prism.ApplyForce(50)

        return Arenas.SuperArena.Tick(self)
Пример #27
0
    def Tick(self):
        #@@@@@@@@@@@@@@@@@@@@@@
        #  Servo Aiming and firing. (Must enter servo's component assembly number in Bindings [see above]).
        if self.Motor < 1000:  # If there IS a Servo motor controlling the direction of the weapon....
            for trigger in self.Aim_triggers: self.Input(trigger, 0, 0)
            Target, range = self.GetNearestEnemy()
            if Target != None:
                Winkel = (self.GetHeadingToID(Target, False) - self.GetMotorAngle(self.Motor))
                self.DebugString(6, str(self.GetHeadingToID(Target, False)))
                self.DebugString(7, str(-self.GetMotorAngle(self.Motor)))
                self.DebugString(8, str(Winkel))
                if self.AimTowards(Winkel) and range < self.TS_range: # Firing is determined by Aiming and Range set in Bindings "TS_range".
                    for trigger in self.Aim_triggers:  self.Input(trigger, 0, 1)
        #@@@@@@@@@@@@@@@@@@@@@@


        ############--TS_range--#############
        if self.Motor == 1000: # If there's NO Servo motor controlling the direction of the weapon, then just use 'Range' to fire weapon(s).
            enemy, TS_range = self.GetNearestEnemy()
            if enemy is not None and range < self.TS_range:
                plus.playSound(self.Alarm)
                for trigger in self.Aim_triggers:  self.Input(trigger, 0, 1)
        ############--TS_range--#############


        ######WWWWWWWWWWW
        # 3 looping timers for sequential weapon activation (with Bindings input)
        self.weptimerA += self.ACounter3thru4
        if self.weptimerA == self.AParameter3thru4:
            self.weptimerA = 0

        self.weptimerB += self.BCounter5thru8
        if self.weptimerB == self.BParameter5thru8:
            self.weptimerB = 0

        self.weptimerC += self.CCounter1thru7
        if self.weptimerC == self.CParameter1thru7:
            self.weptimerC = 0
        ######WWWWWWWWWWW

        ############--SRM--#############
        self.OnGoingTimer +=1
        if self.OnGoingTimer == 1:  ##############  Get Location "A"
            self.LocX_FactorA = plus.getLocation(self.GetID())[0]
            self.LocZ_FactorA = plus.getLocation(self.GetID())[2]

        if self.OnGoingTimer == 8:  ##############  Get Location "B"
            self.LocX_FactorB = plus.getLocation(self.GetID())[0]
            self.LocZ_FactorB = plus.getLocation(self.GetID())[2]

        if self.LocX_FactorA > self.LocX_FactorB - 0.05 and self.LocX_FactorA < self.LocX_FactorB + 0.05 and self.LocZ_FactorA > self.LocZ_FactorB - 0.05 and self.LocZ_FactorA < self.LocZ_FactorB + 0.05:
            if self.OnGoingTimer == 8:
                for trigger in self.Aim_triggers:  self.Input(trigger, 0, 1)

        if self.OnGoingTimer == 8:  self.OnGoingTimer = 0  # Keep Looping this sensor.
        ############--SRM--#############


        ##########AAAAAAAAAAAAAAAAA
#        if self.altitude > 0: # If there's an 'altitude' entry in Bindings...
#            self.ongoingtimerAA += 1
#
#            if self.ongoingtimerAA <2:
#                self.floor = self.GetLocation()[1]
#
#            if self.GetLocation()[1] < self.floor + self.altitude: # "self.altitude" added for Bindings input #
#                plus.force(0, 0, 100 * plus.getWeight(0), 0)
        ##########AAAAAAAAAAAAAAAAA


        return AI.SuperAI.Tick(self)
Пример #28
0
    def Execute(self):
        if self.target_id != None:
            self.ai.enemy_id = self.target_id

            # default turning & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(0)

            # other info
            heading = self.ai.GetHeadingToID(self.target_id, False)
            target_loc = plus.getLocation(self.target_id)
            clear_path = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                     target_loc)
            distance = (vector3(target_loc) -
                        vector3(self.ai.GetLocation())).length()
            speed = self.ai.GetSpeed()

            # adjust sight range based on speed so we have time to react to obstacles
            self.sight_range = self.sight_range_base + (0.2 * abs(speed))

            # keep track of points in front of and behind us for obstacle detection
            fx = (self.sight_range * math.sin(
                self.ai.GetHeading(False))) + self.ai.GetLocation()[0]
            fz = (self.sight_range * math.cos(
                self.ai.GetHeading(False))) + self.ai.GetLocation()[2]
            rx = (-1 * self.sight_range * math.sin(
                self.ai.GetHeading(False))) + self.ai.GetLocation()[0]
            rz = (-1 * self.sight_range * math.cos(
                self.ai.GetHeading(False))) + self.ai.GetLocation()[2]
            fry = self.ai.GetLocation()[1]
            forloc = (fx, fry, fz)
            rearloc = (rx, fry, rz)

            # markers for detection points
            #plus.emitSmoke(30, (forloc), (0, 2, 0), (3, 3, 3))
            #plus.emitSmoke(30, (rearloc), (0, 2, 0), (3, 3, 3))

            # are there obstacles in front of us or behind us
            forclear = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                   forloc)
            rearclear = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                    rearloc)

            #self.tauntbox.get("taunt1").setText("fc:" + str(forclear) + " rc:" + str(rearclear) + " reorient:" + str(self.reorient) + " BUtimer:" + str(self.backuptimer))

            # if we're close to the enemy and not moving fast, try to get away for another ram
            if (distance < self.sight_range_base
                    and speed > -self.threshold_speed and
                    self.backuptimer < self.backuptime) or self.reorient == 1:
                # if the enemy is on our flank, turn to face them a bit better
                if (math.pi / 3) < abs(heading) < (2 * math.pi / 3):
                    self.ai.AimToHeading(heading)
                # if we're facing the enemy and there's nothing behind us, back up as far as possible
                if abs(heading) <= (math.pi / 3):
                    if rearclear:
                        self.reorient = 1
                        self.ai.Turn(0)
                        self.ai.Throttle(100)
                    else:
                        self.reorient = 0
                        # if we can't get away, push back
                        if abs(heading) < (math.pi - 0.25):
                            self.ai.AimToHeading(heading)
                        else:
                            self.ai.Throttle(100)
                # if we're facing away from the enemy and there's nothing in front of us, drive forward to get away
                if abs(heading) >= (2 * math.pi / 3):
                    if forclear:
                        self.reorient = 1
                        self.ai.Turn(0)
                        self.ai.Throttle(-100)
                    else:
                        self.reorient = 0
                        # if we can't get away, try to turn around and push back
                        if abs(heading) < (math.pi - 0.25):
                            self.ai.AimToHeading(heading)
                        else:
                            self.ai.Throttle(100)
                # optional timer for bots that go crazy after too long in reverse
                if self.reorient == 1:
                    self.backuptimer += 1
                if self.backuptimer >= self.backuptime:
                    self.reorient = 0
                # 2 times our base sight range is far enough away
                if distance >= (self.sight_range_base * 2):
                    self.backuptimer = 0
                    self.reorient = 0
            elif (distance < self.sight_range_base
                  and speed > -self.threshold_speed
                  and self.backuptimer >= self.backuptime):
                if abs(heading) < (math.pi - 0.25):
                    self.ai.AimToHeading(heading)
                else:
                    self.ai.Throttle(100)
                # reset backuptimer when we hit the enemy
                if plus.getTimeElapsed() - self.ai.GetLastDamageDone(
                )[2] <= 0.5:
                    self.backuptimer = 0
            elif not clear_path:
                # if we don't have a clear shot, get closer
                self.ai.DriveToLocation(plus.getLocation(self.target_id))
            else:
                # Ram the opponent
                if self.nosecone > 0:
                    if abs(heading) < math.pi - math.tan(
                            self.nosecone / distance):
                        self.ai.AimToHeading(heading)
                    else:
                        self.ai.Throttle(100)
                # stop charging if we're near the edge!
                if plus.getGameType() == "TABLETOP":
                    a = Arenas.currentArena
                    loc = vector3(self.ai.GetLocation())

                    # check to see if we're already over
                    dist, over, h = a.DistanceToEdge(loc.asTuple())
                    if over: return False

                    # now check to see if we're heading over
                    angle = self.ai.GetHeading(False)
                    dir = vector3(math.sin(angle), 0, math.cos(angle))
                    speed = self.ai.GetSpeed()

                    look_ahead = .5

                    loc += dir * speed * look_ahead

                    dist, over, h = a.DistanceToEdge(loc.asTuple())
                    if over: return False

                # drive as fast as we can toward the target
                if abs(heading) < (math.pi - 0.25):
                    self.ai.AimToHeading(heading)
                else:
                    self.ai.Throttle(100)
            return True
        else:
            return False
Пример #29
0
    def Secret(self, bTarget):
        #This is definitely NOT a secret super death AI for Spinner from the west!!!  You don't need to scroll down any further!!!
        # Tauntauns
        if self.numComps > 0:
            if plus.getTimeElapsed() < 3:
                self.tauntbox.get("taunt1").setText("I have been waiting a long time for this.")
            if 3 < plus.getTimeElapsed() < 5:
                self.tauntbox.get("taunt1").setText("Go on, squirm!")
            if 5 < plus.getTimeElapsed() < 8:
                self.tauntbox.get("taunt1").setText("Just try and budge that useless hood ornament you call a weapon!")
            if 8 < plus.getTimeElapsed() < 10:
                self.tauntbox.get("taunt1").setText("Squirm like the worm you are!")
            if 10 < plus.getTimeElapsed() < 12:
                self.tauntbox.get("taunt1").setText("Your struggles will not avail you...")
            if 12 < plus.getTimeElapsed() < 16:
                self.tauntbox.get("taunt1").setText("...against the power of the EYE OF THE WEST!")
            if 16 < plus.getTimeElapsed() < 18:
                self.tauntbox.get("taunt1").setText("Long have I tolerated your abuse, but NO LONGER!")
            if 18 < plus.getTimeElapsed() < 22:
                self.tauntbox.get("taunt1").setText("With the power of the Western Eye at my command, I AM INVINCIBLE!")
            if 22 < plus.getTimeElapsed() < 24:
                self.tauntbox.get("taunt1").setText("Now... suffer.")
            if 24 < plus.getTimeElapsed() < 27:
                self.tauntbox.get("taunt1").setText("Know the black depths of pain you have inflicted upon me!")
            if 27 < plus.getTimeElapsed() < 29:
                self.tauntbox.get("taunt1").setText("FEEL THE WRATH OF THE WEST!")
            if 29 < plus.getTimeElapsed() < 32:
                self.tauntbox.get("taunt1").setText("HA HA HA HA HA HA HA HA HA HA HA HA HA...")

        #stay put unless we're being counted out
        if not self.bImmobile:
            self.Throttle(0)

        for bot in self.bids:
            #cool psychic lightning effects
            self.arena.SetLightningStartEnd(bot, self.GetLocation(), plus.getLocation(bot))
            self.zaptimer += 1
            if self.zaptimer > 4:
                plus.zap(bot, 20, 1)
                self.zaptimer = 0

            #apply more force as bots get further from center
            self.xforce = -1 * plus.getLocation(bot)[0] * plus.getWeight(bot)
            self.yforce = -30 * (plus.getLocation(bot)[1] - self.yCenter) * plus.getWeight(bot)
            self.zforce = -1 * plus.getLocation(bot)[2] * plus.getWeight(bot)

            plus.force(bot, self.xforce, self.yforce, self.zforce)

            #summon THE EYE OF THE WEST
            if abs(plus.getLocation(bot)[0]) < 2 and abs(plus.getLocation(bot)[2]) < 2 and self.eyetimer == 0:
                self.summon = 1
                plus.removeSound(self.psygrab)

        if self.summon == 1 and self.eyetimer < 17:
            self.eyetimer += 0.25
        if 0 < self.eyetimer <= 8 and self.eyetimer%1 == 0:
            plus.AddParticleEmitter((4*math.cos((math.pi/8)*self.eyetimer), (self.yCenter - 6), 4*math.sin((math.pi/8)*self.eyetimer)), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((4*math.cos((math.pi/8)*self.eyetimer + math.pi), (self.yCenter - 6), 4*math.sin((math.pi/8)*self.eyetimer + math.pi)), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 9:
            plus.AddParticleEmitter((1, (self.yCenter - 6), 3), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-1, (self.yCenter - 6), -3), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 10:
            plus.AddParticleEmitter((1.6, (self.yCenter - 6), 2), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-1.6, (self.yCenter - 6), -2), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 11:
            plus.AddParticleEmitter((1.9, (self.yCenter - 6), 1), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-1.9, (self.yCenter - 6), -1), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 12:
            plus.AddParticleEmitter((2, (self.yCenter - 6), 0), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-2, (self.yCenter - 6), 0), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 13:
            plus.AddParticleEmitter((1.9, (self.yCenter - 6), -1), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-1.9, (self.yCenter - 6), 1), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 14:
            plus.AddParticleEmitter((1.6, (self.yCenter - 6), -2), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-1.6, (self.yCenter - 6), 2), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 15:
            plus.AddParticleEmitter((1, (self.yCenter - 6), -3), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.AddParticleEmitter((-1, (self.yCenter - 6), 3), (0, 3, 0), (1, 5, 1)).SetEmitting(True)
            plus.playSound(self.flamepuff)
        if self.eyetimer == 16:
            plus.AddParticleEmitter((0, (self.yCenter - 6), 0), (0, 16, 0), (1, 16, 1)).SetEmitting(True)
            plus.playSound(self.eye)
            plus.removeSound(self.flamepuff)
            self.timetodie = 1

        #remove enemy components one by one
        if self.timetodie == 1:
            if self.numComps > 0:
                self.numComps -= 0.25
                if self.numComps%1 == 0:
                    plus.addPoints(self.GetID(), 1337)
                    for bot in self.bids:
                        if self.numComps > 0:
                            plus.emitSmoke(30, (plus.getLocation(bot)), (0, 0, 0), (5, 5, 5))
                            plus.damage(bot, self.numComps, 100000, plus.getLocation(bot))
                            plus.damage(bot, self.numComps, 100000, plus.getLocation(bot))
                            plus.addPoints(bot, -1000)

        #finishing blow
        if self.numComps == 0:
            if self.smoker == 32:
                plus.removeSound(self.eye)
                plus.fadeInToLoop(self.finale, -100, 3200)
                self.tauntbox.get("taunt1").setText("Do you hear that sound? Know what it is?")
            if self.smoker > 1:
                self.smoker -= 0.5
            self.smoketimer += 0.1
            self.smokeh = (self.yCenter - 6) + (6 * ((1 / self.smoker) ** 2))

            #SMOKE TORNADO
            plus.emitSmoke(30, ((self.smoker * (math.cos((math.pi/4) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((math.pi/4) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((math.pi/2) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((math.pi/2) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((3*math.pi/4) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((3*math.pi/4) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((math.pi) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((math.pi) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((5*math.pi/4) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((5*math.pi/4) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((3*math.pi/2) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((3*math.pi/2) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((7*math.pi/4) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((7*math.pi/4) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))
            plus.emitSmoke(30, ((self.smoker * (math.cos((2*math.pi) + self.smoketimer))), self.smokeh, (self.smoker * (math.sin((2*math.pi) + self.smoketimer)))), (0, 0, 0), (5, 8, 5))

            if self.smoker == 24:
                self.tauntbox.get("taunt1").setText("That is the sound of your death approaching.")
            if self.smoker == 16:
                self.tauntbox.get("taunt1").setText("At last... vengeance shall be mine.")
            if self.smoker == 8:
                self.tauntbox.get("taunt1").setText("HA HA HA HA HA HA HA HA HA HA HA HA HA...")
            if self.smoker == 2:
                plus.stopAllSounds()
                plus.playSound(self.charge)
            if self.smoker == 1:
                plus.removeSound(self.charge)
                plus.playSound(self.bang)
                self.smoker = 0.9
                plus.fadeFromBlack(6)
                for bot in self.bids:
                    #must un-disable bots in order to kill them
                    plus.disable(bot, 0)
                    self.arena.SetLightningVisible(bot, False)
                    plus.damage(bot, 0, 100000, plus.getLocation(bot))
                    plus.damage(bot, 0, 100000, plus.getLocation(bot))
                    plus.damage(bot, 0, 100000, plus.getLocation(bot))
                    plus.damage(bot, 0, 100000, plus.getLocation(bot))
                    #reset numLosses
                    file("adaptiveAI_2.txt", "w").write("0")
Пример #30
0
    def Execute(self):
        if self.target_id != None:
            self.ai.enemy_id = self.target_id

            # default turning & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(0)

            heading = self.ai.GetHeadingToID(self.target_id, False)
            target_loc = plus.getLocation(self.target_id)
            clear_path = self.ai.IsStraightPathClear(self.ai.GetLocation(),
                                                     target_loc)

            distance = (vector3(target_loc) -
                        vector3(self.ai.GetLocation())).length()
            speed = self.ai.GetSpeed()

            # if we're close but not moving very fast, pick a new location and back toward it
            if (distance < 3 and speed < 2.0) or (distance < 5 and speed < 0):
                if self.regroupPos == None or self.regroupTime <= 0:
                    self.regroupPos = None
                    # pick a point near us that has a clear shot at the target?
                    for r in (0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6):
                        angle = self.ai.GetHeading(True) + r * (math.pi / 6)
                        new_dir = vector3(math.sin(angle), 0, math.cos(angle))
                        dest = vector3(target_loc) + new_dir * 5

                        clear_path = self.ai.IsStraightPathClear(
                            dest.asTuple(), target_loc)
                        if clear_path:
                            self.regroupPos = dest.asTuple()
                            self.regroupDir = (abs(r) <= 3)
                            self.regroupTime = 16
                            break

                # sanity check: if we can't find a valid position, drive forward or backward
                if self.regroupPos == None:
                    self.regroupDir = not self.regroupDir
                    range = 5
                    if self.regroupDir: range = -5
                    self.regroupPos = (
                        vector3(self.ai.GetLocation()) +
                        vector3(self.ai.GetDirection()) * range).asTuple()
                    self.regroupTime = 16

                self.ai.DriveToLocation(self.regroupPos, self.regroupDir)
                self.regroupTime -= 1
            elif distance > 3 and abs(heading) > .35 or not clear_path:
                # if we don't have a clear shot, get closer
                self.ai.DriveToLocation(plus.getLocation(self.target_id))
            else:
                # stop charging if we're near the edge!
                if plus.getGameType() == "TABLETOP":
                    a = Arenas.currentArena
                    loc = vector3(self.ai.GetLocation())

                    # check to see if we're already over
                    dist, over, h = a.DistanceToEdge(loc.asTuple())
                    if over: return False

                    # now check to see if we're heading over
                    angle = self.ai.GetHeading(False)
                    dir = vector3(math.sin(angle), 0, math.cos(angle))
                    speed = self.ai.GetSpeed()

                    look_ahead = .5

                    loc += dir * speed * look_ahead

                    dist, over, h = a.DistanceToEdge(loc.asTuple())
                    if over: return False

                # drive as fast as we can toward the target
                self.ai.AimToHeading(heading)
                self.ai.Throttle(100)
                self.regroupPos = None

            return True
        else:
            return False