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 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 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 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 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 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)
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 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 enterPipe(a: example.Wrap1): if not vars.paused and vars.currentWarp != -1: a.setState('pipe', {}) info = example.getById(vars.currentWarp).getInfo() s = Script() s.addAction(Move(speed=100, by=[0, -64], tag='player')) s.addAction(CallFunc(f=func.gotoWorld(info['world'], info['start']))) example.play(s)
def run_background_script(actor, a, b, c, d): s = Script(loop = 0) s.addAction (DelayRandom(min=a, max=b)) s.addAction (Animate(tag=actor, anim='idle_2', fwd = True, sync = True)) s.addAction (DelayRandom(min=c, max=d)) s.addAction (Animate(tag=actor, anim='idle_2', fwd = False, sync = True)) s.addAction (Animate(tag=actor, anim='idle_1', fwd = True, sync = True)) 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 koopaResponse (player : example.Wrap1, koopa : example.Wrap1, x, y): if koopa.getState() == 'hide': if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): player.vy = 300 koopa.move(-10 * x, 0, 0) left = 0 if (player.x() <koopa.x()) else 1 s = Script() s.addAction (act.SetState(state='walk2', id=koopa.id(), args = {'left': left})) example.play(s) else: if (player.getState() == "jump" and y > 0 and abs(x) < 0.01): player.vy = 300 s = Script() s.addAction (act.SetState(state='hide', id=koopa.id())) example.play(s) else: playerHitByEnemy(player)
def m3(x: float, y: float): a = spr('score100', x, y) main = example.get('main') id = main.add(a) s = Script() s.addAction(act.Move(speed=100, by=[0, 64], id=id)) s.addAction(act.RemoveEntity(id=id)) 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 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 citi3(): s = Script() s.addAction( RunScript( d3(sl, ['player', ('a', 11)], ['citizen', 'a:talk_e', ('_', 33), 'a:idle_e'])())) s.addAction(RunScript(citi_01())) return s
def f(): s = Script() s.addAction( RunScript( d3(sl, ['player', ('a', n)], ['citizen', 'a:talk_e', ('_', 29, 30, 31, 32), 'a:idle_e'])())) s.addAction(RunScript(citi_01())) return s
def playerDead(): s = Script() vars.state=0 s.addAction (act.SetState(state='dead', tag='player')) s.addAction (act.Delay(sec=1)) s.addAction (act.MoveAccelerated(v0 = [0 , 200], a= [0, vars.gravity], yStop= 0, tag='player')) s.addAction (act.RemoveEntity(tag = 'player')) s.addAction (act.CallFunc(f=restart)) example.play(s)
def f(): s = Script() for item in dialogue: print ('tag = ' + item[0]) ist = [dialogueId[a] for a in item[1:]] print ('tag = ' + str(ist)) s.addAction (Say(lines=ist, tag=item[0], font='monkey')) return s
def f(): vars.warp_func = None s = Script() s.addAction (act.SetState(tag='player', state='warp')) s.addAction (act.Move(speed=50, by =[0,-64], tag='player')) if newCamBounds: s.addAction (act.ChangeCamBounds('maincam', newCamBounds[0], newCamBounds[1], newCamBounds[2], newCamBounds[3])) s.addAction (act.Move(speed=0, to = [warpTo[0] * vars.tileSize, warpTo[1]*vars.tileSize], immediate= True, tag = 'player')) s.addAction (act.SetState(tag='player', state='walk')) example.play(s)
def f(): print('ciao' + itemId) s = Script() status = 'open' if open else 'closed' s.addAction(CallFunc(f=setvar(Data.items[itemId]['anim'], status))) # set corresponding variables #sv(Data.items[itemId]['anim'], status) print('set to ' + status) s.addAction(Animate(anim=status, tag=itemId)) return s
def goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y): if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): s = Script() player.vy = 300 s.addAction (act.SetState (state = 'dead', id = goomba.id )) s.addAction (act.Delay (sec = 2)) s.addAction (act.RemoveEntity (id=goomba.id)) example.play(s) else: playerHitByEnemy(player)
def gotoNext(p: example.Wrap1, k: example.Wrap1, x, y): #print (k.getInfo()) addInfo = k.getInfo()['info'] #print('world is ' + ['world']) example.remove(k.id) p.setActive(False) 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 f(player, hotspot): s = Script() s.addAction (act.SetState(tag='player', state='demo', args = { 'left': 0 })), s.addAction (act.Delay (sec=1)) s.addAction (act.SetState(tag='player', state='warp')) if newCamBounds: s.addAction (act.ChangeCamBounds('maincam', newCamBounds[0], newCamBounds[1], newCamBounds[2], newCamBounds[3])) s.addAction (act.Move(speed=0, to = [warpTo[0] * vars.tileSize, warpTo[1]*vars.tileSize], immediate= True, tag = 'player')) s.addAction (act.Move(speed=50, by =[0, 64], tag='player')) s.addAction (act.SetState(tag='player', state='walk')) example.play(s)
def m2(x: float, y: float): print ('x='+ str(x)) def score(): m3(x, y+1) a = Sprite ('flyingcoin', pos=[x * vars.tileSize, (y+1)*vars.tileSize, 0]) main = example.get('main') id = main.add(a) s = Script() s.addAction(MoveAccelerated(v0 = [0, 100], a = [0, -100], yStop = (y*vars.tileSize) +16, id = id)) s.addAction(RemoveEntity(id=id)) s.addAction(CallFunc(f = score)) example.play(s)
def koopaResponse (player : example.Wrap1, koopa : example.Wrap1, x, y): if koopa.getState() == 'hide': koopa.killScripts() if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): player.vy = 300 koopa.move(-10 * x, 0, 0) left = 0 if (player.x <koopa.x) else 1 s = Script() s.addAction (act.SetState(state='walk2', id=koopa.id, args = {'left': left})) koopa.play(s) else: if (player.getState() == "jump" and y > 0 and abs(x) < 0.01): player.vy = 300 s = Script() s.addAction (act.SetState(state='hide', id=koopa.id)) s.addAction (act.Delay(sec=2)) s.addAction (act.Blink(duration=2,blink_duration=0.2,id=koopa.id)) s.addAction (act.SetState(state='walk', id = koopa.id)) koopa.play(s) else: playerHitByEnemy(player)
def flag(p, h): p.vx = 0 p.vy = 0 example.remove(h.id()) flag = example.get('flag') s = Script() s.addAction(act.SetState (state = 'warp', tag='player', args = {'anim': 'slide'}), id = 0) s.addAction (act.Move (speed = 80, by = [0, -(flag.y()-h.y())], tag='flag'), after= [0]) s.addAction (act.Move (speed = 80, to = [p.x(), h.y()], tag='player'), after= [0]) s.addAction (act.SetState(tag='player', state='demo', args = { 'left': 0 })), #s.addAction (act.SetState (state='walk', tag='player')) example.play(s)
def downgradePlayer(): vars.state -= 1 if vars.state < 0: playerDead() else: vars.invincibility = True pl = example.get('player') pl.setModel(vars.stateInfo[vars.state]) s = Script() s.addAction (act.Blink (duration=5, blink_duration=0.2, id=pl.id)) s.addAction (act.CallFunc (f = resetInvincible)) example.play(s)
def goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y): if vars.invincibility: return print ('qui') if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): s = Script() player.vy = 300 s.addAction (act.SetState (state = 'dead', id = goomba.id() )) example.play(s) print ('ciao') else: playerHitByEnemy(player)
def talkToCitizen(): s = Script() s.addAction(EnableControls(False)) lines = ('_', 27, 28) if var.knows_map == 1 else (( '_', 1) if not var.talked_to_citizen else ('_', 8, 9)) s.addAction( RunScript( d3(st['dialogues']['citizen'], ['citizen', 'a:talk_s', lines, 'a:idle_s'])())) s.addAction(RunScript(ssc.startDialogue('citizen')())) var.talked_to_citizen = 1 return s