02-05-2014, 05:53 AM
I'm really screwing things up repeatedly with editing this script to try and improve perceived issues, ahaha.
Except I think this would cause a lot of lag? Maybe it's part of the lag that plagued RMXP. RMXP had different levels of priority for [*] tiles, what maybe needs to be done is altering the priority of those tiles, not the event sprites.
This is what my experimentation resulted in anyway, I don't think it's much better. The only thing that's really that great is the terrain tag 7 check to make a tile always appear over the hero, which works for the likes of doorways.
- This script does not take in account shift_y that makes sprites offset. If a game creator alters this, sprites extend further into other tiles. Editing the code to compensate for this, I then find that tall events standing under * tiles and the hero walking away from them there's momentary feet appearing over the hero.
- I'm not sure why x-axis tiles are being a bother. I was unable to be successful with having a loop to check tiles either side of an event. Sometimes walking away from a * tile there's a moment where the tile will reappear over the hero. This is a problem with tiles like fences or reception desks. Other times it's the opposite, which might be caused by my edits. Reverting those avoids that.
- It appears that even with the default offset of 4px, my sprites will cover three tiles. Their location, their upper body, and the smidgen of pixels they phase into. This is probably a cause of a large number of issues, as I edit things to consider their height and run into those issues.
Except I think this would cause a lot of lag? Maybe it's part of the lag that plagued RMXP. RMXP had different levels of priority for [*] tiles, what maybe needs to be done is altering the priority of those tiles, not the event sprites.
This is what my experimentation resulted in anyway, I don't think it's much better. The only thing that's really that great is the terrain tag 7 check to make a tile always appear over the hero, which works for the likes of doorways.
PHP Code:
<?php
#==============================================================================
# ▼ Moby's Script System - Correct Sprite Display V1.0
# -- Last Updated: 2014.02.05
# Edit by Taylor and brushfe
#==============================================================================
#==============================================================================
# ** Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Update Character Sprite
#--------------------------------------------------------------------------
alias :msscsd_update_characters :update_characters unless $@
def update_characters
# Original method
msscsd_update_characters
# On every sprite
@character_sprites.each do |curr_sprite|
# Determine if sprite has hero priority and visible
if curr_sprite.character.normal_priority? &&
curr_sprite.visible && curr_sprite.character.character_name != ""
# Get height in tiles
height = get_height(curr_sprite)
if height > 1
x = curr_sprite.character.x
#curr_sprite.z = 100
# Get tile data
id = $game_map.data[x, curr_sprite.character.y, 2]
flag_pos = $game_map.tileset.flags[id]
# Return if invalid tile
if (!(flag_pos & 0x10 != 0) || id == 0) # I HATE THIS LINE WITH A PASSION FOR NOT LETTING ME REPLACE IT WITH 'RETURN', FUCK
# Go through every tile the sprite may appear over
for i in 2..height
y = curr_sprite.character.y - (i - 1)
# Return if invalid tile
return if $game_map.data[x, y, 2].nil?
flag = $game_map.tileset.flags[$game_map.data[x, y, 2]]
# If valid and not terrian ID 7
if flag & 0x10 != 0 && $game_map.data[x, y, 2] != 0 && $game_map.terrain_tag(x, y) != 7
curr_sprite.z = 300 #+ curr_sprite.character.y
break
else
curr_sprite.z = 100
end
loc = [curr_sprite.character.x, curr_sprite.character.y - 1]
$game_map.events_xy(*loc).each do |event|
if event.normal_priority?
curr_sprite.z = 300 #+ curr_sprite.character.y
break
end
end
end
end # (!(flag_pos & 0x10 != 0) || id == 0)
end
end
end
end
#--------------------------------------------------------------------------
# * Gets the given Sprites height
#--------------------------------------------------------------------------
def get_height(curr_sprite)
height = 0
height = (curr_sprite.src_rect.height + curr_sprite.character.shift_y).to_f / 32
height += 1 if curr_sprite.src_rect.height % 32 > 0
return height.round + 1
end
end
(we could really do with a ruby tag with ruby syntax highlighting, 'cause this aint php)