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()