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
17 장비 사용자 장비 슬롯 1.1 27 file 아방스 2012.01.31 6615
16 스킬 VXACE 패시브 스킬 스크립트 Ver. 0.82 21 file 아이미르 2012.03.07 6669
15 메뉴 [VX Ace] 다이얼 링 메뉴 스크립트 8 file RaonHank 2012.04.16 6670
14 제작도구 VXAce HUD Designer by Cidiomar R. Dias Jr 1 file 습작 2013.01.19 6761
13 전투 [스크립트] Sideview Battle System ver. 1.00 (일본어) 7 file 허걱 2012.05.20 6912
12 메뉴 Etude87's Menu Editor 44 file 습작 2014.07.17 6992
11 그래픽 [ACE][BR] Awesome Light Effects 1.0(빛관련 스크립트) 37 file 꿈꾸는사람 2012.08.02 7014
10 메시지 [스크립트] Ace Message System - by. Yanfly 17 file 허걱 2012.05.21 7253
9 전투 SRPG 컨버터 for Ace (SRPGコンバータ for Ace) by AD.Bank 27 file 습작 2012.04.17 7274
8 전투 vx ace 애니메이션 배틀 3 gor 2012.05.27 7664
7 이름입력 전체키 + 조합한글 + 이름입력처리 변경 47 file 허걱 2012.07.04 8198
6 기타 원하는 글씨체로 변경하기 12 조말생 2012.04.20 8847
5 기타 Dialog Extractor 1.04 (VXA/VX/XP) 6 AltusZeon 2014.01.16 11668
4 이름입력 한글 이름입력창 23 file 에틴 2012.01.23 11679
3 전투 Yanfly 엔진 - 몬스터의 레벨 설정 6 file 스리아씨 2013.11.08 13003
2 전투 RPG VX Ace 전투 대사 한글화 37 재규어 2012.01.04 20291
1 전투 스킬 캐스팅 시스템 3 스리아씨 2013.10.12 32165
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11