XP 스크립트

http://www.rmxp.org/forums/showthread.php?t=7121
(로그인 필요)
이벤트에 지정된 스프라이트의 크기가 클 경우, 거기에 맞춰서 이벤트의 '크기'를 지정하는 것입니다.(여기서 말하는 이벤트의 '크기'는 해당 이벤트를 플레이어나 다른 이벤트가 통과할 수 있는가 여부와 관련있습니다) 일단 작동은 첨부된 데모를 참조하기 바랍니다.


class Game_Character

attr_accessor :size_x # event size x
attr_accessor :size_y # event size y
attr_accessor :tiles_left # sizing - tiles to the left
attr_accessor :tiles_right # sizing - tiles to the right

def initialize
@id = 0
@x = 0
@y = 0
@real_x = 0
@real_y = 0
@tile_id = 0
@character_name = ""
@character_hue = 0
@opacity = 255
@blend_type = 0
@direction = 2
@pattern = 0
@move_route_forcing = false
@through = false
@animation_id = 0
@transparent = false
@original_direction = 2
@original_pattern = 0
@move_type = 0
@move_speed = 4
@move_frequency = 6
@move_route = nil
@move_route_index = 0
@original_move_route = nil
@original_move_route_index = 0
@walk_anime = true
@step_anime = false
@direction_fix = false
@always_on_top = false
@anime_count = 0
@stop_count = 0
@jump_count = 0
@jump_peak = 0
@wait_count = 0
@locked = false
@prelock_direction = 0
@size_x = 1
@size_y = 1
@tiles_left = 0
@tiles_right = 0
end

#--------------------------------------------------------------------------
# *** BEGIN Sized Events v1.0
#--------------------------------------------------------------------------
# By Toby Zerner
# USAGE:
# In a parallel process event, call this script-x:
# $game_map.events[ID].size(SIZE_X, SIZE_Y)
# Replacing the words in capitals with the actual details.
#--------------------------------------------------------------------------
def size(x, y)
# Set instance variables
@size_x = x
@size_y = y
# Work out the number of tiles either side of the event
tiles_x = (@size_x - 1) / 2
@tiles_left = tiles_x.floor
@tiles_right = tiles_x.ceil
end

#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
# EDITED FOR SIZED EVENTS
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# If coordinates are outside of map
unless $game_map.valid?(new_x, new_y)
# impassable
return false
end
# If through is ON
if @through
# passable
return true
end

# Check map passability settings
# Loop through each x tile
for i in 0...@size_x
# Check x coordinates
# If unable to leave first move tile in designated direction
unless $game_map.passable?(x - @tiles_left + i, y, d, self) then return false end
unless $game_map.passable?(new_x - @tiles_left + i, new_y, 10 - d) then return false end
# Loop through each y tile
for j in 0...@size_y
# Check y coordinates
# If unable to leave first move tile in designated direction
unless $game_map.passable?(x, y - j, d, self) then return false end
# If unable to enter move tile in designated direction
unless $game_map.passable?(new_x, new_y - j, 10 - d) then return false end
# Check x and y coordinates
# If unable to leave first move tile in designated direction
unless $game_map.passable?(x - @tiles_left + i, y - j, d, self) then return false end
# If unable to enter move tile in designated direction
unless $game_map.passable?(new_x - @tiles_left + i, new_y - j, 10 - d) then return false end
end
end

# Loop through map events
for event in $game_map.events.values
# If self is in range of [event]'s sizing, we can't pass
if event_collide?(self, event, new_x, new_y)
return false
end
end

# If player coordinates are consistent with move destination
if event_collide?(self, $game_player, new_x, new_y) and self != $game_player
return false
end

# passable
return true
end

#--------------------------------------------------------------------------
# * Check if two events collide (event sizing)
# event1 : the first event
# event2 : the second event
# new_x : the new x coordinate of event 1
# new_y : the new y coordinate of event 1
#--------------------------------------------------------------------------
def event_collide?(event1, event2, new_x, new_y)
if event1.id == event2.id then return false end
collision = false
# Check if there is a collision on the y axis
# Loop through each individual tile on both events and compare them
for i in (new_y - (event1.size_y - 1))..new_y
for j in (event2.y - (event2.size_y - 1))..event2.y
# If event 1's tile is the same as event 2's tile, we have a collision
if i == j
unless event1.through or event2.through
# Make sure there is a graphic - if not, no collision
if event1.character_name != "" and event2.character_name != ""
# There was a collision
collision = true
end
end
end
end
end
# If there was a collision on the y axis...
if collision == true
# Check the x axis
# Loop through each individual tile on both events and compare them
for i in (new_x - event1.tiles_left)..(new_x + event1.tiles_right)
for j in (event2.x - event2.tiles_left)..(event2.x + event2.tiles_right)
# If event 1's tile is the same as event 2's tile, we have a collision
if i == j
unless event1.through or event2.through
# Make sure there is a graphic - if not, no collision
if event1.character_name != "" and event2.character_name != ""
# There was a collision
return true
end
end
end
end
end
end
# No collision
return false
end

end

class Game_Player

#--------------------------------------------------------------------------
# * Same Position Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
# EDITED FOR SIZED EVENTS
# If player's coordinates collide with the event and its sizing
if @x >= event.x - event.tiles_left and @x <= event.x + event.tiles_right and
@y >= event.y - (event.size_y - 1) and @y <= event.y and
triggers.include?(event.trigger)
# If starting determinant is same position event (other than jumping)
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# * Front Envent Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# Calculate front event coordinates
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
# EDITED FOR SIZED EVENTS
# If player's new coordinates collide with the event and its sizing
if new_x >= event.x - event.tiles_left and new_x <= event.x + event.tiles_right and
new_y >= event.y - (event.size_y - 1) and new_y <= event.y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# If fitting event is not found
if result == false
# If front tile is a counter
if $game_map.counter?(new_x, new_y)
# Calculate 1 tile inside coordinates
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
# EDITED FOR SIZED EVENTS
# If player's new coordinates collide with the event and its sizing
if new_x >= event.x - event.tiles_left and new_x <= event.x + event.tiles_right and
new_y >= event.y - (event.size_y - 1) and new_y <= event.y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# * Touch Event Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# All event loops
for event in $game_map.events.values
# EDITED FOR SIZED EVENTS
# If passed coordinates collide with the event and its sizing
if x >= event.x - event.tiles_left and x <= event.x + event.tiles_right and
y >= event.y - (event.size_y - 1) and y <= event.y and [1,2].include?(event.trigger)
event.start
result = true
end
end
return result
end

end


사용법: 맵에 병렬처리되는 이벤트를 하나 만들고 다음처럼 지정합니다 -
$game_map.events[ID].size(SIZE_X, SIZE_Y)
size_x/y는 이벤트의 가로/세로 크기(단위가 어떻게 되는지는 데모를 보세요).

Who's 백호

?

이상혁입니다.

http://elab.kr

Atachment
첨부 '1'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
641 전투 턴제 전투메시지 스크립트 10 file 백호 2009.02.21 2197
640 전투 오버드라이브 8 file 키라링 2009.01.23 2193
639 기타 [회복] 대기 회복 스크립트4.0 여러 오류 문제 해결 및 길이 줄임 11 file 코아 코스튬 2010.11.06 2189
638 상점 상점아템 가격변동(중뷁?) 4 캉쿤 2011.09.14 2188
637 기타 클리어 횟수 기록하기 1 file 허걱 2009.08.22 2187
636 기타 [신기술 체험] 솔로채팅창 17 file 백호 2009.02.22 2187
635 기타 대화창 글자 한글자씩뜨는 스크립트 7 백호 2009.02.22 2185
634 기타 [신기술 체험] 레이싱 스크립트 8 file 백호 2009.02.22 2184
633 메시지 Universal Message System 1.8.0 by ccoa 1 file Alkaid 2010.09.08 2183
632 기타 [All RGSS] 윈도우 메세지박스 스크립트 (Completed ver) 5 file Cheapmunk 2014.06.22 2178
631 메시지 Etude87_Item_Choice_XP ver.1.10 13 file 습작 2013.05.19 2177
630 온라인 Multi-Netplay Extended[구버전용] 3 백호 2009.02.22 2175
629 기타 데이터베이스 자체 제한 해체 XP Ver. 13 THE풀잎 2010.07.04 2170
628 맵/타일 H-Mode7 Engine 1.0 by MGCaladtogel 8 Alkaid 2010.12.23 2161
627 기타 [맵 아이디 확인 스크립트] 맵아이디 모르는 사람을 위한 스크립트 9 file 코아 코스튬 2010.10.09 2161
626 키입력 Aleworks Input Module 1.21 by vgvgf (SDK호환) 8 WMN 2008.04.06 2145
625 기타 홈페이지 띄우기 (VX 상관없음.) 6 KNAVE 2009.08.25 2137
624 기타 Upload & Download files with RGSS 2.1 by berka (XP/VX 공용) 5 Alkaid 2010.11.20 2134
623 기타 KGC꺼 몬스터도감 수정해봤어요;;; 9 file 백호 2009.02.21 2134
622 스킬 기술문서(스킬 습득 아이템) 7 ok하승헌 2010.02.18 2132
Board Pagination Prev 1 ... 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ... 52 Next
/ 52