- action = self.actions[self.pc]
-
- if isinstance(action, parser.Repeat):
- repeat, (actions, params) = action(self.params, self.rank)
- child = Action(self.owner, self, actions, params, self.rank)
- child.repeat = repeat
- self.owner.replace(self, child)
- created.extend(child.step())
- break
-
- elif isinstance(action, (parser.ActionDef, parser.ActionRef)):
- actions, params = action(self.params, self.rank)
- child = Action(self.owner, self, actions, params, self.rank)
- self.owner.replace(self, child)
- created.extend(child.step())
- break
-
- elif isinstance(action, (parser.FireDef, parser.FireRef)):
- direction, speed, actions = action(self.params, self.rank)
- if direction:
- direction, type = direction
- if type == "aim" or type is None:
- direction += self.owner.aim
- elif type == "sequence":
- direction += self.previous_fire_direction
- elif type == "relative":
- direction += self.owner.direction
- else:
- direction = self.owner.aim
- self.previous_fire_direction = direction
-
-
- if speed:
- speed, type = speed
- if type == "sequence":
- speed += self.previous_fire_speed
- elif type == "relative":
- # FIXME(jfw): Reference impl uses prvFireSpeed
- # here? That doesn't seem right at all.
- speed += self.owner.speed
- else:
- speed = 1
- self.previous_fire_speed = speed
-
- bullet = Bullet(self.owner.x, self.owner.y, direction, speed,
- self.owner.target, actions, self)
- created.append(bullet)
-
- elif isinstance(action, parser.ChangeSpeed):
- frames, (speed, type) = action(self.params, self.rank)
- self.speed_frames = frames
- if type == "sequence":
- self.speed = speed
- elif type == "relative":
- self.speed = speed / frames
- else:
- self.speed = (speed - self.owner.speed) / frames
-
- elif isinstance(action, parser.ChangeDirection):
- frames, (direction, type) = action(self.params, self.rank)
- self.direction_frames = frames
- self.aiming = False
- if type == "sequence":
- self.aiming = False
- self.direction = direction
- else:
- if type == "absolute":
- self.aiming = False
- self.direction = (
- direction - self.owner.direction) % 360
- elif type == "relative":
- self.aiming = False
- self.direction = direction
- else:
- self.aiming = True
- self.direction = (
- direction
- + self.owner.aim
- - self.owner.direction) % 360
-
- while self.direction > 180:
- self.direction -= 360
- while self.direction < -180:
- self.direction += 360
- self.direction /= self.direction_frames
-
- elif isinstance(action, parser.Accel):
- frames, horizontal, vertical = action(self.params, self.rank)
- self.accel_frames = frames
- if horizontal:
- mx, type = horizontal
- if type == "sequence":
- self.mx = mx
- elif type == "absolute":
- self.mx = (mx - self.owner.mx) / frames
- elif type == "relative":
- self.mx = mx / frames
- if vertical:
- my, type = vertical
- if type == "sequence":
- self.my = my
- elif type == "absolute":
- self.my = (my - self.owner.my) / frames
- elif type == "relative":
- self.my = my / frames
-
- elif isinstance(action, parser.Wait):
- self.wait_frames = action(self.params, self.rank)
- break
-
- elif isinstance(action, parser.Vanish):
- self.owner.vanish()