=begin #=========================== # ccoa's weather script # Script Original de CCoa y adaptado para pokémon essentials por Clara # Gracias a Xabier2012 de WaH por haber subido una de las pocas copias del script que quedan para XP # Información de como utilizarlo en: http://whackahack.com/foro/t-21727/tutorial-script-rpg-maker-xp-essentials-clima-avanzado#post199093 #=========================== # Para usar llama esto desde cualquier evento: $game_screen.weather( CCOAWeatherTypes::AUTUMN_FALLING, 5, 0) # Cambia AUTUMN_FALLING por cualquiera de los climas en el script, puedes verlos ahi abajo. #=========================== =end module CCOAWeatherTypes AUTUMN_FALLING = 6 AUTUMN_BLOWING = 7 AUTUMN_SWIRLING = 8 GREEN_LEAVES = 9 SAKURA_PETALS = 10 ROSE_PETALS = 11 FEATHERS = 12 BLOOD_RAIN = 13 SPARKLES = 14 BLUE_PETALS = 15 USER_DEFINED = 16 end $WEATHER_UPDATE = false $WEATHER_IMAGES = [] $WEATHER_X = 0 $WEATHER_Y = 0 $WEATHER_FADE = 0 $WEATHER_ANIMATED = false module RPG class Weather alias ccoa_weather_initialize initialize def initialize(viewport = nil) ccoa_weather_initialize(viewport) @current_pose = [] @info = [] @countarray = [] @ccoa_active = false for i in 1..40 @current_pose.push(0) @info.push(rand(50)) @countarray.push(rand(15)) end make_ccoa_bitmaps end alias ccoa_weather_dispose dispose def dispose dispose_ccoa_bitmaps if @ccoa_active ccoa_weather_dispose end alias ccoa_weather_type_set type= def type=(type) if type >= CCOAWeatherTypes::AUTUMN_FALLING && type <= CCOAWeatherTypes::USER_DEFINED @ccoa_active = true setup_ccoa_weather(type) else @ccoa_active = false ccoa_weather_type_set(type) end end alias ccoa_weather_update update def update if @ccoa_active update_ccoa_weather else ccoa_weather_update end end def setup_ccoa_weather(type) return if @type == type @type = type bitmap = case @type when CCOAWeatherTypes::AUTUMN_FALLING, CCOAWeatherTypes::AUTUMN_BLOWING, CCOAWeatherTypes::AUTUMN_SWIRLING @autumn_leaf_bitmaps[0] when CCOAWeatherTypes::GREEN_LEAVES @green_leaf_bitmaps[0] when CCOAWeatherTypes::SAKURA_PETALS @petal_bitmap when CCOAWeatherTypes::ROSE_PETALS @rose_bitmaps[0] when CCOAWeatherTypes::FEATHERS @feather_bitmaps[0] when CCOAWeatherTypes::BLOOD_RAIN @blood_rain_bitmap when CCOAWeatherTypes::SPARKLES @sparkle_bitmaps[0] when CCOAWeatherTypes::BLUE_PETALS @bluef_bitmaps[0] when CCOAWeatherTypes::USER_DEFINED @user_bitmaps[rand(@user_bitmaps.size)] else nil end ensureSprites for i in 0...@sprites.length sprite = @sprites[i] if sprite sprite.visible = (i < @max) sprite.bitmap = bitmap end end end def update_ccoa_weather return if @type == 0 || !@ccoa_active for i in 0...@max sprite = @sprites[i] break if sprite.nil? case @type when CCOAWeatherTypes::AUTUMN_FALLING update_autumn_falling(sprite, i) when CCOAWeatherTypes::AUTUMN_BLOWING update_autumn_blowing(sprite, i) when CCOAWeatherTypes::AUTUMN_SWIRLING update_autumn_swirling(sprite, i) when CCOAWeatherTypes::GREEN_LEAVES update_green_leaves(sprite, i) when CCOAWeatherTypes::SAKURA_PETALS update_sakura_petals(sprite, i) when CCOAWeatherTypes::ROSE_PETALS update_rose_petals(sprite, i) when CCOAWeatherTypes::FEATHERS update_feathers(sprite, i) when CCOAWeatherTypes::BLOOD_RAIN update_blood_rain(sprite) when CCOAWeatherTypes::SPARKLES update_sparkles(sprite, i) when CCOAWeatherTypes::BLUE_PETALS update_blue_petals(sprite, i) when CCOAWeatherTypes::USER_DEFINED update_user_defined_weather(sprite, i) end reset_sprite_if_offscreen(sprite) end end def update_autumn_falling(sprite, i) if rand(20) == 0 sprite.bitmap = @autumn_leaf_bitmaps[@current_pose[i]] @current_pose[i] = (@current_pose[i] + 1) % @autumn_leaf_bitmaps.size end sprite.x -= 1 sprite.y += 1 end def update_autumn_blowing(sprite, i) if rand(20) == 0 sprite.bitmap = @autumn_leaf_bitmaps[@current_pose[i]] @current_pose[i] = (@current_pose[i] + 1) % @autumn_leaf_bitmaps.size end sprite.x -= 10 sprite.y += (rand(4) - 2) end def update_autumn_swirling(sprite, i) if rand(20) == 0 sprite.bitmap = @autumn_leaf_bitmaps[@current_pose[i]] @current_pose[i] = (@current_pose[i] + 1) % @autumn_leaf_bitmaps.size end if @info[i] != 0 case @info[i] when 1..10 then sprite.x -= 3; sprite.y -= 1 when 11..16 then sprite.x -= 1; sprite.y -= 2 when 17..20 then sprite.y -= 3 when 21..30 then sprite.y -= 2; sprite.x += 1 when 31..36 then sprite.y -= 1; sprite.x += 3 when 37..40 then sprite.x += 5 when 41..46 then sprite.y += 1; sprite.x += 3 when 47..58 then sprite.y += 2; sprite.x += 1 when 59..64 then sprite.y += 3 when 65..70 then sprite.x -= 1; sprite.y += 2 when 71..81 then sprite.x -= 3; sprite.y += 1 when 82..87 then sprite.x -= 5 end @info[i] = (@info[i] + 1) % 88 else @info[i] = 1 if rand(200) == 0 sprite.x -= 5 sprite.y += 1 end end def update_green_leaves(sprite, i) if @countarray[i] == 0 @current_pose[i] = (@current_pose[i] + 1) % @green_leaf_bitmaps.size sprite.bitmap = @green_leaf_bitmaps[@current_pose[i]] @countarray[i] = rand(15) end @countarray[i] = (@countarray[i] + 1) % 15 sprite.y += 1 end def update_sakura_petals(sprite, i) sprite.x += (@info[i] < 25) ? -1 : 1 @info[i] = (@info[i] + 1) % 50 sprite.y += 1 end def update_rose_petals(sprite, i) if rand(20) == 0 sprite.bitmap = @rose_bitmaps[@current_pose[i]] @current_pose[i] = (@current_pose[i] + 1) % @rose_bitmaps.size end sprite.x += (@info[i] < 10) ? -1 : 1 if @info[i] % 2 == 0 sprite.y += 1 end def update_blue_petals(sprite, i) if rand(20) == 0 sprite.bitmap = @bluef_bitmaps[@current_pose[i]] @current_pose[i] = (@current_pose[i] + 1) % @bluef_bitmaps.size end sprite.x += (@info[i] < 10) ? -1 : 1 if @info[i] % 2 == 0 sprite.y += 1 end def update_feathers(sprite, i) if @countarray[i] == 0 @current_pose[i] = (@current_pose[i] + 1) % @feather_bitmaps.size sprite.bitmap = @feather_bitmaps[@current_pose[i]] end @countarray[i] = (@countarray[i] + 1) % 15 sprite.x -= 1 if rand(100) == 0 sprite.y -= 1 if rand(100) == 0 if @info[i] < 50 rand(2) == 0 ? sprite.x -= 1 : sprite.y -= 1 else rand(2) == 0 ? sprite.x += 1 : sprite.y += 1 end @info[i] = (@info[i] + 1) % 100 end def update_blood_rain(sprite) sprite.x -= 2 sprite.y += 16 sprite.opacity -= 8 end def update_sparkles(sprite, i) if @countarray[i] == 0 @current_pose[i] = (@current_pose[i] + 1) % @sparkle_bitmaps.size sprite.bitmap = @sparkle_bitmaps[@current_pose[i]] end @countarray[i] = (@countarray[i] + 1) % 15 sprite.y += 1 sprite.opacity -= 1 end def update_user_defined_weather(sprite, i) if $WEATHER_UPDATE update_user_bitmaps $WEATHER_UPDATE = false end if $WEATHER_ANIMATED && @countarray[i] == 0 @current_pose[i] = (@current_pose[i] + 1) % @user_bitmaps.size sprite.bitmap = @user_bitmaps[@current_pose[i]] end @countarray[i] = (@countarray[i] + 1) % 15 sprite.x += $WEATHER_X sprite.y += $WEATHER_Y sprite.opacity -= $WEATHER_FADE end def reset_sprite_if_offscreen(sprite) x = sprite.x - @ox y = sprite.y - @oy nomwidth = Graphics.width nomheight = Graphics.height if sprite.opacity < 64 || x < -50 || x > nomwidth + 128 || y < -300 || y > nomheight + 20 sprite.x = rand(nomwidth + 150) - 50 + @ox sprite.y = rand(nomheight + 150) - 200 + @oy sprite.opacity = 255 end end def make_ccoa_bitmaps color3 = Color.new(255, 167, 192, 255) color4 = Color.new(213, 106, 136, 255) @petal_bitmap = Bitmap.new(8, 8) @petal_bitmap.fill_rect(0, 6, 2, 2, color3) @petal_bitmap.fill_rect(2, 4, 2, 2, color3) @petal_bitmap.fill_rect(4, 2, 2, 2, color3) @petal_bitmap.fill_rect(6, 0, 2, 2, color3) @petal_bitmap.fill_rect(2, 6, 2, 2, color4) @petal_bitmap.fill_rect(4, 4, 2, 2, color4) @petal_bitmap.fill_rect(6, 2, 2, 2, color4) create_autumn_leaf_bitmaps # Hojas de otoño create_green_leaf_bitmaps # Hojas verdes create_rose_bitmaps # Pétalos de rosa create_bluef_bitmaps # Pétalos de rosa create_feather_bitmaps # Plumas create_sparkle_bitmaps # Chispas # Lluvia de sangre darkRed = Color.new(141, 9, 9, 255) @blood_rain_bitmap = Bitmap.new(14, 112) for i in 0..6 @blood_rain_bitmap.fill_rect(12-(i*2), i*16, 2, 16, darkRed) end # Usuario definido @user_bitmaps = [] update_user_bitmaps end def create_autumn_leaf_bitmaps brightOrange = Color.new(248, 88, 0, 255) orangeBrown = Color.new(144, 80, 56, 255) burntRed = Color.new(152, 0, 0, 255) paleOrange = Color.new(232, 160, 128, 255) darkBrown = Color.new(72, 40, 0, 255) @autumn_leaf_bitmaps = [] @autumn_leaf_bitmaps[0] = Bitmap.new(16, 16) @autumn_leaf_bitmaps[0].fill_rect(10, 2, 2, 2, orangeBrown) @autumn_leaf_bitmaps[0].fill_rect(12, 2, 2, 2, brightOrange) @autumn_leaf_bitmaps[0].fill_rect(14, 2, 2, 2, paleOrange) @autumn_leaf_bitmaps[0].fill_rect(6, 4, 2, 2, orangeBrown) @autumn_leaf_bitmaps[0].fill_rect(8, 4, 4, 2, brightOrange) @autumn_leaf_bitmaps[0].fill_rect(12, 4, 2, 2, paleOrange) @autumn_leaf_bitmaps[0].fill_rect(4, 6, 2, 2, orangeBrown) @autumn_leaf_bitmaps[0].fill_rect(6, 6, 2, 2, brightOrange) @autumn_leaf_bitmaps[0].fill_rect(8, 6, 4, 2, paleOrange) @autumn_leaf_bitmaps[0].fill_rect(2, 8, 2, 2, orangeBrown) @autumn_leaf_bitmaps[0].fill_rect(4, 8, 2, 2, brightOrange) @autumn_leaf_bitmaps[0].fill_rect(6, 8, 2, 2, paleOrange) @autumn_leaf_bitmaps[0].fill_rect(2, 10, 2, 2, brightOrange) @autumn_leaf_bitmaps[0].fill_rect(4, 10, 2, 2, paleOrange) @autumn_leaf_bitmaps[0].fill_rect(0, 12, 2, 2, orangeBrown) @autumn_leaf_bitmaps[0].fill_rect(2, 12, 2, 2, paleOrange) @autumn_leaf_bitmaps[0].fill_rect(0, 14, 2, 2, paleOrange) @autumn_leaf_bitmaps[1] = Bitmap.new(16, 16) @autumn_leaf_bitmaps[1].fill_rect(6, 0, 2, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(14, 0, 2, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(6, 2, 2, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(8, 2, 2, 2, burntRed) @autumn_leaf_bitmaps[1].fill_rect(12, 2, 2, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(0, 4, 2, 2, paleOrange) @autumn_leaf_bitmaps[1].fill_rect(2, 4, 2, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(4, 4, 2, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(6, 4, 2, 2, burntRed) @autumn_leaf_bitmaps[1].fill_rect(8, 4, 2, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(10, 4, 2, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(2, 6, 6, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(8, 6, 4, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(12, 6, 2, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(4, 8, 2, 2, burntRed) @autumn_leaf_bitmaps[1].fill_rect(6, 8, 6, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(12, 8, 2, 2, burntRed) @autumn_leaf_bitmaps[1].fill_rect(14, 8, 2, 2, darkBrown) @autumn_leaf_bitmaps[1].fill_rect(2, 10, 2, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(4, 10, 4, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(8, 10, 2, 2, orangeBrown) @autumn_leaf_bitmaps[1].fill_rect(10, 10, 2, 2, burntRed) @autumn_leaf_bitmaps[1].fill_rect(2, 12, 4, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(8, 12, 4, 2, burntRed) @autumn_leaf_bitmaps[1].fill_rect(0, 14, 2, 2, brightOrange) @autumn_leaf_bitmaps[1].fill_rect(10, 14, 2, 2, darkBrown) @autumn_leaf_bitmaps[2] = @autumn_leaf_bitmaps[0].clone @autumn_leaf_bitmaps[3] = @autumn_leaf_bitmaps[1].clone end def create_green_leaf_bitmaps darkGreen = Color.new(62, 76, 31, 255) midGreen = Color.new(76, 91, 43, 255) khaki = Color.new(105, 114, 66, 255) lightGreen = Color.new(128, 136, 88, 255) @green_leaf_bitmaps = [] @green_leaf_bitmaps[0] = Bitmap.new(16, 16) @green_leaf_bitmaps[0].fill_rect(2, 0, 2, 2, darkGreen) @green_leaf_bitmaps[0].fill_rect(2, 2, 2, 2, midGreen) @green_leaf_bitmaps[0].fill_rect(4, 2, 2, 2, darkGreen) @green_leaf_bitmaps[0].fill_rect(4, 4, 2, 2, khaki) @green_leaf_bitmaps[0].fill_rect(6, 4, 2, 2, darkGreen) @green_leaf_bitmaps[0].fill_rect(8, 4, 2, 2, khaki) @green_leaf_bitmaps[0].fill_rect(4, 6, 6, 2, midGreen) @green_leaf_bitmaps[0].fill_rect(10, 6, 2, 2, khaki) @green_leaf_bitmaps[0].fill_rect(4, 8, 4, 2, midGreen) @green_leaf_bitmaps[0].fill_rect(8, 8, 2, 2, darkGreen) @green_leaf_bitmaps[0].fill_rect(10, 8, 2, 2, lightGreen) @green_leaf_bitmaps[0].fill_rect(12, 8, 2, 2, khaki) # Clonar para variaciones for i in 1..11 @green_leaf_bitmaps[i] = @green_leaf_bitmaps[0].clone end end def create_rose_bitmaps brightRed = Color.new(255, 0, 0, 255) midRed = Color.new(179, 17, 17, 255) darkRed = Color.new(141, 9, 9, 255) @rose_bitmaps = [] @rose_bitmaps[0] = Bitmap.new(6, 6) @rose_bitmaps[0].fill_rect(2, 0, 4, 2, brightRed) @rose_bitmaps[0].fill_rect(0, 2, 2, 4, brightRed) @rose_bitmaps[0].fill_rect(2, 2, 4, 4, midRed) @rose_bitmaps[0].fill_rect(4, 4, 2, 2, darkRed) @rose_bitmaps[1] = Bitmap.new(6, 6) @rose_bitmaps[1].fill_rect(0, 2, 2, 2, midRed) @rose_bitmaps[1].fill_rect(2, 2, 2, 2, brightRed) @rose_bitmaps[1].fill_rect(2, 4, 2, 4, midRed) end def create_bluef_bitmaps brightRed = Color.new(94, 107, 245, 255) midRed = Color.new(70, 79, 218, 255) darkRed = Color.new(34, 55, 190, 255) @bluef_bitmaps = [] @bluef_bitmaps[0] = Bitmap.new(6, 6) @bluef_bitmaps[0].fill_rect(2, 0, 4, 2, brightRed) @bluef_bitmaps[0].fill_rect(0, 2, 2, 4, brightRed) @bluef_bitmaps[0].fill_rect(2, 2, 4, 4, midRed) @bluef_bitmaps[0].fill_rect(4, 4, 2, 2, darkRed) @bluef_bitmaps[1] = Bitmap.new(6, 6) @bluef_bitmaps[1].fill_rect(0, 2, 2, 2, midRed) @bluef_bitmaps[1].fill_rect(2, 2, 2, 2, brightRed) @bluef_bitmaps[1].fill_rect(2, 4, 2, 4, midRed) end def create_feather_bitmaps white = Color.new(255, 255, 255, 255) grey = Color.new(214, 217, 217, 150) @feather_bitmaps = [] for i in 0..3 @feather_bitmaps[i] = Bitmap.new(6, 6) # Crear plumas más visibles x2 @feather_bitmaps[i].fill_rect(rand(3)*2, rand(3)*2, 2, 2, white) @feather_bitmaps[i].fill_rect(rand(3)*2, rand(3)*2, 2, 2, grey) end end def create_sparkle_bitmaps lightBlue = Color.new(181, 244, 255, 255) midBlue = Color.new(126, 197, 235, 255) darkBlue = Color.new(77, 136, 225, 255) white = Color.new(255, 255, 255, 255) @sparkle_bitmaps = [] @sparkle_bitmaps[0] = Bitmap.new(14, 14) @sparkle_bitmaps[0].fill_rect(6, 6, 2, 2, darkBlue) @sparkle_bitmaps[1] = Bitmap.new(14, 14) @sparkle_bitmaps[1].fill_rect(6, 4, 2, 6, darkBlue) @sparkle_bitmaps[1].fill_rect(4, 6, 6, 2, darkBlue) @sparkle_bitmaps[1].fill_rect(6, 6, 2, 2, midBlue) @sparkle_bitmaps[2] = Bitmap.new(14, 14) @sparkle_bitmaps[2].fill_rect(4, 4, 6, 6, midBlue) @sparkle_bitmaps[2].fill_rect(6, 6, 2, 2, lightBlue) @sparkle_bitmaps[3] = Bitmap.new(14, 14) @sparkle_bitmaps[3].fill_rect(6, 2, 2, 10, darkBlue) @sparkle_bitmaps[3].fill_rect(2, 6, 10, 2, darkBlue) @sparkle_bitmaps[3].fill_rect(6, 6, 2, 2, white) @sparkle_bitmaps[4] = @sparkle_bitmaps[2].clone @sparkle_bitmaps[5] = @sparkle_bitmaps[3].clone @sparkle_bitmaps[6] = @sparkle_bitmaps[3].clone end def update_user_bitmaps for image in @user_bitmaps image.dispose rescue nil end @user_bitmaps.clear for name in $WEATHER_IMAGES begin @user_bitmaps.push(RPG::Cache.picture(name)) rescue end end @user_bitmaps.push(Bitmap.new(1, 1)) if @user_bitmaps.empty? end def dispose_ccoa_bitmaps [@petal_bitmap, @blood_rain_bitmap].each { |bm| bm.dispose rescue nil } [@autumn_leaf_bitmaps, @green_leaf_bitmaps, @rose_bitmaps, @bluef_bitmaps, @feather_bitmaps, @sparkle_bitmaps, @user_bitmaps].each do |array| array.each { |bm| bm.dispose rescue nil } if array end end end end