| Roi |
 |
 |
Inscrit le: 13 Aoû 2006, 00:00 Messages: 2414 Localisation: Montréal, QC Logiciel(s) préféré(s): RMXP, VS2008 Point(s) Fort(s): Script Points d'aide: Illimité
Créations :
- Séparation d'inventaire
- Sprite_Text
Voir ses créations
|
Scene_FishFight- Code: Tout sélectionner
# The window that shows the fight... class Window_Versus < Window_Base
def initialize super(16,16,260, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype self.contents.font.size = $defaultfontsize == nil ? $fontsize : $defaultfontsize self.z = 9999 if $fish == nil $fish = FishCatch.new end refresh end
def refresh self.contents.clear inc = $data_items[$fish.equipped_rod].name if inc.include?("Harpoon") == false and inc.include?("Net") == false rect = Rect.new(63, 9, 102, 6) self.contents.fill_rect(rect, Color.new(0, 0, 0)) # Modify the color as pleased rect = Rect.new(63, 25, 102, 6) self.contents.fill_rect(rect, Color.new(0, 0, 0)) # Modify the color as pleased self.contents.font.size = $fontsize.is_a?(Numeric) ? $fontsize - 4 : $defaultfontsize - 4 self.contents.draw_text(0,-6,self.width-40,32,"Player") rect = Rect.new(64, 10, $fish.meter_player, 4) self.contents.fill_rect(rect, Color.new(0, 0, 255)) # Modify the color as pleased self.contents.draw_text(0,10,self.width-40,32,"Fish") rect = Rect.new(64, 26, $fish.meter_fish, 4) self.contents.fill_rect(rect, Color.new(255, 0, 0)) # Modify the color as pleased self.contents.draw_text(170,-6,self.width-40,32,$fish.meter_player.round.to_s + " %") self.contents.draw_text(170,10,self.width-40,32,$fish.meter_fish.round.to_s + " %") elsif inc.include?("Harpoon") rect = Rect.new(63, 9, 102, 6) self.contents.fill_rect(rect, Color.new(0, 0, 0)) # Modify the color as pleased self.contents.font.size = $fontsize.is_a?(Numeric) ? $fontsize - 4 : $defaultfontsize - 4 self.contents.draw_text(0,-6,self.width-40,32,"Player") rect = Rect.new(64, 10, $fish.meter_fish, 4) self.contents.fill_rect(rect, Color.new(0, 0, 255)) # Modify the color as pleased self.contents.draw_text(0,10,self.width-40,32,"HARPOON vs FISH", 1) self.contents.draw_text(170,-6,self.width-40,32,$fish.meter_fish.round.to_s + " %") elsif inc.include?("Net") rect = Rect.new(63, 9, 102, 6) self.contents.fill_rect(rect, Color.new(0, 0, 0)) # Modify the color as pleased self.contents.font.size = $fontsize.is_a?(Numeric) ? $fontsize - 4 : $defaultfontsize - 4 self.contents.draw_text(0,-6,self.width-40,32,"Net") rect = Rect.new(64, 10, $fish.meter_fish, 4) self.contents.fill_rect(rect, Color.new(0, 0, 255)) # Modify the color as pleased self.contents.draw_text(0,10,self.width-40,32,"NET vs FISHES!", 1) self.contents.draw_text(170,-6,self.width-40,32,$fish.meter_fish.round.to_s + " %") end end end
# Window when fish is caught class Window_Fish < Window_Base
def initialize(fish, start = 0) super(320, 240, 320, 240) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype self.contents.font.size = $defaultfontsize == nil ? $fontsize : $defaultfontsize @fish = fish @points = $fish.fish_point[@fish] refresh end
def get_points @points = 0 unless $fish.equipped_rod == nil or $fish.equipped_rod == 0 if $data_items[$fish.equipped_rod].name.include?("Net") for id in $fish.fish_party @points += $fish.fish_point[id] end else @points = $fish.fish_point[$fish.active_fish_id] end end end
def get_avarage_str @avarage1 = 0 @amount1 = 0 for id in 0...@size @amount1 += $fish.fish_resist[id].to_i end @avarage1 = @amount1 / @size end def get_avarage_pnt @avarage2 = 0 @amount2 = 0 for id in 0...@size @amount2 += $fish.fish_point[id].to_i end @avarage2 = @amount2 / @size end def refresh self.contents.clear get_points if $fish.phase == 0 $fish.caught(@fish) self.contents.clear if $data_items[$fish.equipped_rod].name.include?("Net") @size = $fish.net_fish_ids.size get_avarage_str get_avarage_pnt self.contents.draw_text(0, 0, self.width - 40, 32, "#{@size} Kinds of fish caught! #{@points} Points!", 1) self.contents.draw_text(0, 64, self.width - 40, 32, "Avarage points: #{@avarage2}") self.contents.draw_text(0, 96, self.width - 40, 32, "Avarage strentgh: #{@avarage1}") self.contents.draw_text(0, 128, self.width - 40, 32, "More info, press A button", 1) self.contents.draw_text(0, 160, self.width - 40, 32, "Congrats! Total points: #{$fish.points}", 1) else self.contents.draw_text(0, 0, self.width - 40, 32, "Fish caught! #{@points} Points!", 1) bitmap = RPG::Cache.icon($data_items[@fish].icon_name) self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color self.contents.draw_text(28, 32, 212, 32, $data_items[@fish].name) self.contents.draw_text(0, 64, self.width - 40, 32, "Size: " + $fish.fish_size[@fish].to_s + " cm.") self.contents.draw_text(0, 96, self.width - 40, 32, "Weight: " + $fish.fish_weight[@fish].to_s + " kg.") self.contents.draw_text(0, 128, self.width - 40, 32, "Power: " + $fish.fish_resist[@fish].to_s + " fpwr.") self.contents.draw_text(0, 160, self.width - 40, 32, "Congratulations. Total points: #{$fish.points}", 1) end $fish.total_points += @points elsif $fish.phase == 1 self.contents.draw_text(0, 90, self.width - 40, 32, "The fish got away!", 1) if SC::LOSE_BAIT == true self.contents.draw_text(0, 64, self.width - 40, 32, "You lost your bait...") $game_party.lose_item($fish.equipped_bait, 1) end elsif $fish.phase == -1 and @fish == 0 self.contents.draw_text(0, 90, self.width - 40, 32, "No equipment!", 1) end end end
# This is the scene where the fight is done through. class Scene_FishFight
def main
if $fish.equipped_rod == nil or $fish.equipped_rod == 0 $fish.phase = -1 @catch = Window_Fish.new(0) @catch.x = 320 - @catch.width / 2 @catch.y = 240 - @catch.height / 2 @catch.z = 9999 @block = true end @spriteset_map = Spriteset_Map.new unless @block == true if $data_items[$fish.equipped_rod].name.include?("Net") starting = $fish.get_net_range[0] + $fish.get_net_range[1] $fish.meter_fish = starting / 2 @timer = 0 @resist = 0 $fish.pick_net_fish for i in 0...$fish.net_fish_ids.size @resist += $fish.fish_resist[$fish.net_fish_ids[i]] / SC::FISH_SPEED end @startingsec = Graphics.frame_count / Graphics.frame_rate else $fish.pick_fish end @bar = Window_Versus.new @bar.z = 9999 @catch = Window_Fish.new($fish.active_fish_id) @catch.x = 320 - @catch.width / 2 @catch.y = 240 - @catch.height / 2 @catch.z = 9999 @catch.active = false @catch.visible = false @str = 0 @stop = false end Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @spriteset_map.dispose unless @block == true @bar.dispose end @catch.dispose end
def update @spriteset_map.update unless @block == true @bar.update @bar.refresh end @catch.update if @catch.active update_catch return end if Input.trigger?(Input::B) # cancel, loses bait $game_system.se_play($data_system.cancel_se) $fish.meter_player = 0 $fish.meter_fish = 0 $game_party.lose_item($fish.equipped_bait, 1) $scene = Scene_Map.new end inc = $data_items[$fish.equipped_rod].name if Input.trigger?(Input::C) and @stop != true # tab this! if inc.include?("Harpoon") == false and inc.include?("Net") == false $fish.meter_player += $fish.get_rod_power elsif inc.include?("Harpoon") rangemin = $fish.get_harpoon_range[0] rangemax = $fish.get_harpoon_range[1] if $fish.meter_fish > rangemin and $fish.meter_fish < rangemax @stop = true if SC::KEEP_FISH == true $game_party.gain_item($fish.active_fish_id, 1) end $fish.phase = 0 @catch.refresh @catch.active = true @catch.visible = true else @stop = true $fish.phase = 1 @catch.refresh @catch.active = true @catch.visible = true end elsif inc.include?("Net") # end end
#Net info starts here if inc.include?("Net") @currentsec = Graphics.frame_count / Graphics.frame_rate @secdiff = @currentsec - @startingsec if @secdiff >= $fish.get_net_time @stop = true if SC::KEEP_FISH == true for i in 0...$fish.net_fish_ids.size $game_party.gain_item($fish.net_fish_ids[i], 1) end end $fish.phase = 0 @catch.refresh @catch.active = true @catch.visible = true end if $fish.get_net_range[0] > $fish.meter_fish or $fish.get_net_range[1] < $fish.meter_fish @stop = true $fish.phase = 1 @catch.refresh @catch.active = true @catch.visible = true end end if Input.trigger?(Input::X) and inc.include?("Net") $fish.meter_fish -= $fish.get_net_power elsif Input.trigger?(Input::Y) and inc.include?("Net") $fish.meter_fish += $fish.get_net_power end #End net info unless @block == true update_fish if $fish.meter_player >= 100 $fish.meter_player = 100 @stop = true if SC::KEEP_FISH == true $game_party.gain_item($fish.active_fish_id, 1) end $fish.phase = 0 @catch.refresh @catch.active = true @catch.visible = true end end end
def update_fish inc = $data_items[$fish.equipped_rod].name if inc.include?("Net") == false and inc.include?("Harpoon") == false if @str >= $fish.fish_life[$fish.active_fish_id] and $fish.meter_player < 100 $fish.meter_fish = 100 @stop = true $fish.phase = 1 @catch.refresh @catch.active = true @catch.visible = true elsif @stop == true # elsif @str <= $fish.fish_life[$fish.active_fish_id] @add = $fish.fish_resist[$fish.active_fish_id] / SC::FISH_SPEED @str += @add $fish.meter_fish += @add end elsif inc.include?("Harpoon") if @str >= 100 @str = 0 $fish.meter_fish = 0 end @add = $fish.fish_resist[$fish.active_fish_id] * 5 / SC::FISH_SPEED @str += @add $fish.meter_fish += @add elsif inc.include?("Net") @timer += 1 if @timer > 3 @timer = 0 end if @stop == true # elsif @timer == 3 phase = rand(7) case phase when 0 unless $fish.meter_fish > 100 $fish.meter_fish += @resist + 1 else $fish.meter_fish -= @resist + 1 end when 1 unless $fish.meter_fish > 100 $fish.meter_fish += @resist - 1 else $fish.meter_fish -= @resist - 1 end when 2 unless $fish.meter_fish > 100 $fish.meter_fish += @resist else $fish.meter_fish -= @resist end when 3 unless $fish.meter_fish > 100 $fish.meter_fish += @resist / 2 else $fish.meter_fish -= @resist / 2 end when 4 unless $fish.meter_fish < 0 $fish.meter_fish -= @resist + 1 else $fish.meter_fish += @resist + 1 end when 5 unless $fish.meter_fish < 0 $fish.meter_fish -= @resist - 1 else $fish.meter_fish += @resist - 1 end when 6 unless $fish.meter_fish < 0 $fish.meter_fish -= @resist else $fish.meter_fish += @resist end when 7 unless $fish.meter_fish < 0 $fish.meter_fish -= @resist / 2 else $fish.meter_fish += @resist / 2 end end if $fish.meter_fish < 0 $fish.meter_fish = 1 elsif $fish.meter_fish > 100 $fish.meter_fish = 99 end end end end
def update_catch inc = $data_items[$fish.equipped_rod].name if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $fish.phase = 1 $fish.meter_player = 0 $fish.meter_fish = 0 @str = 0 $scene = Scene_Map.new elsif Input.trigger?(Input::X) and inc.include?("Net") $game_system.se_play($data_system.decision_se) $scene = Scene_FishResult.new end end end
|
|