def use_meat_potostew(item1, item2): s = a.Scripts.use_base(item1, item2) # do whatever else u need to do s.add_action(actions.CallFunc(f=a.Callbacks.rm_from_inventory(item1))) s.add_action(actions.CallFunc(f=a.Callbacks.set_item_text(item2, '$objects/stewed_meat'))) s.add_action(actions.CallFunc(f=a.Callbacks.set_var('@meat_in_pot', True))) example.play(s)
def collide_with_kitchen_trap(): print('ciappo') s = Script() s.addAction(AddEntity(buildItem(id='seagull'), 'main')) s.addAction(Animate(anim='fly', tag='seagull', sync=True)) s.addAction(Animate(anim='eat', tag='seagull')) example.play(s)
def onstart_scummbar(): run_background_script('scummbar_pirate1', 1, 4, 1, 4) run_background_script('scummbar_pirate2', 1, 4, 1, 4) run_background_script('scummbar_mancomb', 1, 4, 0, 0) run_background_script("scummbar_pirate3", 1, 4, 0.5, 0.5) run_background_script("scummbar_pirate4", 1, 4, 0, 0) run_background_script("scummbar_pirate5", 1, 4, 1, 2) run_background_script("scummbar_pirate7", 1, 4, 1, 2) run_background_script("scummbar_pirate8", 1, 4, 0, 0) run_background_script("scummbar_pirate9", 1, 4, 0, 0) run_background_script("scummbar_estevan", 1, 4, 0, 0) run_background_script("scummbar_loom", 1, 4, 0, 0) # play the cook script if eng.previous_room != 'kitchen': s = Script (id = '_cook', loop= 0) s.addAction (Delay (sec = 10)) s.addAction (RunScript ( toggleDoor('scummbar_door_kitchen', True)() )) s.addAction (AddEntity (buildItem (id = 'cook'), 'walkarea')) s.addAction (Walk (tag ='cook', pos = [125, 17])) s.addAction (Turn (tag = 'cook', dir='n')) s.addAction (Delay (sec = 10)) s.addAction (Walk (tag = 'cook', pos = [589, 14])) s.addAction (RemoveEntity (tag='cook')) s.addAction (RunScript ( toggleDoor('scummbar_door_kitchen', False)() )) example.play(s)
def playerIsHit(player: example.Wrap1, foe: example.Wrap1, x, y): # decrease foe energy #info = player.getInfo() #info['energy'] -= 1 vars.energy -= 1 func.updateEnergy() if vars.energy <= 0: x = player.x() y = player.y() vars.lives -= 1 func.updateLives() example.remove(player.id()) s = Script() s.addAction(act.Delay(sec=1)) s.addAction(act.CallFunc(f=createPlayer(x, y))) s.addAction(act.CallFunc(f=restart)) example.play(s) else: player.setState('ishit', {}) vx = 200 if foe.x() < player.x() else -200 if player.flipx: vx *= -1 player.vx = vx print('ciao')
def pipe_out(p: example.Wrap1, k, x, y): p.setState('demo', {'left': 0}) add_info = k.getInfo()['info'] s = Script() s.add_action(act.Delay(0.5)) s.add_action(act.CallFunc(goto_world(add_info['world'], add_info['pos']))) example.play(s)
def on_exit_storekeeper(): s = Script() s.add_action(scumm.actions.ExitDialogue()) # resume script unless storekeeper is away if vars.items['storekeeper']['room'] == 'store': s.add_action(actions.ResumeScript(s='_storekeeper')) example.play(s)
def f(item_id, entity): s = Scripts.walk(item_id) s.add_action( actions.CallFunc( f=Callbacks.set_pos(vars.current_player, room, pos, dir))) s.add_action(actions.ChangeRoom(room=room)) example.play(s)
def f(): print('opening dialogue: ' + dialogueId) d: Dialogue = s.Data.dialogues[dialogueId] # check if this dialogue has an onstart script associated onStart = func.addCustomScript(engine.scripts.dialogues, 'onstart_' + dialogueId) if onStart: print('found script') example.play(onStart) d.reset() if d.onStart: d.onStart() lines = d.getLines() if lines: main: example.Wrap1 = example.get('main') ui: example.Wrap1 = example.get('ui') if ui.valid: ui.setActive(False) dial: example.Wrap1 = example.get('dialogue') dial.setActive(True) main.enableControls(False) # get the dialogue for line in lines: dial.appendText(line) else: # no lines, just exit dialogue return EndDialogue.pippo(dialogueId)()
def walkto(x, y, obj=None): #ds = example.getDeviceSize() #print('device size is ' + str(ds)) s = script.Script(id='_main') s.addAction(sa.Walk(pos=[x, y], tag='player')) example.play(s) print('clicked on ' + str(x) + ', ' + str(y))
def init_scummbar(): if mopy.monkey.engine.previous_room == 'kitchen': s = Script(loop=100, uid='cook') s.add_action( al.create_item('cook', { 'pos': (115, 18), 'dir': 'n' }, 'walkarea_0')) s.add_action(actions.Delay(sec=2)) s.add_action( actions.Walk( tag='cook', pos=mopy.monkey.engine.data.game.pos.scummbar_kitchen_door)) s.add_action(al.remove_item('cook')) s.add_action(al.close_door('door_scummbar_kitchen', 'kitchen')) cook_init_helper(s, 100) # # s.add_action(actions.CallFunc(f=a.Callbacks.add_item('cook', {'pos': (115, 18), 'parent': 'walkarea_0'}))) # s.add_action(scumm.actions.Turn(tag='cook', dir='n')) # s.add_action(actions.Delay(sec=2)) # s.add_action(scumm.actions.Walk(tag='cook', pos=vars.pos.scummbar_kitchen_door)) # s.add_action(actions.RemoveEntity(tag='cook')) # s.add_action(actions.Animate(tag='scummbar_kitchen_door', anim='closed')) example.play(s) else: s = Script(loop=0, uid='cook') cook_init_helper(s, 0) example.play(s) anim_helper('scummbar_mancomb') anim_helper('scummbar_estevan')
def setup_bar(): ra = mopy.monkey.engine.room_args gl = mopy.monkey.engine.data.globals bonus_left = Entity() bonus_left.model = gl.bonus_list[ra[0]]['gfx'] bonus_left.pos = (2.5*16, 10.2*16, 0.11) example.get('main').add(bonus_left) bonus_right = Entity() bonus_right.model = gl.bonus_list[ra[2]]['gfx'] bonus_right.pos = (9.5*16, 10.2*16, 0.11) example.get('main').add(bonus_right) from wbml.data.actions import WBM # check if player has enough gold to buy items min_cost = min(int(ra[1]), int(ra[3])) if gl.gold < min_cost: s = Script() s.seq([WBM('$msg/8'), act.ChangeRoom('citywl')]) example.play(s) else: mopy.monkey.engine.data.globals.pos = [(2, 7.625, 0.1), (5.25, 7.625, 0.1), (9.5, 7.625, 0.1)] mopy.monkey.engine.data.globals.cpos = 1 s = Script() s.seq([WBM('$msg/5')]) example.play(s)
def rise(): player = example.get('player') player.setState('warp', {}) s = Script() s.add_action(act.Move(speed=50, by=(0, 64), tag='player')) s.add_action(act.SetState(tag='player', state='walk')) example.play(s)
def play_flag_scene(player, obj, x, y): player.vy = 0 s = Script() s.add_action(act.SetState(tag='player', state='slide')) s.add_action(act.Move(tag='player', by=(0, obj.y - player.y), speed=50)) s.add_action(act.SetState(tag='player', state='npcwalk', args={'direction': 1})) example.play(s)
def fireHitsFoe(foe: example.Wrap1, fire: example.Wrap1, x, y): example.remove(fire.id) foe.setState ('dead2', {}) s = Script() s.addAction (MoveAccelerated(v0=[50 if fire.x < foe.x else -50, 150], a=[0,vars.gravity], yStop = -32, id=foe.id)) s.addAction (RemoveEntity (id=foe.id)) example.play(s)
def f(x, y, obj = None): dial = example.get('dialogue') dial.clearText() # check if there's any script to run a = Script() node = s node.said = True for cn in node.closeNodes: s.dialogue.nodes[cn].status = 2 for an in node.activateNodes: n = s.dialogue.nodes[an] if n.status != 2: n.status = 1 #for id, d in s.dialogue.nodes.items(): # print (str(d.id) + ' ' + str(d.active)) #if s.node.nextStatus != NodeStatus.SAME: # s.node.status = s.node.nextStatus #s.node.dialogue.openNode(s.node) # check if I have a script associated to this line func = s.dialogue.id + '_'+node.id print ('check if ' + func) addCustomScript (engine.scripts.dialogues, func, a) #ds = s.script() #if ds: # a.addAction(act.RunScript(s = ds)) if s.nextId == None: print ('ending') a.addAction(scact.EndDialogue(s.dialogue.id)) else: print ('next is ' + s.nextId) s.dialogue.current = s.nextId a.addAction(scact.ResumeDialogue(s.dialogue.id)) example.play(a)
def hand_select(): from wbml.data.actions import WBM gl = mopy.monkey.engine.data.globals selected = mopy.monkey.engine.data.globals.cpos s = Script() if selected == 1: s.seq([act.SetActive(tag='hand', value=False), WBM('$msg/6'), act.SetVariable('globals.start_position', 2), act.ChangeRoom('citywl')]) else: bonus_picked = None cost = 0 msg = None if selected == 0: bonus_picked = mopy.monkey.engine.room_args[0] cost = int(mopy.monkey.engine.room_args[1]) msg = mopy.monkey.engine.room_args[4] else: bonus_picked = mopy.monkey.engine.room_args[2] cost = int(mopy.monkey.engine.room_args[3]) msg = mopy.monkey.engine.room_args[5] if mopy.monkey.engine.data.globals.gold >= cost: mopy.monkey.engine.data.globals.gold -= cost bonus =gl.bonus_list[bonus_picked] bonus['callback']() s.seq([ act.SetActive(tag='hand', value=False), WBM(msg), act.SetVariable('globals.start_position', 2), act.ChangeRoom('citywl')]) example.play(s)
def on_load_swordmaster(): if example.get('storekeeper').valid: s = Script() s.add_action(a.custom_actions.disable_controls) s.add_action(a.custom_actions.set_follow(False), id=1) s.add_action(scumm.actions.Walk(tag='storekeeper', pos=(375, 68)), id=2) s.add_action(actions.Scroll(pos=(304, 72), cam='maincam', speed=50, relative=False), after=[1]) s.add_action(scumm.actions.Walk(tag='player', pos=(210, 14)), id=3, after=[1]) s.add_action(scumm.actions.Turn(tag='storekeeper', dir='e'), after=[2]) s.add_action(scumm.actions.Turn(tag='player', dir='s'), after=[3]) s.add_action( scumm.actions.Say(tag='player', font='monkey', lines=a.make_lines(['$lines/50']))) s.add_action(scumm.actions.Turn(tag='player', dir='n')) s.add_action(actions.Delay(sec=1.0), after=[2]) # TODO change room to sword master house here s.add_action(a.custom_actions.enable_controls) example.play(s)
def open_front_door(item_id, entity): if not status.front_door_open: a.Actions.say(['$lines/4'])(item_id, entity) else: s = a.Scripts.walk(item_id) s.add_action(actions.CallFunc(f=a.openDoor(item_id, 'open'))) example.play(s)
def init_flying_coin(id, x, y): s = Script() s.seq([ act.MoveAccelerated(v0=(0, 300), a=(0, -mopy.monkey.engine.data.globals.gravity), yStop=y+16, entity_id=id), act.RemoveEntity(entity_id=id), act.AddEntity(entity_id='entities.score_100', pos=[x/16, y/16+1, 1])]) example.play(s)
def end_level(player, warp, x, y): player.setActive(False) info = warp.getInfo() s = Script() s.add_action(act.Delay(sec=1)) s.add_action(act.SetVariable('globals.start_position', info['start_position'])) s.add_action(act.ChangeRoom(room=info['warp_to'])) example.play(s)
def warp_down(a): if data.globals.active_warp: s = Script() s.seq([ act.SetState(tag='player', state='warp'), act.Move(speed=50, by=(0, -64), tag='player'), act.ChangeRoom(data.globals.active_warp)]) example.play(s)
def makePiece(pos, vx, vy, model, parent : example.Wrap1): a = Sprite(model = model, pos = pos) id = parent.add(a) s = Script() s.addAction (act.MoveAccelerated (id = id, v0 = [vx, vy], a = [0, 0.5*vars.gravity], yStop=0)) s.addAction (act.RemoveEntity (id = id)) # type = action.remove_object, args = { id = id1} example.play(s)
def m3(x: float, y: float): a = Sprite('score100', pos=[x * vars.tileSize, (y + 1) * vars.tileSize, 0]) main = example.get('main') id = main.add(a) s = Script() s.addAction(Move(speed=100, by=[0, 64], id=id)) s.addAction(RemoveEntity(id=id)) example.play(s)
def on_kitchen_trap(player, entity, x, y): example.remove(entity.id) s = Script() s.add_action(al.create_item('seagull')) s.add_action(actions.Animate(tag='seagull', anim='fly', sync=True)) s.add_action(actions.Animate(tag='seagull', anim='eat')) s.add_action(actions.SetVariable("game.seagull_on_plank", True)) example.play(s)
def f(item_id, entity): print('HEY item = ' + item_id) s = Scripts.walk(item_id) if item_id else Script() s.add_action( actions.CallFunc( f=Callbacks.set_pos(data.current_player, room, pos, dir))) s.add_action(actions.ChangeRoom(room=room)) example.play(s)
def pipe_out(p: example.Wrap1, k, x, y): p.setState('demo', {'left': 0}) addInfo = k.getInfo()['info'] s = Script() from smb_py.funcs import gotoWorld s.addAction(Delay(sec=0.5)) s.addAction(CallFunc(gotoWorld(addInfo['world'], addInfo['pos']))) example.play(s)
def m1(x: float, y: float): a = mushroom(x, y) main = example.get('main') id = main.add(a) s = Script() s.addAction(Move(id=id, speed=10, by=[0, 16])) s.addAction(SetState(id=id, state='walk')) example.play(s)
def seagull_lands(): s = Script() if 'fish' in mopy.monkey.engine.data.globals.inventory: s.add_action(actions.Animate(tag='seagull', anim='leave', sync=True)) s.add_action(al.remove_item('seagull')) else: s.add_action(actions.Animate(tag='seagull', anim='eat')) example.play(s)
def cippo(): print('ciappo') example.get('w1').setActive(False) s = Script() s.addAction(SetState(tag='player', state='pipe')) s.addAction(Move(tag='player', speed=50, by=[0, 64])) s.addAction(SetState(tag='player', state='walk')) example.play(s)
def winSlide(p: example.Wrap1, k, x, y): example.remove(k.id) p.setState('slide', {}) s = Script() p.vy = 0 s.addAction(Move(speed=50, to=[p.x, 48], tag='player')) s.addAction(SetState(tag='player', state='demo', args={'left': 0})) example.play(s)