Advertisement
Guest User

Fixed system.rb (WTFPL)

a guest
Sep 11th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 50.66 KB | None | 0 0
  1. def events(id)
  2.   case id
  3.     when 'i1'
  4.     if @start
  5.       Song.current_song.stop if Song.current_song
  6.       @player.ignore=true
  7.       @temp[0]=Message.new("Toad","Toad","Mario, wake up!^^(NOTE: Hold Jump key to speed up^message or press Spin to skip)")
  8.       @map.modify_mask(0,0,:splice,'Backgrounds/MI-mask')
  9.       @temp[3]=120
  10.     end
  11.     if !@temp[1]
  12.       $screen.draw_quad(0,0,c=0xff000000,640,0,c,640,480,c,0,480,c,3.9)
  13.       if @temp[0].closed
  14.         Snd['Jump1'].play
  15.         @player.vx=@player.vy=-6
  16.         @temp[1]=true
  17.       end
  18.     elsif !@temp[2] and @player.vx.to_i==0 and @player.down
  19.       Message.new("Mario","Mario","What? Peach is again in^danger?")
  20.       @temp[2]=Message.new("Toad","Toad","No. Come outside. You^have to see this.")
  21.     end
  22.     if !@temp[2] or !@temp[2].closed
  23.       Img['Objects/Toad'].draw(@temp[3],339,1)
  24.     else
  25.       Tls['Objects/Toadwalk',32,54][[0,1,2,1][$count/8%4]].draw(@temp[3]+32,339,1,-1)
  26.       @temp[3]-=4
  27.       @player.vx=-4
  28.     end
  29.     if @player.x<0
  30.       reset('i2')
  31.       @player.x,@player.y=360,325
  32.       @player.vx=2
  33.       @map.modify_mask(0,0,:splice,'Backgrounds/MH-mask')
  34.       # @map.modify_mask(304,349,:rect,[180,32,0xff000000])
  35.       # @map.modify_mask(340,384,:rect,[240,96,0xff000000])
  36.     end
  37.    
  38.     when 'i2'
  39.     @temp[0]=Message.new("Mario","Mario","What is this?") if !@temp[0] and @player.vx.to_i==0
  40.     if @temp[0] and @temp[0].closed and @player.x<540
  41.       @player.vx=4
  42.     elsif @temp[0] and @temp[0].closed and !@temp[1] and @player.vx.to_i==0
  43.       @player.mammamia
  44.       Snd['MarioDamage4'].play
  45.       @temp[1]=Message.new("Mario","Mario","WHAT IS BOWSER'S CASTLE^DOING AT MY PLACE?!")
  46.     elsif @temp[1] and @temp[1].closed and !@temp[2]
  47.       @player.demammamia
  48.       @temp[2]=0
  49.     elsif @temp[2] and @temp[2]==120 and !@temp[3]
  50.       Message.new("Toad","Toad","Don't you think it's too^big for Bowser's?^We've sent an expedition,^nobody yet returned.")
  51.       Message.new("Mario","Mario","But Peach is not there?")
  52.       Message.new("Toad","Toad","No, she's safe in another castle.^But anyway you should go.")
  53.       @temp[3]=Message.new("Mario","Mario","Right. I'll make some^exploration.")
  54.     elsif @temp[3] and @temp[3].closed
  55.       @player.vx=4
  56.       if @player.x>640
  57.         reset(0)
  58.         @player.x=0
  59.         @player.y=1288
  60.         # @player.y+=928
  61.       end
  62.     end
  63.      
  64.     Img['Backgrounds/Castle at home'].draw(0,0,3) if @temp[2] and (@temp[2]+=1)<120
  65.     Img['Objects/Toad'].draw(600,330,1)
  66.    
  67.     when 0
  68.     if !$save[:events][3]
  69.       if @player.x<300
  70.         @player.vx=4
  71.       else
  72.         Gate.new
  73.         $save[:events][3]=true
  74.       end
  75.     elsif @start
  76.       Gate.new(true)
  77.     end
  78.    
  79.     when 1
  80.     if !$save[:areas][0]
  81.       @area=["Castle's Entrance",120]
  82.       $save[:areas]<<0
  83.       @map.music 0
  84.     end
  85.    
  86.     when 3
  87.     if !$save[:events][4]
  88.       if @start
  89.         @temp[0]=800
  90.         @entities[1].each{|ent| ent.remove}
  91.       end
  92.       if @player.x>600 and !@temp[1]
  93.         @player.ignore=true
  94.         @player.vx=2
  95.         Message.new("Toad","Toad2","Oh, it's you Mario!^We have a big problem. It's not^Bowser's castle. This place is^called Castlevania and it's a^property of Count Dracula,")
  96.         Message.new("Toad","Toad2","the Lord of Darkness.^But it also appears to be^controled by Bowser.")
  97.         Message.new("Mario","Mario","This Bowser starts to really^annoy me!")
  98.         Message.new("Toad","Toad2","Anyway, I made small exploration.^Take the map from box,^it may help you.")
  99.         @temp[1]=Message.new("Mario","Mario","Thanks.")
  100.       end
  101.       Img['Objects/Toad2'].draw(@temp[0]+32-@scx,394,2,-1) if !@temp[1] or !@temp[1].closed
  102.       if @temp[1] and @temp[1].closed
  103.         @temp[0]+=4
  104.         @player.ignore=nil
  105.         $save[:events][4]=true
  106.       end
  107.     end
  108.     if @temp[0] and @temp[1] and @temp[1].closed
  109.       Tls['Objects/Toadwalk2',32,54][[0,1,2,1][$count/8%4]].draw(@temp[0]-@scx,394,2)
  110.       @temp[0]+=4
  111.     end
  112.    
  113.     when 5
  114.     if @start
  115.       ary=[]
  116.       6.times{|y| ary << [160,192+y*32,'Wall',2]}
  117.       QSwitch.new(192,480,2,false,ary)
  118.     end
  119.    
  120.     when 6
  121.     BossDoor.new(2528,320) if @start and !$save[:events][0]
  122.    
  123.     when 7
  124.     if @start and !$save[:events][0] || $bossrush
  125.       BossDoor.new(0,320,true)
  126.       BossDoor.new(608,320,true)
  127.       Msc['Confrontation',true].play
  128.       @temp[0]=BBB.new(512,308)
  129.     end
  130.     $save[:events][0]=true if @temp[0] and @temp[0].dead?
  131.    
  132.     when 10
  133.     if @start
  134.       ary=[]
  135.       6.times{|y| ary << [1376,352+y*32+y/3*32,'Wood',[4,8,12,8,12,16][y]]}
  136.       QSwitch.new(1440,192,16,true,ary)
  137.     end
  138.    
  139.     when 16
  140.     if  !$save[:events][1] and $game.player.x>640 and $save[:equip][1]==0 || $save[:items][:magic].include?(0) and !@temp[0]
  141.       @temp[0]=[BossDoor.new(0,288,true),BossDoor.new(1248,288,true)]
  142.       Msc['Fight Against Monsters',true].play
  143.       Spawner.new(64,96,10,30,[:goomba]*20)
  144.       Spawner.new(1184,96,10,30,[:goomba]*20)
  145.       Spawner.new(320,96,5,30,[:gktroopa]*10)
  146.       Spawner.new(864,96,5,30,[:gktroopa]*10)
  147.       Spawner.new(192,96,5,30,[:spiny]*15)
  148.       Spawner.new(992,96,5,30,[:spiny]*15)
  149.     end
  150.     if @temp[0] and !$game.entities[0].find{|ent| ent.class==Spawner}
  151.       @temp[0].each{|door| door.open=true}
  152.       @temp[0]=nil
  153.       @map.music(1)
  154.       $save[:events][1]=true
  155.     end
  156.    
  157.     when 18
  158.     NPC.new(160,330,'Toad3') if @start
  159.     if !$save[:events][5] and @player.x<320 and !@temp[0]
  160.       @player.ignore=true
  161.       @player.vx=-2
  162.       Message.new("Toad","Toad3","Hi Mario! Wanna shoppin'?")
  163.       Message.new("Mario","Mario","What? You made a shop in the^castle?")
  164.       Message.new("Toad","Toad3","You're going to explore it longer,^so I may have a good income.^Also, I found an interesting map.^Of course it's not free.")
  165.       @temp[0]=Message.new("Mario","Mario","I'll check what you have.")
  166.     elsif @temp[0] and @temp[0].closed
  167.       $save[:events][5]=true
  168.       @player.ignore=nil
  169.     end
  170.     if !$save[:events][34] and $save[:enemies][87] and @player.x<320 and !@temp[1]
  171.       @player.ignore=true
  172.       @player.vx=-2
  173.       Message.new("Toad","Toad3","Hi again Mario!^There's something I must tell^you!")
  174.       Message.new("Mario","Mario","What is it, Toad?")
  175.       Message.new("Toad","Toad3","I've seen a Goomba made of gold!^He must be insanely valuable!")
  176.       Message.new("Mario","Mario","Interesting, I've never seen a^golden Goomba.^Where was it?")
  177.       Message.new("Toad","Toad3","In Goomba halls.")
  178.       @temp[1]=Message.new("Mario","Mario","Right, I will go there later.")
  179.     elsif @temp[1] and @temp[1].closed
  180.       $save[:events][34]=true
  181.       @player.ignore=nil
  182.     end
  183.    
  184.     Img["Objects/Shop"].draw(200,384-23,1)
  185.     Img["Objects/Shop2"].draw(390,384-8,1) if $save[:events][6]
  186.     Img["Objects/Shop3"].draw(410,384-20,1) if $save[:events][7]
  187.     Img["Objects/Shop4"].draw(320,384-29,1) if $save[:events][10]
  188.     Img["Objects/Shop5"].draw(436,384-17,1) if $save[:events][23]
  189.     Img["Objects/Shop6"].draw(300,384-33,1) if $save[:events][14]
  190.     Img["Objects/Shop7"].draw(520,384-17,1) if $save[:enemies][94] and $save[:enemies][94][0]
  191.     Img["Objects/Shop8"].draw(580,384-17,1) if $save[:cores].length>0
  192.    
  193.     when 23
  194.     if $save[:cores].length<13
  195.       @map.modify_mask(256,864,:rect,[160,160,0xff000000]) if @start
  196.       $screen.clip_to(240,320,160,160){2.times{|x| Img['Objects/ChaosGate'].draw(240-x*160+$count%160-$game.scx,800-$game.scy,1.8)}}
  197.     end
  198.    
  199.     when 37
  200.     BossDoor.new(608,768) if @start and !$save[:events][6]
  201.    
  202.     when 38
  203.     if @start and !$save[:events][6] || $bossrush
  204.       BossDoor.new(0,288,true)
  205.       BossDoor.new(608,288,true)
  206.       Msc['Boss A',true].play
  207.       @entities[1].each{|ent| ent.remove}
  208.       @temp[0]=Unagi.new
  209.     end
  210.     $save[:events][6]=true if @temp[0] and @temp[0].dead?
  211.    
  212.     when 67,150,152,183,187,188,186,185,151
  213.     r=rand(2)
  214.     r=1 if @player.x<@scx+100
  215.     r=0 if @player.x>@scx+540
  216.     Eerie.new([@scx-44,@scx+638][r],@scy+rand(454),[:right,:left][r]) if @time%120==0
  217.     Eerie.new([@scx-44,@scx+638][r],@scy+rand(454),[:right,:left][r]) if @time%120==0 and rand(8)==0
  218.     Eerie.new([@scx-44,@scx+638][r],@scy+rand(454),[:right,:left][r]) if @time%120==0 and rand(16)==0
  219.    
  220.     when 71
  221.     # Bobomb.new(1152,-32,:right,true) if @time%240==0
  222.     Crate.new(1120,-96,1+rand(3)) if @time%600==60
  223.    
  224.     when 76
  225.     BossDoor.new(1248,224) if @start and !$save[:events][7]
  226.    
  227.     when 77
  228.     if @start and !$save[:events][7] || $bossrush
  229.       BossDoor.new(0,224,true)
  230.       BossDoor.new(1248,224,true)
  231.       Msc['Boss A',true].play
  232.       @entities[1].each{|ent| ent.remove}
  233.       @temp[0]=PUltimatus.new
  234.     end
  235.     $save[:events][7]=true if @temp[0] and @temp[0].dead?
  236.    
  237.     when 83
  238.     3.times{|x| 2.times{|y| $game[Tile.new(x*32,1248+y*32,"Sewers",(x==2 ? 9 : 8))]}} if @start and !$save[:items][:misc].include? 3
  239.    
  240.     when 89
  241.     $save[:area]=1
  242.     @map.music(1) if @start
  243.    
  244.     if  !$save[:events][10] and $game.player.x<640 and !@temp[0]
  245.       @temp[0]=[BossDoor.new(1056,672,true),BossDoor.new(320,672,true)]
  246.       Msc['Fight Against Monsters',true].play
  247.       temp=[]
  248.       temp<<Spawner.new(592,720,1,60,["iplant0"]*5+["venus0"]*5)
  249.       temp<<Spawner.new(656,592,1,60,["venus0"]*5+["mplant0"]*5+["hplant0"])
  250.       temp<<Spawner.new(720,656,1,60,["iplant0"]*5+["mplant0"]*5)
  251.       temp<<Spawner.new(352,528,1,60,["venus1"]*5+["iplant1"]*5)
  252.       temp<<Spawner.new(1008,592,1,60,["mplant3"]*5+["iplant3"]*5)
  253.       Spawner.new(1056,192,5,30,[:vspiny]*15,temp)
  254.       Spawner.new(320,192,5,30,[:vspiny]*15,temp)
  255.       Spawner.new(1024,451,1,180,[:sniper]*2)
  256.     end
  257.     if @temp[0] and !$game.entities[0].find{|ent| ent.class==Spawner}
  258.       @temp[0].each{|door| door.open=true}
  259.       @temp[0]=nil
  260.       @map.music(1)
  261.       $save[:events][10]=true
  262.     end
  263.    
  264.     when 90
  265.     $save[:area]=8
  266.     @map.music(8) if @start
  267.     if !$save[:areas].include?(8)
  268.       @area=[areas[8],120]
  269.       $save[:areas] << 8
  270.     end
  271.    
  272.     when 91
  273.     BossDoor.new(0,352) if @start and !$save[:events][15]
  274.    
  275.     when 92
  276.     if !$save[:events][8]
  277.       if @start
  278.         @entities[1].each{|ent| ent.remove}
  279.         @temp[0]=Luigi.new(400,726)
  280.       end
  281.      
  282.       if @player.x>240 and !@temp[4]
  283.         @player.vx=2
  284.         Message.new("Luigi","Luigi","That's why this place is called^'skyfall'. I know it's^probably an illusion, but^makes me sick anyway.")
  285.         @temp[2]=Message.new("Mario","Mario","Luigi? What are you doing here?")
  286.         Message.new("Luigi","Luigi","You thought you'll be a hero^again and take all the glory?^I came to take care of Bowser,^so go home.")
  287.         Message.new("Mario","Mario","What are you talking about?^That's our job to protect the^Mushroom Kingdom! We can do it^together as always.")
  288.         @temp[3]=Message.new("Luigi","Luigi","As always? And you will take the^Peach for you and I will be^forever alone. Just assistant^to the great hero. Whole life in^your shadow.")
  289.         @temp[4]=Message.new("Mario","Mario","Luigi, stop!^Oh, that's too bad. Where I made^a mistake?")
  290.       elsif @temp[2] and @temp[2].closed and !@temp[3].closed
  291.         @temp[0].model.mirror_x=true
  292.       elsif @temp[3] and @temp[3].closed
  293.         @temp[0].vx=4
  294.         $save[:events][8]=true if @temp[4].closed
  295.       end
  296.     end
  297.    
  298.     when 95
  299.     if @start and !$save[:events][19]
  300.       @entities[1].each{|ent| ent.remove}
  301.       @temp[0]=96
  302.     end
  303.     if !$save[:events][19] and @player.x<320 and !@temp[1]
  304.       @player.vx=-2
  305.       Message.new("Toad","Toad4","Hey Mario!")
  306.       Message.new("Mario","Mario","Oh, haven't you seen Luigi?^We met and he seemed weird.")
  307.       Message.new("Toad","Toad4","Luigi? Maybe we missed each^other. But, I made an important^discovery.")
  308.       Message.new("Toad","Toad4","Dracula's true power is sealed^by Bowser somewhere in the cast-^le. And if you want to get rid of^the castle, you need to release^it.")
  309.       Message.new("Mario","Mario","Isn't it dangerous?")
  310.       Message.new("Toad","Toad4","It is. After unsealing it, you^need to defeat Bowser to resur-^rect Dracula. And if you defeat^Dracula, the castle will vanish^from Mushroom Kingdom.")
  311.       Message.new("Mario","Mario","But first, I need to find the^seals.")
  312.       Message.new("Toad","Toad4","It shouldn't be to hard. Defea-^ting Dracula will be much worse.^Anyway, good luck. I'm on my way.")
  313.       @temp[1]=Message.new("Mario","Mario","See ya.")
  314.     elsif @temp[1] and @temp[1].closed
  315.       @temp[0]+=4
  316.       !$save[:events][19]=true
  317.     end
  318.     if @temp[0] and not @temp[1] && @temp[1].closed
  319.       Img['Objects/Toad4'].draw(@temp[0]-@scx,746-@scy,1)
  320.     elsif @temp[0]
  321.       Tls['Objects/Toadwalk4',32,54][[0,1,2,1][$count/8%4]].draw(@temp[0]-@scx,746-@scy,1)
  322.     end
  323.    
  324.     when 105
  325.     Bobomb.new(1312,-32,:right,true) if @time%120==0
  326.     Bobomb.new(3392,-32,:left,true) if @time%120==0
  327.     Crate.new(1280,-128,1+rand(4)) if @time%240==60
  328.     Crate.new(3328,-128,1+rand(4)) if @time%240==60
  329.    
  330.     when 106
  331.     BossDoor.new(0,672) if @start and !$save[:events][9]
  332.    
  333.     when 107
  334.     if !@temp[0] and !$save[:events][9] || $bossrush and @player.x<1168
  335.       Song.current_song.stop
  336.       $premusic=nil
  337.       BossDoor.new(1184,192,true)
  338.       BossDoor.new(1184,672,true)
  339.       @temp[0]=true
  340.     elsif @temp[0] and !@temp[1] and @player.x.between?(600,680)
  341.       Msc['Confrontation',true].play
  342.       @temp[1]=true
  343.       Destroyer.new
  344.     end
  345.    
  346.     when 109
  347.     2.times{|x| Crate.new(576+x*256,-128,4)} if @time%60==0
  348.     3.times{|x| Crate.new(448+x*256,-128,4)} if @time%60==30
  349.    
  350.     when 110
  351.     Bobomb.new(864,-32,:left,true) if @time%180==0
  352.     Crate.new(832,-128,1+rand(4)) if @time%300==60
  353.    
  354.     when 116
  355.     r=(@player.x<@scx+320 ? 1 : 0)
  356.     Stoney.new([@scx-44,@scx+638][r],@scy+rand(454),[:right,:left][r],false) if @time%120==0
  357.    
  358.     when 117,118,128
  359.     r=(@player.x<@scx+320 ? 1 : 0)
  360.     Stoney.new([@scx-44,@scx+638][r],@scy+rand(454),[:right,:left][r],rand(5)==0) if @time%120==0
  361.    
  362.     when 132,134
  363.     r=(@player.x<@scx+320 ? 1 : 0)
  364.     Stoney.new([@scx-44,@scx+638][r],@scy+rand(454),[:right,:left][r],rand(5)<3) if @time%120==0 and id==134 || @scy<1536
  365.    
  366.     when 124
  367.     QSwitch.new(992,608,12,nil,[]) if @start
  368.     QSwitch.new(0,0,11,false,[[992,576,"Wood",15]]) if @start
  369.    
  370.     when 125
  371.     QSwitch.new(0,0,13,false,[[832,352,"Wood",0],[864,352,"Wood",1],[896,352,"Wood",2],[928,352,"Wood",3]]) if @start
  372.    
  373.     when 126
  374.     QSwitch.new(1088,352,13,nil,[]) if @start
  375.     QSwitch.new(0,0,12,false,[[1024,384,"Wood",15],[960,320,"Wood",15],[992,352,"Wood",15]]) if @start
  376.    
  377.     when 127
  378.     QSwitch.new(1472,288,11,nil,[]) if @start
  379.    
  380.     when 135
  381.     BossDoor.new(0,224) if @start and !$save[:events][14]
  382.    
  383.     when 136
  384.     $game[Background.new(455,64,"Clock")] if @start
  385.     if @start and !$save[:events][14] || $bossrush
  386.       BossDoor.new(0,224,true)
  387.       BossDoor.new(1248,224,true)
  388.       Song.current_song.stop
  389.       $premusic=nil
  390.     end
  391.     if @player.x<640 and !@temp[0] and !$save[:events][14] || $bossrush
  392.       @temp[0]=Death.new
  393.     end
  394.    
  395.     Tls['Objects/Pointer',42,302][0].draw_rot(640-@scx,240,1,Time.new.min*6,0.5,0.735)
  396.     Tls['Objects/Pointer',42,302][1].draw_rot(640-@scx,240,1,Time.new.hour*15,0.5,0.735)
  397.    
  398.     when 139
  399.     $save[:area]=10
  400.     @map.music(10) if @start
  401.    
  402.     when 140
  403.     $save[:area]=11
  404.     @map.music(11) if @start
  405.     if !$save[:areas].include?(11)
  406.       @area=[areas[11],120]
  407.       $save[:areas] << 11
  408.     end
  409.    
  410.     when 141
  411.     if @start
  412.       $save[:events][35]=false if !$save[:events][36]
  413.       ary=[]
  414.       8.times{|y| ary << [320,1120+y*32,'Corridor',20]}
  415.       @temp[0]=QSwitch.new(128,256,35,false,ary)
  416.       @temp[1]=0
  417.      
  418.       QSwitch.new(416,1344,36,false,[])
  419.     end
  420.    
  421.     if $save[:events][35] and !$save[:events][36]
  422.       @temp[1]+=1
  423.       Snd["Tick"].play if @temp[1]%20==0
  424.       Snd["Tick"].play if @temp[1]%20==10
  425.       if @temp[1]==140
  426.         Snd['Deswitch'].play
  427.         @temp[1]=0
  428.         ary=[]
  429.         8.times{|y| ary << [320,1120+y*32,'Corridor',20]}
  430.         @temp[0].remove
  431.         $save[:events][35]=false
  432.         @temp[0]=QSwitch.new(128,256,35,false,ary)
  433.       end
  434.     elsif $save[:events][36] and !$save[:events][35]
  435.       @temp[0].press
  436.     end
  437.    
  438.     when 142
  439.     if @start and !$save[:events][21]
  440.       @entities[1].each{|ent| ent.remove}
  441.     end
  442.     if !$save[:events][21] and @player.x>1300 and !@temp[0]
  443.       Song.current_song.stop
  444.       $premusic=nil
  445.       @player.ignore=true
  446.       @player.vx=2
  447.       Message.new("Mario","Mario","Peach? What are you doing here?")
  448.       Message.new("Peach","Peach","Oh, Mario! Glad you are here.^I got lost, can you guide me to^exit?")
  449.       @temp[0]=Message.new("Mario","Mario","Ugh, I think I can.")
  450.     elsif @temp[0] and @temp[0].closed and !@temp[1]
  451.       Snd['Bowsa'].play
  452.       Snd['MarioDamage4'].play
  453.       @player.mammamia
  454.       @temp[1]=0
  455.     elsif @temp[1] and @temp[1]<90
  456.       @temp[1]+=1
  457.       Img['Effects/Teleport'].draw_rot(1528-@scx,192-@scy,3,0,0.5,0.5,offset_x(@temp[1]*2,5),12,Color.new(offset_x(@temp[1]*2,255).to_i,255,255,255))
  458.     elsif @temp[1] and !@temp[2]
  459.       @player.demammamia
  460.       Message.new("Bowser","Bowser","No, you can't.^Gwahahaha!")
  461.       Message.new("Mario","Mario","Bowser! Stay away of her!")
  462.       Message.new("Bowser","Bowser","Poor Mario, you still think^I kidnap her all the time? As^you see, she comes to^me on her own.")
  463.       @temp[5]=Message.new("Mario","Mario","What the...?!")
  464.       Message.new("Peach","Peach","Don't believe him! It's Bowser,^you know...")
  465.       Message.new("Bowser","Bowser","Gwahahaha! You're mine now!")
  466.       Message.new("Peach","Peach","Mario! Help!")
  467.       Message.new("Mario","Mario","Get your filthy hands off Peach,^Bowser!")
  468.       @temp[2]=Message.new("Bowser","Bowser","We meet in throne room.^Remember also to play with your^brother. Gwahahaha!")
  469.     elsif @temp[2] and @temp[2].closed and !@temp[3]
  470.       Snd['Bowsa'].play
  471.       Snd['Bowser Hahaha'].play
  472.       Snd['PeachScream'].play
  473.       @temp[3]=0
  474.     elsif @temp[3] and @temp[3]<90
  475.       @temp[3]+=1
  476.       Img['Effects/Teleport'].draw_rot(1528-@scx,192-@scy,3,0,0.5,0.5,offset_x(@temp[3]*2,8),12,Color.new(offset_x(@temp[3]*2,255).to_i,255,255,255))
  477.     elsif @temp[3] and !@temp[4]
  478.       Message.new("Mario","Mario","Nooo! That Bowser... The^teleportation... He grew strong.^Is this Dracula's power?")
  479.       @temp[4]=Message.new("Mario","Mario","Ohh, Peach...")
  480.       @player.ignore=false
  481.     elsif @temp[4] and @temp[4].closed
  482.       $save[:events][21]=true
  483.     end
  484.    
  485.     if !$save[:events][21]
  486.       if @temp[1] and !@temp[5] || !@temp[5].closed
  487.         frame=1
  488.         dir=:right
  489.       else
  490.         frame=0
  491.         dir=:left
  492.       end
  493.       Tls['Objects/Peach',32,78][frame].draw(1450-@scx+(dir==:right ? 32 : 0),306-@scy,2,dir==:right ? -1 : 1) if not @temp[3] && @temp[3]>=45
  494.       Tls['Enemies/Bowser',96,120][0].draw(1576-@scx,264-@scy,2,-1) if @temp[1] and @temp[1]>=45 and not @temp[3] && @temp[3]>=45 ##do poprawy
  495.     end
  496.    
  497.     when 143
  498.     @map.music 12 if @start and !Song.current_song
  499.    
  500.     when 156
  501.     if @start and !$save[:events][20]
  502.       @entities[1].each{|ent| ent.remove}
  503.       @temp[0]=1280
  504.     end
  505.     if !$save[:events][20] and @player.x<1600 and !@temp[1]
  506.       @player.vx=-2
  507.       Message.new("Toad","Toad4","Oh, hi again! I made a small re-^search on these teleport pipes.^As you noticed, they allow you^to move across the castle with^speed of light.")
  508.       Message.new("Toad","Toad4","But moreover, they cause a^distortion in space around them.")
  509.       Message.new("Mario","Mario","So, what exactly it is?")
  510.       Message.new("Toad","Toad4","It's a tunnel to parrarel dimen-^sion. Well, theoretically. I have^no idea if it's even possible to^to enter there.")
  511.       Message.new("Mario","Mario","Nah, so I don't even bother.")
  512.       @temp[1]=Message.new("Toad","Toad4","Anyway, see you later.")
  513.     elsif @temp[1] and @temp[1].closed
  514.       @temp[0]+=4
  515.       !$save[:events][20]=true
  516.     end
  517.     if @temp[0] and not @temp[1] && @temp[1].closed
  518.       Img['Objects/Toad4'].draw(@temp[0]-@scx,298-@scy,1)
  519.     elsif @temp[0]
  520.       Tls['Objects/Toadwalk4',32,54][[0,1,2,1][$count/8%4]].draw(@temp[0]-@scx,298-@scy,1)
  521.     end
  522.    
  523.     when 157
  524.     if @start
  525.       ary=[]
  526.       2.times{|x| ary << [800+x*32,160,'Shrine',13]}
  527.       QSwitch.new(960,320,17,false,ary)
  528.     end
  529.    
  530.     when 159
  531.     if @start and !$save[:events][15] || $bossrush
  532.       BossDoor.new(0,32,true)
  533.       BossDoor.new(1248,832,true)
  534.       Song.current_song.stop
  535.       @entities[1].each{|ent| ent.remove}
  536.       Goombfalloon.new
  537.     end
  538.    
  539.     when 160
  540.     if @player.x.between?(64,320) and @player.y>384 and @player.crouch
  541.       @temp[0]||=0
  542.       @temp[0]+=1
  543.       if @temp[0]==300 and !@temp[1] and !$save[:items][:misc].include?(3)
  544.         @temp[1]=true
  545.         Item.new(@player.x-16,192,:misc,3).vy=-16
  546.       end
  547.     else
  548.       @temp[0]=nil
  549.     end
  550.    
  551.     GGoomba.new(0,416) if @start and $save[:enemies][87]
  552.    
  553.     when 172
  554.     Bobomb.new(160,-32,:right,true) if @time%60==0
  555.    
  556.     when 181
  557.     BossDoor.new(1248,256) if @start and !$save[:events][18]
  558.    
  559.     when 182
  560.     if @start and !$save[:events][18] || $bossrush
  561.       BossDoor.new(0,256,true)
  562.       BossDoor.new(608,256,true)
  563.       Msc['Chaotic Playground',true].play
  564.       @temp[0]=0
  565.       @temp[1]=-1
  566.       @temp[2]=[]
  567.     end
  568.     if @temp[0] and @temp[2]
  569.       @temp[2] << BooFormation.new(@temp[1]+=1) if @temp[0]%40==0
  570.       @temp[0]+=1
  571.       @temp[0]=nil if @temp[0]==321
  572.     end
  573.     if @temp[2] and boo=@temp[2][0].hp<=10000
  574.       if boo=@temp[2].find{|boof| boof.hp<=0}
  575.         @temp[2].each{|boof| boof.die if boof != boo}
  576.         @temp[2]=nil
  577.       else
  578.         @temp[2].each{|boof| boof.action}
  579.       end
  580.     end
  581.     if @temp[2] and boo=@temp[2][0].hp<=5000
  582.       if boo=@temp[2].find{|boof| boof.hp<=0}
  583.         @temp[2].each{|boof| boof.die if boof != boo}
  584.         @temp[2]=nil
  585.       else
  586.         @temp[2].each{|boof| boof.action}
  587.       end
  588.     end
  589.     if @temp[2]
  590.       min=100000
  591.       @temp[2].each{|t| min=t.hp if t.hp<min}
  592.       @temp[2].each{|t| t.hp=min}
  593.     end
  594.    
  595.     when 189
  596.     BossDoor.new(608,320) if @start and !$save[:events][22]
  597.    
  598.     when 190
  599.     if @start and !$save[:events][22] || $bossrush
  600.       BossDoor.new(0,320,true)
  601.       BossDoor.new(1888,320,true)
  602.       Msc['Confrontation',true].play
  603.       ToxBoxMax.new
  604.     end
  605.    
  606.     when 206
  607.     BossDoor.new(0,224) if @start and !$save[:events][23]
  608.     $game.map.music(12) if @start and !Song.current_song
  609.    
  610.     when 207
  611.     if @start and !$save[:events][23] || $bossrush
  612.       BossDoor.new(0,224,true)
  613.       BossDoor.new(1248,224,true)
  614.       Song.current_song.stop
  615.       $premusic=nil
  616.       @entities[1].each{|ent| ent.remove if ent.class != Luigi}
  617.       @temp[2]=Luigi.new(320,390)
  618.     end
  619.    
  620.     if @player.x<520 and !@temp[0] and !$save[:events][23]
  621.       @player.vx=-2
  622.       Message.new("Mario","Mario","Luigi?")
  623.       Message.new("Luigi","Luigi","Mario... Peach is in castle...")
  624.       Message.new("Mario","Mario","I know. Let's go and save her^together.")
  625.       Message.new("Luigi","Luigi","No, this time I'll be the one...^I will be the PLAYER ONE!!")
  626.       Message.new("Mario","Mario","WTF are you saying? Luigi! Come^on!")
  627.       @temp[0]=Message.new("Luigi","Luigi","Mario... Brother...^Your mission ends... Here...")
  628.     elsif @temp[0] && @temp[0].closed && !@temp[1] or $bossrush && !@temp[1]
  629.       @temp[1]=true
  630.       Msc['Fight Against Culex',true].play
  631.       @temp[2].boss!
  632.     end
  633.    
  634.     when 208
  635.     $game.map.music(12) if @start and !Song.current_song
  636.    
  637.     when 213
  638.     QSwitch.new(640,352,24,nil,[]) if @start
  639.    
  640.     when 214
  641.     QSwitch.new(608,480,25,nil,[]) if @start
  642.    
  643.     when 215
  644.     if @start
  645.       4.times{|i| ary=[]
  646.       4.times{|y| ary << [1088+i*32,192+y*32,'Bonus',y==0 ? 5 : y==3 ? 27 : 16]}
  647.       QSwitch.new(i==2 ? 480 : 0,i==2 ? 544 : 0,24+i,nil,ary)}
  648.     end
  649.    
  650.     when 216
  651.     QSwitch.new(768,448,27,nil,[]) if @start
  652.    
  653.     when 218
  654.     if !$save[:events][31] and !@temp[0] and @player.x>128
  655.       @player.mammamia
  656.       Snd['MarioDamage4'].play
  657.       @temp[0]=Message.new("Mario","Mario","DAFUQ? This stupid Bowser!^Why the hell would he keep^such slanderous pictures?")
  658.     elsif @temp[0] and @temp[0].closed
  659.       $save[:events][31]=true
  660.       @player.demammamia
  661.     end
  662.    
  663.     when 222
  664.     BossDoor.new(608,1280) if @start and !$save[:events][30]
  665.    
  666.     when 223
  667.     if @start and !$save[:events][30] || $bossrush
  668.       BossDoor.new(0,320,true)
  669.       BossDoor.new(1248,320,true)
  670.       Msc['Confrontation',true].play
  671.       Lakithunder.new
  672.     end
  673.    
  674.     when 242
  675.     @map.music 15 if !Song.current_song
  676.     @entities[1].each{|ent| ent.remove} if @start and !$save[:events][28]
  677.    
  678.     when 243
  679.     if @start and !$save[:events][28]
  680.       Song.current_song.stop
  681.       $premusic=nil
  682.     end
  683.    
  684.     if $save[:relics][10] and !@temp[0] and !$save[:events][28] and !$bossrush
  685.       Snd['Kamek Hahaha'].play
  686.       @player.vx=-2
  687.       @temp[2]=Kamek.new(0,380)
  688.       Message.new("Kamek","Kamek","Well, well... Who do we have^here?")
  689.       Message.new("Mario","Mario","Kamek?")
  690.       Message.new("Kamek","Kamek","Indeed, it's me. Long way you had^to go, but you came here finally.")
  691.       if !$save[:relics][9]
  692.         Message.new("Kamek","Kamek","You didn't find castle's biggest^secret and I'm going to make sure^you won't.")
  693.       else
  694.         Message.new("Kamek","Kamek","You found castle's big secret.^I'm going to put an end to you.^You are such a troublemaker.")
  695.       end
  696.       Message.new("Mario","Mario","It is your fault! You cursed^Luigi and are responsible for^summoning the castle!")
  697.       Message.new("Kamek","Kamek","How clever you are! I'm really^impressed! But it is obvious that^Bowser wouldn't make all of this^if not my powerful magic.")
  698.       Message.new("Kamek","Kamek","It is me who summoned Dracula's^castle to this world and it is^me who mastered the control over^it's power.")
  699.       Message.new("Mario","Mario","What for? Aren't you enough?")
  700.       Message.new("Kamek","Kamek","For master Bowser of course!^I did it all so he can finally^take control over Mushroom^Kingom. And princess Peach will^be finally his own.")
  701.       Message.new("Kamek","Kamek","We were planning to launch an^attack to the kingdom, but you^came here bringing this stupid^princess with you. That's even^better and easier that way.")
  702.       @temp[0]=Message.new("Kamek","Kamek","And this is as far as you will^go.^PERISH NOW! MARIO!")
  703.     elsif @temp[0] && @temp[0].closed && !@temp[1] or $bossrush && !@temp[1]
  704.       @temp[2]||=Kamek.new(0,380)
  705.       @temp[2].start=@temp[1]=true
  706.       BossDoor.new(1248,288,true)
  707.       Msc['Fight Against Culex',true].play
  708.     end
  709.    
  710.     when 248
  711.     if @start
  712.       BossDoor.new(0,320)
  713.     end
  714.    
  715.     when 249
  716.     # return @start=nil if @bowser and !@temp[11] and !@temp[30]##
  717.     # return @bowser=Bowser.new(@scx+32,296) if @start and !@temp[11] and !@temp[30]##
  718.     if @start and !@temp[1] and !@temp[11] and !@temp[30] and !$bossrush
  719.       BossDoor.new(1248,320,true)
  720.       @player.ignore=true
  721.       Msc['Item Room'].play true
  722.       @temp[0]=Sprite.new(588,237,'Enemies/Bowser',96,120)
  723.       @temp[8]=Sprite.new(604,310,'Effects/Cup',16,23)
  724.       @temp[0].frame=7
  725.       Message.new("Bowser","Bowser","Mario! Whadya doin' here?^Kamek was supposed to stop you^from coming.")
  726.       @temp[1]=Message.new("Mario","Mario","Your dear and reliable almighty^super-sorcery devoted minion...^has...^failed.")
  727.     elsif @temp[1] and @temp[1].closed and !@temp[2]
  728.       @temp[0].frame=9
  729.       Message.new("Bowser","Bowser","Kamek has... failed? You^defeated even Luigi, your own^brother?")
  730.       Message.new("Bowser","Bowser","Well, that's no surprise.^They have always been useless.^That's why you are the main hero^and I am the main badass villain.")
  731.       Message.new("Mario","Mario","I will avenge Luigi!")
  732.       @temp[2]=Message.new("Bowser","Bowser","Something bad happened? Well,^that's so sad. So much sad.^Gwahahahahahahahaha!!!")
  733.     elsif @temp[2] and @temp[2].closed and !@temp[7]
  734.       @temp[0].animation(4,10,11,12,11)
  735.       @temp[7]=0
  736.       Snd['Bowser Hahaha'].play
  737.     elsif @temp[7] and !@temp[9] and (@temp[7]+=1)==180
  738.       @temp[8].angle=135
  739.       @temp[8].x=618
  740.       @temp[8].y=276
  741.       @temp[9]=true
  742.       @temp[7]=0
  743.       @temp[0].frame=13
  744.     elsif @temp[9] and !@temp[3] and (@temp[7]+=1)==60
  745.       Snd['Bowser Hit'].play
  746.       @temp[8].remove
  747.       Particle.new(618,276,1.5,'Effects/Cup',-4,-8,:rotate=>-8,:wine=>true)
  748.       @temp[0].frame=5
  749.       @temp[3]=Message.new("Bowser","Bowser","YUCK!!^The hell is wrong with this^wine?!")
  750.     elsif @temp[3] and @temp[3].closed and !@temp[4]
  751.       @temp[0].frame=0
  752.       @temp[0].y=296
  753.       Message.new("Bowser","Bowser","Enough talking. Let's just finish^it Mario. Peach is mine, I am^pretty immortal with my powers.^I will just crush you, 'kay?")
  754.       @temp[4]=Message.new("Mario","Mario","Yeah, whatever.")
  755.     elsif @temp[4] and @temp[4].closed and !@temp[10]
  756.       Song.current_song.stop
  757.       Snd['Bowsa'].play
  758.       @temp[10]=Trace.new(@temp[0].x+48,0,2,'Effects/Teleport',8,:vanish=>true)
  759.     elsif @temp[10] && @temp[10].removed && !@temp[5] or $bossrush && !@temp[5]
  760.       BossDoor.new(1248,320,true) if $bossrush
  761.       Msc['Fight Against Culex',true].play
  762.       @temp[5]=true
  763.       @player.ignore=false
  764.       Bowser.new(@scx+32,296)
  765.     end
  766.    
  767.     if @temp[0] and !@temp[6]
  768.       @player.vx=-4
  769.       @temp[6]=true if @player.x<750
  770.     end
  771.    
  772.     if @temp[10] and @temp[10].vanish
  773.       @temp[0].remove
  774.     end
  775.    
  776.     if @temp[11] and flashing==64
  777.       Message.new("Bowser","Bowser","I've failed. Mario, you fool.^Defeat Dracula or our world is^done.")
  778.     elsif @temp[11] and !flashing and !@temp[12]
  779.       Snd['Bats'].play
  780.       @temp[12]=0
  781.     elsif @temp[12] and @temp[12]<120
  782.       @temp[12]+=1
  783.       angle=rand(360)
  784.       Trail.new(520+rand(44)-offset_x(angle,72),280+rand(126)-offset_y(angle,72),2.2,['Effects/Bat',15,15,0],[0,1,2,1]*3,3,:movex=>offset_x(angle,2),:movey=>offset_y(angle,2)) if @temp[12]%3==0
  785.       @temp[16]=Sprite.new(520,280,'Enemies/Dracula',74,156) if @temp[12]==60
  786.     elsif @temp[12] and @temp[12]==120 and !@temp[13]
  787.       @temp[13]=Message.new("Dracula","Dracula","I am count Dracula, the true^master...")
  788.     elsif @temp[13] and @temp[13].closed and !@temp[14]
  789.       Snd['Fire1'].play
  790.       @temp[15]=Trail.new(537,280,2.2,['Effects/Fire1',40,92,0],[0,1,2,3]*999,4)
  791.       Message.new("Dracula","Dracula","Wah! Who the hell put glass roof^in the throne room?")
  792.       @temp[14]=Message.new("Dracula","Dracula","Oh no! The sun, it burns!")
  793.     elsif @temp[14] and @temp[14].closed and !@temp[17]
  794.       @temp[15].remove
  795.       @temp[16].remove
  796.       Trail.new(520,280,2,['Effects/Dracend',74,156,0],[0,1,2,3],16)
  797.       @temp[17]=Message.new("Mario","Mario","Well, that was awkward.")
  798.     elsif @temp[17] and @temp[17].closed and !@temp[18]
  799.       @temp[19]=Snd['Earthquake'].play
  800.       $game.shake(8,4,9999)
  801.       @temp[18]=Timer.new(60)
  802.     elsif @temp[18] and @temp[18].finished and !@temp[20]
  803.       @temp[20]=Message.new("Bowser","Bowser","Ok, Mario, you won.^This castle is yours now.^I'm outta here.")
  804.       Message.new("Mario","Mario","Finally, my own castle!^I'm so happy :))))))")
  805.     elsif @temp[20] and @temp[20].closed and !@temp[21]
  806.       @temp[21]=Sprite.new(384,480,'Enemies/Clown',128,128,true)
  807.       @temp[21].animation(4,0,1,2,3)
  808.       @temp[23]=@entities[0].find{|ent| ent.class==Sprite and ent.x==400}
  809.     elsif @temp[21] and !@temp[22]
  810.       @temp[21].y-=4
  811.       @temp[23].y-=4 if @temp[21].y<=364
  812.        if @temp[21].y<=240
  813.         Message.new("Bowser","Bowser","You should practice your sarcasm,^Mario.")
  814.         Message.new("Mario","Mario","And you should practise your^fighting.")
  815.         @temp[22]=Message.new("Bowser","Bowser","It's not over. One day,^Peach will be all mine.")
  816.       end
  817.     elsif @temp[22] and @temp[22].closed and !@temp[24]
  818.       @temp[24]=Timer.new(120)
  819.     elsif @temp[24] and @temp[24].finished and !@temp[25]
  820.       @temp[25]=Message.new("Mario","Mario","By the way, where's Peach?")
  821.     elsif @temp[25] and !@temp[26]
  822.       @temp[26]=Sprite.new(1280,338,'Objects/Peach',32,78)
  823.       @temp[26].animation(8,0,2)
  824.       @temp[27]=Luigi.new(1200,375)
  825.     elsif @temp[26] and @temp[26].x>800
  826.       @temp[26].x-=4
  827.       @temp[27].vx=-4
  828.     elsif @temp[26] and !@temp[28]
  829.       @temp[26].frame=0
  830.       @player.vx=2
  831.       @temp[27].vx=-0.1
  832.      
  833.       Message.new("Luigi","Luigi","Mario! Found you at last!")
  834.       Message.new("Mario","Mario","Luigi? So you are alive?")
  835.       Message.new("Mario","Mario","And... P-p-p-each!!!")
  836.       Message.new("Peach","Peach","I'm alright.  Don't worry, honey.")
  837.       Message.new("Luigi","Luigi","I was eaten by the curse.^You freed me by breaking the^seal.")
  838.       Message.new("Luigi","Luigi","But this time, I saved the Peach.")
  839.       Message.new("Peach","Peach","He is right. I'm now all his,^for some time of course.")
  840.       Message.new("Luigi","Luigi","And who is the player one now?!")
  841.       Message.new("Mario","Mario","I just want to leave this damn,^collapsing castle.")
  842.       @temp[28]=Message.new("Luigi","Luigi","I know the way to exit.^Everyone else has left safely^already.")
  843.     elsif @temp[28] and @temp[28].closed
  844.       ##jescze animka rozwalania zamku
  845.       $game=End.new(true)
  846.     end
  847.    
  848.     @temp[19]=Snd['Earthquake'].play if @temp[19] and !@temp[19].playing?
  849.     if @temp[24]
  850.       @temp[21].y-=4
  851.       @temp[23].y-=4
  852.     end
  853.    
  854.     if @temp[30] and !@temp[31]
  855.       @temp[31]=Timer.new(120)
  856.       @player.ignore=true
  857.     elsif @temp[31] and @temp[31].finished and !@temp[32]
  858.       Message.new("Mario","Mario","What will I do now?")
  859.       Message.new("Mario","Mario","Luigi is dead.^Peach is missing.")
  860.       Message.new("Mario","Mario","PEACH!! I didn't find her.")
  861.       Message.new("Mario","Mario","I want to destroy this castle.^This Bowser is so tiring.^I don't know what to do.")
  862.       @temp[32]=Message.new("Mario","Mario","Is there something I missed?")
  863.     elsif @temp[32] and @temp[32].closed
  864.       $game=End.new(false)
  865.     end
  866.    
  867.     when 252
  868.     if @start and !@temp[0] and !$save[:events][29] || $bossrush
  869.       BossDoor.new(0,224,true)
  870.       BossDoor.new(608,224,true)
  871.       Msc['Confrontation',true].play
  872.       OmniSledge.new(416,224)
  873.     end
  874.    
  875.     when 267
  876.     if @start
  877.       ary=[]
  878.       3.times{|y| ary << [224+y*32,256,'Shrine',13]}
  879.       QSwitch.new(576,384,32,false,ary)
  880.      
  881.       TheDoor.new(3456,352)
  882.     end
  883.    
  884.     when '45a'
  885.     Tls['Objects/Pointer',42,302][0].draw_rot(320-@scx,416-@scy,1,-$count*15,0.5,0.735)
  886.     Tls['Objects/Pointer',42,302][1].draw_rot(320-@scx,416-@scy,1,-$count,0.5,0.735)
  887.    
  888.     when '7a' ; BossDoor.new(0,1248) if @start and !$save[:cores].include?('7a')
  889.     BangStar.new(@scx+rand(606),@scy-102) if rand(60)==0 and !stopped
  890.    
  891.     when '13a'
  892.     TheDoor.new(896,416) if @start
  893.    
  894.     when '26a' ; BossDoor.new(1888,768) if @start and !$save[:cores].include?('26a')
  895.     when '33a' ; BossDoor.new(5728,288) if @start and !$save[:cores].include?('33a')
  896.     when '38a' ; BossDoor.new(0,288) if @start and !$save[:cores].include?('38a')
  897.     when '43a' ; BossDoor.new(1248,288) if @start and !$save[:cores].include?('43a')
  898.     when '54a' ; BossDoor.new(0,288) if @start and !$save[:cores].include?('54a')
  899.     when '64a' ; BossDoor.new(608,768) if @start and !$save[:cores].include?('64a')
  900.     when '66a' ; BossDoor.new(1888,288) if @start and !$save[:cores].include?('66a')
  901.     when '68a' ; BossDoor.new(0,288) if @start and !$save[:cores].include?('68a')
  902.     when '75a' ; BossDoor.new(0,288) if @start and !$save[:cores].include?('75a')
  903.     when '98a' ; BossDoor.new(608,288) if @start and !$save[:cores].include?('98a')
  904.     when '102a' ; BossDoor.new(0,288) if @start and !$save[:cores].include?('102a')
  905.     when '114a' ; BossDoor.new(0,288) if @start and !$save[:cores].include?('114a')
  906.   end
  907.  
  908.   @start=nil
  909. end
  910.  
  911. def areas
  912.   ["Castle's Entrance","Tangled Garden","Waterway","Dimensional Distortion","Corridor of Infinity","Pipeline","Haunted Library","Weapons Factory","Chambers of Goombas","Skyfall Shrine","Clock Tower","Bonus Area","Catacombs","Forbidden Cave","The Abyss","Halls of Bowser"]
  913. end
  914.  
  915. class Load
  916.   def initialize
  917.     Fnt[['System/Font',20,20],['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0','.','/',':','!','@','%','?','_','-',',','<','>','+',"'",'#','(',')']]
  918.     Fnt[['System/Damage1',14,16],['1','2','3','4','5','6','7','8','9','0','-','+']]
  919.     Fnt[['System/Damage2',14,16],['1','2','3','4','5','6','7','8','9','0','-','+']]
  920.     (Dir.entries('data/music')-['.','..']).each{|msc| Msc[msc.chomp('.ogg')]}
  921.     return
  922.     (Dir.entries('data/gfx')-['.','..']).each{|dir| (Dir.entries('data/gfx/'+dir)-['.','..']).each{|img| if img.end_with?('png')
  923.       Img[dir+'/'+img.chomp('.png')]
  924.     else
  925.       (Dir.entries('data/gfx/'+dir+'/'+img)-['.','..']).each{|img2| Img[dir+'/'+img+'/'+img2.chomp('.png')]}
  926.     end}}
  927.     (Dir.entries('data/sfx')-['.','..']).each{|sfx| Snd[sfx.chomp('.ogg')]}
  928.   end
  929.  
  930.   def update
  931.   end
  932.  
  933.   def draw
  934.     $shaders||=[Ashton::Shader.new(fragment: "data/stone.frag"),Ashton::Shader.new(fragment: "data/curse.frag"),Ashton::Shader.new(fragment: "data/poison.frag"),Ashton::Shader.new(fragment: "data/protec.frag"),Ashton::Shader.new(fragment: "data/starman.frag")]
  935.     $game=MainMenu.new
  936.   end
  937.  
  938.   def Load.Model(name)
  939.     model=Marshal.load(f=File.new("data/models/#{name.downcase}.2dm",'r'))
  940.     f.close
  941.     model
  942.   end
  943.  
  944.   def Load.Animation(name)
  945.     anim=Marshal.load(f=File.new("data/models/animations/#{name.downcase}.2da",'r'))
  946.     f.close
  947.     anim
  948.   end
  949. end
  950.  
  951. class Model
  952.   attr_accessor :x,:y,:z,:skin,:angle,:mirror_x,:mirror_y
  953.   attr_reader :bones,:order
  954.   def initialize
  955.     @bones={}
  956.     @order=[]
  957.     @x=@y=@z=@angle=0
  958.   end
  959.  
  960.   def update
  961.     @bones.each_value{|bone| bone.update}
  962.   end
  963.  
  964.   def draw
  965.     scale(@mirror_x ? -1 : 1, @mirror_y ? -1 : 1, @x, @y)  do
  966.       @order.each{|bone| x1,y1=bone_origin(bone) ; x2,y2=bone_tip(bone) ; @bones[bone].draw(x1,y1,x2,y2)}
  967.     end
  968.   end
  969.  
  970.   def bone_origin(name)
  971.     if @bones[name].parent != self
  972.       x,y=bone_tip(@bones[name].parent)
  973.       x+=-offset_y(@bones[@bones[name].parent].angle,@bones[name].offset_x)-offset_x(@bones[@bones[name].parent].angle,@bones[name].offset_y)
  974.       y+=-offset_y(@bones[@bones[name].parent].angle,@bones[name].offset_y)+offset_x(@bones[@bones[name].parent].angle,@bones[name].offset_x)
  975.     else
  976.       x,y=@x,@y
  977.       x+=-offset_y(@angle,@bones[name].offset_x)-offset_x(@angle,@bones[name].offset_y)
  978.       y+=-offset_y(@angle,@bones[name].offset_y)+offset_x(@angle,@bones[name].offset_x)
  979.     end
  980.     [x,y]
  981.   end
  982.  
  983.   def bone_tip(name)
  984.     return @x,@y if name==self
  985.     x,y=bone_origin(name)
  986.     x+=offset_x(@bones[name].angle,@bones[name].length)
  987.     y+=offset_y(@bones[name].angle,@bones[name].length)
  988.     [x,y]
  989.   end
  990.  
  991.   def animation(animation,args={})
  992.     animation.frames.each_pair do |name,frames|
  993.       @bones[name].animation(animation, frames, args[:delay] ? args[:delay] : 1, args[:loop], args[:override], args[:keep]) if !@bones[name].animation? or @bones[name].animation? != animation && args[:force] || @bones[name].animation? == animation && args[:repeat]
  994.     end
  995.    
  996.     return
  997.     return if animation==@animation and !args[:repeat]
  998.     return if @animation and !args[:force]
  999.     @delay||=1
  1000.     args[:delay]||=@delay
  1001.     @delay=args[:delay]
  1002.     @loop=args[:loop]
  1003.     @animation=animation
  1004.     @count=@delay-1
  1005.     if args[:smooth]
  1006.       @frame=-1
  1007.     else
  1008.       @frame=0
  1009.       @animation.frames[0].bones.each_pair{|name,angle| @bones[name].angle0=angle if @bones[name]}
  1010.     end
  1011.   end
  1012.  
  1013.   def stop
  1014.     @bones.each_value{|bone| bone.animation(nil,nil,nil)}
  1015.   end
  1016.  
  1017.   def add_bone(name)
  1018.     @bones[name]=Bone.new(self,(@select and @select != name) ? @select : self)
  1019.     @order << name
  1020.     @bones[name]
  1021.   end
  1022. end
  1023.  
  1024. class Bone
  1025.   attr_accessor :length,:angle0,:skin,:mirror_x,:mirror_y,:offset_x,:offset_y,:origin_x,:origin_y
  1026.   attr_reader :parent
  1027.   # attr_reader :angle, :parent
  1028.   def initialize(model,parent)
  1029.     @model,@parent=model,parent
  1030.     @length=@angle=@angle0=@offset_x=@offset_y=0
  1031.     @origin_x=@origin_y=0.5
  1032.   end
  1033.  
  1034.   def update
  1035.     if @animation
  1036.       return if @animation_frame==@animation.length and @animation_keep
  1037.       @angle0=@animation[@animation_frame]
  1038.       @animation_time+=1
  1039.      
  1040.       if @animation_time == @animation_delay
  1041.         @animation_frame+=1
  1042.         @animation_time=0
  1043.       end
  1044.      
  1045.       if @animation_frame==@animation.length
  1046.         if @animation_loop
  1047.           @animation_frame=0
  1048.         elsif !@animation_keep
  1049.           @animation=@animation_override=@animation_name=nil
  1050.         end
  1051.       end
  1052.     end
  1053.    
  1054.     # @angle=@angle0+(parent.class == Model ? parent.angle : @model.bones[parent].angle)
  1055.   end
  1056.  
  1057.   def draw(x1,y1,x2,y2)
  1058.     parent = (@parent.class==Model ? @model : @model.bones[@parent])
  1059.     Img["models/skins/#{@model.skin}/#{@skin}"].draw_rot((x1+x2)/2,(y1+y2)/2,@model.z,angle,@origin_x,@origin_y,@mirror_x ? -1 : 1,@mirror_y ? -1 : 1)
  1060.   end
  1061.  
  1062.   def animation(animation, frames, delay, loop, override, keep)
  1063.     return if @animation_override and !override
  1064.     @animation_name=animation
  1065.     @animation=frames
  1066.     @animation_frame=0
  1067.     @animation_time=0
  1068.     @animation_delay=delay
  1069.     @animation_loop=loop
  1070.     @animation_override=override
  1071.     @animation_keep=keep
  1072.   end
  1073.  
  1074.   def animation?
  1075.     @animation_name
  1076.   end
  1077.  
  1078.   def angle
  1079.     @angle0+(parent.class == Model ? parent.angle : @model.bones[parent].angle)
  1080.   end
  1081. end
  1082.  
  1083. class Animation
  1084.   attr_reader :frames
  1085.   def initialize
  1086.     @frames={}
  1087.   end
  1088. end
  1089.  
  1090. class Enemy < Entity
  1091.   attr_reader :name
  1092.   attr_accessor :hp,:nodrop
  1093.   def initialize(enemy)
  1094.     enemy=$enemies.index{|en| en[:name]==enemy}
  1095.     @name=$enemies[enemy][:name]
  1096.     @hp=$enemies[enemy][:hp]
  1097.     @sp=$enemies[enemy][:sp]
  1098.     @attack=$enemies[enemy][:attack]
  1099.     @exp=$enemies[enemy][:exp]
  1100.     @defence=($enemies[enemy][:defence] ? $enemies[enemy][:defence] : 0)
  1101.     @resistance=($enemies[enemy][:resistance] ? $enemies[enemy][:resistance] : 0)
  1102.     @tolerance=($enemies[enemy][:tolerance] ? $enemies[enemy][:tolerance] : [])
  1103.     @weakness=($enemies[enemy][:weakness] ? $enemies[enemy][:weakness] : [])
  1104.     @id=enemy
  1105.     @unstoppable=true
  1106.     @setinv=30
  1107.     @element=$enemies[enemy][:element]
  1108.    
  1109.     @offx||=0
  1110.     @offy||=0
  1111.   end
  1112.  
  1113.   def update
  1114.     @offx||=0
  1115.     @offy||=0
  1116.     @inv=nil if @invincible
  1117.     preact if !@active
  1118.     return @active=(@x.between?($game.scx-size[0],$game.scx+640) and @y.between?($game.scy-size[1],$game.scy+480)) if !@active
  1119.     if @hp and @hp<=0
  1120.       dead
  1121.       return if @dead
  1122.       @dead=true
  1123.       if @nodrop
  1124.         Star.new(@x,@y,rand(50)==0) if @nodrop==:star and rand(5)==0
  1125.         return
  1126.       end
  1127.       $save[:exp]+=(@exp*($save[:equip][4]==5 ? 1.2 : 1)).round
  1128.       $save[:enemies][@id] ||= []
  1129.       $save[:kills][@id] ||= 0
  1130.       $save[:kills][@id]+=1
  1131.       $save[:allkills]+=1
  1132.       drop=$enemies[@id][:drop]
  1133.       dropped=nil
  1134.       drop.each{|drp| if !dropped and rand(100000)<(drp[2]+$save[:luck]*0.025)*([$save[:equip][6],$save[:equip][7]].include?(3) ? 2 : 1)*1000
  1135.         dropped=true
  1136.         @drop=Item.new(@x+size[0]/2-16,@y+size[1]-32,drp[0],drp[1])
  1137.         $save[:enemies][@id][drop.index(drp)]=true end}
  1138.       if !dropped and rand(100000)<(0.5+$save[:luck]*0.025)*($save[:equip][0]==3 ? 15 : 1)*1000
  1139.         coin=rand([$save[:equip][6],$save[:equip][7]].include?(11) ? 8 : 4)
  1140.         Coin.new(@x+size[0]/2-[10,14,14,16,20,14,16,20][coin],@y+size[1]-[32,32,32,50,42,32,50,42][coin],coin)
  1141.       end
  1142.       $save[:magic][@magic][0]+=@sp if @magic
  1143.     else
  1144.       action if not !@unstoppable2 && $game.stopped
  1145.       @attacked=@damaged=@stomped=@powed=nil
  1146.       if !@harmless and !$game.gameover and !pl.inv || @omnir and $save[:hp]>0 and collide
  1147.         if pl.starman
  1148.           self.damage($save[:strength]+100,true,nil) if self.respond_to? :damage
  1149.           return
  1150.         end
  1151.         return pl.inv=60 if ($save[:equip][0]==5 and rand(5)==0)
  1152.         return @attacked=true if self.class==Spikes and $save[:equip][0]==2
  1153.         $game.player.reset
  1154.         Snd["MarioDamage#{1+rand(5)}"].play
  1155.         pl.inv=@setinv
  1156.         damage=@attack-(@matk ? $save[:mind] : $save[:defence])
  1157.         8.times{|i| damage/=2 if $save[:resistance][i]==@element} if @element
  1158.         damage=1 if damage<=0
  1159.         damage*=2 if $save[:status]=='STONE'
  1160.         damage=100 if @absolute100
  1161.         $save[:hp]-=damage
  1162.         Info.new(pl.x-damage.to_s.length*7,pl.y-40,damage,"Damage1")
  1163.         pl.vx=6*(pl.x<@x+size[0]/2 ? -1 : 1)*(@knockback ? @knockback : 1) if $save[:status]!='STONE' and $save[:equip][0]!=2
  1164.         pl.vy=-10 if $save[:status]!='STONE' and $save[:equip][0]!=2 and @knockback != 0
  1165.         @attacked=damage
  1166.         $save[:status]=['POISON',"CURSE","STONE"][@element-8] if $save[:status]!='PROTEC' and [8,9,10].include?(@element) and !$save[:resistance].include?(@element)
  1167.         if self.class != Projectile and $save[:equip][0]==11
  1168.           self.damage($save[:intelligence]/2,true,5)
  1169.           Snd['Blast'].play
  1170.           Trail.new(pl.x-21,pl.y-20,3,['Effects/Backfire',42,40],[0,1,2,3],8)
  1171.         end
  1172.       end
  1173.     end
  1174.     @inv=nil if @inv and (@inv-=1)==0
  1175.     remove if !@notoffmap and @x>$game.map.data[:width]*640 || @x+size[0]<0 || @y>$game.map.data[:height]*480 || !@notoffup && @y+size[1]<0
  1176.   end
  1177.  
  1178.   def stomp(x,y,pound)
  1179.     return if !@active or @inv or @immortal or @unstompable && @unstompable != :solid && $save[:equip][5] != 1 && $save[:equip][0] != 2 && (@unstompable !=true || pound !=:spin) or @unstompable==:through
  1180.     if x+12>@x+@offx and x-12<@x+@offx+size[0] and y+24>@y+@offy-8 and y-40<@y+@offy+size[1]
  1181.       $game.enemy=self
  1182.       @invincible ? Snd['Guard'].play : dam_snd ? dam_snd.play : Snd['Stomp'].play
  1183.       $game.player.bounce
  1184.       return if @unstompable==:solid
  1185.       damage($save[:stomp]*(pound==:spin ? 1.5 : (pound and pound != :slide) ? 2 : 1),false,($save[:equip][5]==2 and !pound || pound==:spin) ? 1 : 0)
  1186.       @stomped=true
  1187.     end
  1188.   end
  1189.  
  1190.   def pow(x,y,width,pound)
  1191.     return if !@active or @inv or @immortal
  1192.     if x<@x+size[0] and x+width>@x+@offx and y<@y+size[1] and y>@y+@offy
  1193.       $game.enemy=self
  1194.       # Snd['Stomp'].play
  1195.       # $game.player.bounce if !pound
  1196.       damage($save[:stomp]*(pound ? 2 : 0.5),false,0)
  1197.       @powed=(pound ? :pound : true)
  1198.     end
  1199.   end
  1200.  
  1201.   def kill(x,y,sizex,sizey,attack,element,id,inv=nil)
  1202.     return if @inv or !@active or @immortal
  1203.     if x+sizex>@x+@offx and x<@x+@offx+size[0] and y+sizey>@y+@offy and y<@y+@offy+size[1]
  1204.       $game.enemy=self
  1205.       @invincible ? Snd['Guard'].play : dam_snd ? dam_snd.play : Snd['Stun'].play
  1206.       damage(attack,![nil,0,1,2].include?(element),element)
  1207.       @magic=id if id
  1208.       @inv=inv if inv
  1209.       true
  1210.     end
  1211.   end
  1212.  
  1213.   def pl;$game.player;end
  1214.  
  1215.   def damage(attack,magical,element,ix=@x+@offx+size[0]/2,iy=@y)
  1216.     return if !@hp
  1217.     iy=@iy if @iy
  1218.     return Info.new(ix-24,iy-20,attack,Tls['System/Status',48,16][3]) if @invincible
  1219.     return if @immortal
  1220.     if attack==:absolute
  1221.       attack=77
  1222.     elsif attack.class==String
  1223.       attack=attack.to_i
  1224.     else
  1225.       attack*=0.5 if @tolerance.include?(element)
  1226.       attack*=1.5 if @weakness.include?(element)
  1227.       attack-=@defence if !magical
  1228.       attack-=@resistance if magical
  1229.       attack=[attack.round,1].max
  1230.     end
  1231.     Info.new(ix-attack.to_s.length*7,iy-20,attack,"Damage1")
  1232.     @hp-=attack
  1233.     @inv=8
  1234.     @damaged=true
  1235.   end
  1236.  
  1237.   def dead
  1238.     Snd['KO'].play
  1239.     Particle.new(@x+size[0]/2,@y+size[1]/2,3,img,vx=-8+rand(17),-6-rand(7),:angle=>0,:rotate=>vx*4)
  1240.     remove
  1241.   end
  1242.  
  1243.   def collide
  1244.     pl.x+12>@x+@offx and pl.x-12<@x+@offx+size[0] and pl.y+20>@y+@offy and pl.y-(pl.crouch ? 8 : 40)<@y+@offy+size[1]
  1245.   end
  1246.  
  1247.   def preact;end
  1248.   def dam_snd;end
  1249.  
  1250.   def dead?;@dead;end
  1251. end
  1252.  
  1253. class Info < Entity
  1254.   def initialize(x,y,text,font)
  1255.     @x,@y,@text,@font=x,y,text,font
  1256.     @time=30
  1257.     @unstoppable=true
  1258.     init
  1259.   end
  1260.  
  1261.   def update
  1262.     remove if (@time-=1)==0
  1263.     @y-=1
  1264.   end
  1265.  
  1266.   def draw
  1267.     if @font.class==Image
  1268.       @font.draw(@x,@y,4)
  1269.     elsif @font.class==Array
  1270.       @font[$count/8%2].draw(@x,@y,4)
  1271.       @time=60 if !@timed
  1272.       @timed=true
  1273.     else
  1274.       Fnt[["System/#{@font}",14,16]].draw(@text,@x,@y,4)
  1275.     end
  1276.   end
  1277. end
  1278.  
  1279. class Room
  1280.   attr_reader :x,:y,:discovered,:dimension,:mapped
  1281.   def draw(option)
  1282.     return if !@mapped && !@discovered or @dimension && option==1 or !@dimension && option==2
  1283.     if @type>0
  1284.       color=@discovered ? [0xffff0000,0xffffff00][@type-1] : 0xff404040
  1285.     elsif @type==0
  1286.       color=(@dimension ? 0x80ff0000 : 0x800000ff) if option==0
  1287.       color=0xffc000c0 if option==0 and (room=$save[:map].find{|room| room.dimension==!@dimension and room.x==@x and room.y==@y}) && @discovered && room.discovered || !room
  1288.       color=0xff000080 if option==1
  1289.       color=0xff800000 if option==2
  1290.       color=0xff800080 if option==3
  1291.       color=0xff404040 if !@discovered
  1292.     end
  1293.     Img["System/#{@fall ? 'Fall' : 'Back'}"].draw(@x,@y,0,1,1,color)
  1294.     4.times{|i| Img['System/Wall'].draw_rot(@x+5,@y+5,(@walls[i]==2 ? 1 : 2)*(@dimension ? 0.2 : 1),i*90,0.5,0.5,1,1,@walls[i]==2 ? 0xff008040 : @discovered ? 0xffffffff : 0xffc0c0c0) if @walls[i]>0}
  1295.   end
  1296.  
  1297.   def discover
  1298.     @discovered=true
  1299.   end
  1300.  
  1301.   def map!
  1302.     @mapped=true
  1303.   end
  1304.  
  1305.   def setwall(wall,value)
  1306.     @walls[wall]=value
  1307.   end
  1308. end
  1309.  
  1310. class Message
  1311.   attr_reader :closed,:guide
  1312.   def initialize(name,face,text,guide=false)
  1313.     @name,@face,@text,@guide=name,face,text,guide
  1314.     @char=0
  1315.     $game.messages << self
  1316.   end
  1317.  
  1318.   def draw
  1319.     @master=true if !$game.player.ignore
  1320.     $game.player.ignore=true
  1321.     Img['System/Message'].draw(0,0,4)
  1322.     if @face.class==String
  1323.       Img["Faces/#{@face}"].draw(16,16,4)
  1324.     else
  1325.       @face.draw(64,64,4)
  1326.     end
  1327.     Fnt[['System/Font',20,20]].draw(@text[(0...@char)],150,20,4,:xspacing=>15)
  1328.     Fnt[['System/Font',20,20]].draw(@name,320,0,4,:align=>:center)
  1329.     @char+=1 if @char<@text.length and $count% (Keypress[:jump] ? 1 : 4)==0
  1330.    
  1331.     if Keypress[:jump,false] &&  @char==@text.length or Keypress[:spin,false]
  1332.       $game.messages.shift
  1333.       $game.player.freeze=true
  1334.       @closed=true
  1335.       $game.player.ignore=nil if @master
  1336.     end
  1337.   end
  1338. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement