Ace 스크립트

링크 : http://arcthunder.blogspot.kr/p/rpg-maker.html

예제 : http://www.mediafire.com/download/xu9i56yi6dpsc4b/%5BACE%5D%5BEN%5D+Khas+Pathfinder+1.0.rar


스크립트

---------------------------------------------------------------------------------------------------------------------

#-------------------------------------------------------------------------------

# * [ACE] Khas Pathfinder

#-------------------------------------------------------------------------------

# * By Khas Arcthunder - arcthunder.site40.net

# * Version: 1.0 EN

# * Released on: 28/02/2012

#

#-------------------------------------------------------------------------------

# * Terms of Use

#-------------------------------------------------------------------------------

# When using any Khas script, you agree with the following terms:

# 1. You must give credit to Khas;

# 2. All Khas scripts are licensed under a Creative Commons license;

# 3. All Khas scripts are for non-commercial projects. If you need some script 

#    for your commercial project (I accept requests for this type of project), 

#    send an email to nilokruch@live.com with your request;

# 4. All Khas scripts are for personal use, you can use or edit for your own 

#    project, but you are not allowed to post any modified version;

# 5. You can’t give credit to yourself for posting any Khas script;

# 6. If you want to share a Khas script, don’t post the script or the direct 

#    download link, please redirect the user to arcthunder.site40.net

# 7. You are not allowed to convert any of Khas scripts to another engine, 

#    such converting a RGSS3 script to RGSS2 or something of that nature.

# Check all terms at http://arcthunder.site40.net/terms/

#

#-------------------------------------------------------------------------------

# * Features

#-------------------------------------------------------------------------------

# Smart pathfinding

# Fast Algorithm

# Easy to use

# Plug'n'Play

# Game_Character objects compatible

# Log tool

#

#-------------------------------------------------------------------------------

# * Instructions

#-------------------------------------------------------------------------------

# Use the following code inside the "Call Script" box:

# find_path(id,fx,fy)

# Runs the pathfinder.

# id => An integer, use -1 for game player, 0 for the event that the command

# will be called and X for event ID X.

# fx => X destination

# fy => Y destination

#

# find_path(id,fx,fy,true)

# Call this command if you want the game to wait the moving character.

#

# If you want to enable Pathfinder's logs, set "Log" constant to true.

#

#-------------------------------------------------------------------------------

# * Register

#-------------------------------------------------------------------------------

$khas_awesome = [] if $khas_awesome.nil?

$khas_awesome << ["Pathfinder",1.0]

#-------------------------------------------------------------------------------

# * Script

#-------------------------------------------------------------------------------

class Game_Interpreter

  def find_path(char,fx,fy,wait=false)

    $game_map.refresh if $game_map.need_refresh

    character = get_character(char)

    return if character.nil?

    return unless Path_Core.runnable?(character,fx,fy)

    path = Path_Core.run(character,fx,fy)

    return if path.nil?

    route = RPG::MoveRoute.new

    route.repeat = false

    route.wait = wait

    route.skippable = true

    route.list = []

    path << 0x00

    path.each { |code| route.list << RPG::MoveCommand.new(code)}

    character.force_move_route(route)

    @moving_character = character if wait

  end

end

class Path

  attr_accessor :axis

  attr_accessor :from

  attr_accessor :cost

  attr_accessor :dir

  def initialize(x,y,f,c,d)

    @axis = [x,y]

    @from = f

    @cost = c

    @dir = d

  end

end

module Path_Core

  Log = false

  Directions = {[1,0] => 3,[-1,0] => 2,[0,-1] => 4,[0,1] => 1}

  def self.runnable?(char,x,y)

    return false unless $game_map.valid?(x,y)

    return false if char.collide_with_characters?(x,y)

    $game_map.all_tiles(x,y).each { |id|

    flag = $game_map.tileset.flags[id]

    next if flag & 0x10 != 0

    return flag & 0x0f != 0x0f}

    return false

  end

  def self.run(char,fx,fy)

    return nil if char.x == fx && char.y == fy

    st = Time.now

    @char = char

    @start = Path.new(@char.x,@char.y,nil,0,nil)

    @finish = Path.new(fx,fy,nil,0,nil)

    @list = []

    @queue = []

    @preference = ((@char.x-fx).abs > (@char.y-fy).abs ? 0x0186aa : 0x01d)

    class << @list

      def new_path?(path_class)

        for path in self

          return false if path.axis == path_class.axis

        end

        return true

      end

    end

    class << @queue

      def new_path?(path_class)

        for path in self

          return false if path.axis == path_class.axis

        end

        return true

      end

    end

    if @preference & 0x02 == 0x02

      @queue << Path.new(@char.x,@char.y+1,@start,1,[0,1]) if @char.passable?(@char.x,@char.y,2)

      @queue << Path.new(@char.x,@char.y-1,@start,1,[0,-1]) if @char.passable?(@char.x,@char.y,8)

      @queue << Path.new(@char.x+1,@char.y,@start,1,[1,0]) if @char.passable?(@char.x,@char.y,6)

      @queue << Path.new(@char.x-1,@char.y,@start,1,[-1,0]) if @char.passable?(@char.x,@char.y,4)

      @list << @start

      loop do

        break if @queue.empty?

        @cpath = @queue[0]

        if @cpath.axis == @finish.axis

          @finish.cost = @cpath.cost

          @finish.from = @cpath

          break

        end

        @list << @cpath

        @path_array = []

        p1 = Path.new(@cpath.axis[0]+1,@cpath.axis[1],@cpath,@cpath.cost+1,[1,0])

        p2 = Path.new(@cpath.axis[0]-1,@cpath.axis[1],@cpath,@cpath.cost+1,[-1,0])

        p3 = Path.new(@cpath.axis[0],@cpath.axis[1]+1,@cpath,@cpath.cost+1,[0,1])

        p4 = Path.new(@cpath.axis[0],@cpath.axis[1]-1,@cpath,@cpath.cost+1,[0,-1])

        @path_array << p3 if @char.passable?(@cpath.axis[0],@cpath.axis[1],2) && @list.new_path?(p3) && @queue.new_path?(p3)

        @path_array << p4 if @char.passable?(@cpath.axis[0],@cpath.axis[1],8) && @list.new_path?(p4) && @queue.new_path?(p4)

        @path_array << p1 if @char.passable?(@cpath.axis[0],@cpath.axis[1],6) && @list.new_path?(p1) && @queue.new_path?(p1)

        @path_array << p2 if @char.passable?(@cpath.axis[0],@cpath.axis[1],4) && @list.new_path?(p2) && @queue.new_path?(p2)

        @path_array.each { |path| @queue << path }

        @queue.delete(@cpath)

      end

    else

      @queue << Path.new(@char.x+1,@char.y,@start,1,[1,0]) if @char.passable?(@char.x,@char.y,6)

      @queue << Path.new(@char.x-1,@char.y,@start,1,[-1,0]) if @char.passable?(@char.x,@char.y,4)

      @queue << Path.new(@char.x,@char.y+1,@start,1,[0,1]) if @char.passable?(@char.x,@char.y,2)

      @queue << Path.new(@char.x,@char.y-1,@start,1,[0,-1]) if @char.passable?(@char.x,@char.y,8)

      @list << @start

      loop do

        break if @queue.empty?

        @cpath = @queue[0]

        if @cpath.axis == @finish.axis

          @finish.cost = @cpath.cost

          @finish.from = @cpath

          break

        end

        @list << @cpath

        @path_array = []

        p1 = Path.new(@cpath.axis[0]+1,@cpath.axis[1],@cpath,@cpath.cost+1,[1,0])

        p2 = Path.new(@cpath.axis[0]-1,@cpath.axis[1],@cpath,@cpath.cost+1,[-1,0])

        p3 = Path.new(@cpath.axis[0],@cpath.axis[1]+1,@cpath,@cpath.cost+1,[0,1])

        p4 = Path.new(@cpath.axis[0],@cpath.axis[1]-1,@cpath,@cpath.cost+1,[0,-1])

        @path_array << p1 if @char.passable?(@cpath.axis[0],@cpath.axis[1],6) && @list.new_path?(p1) && @queue.new_path?(p1)

        @path_array << p2 if @char.passable?(@cpath.axis[0],@cpath.axis[1],4) && @list.new_path?(p2) && @queue.new_path?(p2)

        @path_array << p3 if @char.passable?(@cpath.axis[0],@cpath.axis[1],2) && @list.new_path?(p3) && @queue.new_path?(p3)

        @path_array << p4 if @char.passable?(@cpath.axis[0],@cpath.axis[1],8) && @list.new_path?(p4) && @queue.new_path?(p4)

        @path_array.each { |path| @queue << path }

        @queue.delete(@cpath)

      end

    end

    if @finish.from.nil?

      return nil

    else

      steps = [@finish.from]

      loop do

        cr = steps[-1]

        if cr.cost == 1

          @result = []

          steps.each { |s| @result << Directions[s.dir]}

          break

        else

          steps << cr.from

        end

      end

      self.print_log(Time.now-st) if Log

      return @result.reverse

    end

  end

  def self.print_log(time)

    print "\n--------------------\n"

    print "Khas Pathfinder\n"

    print "Time: #{time}\n"

    print "Size: #{@result.size}\n"

    print "--------------------\n"

  end

end





사용조건은 크레딧에 Khas 이름을 넣는 것입니다.

  • ?
    비형 2015.07.16 13:23
    혹시 변수값으로 이동도 가능한가요?
  • profile
    찬잎 2015.07.16 15:02
    예를 들어서,
    변수 001 == 목표의 X좌표
    변수 002 == 목표의 Y좌표
    를 대입했다고 치면,

    커맨드의 스크립트에다가

    x = $game_variables[001];
    y = $game_variables[002];
    find_path(id,x,y)

    이렇게 입력해주시면 됩니다.
  • ?
    비형 2015.07.18 03:08
    답변 감사합니다!
    그런데 y에서 오류가 나네요..
    어디서 잘못한건지 ㅜㅜ
  • profile
    찬잎 2015.07.18 21:13
    엥? 저는 이렇게 잘 쓰고 있는데;; 왜 그런지 모르겠네요;;
  • ?
    비형 2015.07.19 18:55
    변수001 -- 목표의 X좌표와,
    변수002 -- 목표의 Y좌표가 이벤트 에디터에서 입력된 상태고,
    조건분기로 스크립트 란에,
    x = $game_variables[001];
    y = $game_variables[002];
    find_path(id,x,y)
    입력했는데, 사용법이 잘못된건가요..?
  • profile
    찬잎 2015.07.19 21:22
    아 설마
    find_path(id,x,y)에서 id를 정말 id로 쓰신건가요!!
    여기서 id는 이벤트 번호입니다.
    움직이고자 하는 이벤트 번호를 써주셔야 되요.
    플레이어라면 -1, 현재 이벤트라면 0,
    그 외에는 해당 이벤트 번호를 써주셔야 합니다.

    그러니까
    1번 이벤트를 움직이고 싶으면
    find_path(1, x, y)로 입력해야죠.
  • ?
    비형 2015.07.19 22:18
    아.. 변수 적을때 [000]세자리를 [0000]로 적어서 오류난 거였어요..
    변수 자릿수가 4자리잖아요.. ㅎ
    답변 일일히 달아주셔서 감사했습니다..^^ 복 많이 받으세요~!!
  • ?
    lud 2015.07.20 22:35
    000빼고 그냥 0,1 해도 변수번호가 됩니다.
    $game_variables[1], $game_variables[2] 이런식으로 할 수 있죠^^
  • ?
    비형 2015.07.21 01:39

    그런 방법도 있었군요..! 알려주셔서 감사합니다 ^^

    혹시 다른 것도 여쭤봐도 될까요..?

    http://avangs.info/index.php?mid=rgss_vx_ace&category=812556&document_srl=1025077 캐릭 머리위에 메세지 띄우는 스크립트인데,
    변수값이 텍스트로 표시되게 할 수 있는 방법이 있을까요..?

  • ?
    lud 2015.07.21 10:25
    이런건 질문답변 게시판에...;;
  • ?
    비형 2015.07.21 11:19
    네 ㅜㅜ
  • ?
    아쳐 2015.07.31 16:21
    길찾기면 공포게임에 사용돼는 그런건가요?
  • ?
    삡코 2015.08.06 06:32

    "사용조건은 크레딧에 Khas 이름을 넣는 것입니다."라는게 무슨뜻인가요? 그리고 이거 그냥 써도 작동이 되네요ㅎ 그런데 렉이 어마무시하게 걸리네요
    제가 뭘 잘못사용하고 있는건가요?

  • profile
    찬잎 2015.08.06 14:52
    이 스크립트를 사용하려면 반드시 제작하고 계신 게임 엔딩 크레딧에
    Khas 를 넣어달라는 겁니다. 저작권이 있는 스크립트니까요.
  • ?
    삡코 2015.08.07 10:08
    아 감사합니다. 그런거군요 ㅇㅇ

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 5110
공지 RPG VX ACE 유용한 링크 모음 16 아방스 2012.01.03 28925
217 그래픽 셰이크 강화 스크립트 file 시낵스 2023.12.13 109
216 오디오 볼륨변경 스크립트 레기우스州 2020.08.09 504
215 전투 LNX11 전투 RPGXP 전투처럼 만들기 큔. 2018.11.23 1444
214 온라인 브라우저 열기 스크립트 1 큔. 2018.09.09 671
213 타이틀/게임오버 GG침 스크립트 file 큔. 2018.07.18 835
212 메뉴 파티 개별 인벤토리 스크립트 안나카레리나 2018.06.25 739
211 전투 기본전투의 커스텀 명중률 제작 안나카레리나 2018.06.10 543
210 기타 LUD Script Package file LuD 2017.08.15 1079
209 맵/타일 레이어 맵 <layer> 기능 2 file LuD 2017.08.03 1470
208 HUD 아이템 레어리티 스크립트 (번역기 돌림) 2 file 부초 2017.07.21 1424
207 기타 (링크)RPG VX ACE 블랙잭 스크립트 게임애호가 2017.06.18 1003
206 전투 SPRG 컨버터 NEXT 1 file 게임애호가 2016.06.09 1905
205 전투 Tomoaky's RGSS3_SRPG ver.0.15a 한국어번역 3 file 초코빙수 2016.06.05 2071
204 맵/타일 Map Zoom Ace by MGC 습작 2016.02.28 1015
203 메시지 Item Choice Help Window for Ace 2 file 습작 2016.02.15 1379
202 기타 '결정 키로 이벤트 시작' 조건분기 추가 file Bunny_Boy 2016.01.16 1165
201 그래픽 커스텀 아이콘 적용하기 2 file 간로 2015.09.28 2721
200 버그픽스 RGSS3 Unofficial Bug Fix Snippets Alkaid 2015.09.09 662
» 이동 및 탈것 Khas Pathfinder(길찾기 스크립트) 15 찬잎 2015.07.10 1961
198 메시지 아이템 정보 메세지가 뜨는 아이템 획득 1 폴라 2015.05.21 2217
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11