1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
#==============================================================================
# ■ Sprite_Sun
# # Based on Sprite_Shadow, modified by Rataime
#==============================================================================
CATERPILLAR_COMPATIBLE = true
class Game_Party
attr_reader :characters
end
class Sprite_Sun < RPG::Sprite
attr_accessor :character
def initialize(viewport, character = nil, self_angle = 45,self_opacity = 128)
super(viewport)
@character = character
@self_angle=self_angle
@self_opacity=self_opacity
update
end
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
@direct=@character.direction
if self.angle>90 or angle<-90
if @direct== 6
sy = ( 4- 2) / 2 * @ch
end
if @direct== 4
sy = ( 6- 2) / 2 * @ch
end
if @direct != 4 and @direct !=6
sy = (@character.direction - 2) / 2 * @ch
end
else
sy = (@character.direction - 2) / 2 * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y-5
self.z = @character.screen_z(@ch)-1
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
self.angle = @self_angle-90
self.color = Color.new(0, 0, 0)
$game_map.sun==-1 ? self.opacity = 0: self.opacity = @self_opacity
end
end
#===================================================
# ▼ CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias sun_initialize initialize
def initialize(viewport, character = nil)
@character = character
super(viewport)
@sunlist=[]
if (character.is_a?(Game_Event) and character.list!=nil and character.list[0].code == 108 and character.list[0].parameters == ["sun"])
if (character.list[1]!=nil and character.list[1].code == 108)
@self_angle=character.list[1].parameters[0]
else
@self_angle=45
end
if (character.list[2]!=nil and character.list[2].code == 108)
@self_opacity=character.list[2].parameters[0]
else
@self_opacity=128
end
for i in $game_map.events.keys.sort
if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["o"])
@sunlist[i+1] = Sprite_Sun.new(viewport, $game_map.events[i],@self_angle,@self_opacity)
end
end
@sunlist[1] = Sprite_Sun.new(viewport, $game_player,@self_angle,@self_opacity)
#===================================================
# ● Compatibility with fukuyama's caterpillar script
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
@sunlist.push(Sprite_Sun.new(viewport, member,@self_angle,@self_opacity))
end
end
#===================================================
# ● End of the compatibility
#===================================================
end
sun_initialize(viewport, @character)
end
alias sun_update update
def update
sun_update
if @sunlist!=[]
for i in 1..@sunlist.size
if @sunlist[i]!=nil
@sunlist[i].update
end
end
end
end
end
#===================================================
# ▼ CLASS Scene_Save edit
#===================================================
class Scene_Save < Scene_File
alias sun_write_save_data write_save_data
def write_save_data(file)
$game_map.sun = nil
sun_write_save_data(file)
end
end
#===================================================
# ▼ CLASS Game_Map edit
#===================================================
class Game_Map
attr_accessor :sun
end |