Juwan Park :: 결정 키로 이벤트 시작하는 조건분기 (RPG XP용)

결정 키로 이벤트 시작하는 조건분기 (RPG XP용)

◆게임 창작 관련/코드, 스크립트 :: 2016. 1. 18. 12:05

RPG 만들기 2000/2003의 조건분기를 보면 '결정 키로 이 이벤트를 시작'이라는 항목이 있는데 XP 이후 이 항목이 사라졌습니다.
하지만 스크립트를 조금만 고치면 결정 키로 이벤트를 시작하는 조건분기를 넣을 수 있습니다.
이 포스트에서는 RPG VX Ace용으로 만든 것을 XP에 적용할 수 있게 하기 위해 재구성했습니다. ([for VX], [for VXA])

(C 버튼을 누르고 있는지의 여부로 하는 방법은 결정 키를 누른 상태에서 접촉해도 인식하므로 완벽한 방법이 아닙니다.)

다음 스크립트를 복사해서 스크립트창(F11)의 '▼ 소재(Materials)' 부분 밑에 새 스크립트를 추가해 붙여넣기하시면 됩니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Start with OK Button in Conditional Branch v1.0 (for XP)
# '결정 키로 이벤트 시작' 조건분기 스크립트입니다.
# (RPG 만들기 VX Ace용으로 만든 코드를 XP용으로 재구성했습니다.)
#
# 만든이: Juwan Park
#
# 저작권: Creative Commons BY 3.0
# (영리/비영리 여부에 관계없이 자유롭게 이용 가능합니다.)
#
# [사용법]
# 조건분기에서 스크립트 선택 후 다음과 같이 넣으면 됩니다.
#   $game_player.swob?
# 그리고 결정 키로 이벤트를 시작했을 경우 실행될 커맨드를 넣으면 됩니다.
 
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # Object Initialization
  #--------------------------------------------------------------------------
  alias playerinit initialize
  def initialize
    playerinit
    @start_with_ok_button = false
  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
    @start_with_ok_button = true
    # 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
      if event.x == new_x and event.y == new_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
          if event.x == new_x and event.y == new_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
      # If event coordinates and triggers are consistent
      if event.x == x and event.y == y and [1,2].include?(event.trigger)
        # If starting determinant is front event (other than jumping)
        if not event.jumping? and not event.over_trigger?
          @start_with_ok_button = false
          event.start
          result = true
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # Start with [OK] Button?
  #--------------------------------------------------------------------------
  def swob?
    return @start_with_ok_button
  end
  #--------------------------------------------------------------------------
  # SWOB to false
  #--------------------------------------------------------------------------
  def noswob
    @start_with_ok_button = false
  end
end
 
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # Touch Event Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    # If event is running
    if $game_system.map_interpreter.running?
      return
    end
    # If trigger is [touch from event] and consistent with player coordinates
    if @trigger == 2 and x == $game_player.x and y == $game_player.y
      # If starting determinant other than jumping is front event
      if not jumping? and not over_trigger?
        $game_player.noswob
        start
      end
    end
  end
  #--------------------------------------------------------------------------
  # Unlock
  #--------------------------------------------------------------------------
  def unlock
    # If not locked
    unless @locked
      # End method
      return
    end
    # Clear locked flag
    @locked = false
    $game_player.noswob
    # If direction is not fixed
    unless @direction_fix
      # If prelock direction is saved
      if @prelock_direction != 0
        # Restore prelock direction
        @direction = @prelock_direction
      end
    end
  end
end


예제 파일은 다음과 같습니다.

SWOB_in_Branch(XP).zip

스크립트만 추출한 파일은 다음과 같습니다.

swob_in_branch_for_xp.rb

Today    Yday    Tot
Juwan Park
Juwan Park's blog is powered by Daum and .
Contemporary Blue for .
Designed by Juwan Park. Creative Commons License
▲ TOP