class MassBattle(Story): storybook_path = "demos" def __init__(self, *args): Story.__init__(self, *args) self.default_scenery() world = self.world for i in xrange(50): d = world.new_actor(self.dragon, 200.0 + random() * 400.0) v = world.new_actor(self.villager, 800.0 - random() * 400.0) d.controller.set_waypoint(800.0) v.controller.set_waypoint(200.0) world.camera.goto(400.0) def get_player(self): return None def update(self): pass class MassHunting(MassBattle): story_title = "Massive FSM Battle" dragon = actors.HuntingDragon villager = actors.HuntingVillager storybook.add(MassHunting) class MassBehaving(MassBattle): story_title = "Massive Planner Battle" dragon = actors.BehavingDragon villager = actors.BehavingVillager storybook.add(MassBehaving)
self.batch_narrate(( (0.0, "...13, 14, 15!"), (2.0, "That's the last one!"), (6.0, "So, if I can make a Wind Magic Ball [press 'x']..."), (2.0, "I can change the speed and direction of the wind ['w' and 's' keys]..."), (2.0, "And move it close to my rabbits ['a' and 'd' keys]..."), (3.0, "I should have them gathered between the posts in no time!"), (5.0, "Of course, I must be careful not to hurt them."), )) if self.narrated() and self.time_passed(30): self.narrate("I should use a Wind Magic Ball [press 'x']...", duration = 10.0) self.narrate("...change it's wind direction ['w' and 's' keys]...", duration = 10.0) self.narrate("...and move it close to rabbits ['a' and 'd' keys]...", duration = 10.0) self.narrate("...to guide them between the posts [to the right].", duration = 10.0) storybook.add(Shepherd) class Massacre(Story): story_title = "Fiery Massacre" storybook_path = "campaign" themesong = "warmarch2" def __init__(self, *args): Story.__init__(self, *args) world = self.world self.default_scenery() # paint the destination world.new_actor(actors.Post, 0.0) world.new_actor(actors.Post, 50.0)
from lib.stories import Story, storybook from lib import actors class TestBed(Story): storybook_path = "demos" def __init__(self, *args): Story.__init__(self, *args) world = self.world for i in xrange(2): d = world.new_actor(actors.BehavingDragon, 75.0) for i in xrange(1): d = world.new_actor(actors.BehavingVillager, 125.0) # d.controller.set_waypoint(-100.0) self.dude = world.new_actor(actors.Dude, 125.0) world.camera.follow(self.dude) def get_player(self): return self.dude def update(self): pass storybook.add(TestBed)
from lib.stories import Story, storybook from lib import actors class PlannerSkirmish(Story): storybook_path = "demos" def __init__(self, *args): Story.__init__(self, *args) world = self.world for i in xrange(2): d = world.new_actor(actors.BehavingDragon, 75.0) d = world.new_actor(actors.BehavingVillager, 100.0) #d.controller.set_waypoint(-100.0) world.camera.follow(d) def get_player(self): return None def update(self): pass storybook.add(PlannerSkirmish)
def update(self): story_time, state_time = self.times() if not self.game_over: alldead = True for p in self.prey: if not p.dead: alldead = False break if alldead: self.set_state("prey-killed") self.set_result(True, exit_now = True) elif story_time > self.max_time: self.set_state("prey-survived") self.set_result(False, exit_now = True) storybook.add(Kill) class TripleKill(Kill): enemies = 3 max_time = 60.0 storybook.add(TripleKill) class MultiKill(Kill): enemies = 10 max_time = 120.0 storybook.add(MultiKill) class Evasion(TestBase): subj_class = actors.BehavingVillager enemy_class = actors.HuntingDragon enemies = 1