Advertisement
Guest User

Fixed player.rb (WTFPL)

a guest
Sep 11th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 61.58 KB | None | 0 0
  1. class Mario < Entity
  2.   attr_accessor :vx,:vy,:inv,:ignore,:freeze,:crouch,:wall,:antirec
  3.   attr_reader :model,:starman
  4.   def initialize(x,y)
  5.     @unstoppable=true
  6.     @x,@y=x,y
  7.     @model=Load.Model('Mario')
  8.     @animations={}
  9.     [:stand,:run,:jump1,:jump2,:fall,:wallslide,:shoot,:warp,:crouch,:swim1,:swim2,:pound,:destone,:spin,:mammamia].each{|name| @animations[name]=Load.Animation(name.to_s.capitalize)}
  10.     @vx=@vy=0
  11.     @delay=0
  12.     @water=($game.map.water?(@x,@y+20) or $game.map.water?(@x,@y-20))
  13.     @model.z=1.5
  14.   end
  15.  
  16.   def update
  17.     @frozen=@down=@stomped=@solid=nil
  18.     @ignore=nil if @ignore.class==Fixnum and (@ignore-=1)==0
  19.     @peffect.init if @peffect and $game.missing(@peffect)
  20.     if @portal
  21.       @model.animation(@animations[:fall],:force=>true,:keep=>true)
  22.       @model.angle+=8
  23.       @x-=(@x<=>@portal[0])
  24.       @y-=(@y<=>@portal[1])
  25.       return
  26.     end
  27.    
  28.     return @freeze=nil if @freeze
  29.     maxspeed=($save[:equip][0]==9 ? 16 : 8)
  30.     @inv=@inv2=nil if @inv and (@inv-=1)==0
  31.     @delay-=1
  32.     @delay=0 if $save[:recoil]
  33.     $save[:recoil]=nil if $save[:recoil] and ($save[:recoil]-=1)==0
  34.     # $save[:mp_regen].times{|i| $save[:mp]+=1 if $save[:mp]<$save[:max_mp] and @delay<=0} if $save[:status]!='CURSE'
  35.     $save[:mp]=[$save[:mp]+$save[:mp_regen],$save[:max_mp]].min if @delay<=0 and $save[:status]!='CURSE' and ![$save[:equip][6],$save[:equip][7]].include?(9)
  36.     $save[:mp]=[$save[:mp]-$save[:max_mp]/100,0].max if $save[:status]=='CURSE'
  37.     $save[:stars]=[$save[:stars]+1,$save[:max_stars]].min if [$save[:equip][6],$save[:equip][7]].include?(9) and $count% ((15*(1-$save[:stars].to_f/$save[:max_stars])).to_i+1)==0
  38.     if $save[:status]=='POISON' and $count%60==0
  39.       Snd['MarioDamage2'].play
  40.       $save[:hp]-=(damage=$save[:max_hp]/50)
  41.       Info.new(@x-damage.to_s.length*7,@y-40,damage,"Damage1")      
  42.     end
  43.     if @jump3
  44.       @model.angle+=6
  45.     elsif @pound
  46.       @model.angle=@pound*18 if @pound.between?(0,19)
  47.       @model.angle=0 if @pound==20
  48.     elsif @wall
  49.       @model.angle=(@wall==:left ? 270 : 90)
  50.     else
  51.       @model.angle=0
  52.     end
  53.    
  54.     if @spin
  55.       @model.mirror_x=($count%4<2)
  56.     end
  57.    
  58.     if @warp
  59.       @x+=[0,1,0,-1][[:up,:right,:down,:left].index(@warp[0])]
  60.       @y+=[-2,0,2,0][[:up,:right,:down,:left].index(@warp[0])]
  61.       @warp[1]-=1
  62.       $game.came=[$game.player.x,$game.player.y] if @warp[1]==0 and @warp[2]
  63.       @warp=nil if @warp[1]==0
  64.     end
  65.     return if @warp
  66.     @warp2=nil if !Keypress[@warp2]
  67.    
  68.     if !@water && $game.map.water?(@x,@y+20) || @water && !$game.map.water?(@x,@y+20) and !@rewater
  69.       @rewater=true
  70.     elsif !@water && $game.map.water?(@x,@y+20) || @water && !$game.map.water?(@x,@y+20) and @rewater
  71.       @vx=@vy=0 if !@water
  72.       @spin=false
  73.       if @water and key(:jump) || key(:spin,false)
  74.         Snd['Jump1'].play
  75.         @model.animation(@animations[:jump2],:force=>true,:keep=>true)
  76.         @vy=-16
  77.         if key(:spin)
  78.           Snd['Spin'].play
  79.           @spin=true
  80.         end
  81.       end
  82.       @glide=@pound=@rewater=nil
  83.       Snd['Swim'].play
  84.       @water=!@water
  85.       l=$game.entities[0].find{|ent| ent.class==Lava and distance(ent.x+16,ent.y+16,@x,@y)<48}
  86.       tr=Trail.new(@x-16,@y-64,2,["effects/splash#{l ? "2" : ""}",32,32],[0,1,2,3],4)
  87.       64.times{if !$game.map.water?(tr.x+16,tr.y+32) then tr.y+=1 else break end}
  88.       64.times{if $game.map.water?(tr.x+16,tr.y+31) then tr.y-=1 else break end}
  89.     end
  90.    
  91.     if key(:right) and !@crouch and @vx<(key(:shoot) ? maxspeed : 4)
  92.       @vx+=(@water ? 0.2 : 0.4)
  93.     elsif key(:left) and !@crouch and  @vx>-(key(:shoot) ? maxspeed : 4)
  94.       @vx-=(@water ? 0.2 : 0.4)
  95.     end
  96.     if !key(:right) && !key(:left) || @crouch or !key(:shoot) && @vx.abs>4 or @vx.abs>maxspeed
  97.       @vx+=0.25 if @vx.round<0
  98.       @vx-=0.25 if @vx.round>0
  99.     end
  100.    
  101.     if @crouch and $save[:relics][3] and $game.solid?(@x-16,@y+24,:super) and !$game.solid?(@x+8,@y+24) and $game.solid?(@x+8,@y+64,:super)
  102.       @vx+=0.5
  103.       @slide=true
  104.       @model.animation(@animations[:pound],:force=>:true) if @slide
  105.     elsif @crouch and $save[:relics][3] and $game.solid?(@x+16,@y+24,:super) and !$game.solid?(@x-8,@y+24) and $game.solid?(@x-8,@y+64,:super)
  106.       @vx-=0.5
  107.       @slide=true
  108.       @model.animation(@animations[:pound],:force=>:true) if @slide
  109.     end
  110.     @slide=@crouch=nil if @slide and !key(:down)
  111.    
  112.     if @vx.to_i>0
  113.       @model.mirror_x=nil if !@spin
  114.       @vx.to_i.times{if !right ; @x+=1
  115.         4.times{if $game.solid?(@x+14,@y+23,true) and !$game.solid?(@x+14,@y-40) ; @y-=1 ; @vx-=0.1 else break end}
  116.         4.times{|y| if $game.solid?(@x-14,@y+25+y,:super) and !$game.solid?(@x-14,@y+24+y) ; @y+=y ; @vx+=0.05*y; break  end}
  117.         else @vx=0 ; break end}
  118.         if @slide ; $game.stomp(@x+8,@y,:slide) end
  119.     elsif @vx.to_i<0
  120.       @model.mirror_x=true if !@spin
  121.       (-@vx).to_i.times{if !left ; @x-=1
  122.         4.times{if $game.solid?(@x-14,@y+23,true) and !$game.solid?(@x-14,@y-40) ; @y-=1 ; @vx+=0.1 else break end}
  123.         4.times{|y| if $game.solid?(@x+14,@y+25+y,:super) and !$game.solid?(@x+14,@y+24+y) ; @y+=y ; @vx-=0.05*y ; break end}
  124.         else @vx=0 ; break end}
  125.         if @slide ; $game.stomp(@x-8,@y,:slide) end
  126.     end
  127.    
  128.     @vy+=(@water ? 0.5 : 1) if !@water || @vy<4 and !@pound || @pound<0 and !@wall and !@morejump
  129.     @glide=true if !@water and @vy>1 and $save[:relics][5] && key(:up) && key(:jump)
  130.     @vy=2 if !@jump && @glide
  131.    
  132.     if @jump3 and !@cape and $save[:relics][10] and !@pwing and key(:jump,false)
  133.       Snd['PWing'].play
  134.       @pwing=0
  135.       @jump3=@jump1=@jump2=@spin=nil
  136.       @peffect=Trail.new(@x+(@model.mirror_x ? 32 : -32),@y-44,1.4,['Effects/PWing',26,32],[0,1]*38,4,:scalex=>(@model.mirror_x ? -1 : 1))
  137.     elsif @pwing and @pwing<300
  138.       @model.animation(@animations[:jump2],:force=>true,:keep=>true)
  139.       @pwing+=1
  140.       Snd['PWing'].play if @pwing%60==0
  141.       @vy=-(2+@pwing*0.05)
  142.       @peffect.x=@x+(@model.mirror_x ? 32 : -32)
  143.       @peffect.y=@y-44
  144.       @peffect.args[:scalex]=(@model.mirror_x ? -1 : 1)
  145.       @pwing=300 if !key(:jump)
  146.     elsif @pwing
  147.       @peffect.remove
  148.       @pwing=@peffect=nil
  149.     end
  150.    
  151.     if @vy>0
  152.       @vy.to_i.times{if !down ; @y+=1
  153.         $game.stomp(@x,@y,@spin ? :spin : @pound) if !@water
  154.         break if @stomped
  155.         else @vy=0
  156.           @cape=nil
  157.           if @pound and @pound>0
  158.             $game.pow(@x-18,@y+32,36,true)
  159.             Snd['Butt'].play
  160.             9.times{|i| Trace.new(@x-12,@y+12,2,'effects/butt',16,:movex=>offset_x(280+i*20,2),:movey=>offset_y(280+i*20,2))}
  161.             @pound=-30
  162.           end
  163.           break end}
  164.     elsif @vy<0
  165.       @vy.to_i.abs.times{if !up ; @y-=1 else $game.pow(@x-18,@y-40,36,false) ; @vy=0 ; @wall=@model.mirror_y=nil ; break end}
  166.     end
  167.     @poubd=nil if @vy.to_i<1
  168.    
  169.     dn=(@wall ? @wall==:left ? left : right : down)
  170.     dn2=down(true)
  171.    
  172.     if Keypress[:down,false] and $save[:relics][2] and !@pound and !@water and !@slide and !@crouch and !dn
  173.       @pound=0
  174.       @spin=@crouch=nil
  175.       @vy=@vx=0
  176.     elsif @pound
  177.       @model.animation(@animations[:pound],:force=>:true)
  178.       @pound+=1
  179.       @vy=16 if @pound==20
  180.       @pound=nil if @pound==0
  181.     end
  182.    
  183.     return if @mammamia
  184.     if @water
  185.       Trail.new(@x-4,@y-30,3,'effects/bubble',:bubble,0) if rand(60)==0 and $game.map.water?(@x,@y-20)
  186.       if @vy>0 and !dn
  187.         @model.animation(@animations[:swim1],:force=>true)
  188.       elsif @vy<0
  189.         @model.animation(@animations[:swim2],:force=>true)
  190.       elsif dn
  191.         if @vx.to_i !=0
  192.           @model.animation(@animations[:run],:force=>true)
  193.         else
  194.           @model.animation(@animations[:stand],:force=>true)
  195.         end
  196.       end
  197.     elsif !@pound and !@spin and !@slide
  198.       if dn and key(:down)
  199.         @model.animation(@animations[:crouch],:force=>true,:keep=>true)
  200.         @crouch||=0
  201.       elsif dn and @vx.to_i !=0 || @wall
  202.         @model.animation(@animations[:run],:force=>true)
  203.       elsif dn
  204.         @model.animation(@animations[:stand],:force=>true)
  205.       elsif @vy>0
  206.         @model.animation(@animations[:fall],:force=>true,:keep=>true)
  207.       end
  208.       @crouch=nil if !key(:down)
  209.     elsif !@pound and !@slide
  210.       @model.animation(@animations[:spin],:force=>:true)
  211.     end
  212.    
  213.     jumph=($save[:equip][0]==4 ? 4 : $save[:equip][0]==2 ? -4 : 0)
  214.     if !@water and $save[:relics][6] and !dn and @vy>0 and key(:left) && $game.solid?(@x-16,@y-32) || key(:right) && $game.solid?(@x+16,@y-32) and !$game.entities[1].find{|e| e.class==Spikes and !e.harmless and e.collide}
  215.       @vy=0
  216.       @wallslide=true
  217.       @model.animation(@animations[:wallslide],:force=>true)
  218.       @jump1=@jump2=@jump3=@spin=nil
  219.       Trail.new(@x+(@model.mirror_x  ? -30 : 8),@y-48,2.2,['Effects/Slide',22,20],[2,1,0],6) if $count%12==0
  220.       if key(:jump,false)
  221.         jump
  222.         Snd['Jump1'].play
  223.         @vx=(@model.mirror_x ? 10 : -10)
  224.         @jump1=@jump2=@jump3=@spin=nil
  225.         @vy=-20-jumph
  226.         @model.animation(@animations[:jump1],:force=>true)
  227.       end
  228.     else
  229.       @wallslide=nil
  230.     end
  231.    
  232.     if @water
  233.       if key(:jump,false)
  234.         Snd['Swim'].play
  235.         @vy=-8
  236.       end
  237.     else
  238.       @spec_jump=0 if key(:jump,false)
  239.       @spec_jump+=1 if @spec_jump
  240.       @spec_jump=nil if @spec_jump==15 or !key(:jump)
  241.      
  242.       if key(:jump,false) and !@jump1 and dn and !@wall and !@slide
  243.         Snd['Jump'].play
  244.         Snd['Jump1'].play
  245.         @vy=-8-@vx.abs-jumph
  246.         @morejump=(-12-maxspeed-jumph)-@vy
  247.         @morejump+=[@morejump+6+jumph,0].min
  248.         @spec_jump=nil
  249.         @jump1=@jump=true
  250.         @model.animation(@animations[:jump1],:force=>true)
  251.         jump
  252.       elsif @spec_jump || @bouncing and @jump1 and !@jump2 and @vx.abs>3 and dn2
  253.         Snd['Jump'].play
  254.         Snd['Jump2'].play
  255.         @vy=-25-jumph
  256.         @jump2=@jump=true
  257.         @spec_jump=nil
  258.         @model.animation(@animations[:jump2],:force=>true)
  259.         jump
  260.       elsif @spec_jump || @bouncing and @jump2 and !@jump3 and @vx.abs>7 and dn2
  261.         Snd['Jump'].play
  262.         Snd['Jump3'].play
  263.         @vy=-30-jumph
  264.         @jump3=@jump=true
  265.         jump
  266.       elsif dn
  267.         @jump1=@jump2=@jump3=@spin=nil
  268.       end
  269.       @jump=@bouncing=@glide=nil if !key(:jump)
  270.       @jump1=nil if !$save[:relics][0]
  271.       @jump2=nil if !$save[:relics][1]
  272.       @bouncing=true if key(:jump,false) and @vy>0 and [30,40,50,60,70].find{|y| $game.solid?(@x,@y+y,:super)}
  273.      
  274.       if key(:spin,false) and $save[:relics][11] and dn and !@wall
  275.         jump
  276.         Snd['Jump'].play
  277.         Snd['Spin'].play
  278.         @spin=true
  279.         @vy=-8-@vx.abs-jumph
  280.         @morejump=(-12-maxspeed-jumph)-@vy
  281.         @morejump+=[@morejump+6+jumph,0].min
  282.       end
  283.     end
  284.    
  285.     if @wall
  286.       @wallfx||=0
  287.       @wallfx2=Trail.new(@x+(@wall==:left ? 12 : 0),@y+4,1.4,['Effects/Cape',32,32],[0,1,2,1],4,:scalex=>(@wall==:right ? -1 : 1)) if @wallfx%19==0
  288.       @wallfx2.y=@y+4
  289.       @wallfx+=1
  290.       @model.mirror_x=true
  291.       @model.mirror_y=(@wall==:right)
  292.       if !key(@wall) or @wall==:left && !left or @wall==:right && !right
  293.         @vx=(@wall==:left ? -4 : 4)
  294.         @wallfx2.remove
  295.         @model.mirror_y=@wall=@wallfx=@wallfx2=nil
  296.       elsif Keypress[:jump,false]
  297.         jump
  298.         Snd['Jump'].play
  299.         Snd['Jump3'].play
  300.         @jump1=@jump2=@jump3=true
  301.         @cape=true
  302.         @vy=-18
  303.         @vx=(@wall==:left ? 12 : -12)
  304.         @wallfx2.remove
  305.         @model.mirror_y=@wall=@wallfx=@wallfx2=nil
  306.       end
  307.     end
  308.    
  309.     if @glide and !dn
  310.       @glidefx||=0
  311.       @glidefx2=Trail.new(@x+(@model.mirror_x ? 8 : -8),@y-24,1.4,['Effects/Tail',33,36],[0,1,2,3,4,5,4,3,2,1],2,:scalex=>(@model.mirror_x ? 1 : -1),:unstop=>true) if @glidefx%28==0
  312.       @glidefx2.y=@y-24
  313.       @glidefx2.x=@x+(@model.mirror_x ? 8 : -8)
  314.       @glidefx+=1
  315.     else
  316.       @glidefx2.remove if @glidefx2
  317.       @glidefx=@glidefx2=nil
  318.     end
  319.    
  320.     if !@wall and key(:shoot,false) and !key(:up)
  321.       shoot(false,$save[:equip][1]) if $save[:equip][1]
  322.     elsif !@wall and key(:shoot,false)
  323.       shoot(true,$save[:equip][2]) if $save[:equip][2]
  324.     end
  325.    
  326.     if $save[:equip][0]==7 and $count%30==0 and $save[:hp]< $save[:max_hp]
  327.       heal=[$save[:max_hp]/300+1,$save[:max_hp]-$save[:hp]].min
  328.       Info.new(@x-7,@y-40,"+#{heal}","Damage2")
  329.       $save[:hp]+=heal
  330.     end
  331.    
  332.     @firebar=nil if @firebar and (@firebar[1]-=1)==0
  333.     if @firebar
  334.       @firebar[3]||=(@model.mirror_x ? 270 : 90) if $save[:magic][5][1]==5 and @firebar[0]==10 and Keypress[:shoot]
  335.       @firebar[3]+=(@model.mirror_x ? -8 : 8) if @firebar[3]
  336.       angle=(@firebar[3] ? @firebar[3] : (@model.mirror_x ? 270 : 90))
  337.       @firebar[2].each{|bar| dist=(@firebar[2].index(bar)+1)*16 ; bar.x=@x-8+offset_x(angle,dist) ; bar.y=@y-(@crouch ? 8 : 24)+offset_y(angle,dist)}
  338.       if @firebar[3] and Keypress[:shoot]
  339.         @firebar[1]=15
  340.         @firebar[2].each{|bar| bar.args[:repeat]=15; bar.init if $game.missing(bar)}
  341.       end
  342.       if @firebar[3] and $save[:mp]>1
  343.         $save[:mp]-=2
  344.       elsif @firebar[3]
  345.         @firebar=nil
  346.       end
  347.     end
  348.    
  349.     if @poisonball and $save[:mp]>=[40-@poisonball/5,1].max and Keypress[:shoot]
  350.       @poisonball+=1
  351.       return @poisonball=nil if @poisonball==0 and !@poisonball2
  352.       @delay=120
  353.       if @poisonball>0 and @poisonball%5==0
  354.         @model.animation(@animations[:shoot],:force=>true,:solid=>true,:repeat=>true)
  355.         $save[:mp]-=[40-@poisonball/5,1].max
  356.         Snd['Fireball'].play
  357.         Projectile.new(@x-8,@y-8,2,'Projectiles/Poisonball',[16,16],60+$save[:intelligence],:vx=>@model.mirror_x ? -6-rand(7) : 6+rand(7),:bounce=>-6,:angle=>0,:rotate=>@model.mirror_x ? -10-rand(20) : 10+rand(20),:element=>8,:wallbounce=>0,:fx=>1,:remove2=>[-4,-4,'Effects/Poison',16],:id=>2)
  358.       end
  359.     elsif @poisonball and !Keypress[:shoot] and !@poisonball2
  360.       @poisonball2=15
  361.     elsif @poisonball and !Keypress[:shoot] and @poisonball2>0
  362.       @poisonball2-=1
  363.     elsif @poisonball
  364.       @poisonball=@poisonball2=nil
  365.     end
  366.    
  367.     if @sword
  368.       @model.mirror_x=@sword[1]
  369.       @sword[0].x=@x+(@model.mirror_x ? -([76,118,160,188][$save[:magic][8][1]]) : 16)
  370.       @sword[0].y=@y-[40,61,103,131][$save[:magic][8][1]]
  371.       @sword=nil if $game.missing(@sword[0])
  372.     end
  373.    
  374.     @blast=@blast2=nil if @blast and (@blast-=1)==0##$game.missing(@blast)
  375.    
  376.     if $save[:equip][2]==11
  377.       return if @reload and (@reload-=1)>0
  378.       if key(:up)
  379.         @aim||=180
  380.         @aim+=(key(:down) ? 1 : 2)*(@model.mirror_x ? 1 : -1) if @aim>0
  381.       else
  382.         @aim=@reload=nil
  383.       end
  384.     end
  385.    
  386.     @boomerang=nil if @boomerang and $game.missing(@boomerang)
  387.    
  388.     if @rotodisc
  389.       @rotodisc[0].init if $game.missing(@rotodisc[0])
  390.       @rotodisc[0].x=@x-16+offset_x(@rotodisc[1],128)
  391.       @rotodisc[0].y=@y-16+offset_y(@rotodisc[1],128)
  392.       @rotodisc[1]+=4
  393.       if $save[:stars]<1 or $save[:equip][2] != 8
  394.         @rotodisc[0].remove
  395.         @rotodisc=nil
  396.       end
  397.       $save[:stars]-=1 if @rotodisc and @rotodisc[1]%80==0
  398.     end
  399.    
  400.     if @rainbow and Keypress[:shoot] and $save[:mp]>0
  401.       level=$save[:magic][11][1]
  402.       attack=set_att(11)
  403.       $save[:mp]-=(level==4 ? 1 : 2)
  404.       angle=angle(@x,@y,@rainbow[0],@rainbow[1])
  405.       Projectile.new(@x-16,@y-16,0,'Projectiles/Rainbow',[32,32],attack,:through=>(level==4),:z=>1.4,:repeat=>(60+level*30),:id=>11,:angle=>angle,:mirror_x=>(angle>=180 ? true : false)) if @rainbow[0] != @x or @rainbow[1] != @y
  406.       @rainbow=[@x,@y]
  407.       @delay=6
  408.     elsif @rainbow
  409.       @rainbow=nil
  410.     end
  411.    
  412.     if @noob
  413.       @noob+=1
  414.       list=[]
  415.       $game.entities[1].each{|ent| list << ent if ent.respond_to?(:damage) and !ent.dead? and distance(ent.x+ent.size[0]/2,ent.y+ent.size[1]/2,@x,@y)<=320}
  416.       list.sample.damage((1+@noob/600).to_s,nil,nil) if !list.empty?
  417.       @noob=nil if !Keypress[:shoot]
  418.     end
  419.    
  420.     if @starman
  421.       @inv=1
  422.       Projectile.new(@x-15,@y-14,0,'Projectiles/Starman',[30,38],$save[:strength]+100,:through=>true,:setinv=>1)
  423.       @starman=Snd["Starman"].play if !@starman.playing?
  424.       $save[:stars]-=1 if $count%2==0
  425.       if $save[:stars]==0
  426.         @starman.stop
  427.         @starman=nil
  428.       end
  429.     end
  430.    
  431.     if @charge and Keypress[:shoot]
  432.       @charge+=1
  433.       8.times{|i| Trail.new(@x+offset_x(i*45,64),@y+offset_y(i*45,64),3,['Effects/ChaosF',11,11,0],(0..7).to_a.shuffle,4,:movex=>-offset_x(i*45,@charge<60 ? 1 : -1),:movey=>-offset_y(i*45,@charge<60 ? 1 : -1),:unstop=>true)} if @charge%24==0
  434.       Snd['Bowsa'].play if @charge==60
  435.     elsif @charge
  436.       if @charge>=60
  437.         attack=120
  438.         id=14
  439.         Snd['Fireball'].play
  440.         Projectile.new(@x-8,@y-8,2,'Projectiles/Fireball2',[17,17],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-9,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>3,:wallbounce=>0,:fx=>1,:id=>id,:trail=>[4,'Projectiles/Fireball2 Trail',15,15,3,2],:remove=>[-16,-16,'Effects/Fireball Trail',48,48,4])
  441.         Snd['Fireball2'].play
  442.         Projectile.new(@x-8,@y-8,2,'Projectiles/Iceball',[16,16],attack+$save[:intelligence],:vy=>-12,:vx=>@model.mirror_x ? -4 : 4,:bounce=>-11,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>4,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Iceball Trail',16,16,3,2],:remove=>[-16,-16,'Effects/Iceball Trail',48,48,4],:id=>id)
  443.         Snd['Fireball'].play
  444.         Projectile.new(@x-8,@y-8,2,'Projectiles/Poisonball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-6,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>8,:wallbounce=>0,:fx=>1,:remove2=>[-4,-4,'Effects/Poison',16],:id=>id)
  445.         Snd['Darkball'].play
  446.         Projectile.new(@x-16,@y-16,2,'Projectiles/Darkball',[33,33],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -1-3-rand(8) : 1+3+rand(8),:bounce=>-3-rand(15),:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>9,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Darkball Trail',15,15,3,2],:remove2=>[4,4,'Effects/Curse',16],:id=>id)
  447.         Snd['TCharge'].play
  448.         Projectile.new(@x-8,@y-8,2,'Projectiles/Boltball',[16,16],attack+$save[:intelligence],:vy=>-4,:vx=>@model.mirror_x ? -10 : 10,:bounce=>-8,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>5,:wallbounce=>0,:through=>true,:fx=>1,:trail=>[4,'Projectiles/Boltball Trail',16,16,3,2],:remove=>[-16,-16,'Effects/Boltball Trail',48,48,4],:id=>id)
  449.         Snd['Priest'].play
  450.         Projectile.new(@x-16,@y-16,3,'Projectiles/Lightball',[32,32],attack+$save[:intelligence],:speed=>9,:dir=>@model.mirror_x ? 270 : 90,:rotate=>@model.mirror_x ? -10 : 10,:element=>7,:trace=>[true,1,24],:id=>id,:z=>3,:remove=>[-8,-8,'Effects/Lightball Trail',48,48,4])
  451.         Snd['Darkball'].play
  452.         Projectile.new(@x-14,@y-14,2,'Projectiles/Shadeball',[28,28],attack+$save[:intelligence],:vy=>-2,:vx=>@model.mirror_x ? -8 : 8,:bounce=>-12,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>6,:wallbounce=>0,:fx=>1,:id=>id,:trace=>[true,1,24],:remove=>[-16,-16,'Effects/Shadeball Trail',48,48,4],:antigrav=>true)
  453.         Snd['Stoneball'].play
  454.         Projectile.new(@x-8,@y-8,2,'Projectiles/Stoneball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>0,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>10,:wallbounce=>0,:fx=>1,:id=>id,:trail=>[4,'Projectiles/Stoneball Trail',15,15,3,2],:remove=>[-5,-4,'Effects/Stoneball Trail',22,20,4])
  455.       end
  456.       @charge=nil
  457.     end
  458.   end
  459.  
  460.   def draw
  461.     @model.skin=['Mario','Koopa','Metal','Wario','Luigi','Boo','Fire','Life','Magic','Athlete','Ice','Thor','Shadow'][$save[:equip][0]]
  462.     if $save[:equip][0]==11 && @last != 11 or @last==11 && $save[:equip][0]!=11
  463.       @last=$save[:equip][0]
  464.       a=@model.order[4]
  465.       @model.order[4]=@model.order[6]
  466.       @model.order[6]=a
  467.       a=@model.order[5]
  468.       @model.order[5]=@model.order[7]
  469.       @model.order[7]=a
  470.     end
  471.    
  472.     @model.animation(Keypress[:jump] ? @animations[:destone] : @animations[:stand],:force=>true) if $save[:status]=='STONE'
  473.     @crouch+=1 if @crouch and @crouch<10
  474.     if $save[:status] != 'GOOD'
  475.       @status ||= 600
  476.       @status-=1 if $save[:status] != 'STONE'
  477.       $save[:status]='GOOD' if @status<=0
  478.     else
  479.       @status=nil
  480.     end
  481.     if $save[:status]=='STONE' and Keypress[:jump,false]
  482.       @status-=60
  483.       Snd[@status==0 ? 'Bricks' : 'Stone'].play
  484.     end
  485.    
  486.     if @aim
  487.       # dir=(@model.mirror_x ? -48 : 48)
  488.       dir=48
  489.       x=@x+offset_x(@aim,dir) ; y=@y+offset_y(@aim,dir)
  490.       Img['Enemies/SK Crosshair'].draw_rot(x,y,3,0)
  491.       Img['Enemies/SK Gun'].draw_rot(@x,@y,3,angle(@x,@y,x,y))
  492.       $screen.draw_line(@x,@y,0xffff0000,@x+offset_x(@aim,dir*15),@y+offset_y(@aim,dir*15),0x00000000,3)
  493.     end
  494.    
  495.     @model.x=@x+(@wall ? @wall==:left ? 6 : -5 : @wallslide ? @model.mirror_x ? 5 : -4 : 0) if !@frozen
  496.     @model.y=@y-5+(@crouch ? [6,6,7,8,8,9,9,10,11,12,13][@crouch] : 7)+(@pound ? 22 : 0)+(@slide ? 14 : 0)+(@warp ? 8 : 0) if !@frozen
  497.     @model.update if !@frozen
  498.    
  499.     return if @inv and !@inv2 and $count%3==0
  500.     if @starman
  501.       $shaders[4].enable(1.5)
  502.     else
  503.       $shaders[0].enable(1.5) if $save[:status]=='STONE'
  504.       $shaders[1].enable(1.5) if $save[:status]=='CURSE'
  505.       $shaders[2].enable(1.5) if $save[:status]=='POISON'
  506.       $shaders[3].enable(1.5) if $save[:status]=='PROTEC'
  507.     end
  508.     @model.draw
  509.     if @starman
  510.       $shaders[4].disable(1.5)
  511.     else
  512.       $shaders[0].disable(1.5) if $save[:status]=='STONE'
  513.       $shaders[1].disable(1.5) if $save[:status]=='CURSE'
  514.       $shaders[2].disable(1.5) if $save[:status]=='POISON'
  515.       $shaders[3].disable(1.5) if $save[:status]=='PROTEC'
  516.     end
  517.     Tls['System/Status',48,16][['POISON','CURSE','STONE',nil,'PROTEC'].index($save[:status])].draw(@x-24,@y-64,4,1,1,(@status>60 or $count%8<4) ? 0xffffffff : 0x80ffffff) if $save[:status] != 'GOOD'
  518.     @morejump=nil if @morejump and (@morejump+=1)>=0 || !key(:jump) && !@spin && !key(:spin)
  519.     @frozen=true
  520.     @solid=($save[:equip][0]==1)
  521.   end
  522.  
  523.   def bounce
  524.     @inv=8
  525.     return if @pound or @slide
  526.     jump
  527.     @model.animation(@animations[:jump1],:force=>true) if !@slide
  528.     @vy=-(($save[:relics][7] and @spin && key(:spin) || !@spin && key(:jump)) ? 20 : 10)
  529.     @inv2=true if @inv==8
  530.     @stomped=true
  531.   end
  532.  
  533.   def down(spec=false)
  534.     $down=self
  535.     5.times{|x| ($down=nil;return true) if $game.solid?(@x-14+x*7,@y+24,spec ? :super : true)}
  536.     false
  537.   end
  538.  
  539.   def down?
  540.     @down||=down
  541.     @down
  542.   end
  543.  
  544.   def up
  545.     5.times{|x| return true if $game.solid?(@x-14+x*7,@y-40)}
  546.     false
  547.   end
  548.  
  549.   def right
  550.     9.times{|y| return true if $game.solid?(@x+15,[@y-36+y*7,@y+19].min)}
  551.     false
  552.   end
  553.  
  554.   def left
  555.     9.times{|y| return true if $game.solid?(@x-15,[@y-36+y*7,@y+19].min)}
  556.     false
  557.   end
  558.  
  559.   def dir;@model.mirror_x ? :left : :right;end
  560.  
  561.   def shoot(weapon,id)
  562.     if !weapon
  563.       return if $save[:mp]<$items[:magic][id][:use]
  564.       $save[:mp]-=$items[:magic][id][:use]
  565.       @model.animation(@animations[:shoot],:force=>true,:override=>true,:repeat=>true)
  566.       @delay=$items[:magic][id][:recoil].to_f*60
  567.       @delay*=0.5 if $save[:equip][6]==5
  568.       @delay*=0.25 if $save[:equip][6]==7
  569.       @delay-=[($save[:mp_regen]-1)*6,0].max
  570.       level=$save[:magic][id][1]
  571.       case id
  572.         when 0
  573.         Snd['Fireball'].play
  574.         attack=set_att(0)
  575.         if level==2
  576.           Projectile.new(@x-8,@y-8,2,'Projectiles/Fireball2',[17,17],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-9,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>3,:wallbounce=>0,:fx=>1,:id=>id,:trail=>[4,'Projectiles/Fireball2 Trail',15,15,3,2],:remove=>[-16,-16,'Effects/Fireball Trail',48,48,4])
  577.         else
  578.           Projectile.new(@x-8,@y-8,2,'Projectiles/Fireball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-9,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>3,:wallbounce=>0,:fx=>1,:remove2=>[-4,-4,'Effects/Fireball Trace',16],:id=>id)
  579.         end
  580.        
  581.         when 1
  582.         Snd['Fireball2'].play
  583.         attack=set_att(1)
  584.         Projectile.new(@x-8,@y-8,2,'Projectiles/Iceball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -4 : 4,:bounce=>-11,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>4,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Iceball Trail',16,16,3,2],:remove=>[-16,-16,'Effects/Iceball Trail',48,48,4],:id=>id)
  585.         Projectile.new(@x-8,@y-8,2,'Projectiles/Iceball',[16,16],attack-5+$save[:intelligence],:vy=>-12,:vx=>@model.mirror_x ? -4 : 4,:bounce=>-9,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>4,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Iceball Trail',16,16,3,2],:remove=>[-16,-16,'Effects/Iceball Trail',48,48,4],:id=>id) if level==2
  586.        
  587.         when 2
  588.         Snd['Fireball'].play
  589.         attack=set_att(2)
  590.         Projectile.new(@x-8,@y-8,2,'Projectiles/Poisonball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-6,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>8,:wallbounce=>0,:fx=>1,:remove2=>[-4,-4,'Effects/Poison',16],:id=>id)
  591.         @poisonball||=-15 if level==2
  592.        
  593.         when 3
  594.         # Projectile.new(@x-40,@y-40,0,'Projectiles/TCharge',[80,80],120+$save[:intelligence],:harmless=>true,:spec1=>true,:targetx=>@x+(@model.mirror_x ? -120 : 40),:targety=>@y-264,:id=>id,:notoffmap=>true)
  595.         if !@_thunder or @_thunder.removed or $game.missing(@_thunder)
  596.           return $save[:mp]+=$items[:magic][id][:use] if @_thunderwait and $count-@_thunderwait<80
  597.           @_thunder=Projectile.new(@x+(@model.mirror_x ? -120 : 40),@y-264,0,'Projectiles/TCharge',[80,80],120+$save[:intelligence],:harmless=>true,:spec1=>true,:id=>id,:notoffmap=>true)
  598.         elsif @_thunder and level>0
  599.           @_thunder.instance_variable_set(:@wait,1)
  600.           @_thunder.args[:spec1a]=(@model.mirror_x ? -4 : 4) if level==3
  601.           @_thunderwait=$count if level==1
  602.         else
  603.           $save[:mp]+=$items[:magic][id][:use]
  604.         end
  605.        
  606.         when 4
  607.         attack=set_att(4)
  608.         Snd['Darkball'].play
  609.         Projectile.new(@x-16,@y-16,2,'Projectiles/Darkball',[33,33],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -1-level-rand(8) : 1+level+rand(8),:bounce=>-level-rand(15),:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>9,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Darkball Trail',15,15,3,2],:remove2=>[4,4,'Effects/Curse',16],:id=>id)
  610.        
  611.         when 5
  612.         @firebar||=[0,60,[],nil]
  613.         if @firebar[0]<level+5
  614.           Snd['Fireball'].play
  615.           @firebar[0]+=1
  616.           _time=60+level*20
  617.           @firebar[1]=_time
  618.           @firebar[2].each{|bar| bar.args[:repeat]=_time; bar.init if $game.missing(bar)}
  619.           @firebar[2]<<Projectile.new(@x-8+@firebar[0]*(@model.mirror_x ? -16 : 16),@y-24,0,'Projectiles/Fireball',[16,16],50+$save[:intelligence],:angle=>0,:rotate=>@model.mirror_x ? -16 : 16,:element=>3,:repeat=>_time,:through=>true,:notoffmap=>true,:z=>3,:id=>id)
  620.         else
  621.           $save[:mp]+=20
  622.         end
  623.        
  624.         when 6
  625.         Snd['KO'].play
  626.         Projectile.new(@x,@y-32,2,['Projectiles/Goombavenger',32,32,0],[32,32],$items[:magic][6][:attack]+$save[:intelligence],:vx=>@model.mirror_x ? -4 : 4,:vy=>-4,:stop=>true,:animation=>[2,8],:through=>true,:wallbounce=>(level==1 ? 3 : 1),:fx=>0,:climb=>2,:id=>id)
  627.        
  628.         when 7
  629.         Snd['KO'].play
  630.         attack=set_att(7)
  631.         Projectile.new(@x-10,@y-32,3,'Projectiles/Reboundst2',[20,18],attack+$save[:intelligence]/8,:dir=>(@model.mirror_x ? 225 : 135),:speed=>8+level,:bounce=>4+level,:through=>true,:line=>true,:id=>id)
  632.        
  633.         when 8
  634.         return $save[:mp]+=100 if @sword
  635.         attack=set_att(8)
  636.         Snd['Sword'].play
  637.         if level==0
  638.           @sword=[Projectile.new(@x+(@model.mirror_x ? -76 : 16),@y-40,0,'Projectiles/Astral1',[60,60],attack+$save[:intelligence],:repeat=>16,:dir=>(@model.mirror_x ? 315 : 45),:rotate=>@model.mirror_x ? -8 : 8,:through=>true,:origin=>[(@model.mirror_x ? 60 : 0),30,0.5,0.88],:id=>id,:mirror_x=>@model.mirror_x,:element=>7),@model.mirror_x]
  639.         elsif level==1
  640.           @sword=[Projectile.new(@x+(@model.mirror_x ? -118 : 16),@y-61,0,'Projectiles/Astral2',[102,102],attack+$save[:intelligence],:repeat=>32,:dir=>(@model.mirror_x ? 315 : 45),:rotate=>@model.mirror_x ? -8 : 8,:through=>true,:origin=>[(@model.mirror_x ? 102 : 0),51,0.5,0.92],:id=>id,:mirror_x=>@model.mirror_x,:element=>7),@model.mirror_x]
  641.         elsif level==2
  642.           @sword=[Projectile.new(@x+(@model.mirror_x ? -160 : 16),@y-103,0,'Projectiles/Astral3',[140,140],attack+$save[:intelligence],:repeat=>32,:dir=>(@model.mirror_x ? 315 : 45),:rotate=>@model.mirror_x ? -8 : 8,:through=>true,:origin=>[(@model.mirror_x ? 144 : 0),72,0.5,0.93],:id=>id,:mirror_x=>@model.mirror_x,:element=>7),@model.mirror_x]
  643.         elsif level==3
  644.           @sword=[Projectile.new(@x+(@model.mirror_x ? -188 : 16),@y-131,0,['Projectiles/Astral4',72,172,0],[172,172],attack+$save[:intelligence],:animation=>[5,4],:repeat=>2,:dir=>(@model.mirror_x ? 315 : 45),:rotate=>@model.mirror_x ? -4 : 4,:through=>true,:origin=>[(@model.mirror_x ? 172 : 0),120,0.5,0.9],:id=>id,:mirror_x=>@model.mirror_x,:element=>7,:unstoppable=>true),@model.mirror_x]
  645.         end
  646.        
  647.         when 9
  648.         Snd['KO'].play
  649.         attack=set_att(9)
  650.         Projectile.new(@x-8,@y-8,2,['Projectiles/Beet',27,32,0],[27,32],attack+$save[:intelligence],:sequence=>[0,1,2,1],:animation=>[4,4],:vy=>-12,:vx=>@model.mirror_x ? -4 : 4,:bounce=>-9,:angle=>0,:element=>0,:fx=>1,:id=>id,:back=>3+level,:through=>true,:bouncenemy=>true,:z=>3,:pow=>true,:superbeet=>(level==3))
  651.      
  652.         when 10
  653.         return $save[:mp]+=25 if @blast2 and @blast2[1]>0
  654.         attack=set_att(10)
  655.         Snd['Blast'].play
  656.         if !@blast
  657.           @blast=60
  658.           @blast2=[0,level>0 ?  0 : 60]
  659.         elsif @blast2[0]<level
  660.           @blast2[0]+=1
  661.           @blast2[1]=60 if @blast2[0]==level
  662.         end
  663.         dx=(@model.mirror_x ? -58 : 16)+[0,8,12,4,8][@blast2[0]]*(@model.mirror_x ? -1 : 1)
  664.         dy=-32+[0,12,-4,-16,8][@blast2[0]]
  665.         scale=(level==4 ? 2 : level>1 ? 1.5 : 1)
  666.         Projectile.new(@x+dx-(scale>1 ? 42.0/(scale+1) : 0),@y+dy-(scale>1 ? 40.0/(scale+1) : 0),0,['Projectiles/Blast',42,40,0],[42*scale,40*scale],attack+$save[:intelligence]/(3.0/4),:animation=>[4,4],:through=>true,:id=>id,:angle=>0,:scale=>scale,:movex=>(level==4 ? @model.mirror_x ? -1 : 1 : 0),:movey=>(level==4 ? (-1+@blast[0]%3) : 0))
  667.        
  668.         when 11
  669.         @rainbow=[@x,@y]
  670.        
  671.         when 12
  672.         @noob=0
  673.        
  674.         when 13
  675.         Snd['Magi'].play
  676.         attack=set_att(13)
  677.        
  678.         select=nil
  679.         targets=[]
  680.         $game.entities[1].each{|enemy| targets << enemy if enemy.class != Projectile and enemy.class != Spikes and !enemy.dead? and dir==:left && enemy.x+enemy.size[0]<@x || dir==:right && enemy.x>@x and enemy.x+enemy.size[0]>$game.scx and enemy.x<$game.scx+640 and enemy.y+enemy.size[1]>$game.scy and enemy.y<$game.scy+480}
  681.         if !targets.empty?
  682.           distances={}
  683.           targets.each{|target| distances[distance(@x,@y,target.x+target.size[0]/2,target.y+target.size[1]/2)]=target}
  684.           select=distances[distances.keys.min]
  685.         end
  686.        
  687.         if select and level==4
  688.           Projectile.new(@x-8,@y-24,1,['Projectiles/Magi',32,32,0],[32,32],attack+$save[:intelligence],:rotate=>(dir==:left ? -8 : 8),:dir=>(select ? angle(@x,@y,select.x+select.size[0]/2,select.y+select.size[1]/2) : dir==:left ? 270 : 90),:speed=>8+level,:id=>id,:through=>level+1,:z=>3,:magic=>true,:target=>select,:limit=>60,:setinv=>30)
  689.         else
  690.           Projectile.new(@x-8,@y-24,3,['Projectiles/Magi',32,32,0],[32,32],attack+$save[:intelligence],:rotate=>(dir==:left ? -8 : 8),:dir=>(select ? angle(@x,@y,select.x+select.size[0]/2,select.y+select.size[1]/2) : dir==:left ? 270 : 90),:speed=>8+level,:id=>id,:through=>level+1,:z=>3,:magic=>true,:setinv=>30)
  691.         end
  692.        
  693.         when 14
  694.         proj=rand([level+1,8].min)
  695.         attack=set_att(14)
  696.        
  697.         case proj
  698.           when 0
  699.           Snd['TCharge'].play
  700.           Projectile.new(@x-8,@y-8,2,'Projectiles/Boltball',[16,16],attack+$save[:intelligence],:vy=>-4,:vx=>@model.mirror_x ? -10 : 10,:bounce=>-8,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>5,:wallbounce=>0,:through=>true,:fx=>1,:trail=>[4,'Projectiles/Boltball Trail',16,16,3,2],:remove=>[-16,-16,'Effects/Boltball Trail',48,48,4],:id=>id)
  701.           when 1
  702.           Snd['Darkball'].play
  703.           Projectile.new(@x-14,@y-14,2,'Projectiles/Shadeball',[28,28],attack+$save[:intelligence],:vy=>-2,:vx=>@model.mirror_x ? -8 : 8,:bounce=>-12,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>6,:wallbounce=>0,:fx=>1,:id=>id,:trace=>[true,1,24],:remove=>[-16,-16,'Effects/Shadeball Trail',48,48,4],:antigrav=>true)
  704.           when 2
  705.           Snd['Stoneball'].play
  706.           Projectile.new(@x-8,@y-8,2,'Projectiles/Stoneball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>0,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>10,:wallbounce=>0,:fx=>1,:id=>id,:trail=>[4,'Projectiles/Stoneball Trail',15,15,3,2],:remove=>[-5,-4,'Effects/Stoneball Trail',22,20,4])
  707.           when 3
  708.           Snd['Fireball'].play
  709.           Projectile.new(@x-8,@y-8,2,'Projectiles/Fireball2',[17,17],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-9,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>3,:wallbounce=>0,:fx=>1,:id=>id,:trail=>[4,'Projectiles/Fireball2 Trail',15,15,3,2],:remove=>[-16,-16,'Effects/Fireball Trail',48,48,4])
  710.           when 4
  711.           Snd['Fireball2'].play
  712.           Projectile.new(@x-8,@y-8,2,'Projectiles/Iceball',[16,16],attack+$save[:intelligence],:vy=>-12,:vx=>@model.mirror_x ? -4 : 4,:bounce=>-11,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>4,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Iceball Trail',16,16,3,2],:remove=>[-16,-16,'Effects/Iceball Trail',48,48,4],:id=>id)
  713.           when 5
  714.           Snd['Fireball'].play
  715.           Projectile.new(@x-8,@y-8,2,'Projectiles/Poisonball',[16,16],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -6 : 6,:bounce=>-6,:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>8,:wallbounce=>0,:fx=>1,:remove2=>[-4,-4,'Effects/Poison',16],:id=>id)
  716.           when 6
  717.           Snd['Darkball'].play
  718.           Projectile.new(@x-16,@y-16,2,'Projectiles/Darkball',[33,33],attack+$save[:intelligence],:vy=>-6,:vx=>@model.mirror_x ? -1-3-rand(8) : 1+3+rand(8),:bounce=>-3-rand(15),:angle=>0,:rotate=>@model.mirror_x ? -10 : 10,:element=>9,:wallbounce=>0,:fx=>1,:trail=>[4,'Projectiles/Darkball Trail',15,15,3,2],:remove2=>[4,4,'Effects/Curse',16],:id=>id)
  719.           when 7
  720.           Snd['Priest'].play
  721.           Projectile.new(@x-8,@y-16,3,'Projectiles/Lightball',[32,32],attack+$save[:intelligence],:speed=>9,:dir=>@model.mirror_x ? 270 : 90,:rotate=>@model.mirror_x ? -10 : 10,:element=>7,:trace=>[true,1,24],:id=>id,:z=>3,:remove=>[-8,-8,'Effects/Lightball Trail',48,48,4])
  722.         end
  723.         @charge=0 if level==9
  724.       end
  725.     else
  726.       return if $items[:weapon][id][:use].class != String and $save[:stars]<$items[:weapon][id][:use]/([$save[:equip][6],$save[:equip][7]].include?(8) ? 2 : 1)
  727.       $save[:stars]-=$items[:weapon][id][:use]/([$save[:equip][6],$save[:equip][7]].include?(8) ? 2 : 1) if $items[:weapon][id][:use].class != String
  728.       @model.animation(@animations[:shoot],:force=>true,:override=>true,:repeat=>true)
  729.       case id
  730.         when 0
  731.         Snd['KO'].play
  732.         Projectile.new(@x,@y-32,2,['Projectiles/Green Shell',32,32,0],[32,32],10+$save[:strength],:vx=>@model.mirror_x ? -10 : 10,:vy=>-4,:stop=>true,:element=>0,:animation=>[3,4],:through=>true,:wallbounce=>3,:fx=>0)
  733.         when 1
  734.         Snd['KO'].play
  735.         Projectile.new(@x,@y-32,2,['Projectiles/Yellow Shell',32,32,0],[32,32],25+$save[:strength],:vx=>@model.mirror_x ? -10 : 10,:vy=>-4,:element=>0,:animation=>[3,4],:through=>true,:wallbounce=>3,:fx=>0,:bounce=>-12)
  736.         when 2
  737.         Snd['Hammer'].play
  738.         Projectile.new(@x-16,@y-32,2,'Projectiles/Hammer',[32,32],40+$save[:strength],:vx=>@model.mirror_x ? -5 : 5,:vy=>-15,:element=>0,:angle=>0,:rotate=>@model.mirror_x ? -15 : 15,:z=>2.2,:notoff0=>true)
  739.         when 3
  740.         return $save[:stars]+=40 if $game.stopped
  741.         $game.stop_time(Snd['Timestop'].play)
  742.         when 4
  743.         Snd['KO'].play
  744.         Projectile.new(@x,@y-32,2,['Projectiles/Blue Shell',32,32,0],[32,32],40+$save[:strength],:vx=>@model.mirror_x ? -10 : 10,:stop=>true,:element=>0,:animation=>[3,4],:through=>true,:wallbounce=>3,:fx=>0,:fly=>true)
  745.         when 5
  746.         Snd['KO'].play
  747.         Projectile.new(@x,@y-32,2,['Projectiles/Bomb',28,38,0,0],[28,38],200+$save[:strength],:vx=>@model.mirror_x ? -8 : 8,:vy=>-8,:bounce=>-16,:spec1=>true,:harmless=>true,:traction=>0.5,:wallbounce=>-1)
  748.         when 6
  749.         Snd['Hammer'].play
  750.         Projectile.new(@x-16,@y-32,2,'Projectiles/GoldHammer',[32,32],77,:vx=>@model.mirror_x ? -5 : 5,:vy=>-15,:element=>0,:angle=>0,:rotate=>@model.mirror_x ? -15 : 15,:z=>2.2,:absolute=>true,:notoff0=>true)
  751.         when 7
  752.         Snd['KO'].play
  753.         Projectile.new(@x-10,@y-32,3,'Projectiles/Reboundst',[20,18],20+$save[:strength],:dir=>(@model.mirror_x ? 225 : 135),:speed=>8,:bounce=>4,:through=>true,:line=>true)
  754.        
  755.         when 8
  756.         if @rotodisc
  757.           @rotodisc[0].remove
  758.           @rotodisc=nil
  759.         else
  760.           @rotodisc=[Projectile.new(@x+16,@y-16,0,['Projectiles/Rotodisc',32,32,0],[32,32],30+$save[:strength],:animation=>[21,8],:z=>3,:notoffmap=>true,:repeat=>-1,:through=>true),0]
  761.         end
  762.        
  763.         when 9
  764.         return $save[:stars]+=60 if @inv and @inv>30
  765.         Trace.new(@x-16,@y-16,2,'Icons/Weapon/9',8)
  766.         # Projectile.new(@x-10,@y-32,3,'Projectiles/Reboundst',[20,18],20+$save[:strength]/8,:dir=>(@model.mirror_x ? 225 : 135),:speed=>8,:bounce=>4,:through=>true,:line=>true)
  767.         @inv=300
  768.        
  769.         when 10
  770.         Snd['Throw'].play
  771.         Projectile.new(@x-20,@y-24,3,'Projectiles/Knife',[19,7],5+$save[:strength],:dir=>(@model.mirror_x ? 270 : 90),:speed=>24,:bounce=>1,:mirrorx=>@model.mirror_x,:element=>1)
  772.        
  773.         when 11
  774.         Snd['Barret'].play
  775.         # dir=(@model.mirror_x ? -48 : 48)
  776.         dir=48
  777.         @aim||=0
  778.         x=@x+offset_x(@aim,dir) ; y=@y+offset_y(@aim,dir)
  779.         Trace.new(@x,@y,2,'Effects/Firecone',20,:angle=>angle(@x,@y,x,y))
  780.         Projectile.new(@x,@y,3,'Projectiles/Barret',[18,18],500,:dir=>(angl=angle(0,0,offset_x(@aim,dir),offset_y(@aim,dir))),:angle=>angl,:speed=>60,:element=>1,:bounce=>1,:through=>true,:accurate=>true)
  781.         @aim=nil
  782.         @reload=180
  783.        
  784.         when 12
  785.         return $save[:stars]+=20 if @boomerang
  786.         @boomerang=Projectile.new(@x-15,@y-16,1,'Projectiles/Boomerang',[32,32],80+$save[:strength],:dir=>(@model.mirror_x ? 315 : 45),:speed=>8,:through=>true,:element=>2,:rotate=>(dir==:left ? -16 : 16),:boomerang=>0,:target=>self,:z=>3,:notoffmap=>true,:reach=>32,:accuracy=>3)
  787.        
  788.         when 13
  789.         Snd['Guard'].play
  790.         Trace.new(@x-16,@y-16,2,'Icons/Weapon/13',8)
  791.         $save[:status]='PROTEC'
  792.         @status=900
  793.        
  794.         when 14
  795.         Snd['KO'].play
  796.         Projectile.new(@x-16,@y-72,3,['Objects/POW',32,32,0],[32,32],0,:animation=>[4,8],:dir=>180,:speed=>0,:harmless=>true,:pow=>true)
  797.        
  798.         when 15
  799.         Snd['Throw'].play
  800.         Projectile.new(@x-16,@y-24,3,'Projectiles/Shuriken',[16,16],25+($save[:strength]*1.5).to_i,:dir=>(@model.mirror_x ? 270 : 90),:rotate=>(@model.mirror_x ? 32 : -32),:speed=>30,:bounce=>1,:mirror_x=>@model.mirror_x,:element=>1,:shuri=>true)
  801.        
  802.         when 16
  803.         if @starman
  804.           @starman.stop
  805.           @starman=nil
  806.         else
  807.           @starman=Snd["Starman"].play
  808.         end
  809.       end
  810.     end
  811.   end
  812.  
  813.   def warp(dir,save=nil)
  814.     @firebar=@pound=nil
  815.     @model.animation(@animations[:warp],:force=>true)
  816.     @warp=[dir,32,save]
  817.     @model.mirror_x=true if dir==:left
  818.     @model.mirror_x=nil if dir==:right
  819.     @warp2=dir
  820.   end
  821.  
  822.   def key(id,looping=true)
  823.     return if @ignore or @pound or warping? or $save[:status]=='STONE'
  824.     Keypress[id,looping]
  825.   end
  826.  
  827.   def jump
  828.     if $save[:equip][5]==5 and $save[:hp]<$save[:max_hp]
  829.       heal=[$save[:max_hp]/400+1,$save[:max_hp]-$save[:hp]].min
  830.       Info.new(@x-7,@y-40,"+#{heal}","Damage2")
  831.       $save[:hp]+=heal
  832.     end
  833.   end
  834.  
  835.   def warping?(w2=nil)
  836.     @warp or @warp2 &&w2
  837.   end
  838.  
  839.   def unpound
  840.     @pound=nil
  841.   end
  842.  
  843.   def reset
  844.     @pound=@wall=@wing=@glide=nil
  845.   end
  846.  
  847.   def pound!
  848.     @pound=20
  849.     @vy=16
  850.   end
  851.  
  852.   def set_att(id)
  853.     level=$save[:magic][id][1]
  854.     case id
  855.       when 0
  856.       $items[:magic][id][:attack]=[5,15,25][level]
  857.       when 1
  858.       $items[:magic][id][:attack]=[15,20,20][level]
  859.       when 2
  860.       $items[:magic][id][:attack]=[40,45,60][level]
  861.       when 4
  862.       $items[:magic][id][:attack]=[70,85,95,120][level]
  863.       when 7
  864.       $items[:magic][id][:attack]=10+level/2*5
  865.       when 8
  866.       $items[:magic][id][:attack]=50+level*25
  867.       when 9
  868.       $items[:magic][id][:attack]=20+level*20
  869.       when 10
  870.       $items[:magic][id][:attack]=15+level*15
  871.       when 11
  872.       $items[:magic][id][:attack]=20+level*5
  873.       when 13
  874.       $items[:magic][id][:attack]=60+level*20
  875.       when 14
  876.       $items[:magic][id][:attack]=20+level*20
  877.     end
  878.   end
  879.  
  880.   def check(x,y,down);return if !@solid
  881.     !@model.mirror_x && x.between?(@x-24,@x) || @model.mirror_x && x.between?(@x,@x+24) and y.between?(@y-24,@y+24)
  882.   end
  883.  
  884.   def size;[0,0];end
  885.  
  886.   def mammamia
  887.     @vx=0
  888.     @mammamia=true
  889.     @model.animation(@animations[:mammamia],:force=>true)
  890.   end
  891.  
  892.   def demammamia;@mammamia=nil;end
  893.  
  894.   def portal(x,y)
  895.     @portal=[x,y]
  896.   end
  897.  
  898.   def deportal
  899.     @vx=@vy=0
  900.     @portal=nil
  901.   end
  902. end
  903.  
  904. class Projectile < Enemy
  905.   attr_reader :size
  906.   attr_writer :type,:vx,:vy
  907.   attr_accessor :args
  908.   def initialize(x,y,type,img,size,attack,args={})
  909.     @x,@y,@type,@img,@size,@attack,@args=x,y,type,img,size,attack,args
  910.     @through=@args[:through]
  911.     @animation=[0]+@args[:animation] if @args[:animation]
  912.     @args[:offx]||=0;@args[:offy]||=0
  913.     @offx=@args[:offx]
  914.     @offy=@args[:offy]
  915.     @knockback=@args[:knockback] if @args[:knockback]
  916.     @vx=(@args[:vx] ? @args[:vx] : 0) if @type==2
  917.     @vy=(@args[:vy] ? @args[:vy] : 0) if @type==2
  918.     @traction=(@args[:traction] ? @args[:traction] : 1)
  919.     @line=[] if @args[:line]
  920.     @maxline=@args[:line]
  921.     @line << [@x,@y,255] if @line
  922.     @inv=-1
  923.     @args[:angle]||=0 if @args[:rotate]# || @args[:autorotate]
  924.     @active=@notoffmap=true
  925.     @setinv=@args[:setinv]
  926.     @absolute100=@args[:absolute100]
  927.     @setinv||=(@args[:enemy] ? 30 : 15)
  928.     @element=@args[:element]
  929.     @element=@args[:magic] if @args[:magic].class==Fixnum
  930.     @count=0
  931.     @matk=true if @args[:magic] or @element && !@args[:nomagic] && ![0,1,2].include?(@element)
  932.     @harmless=true if @args[:harmless]==true
  933.     @args[:sequence]=[@args[:sequence],0] if @args[:sequence]
  934.     @unstoppable2=@unstoppable=true
  935.     init((:enemy if @args[:enemy]))
  936.   end
  937.  
  938.   def update ; if @args[:enemy] then super else action end ; end
  939.  
  940.   def action
  941.     return killl if $game.stopped and !@args[:unstoppable]
  942.     @count+=1
  943.     return if @removed
  944.     remove if !@args[:offdown] and @args[:offscreen] and @x>$game.scx+640 || @x+size[0]<$game.scx || @y>$game.scy+480 || @y+size[1]<$game.scy
  945.     remove if !@args[:offdown] and !@args[:notoffmap] and @x>$game.map.data[:width]*640 || @x+size[0]<0 || @y>$game.map.data[:height]*480 || @y+size[1]<0 && !@args[:notoff0]
  946.     remove if @args[:offdown] and @y>$game.scy+480
  947.     @args[:angle]+=@args[:rotate] if @args[:rotate]
  948.     Snd['Boomerang'].play if @args[:boomerang] and (@args[:boomerang]+=1)%15==0
  949.    
  950.     case @type
  951.       when 0 #trail
  952.       if @args[:spec1] and !@wait
  953.         Snd['TCharge'].play
  954.         @wait=90
  955.       elsif @args[:spec1] and @wait and (@wait-=1)<=0
  956.         $game.flash(0xffffffff,16)
  957.         Snd['Thunder'].play
  958.         Trail.new(@x-41,@y-16,2.1,'Effects/Thunder',[0],66,:fade=>6,:movex=>(@args[:spec1a] ? @args[:spec1a] : 0))
  959.         Projectile.new(@x-25,@y,0,['Projectiles/Thunder',130,288,0,0],[130,288],120+$save[:intelligence],:element=>5,:animation=>[33,2],:sequence=>[0]+[1,2]*16,:through=>true,:id=>3,:per_frame=>(@args[:spec1a] ? "@x+=#{@args[:spec1a]}" : nil)) if !@args[:enemy]
  960.         Projectile.new(@x-25,@y,0,['Projectiles/Thunder',130,288,0,0],[130,288],@attack,:element=>5,:animation=>[33,2],:sequence=>[0]+[1,2]*16,:through=>true,:enemy=>true) if @args[:enemy]
  961.         remove
  962.       elsif @args[:spec1] or @args[:elec]
  963.         @args[:angle]=rand(360)
  964.       end
  965.       @x-=(@x<=>@args[:targetx])*4 if @args[:targetx]
  966.       @y-=(@y<=>@args[:targety])*4 if @args[:targety]
  967.       return if @args[:spec1]
  968.       @x+=@args[:movex] if @args[:movex]
  969.       @y+=@args[:movey] if @args[:movey]
  970.       @y-=1 if @args[:targety] and @y>@args[:targety]
  971.      
  972.       @harmless=@args[:harmless].include?(@img[3]) if @args[:harmless]
  973.      
  974.       if @args[:fade] and @args[:repeat]<@args[:fade]
  975.         @args[:color] ||=Color.new(0xffffffff)
  976.         @args[:color].alpha=((@args[:fade]-(@args[:fade]-@args[:repeat]))*(255.0/@args[:fade])).to_i
  977.         @harmless=true
  978.       end
  979.      
  980.       if @args[:fade2]
  981.         @args[:color] ||=Color.new(0xffffffff)
  982.         @args[:color].alpha=[@args[:color].alpha-@args[:fade2],0].max
  983.       end
  984.      
  985.       if @args[:next] and @count==@args[:next][0]
  986.         @args[:next][1]-=1
  987.         Projectile.new(@x+@args[:next][2],@y+@args[:next][3],0,@img[0..2]+[0],@size,@attack,:animation=>@args[:animation],:enemy=>true,:magic=>@args[:magic],:through=>@args[:through],:next=>@args[:next])
  988.       end
  989.      
  990.       if @args[:eject]
  991.         img=(@img.class == Array ? Tls[@img[0], @img[1], @img[2]][@img[3]] : Img[@img])
  992.         @size[0]=@args[:eject][1]
  993.         if !@args[:eject][2]
  994.           @args[:eject][1]=[@args[:eject][1]+=@args[:eject][0],img.width].min
  995.           @args[:eject][2]=true if @args[:eject][1]==img.width
  996.         else
  997.           @args[:eject][1]-=@args[:eject][0]
  998.           remove if @args[:eject][1]<=0
  999.         end
  1000.         if @args[:eject][3]
  1001.           @x=@args[:eject][3]+img.width-@args[:eject][1]
  1002.         end
  1003.       end
  1004.      
  1005.       when 1 #aimed
  1006.       aim=(@args[:accuracy] ? @args[:accuracy] : 2)
  1007.       target=(@args[:target] ? [@args[:target],@args[:target].size[0]/2,@args[:target].size[1]/2] : [$game.player,0,0])
  1008.       if (d=angle_diff(@args[:dir],angle(@x,@y,target[0].x+target[1],target[0].y+target[2])).to_i)>(aim-1) then @args[:dir]+=aim elsif d<(aim-1) then @args[:dir]-=aim end if !@args[:limit] || @args[:limit]>0 and not @args[:reach] && target[0].removed and !@args[:wait] || @args[:wait]<0
  1009.       @x+=offset_x(@args[:dir],@args[:speed])
  1010.       @y+=offset_y(@args[:dir],@args[:speed])
  1011.       @args[:angle]=@args[:dir]+90 if @args[:angle] and !@args[:rotate]
  1012.       @args[:angle]=rand(360) if @args[:elec]
  1013.       @args[:limit]-=1 if @args[:limit] and !@args[:wait] || @args[:wait]<=0
  1014.       @args[:wait]-=1 if @args[:wait]
  1015.       remove if @args[:afterlimit] and @args[:limit]<=0 and @x>$game.scx+640 || @x+size[0]<$game.scx || @y>$game.scy+480 || @y+size[1]<$game.scy
  1016.       @args[:speed]+=@args[:acceleration] if @args[:acceleration]
  1017.       remove if @args[:reach] and !@args[:boomerang] || @args[:boomerang]>60 and distance(@x,@y,target[0].x+target[1],target[0].y+target[2])<@args[:reach]
  1018.       @args[:notoffmap]=false if @args[:reach] && target[0].removed
  1019.       @args[:notoffmap]=true if @args[:limit]
  1020.       @args[:notoffmap]=false if @args[:limit] and @args[:limit]<=0
  1021.       # @args[:rotate]=offset_x(@args[:dir],@args[:speed]*16) if @args[:autorotate]
  1022.      
  1023.       when 2 #falling
  1024.       @vx.abs.to_i.times{
  1025.         @x+=(@vx<=>0)
  1026.         if @args[:climb]
  1027.           @args[:climb].times{|y| @y-=1 if @vx<0 && $game.solid?(@x-2,@y+size[1]-1) && !$game.solid?(@x-2,@y+size[1]-1-@args[:climb]+y) || @vx>0 && $game.solid?(@x+size[0]+2,@y+size[1]-1) && !$game.solid?(@x+size[0]+2,@y+size[1]-1-@args[:climb]+y)}
  1028.         end
  1029.         if @args[:wallbounce] and @vx<0 && $game.solid?(@x-1,@y+size[1]-(@args[:climb] ? @args[:climb]+1 : 1)) || @vx>0 && $game.solid?(@x+size[0]+1,@y+size[1]-(@args[:climb] ? @args[:climb]+1 : 1))
  1030.           if @args[:wallbounce]!=0
  1031.             Snd['Bump'].play
  1032.             @args[:wallbounce]-=1
  1033.             Trail.new(@x-4,@y-4,3,['Effects/Bounce',40,40,0],[0,1,2,3],1)
  1034.             @vx=-@vx
  1035.           else
  1036.             if @args[:fx]==0
  1037.               Snd['KO'].play
  1038.               Particle.new(@x+size[0]/2,@y+size[1]/2,3,@img,vx=-@vx,-6-rand(7),:angle=>0,:rotate=>vx*4)
  1039.             end
  1040.             eval @args[:on_wall] if @args[:on_wall]
  1041.             remove
  1042.             break
  1043.           end
  1044.         end}
  1045.      
  1046.       @vy.abs.to_i.times{
  1047.         if @vy>0 and @args[:back] != 0 and @args[:bouncenemy] && $game.kill(@x,@y,size[0],size[1],@args[:absolute] ? :absolute : @attack,@args[:element],@args[:id]) || @args[:pow] && $game.pow(@x,@y+size[1]/2,size[0],false) || $game.solid?(@x+@size[0]/2,@y+(@args[:antigrav] ? -1 : @size[1]),true)
  1048.           eval @args[:on_fall] if @args[:on_fall]
  1049.           vy=@vy
  1050.           Snd['Bump'].play if @args[:spec1] and @vy>2
  1051.           @vy=0 if @args[:stop]
  1052.           @vy=(@args[:bounce]*=@traction) if @args[:bounce]
  1053.           @vx*=@traction
  1054.           if @args[:back]
  1055.             @vx=-@vx
  1056.             Snd['Stun'].play
  1057.             @args[:back]-=1
  1058.             @args[:harmless]=true if @args[:back]==0
  1059.             Trail.new(@x-4,@y+8,3,['Effects/Bounce',40,40,0],[0,1,2,3],1)
  1060.             if @args[:superbeet]
  1061.               Projectile.new(@x+7,@y+6,2,['Projectiles/Beetsmall',14,16,0],[14,16],@attack/2,:sequence=>[0,1,2,1],:animation=>[4,4],:vy=>-6,:vx=>@vx>0 ? -2 : 2,:bounce=>-5,:angle=>0,:element=>0,:fx=>1,:id=>@args[:id],:back=>1,:through=>true,:bouncenemy=>true,:z=>3)
  1062.             end
  1063.           end
  1064.           break if @vy!=vy
  1065.         end
  1066.         @y+=(@vy<=>0)*(@args[:antigrav] ? -1 : 1)
  1067.       }
  1068.       @vy+=(@args[:gravity] ? @args[:gravity] : 1) if !@args[:fly]
  1069.       @args[:angle] += @args[:rotation] if @args[:rotation]
  1070.       @args[:angle]=angle(0,0,@vx,@vy) if @args[:follow]
  1071.       if @args[:trail]
  1072.         Trail.new(@x-8+rand(17),@y-8+rand(17),1,[@args[:trail][1],@args[:trail][2],@args[:trail][3]],(0...(@args[:trail][4])).to_a,@args[:trail][5]) if ($count% @args[:trail][0])==0
  1073.       end
  1074.       if @args[:spec1]
  1075.         @img[4]+=1
  1076.         @img[3]=([0,1]*4+[2,3]*4+[4,5]*4+[6,7]*4)[@img[4]/8]
  1077.         if @img[4]==256
  1078.           remove
  1079.           Snd['Explosion'].play
  1080.           Projectile.new(@x-82,@y-45,0,['Projectiles/Explosion',192,128,0],[192,128],200,:animation=>[2,4],:repeat=>16,:z=>3,:through=>true)
  1081.         end
  1082.       end
  1083.      
  1084.       when 3 #straight
  1085.       # @args[:speed]+=@args[:acceleration] if @args[:acceleration]
  1086.       # remove if vx<0 && @x+size[0]<$game.scx || vx>0 && @x>$game.scx+768 || vy>0 && @y>$game.scy+672 || vy<0 && @y+size[1]<$game.scy
  1087.       @args[:speed].to_i.times{@x+=(vx=offset_x(@args[:dir],1)) ; @y+=(vy=offset_y(@args[:dir],1))
  1088.       if (@args[:bounce] and (vx<0 and $game.solid?(@x-2,@y) || $game.solid?(@x-2,@y+size[1]-1)) || (vx>0 and $game.solid?(@x+size[0]+1,@y) || $game.solid?(@x+size[0]+1,@y+size[1])))
  1089.         @args[:dir]=angle(0,0,-vx,vy)
  1090.         @args[:bounce]-=1
  1091.         @line << [@x,@y,255] if @line
  1092.         break
  1093.       elsif @args[:bounce] and (vy<0 and $game.solid?(@x,@y-2) || $game.solid?(@x+size[0]-1,@y-2)) || (vy>0 and $game.solid?(@x,@y+size[1]+1) || $game.solid?(@x+size[0]-1,@y+size[1]+1))
  1094.         @args[:dir]=angle(0,0,vx,-vy)
  1095.         @line << [@x,@y,255] if @line
  1096.         @args[:bounce]-=1
  1097.         break
  1098.       elsif @args[:bounce] and @args[:bounce]<=0
  1099.         if @line
  1100.           @removed=true
  1101.         else
  1102.           remove
  1103.           if @args[:shuri]
  1104.             Snd['Shuriken'].play
  1105.             Particle.new(@x,@y,3,Img['Projectiles/Shuriken'],(4+rand(4))*(@args[:dir]<180 ? 1 : -1),-4-rand(4),:rotate=>-@args[:rotate])
  1106.             return
  1107.           end
  1108.         end
  1109.       end
  1110.       $game.kill(@x,@y,size[0],size[1],@args[:absolute] ? :absolute : @attack,@args[:element],@args[:id]) if !@args[:enemy] and @args[:accurate]}
  1111.       remove if @args[:destroy] and distance(@x,@y,@args[:destroy][0],@args[:destroy][1])<@args[:destroy][2]
  1112.       @args[:speed]+=@args[:acceleration] if @args[:acceleration]
  1113.      
  1114.       vx=offset_x(@args[:dir],@args[:speed])
  1115.       vy=offset_y(@args[:dir],@args[:speed])
  1116.       if @args[:stopwall] and $game.solid?(@x+vx/2,@y+vy/2)
  1117.         Snd[@args[:stopwall]].play
  1118.         @harmless=@frozen=@unhittable=true
  1119.       end
  1120.       if @args[:float]
  1121.         remove if @args[:float]>=2
  1122.         @y-=(@args[:float]+=0.05)
  1123.         if $game.solid?(@x+vx,@y)
  1124.           @args[:dir]=angle(0,0,-vx,vy)
  1125.         end
  1126.         if $game.solid?(@x,@y+vy)
  1127.           @args[:dir]=angle(0,0,vx,-vy)
  1128.         end
  1129.         $game.hit(@x,@y,size[0],size[1],:specjal1)
  1130.       end
  1131.      
  1132.       # collided=true if @args[:collide] and vx<0 && $game.solid?(@x+vx,@y.to_i+size[1],true) || vx>0 && $game.solid?(@x+size[0]+vx,@y.to_i+size[1]-1,true) || vy<0 && $game.solid?(@x+vy,@y.to_i+size[1],true) || vy>0 && $game.solid?(@x+size[0]+vy,@y.to_i+size[1]-1,true)
  1133.       # collided=true if @args[:collide] and vx<0 && $game.solid?(@x+vx,@y.to_i+size[1]/2,true) || vx>0 && $game.solid?(@x+size[0]+vx,@y.to_i+size[1]/2,true) || vy<0 && $game.solid?(@x+size[0]/2,@y+vy,true) || vy>0 && $game.solid?(@x+size[0]/2,@y+size[1]+vy,true)
  1134.       collided=true if @args[:collide] and $game.solid?(@x+(vx>0 ? size[0] : vx==0 ? size[1]/2 : 0)+vx,@y+(vy>0 ? size[1] : vy.to_i==0 ? size[1]/2 : 0)+vy,true)
  1135.      
  1136.       if collided
  1137.         remove
  1138.         eval @args[:on_collide] if @args[:on_collide]
  1139.       end
  1140.      
  1141.       if @args[:lotus]
  1142.         @args[:lotus]-=1
  1143.         if @args[:lotus]<0
  1144.           @args[:dir]=180
  1145.           @args[:speed]=(@args[:slotus] ? 16 : 2)
  1146.           @ix||=@x
  1147.           @x=@ix-8-offset_x(@args[:lotus]*(@args[:slotus] ? 32 : 8),16)
  1148.           Trace.new(@x,@y,3,@img,16) if @args[:slotus]
  1149.         end
  1150.       end
  1151.      
  1152.       if @args[:bolt]
  1153.         if !@disp and @y<-96
  1154.           @disp=45
  1155.           @x=$game.player.x-80+rand(161)
  1156.           @y=48
  1157.           @args[:speed]=0
  1158.         elsif @disp and (@disp-=1)==0
  1159.           remove
  1160.           Snd['Blast'].play
  1161.           Projectile.new(@x-3,-32,0,['Projectiles/Toxbolt',38,448,0],[38,448],120,:animation=>[8,8],:through=>true,:enemy=>true,:harmless=>[0,1,8],:magic=>true,:z=>3)
  1162.         end
  1163.       end
  1164.      
  1165.       if @args[:maxx]
  1166.         remove if @x>=@args[:maxx]
  1167.       end
  1168.      
  1169.       if @args[:minx]
  1170.         remove if @x<=@args[:minx]
  1171.       end
  1172.      
  1173.       if @args[:pow]
  1174.         @args[:speed]+=0.5
  1175.         if $game.solid?(@x+16,@y+32)
  1176.           Snd['KaBoom'].play
  1177.           Projectile.new(@x-304,@y-304,0,'Projectiles/Shockwave',[640,640],300,:through=>true,:z=>3,:inv=>120,:repeat=>100,:shock=>true)
  1178.           remove
  1179.         end
  1180.       end
  1181.  
  1182.      
  1183.       when 4 #scythe
  1184.       @args[:angle]||=0
  1185.       Snd['Scythe'].play if $count%15==0
  1186.       @args[:angle]+=16
  1187.       @phase||=0
  1188.       if @phase==0
  1189.         if @y>32
  1190.           @y-=4
  1191.         else
  1192.           @phase+=1
  1193.         end
  1194.       elsif @phase==1
  1195.         if @x<960
  1196.           @x+=8
  1197.         else
  1198.           @phase+=1
  1199.         end
  1200.       elsif @phase==2
  1201.         if @y<320
  1202.           @y+=8
  1203.         else
  1204.           @phase+=1
  1205.         end
  1206.       elsif @phase==3
  1207.         if @x>64
  1208.           @x-=8
  1209.         else
  1210.           @phase+=1
  1211.         end
  1212.       elsif @phase==4
  1213.         if distance(@x,@y,@args[:death].x,@args[:death].y-43)>4
  1214.           @x+=offset_x(angl=angle(@x,@y,@args[:death].x,@args[:death].y-43),4)
  1215.           @y+=offset_y(angl=angle(@x,@y,@args[:death].x,@args[:death].y-43),4)
  1216.         elsif !@time
  1217.           @time=0
  1218.         elsif @time<60
  1219.           @time+=1
  1220.         else
  1221.           remove
  1222.         end
  1223.       end
  1224.     end
  1225.    
  1226.     if @args[:trace] and @count% @args[:trace][1]==0
  1227.       Trace.new(@x+(@args[:angle] ? size[0]/2 : 0),@y+(@args[:angle] ? size[1]/2 : 0),@args[:z] ? @args[:z]-0.1 : 1.9,@img,@args[:trace][2],:angle=>@args[:angle])
  1228.     end
  1229.    
  1230.     # puts (!@through || !(@through.class==Fixnum and (@through-=1)>=0))
  1231.     # puts $game.kill(@x,@y,size[0],size[1],@args[:absolute] ? :absolute : @attack,@args[:element],@args[:id])
  1232.     killl
  1233.     # $game.pow(@x,@y+size[1]/2,size[0],false) if @args[:pow]
  1234.    
  1235.     if @removed and @args[:remove]
  1236.       t=@args[:remove]
  1237.       Trail.new(@x+t[0],@y+t[1],2,t[(2..4)],:default,t[5])
  1238.     end
  1239.     if @removed and @args[:remove2]
  1240.       t=@args[:remove2]
  1241.       Trace.new(@x+t[0],@y+t[1],2,t[2],t[3])
  1242.     end
  1243.    
  1244.     if @args[:sizesx]
  1245.       @size[0]=@args[:sizesx][@args[:sequence][1]]
  1246.     end
  1247.     if @args[:offsetsx]
  1248.       @offx=@args[:offsetsx][@args[:sequence][1]]
  1249.     end
  1250.     if @args[:sizesy]
  1251.       @size[1]=@args[:sizesy][@args[:sequence][1]]
  1252.     end
  1253.     if @args[:offsetsy]
  1254.       @offy=@args[:offsetsy][@args[:sequence][1]]
  1255.     end
  1256.    
  1257.     if @args[:per_frame]
  1258.       eval @args[:per_frame]
  1259.     end
  1260.    
  1261.     if @removed and @args[:electrosion]
  1262.       Snd['Electrosion'].play
  1263.       Trace.new(@x+40,@y+40,2.2,'Projectiles/Electrosion',16,:randangle=>true)
  1264.     end
  1265.    
  1266.     if @args[:randangle]
  1267.       @args[:angle]=rand(360)
  1268.     end
  1269.   end
  1270.  
  1271.   def draw
  1272.     if @line
  1273.       dis=(@removed ? 12 : @line.length)
  1274.       @line[1][2]=@line[0][2]-=dis if @line.length>1
  1275.       @line[0][2]-=dis if @line.length==1
  1276.       if @line[0][2]<=0
  1277.         return remove if @line.length==1
  1278.         @line.shift
  1279.         @line[0][2]=255
  1280.       end
  1281.       @line.length.times{|line| if line<@line.length-1 then
  1282.         $screen.draw_line(@line[line][0]+size[0]/2,@line[line][1]+size[1]/2,line==0 ? 0x00000000 : line==1 ? Color.new(@line[1][2],255,255,255) : 0xffffffff,@line[line+1][0]+size[0]/2,@line[line+1][1]+size[1]/2,line==0 ? Color.new(@line[0][2],255,255,255) : 0xffffffff,2)  else
  1283.           $screen.draw_line(@line[line][0]+size[0]/2,@line[line][1]+size[1]/2,line==1 ? Color.new(@line[1][2],255,255,255) : @line.length==1 ? Color.new(@line[0][2],255,255,255) : 0xffffffff,@x+size[0]/2,@y+size[1]/2,0xffffffff,2)  end}
  1284.     end
  1285.     return if !@img or @removed
  1286.     if @args[:shock]
  1287.       Img[@img].draw_rot(@x+size[0]/2,@y+size[1]/2,3,0,0.5,0.5,(@count%10+1)*0.23,(@count%10+1)*0.23)
  1288.       remove if @count==99
  1289.       return
  1290.     end
  1291.    
  1292.     if @args[:animation]
  1293.       if (@animation[0]+=1) % @animation[2]==0
  1294.         if @args[:sequence]
  1295.           @args[:sequence][1]+=1
  1296.           @img[3]=@args[:sequence][0][@args[:sequence][1]]
  1297.         else
  1298.           @img[3]+=1
  1299.         end
  1300.       end
  1301.       if @args[:sequence] && @args[:sequence][1]==@animation[1] or !@args[:sequence] && @img[3]==@animation[1]
  1302.         if @args[:sequence]
  1303.           @args[:sequence][1]=0
  1304.           @img[3]=@args[:sequence][0][@args[:sequence][1]]
  1305.         else
  1306.           @img[3]=0
  1307.         end
  1308.         return remove if @type==0 and !@args[:still] and !@args[:repeat] || (@args[:repeat]-=1)==0
  1309.       end
  1310.     elsif @type==0 and !@args[:spec1]
  1311.       return remove if @type==0 and !@args[:still] and !@args[:repeat] || (@args[:repeat]-=1)==0
  1312.     end
  1313.     img=(@img.class == Array ? Tls[@img[0], @img[1], @img[2]][@img[3]] : Img[@img])
  1314.     # Trace.new(@x+(@args[:mirrorx] ? size[0] : 0),@y,@args[:z] ? @args[:z] : 2,(@img.class == Array ? [@img[0], [@img[1], @img[2]],@img[3]] : Img[@img]),@args[:trace][0],:scalex=>(@args[:mirrorx] ? -1 : 1)) if @args[:trace] and $game.time % @args[:trace][1]==0
  1315.    
  1316.     if @args[:eject]
  1317.       $screen.clip_to(@x,@y,@args[:eject][1],@y+12){img.draw(@x+(@args[:mirrorx] ? @args[:eject][1] : 0),@y,@args[:z] ? @args[:z] : 2,@args[:mirrorx] ? -1 : 1,1)}
  1318.     else
  1319.     if @args[:angle]
  1320.       origin=(@args[:origin] ? @args[:origin] : [size[0]/2,size[1]/2,0.5,0.5])
  1321.       img.draw_rot(@x+origin[0],@y+origin[1],@args[:z] ? @args[:z] : 2,@args[:angle],origin[2],origin[3],(@args[:mirrorx] ? -1 : 1)*(@args[:scale] ? @args[:scale] : 1),@args[:scale] ? @args[:scale] : 1,@args[:color] ? @args[:color] : 0xffffffff)
  1322.     else
  1323.       img.draw(@x+(@args[:mirrorx] ? img.width : 0),@y,@args[:z] ? @args[:z] : 2,@args[:mirrorx] ? -1 : 1,1,@args[:color] ? @args[:color] : 0xffffffff)
  1324.     end end
  1325.   end
  1326.  
  1327.   def killl
  1328.     _remove if !@args[:harmless] and !@args[:bouncenemy] and !@args[:enemy] && $game.kill(@x,@y,size[0],size[1],@args[:absolute] ? :absolute : @attack,@element ? @element : @matk,@args[:id],@setinv) || @args[:enemy] && @attacked and !@through || @through.class==Fixnum && (@through-=1)==0
  1329.     _remove if @args[:enemy]==:both && $game.kill(@x,@y,size[0],size[1],@args[:absolute] ? :absolute : @attack,@args[:element],@args[:id]) and !@through
  1330.   end
  1331.  
  1332.   def _remove
  1333.     @args[:on_hit] ? eval(@args[:on_hit]) : remove
  1334.   end
  1335. end
  1336.  
  1337. class Corpse < Entity
  1338.   def initialize(x,y,vx,vy,slash=nil)
  1339.     @x,@y,@vx,@vy,@slash=x,y,vx,vy,slash
  1340.     @vy=13 if slash
  1341.     @vx=1 if slash
  1342.     init
  1343.   end
  1344.  
  1345.   def update
  1346.     return if @slash
  1347.     @vx.to_i.abs.times{@x+=(@vx<=>0) ; @vx=-@vx if $game.solid?(@vx<0 ? @x-1 : @x+48,@y+15)}
  1348.     @vy.to_i.abs.times{@y+=(@vy<=>0) ; if $game.solid?(@x+24,@vy<0 ? @y-1 : @y+30) ; if @vy<0 ; @vy=-@vy else @vy=@vx=0 ; @fallen=true end end}
  1349.     @vy+=1 if !@fallen
  1350.   end
  1351.  
  1352.   def draw
  1353.     if @slash
  1354.       @vy+=1.0/@vx
  1355.       @vx+=0.1
  1356.       Tls['Objects/Mario2',32,39][0].draw(@x+(@slash==:left ? 32 : 0),@y-@vy,1.5,@slash==:left ? -1 : 1)
  1357.       Tls['Objects/Mario2',32,39][1].draw(@x+(@slash==:left ? 32 : 0),@y+@vy,1.5,@slash==:left ? -1 : 1)
  1358.     else
  1359.       Tls['Objects/Mario',48,29][@fallen ? 1 : 0].draw(@x,@y,1.5)
  1360.     end
  1361.   end
  1362. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement