Ejemplo n.º 1
0
    def func(self):
        caller = self.caller
        if not self.args:
            caller.msg(self.usage)
            return
        self.heading, self.distance = self.args.split()
        vessel = caller.location
        report = caller.msg
        heading = int(self.heading)
        print heading
        distance = float(self.distance)
        print distance

        report("You set a heading of %s, and travel %s nautical miles"
               % (str(heading), str(distance)))

        start_position = (tuple(vessel.db.position))
        # start_position = (0, 0)
        report("given a starting position of %s" % str(start_position))

        final_position = move_vector(start_position, (heading, distance))

        report("You will arrive at %s" % str(final_position))

        # Lets see if arrive at works out of the box:
        self.obj.arrive_at(vessel, final_position)
Ejemplo n.º 2
0
    def func(self):
        caller = self.caller
        if not self.args:
            caller.msg(self.usage)
            return
        self.heading, self.distance = self.args.split()
        vessel = caller.location
        report = caller.msg
        heading = int(self.heading)
        print heading
        distance = float(self.distance)
        print distance

        report("You set a heading of %s, and travel %s nautical miles"
               % (str(heading), str(distance)))

        start_position = (tuple(vessel.db.position))
        # start_position = (0, 0)
        report("given a starting position of %s" % str(start_position))

        final_position = move_vector(start_position, (heading, distance))

        report("You will arrive at %s" % str(final_position))

        # Lets see if arrive at works out of the box:
        self.obj.arrive_at(vessel, final_position)
Ejemplo n.º 3
0
 def make_way(self):  # over ride the floating objects make_way
     '''
     move in response to impelling forces:
     wind, current, and power
     '''
     # Could get wind and current here
     (wind, current) = get_weather(self.db.position)
     power = self.db.power
     sails = self.db.sails
     # polar = self.db.polar  # set by spawner?
     heading = float(self.db.heading)
     bearing = (heading, power)
     print "wind: %s" % str(wind)
     print "current: %s" % str(current)
     # then calculate actual course here.
     if sails:
         self.msg_contents("You're sailing")
         wind = (heading, wind[1] / 2)
         # this lets us sail at any wind angle at half windspeed
     else:
         '''
         if no sails, then wind exerts a fraction of its power
         on the floating object based on the vessel's windage
         '''
         wind = (wind[0], wind[1] * self.db.windage)
         # reduces wind effect to a fraction
     course = add_vector(wind, current)
     if power:
         print "power: %s" % str(power)
         print "bearing: %s" % str(bearing)
         course = add_vector(course, bearing)
         print "course: %s" % str(course)
     position = move_vector(self.db.position, course)
     self.arrive_at(position)
Ejemplo n.º 4
0
 def make_way(self):
     """
     move in response to impelling forces:
     wind, current, and power
     on a bare floating object this is purely based on wind and current
     a floater doesn't have a heading and never has power.
     """
     # Could get wind and current here
     (wind, current) = get_weather(self.db.position)
     print "wind: %s" % str(wind)
     print "current: %s" % str(current)
     # then calculate actual course here.
     course = add_vector(wind, current)
     position = move_vector(self.db.position, course)
     self.arrive_at(position)
Ejemplo n.º 5
0
 def make_way(self):
     '''
     move in response to impelling forces:
     wind, current, and power
     on a bare floating object this is purely based on wind and current
     a floater doesn't have a heading and never has power.
     '''
     # Could get wind and current here
     (wind, current) = get_weather(self.db.position)
     print "wind: %s" % str(wind)
     print "current: %s" % str(current)
     # then calculate actual course here.
     wind[1] = wind[1] * self.windage  # reduces wind effect to a fraction
     course = add_vector(wind, current)
     position = move_vector(self.db.position, course)
     self.arrive_at(position)
Ejemplo n.º 6
0
 def make_way(self):  # over ride the floating objects make_way
     """
     move in response to impelling forces:
     wind, current, and power
     """
     # Could get wind and current here
     (wind, current) = get_weather(self.db.position)
     power = self.db.power
     heading = float(self.db.heading)
     bearing = (heading, power)
     print "wind: %s" % str(wind)
     print "current: %s" % str(current)
     # then calculate actual course here.
     course = add_vector(wind, current)
     if power:
         print "power: %s" % str(power)
         print "bearing: %s" % str(bearing)
         course = add_vector(course, bearing)
         print "course: %s" % str(course)
     position = move_vector(self.db.position, course)
     self.arrive_at(position)
Ejemplo n.º 7
0
 def make_way(self, course):
     old_position = self.db.position
     position = move_vector(old_position, course)
     self.msg_contents("New position = %s" % str(position))
     self.arrive_at(self, position)
Ejemplo n.º 8
0
 def make_way(self, course):
     old_position = self.db.position
     position = move_vector(old_position, course)
     self.msg_contents("New position = %s" % str(position))
     self.arrive_at(self, position)