SHOW:
|
|
- or go back to the newest paste.
1 | ##----------------------------------------------------------------------------- | |
2 | - | # Large Sprite ☆ Display Fix v1.3 |
2 | + | # Large Sprite ☆ Display Fix v1.2b |
3 | # Created by Neon Black at request of seita | |
4 | - | # v1.4 - 12.18.14 - Added position tuning |
4 | + | # v1.2 - 8.23.13 - Fixed a few slight positioning issues |
5 | - | # v1.3 - 1.12.14 - Viewport/position issue fixes |
5 | + | # v1.1 - 8.18.13 - Fixed an odd lag issue |
6 | - | # v1.1 - 8.18.13 - Fixed an odd lag issue |
6 | + | # v1.0 - 8.17.13 - Main script completed |
7 | - | # v1.0 - 8.17.13 - Main script completed |
7 | + | # Only for non-commercial use. See full terms of use and contact info at: |
8 | - | # For both commercial and non-commercial use as long as credit is given to |
8 | + | # http://cphouseset.wordpress.com/liscense-and-terms-of-use/ |
9 | - | # Neon Black and any additional authors. Licensed under Creative Commons |
9 | + | |
10 | - | # CC BY 4.0 - http://creativecommons.org/licenses/by/4.0/ |
10 | + | |
11 | ##------ | |
12 | ## By default, this script only affects the player. To allow it to affect | |
13 | ## an event page as well, add a comment with the tag <large sprite> to the page | |
14 | ## of the event you would like to have affected by this. | |
15 | ||
16 | class Sprite_Character < Sprite_Base | |
17 | ##------ | |
18 | ## The ID of the terrain used to display the large character above ☆ tiles. | |
19 | ## If the player is below this tile (y position), the sprite will appear | |
20 | ## above all tiles and events from that y position up. If the player is on | |
21 | ## the same tile or above (y position) the event will appear BELOW ☆ tiles | |
22 | ## from that position up. | |
23 | ##------ | |
24 | UpperTerrain = 7 | |
25 | ||
26 | ## Alias the update method to add in the new graphic check. | |
27 | - | |
27 | + | |
28 | def update_position(*args) | |
29 | - | ## This value is the pixel tuning used to check the location. This is |
29 | + | |
30 | - | ## because characters tagged with a '!' in their name are drawn lower than |
30 | + | |
31 | - | ## normal characters and are considered to be lower than these. This causes |
31 | + | |
32 | - | ## the script to think they are on the tile below where they really are and |
32 | + | |
33 | - | ## draw them above tiles they should appear under. |
33 | + | |
34 | alias :cp_073013_dispose :dispose | |
35 | - | Tuning = -1 |
35 | + | |
36 | - | |
36 | + | |
37 | - | alias :cp_011214_update_bitmap :update_bitmap |
37 | + | |
38 | - | def update_bitmap(*args) |
38 | + | |
39 | - | if graphic_changed? && @set_upper_area_sprite |
39 | + | |
40 | - | @force_no_gfx_change = true |
40 | + | ## Alias the graphic changed method to allow the sprite to revent to what it |
41 | - | else |
41 | + | ## was during the last frame. This allows the check to work again. |
42 | - | @force_no_gfx_change = false |
42 | + | alias :cp_073013_graphic_changed? :graphic_changed? |
43 | def graphic_changed?(*args) | |
44 | - | cp_011214_update_bitmap(*args) |
44 | + | cp_073013_graphic_changed?(*args) || @set_upper_area_sprite |
45 | end | |
46 | ||
47 | ## Check if the sprite is onscreen. Reduces redundant drawing. | |
48 | def sprite_is_onscreen? | |
49 | return false if @character.is_a?(Game_Vehicle) || @character.is_a?(Game_Follower) | |
50 | return false unless @character.is_a?(Game_Player) || @character.large_sprite | |
51 | return false if @character.screen_z >= 200 | |
52 | top_left, bot_right = get_edge_corner_dis | |
53 | return false if top_left[0] > Graphics.width | |
54 | return false if top_left[1] > Graphics.height | |
55 | return false if bot_right[0] < 0 | |
56 | return false if bot_right[1] < 0 | |
57 | return true | |
58 | end | |
59 | ||
60 | ## Get the top left and bottom right positions. | |
61 | - | #~ ## Alias the graphic changed method to allow the sprite to revent to what it |
61 | + | |
62 | - | #~ ## was during the last frame. This allows the check to work again. |
62 | + | |
63 | - | #~ alias :cp_073013_graphic_changed? :graphic_changed? |
63 | + | |
64 | - | #~ def graphic_changed?(*args) |
64 | + | |
65 | - | #~ cp_073013_graphic_changed?(*args) || @set_upper_area_sprite |
65 | + | |
66 | - | #~ end |
66 | + | |
67 | ## Long method that checks each position and draws the upper sprite. | |
68 | def check_encompassed_area | |
69 | @set_upper_area_sprite = false | |
70 | top_left, bot_right = get_edge_corner_dis | |
71 | last_x, last_y, copy_region = nil, nil, 0 | |
72 | map_xd, map_yd = $game_map.display_x * 32, $game_map.display_y * 32 | |
73 | ##total_height = (self.height + @character.jump_height).round | |
74 | total_height = (self.oy).round | |
75 | self.width.times do |x| | |
76 | xp = map_xd.to_i + top_left[0] + x | |
77 | unless xp / 32 == last_x | |
78 | last_x = xp / 32 | |
79 | last_y, copy_region = nil, 0 | |
80 | total_height.times do |y| | |
81 | yp = map_yd.to_i + bot_right[1] + @character.jump_height - y | |
82 | next if yp.to_i / 32 == last_y | |
83 | last_y = yp.to_i / 32 | |
84 | if last_y == (@character.screen_y + map_yd).to_i / 32 | |
85 | #~ if last_y == (@character.screen_y + @character.jump_height + | |
86 | #~ map_yd).to_i / 32 | |
87 | break if $game_map.terrain_tag(last_x, last_y) == UpperTerrain | |
88 | next | |
89 | end | |
90 | - | if @set_upper_area_sprite && !@force_no_gfx_change |
90 | + | |
91 | - | old_src = self.src_rect.clone |
91 | + | |
92 | - | self.bitmap = @old_bitmap |
92 | + | |
93 | - | self.src_rect = old_src |
93 | + | |
94 | end | |
95 | end | |
96 | next if copy_region == 0 | |
97 | rect = Rect.new(src_rect.x + x, src_rect.y, 1, copy_region) | |
98 | @upper_area_sprite.bitmap.blt(x, 0, self.bitmap, rect) | |
99 | - | total_height = (self.height + @character.jump_height).round |
99 | + | |
100 | end | |
101 | if !@set_upper_area_sprite && @upper_area_sprite | |
102 | @upper_area_sprite.visible = false | |
103 | end | |
104 | end | |
105 | ||
106 | - | yp = map_yd.to_i + bot_right[1] + @character.jump_height - y + Tuning |
106 | + | |
107 | def set_upper_sprite | |
108 | return if @set_upper_area_sprite | |
109 | - | if last_y == (@character.screen_y + @character.jump_height + Tuning + |
109 | + | |
110 | - | map_yd).to_i / 32 |
110 | + | |
111 | props = ["x", "y", "ox", "oy", "zoom_x", "zoom_y", "angle", "mirror", | |
112 | "bush_depth", "opacity", "blend_type", "color", "tone", "visible", | |
113 | "viewport"] | |
114 | props.each do |meth| | |
115 | @upper_area_sprite.method("#{meth}=").call(self.method(meth).call) | |
116 | end | |
117 | #~ @upper_area_sprite.x = @upper_area_sprite.y = 100 | |
118 | @upper_area_sprite.z = 200 | |
119 | @upper_area_sprite.viewport = @viewport1 | |
120 | @set_upper_area_sprite = true | |
121 | old_bitmap, old_src_rect = self.bitmap, self.src_rect.clone | |
122 | self.bitmap = Bitmap.new(old_bitmap.width, old_bitmap.height) | |
123 | self.bitmap.blt(0, 0, old_bitmap, old_bitmap.rect) | |
124 | self.src_rect = old_src_rect | |
125 | end | |
126 | end | |
127 | ||
128 | class Game_Event < Game_Character | |
129 | attr_reader :large_sprite | |
130 | ||
131 | alias :cp_081713_setup_page_settings :setup_page_settings | |
132 | def setup_page_settings(*args) | |
133 | cp_081713_setup_page_settings(*args) | |
134 | get_large_sprite_conditions | |
135 | end | |
136 | ||
137 | def get_large_sprite_conditions | |
138 | @large_sprite = false | |
139 | return if @list.nil? || @list.empty? | |
140 | @list.each do |line| | |
141 | next unless line.code == 108 || line.code == 408 | |
142 | case line.parameters[0] | |
143 | - | @old_bitmap, old_src_rect = self.bitmap, self.src_rect.clone |
143 | + | |
144 | - | self.bitmap = Bitmap.new(@old_bitmap.width, @old_bitmap.height) |
144 | + | |
145 | - | self.bitmap.blt(0, 0, @old_bitmap, @old_bitmap.rect) |
145 | + | |
146 | end | |
147 | end | |
148 | end |