def relaxlever(storage, obj, m):
    storage._go()
    if not storage._getData('library_relaxlever_pressed')\
    and storage._playerInDistance(m.getPlayer().position, obj.rect):
        ad = GlobalServices.getAudioDevice()
        ad.play(SOUND, 'pull_switch', VOLUME_SOUND)
        # Change graphics
        downswitch = os.path.join(PATH_GRAPHICS_TILES,'switch_down.png')
        obj.changeImage(downswitch)
        shelf = m.getObjectByName('shelf')
        ad.play(SOUND, 'shelf', VOLUME_SOUND)
        # Re-position the shelf
        m.removeObject(shelf, True)
        
        add_to_map(get_savegame(), OBJECT, 'libraryupstairs', 'shelf',\
                   pygame.Rect(conv_tile_pixel((47,10), m), conv_tile_pixel((4,6), m)),\
                   'libraryupstairs_shelf', 'bigshelf_four.png', True)
        
        # Add the next lever (that was behind the moved shelf)
        add_to_map(get_savegame(), OBJECT, 'libraryupstairs', 'officelever',\
                   pygame.Rect(conv_tile_pixel((45,11), m), conv_tile_pixel((1,2), m)),\
                   'libraryupstairs_officelever', 'switch_up.png', True)
        
        storage._accessData()
        storage._setData('library_relaxlever_pressed', True)
    storage._halt()
def init(storage, m):
    storage._go()
    storage._toggleCutscene(True)
    ad = GlobalServices.getAudioDevice()
    tr = GlobalServices.getTextRenderer()
    ad.stop(MUSIC, 5000)
    ad.stop(SOUND, 5000, 'amb_guardian')
    # Make the overlay
    darktrans = OverlayFactory.create_animated_color((20,0,0),\
                5000, 0, True, 0, 220)
    dark = OverlayFactory.create_by_color((20,0,0), 0, 220)
    fog = OverlayFactory.create("fog.png", pygame.BLEND_MULT)
    white = OverlayFactory.create("noise.png", pygame.BLEND_MULT)
    m.clearOverlays()
    m.addOverlay(darktrans)
    m.addOverlay(fog)
    
    player = m.getPlayer()
    shadow = m.getShadow()
    shadow.setPosition(conv_tile_pixel((8,10),m))
    
    player.setDirection([0,-1])
    player.halfSpeed()
    
    
    # Here be dragons
    storage._wait(5000)
    m.rendering_enabled = True
    m.addOverlay(dark)
    m.removeOverlay(darktrans)
    ad.play(MUSIC, 'bgm_4', VOLUME_MUSIC, -1)
    ad.play(SOUND, 'flashlight_toggle', VOLUME_SOUND)
    
    storage._wait(2000)
    tr.write("What is this place?", 3)
    storage._wait(3000)
    tr.write("It feels... strangely familiar.", 3)
    storage._wait(2000)
    ad.play(SOUND, 'noise', VOLUME_SOUND_AMBIENT + 0.3, -1)
    m.addOverlay(white)
    shadow.setVisible(True)
    storage._wait(300)
    m.removeOverlay(white)
    ad.stop(SOUND, 0, 'noise')
    shadow.setVisible(False)
    shadow.setPosition(conv_tile_pixel((8,12),m))
    storage._wait(1500)
    m.addOverlay(white)
    ad.play(SOUND, 'noise', VOLUME_SOUND_AMBIENT + 0.3, -1)
    shadow.setVisible(True)
    shadow.moveBy((0, 15), 500)
    storage._wait(450)
    m.removeOverlay(white)
    ad.stop(SOUND, 0, 'noise')
    shadow.setVisible(False)
    
    storage._toggleCutscene(False)
    set_property(SAVE_ENABLED, False)
    storage._halt()
def checkEnding(storage, m):
    storage._go()
    ad = GlobalServices.getAudioDevice()
    ad.stop(SOUND, 0, 'insanity_ear_ring')
    ad.play(SOUND, 'insanity_ear_ring', (0.02*_lastitem[1]), -1, 0)
    # Check if the ending has been reached
    if  storage._getData('attic_photoseen')\
    and storage._getData('attic_handseen')\
    and storage._getData('attic_noteseen')\
    and storage._getData('attic_gunseen')\
    and storage._getData('attic_pencilseen'):
        storage._halt()
        ending(storage, m)
    else:
        # Add a random scare if necessary
        if _lastitem[1] % 2 == 0:
            white = OverlayFactory.create("noise.png", pygame.BLEND_MULT)
            storage._wait(1000)
            shadow = m.getShadow()
            shadow.setPosition(conv_tile_pixel((random.randrange(3,12),\
                                                random.randrange(7,11)),m))
            m.addOverlay(white)
            shadow.setVisible(True)
            ad.play(SOUND, 'noise', VOLUME_SOUND + 0.1, -1)
            storage._wait(300)
            m.removeOverlay(white)
            ad.stop(SOUND, 0, 'noise')
            shadow.setVisible(False)
        storage._halt()
def officelever(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect):
        if not storage._getData('library_officelever_pressed'):
            storage._toggleCutscene(True)
            ad = GlobalServices.getAudioDevice()
            ad.play(SOUND, 'pull_switch', VOLUME_SOUND)
            
            # Change graphics for this lever
            downswitch = os.path.join(PATH_GRAPHICS_TILES,'switch_down.png')
            obj.changeImage(downswitch)
            
            # Grab the shelf in atrium.tmx and delete it
            remove_object_from_map_properties(get_savegame(), 'atrium',\
                                              OBJECT, 'mastershelf', True)
            
            # Add the TeleportClickable to that map
            from src.model.Clickable import TeleportClickable, Clickable
            tele = TeleportClickable('tpmasterroom',\
                                     pygame.Rect(conv_tile_pixel((24, 4), m),\
                                            conv_tile_pixel( (2, 3), m)),\
                                     None, 'atrium_tpmasterroom', 'doormove6',\
                                     'masterroom', 32*16, 35*16)
            add_object_to_map_properties(get_savegame(), 'atrium',\
                                         TELEPORTOBJECT, tele)
            
            # Add vandalized painting image
            painting = get_object_from_map_properties(get_savegame(), 'librarydownstairs','painting')
            vandalized = os.path.join(PATH_GRAPHICS_TILES, 'vandalizedpainting.png')
            painting.changeImage(vandalized)
            update_object_in_map_properties(get_savegame(), 'librarydownstairs', painting)
            
            # Add new wall texts on this map and librarydownstairs.tmx
            add_to_map(get_savegame(), OBJECT, 'libraryupstairs', 'message',\
               pygame.Rect(conv_tile_pixel((43,36), m), conv_tile_pixel((14,5), m)),\
               'libraryupstairs_message', 'message_3.png', True)
            
            # Add the scare script
            add_to_map(get_savegame(), SCRIPT, 'libraryupstairs', 'scare',\
                   pygame.Rect(conv_tile_pixel((38,14), m), conv_tile_pixel((1,6), m)),\
                   'libraryupstairs_scare')
            
            message4path = os.path.join(PATH_GRAPHICS_TILES, 'message_4.png')
            message4 = pygame.image.load(message4path).convert_alpha()
            othermsg = Clickable('message', pygame.Rect(conv_tile_pixel((22,18), m),\
                                 conv_tile_pixel((6,6), m)),\
                                 'librarydownstairs_message', None,
                                 message4, message4path)
            add_object_to_map_properties(get_savegame(), 'librarydownstairs',\
                                         OBJECT, othermsg)                                 
            
            # Toggle this event as "happened"
            storage._setData('library_officelever_pressed', True)
            
            storage._toggleCutscene(False)
        
    storage._halt()
def ceilingdoor(storage, obj, m):
    storage._go()
    if storage._playerInDistance(m.getPlayer().position, obj.rect, 180):
        GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
        inv = m.getPlayer().inventory
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        storage._toggleCutscene(True)
        if inv.containsName(INVENTORY_ITEM_LADDER):
            m.getPlayer().setPosition(conv_tile_pixel((9,15), m))
            # Add ladder to this map
            ad.play(SOUND, '05_attach_ladder', VOLUME_SOUND)
            from src.model.Clickable import TeleportClickable
            ladderpath = os.path.join(PATH_GRAPHICS_TILES, 'ladder_vertical.png')
            laddersurf = pygame.image.load(ladderpath).convert_alpha()            
            
            ladder = TeleportClickable('tpattic',\
                                     pygame.Rect(conv_tile_pixel((9, 7), m),\
                                            conv_tile_pixel( (2, 7), m)),\
                                     m, None, 'ladder_climb',\
                                     'attic', 8*16, 17*16, laddersurf,\
                                     ladderpath, True)
            add_object_to_map_properties(get_savegame(), 'masterroom',\
                                         TELEPORTOBJECT, ladder)
            remove_from_map(get_savegame(), OBJECT, 'masterroom', 'ceilingdoor')
            # Reset player blah
            inv.remove(inv.get(INVENTORY_ITEM_LADDER))
        else:
            tr.write("There is a loft hatch on the ceiling.", 3)
            storage._wait(3000)
            tr.write("I need something to get up there.", 3)
            if not storage._getData('masterroom_ladder_needed'):
                storage._wait(3000)
                ad.play(MUSIC, 'bgm_3', VOLUME_MUSIC, -1)
            storage._setData('masterroom_ladder_needed', True)
        storage._toggleCutscene(False)
    storage._halt()
def scare(storage, obj, m):
    storage._go()
    player = m.getPlayer()
    shadow = m.getShadow()
    ad = GlobalServices.getAudioDevice()
    fl = m.getOverlay("_flashlight")
    player.stopMoving()
    storage._toggleCutscene(True)
    # Helper function for looking in a direction
    def face(direction):
        fl.point(direction)
        player.setDirection(string_to_direction(direction))
        
    face("left")
    
    fog = OverlayFactory.create("fog.png", pygame.BLEND_MULT)
    black = OverlayFactory.create_by_color((0,0,0), 0, 255)
    red = OverlayFactory.create_by_color((200,0,0), 0, 40)
    m.addOverlay(fog)
    m.addOverlay(red)
    # Show shadow
    shadow.setPosition(conv_tile_pixel((31,17), m))
    ad.play(SOUND, '27_orb_implode', VOLUME_SOUND + 0.1)
    ad.play(SOUND, 'scare_male_terrified5', VOLUME_SOUND)
    shadow.setVisible(True)
    storage._wait(1100)
    shadow.moveBy((-70,0), 3000)
    storage._wait(1900)
    ad.play(SOUND, 'insanity_whisper03', VOLUME_SOUND)
    m.addOverlay(black)
    ad.play(SOUND, '27_spark2', VOLUME_SOUND)
    storage._wait(300)
    m.removeOverlay(fog)
    m.removeOverlay(red)
    shadow.setVisible(False)
    m.removeOverlay(black)
    ad.play(SOUND, '27_spark4', VOLUME_SOUND)
    storage._wait(2000)
    
    # Delete script
    m.removeObject(obj)
    
    storage._toggleCutscene(False)
    storage._halt()
def murderscene(storage, obj, m):
    storage._go()
    
    if not storage._getData('mirrorhall_murder_done'):
        GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
        player = m.getPlayer()
        player.stopMoving()
        storage._toggleCutscene(True)
        shadow = m.getShadow()
        shadow.setPosition(conv_tile_pixel((24, 17), m))
        tr = GlobalServices.getTextRenderer()
        ad = GlobalServices.getAudioDevice()
        
        fog = OverlayFactory.create("fog.png", pygame.BLEND_MULT)
        nolight = OverlayFactory.create("nolighting.png", 0)
        
        fl = m.getOverlay("_flashlight")
        # Helper function for looking in a direction
        def face(direction):
            fl.point(direction)
            player.setDirection(string_to_direction(direction))
            
        face("up")
        ad.play(MUSIC, 'event2', VOLUME_MUSIC)
        tr.write("Huh?", 0.5)
        storage._wait(500)
        ad.play(SOUND, 'insanity_whisper03', VOLUME_SOUND)
        storage._wait(250)
        m.addOverlay(fog)
        shadow.setVisible(True)
        shadow.moveBy((-60,0), 3750)
        ad.play(SOUND, 'scare_wood_creak_walk2', VOLUME_SOUND)
        storage._wait(750)
        tr.write("What the hell are you!?", 2)
        storage._wait(1500)
        tr.write("ANSWER ME!! Why did you kill this girl?!", 3)
        storage._wait(1500)
        ad.stop(MUSIC, 10)
        shadow.moveBy((0,70), 1000)
        ad.play(SOUND, 'scare_wood_creak_scuf3', VOLUME_SOUND)
        ad.play(SOUND, 'fb_sfx_19_false_dead01', VOLUME_SOUND - 0.1)
        towhite = OverlayFactory.create_animated_color((255,255,255), 1000, 0, True, 0, 255)
        m.addOverlay(towhite)
        ad.play(SOUND, 'insanity_ear_ring', VOLUME_SOUND_AMBIENT - 0.2, -1, 1000)
        storage._wait(1000)
        ad.play(SOUND, '21_scream10', VOLUME_SOUND - 0.4)
        m.removeOverlay(fog)
        shadow.setVisible(False)
        
        add_to_map(storage.s, OBJECT, 'mirrorhall', 'message',\
                   pygame.Rect(conv_tile_pixel((11,22), m), conv_tile_pixel((4,4), m)),\
                   'mirrorhall_message', 'message_2.png', True)
        
        player.setAnimation("lie_eyesclosed")
        
        storage._wait(5500)
        ad.stop(SOUND, 5000, 'insanity_ear_ring')
        m.removeOverlay(fl)
        totrans = OverlayFactory.create_animated_color((255,255,255), 5500, 0, True, 255, 0)
        m.addOverlay(totrans)
        m.addOverlay(nolight, 0)
        m.removeOverlay(towhite)
        ad.stop(SOUND, 5000, 'fb_sfx_19_false_dead01')
        ad.play(SOUND, '24_amb_noise', VOLUME_SOUND_AMBIENT, -1, 1000)
        storage._wait(6500)
        
        player.setAnimation("lie_eyesopen")
        storage._wait(1000)
        player.setAnimation("lie_eyesclosed")
        storage._wait(400)
        player.setAnimation("lie_eyesopen")
        storage._wait(500)
        player.setAnimation("lie_eyesclosed")
        storage._wait(100)
        player.setAnimation("lie_eyesopen")
        storage._wait(2000)
        player.setAnimation("kneel")
        tr.write("Did I... did I pass out?", 3)
        storage._wait(1500)
        
        player.setAnimation("walk")
        face("down")
        
        storage._wait(4000)
        
        ad.play(SOUND, 'flashlight_toggle', VOLUME_SOUND)
        m.addOverlay(fl)
        m.removeOverlay(nolight)
        m.removeOverlay(totrans)
        face("left-up")
        storage._wait(1000)
        face("up-right")
        storage._wait(500)
        face("down")
        storage._wait(250)
        face("down-left")
        storage._wait(300)
        face("left")
        storage._wait(750)
        face("left-up")
        storage._wait(300)
        face("up")
        storage._wait(400)
        tr.write("My head hurts so badly. Everything's a blur...", 3)
        storage._wait(3000)
        ad.stop(SOUND, 3000, '24_amb_noise')
        storage._wait(3000)
        ad.play(MUSIC, 'bgm_2', VOLUME_MUSIC, -1, 2000)
        storage._setData('mirrorhall_murder_done', True)
        storage._toggleCutscene(False)
    
    storage._halt()
def init(storage, m):
    # If the scare hasn't been done yet and the player triggered
    # the abandoned room's canvas, this goes here
    storage._go()
    m.rendering_enabled = True
    if not storage._getData('lefthallway_scare_done') and\
       storage._getData('lefthallway_scare_enabled') and\
       not storage._getData('mirrorhall_murder_done'):
        
        # Scare
        storage._toggleCutscene(True)
        player = m.getPlayer()
        player.stopMoving()
        
        # Helper function for looking in a direction
        def face(direction):
            fl = m.getOverlay("_flashlight")
            fl.point(direction)
            player.setDirection(string_to_direction(direction))
            
        face("up")
        
        # Overlay creation
        ad = GlobalServices.getAudioDevice()
        fog = OverlayFactory.create("fog.png", pygame.BLEND_MULT)
        black = OverlayFactory.create_by_color((0, 0, 0), 0, 200)
        grad = OverlayFactory.create_animated_color((0,0,0),\
               3000, 0, True, 200, 0)
        
        ad.play(SOUND, '21_hole_loop', VOLUME_SOUND)
        ad.stop(MUSIC, 2000)
        ad.stop(SOUND, 2000, 'ambient_spooky')
        storage._wait(2000)
        
        # Show the figure
        ad.play(MUSIC, 'event1', VOLUME_MUSIC + 0.4)
        m.addOverlay(fog)
        shadow = m.getShadow()
        shadow.setPosition(conv_tile_pixel((41, 10), m))
        m.addOverlay(black)
        ad.play(SOUND, '27_spark1', VOLUME_SOUND)
        storage._wait(100)
        shadow.setVisible(True)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark2', VOLUME_SOUND)
        ad.play(SOUND, 'scare_wood_creak_scuf3', VOLUME_SOUND)
        shadow.moveBy((-30, 0), 2000)
        storage._wait(2000)
        shadow.moveBy((0, 1), 10)
        face("up-right")
        shadow.setVisible(False)
        storage._wait(250)
        face("up")
        storage._wait(100)
        shadow.setVisible(True)
        face("left-up")
        storage._wait(250)
        face("up")
        storage._wait(400)
        ad.play(SOUND, 'scare_wood_creak_walk2', VOLUME_SOUND)
        shadow.moveBy((0, -50), 4500)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark4', VOLUME_SOUND)
        storage._wait(300)
        shadow.setVisible(False)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark3', VOLUME_SOUND)
        storage._wait(200)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark4', VOLUME_SOUND)
        storage._wait(50)
        shadow.setVisible(True)
        m.removeOverlay(black)
        storage._wait(1450)
        ad.play(SOUND, 'general_chain_rattle2', VOLUME_SOUND)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark1', VOLUME_SOUND)
        storage._wait(100)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark2', VOLUME_SOUND)
        storage._wait(200)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark4', VOLUME_SOUND)
        storage._wait(50)
        shadow.setVisible(False)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark3', VOLUME_SOUND)
        storage._wait(390)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark1', VOLUME_SOUND)
        storage._wait(200)
        shadow.setVisible(True)
        m.removeOverlay(black)
        ad.play(SOUND, '27_spark2', VOLUME_SOUND)
        storage._wait(777)
        m.removeOverlay(fog)
        m.addOverlay(black)
        ad.play(SOUND, '27_spark4', VOLUME_SOUND)
        storage._wait(500)
        shadow.setVisible(False)
        m.addOverlay(grad)
        m.removeOverlay(black)
        m.removeOverlay(fog)
        ad.play(SOUND, '27_spark3', VOLUME_SOUND)
        storage._wait(3000)
        m.removeOverlay(grad)
        ad.play(MUSIC, 'bgm_1', VOLUME_MUSIC, -1)
        ad.play(SOUND, 'ambient_spooky', VOLUME_SOUND_AMBIENT, -1, 2000)
        storage._setData('lefthallway_scare_done', True)
        storage._toggleCutscene(False)
    storage._halt()
def ending(storage, m):
    storage._go()
    GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
    storage._toggleCutscene(True)
    storage._wait(3000)
    white = OverlayFactory.create("noise.png", pygame.BLEND_MULT)
    def static(ms):
        m.addOverlay(white)
        ad.play(SOUND, 'noise', VOLUME_SOUND + 0.1, -1)
        storage._wait(ms)
        m.removeOverlay(white)
        ad.stop(SOUND, 0, 'noise')
    tr = GlobalServices.getTextRenderer()
    ad = GlobalServices.getAudioDevice()
    tr.write("W-w-what am I supposed to do now?", 3)
    storage._wait(1400)
    static(340)
    storage._wait(1600)
    tr.write("I lose track of the sharp edges around me...", 3)
    storage._wait(2000)
    towhite = OverlayFactory.create_animated_color((255,255,255),\
              1000, 0, True, 0, 255)
    m.addOverlay(towhite)
    storage._wait(1500)
    player = m.getPlayer()
    player.setPosition(conv_tile_pixel((8,9), m))
    player.setAnimation("kneel")
    storage._wait(400)
    fadeout = OverlayFactory.create_animated_color((255,255,255),\
              1000, 0, True, 255, 0)
    m.addOverlay(fadeout)
    m.removeOverlay(towhite)
    storage._wait(3000)
    tr.write("Did I...", 3)
    player.setAnimation("walk")
    storage._wait(800)
    static(200)
    storage._wait(600)
    static(40)
    storage._wait(600)
    static(1000)
    storage._wait(2500)
    player.setDirection([0,-1])
    storage._wait(500)
    tr.write("It was... me..?", 3)
    storage._wait(1000)
    static(500)
    storage._wait(3000)
    static(100)
    storage._wait(1000)
    ad.play(SOUND, 'pick_item', VOLUME_SOUND)
    remove_from_map(get_savegame(), OBJECT, 'attic', 'gun')
    tr.write("I should...", 3)
    storage._wait(3000)
    toblack = OverlayFactory.create_animated_color((0,0,0), 2500, 0, True, 0, 255)
    m.addOverlay(toblack)
    ad.stop(SOUND, 2750, 'insanity_ear_ring')
    ad.stop(MUSIC, 2750)
    storage._wait(3500)
    ad.play(SOUND, 'gun_cock', VOLUME_SOUND)
    storage._wait(3500)
    storage._halt()
    rollCredits(storage, m)
def bed(storage, obj, m):
    storage._go()
        
    tr = GlobalServices.getTextRenderer()
    ad = GlobalServices.getAudioDevice()
    player = m.getPlayer()
    storage._faceObject(player, obj)
    
    if storage._playerInDistance(player.position, obj.rect):
        if storage._getData('bedroom_bedscare_done'):
            tr.write("There is no way I'll be able to sleep with this going on.", 3)
            
        elif storage._getData('entrancenote_obtained'):
            storage._toggleCutscene(True)
            GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
            tr.write("I am not imagining these things.", 3)
            storage._wait(3000)
            tr.write("...am I?", 3)
            storage._wait(3000)
            if storage._getData('leftwing_debrisfound'):
                tr.write("The blocked path in the Left Wing...", 3)
                storage._wait(3000)
                tr.write("I didn't put that stuff there.", 3)
                storage._wait(3000)
            storage._wait(1000)
            player.setDirection([1,0])
            tr.write("I need some sleep.", 3)
            storage._wait(3000)
            togray = OverlayFactory.create_animated_color((0,0,0), 4500, 0, True, 0, 255)
            m.addOverlay(togray)
            ad.stop(MUSIC, 4500)
            ad.stop(SOUND, 4500, 'vind2')
            ad.play(SOUND, 'ambient_spooky', VOLUME_SOUND_AMBIENT, -1, 4500)
            storage._wait(6000)
            
            starty = 200
            ofs = 18
            tr.write("When I think about it, I guess it's no wonder my friends turned on me.",\
                     0, COLOR_TEXT, (200, starty))
            storage._wait(4000)
            tr.write("After all, whenever one of them stayed overnight,",\
                     0, COLOR_TEXT, (200, starty + ofs))
            storage._wait(2000)
            tr.write("nothing weird ever happened the next morning.",\
                     0, COLOR_TEXT, (200, starty + (ofs * 2)))
            storage._wait(3000)
            tr.deleteAll()
            storage._wait(1000)
            starty = 214
            tr.write("I'm afraid.",\
                     0, COLOR_TEXT, (200, starty))
            storage._wait(4000)
            tr.write("Let's hope that I can settle this tomorrow.",\
                     0, COLOR_TEXT, (200, starty + ofs))
            storage._wait(1500)
            
            bed1 = os.path.join(PATH_GRAPHICS_TILES,'bed_clyde_eyesclosed.png')
            obj.changeImage(bed1)
            player.setVisible(False)
                        
            ad.play(SOUND, 'drone', VOLUME_SOUND)
            ad.play(SOUND, 'elec', VOLUME_SOUND)
            red = OverlayFactory.create_by_color((178, 10, 5), 0, 60)
            black = OverlayFactory.create_by_color((0, 0, 0), 0, 255)
            fog = OverlayFactory.create('fog.png', pygame.BLEND_MULT)
            add_global_overlay(fog)
            m.addOverlay(fog)
            tr.deleteAll()
            storage._wait(1500)
            ad.play(SOUND, 'insanity_bug3', VOLUME_SOUND_AMBIENT - 0.1, -1, 1500)
            m.removeOverlay(togray)
            storage._wait(400)
            ad.play(SOUND, 'general_thunder2', VOLUME_SOUND)
            ad.play(SOUND, 'insanity_monster_roar02', VOLUME_SOUND)
            storage._wait(400)
            ad.play(SOUND, '27_spark2', VOLUME_SOUND)
            m.addOverlay(red)
            m.addOverlay(black)
            storage._wait(300)
            
            
            ad.play(SOUND, '27_spark4', VOLUME_SOUND)
            m.removeOverlay(black)
            storage._wait(1000)
            m.removeOverlay(red)
            
            ad.play(SOUND, '27_spark2', VOLUME_SOUND)
            m.addOverlay(black)
            storage._wait(500)
            
            # Anderes Ich hier einfügen
            shadow = m.getShadow()
            shadow.setPosition(conv_tile_pixel((13, 15), m))
            shadow.setVisible(True)
            
            ad.play(SOUND, '27_spark4', VOLUME_SOUND)
            m.removeOverlay(black)
            storage._wait(300)
            
            bed2 = os.path.join(PATH_GRAPHICS_TILES,'bed_clyde_eyesopen.png')
            obj.changeImage(bed2)
            
            m.addOverlay(red)
            shadow.setVisible(False)
            for _ in range(3):
                ad.play(SOUND, '27_spark1', VOLUME_SOUND)
                m.addOverlay(black)
                storage._wait(750)
                m.removeOverlay(black)
                ad.play(SOUND, '27_spark3', VOLUME_SOUND)
                storage._wait(100)
            ad.play(MUSIC, 'bgm_1', VOLUME_MUSIC, -1)
            m.removeOverlay(red)
            grey = OverlayFactory.create_by_color((0, 0, 0), 0, 180)
            m.addOverlay(grey)
            ad.play(SOUND, '27_spark2', VOLUME_SOUND)
            storage._wait(100)
            ad.play(SOUND, '27_spark3', VOLUME_SOUND)
            ad.play(SOUND, 'insanity_monster_roar01', VOLUME_SOUND)
            
            obj.changeImage(None, True)
            
            player.setDirection([-1,1])
            player.setVisible(True)
            
            m.removeOverlay(black)
            storage._wait(2000)
            tr.write("What was that?!", 3)
            storage._wait(3000)
            ad.play(SOUND, 'scare_breath', VOLUME_SOUND)
            tr.write("Did it... happen again?", 3)
            storage._wait(3000)
            tr.write("The power's out completely now.", 3)
            storage._wait(4500)
            player.setDirection([-1,-1])
            tr.write("I better grab my flashlight from the table if I decide to go out.", 3)
            storage._wait(4000)
            tr.deleteAll()
            storage._wait(500)
            player.setDirection([-1,0])
            
            ad.play(SOUND, 'general_thunder2', VOLUME_SOUND)
            tr.write("Grab the flashlight and head out.", 5, COLOR_OBJECTIVE)
            tr.write("[Press F5 to save your progress.]", 3, COLOR_OBJECTIVE,\
                 (0, POSITION_BOTTOM_SCREEN[1]+20))
            # 'Toggled this cutscene' switch
            storage._setData('bedroom_bedscare_done', True)
            
            storage._toggleCutscene(False)
        else:
            tr.write("My bed used to be so comfortable. I don't sleep very well at the moment.", 5)
    else:
        tr.write("My bed. I can't reach it from here.", 3)
        
    storage._halt()
Exemplo n.º 11
0
def scare(storage, obj, m):
    storage._go()
    
    ad = GlobalServices.getAudioDevice()
    tr = GlobalServices.getTextRenderer()
    
    storage._toggleCutscene(True)
    
    # Force the flashlight to point to the right
    player = m.getPlayer()
    player.stopMoving()
    
    fl = m.getOverlay("_flashlight")
    # Helper function for looking in a direction
    def face(direction):
        fl.point(direction)
        player.setDirection(string_to_direction(direction))
        
    face("right")
    
    # Overlay creation
    red = OverlayFactory.create_by_color((170, 0, 0), 0, 50)
    black = OverlayFactory.create_by_color((0, 0, 0), 0, 210)
        
    # Show the figure
    ad.play(SOUND, 'scare_wood_creak_walk2', VOLUME_SOUND)
    ad.play(SOUND, '24_amb_noise', VOLUME_SOUND_AMBIENT, -1)
    shadow = m.getShadow()
    shadow.setPosition(conv_tile_pixel((43, 8), m))
    m.addOverlay(red)
    shadow.setVisible(True)
    shadow.moveBy((0, 100), 5000)
    
    storage._wait(1000)
    
    ad.stop(SOUND, 0, '24_amb_noise')
    ad.play(SOUND, '27_spark3', VOLUME_SOUND)
    ad.play(SOUND, 'scare_tingeling', VOLUME_SOUND, 0, 1000)
    m.addOverlay(black)
    m.removeOverlay(red)
    shadow.setVisible(False)
    shadow.setPosition(conv_tile_pixel((43, 14), m))
    
    storage._wait(2000)
    
    ad.play(SOUND, 'scare_wood_creak_walk3', VOLUME_SOUND)
    ad.play(SOUND, 'insanity_baby_cry2', VOLUME_SOUND)
    ad.play(SOUND, '27_orb_implode', VOLUME_SOUND)
    ad.play(SOUND, '24_amb_noise', VOLUME_SOUND_AMBIENT, -1)
    m.addOverlay(red)
    m.removeOverlay(black)
    shadow.setVisible(True)
    shadow.moveBy((-75, 0), 7500)
    
    storage._wait(2500)
    
    ad.stop(SOUND, 1750, '24_amb_noise')
    ad.play(SOUND, '27_spark4', VOLUME_SOUND)
    ad.play(SOUND, 'scare_male_terrified5', VOLUME_SOUND)
    m.addOverlay(black)
    m.removeOverlay(red)
    shadow.setVisible(False)
    
    add_to_map(get_savegame(), OBJECT, 'atrium', 'message',\
               pygame.Rect(conv_tile_pixel((29,7), m), conv_tile_pixel((8,4), m)),\
               'atrium_message', 'message_1.png', True)
    
    storage._wait(1000)
    
    m.removeOverlay(black)
    tr.write("What in the world was that thing?!", 2)
    face("left")
    storage._wait(250)
    face("up-right")
    storage._wait(250)
    face("right")
    storage._wait(100)
    face("right-down")
    storage._wait(250)
    face("right")
    storage._wait(1150)
    tr.write("Where did it go?", 2)
    storage._wait(2000)
    face("up")
    tr.write("Did it write... this?", 3)
    storage._wait(3000)
    face("right")
    
    m.removeObject(obj)
    storage._toggleCutscene(False)
    
    remove_from_map(get_savegame(), OBJECT, 'atrium', 'blockingshelf')
    storage._setData('atrium_scaredone', True)
    add_to_map(get_savegame(), OBJECT, 'atrium', 'blockingshelf',\
               pygame.Rect(conv_tile_pixel((11,25), m), conv_tile_pixel((2,8), m)),\
               'atrium_blockingshelf', 'bigshelf_right.png', True)
    
    storage._halt()