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 28928
217 기타 '결정 키로 이벤트 시작' 조건분기 추가 file Bunny_Boy 2016.01.16 1167
216 기타 (링크)RPG VX ACE 블랙잭 스크립트 게임애호가 2017.06.18 1004
215 기타 77er 월드 맵 1.0 by 77er 3 file 77ER. 2013.08.14 2281
214 이동 및 탈것 8 방향 이동 스크립트 ( 사선 이동 캐릭터 그래픽 지원 ) 9 file 미루 2013.07.11 4847
213 전투 Ace 경험치 직접 설정 12 쿠쿠밥솥 2012.02.05 4004
212 장비 Ace 장비 착용의 제한 스크립트 11 아이미르 2012.09.01 2786
211 기타 ACE) 오블리비언 락픽 구현 V0.5.2 7 file 77이알 2012.09.02 4811
210 기타 ACE) 캐릭터 사전 by 77ER 19 77이알 2012.09.17 3938
209 메뉴 ace용 mog메뉴와 mog전투 10 file 꿈꾸는사람 2012.08.04 6053
208 액터 Actor Creation System by Tsukihime 4 Alkaid 2012.09.16 3552
207 메시지 Advanced Text System by modern algebra 2 Alkaid 2013.02.04 2317
206 메시지 ATS: Special Message Codes 1.0 by Modern Algebra 1 file Alkaid 2012.01.15 4708
205 오디오 Audio Pump Up: FMOD Ex by mikb89 2 Alkaid 2012.09.08 2071
204 전투 Basic Enemy HP Bars 2.1 by V.M 10 Alkaid 2013.02.21 4207
203 전투 Code Crush VXAce-RGSS3-21 프론트뷰 改 2 15 Alkaid 2013.01.28 4270
202 전투 CP's Battle Engine by Neon Black 20 Alkaid 2013.02.14 4957
201 퀘스트 CSCA]콜로세움 시스템 4 file 글쎄,왜 난 적용이 안될까? 2013.06.09 3624
200 메뉴 Customizable Main Menu 1.0b by modern algebra 4 file Alkaid 2012.02.13 5452
199 기타 Dialog Extractor 1.04 (VXA/VX/XP) 6 AltusZeon 2014.01.16 11672
198 전투 Drop Options by modern algebra 3 Alkaid 2012.09.17 2851
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11