Correct Character Sprite Display
#2
I'm really screwing things up repeatedly with editing this script to try and improve perceived issues, ahaha.
  • 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.
I think the thing is, every tile and event needs to have a z value influenced by their y axis or height. This z value would only come into play if [*] passability for tiles, or if normal priority for events. The cause of these visual errors is because what we're getting basically are "sheets" of sprites, that are associated with z-axies, and the z-axies are associated with what's above (y) the sprite. Because this is checked as a sprite moves onto a tile and is based only on what's above them, weirdness occurs because an event that's not next to a [*] or similar will be on a lower (z) "sheet".

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)
Reply }


Messages In This Thread
RE: Correct Character Sprite Display - by Taylor - 02-05-2014, 05:53 AM
RE: Correct Character Sprite Display - by Taylor - 02-05-2014, 10:17 PM
RE: Correct Character Sprite Display - by Taylor - 02-10-2014, 09:11 AM
RE: Correct Character Sprite Display - by Taylor - 02-10-2014, 11:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Character's Dash Animation kyonides 0 772 04-08-2024, 03:50 AM
Last Post: kyonides
   Set Map's Display Name ACE kyonides 0 1,195 12-16-2022, 09:44 PM
Last Post: kyonides
   New Character Properties with Calls 2.2 PK8 9 21,986 06-11-2012, 10:46 PM
Last Post: PK8
   Victor Engine - Character Control Victor Sant 0 5,112 01-04-2012, 09:54 AM
Last Post: Victor Sant
   Victor Engine - Character Effects Victor Sant 0 4,686 01-01-2012, 02:08 PM
Last Post: Victor Sant
   Sprite Mover woratana 0 4,814 01-22-2009, 01:19 PM
Last Post: woratana
   Sprite Sun syvkal 0 5,442 03-08-2008, 04:36 AM
Last Post: syvkal
   Sprite Shadow syvkal 0 6,055 03-08-2008, 04:31 AM
Last Post: syvkal
   8-Directional Movement with Sprite Support Kylock 0 8,909 03-07-2008, 07:06 PM
Last Post: Kylock



Users browsing this thread: 1 Guest(s)