Пример #1
0
 def startBurning(self):
     if not self.fire_timer and (self.tile.getSurface() != "Water"):
         self.unfreeze()
         self.fire_timer = TacticsTimer(self.name + " stops burning", 12, 1,
                                        self.stopBurning, self.burn, 3)
         self.world.timeline.addTimer(self.fire_timer)
         if self.visual:
             self.visual.startBurning()
Пример #2
0
 def endTurn(self):
     if self.visual:
         self.visual.endTurn()
     self.timer = TacticsTimer(self.name + "'s turn",
                               20 - self.cur_AP * 6 / self.max_AP, 1,
                               self.beginTurn)
     self.cur_AP = 0
     self.world.timeline.addTimer(self.timer)
     self.world.current_character_turn = None
     self.opportunity_attacks = self.max_opportunity_attacks
Пример #3
0
 def unfreeze(self):
     if self.freeze_timer:
         if self.world.timeline.timers.count(self.freeze_timer):
             self.world.timeline.timers.remove(self.freeze_timer)
         self.freeze_timer = None
         self.timer = TacticsTimer(self.name + "'s turn", 20, 1,
                                   self.beginTurn)
         self.world.timeline.addTimer(self.timer)
         if self.visual:
             self.visual.unfreeze()
Пример #4
0
 def freeze(self):
     if not self.freeze_timer:
         self.stopBurning()
         if randint(0, 2) == 0:
             self.freeze_timer = TacticsTimer(self.name + " unfreezes", 4,
                                              1, self.unfreeze)
             self.world.timeline.addTimer(self.freeze_timer)
             if self.world.timeline.timers.count(self.timer):
                 self.world.timeline.timers.remove(self.timer)
             self.timer = None
             if self.visual:
                 self.visual.freeze()
Пример #5
0
	def __init__(self, application, instance, text, time):
		fife.InstanceDeleteListener.__init__(self)
		self.application = application
		self.instance = instance
		self.text = text
		self.timer = TacticsTimer("SayBubble", time, 1, self.destroy, self.adjustPosition)
		self.application.real_timeline.addTimer(self.timer)
		self.instance.addDeleteListener(self)
		self.bubble = PyCEGUI.WindowManager.getSingleton().createWindow("TaharezLook/StaticText", "SayBubble/" + str(self.instance.getFifeId()))
		self.application.gui.root.addChild(self.bubble)
		self.bubble.setText(text)
		self.bubble.setProperty("Size", "{{0," + self.bubble.getProperty("HorzExtent") + "},{0," + self.bubble.getProperty("VertExtent") + "}}")
		self.bubble.setProperty("FrameEnabled", "False")
		self.bubble.setProperty("BackgroundEnabled", "False")
Пример #6
0
    def testTrajectory(self, coords1, coords2, trajectory, visualize=False):
        """
		Return False if an arc from loc1 to loc2 defined by trajectory is blocked by a wall or outside range, True if the arc is clear and in range.
		Uses locations slightly above the ones given.
		Creates an optional visual trajectory.
		"""
        # TODO: visualization probably should not be done here
        ex_coords1 = gridhelper.toExact(coords1)
        ex_coords2 = gridhelper.toExact(coords2)

        z_scale = 3.0
        dist = gridhelper.horizontalDistance(coords1, coords2) * z_scale
        if dist == 0:
            return False
        z = coords2.z - coords1.z
        g = 5.0 / z_scale
        d2 = pow(trajectory.range,
                 4) - g * (g * pow(dist, 2) + 2 * z * pow(trajectory.range, 2))
        if d2 < 0:
            return False
        angle1 = atan((pow(trajectory.range, 2) - sqrt(d2)) / (g * dist))
        #angle2 = atan((pow(trajectory.range, 2) + sqrt(d2)) / (g * dist))

        step = (ex_coords2 - ex_coords1) / 20.0
        if self.visual and visualize:
            los = VisualLOS(self.application)
            self.application.real_timeline.addTimer(
                TacticsTimer("line of sight", 1, 1, los.destroy))
        for i in range(1, 20):
            ex_coords = ex_coords1 + step * float(i)
            ex_coords.z = ex_coords1.z + float(dist) / 20.0 * float(i) * tan(
                angle1) - g * pow(float(dist) / 20.0 * float(i), 2) / (
                    2 * pow(trajectory.range * cos(angle1), 2))
            if self.visual and visualize:
                location = fife.Location(self.maplayer)
                location.setExactLayerCoordinates(
                    fife.ExactModelCoordinate(ex_coords.x, ex_coords.y,
                                              ex_coords.z + 2))
                los.addDot(location, self.shadowLocation(location))
            if self.isBlockedByWall(
                    fife.ExactModelCoordinate(ex_coords.x, ex_coords.y,
                                              ex_coords.z + 1.5), 1):
                if self.visual and visualize:
                    self.application.gui.sayBubble(los.instances[-1],
                                                   "blocked", 50)
                return False
        return True
Пример #7
0
 def __init__(self, name, tile, world):
     self.world = world
     if name == "":
         self.name = "Nameless"
     else:
         self.name = name
     self.team = 0
     self.tile = tile
     self.visual = None
     self.height = 3
     self.max_AP = 6
     self.cur_AP = 0
     self.max_HP = 20
     self.cur_HP = self.max_HP
     self.timer = TacticsTimer(self.name + "'s turn", 20, 1, self.beginTurn)
     self.fire_timer = None
     self.freeze_timer = None
     self.world.timeline.addTimer(self.timer)
     self.combat_actions = []
     self.max_opportunity_attacks = 0
     self.opportunity_attacks = 0
     self.fall_damage = 0
Пример #8
0
	def onMoveFinished(self):
		self.application.real_timeline.addTimer(TacticsTimer("projectile", 0, 1, self.destroy))
		self.application.removeAnimation(self)
		self.final_action()
Пример #9
0
	def onInstanceActionFinished(self, instance, action):
		self.instance.actRepeat('none')
		self.application.real_timeline.addTimer(TacticsTimer("explosion", 0, 1, self.destroy))
		self.application.removeAnimation(self)
Пример #10
0
	def startBurning(self):
		if not self.fire_timer:
			self.fire_timer = TacticsTimer(self.name + " burns out", 24, 1, self.burnOut, self.burn, 3)
			self.world.timeline.addTimer(self.fire_timer)
			if self.visual:
				self.visual.startBurning()