Код:
=begin
* Flashlight System.
Vers. 1.1
Created by Lukas Cahyadi Gunawan; Publish : 16/6/2012
How To Use ? Place above Main.
For RPG XP(RGSS)
Feature:
- Flashlight effect.
- Outdor support.
Thanks to :
- Jesus My Savior
This work is protected by the following license:
----------------------------------------------------------------------------
Creative Commons - Attribusi-NonKomersial 3.0 Unported License.
( http://creativecommons.org/licenses/by-nc/3.0/ )
CC BY-NC (Atribusi-NonKomersial).
Memperbolehkan pihak lain untuk menyalin, mengumumkan, menyebarkan,
menggubah, dan mengadaptasi ciptaan ini,
selama mencantumkan nama pembuat.
----------------------------------------------------------------------------
If you find bugs or errors can contact me at http://www.rpgmakerid.com/u2336.
=end
module LCG
#=============================================================================#
# ▼ CONFIGURATION ▼
#-----------------------------------------------------------------------------#
#Explanation of the configuration, see :
#Tools > Database > Tilesets;
#Note! "Tileset", "Priority" and "Terrain tag" from the map that is
# used in the demo. And also see "Layer" from "Tile of map"
TER_TAGS = 1 # Set terrain tag, trick 1.
TER_TAGSO = 2 # Set terrain tag, trick 2.
SWITCH_SENTER = 3 # Set switch id for flashlight.
# $game_system.opac_senter = 255 (Set opacity light.)
#-----------------------------------------------------------------------------#
# ▲ CONFIGURATION ▲
#=============================================================================#
end
class Game_Temp
attr_accessor :prior_map
alias prior_map_lcg initialize
def initialize; prior_map_lcg; @prior_map = []; end
end
class Game_System
attr_accessor :opac_senter
alias prior__sysmap_lcg initialize
def initialize; prior__sysmap_lcg; @opac_senter = 255; end
end
class Game_Map
def change_prio(x, y, z)
tile_id = data[x, y, 2]; @priorities[tile_id] = z if @map_id != 0 && tile_id != nil
end
end
class Sprite_Character < RPG::Sprite
include LCG
def initialize(viewport, character = nil)
super(viewport)
@character = character
if character == $game_player; @tt = ':P'; @a = @b = @xa = 0
@charsy, @charsx = @character.screen_y, @character.screen_x
@chary, @charx = @character.y, @character.x
@s1 = $game_switches[SWITCH_SENTER]; senter
end
update
end
alias flash_eff_up update
def update; flash_eff_up
if @tt != nil
if @s1 != $game_switches[SWITCH_SENTER]; @s1 = $game_switches[SWITCH_SENTER]
@senter.visible = true if @s1; @senter.visible = false if !@s1; end
return unless @senter.visible
@charsy, @charsx = @character.screen_y, @character.screen_x
@chary, @charx = @character.y, @character.x
senter_update; increase_x if @tt == ':)'
increase_y if @tt == ':ngacay:'; minus_height if @tt == ':v'
minus_width if @tt == ':D'; senter if @direct != @character.direction
senter if !@character.moving? && @tt == ':P'
end
end
def senter; @direct = @character.direction
@tt, @senter_img = ';)', RPG::Cache.picture('light' + @direct.to_s)
@senter.bitmap.clear if @senter != nil; @senter_bitmap.clear if @senter_bitmap != nil
@senter_bitmap = Bitmap.new(@senter_img.width,@senter_img.height)
@senter = Sprite.new(viewport)
@senter.bitmap,@senter.blend_type,@senter.opacity = @senter_bitmap,1,$game_system.opac_senter
@s_w, @s_h = @senter_img.width, @senter_img.height
@senter_w, @senter_h = @senter_img.width, @senter_img.height; @xa = @ya = 0
case @direct
when 8
@senter_w = @s_w - 11 if $game_map.terrain_tag(@charx + 1, @chary - 1) == TER_TAGS
@xa = 16 if $game_map.terrain_tag(@charx - 1, @chary - 1) == TER_TAGS
@senter_w, @xa = @s_w - 27, 16 if @senter_w == @s_w - 11 && @xa == 16
@senter.x, @senter.y = @charsx - 32, @charsy - 64
when 2
@senter_w = @s_w - 11 if $game_map.terrain_tag(@charx + 1, @chary + 1) == TER_TAGS
@xa = 16 if $game_map.terrain_tag(@charx - 1, @chary + 1) == TER_TAGS
@senter_w, @xa = @s_w - 27, 16 if @senter_w == @s_w - 11 && @xa == 16
if $game_map.terrain_tag(@charx, @chary) == TER_TAGS
@senter_h = @s_h - 96 unless $game_map.terrain_tag(@charx, @chary + 1) != TER_TAGS
elsif $game_map.terrain_tag(@charx, @chary + 1) == TER_TAGS
@senter_h = @s_h - 64 unless $game_map.terrain_tag(@charx, @chary + 2) != TER_TAGS
elsif $game_map.terrain_tag(@charx, @chary + 2) == TER_TAGS
@senter_h = @s_h - 32; end; @senter.x, @senter.y = @charsx - 32, @charsy - 20
when 4
if $game_map.terrain_tag(@charx, @chary) == TER_TAGS
if $game_map.terrain_tag(@charx - 1, @chary) != TER_TAGS &&
$game_map.terrain_tag(@charx - 2, @chary) == TER_TAGS; @xa = 96
elsif $game_map.terrain_tag(@charx - 2, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx - 1, @chary - 1) == TER_TAGS; @xa = 128
elsif $game_map.terrain_tag(@charx - 3, @chary) == TER_TAGS; @xa = 64
end
elsif $game_map.terrain_tag(@charx - 3, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx - 2, @chary - 1) == TER_TAGS; @xa = 96
elsif $game_map.terrain_tag(@charx - 4, @chary) == TER_TAGS; @xa = 32
end
elsif $game_map.terrain_tag(@charx - 3, @chary - 1) == TER_TAGS; @xa = 64
elsif $game_map.terrain_tag(@charx - 4, @chary - 1) == TER_TAGS; @xa = 32
end
elsif $game_map.terrain_tag(@charx - 1, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 1, @chary - 1) == TER_TAGS
@xa = 128
elsif $game_map.terrain_tag(@charx - 2, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 2, @chary - 1) == TER_TAGS
@xa = 96
elsif $game_map.terrain_tag(@charx - 3, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 3, @chary - 1) == TER_TAGS
@xa = 64
elsif $game_map.terrain_tag(@charx - 4, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 4, @chary - 1) == TER_TAGS
@xa = 32; end
@senter.ox, @senter.x, @senter.y = 141, @charsx - 3, @charsy - 25
when 6
if $game_map.terrain_tag(@charx, @chary) == TER_TAGS
if $game_map.terrain_tag(@charx + 1, @chary) != TER_TAGS &&
$game_map.terrain_tag(@charx + 2, @chary) == TER_TAGS
@senter_w = @s_w - 96
elsif $game_map.terrain_tag(@charx + 2, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx + 1, @chary - 1) == TER_TAGS
@senter_w = @s_w - 160
elsif $game_map.terrain_tag(@charx + 3, @chary) == TER_TAGS
@senter_w = @s_w - 64
end
elsif $game_map.terrain_tag(@charx + 3, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx + 2, @chary - 1) == TER_TAGS
@senter_w = @s_w - 96
elsif $game_map.terrain_tag(@charx + 4, @chary) == TER_TAGS
@senter_w = @s_w - 32
end
elsif $game_map.terrain_tag(@charx + 3, @chary - 1) == TER_TAGS
@senter_w = @s_w - 64
elsif $game_map.terrain_tag(@charx + 4, @chary - 1) == TER_TAGS
@senter_w = @s_w - 32
end
elsif $game_map.terrain_tag(@charx + 1, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 1, @chary - 1) == TER_TAGS
@senter_w = @s_w - 128
elsif $game_map.terrain_tag(@charx + 2, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 2, @chary - 1) == TER_TAGS
@senter_w = @s_w - 96
elsif $game_map.terrain_tag(@charx + 3, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 3, @chary - 1) == TER_TAGS
@senter_w = @s_w - 64
elsif $game_map.terrain_tag(@charx + 4, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 4, @chary - 1) == TER_TAGS
@senter_w = @s_w - 32; end; @senter.x, @senter.y = @charsx, @charsy - 25
end; @senter.z = self.z + (@direct == 8 ? -1 : 0)
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
@senter.visible = true if @s1; @senter.visible = false if !@s1
end
def increase_x
@xa = @xa + (@a - @senter.x); @senter_bitmap.clear
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
if @xa >= @b; @a = 0; @xa = @b; @b = 0
@senter_bitmap.clear; @senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect); @tt = ':P'
end
end
def increase_y
@ya = @ya + (@a - @senter.y); @senter_bitmap.clear
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
if @ya >= @b; @a = 0; @ya = @b; @b = 0
@senter_bitmap.clear; @senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect); @tt = ':P'
end
end
def minus_height; @senter_h = @senter_h - (@senter.y - @a); @senter_bitmap.clear
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
if @senter_h <= @s_h - @b; @a = 0; @senter_h = @s_h - @b
@senter_bitmap.clear; @senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect); @b = 0; @tt = ':P'
end
end
def minus_width; @senter_w = @senter_w - (@senter.x - @a); @senter_bitmap.clear
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
if @senter_w <= @s_w - @b; @a = 0; @senter_w = @s_w - @b
@senter_bitmap.clear; @senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect); @b = 0; @tt = ':P'
end
end
def senter_update; if @s1
if Input.dir4 != 0
if $game_temp.prior_map[0] != nil; arr_p = $game_temp.prior_map[0]
$game_map.change_prio(arr_p[0],arr_p[1],arr_p[2]); $game_temp.prior_map[0] = nil
end
if $game_temp.prior_map[1] != nil; arr_p = $game_temp.prior_map[1]
$game_map.change_prio(arr_p[0],arr_p[1],arr_p[2]); $game_temp.prior_map[1] = nil
end
if $game_temp.prior_map[2] != nil; arr_p = $game_temp.prior_map[2]
$game_map.change_prio(arr_p[0],arr_p[1],arr_p[2]); $game_temp.prior_map[2] = nil
end
end
case Input.dir4
when 8; @senter_w, @xa = @s_w, 0; @senter_bitmap.clear
@senter_w = @s_w - 11 if $game_map.terrain_tag(@charx + 1, @chary - 1) == TER_TAGS
@xa = 16 if $game_map.terrain_tag(@charx - 1, @chary - 1) == TER_TAGS
@senter_w, @xa = @s_w - 27, 16 if @senter_w == @s_w - 11 && @xa == 16
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
if $game_map.terrain_tag(@charx, @chary - 1) == TER_TAGS
@tt, @a, @b = ':ngacay:', @senter.y, 16; else; @ya = 0; end
when 2; @senter_w, @xa = @s_w, 0; @senter_bitmap.clear
@senter_w = @s_w - 11 if $game_map.terrain_tag(@charx + 1, @chary + 1) == TER_TAGS
@xa = 16 if $game_map.terrain_tag(@charx - 1, @chary + 1) == TER_TAGS
@senter_w, @xa = @s_w - 27, 16 if @senter_w == @s_w - 11 && @xa == 16
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
if $game_map.terrain_tag(@charx, @chary + 2) == TER_TAGSO
$game_map.change_prio(@charx, @chary + 2, 1)
$game_temp.prior_map[0] = [@charx, @chary + 2, 0]
if $game_map.terrain_tag(@charx + 1, @chary + 2) == TER_TAGSO
$game_map.change_prio(@charx + 1, @chary + 2, 1)
$game_temp.prior_map[1] = [@charx + 1, @chary + 2, 0]; end
if $game_map.terrain_tag(@charx - 1, @chary + 2) == TER_TAGSO
$game_map.change_prio(@charx - 1, @chary + 2, 1)
$game_temp.prior_map[2] = [@charx - 1, @chary + 2, 0]; end
end
if $game_map.terrain_tag(@charx, @chary) == TER_TAGS
@tt, @a, @b = ':v', @senter.y, 80 unless $game_map.terrain_tag(@charx, @chary + 1) != TER_TAGS
elsif $game_map.terrain_tag(@charx, @chary + 1) == TER_TAGS
@tt, @a, @b = ':v', @senter.y, 48 unless $game_map.terrain_tag(@charx, @chary + 2) != TER_TAGS
elsif $game_map.terrain_tag(@charx, @chary + 2) == TER_TAGS
@tt, @a, @b = ':v', @senter.y, 16; else; @senter_h = @s_h; end
when 4
if $game_map.terrain_tag(@charx - 4, @chary + 1) == TER_TAGSO
$game_map.change_prio(@charx - 4, @chary + 1, 1)
$game_temp.prior_map[0] = [@charx - 4, @chary + 1, 0]
end
if $game_map.terrain_tag(@charx - 3, @chary + 1) == TER_TAGSO
$game_map.change_prio(@charx - 3, @chary + 1, 1)
$game_temp.prior_map[1] = [@charx - 3, @chary + 1, 0]
end
if $game_map.terrain_tag(@charx - 2, @chary + 1) == TER_TAGSO
$game_map.change_prio(@charx - 2, @chary + 1, 1)
$game_temp.prior_map[2] = [@charx - 2, @chary + 1, 0]
end
if $game_map.terrain_tag(@charx, @chary) == TER_TAGS
if $game_map.terrain_tag(@charx - 1, @chary) != TER_TAGS &&
$game_map.terrain_tag(@charx - 2, @chary) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 80
elsif $game_map.terrain_tag(@charx - 2, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx - 1, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 112
elsif $game_map.terrain_tag(@charx - 3, @chary) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 48
end
elsif $game_map.terrain_tag(@charx - 3, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx - 2, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 80
elsif $game_map.terrain_tag(@charx - 4, @chary) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 16
end
elsif $game_map.terrain_tag(@charx - 3, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 48
elsif $game_map.terrain_tag(@charx - 4, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 16
else; @senter_bitmap.clear; @xa = 0
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
end
elsif $game_map.terrain_tag(@charx - 1, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 1, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 112
elsif $game_map.terrain_tag(@charx - 2, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 2, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 80
elsif $game_map.terrain_tag(@charx - 3, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 3, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 48
elsif $game_map.terrain_tag(@charx - 4, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx - 4, @chary - 1) == TER_TAGS
@tt, @a, @b = ':)', @senter.x, 16; else; @xa = 0; end
when 6
if $game_map.terrain_tag(@charx + 4, @chary + 1) == TER_TAGSO
$game_map.change_prio(@charx + 4, @chary + 1, 1)
$game_temp.prior_map[0] = [@charx + 4, @chary + 1, 0]; end
if $game_map.terrain_tag(@charx + 3, @chary + 1) == TER_TAGSO
$game_map.change_prio(@charx + 3, @chary + 1, 1)
$game_temp.prior_map[1] = [@charx + 3, @chary + 1, 0]; end
if $game_map.terrain_tag(@charx + 2, @chary + 1) == TER_TAGSO
$game_map.change_prio(@charx + 2, @chary + 1, 1)
$game_temp.prior_map[2] = [@charx + 2, @chary + 1, 0]; end
if $game_map.terrain_tag(@charx, @chary) == TER_TAGS
if $game_map.terrain_tag(@charx + 1, @chary) != TER_TAGS &&
$game_map.terrain_tag(@charx + 2, @chary) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 80
elsif $game_map.terrain_tag(@charx + 2, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx + 1, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 112
elsif $game_map.terrain_tag(@charx + 3, @chary) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 48
end
elsif $game_map.terrain_tag(@charx + 3, @chary) != TER_TAGS
if $game_map.terrain_tag(@charx + 2, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 80
elsif $game_map.terrain_tag(@charx + 4, @chary) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 16
end
elsif $game_map.terrain_tag(@charx + 3, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 48
elsif $game_map.terrain_tag(@charx + 4, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 16
else; @senter_bitmap.clear; @senter_w = @s_w
@senter_rect = Rect.new(@xa, @ya, @senter_w, @senter_h)
@senter_bitmap.blt(@xa,@ya, @senter_img, @senter_rect)
end
elsif $game_map.terrain_tag(@charx + 1, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 1, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 112
elsif $game_map.terrain_tag(@charx + 2, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 2, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 80
elsif $game_map.terrain_tag(@charx + 3, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 3, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 48
elsif $game_map.terrain_tag(@charx + 4, @chary) == TER_TAGS &&
$game_map.terrain_tag(@charx + 4, @chary - 1) == TER_TAGS
@tt, @a, @b = ':D', @senter.x, 16; else; @senter_w = @s_w
end
end
case @direct
when 2; @senter.x, @senter.y = @charsx - 32, @charsy - 20
when 4; @senter.x, @senter.y = @charsx - 3, @charsy - 25
when 6; @senter.x, @senter.y = @charsx, @charsy - 25
when 8; @senter.x, @senter.y = @charsx - 32, @charsy - 64
end; @senter.z = self.z + (@direct == 8 ? -1 : 0); end
end
def dispose; super; return if @tt == nil
@senter.bitmap.dispose; @senter.dispose; @senter_bitmap.dispose
end
end
Социальные закладки