rgss3_default_scripts 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +9 -0
- data/Rakefile +2 -0
- data/lib/rgss3_default_scripts.rb +109 -0
- data/lib/rgss3_default_scripts/BattleManager.rb +392 -0
- data/lib/rgss3_default_scripts/Cache.rb +134 -0
- data/lib/rgss3_default_scripts/DataManager.rb +267 -0
- data/lib/rgss3_default_scripts/Game_Action.rb +262 -0
- data/lib/rgss3_default_scripts/Game_ActionResult.rb +159 -0
- data/lib/rgss3_default_scripts/Game_Actor.rb +696 -0
- data/lib/rgss3_default_scripts/Game_Actors.rb +22 -0
- data/lib/rgss3_default_scripts/Game_BaseItem.rb +51 -0
- data/lib/rgss3_default_scripts/Game_Battler.rb +824 -0
- data/lib/rgss3_default_scripts/Game_BattlerBase.rb +731 -0
- data/lib/rgss3_default_scripts/Game_Character.rb +396 -0
- data/lib/rgss3_default_scripts/Game_CharacterBase.rb +443 -0
- data/lib/rgss3_default_scripts/Game_CommonEvent.rb +41 -0
- data/lib/rgss3_default_scripts/Game_Enemy.rb +264 -0
- data/lib/rgss3_default_scripts/Game_Event.rb +308 -0
- data/lib/rgss3_default_scripts/Game_Follower.rb +74 -0
- data/lib/rgss3_default_scripts/Game_Followers.rb +112 -0
- data/lib/rgss3_default_scripts/Game_Interpreter.rb +1413 -0
- data/lib/rgss3_default_scripts/Game_Map.rb +704 -0
- data/lib/rgss3_default_scripts/Game_Message.rb +101 -0
- data/lib/rgss3_default_scripts/Game_Party.rb +418 -0
- data/lib/rgss3_default_scripts/Game_Picture.rb +161 -0
- data/lib/rgss3_default_scripts/Game_Pictures.rb +28 -0
- data/lib/rgss3_default_scripts/Game_Player.rb +488 -0
- data/lib/rgss3_default_scripts/Game_Screen.rb +234 -0
- data/lib/rgss3_default_scripts/Game_SelfSwitches.rb +35 -0
- data/lib/rgss3_default_scripts/Game_Switches.rb +35 -0
- data/lib/rgss3_default_scripts/Game_System.rb +122 -0
- data/lib/rgss3_default_scripts/Game_Temp.rb +45 -0
- data/lib/rgss3_default_scripts/Game_Timer.rb +56 -0
- data/lib/rgss3_default_scripts/Game_Troop.rb +205 -0
- data/lib/rgss3_default_scripts/Game_Unit.rb +131 -0
- data/lib/rgss3_default_scripts/Game_Variables.rb +34 -0
- data/lib/rgss3_default_scripts/Game_Vehicle.rb +193 -0
- data/lib/rgss3_default_scripts/SceneManager.rb +94 -0
- data/lib/rgss3_default_scripts/Scene_Base.rb +132 -0
- data/lib/rgss3_default_scripts/Scene_Battle.rb +693 -0
- data/lib/rgss3_default_scripts/Scene_Debug.rb +87 -0
- data/lib/rgss3_default_scripts/Scene_End.rb +61 -0
- data/lib/rgss3_default_scripts/Scene_Equip.rb +144 -0
- data/lib/rgss3_default_scripts/Scene_File.rb +203 -0
- data/lib/rgss3_default_scripts/Scene_Gameover.rb +85 -0
- data/lib/rgss3_default_scripts/Scene_Item.rb +75 -0
- data/lib/rgss3_default_scripts/Scene_ItemBase.rb +147 -0
- data/lib/rgss3_default_scripts/Scene_Load.rb +40 -0
- data/lib/rgss3_default_scripts/Scene_Map.rb +276 -0
- data/lib/rgss3_default_scripts/Scene_Menu.rb +127 -0
- data/lib/rgss3_default_scripts/Scene_MenuBase.rb +63 -0
- data/lib/rgss3_default_scripts/Scene_Name.rb +32 -0
- data/lib/rgss3_default_scripts/Scene_Save.rb +38 -0
- data/lib/rgss3_default_scripts/Scene_Shop.rb +299 -0
- data/lib/rgss3_default_scripts/Scene_Skill.rb +108 -0
- data/lib/rgss3_default_scripts/Scene_Status.rb +25 -0
- data/lib/rgss3_default_scripts/Scene_Title.rb +137 -0
- data/lib/rgss3_default_scripts/Sound.rb +135 -0
- data/lib/rgss3_default_scripts/Sprite_Base.rb +232 -0
- data/lib/rgss3_default_scripts/Sprite_Battler.rb +231 -0
- data/lib/rgss3_default_scripts/Sprite_Character.rb +226 -0
- data/lib/rgss3_default_scripts/Sprite_Picture.rb +82 -0
- data/lib/rgss3_default_scripts/Sprite_Timer.rb +77 -0
- data/lib/rgss3_default_scripts/Spriteset_Battle.rb +389 -0
- data/lib/rgss3_default_scripts/Spriteset_Map.rb +273 -0
- data/lib/rgss3_default_scripts/Spriteset_Weather.rb +184 -0
- data/lib/rgss3_default_scripts/Vocab.rb +145 -0
- data/lib/rgss3_default_scripts/Window_ActorCommand.rb +78 -0
- data/lib/rgss3_default_scripts/Window_Base.rb +571 -0
- data/lib/rgss3_default_scripts/Window_BattleActor.rb +38 -0
- data/lib/rgss3_default_scripts/Window_BattleEnemy.rb +70 -0
- data/lib/rgss3_default_scripts/Window_BattleItem.rb +40 -0
- data/lib/rgss3_default_scripts/Window_BattleLog.rb +425 -0
- data/lib/rgss3_default_scripts/Window_BattleSkill.rb +34 -0
- data/lib/rgss3_default_scripts/Window_BattleStatus.rb +111 -0
- data/lib/rgss3_default_scripts/Window_ChoiceList.rb +88 -0
- data/lib/rgss3_default_scripts/Window_Command.rb +152 -0
- data/lib/rgss3_default_scripts/Window_DebugLeft.rb +104 -0
- data/lib/rgss3_default_scripts/Window_DebugRight.rb +119 -0
- data/lib/rgss3_default_scripts/Window_EquipCommand.rb +36 -0
- data/lib/rgss3_default_scripts/Window_EquipItem.rb +78 -0
- data/lib/rgss3_default_scripts/Window_EquipSlot.rb +111 -0
- data/lib/rgss3_default_scripts/Window_EquipStatus.rb +97 -0
- data/lib/rgss3_default_scripts/Window_GameEnd.rb +38 -0
- data/lib/rgss3_default_scripts/Window_Gold.rb +47 -0
- data/lib/rgss3_default_scripts/Window_Help.rb +43 -0
- data/lib/rgss3_default_scripts/Window_HorzCommand.rb +106 -0
- data/lib/rgss3_default_scripts/Window_ItemCategory.rb +54 -0
- data/lib/rgss3_default_scripts/Window_ItemList.rb +117 -0
- data/lib/rgss3_default_scripts/Window_KeyItem.rb +55 -0
- data/lib/rgss3_default_scripts/Window_MapName.rb +96 -0
- data/lib/rgss3_default_scripts/Window_MenuActor.rb +43 -0
- data/lib/rgss3_default_scripts/Window_MenuCommand.rb +106 -0
- data/lib/rgss3_default_scripts/Window_MenuStatus.rb +85 -0
- data/lib/rgss3_default_scripts/Window_Message.rb +397 -0
- data/lib/rgss3_default_scripts/Window_NameEdit.rb +129 -0
- data/lib/rgss3_default_scripts/Window_NameInput.rb +253 -0
- data/lib/rgss3_default_scripts/Window_NumberInput.rb +148 -0
- data/lib/rgss3_default_scripts/Window_PartyCommand.rb +47 -0
- data/lib/rgss3_default_scripts/Window_SaveFile.rb +69 -0
- data/lib/rgss3_default_scripts/Window_ScrollText.rb +90 -0
- data/lib/rgss3_default_scripts/Window_Selectable.rb +442 -0
- data/lib/rgss3_default_scripts/Window_ShopBuy.rb +115 -0
- data/lib/rgss3_default_scripts/Window_ShopCommand.rb +36 -0
- data/lib/rgss3_default_scripts/Window_ShopNumber.rb +137 -0
- data/lib/rgss3_default_scripts/Window_ShopSell.rb +27 -0
- data/lib/rgss3_default_scripts/Window_ShopStatus.rb +124 -0
- data/lib/rgss3_default_scripts/Window_SkillCommand.rb +76 -0
- data/lib/rgss3_default_scripts/Window_SkillList.rb +121 -0
- data/lib/rgss3_default_scripts/Window_SkillStatus.rb +38 -0
- data/lib/rgss3_default_scripts/Window_Status.rb +125 -0
- data/lib/rgss3_default_scripts/Window_TitleCommand.rb +45 -0
- data/rgss3_default_scripts.gemspec +23 -0
- metadata +186 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# ** Game_Character
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# A character class with mainly movement route and other such processing
|
|
5
|
+
# added. It is used as a super class of Game_Player, Game_Follower,
|
|
6
|
+
# GameVehicle, and Game_Event.
|
|
7
|
+
#==============================================================================
|
|
8
|
+
|
|
9
|
+
class Game_Character < Game_CharacterBase
|
|
10
|
+
#--------------------------------------------------------------------------
|
|
11
|
+
# * Constants
|
|
12
|
+
#--------------------------------------------------------------------------
|
|
13
|
+
ROUTE_END = 0 # End of Move Route
|
|
14
|
+
ROUTE_MOVE_DOWN = 1 # Move Down
|
|
15
|
+
ROUTE_MOVE_LEFT = 2 # Move Left
|
|
16
|
+
ROUTE_MOVE_RIGHT = 3 # Move Right
|
|
17
|
+
ROUTE_MOVE_UP = 4 # Move Up
|
|
18
|
+
ROUTE_MOVE_LOWER_L = 5 # Move Lower Left
|
|
19
|
+
ROUTE_MOVE_LOWER_R = 6 # Move Lower Right
|
|
20
|
+
ROUTE_MOVE_UPPER_L = 7 # Move Upper Left
|
|
21
|
+
ROUTE_MOVE_UPPER_R = 8 # Move Upper Right
|
|
22
|
+
ROUTE_MOVE_RANDOM = 9 # Move at Random
|
|
23
|
+
ROUTE_MOVE_TOWARD = 10 # Move toward Player
|
|
24
|
+
ROUTE_MOVE_AWAY = 11 # Move away from Player
|
|
25
|
+
ROUTE_MOVE_FORWARD = 12 # 1 Step Forward
|
|
26
|
+
ROUTE_MOVE_BACKWARD = 13 # 1 Step Backward
|
|
27
|
+
ROUTE_JUMP = 14 # Jump
|
|
28
|
+
ROUTE_WAIT = 15 # Wait
|
|
29
|
+
ROUTE_TURN_DOWN = 16 # Turn Down
|
|
30
|
+
ROUTE_TURN_LEFT = 17 # Turn Left
|
|
31
|
+
ROUTE_TURN_RIGHT = 18 # Turn Right
|
|
32
|
+
ROUTE_TURN_UP = 19 # Turn Up
|
|
33
|
+
ROUTE_TURN_90D_R = 20 # Turn 90 Degrees Right
|
|
34
|
+
ROUTE_TURN_90D_L = 21 # Turn 90 Degrees Left
|
|
35
|
+
ROUTE_TURN_180D = 22 # Turn 180 Degrees
|
|
36
|
+
ROUTE_TURN_90D_R_L = 23 # Turn 90 Degrees Right/Left
|
|
37
|
+
ROUTE_TURN_RANDOM = 24 # Turn at Random
|
|
38
|
+
ROUTE_TURN_TOWARD = 25 # Turn toward player
|
|
39
|
+
ROUTE_TURN_AWAY = 26 # Turn away from Player
|
|
40
|
+
ROUTE_SWITCH_ON = 27 # Switch ON
|
|
41
|
+
ROUTE_SWITCH_OFF = 28 # Switch OFF
|
|
42
|
+
ROUTE_CHANGE_SPEED = 29 # Change Speed
|
|
43
|
+
ROUTE_CHANGE_FREQ = 30 # Change Frequency
|
|
44
|
+
ROUTE_WALK_ANIME_ON = 31 # Walking Animation ON
|
|
45
|
+
ROUTE_WALK_ANIME_OFF = 32 # Walking Animation OFF
|
|
46
|
+
ROUTE_STEP_ANIME_ON = 33 # Stepping Animation ON
|
|
47
|
+
ROUTE_STEP_ANIME_OFF = 34 # Stepping Animation OFF
|
|
48
|
+
ROUTE_DIR_FIX_ON = 35 # Direction Fix ON
|
|
49
|
+
ROUTE_DIR_FIX_OFF = 36 # Direction Fix OFF
|
|
50
|
+
ROUTE_THROUGH_ON = 37 # Pass-Through ON
|
|
51
|
+
ROUTE_THROUGH_OFF = 38 # Pass-Through OFF
|
|
52
|
+
ROUTE_TRANSPARENT_ON = 39 # Transparent ON
|
|
53
|
+
ROUTE_TRANSPARENT_OFF = 40 # Transparent OFF
|
|
54
|
+
ROUTE_CHANGE_GRAPHIC = 41 # Change Graphic
|
|
55
|
+
ROUTE_CHANGE_OPACITY = 42 # Change Opacity
|
|
56
|
+
ROUTE_CHANGE_BLENDING = 43 # Change Blending
|
|
57
|
+
ROUTE_PLAY_SE = 44 # Play SE
|
|
58
|
+
ROUTE_SCRIPT = 45 # Script
|
|
59
|
+
#--------------------------------------------------------------------------
|
|
60
|
+
# * Public Instance Variables
|
|
61
|
+
#--------------------------------------------------------------------------
|
|
62
|
+
attr_reader :move_route_forcing # forced move route flag
|
|
63
|
+
#--------------------------------------------------------------------------
|
|
64
|
+
# * Initialize Public Member Variables
|
|
65
|
+
#--------------------------------------------------------------------------
|
|
66
|
+
def init_public_members
|
|
67
|
+
super
|
|
68
|
+
@move_route_forcing = false
|
|
69
|
+
end
|
|
70
|
+
#--------------------------------------------------------------------------
|
|
71
|
+
# * Initialize Private Member Variables
|
|
72
|
+
#--------------------------------------------------------------------------
|
|
73
|
+
def init_private_members
|
|
74
|
+
super
|
|
75
|
+
@move_route = nil # Move route
|
|
76
|
+
@move_route_index = 0 # Move route execution position
|
|
77
|
+
@original_move_route = nil # Original move route
|
|
78
|
+
@original_move_route_index = 0 # Original move route execution position
|
|
79
|
+
@wait_count = 0 # Wait count
|
|
80
|
+
end
|
|
81
|
+
#--------------------------------------------------------------------------
|
|
82
|
+
# * Memorize Move Route
|
|
83
|
+
#--------------------------------------------------------------------------
|
|
84
|
+
def memorize_move_route
|
|
85
|
+
@original_move_route = @move_route
|
|
86
|
+
@original_move_route_index = @move_route_index
|
|
87
|
+
end
|
|
88
|
+
#--------------------------------------------------------------------------
|
|
89
|
+
# * Restore Move Route
|
|
90
|
+
#--------------------------------------------------------------------------
|
|
91
|
+
def restore_move_route
|
|
92
|
+
@move_route = @original_move_route
|
|
93
|
+
@move_route_index = @original_move_route_index
|
|
94
|
+
@original_move_route = nil
|
|
95
|
+
end
|
|
96
|
+
#--------------------------------------------------------------------------
|
|
97
|
+
# * Force Move Route
|
|
98
|
+
#--------------------------------------------------------------------------
|
|
99
|
+
def force_move_route(move_route)
|
|
100
|
+
memorize_move_route unless @original_move_route
|
|
101
|
+
@move_route = move_route
|
|
102
|
+
@move_route_index = 0
|
|
103
|
+
@move_route_forcing = true
|
|
104
|
+
@prelock_direction = 0
|
|
105
|
+
@wait_count = 0
|
|
106
|
+
end
|
|
107
|
+
#--------------------------------------------------------------------------
|
|
108
|
+
# * Update While Stopped
|
|
109
|
+
#--------------------------------------------------------------------------
|
|
110
|
+
def update_stop
|
|
111
|
+
super
|
|
112
|
+
update_routine_move if @move_route_forcing
|
|
113
|
+
end
|
|
114
|
+
#--------------------------------------------------------------------------
|
|
115
|
+
# * Update Move Along Route
|
|
116
|
+
#--------------------------------------------------------------------------
|
|
117
|
+
def update_routine_move
|
|
118
|
+
if @wait_count > 0
|
|
119
|
+
@wait_count -= 1
|
|
120
|
+
else
|
|
121
|
+
@move_succeed = true
|
|
122
|
+
command = @move_route.list[@move_route_index]
|
|
123
|
+
if command
|
|
124
|
+
process_move_command(command)
|
|
125
|
+
advance_move_route_index
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
#--------------------------------------------------------------------------
|
|
130
|
+
# * Process Move Command
|
|
131
|
+
#--------------------------------------------------------------------------
|
|
132
|
+
def process_move_command(command)
|
|
133
|
+
params = command.parameters
|
|
134
|
+
case command.code
|
|
135
|
+
when ROUTE_END; process_route_end
|
|
136
|
+
when ROUTE_MOVE_DOWN; move_straight(2)
|
|
137
|
+
when ROUTE_MOVE_LEFT; move_straight(4)
|
|
138
|
+
when ROUTE_MOVE_RIGHT; move_straight(6)
|
|
139
|
+
when ROUTE_MOVE_UP; move_straight(8)
|
|
140
|
+
when ROUTE_MOVE_LOWER_L; move_diagonal(4, 2)
|
|
141
|
+
when ROUTE_MOVE_LOWER_R; move_diagonal(6, 2)
|
|
142
|
+
when ROUTE_MOVE_UPPER_L; move_diagonal(4, 8)
|
|
143
|
+
when ROUTE_MOVE_UPPER_R; move_diagonal(6, 8)
|
|
144
|
+
when ROUTE_MOVE_RANDOM; move_random
|
|
145
|
+
when ROUTE_MOVE_TOWARD; move_toward_player
|
|
146
|
+
when ROUTE_MOVE_AWAY; move_away_from_player
|
|
147
|
+
when ROUTE_MOVE_FORWARD; move_forward
|
|
148
|
+
when ROUTE_MOVE_BACKWARD; move_backward
|
|
149
|
+
when ROUTE_JUMP; jump(params[0], params[1])
|
|
150
|
+
when ROUTE_WAIT; @wait_count = params[0] - 1
|
|
151
|
+
when ROUTE_TURN_DOWN; set_direction(2)
|
|
152
|
+
when ROUTE_TURN_LEFT; set_direction(4)
|
|
153
|
+
when ROUTE_TURN_RIGHT; set_direction(6)
|
|
154
|
+
when ROUTE_TURN_UP; set_direction(8)
|
|
155
|
+
when ROUTE_TURN_90D_R; turn_right_90
|
|
156
|
+
when ROUTE_TURN_90D_L; turn_left_90
|
|
157
|
+
when ROUTE_TURN_180D; turn_180
|
|
158
|
+
when ROUTE_TURN_90D_R_L; turn_right_or_left_90
|
|
159
|
+
when ROUTE_TURN_RANDOM; turn_random
|
|
160
|
+
when ROUTE_TURN_TOWARD; turn_toward_player
|
|
161
|
+
when ROUTE_TURN_AWAY; turn_away_from_player
|
|
162
|
+
when ROUTE_SWITCH_ON; $game_switches[params[0]] = true
|
|
163
|
+
when ROUTE_SWITCH_OFF; $game_switches[params[0]] = false
|
|
164
|
+
when ROUTE_CHANGE_SPEED; @move_speed = params[0]
|
|
165
|
+
when ROUTE_CHANGE_FREQ; @move_frequency = params[0]
|
|
166
|
+
when ROUTE_WALK_ANIME_ON; @walk_anime = true
|
|
167
|
+
when ROUTE_WALK_ANIME_OFF; @walk_anime = false
|
|
168
|
+
when ROUTE_STEP_ANIME_ON; @step_anime = true
|
|
169
|
+
when ROUTE_STEP_ANIME_OFF; @step_anime = false
|
|
170
|
+
when ROUTE_DIR_FIX_ON; @direction_fix = true
|
|
171
|
+
when ROUTE_DIR_FIX_OFF; @direction_fix = false
|
|
172
|
+
when ROUTE_THROUGH_ON; @through = true
|
|
173
|
+
when ROUTE_THROUGH_OFF; @through = false
|
|
174
|
+
when ROUTE_TRANSPARENT_ON; @transparent = true
|
|
175
|
+
when ROUTE_TRANSPARENT_OFF; @transparent = false
|
|
176
|
+
when ROUTE_CHANGE_GRAPHIC; set_graphic(params[0], params[1])
|
|
177
|
+
when ROUTE_CHANGE_OPACITY; @opacity = params[0]
|
|
178
|
+
when ROUTE_CHANGE_BLENDING; @blend_type = params[0]
|
|
179
|
+
when ROUTE_PLAY_SE; params[0].play
|
|
180
|
+
when ROUTE_SCRIPT; eval(params[0])
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
#--------------------------------------------------------------------------
|
|
184
|
+
# * Calculate Distance in X Axis Direction
|
|
185
|
+
#--------------------------------------------------------------------------
|
|
186
|
+
def distance_x_from(x)
|
|
187
|
+
result = @x - x
|
|
188
|
+
if $game_map.loop_horizontal? && result.abs > $game_map.width / 2
|
|
189
|
+
if result < 0
|
|
190
|
+
result += $game_map.width
|
|
191
|
+
else
|
|
192
|
+
result -= $game_map.width
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
result
|
|
196
|
+
end
|
|
197
|
+
#--------------------------------------------------------------------------
|
|
198
|
+
# * Calculate Distance in Y Axis Direction
|
|
199
|
+
#--------------------------------------------------------------------------
|
|
200
|
+
def distance_y_from(y)
|
|
201
|
+
result = @y - y
|
|
202
|
+
if $game_map.loop_vertical? && result.abs > $game_map.height / 2
|
|
203
|
+
if result < 0
|
|
204
|
+
result += $game_map.height
|
|
205
|
+
else
|
|
206
|
+
result -= $game_map.height
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
result
|
|
210
|
+
end
|
|
211
|
+
#--------------------------------------------------------------------------
|
|
212
|
+
# * Move at Random
|
|
213
|
+
#--------------------------------------------------------------------------
|
|
214
|
+
def move_random
|
|
215
|
+
move_straight(2 + rand(4) * 2, false)
|
|
216
|
+
end
|
|
217
|
+
#--------------------------------------------------------------------------
|
|
218
|
+
# * Move Toward Character
|
|
219
|
+
#--------------------------------------------------------------------------
|
|
220
|
+
def move_toward_character(character)
|
|
221
|
+
sx = distance_x_from(character.x)
|
|
222
|
+
sy = distance_y_from(character.y)
|
|
223
|
+
if sx.abs > sy.abs
|
|
224
|
+
move_straight(sx > 0 ? 4 : 6)
|
|
225
|
+
move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
|
|
226
|
+
elsif sy != 0
|
|
227
|
+
move_straight(sy > 0 ? 8 : 2)
|
|
228
|
+
move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
#--------------------------------------------------------------------------
|
|
232
|
+
# * Move Away from Character
|
|
233
|
+
#--------------------------------------------------------------------------
|
|
234
|
+
def move_away_from_character(character)
|
|
235
|
+
sx = distance_x_from(character.x)
|
|
236
|
+
sy = distance_y_from(character.y)
|
|
237
|
+
if sx.abs > sy.abs
|
|
238
|
+
move_straight(sx > 0 ? 6 : 4)
|
|
239
|
+
move_straight(sy > 0 ? 2 : 8) if !@move_succeed && sy != 0
|
|
240
|
+
elsif sy != 0
|
|
241
|
+
move_straight(sy > 0 ? 2 : 8)
|
|
242
|
+
move_straight(sx > 0 ? 6 : 4) if !@move_succeed && sx != 0
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
#--------------------------------------------------------------------------
|
|
246
|
+
# * Turn Toward Character
|
|
247
|
+
#--------------------------------------------------------------------------
|
|
248
|
+
def turn_toward_character(character)
|
|
249
|
+
sx = distance_x_from(character.x)
|
|
250
|
+
sy = distance_y_from(character.y)
|
|
251
|
+
if sx.abs > sy.abs
|
|
252
|
+
set_direction(sx > 0 ? 4 : 6)
|
|
253
|
+
elsif sy != 0
|
|
254
|
+
set_direction(sy > 0 ? 8 : 2)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
#--------------------------------------------------------------------------
|
|
258
|
+
# * Turn Away from Character
|
|
259
|
+
#--------------------------------------------------------------------------
|
|
260
|
+
def turn_away_from_character(character)
|
|
261
|
+
sx = distance_x_from(character.x)
|
|
262
|
+
sy = distance_y_from(character.y)
|
|
263
|
+
if sx.abs > sy.abs
|
|
264
|
+
set_direction(sx > 0 ? 6 : 4)
|
|
265
|
+
elsif sy != 0
|
|
266
|
+
set_direction(sy > 0 ? 2 : 8)
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
#--------------------------------------------------------------------------
|
|
270
|
+
# * Turn toward Player
|
|
271
|
+
#--------------------------------------------------------------------------
|
|
272
|
+
def turn_toward_player
|
|
273
|
+
turn_toward_character($game_player)
|
|
274
|
+
end
|
|
275
|
+
#--------------------------------------------------------------------------
|
|
276
|
+
# * Turn away from Player
|
|
277
|
+
#--------------------------------------------------------------------------
|
|
278
|
+
def turn_away_from_player
|
|
279
|
+
turn_away_from_character($game_player)
|
|
280
|
+
end
|
|
281
|
+
#--------------------------------------------------------------------------
|
|
282
|
+
# * Move toward Player
|
|
283
|
+
#--------------------------------------------------------------------------
|
|
284
|
+
def move_toward_player
|
|
285
|
+
move_toward_character($game_player)
|
|
286
|
+
end
|
|
287
|
+
#--------------------------------------------------------------------------
|
|
288
|
+
# * Move away from Player
|
|
289
|
+
#--------------------------------------------------------------------------
|
|
290
|
+
def move_away_from_player
|
|
291
|
+
move_away_from_character($game_player)
|
|
292
|
+
end
|
|
293
|
+
#--------------------------------------------------------------------------
|
|
294
|
+
# * 1 Step Forward
|
|
295
|
+
#--------------------------------------------------------------------------
|
|
296
|
+
def move_forward
|
|
297
|
+
move_straight(@direction)
|
|
298
|
+
end
|
|
299
|
+
#--------------------------------------------------------------------------
|
|
300
|
+
# * 1 Step Backward
|
|
301
|
+
#--------------------------------------------------------------------------
|
|
302
|
+
def move_backward
|
|
303
|
+
last_direction_fix = @direction_fix
|
|
304
|
+
@direction_fix = true
|
|
305
|
+
move_straight(reverse_dir(@direction), false)
|
|
306
|
+
@direction_fix = last_direction_fix
|
|
307
|
+
end
|
|
308
|
+
#--------------------------------------------------------------------------
|
|
309
|
+
# * Jump
|
|
310
|
+
# x_plus : x-coordinate plus value
|
|
311
|
+
# y_plus : y-coordinate plus value
|
|
312
|
+
#--------------------------------------------------------------------------
|
|
313
|
+
def jump(x_plus, y_plus)
|
|
314
|
+
if x_plus.abs > y_plus.abs
|
|
315
|
+
set_direction(x_plus < 0 ? 4 : 6) if x_plus != 0
|
|
316
|
+
else
|
|
317
|
+
set_direction(y_plus < 0 ? 8 : 2) if y_plus != 0
|
|
318
|
+
end
|
|
319
|
+
@x += x_plus
|
|
320
|
+
@y += y_plus
|
|
321
|
+
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
|
|
322
|
+
@jump_peak = 10 + distance - @move_speed
|
|
323
|
+
@jump_count = @jump_peak * 2
|
|
324
|
+
@stop_count = 0
|
|
325
|
+
straighten
|
|
326
|
+
end
|
|
327
|
+
#--------------------------------------------------------------------------
|
|
328
|
+
# * Process Move Route End
|
|
329
|
+
#--------------------------------------------------------------------------
|
|
330
|
+
def process_route_end
|
|
331
|
+
if @move_route.repeat
|
|
332
|
+
@move_route_index = -1
|
|
333
|
+
elsif @move_route_forcing
|
|
334
|
+
@move_route_forcing = false
|
|
335
|
+
restore_move_route
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
#--------------------------------------------------------------------------
|
|
339
|
+
# * Advance Execution Position of Move Route
|
|
340
|
+
#--------------------------------------------------------------------------
|
|
341
|
+
def advance_move_route_index
|
|
342
|
+
@move_route_index += 1 if @move_succeed || @move_route.skippable
|
|
343
|
+
end
|
|
344
|
+
#--------------------------------------------------------------------------
|
|
345
|
+
# * Turn 90° Right
|
|
346
|
+
#--------------------------------------------------------------------------
|
|
347
|
+
def turn_right_90
|
|
348
|
+
case @direction
|
|
349
|
+
when 2; set_direction(4)
|
|
350
|
+
when 4; set_direction(8)
|
|
351
|
+
when 6; set_direction(2)
|
|
352
|
+
when 8; set_direction(6)
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
#--------------------------------------------------------------------------
|
|
356
|
+
# * Turn 90° Left
|
|
357
|
+
#--------------------------------------------------------------------------
|
|
358
|
+
def turn_left_90
|
|
359
|
+
case @direction
|
|
360
|
+
when 2; set_direction(6)
|
|
361
|
+
when 4; set_direction(2)
|
|
362
|
+
when 6; set_direction(8)
|
|
363
|
+
when 8; set_direction(4)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
#--------------------------------------------------------------------------
|
|
367
|
+
# * Turn 180°
|
|
368
|
+
#--------------------------------------------------------------------------
|
|
369
|
+
def turn_180
|
|
370
|
+
set_direction(reverse_dir(@direction))
|
|
371
|
+
end
|
|
372
|
+
#--------------------------------------------------------------------------
|
|
373
|
+
# * Turn 90° Right or Left
|
|
374
|
+
#--------------------------------------------------------------------------
|
|
375
|
+
def turn_right_or_left_90
|
|
376
|
+
case rand(2)
|
|
377
|
+
when 0; turn_right_90
|
|
378
|
+
when 1; turn_left_90
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
#--------------------------------------------------------------------------
|
|
382
|
+
# * Turn at Random
|
|
383
|
+
#--------------------------------------------------------------------------
|
|
384
|
+
def turn_random
|
|
385
|
+
set_direction(2 + rand(4) * 2)
|
|
386
|
+
end
|
|
387
|
+
#--------------------------------------------------------------------------
|
|
388
|
+
# * Swap Character Positions
|
|
389
|
+
#--------------------------------------------------------------------------
|
|
390
|
+
def swap(character)
|
|
391
|
+
new_x = character.x
|
|
392
|
+
new_y = character.y
|
|
393
|
+
character.moveto(x, y)
|
|
394
|
+
moveto(new_x, new_y)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# ** Game_CharacterBase
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# This base class handles characters. It retains basic information, such as
|
|
5
|
+
# coordinates and graphics, shared by all characters.
|
|
6
|
+
#==============================================================================
|
|
7
|
+
|
|
8
|
+
class Game_CharacterBase
|
|
9
|
+
#--------------------------------------------------------------------------
|
|
10
|
+
# * Public Instance Variables
|
|
11
|
+
#--------------------------------------------------------------------------
|
|
12
|
+
attr_reader :id # ID
|
|
13
|
+
attr_reader :x # map X coordinate (logical)
|
|
14
|
+
attr_reader :y # map Y coordinate (logical)
|
|
15
|
+
attr_reader :real_x # map X coordinate (real)
|
|
16
|
+
attr_reader :real_y # map Y coordinate (real)
|
|
17
|
+
attr_reader :tile_id # tile ID (invalid if 0)
|
|
18
|
+
attr_reader :character_name # character graphic filename
|
|
19
|
+
attr_reader :character_index # character graphic index
|
|
20
|
+
attr_reader :move_speed # movement speed
|
|
21
|
+
attr_reader :move_frequency # movement frequency
|
|
22
|
+
attr_reader :walk_anime # walking animation
|
|
23
|
+
attr_reader :step_anime # stepping animation
|
|
24
|
+
attr_reader :direction_fix # direction fix
|
|
25
|
+
attr_reader :opacity # opacity level
|
|
26
|
+
attr_reader :blend_type # blending method
|
|
27
|
+
attr_reader :direction # direction
|
|
28
|
+
attr_reader :pattern # pattern
|
|
29
|
+
attr_reader :priority_type # priority type
|
|
30
|
+
attr_reader :through # pass-through
|
|
31
|
+
attr_reader :bush_depth # bush depth
|
|
32
|
+
attr_accessor :animation_id # animation ID
|
|
33
|
+
attr_accessor :balloon_id # balloon icon ID
|
|
34
|
+
attr_accessor :transparent # transparency flag
|
|
35
|
+
#--------------------------------------------------------------------------
|
|
36
|
+
# * Object Initialization
|
|
37
|
+
#--------------------------------------------------------------------------
|
|
38
|
+
def initialize
|
|
39
|
+
init_public_members
|
|
40
|
+
init_private_members
|
|
41
|
+
end
|
|
42
|
+
#--------------------------------------------------------------------------
|
|
43
|
+
# * Initialize Public Member Variables
|
|
44
|
+
#--------------------------------------------------------------------------
|
|
45
|
+
def init_public_members
|
|
46
|
+
@id = 0
|
|
47
|
+
@x = 0
|
|
48
|
+
@y = 0
|
|
49
|
+
@real_x = 0
|
|
50
|
+
@real_y = 0
|
|
51
|
+
@tile_id = 0
|
|
52
|
+
@character_name = ""
|
|
53
|
+
@character_index = 0
|
|
54
|
+
@move_speed = 4
|
|
55
|
+
@move_frequency = 6
|
|
56
|
+
@walk_anime = true
|
|
57
|
+
@step_anime = false
|
|
58
|
+
@direction_fix = false
|
|
59
|
+
@opacity = 255
|
|
60
|
+
@blend_type = 0
|
|
61
|
+
@direction = 2
|
|
62
|
+
@pattern = 1
|
|
63
|
+
@priority_type = 1
|
|
64
|
+
@through = false
|
|
65
|
+
@bush_depth = 0
|
|
66
|
+
@animation_id = 0
|
|
67
|
+
@balloon_id = 0
|
|
68
|
+
@transparent = false
|
|
69
|
+
end
|
|
70
|
+
#--------------------------------------------------------------------------
|
|
71
|
+
# * Initialize Private Member Variables
|
|
72
|
+
#--------------------------------------------------------------------------
|
|
73
|
+
def init_private_members
|
|
74
|
+
@original_direction = 2 # Original direction
|
|
75
|
+
@original_pattern = 1 # Original pattern
|
|
76
|
+
@anime_count = 0 # Animation count
|
|
77
|
+
@stop_count = 0 # Stop count
|
|
78
|
+
@jump_count = 0 # Jump count
|
|
79
|
+
@jump_peak = 0 # Jump peak count
|
|
80
|
+
@locked = false # Locked flag
|
|
81
|
+
@prelock_direction = 0 # Direction before lock
|
|
82
|
+
@move_succeed = true # Move success flag
|
|
83
|
+
end
|
|
84
|
+
#--------------------------------------------------------------------------
|
|
85
|
+
# * Determine Coordinate Match
|
|
86
|
+
#--------------------------------------------------------------------------
|
|
87
|
+
def pos?(x, y)
|
|
88
|
+
@x == x && @y == y
|
|
89
|
+
end
|
|
90
|
+
#--------------------------------------------------------------------------
|
|
91
|
+
# * Determine if Coordinates Match and Pass-Through Is Off (nt = No Through)
|
|
92
|
+
#--------------------------------------------------------------------------
|
|
93
|
+
def pos_nt?(x, y)
|
|
94
|
+
pos?(x, y) && !@through
|
|
95
|
+
end
|
|
96
|
+
#--------------------------------------------------------------------------
|
|
97
|
+
# * Determine if [Same as Characters] Priority
|
|
98
|
+
#--------------------------------------------------------------------------
|
|
99
|
+
def normal_priority?
|
|
100
|
+
@priority_type == 1
|
|
101
|
+
end
|
|
102
|
+
#--------------------------------------------------------------------------
|
|
103
|
+
# * Determine if Moving
|
|
104
|
+
#--------------------------------------------------------------------------
|
|
105
|
+
def moving?
|
|
106
|
+
@real_x != @x || @real_y != @y
|
|
107
|
+
end
|
|
108
|
+
#--------------------------------------------------------------------------
|
|
109
|
+
# * Determine if Jumping
|
|
110
|
+
#--------------------------------------------------------------------------
|
|
111
|
+
def jumping?
|
|
112
|
+
@jump_count > 0
|
|
113
|
+
end
|
|
114
|
+
#--------------------------------------------------------------------------
|
|
115
|
+
# * Calculate Jump Height
|
|
116
|
+
#--------------------------------------------------------------------------
|
|
117
|
+
def jump_height
|
|
118
|
+
(@jump_peak * @jump_peak - (@jump_count - @jump_peak).abs ** 2) / 2
|
|
119
|
+
end
|
|
120
|
+
#--------------------------------------------------------------------------
|
|
121
|
+
# * Determine if Stopping
|
|
122
|
+
#--------------------------------------------------------------------------
|
|
123
|
+
def stopping?
|
|
124
|
+
!moving? && !jumping?
|
|
125
|
+
end
|
|
126
|
+
#--------------------------------------------------------------------------
|
|
127
|
+
# * Get Move Speed (Account for Dash)
|
|
128
|
+
#--------------------------------------------------------------------------
|
|
129
|
+
def real_move_speed
|
|
130
|
+
@move_speed + (dash? ? 1 : 0)
|
|
131
|
+
end
|
|
132
|
+
#--------------------------------------------------------------------------
|
|
133
|
+
# * Calculate Move Distance per Frame
|
|
134
|
+
#--------------------------------------------------------------------------
|
|
135
|
+
def distance_per_frame
|
|
136
|
+
2 ** real_move_speed / 256.0
|
|
137
|
+
end
|
|
138
|
+
#--------------------------------------------------------------------------
|
|
139
|
+
# * Determine if Dashing
|
|
140
|
+
#--------------------------------------------------------------------------
|
|
141
|
+
def dash?
|
|
142
|
+
return false
|
|
143
|
+
end
|
|
144
|
+
#--------------------------------------------------------------------------
|
|
145
|
+
# * Determine if Debug Pass-Through State
|
|
146
|
+
#--------------------------------------------------------------------------
|
|
147
|
+
def debug_through?
|
|
148
|
+
return false
|
|
149
|
+
end
|
|
150
|
+
#--------------------------------------------------------------------------
|
|
151
|
+
# * Straighten Position
|
|
152
|
+
#--------------------------------------------------------------------------
|
|
153
|
+
def straighten
|
|
154
|
+
@pattern = 1 if @walk_anime || @step_anime
|
|
155
|
+
@anime_count = 0
|
|
156
|
+
end
|
|
157
|
+
#--------------------------------------------------------------------------
|
|
158
|
+
# * Get Opposite Direction
|
|
159
|
+
# d : Direction (2,4,6,8)
|
|
160
|
+
#--------------------------------------------------------------------------
|
|
161
|
+
def reverse_dir(d)
|
|
162
|
+
return 10 - d
|
|
163
|
+
end
|
|
164
|
+
#--------------------------------------------------------------------------
|
|
165
|
+
# * Determine if Passable
|
|
166
|
+
# d : Direction (2,4,6,8)
|
|
167
|
+
#--------------------------------------------------------------------------
|
|
168
|
+
def passable?(x, y, d)
|
|
169
|
+
x2 = $game_map.round_x_with_direction(x, d)
|
|
170
|
+
y2 = $game_map.round_y_with_direction(y, d)
|
|
171
|
+
return false unless $game_map.valid?(x2, y2)
|
|
172
|
+
return true if @through || debug_through?
|
|
173
|
+
return false unless map_passable?(x, y, d)
|
|
174
|
+
return false unless map_passable?(x2, y2, reverse_dir(d))
|
|
175
|
+
return false if collide_with_characters?(x2, y2)
|
|
176
|
+
return true
|
|
177
|
+
end
|
|
178
|
+
#--------------------------------------------------------------------------
|
|
179
|
+
# * Determine Diagonal Passability
|
|
180
|
+
# horz : Horizontal (4 or 6)
|
|
181
|
+
# vert : Vertical (2 or 8)
|
|
182
|
+
#--------------------------------------------------------------------------
|
|
183
|
+
def diagonal_passable?(x, y, horz, vert)
|
|
184
|
+
x2 = $game_map.round_x_with_direction(x, horz)
|
|
185
|
+
y2 = $game_map.round_y_with_direction(y, vert)
|
|
186
|
+
(passable?(x, y, vert) && passable?(x, y2, horz)) ||
|
|
187
|
+
(passable?(x, y, horz) && passable?(x2, y, vert))
|
|
188
|
+
end
|
|
189
|
+
#--------------------------------------------------------------------------
|
|
190
|
+
# * Determine if Map is Passable
|
|
191
|
+
# d : Direction (2,4,6,8)
|
|
192
|
+
#--------------------------------------------------------------------------
|
|
193
|
+
def map_passable?(x, y, d)
|
|
194
|
+
$game_map.passable?(x, y, d)
|
|
195
|
+
end
|
|
196
|
+
#--------------------------------------------------------------------------
|
|
197
|
+
# * Detect Collision with Character
|
|
198
|
+
#--------------------------------------------------------------------------
|
|
199
|
+
def collide_with_characters?(x, y)
|
|
200
|
+
collide_with_events?(x, y) || collide_with_vehicles?(x, y)
|
|
201
|
+
end
|
|
202
|
+
#--------------------------------------------------------------------------
|
|
203
|
+
# * Detect Collision with Event
|
|
204
|
+
#--------------------------------------------------------------------------
|
|
205
|
+
def collide_with_events?(x, y)
|
|
206
|
+
$game_map.events_xy_nt(x, y).any? do |event|
|
|
207
|
+
event.normal_priority? || self.is_a?(Game_Event)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
#--------------------------------------------------------------------------
|
|
211
|
+
# * Detect Collision with Vehicle
|
|
212
|
+
#--------------------------------------------------------------------------
|
|
213
|
+
def collide_with_vehicles?(x, y)
|
|
214
|
+
$game_map.boat.pos_nt?(x, y) || $game_map.ship.pos_nt?(x, y)
|
|
215
|
+
end
|
|
216
|
+
#--------------------------------------------------------------------------
|
|
217
|
+
# * Move to Designated Position
|
|
218
|
+
#--------------------------------------------------------------------------
|
|
219
|
+
def moveto(x, y)
|
|
220
|
+
@x = x % $game_map.width
|
|
221
|
+
@y = y % $game_map.height
|
|
222
|
+
@real_x = @x
|
|
223
|
+
@real_y = @y
|
|
224
|
+
@prelock_direction = 0
|
|
225
|
+
straighten
|
|
226
|
+
update_bush_depth
|
|
227
|
+
end
|
|
228
|
+
#--------------------------------------------------------------------------
|
|
229
|
+
# * Change Direction to Designated Direction
|
|
230
|
+
# d : Direction (2,4,6,8)
|
|
231
|
+
#--------------------------------------------------------------------------
|
|
232
|
+
def set_direction(d)
|
|
233
|
+
@direction = d if !@direction_fix && d != 0
|
|
234
|
+
@stop_count = 0
|
|
235
|
+
end
|
|
236
|
+
#--------------------------------------------------------------------------
|
|
237
|
+
# * Determine Tile
|
|
238
|
+
#--------------------------------------------------------------------------
|
|
239
|
+
def tile?
|
|
240
|
+
@tile_id > 0 && @priority_type == 0
|
|
241
|
+
end
|
|
242
|
+
#--------------------------------------------------------------------------
|
|
243
|
+
# * Determine Object Character
|
|
244
|
+
#--------------------------------------------------------------------------
|
|
245
|
+
def object_character?
|
|
246
|
+
@tile_id > 0 || @character_name[0, 1] == '!'
|
|
247
|
+
end
|
|
248
|
+
#--------------------------------------------------------------------------
|
|
249
|
+
# * Get Number of Pixels to Shift Up from Tile Position
|
|
250
|
+
#--------------------------------------------------------------------------
|
|
251
|
+
def shift_y
|
|
252
|
+
object_character? ? 0 : 4
|
|
253
|
+
end
|
|
254
|
+
#--------------------------------------------------------------------------
|
|
255
|
+
# * Get Screen X-Coordinates
|
|
256
|
+
#--------------------------------------------------------------------------
|
|
257
|
+
def screen_x
|
|
258
|
+
$game_map.adjust_x(@real_x) * 32 + 16
|
|
259
|
+
end
|
|
260
|
+
#--------------------------------------------------------------------------
|
|
261
|
+
# * Get Screen Y-Coordinates
|
|
262
|
+
#--------------------------------------------------------------------------
|
|
263
|
+
def screen_y
|
|
264
|
+
$game_map.adjust_y(@real_y) * 32 + 32 - shift_y - jump_height
|
|
265
|
+
end
|
|
266
|
+
#--------------------------------------------------------------------------
|
|
267
|
+
# * Get Screen Z-Coordinates
|
|
268
|
+
#--------------------------------------------------------------------------
|
|
269
|
+
def screen_z
|
|
270
|
+
@priority_type * 100
|
|
271
|
+
end
|
|
272
|
+
#--------------------------------------------------------------------------
|
|
273
|
+
# * Frame Update
|
|
274
|
+
#--------------------------------------------------------------------------
|
|
275
|
+
def update
|
|
276
|
+
update_animation
|
|
277
|
+
return update_jump if jumping?
|
|
278
|
+
return update_move if moving?
|
|
279
|
+
return update_stop
|
|
280
|
+
end
|
|
281
|
+
#--------------------------------------------------------------------------
|
|
282
|
+
# * Update While Jumping
|
|
283
|
+
#--------------------------------------------------------------------------
|
|
284
|
+
def update_jump
|
|
285
|
+
@jump_count -= 1
|
|
286
|
+
@real_x = (@real_x * @jump_count + @x) / (@jump_count + 1.0)
|
|
287
|
+
@real_y = (@real_y * @jump_count + @y) / (@jump_count + 1.0)
|
|
288
|
+
update_bush_depth
|
|
289
|
+
if @jump_count == 0
|
|
290
|
+
@real_x = @x = $game_map.round_x(@x)
|
|
291
|
+
@real_y = @y = $game_map.round_y(@y)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
#--------------------------------------------------------------------------
|
|
295
|
+
# * Update While Moving
|
|
296
|
+
#--------------------------------------------------------------------------
|
|
297
|
+
def update_move
|
|
298
|
+
@real_x = [@real_x - distance_per_frame, @x].max if @x < @real_x
|
|
299
|
+
@real_x = [@real_x + distance_per_frame, @x].min if @x > @real_x
|
|
300
|
+
@real_y = [@real_y - distance_per_frame, @y].max if @y < @real_y
|
|
301
|
+
@real_y = [@real_y + distance_per_frame, @y].min if @y > @real_y
|
|
302
|
+
update_bush_depth unless moving?
|
|
303
|
+
end
|
|
304
|
+
#--------------------------------------------------------------------------
|
|
305
|
+
# * Update While Stopped
|
|
306
|
+
#--------------------------------------------------------------------------
|
|
307
|
+
def update_stop
|
|
308
|
+
@stop_count += 1 unless @locked
|
|
309
|
+
end
|
|
310
|
+
#--------------------------------------------------------------------------
|
|
311
|
+
# * Update Walking/Stepping Animation
|
|
312
|
+
#--------------------------------------------------------------------------
|
|
313
|
+
def update_animation
|
|
314
|
+
update_anime_count
|
|
315
|
+
if @anime_count > 18 - real_move_speed * 2
|
|
316
|
+
update_anime_pattern
|
|
317
|
+
@anime_count = 0
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
#--------------------------------------------------------------------------
|
|
321
|
+
# * Update Animation Count
|
|
322
|
+
#--------------------------------------------------------------------------
|
|
323
|
+
def update_anime_count
|
|
324
|
+
if moving? && @walk_anime
|
|
325
|
+
@anime_count += 1.5
|
|
326
|
+
elsif @step_anime || @pattern != @original_pattern
|
|
327
|
+
@anime_count += 1
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
#--------------------------------------------------------------------------
|
|
331
|
+
# * Update Animation Pattern
|
|
332
|
+
#--------------------------------------------------------------------------
|
|
333
|
+
def update_anime_pattern
|
|
334
|
+
if !@step_anime && @stop_count > 0
|
|
335
|
+
@pattern = @original_pattern
|
|
336
|
+
else
|
|
337
|
+
@pattern = (@pattern + 1) % 4
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
#--------------------------------------------------------------------------
|
|
341
|
+
# * Determine if Ladder
|
|
342
|
+
#--------------------------------------------------------------------------
|
|
343
|
+
def ladder?
|
|
344
|
+
$game_map.ladder?(@x, @y)
|
|
345
|
+
end
|
|
346
|
+
#--------------------------------------------------------------------------
|
|
347
|
+
# * Update Bush Depth
|
|
348
|
+
#--------------------------------------------------------------------------
|
|
349
|
+
def update_bush_depth
|
|
350
|
+
if normal_priority? && !object_character? && bush? && !jumping?
|
|
351
|
+
@bush_depth = 8 unless moving?
|
|
352
|
+
else
|
|
353
|
+
@bush_depth = 0
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
#--------------------------------------------------------------------------
|
|
357
|
+
# * Determine if Bush
|
|
358
|
+
#--------------------------------------------------------------------------
|
|
359
|
+
def bush?
|
|
360
|
+
$game_map.bush?(@x, @y)
|
|
361
|
+
end
|
|
362
|
+
#--------------------------------------------------------------------------
|
|
363
|
+
# * Get Terrain Tag
|
|
364
|
+
#--------------------------------------------------------------------------
|
|
365
|
+
def terrain_tag
|
|
366
|
+
$game_map.terrain_tag(@x, @y)
|
|
367
|
+
end
|
|
368
|
+
#--------------------------------------------------------------------------
|
|
369
|
+
# * Get Region ID
|
|
370
|
+
#--------------------------------------------------------------------------
|
|
371
|
+
def region_id
|
|
372
|
+
$game_map.region_id(@x, @y)
|
|
373
|
+
end
|
|
374
|
+
#--------------------------------------------------------------------------
|
|
375
|
+
# * Increase Steps
|
|
376
|
+
#--------------------------------------------------------------------------
|
|
377
|
+
def increase_steps
|
|
378
|
+
set_direction(8) if ladder?
|
|
379
|
+
@stop_count = 0
|
|
380
|
+
update_bush_depth
|
|
381
|
+
end
|
|
382
|
+
#--------------------------------------------------------------------------
|
|
383
|
+
# * Change Graphics
|
|
384
|
+
# character_name : new character graphic filename
|
|
385
|
+
# character_index : new character graphic index
|
|
386
|
+
#--------------------------------------------------------------------------
|
|
387
|
+
def set_graphic(character_name, character_index)
|
|
388
|
+
@tile_id = 0
|
|
389
|
+
@character_name = character_name
|
|
390
|
+
@character_index = character_index
|
|
391
|
+
@original_pattern = 1
|
|
392
|
+
end
|
|
393
|
+
#--------------------------------------------------------------------------
|
|
394
|
+
# * Determine Triggering of Frontal Touch Event
|
|
395
|
+
#--------------------------------------------------------------------------
|
|
396
|
+
def check_event_trigger_touch_front
|
|
397
|
+
x2 = $game_map.round_x_with_direction(@x, @direction)
|
|
398
|
+
y2 = $game_map.round_y_with_direction(@y, @direction)
|
|
399
|
+
check_event_trigger_touch(x2, y2)
|
|
400
|
+
end
|
|
401
|
+
#--------------------------------------------------------------------------
|
|
402
|
+
# * Determine if Touch Event is Triggered
|
|
403
|
+
#--------------------------------------------------------------------------
|
|
404
|
+
def check_event_trigger_touch(x, y)
|
|
405
|
+
return false
|
|
406
|
+
end
|
|
407
|
+
#--------------------------------------------------------------------------
|
|
408
|
+
# * Move Straight
|
|
409
|
+
# d: Direction (2,4,6,8)
|
|
410
|
+
# turn_ok : Allows change of direction on the spot
|
|
411
|
+
#--------------------------------------------------------------------------
|
|
412
|
+
def move_straight(d, turn_ok = true)
|
|
413
|
+
@move_succeed = passable?(@x, @y, d)
|
|
414
|
+
if @move_succeed
|
|
415
|
+
set_direction(d)
|
|
416
|
+
@x = $game_map.round_x_with_direction(@x, d)
|
|
417
|
+
@y = $game_map.round_y_with_direction(@y, d)
|
|
418
|
+
@real_x = $game_map.x_with_direction(@x, reverse_dir(d))
|
|
419
|
+
@real_y = $game_map.y_with_direction(@y, reverse_dir(d))
|
|
420
|
+
increase_steps
|
|
421
|
+
elsif turn_ok
|
|
422
|
+
set_direction(d)
|
|
423
|
+
check_event_trigger_touch_front
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
#--------------------------------------------------------------------------
|
|
427
|
+
# * Move Diagonally
|
|
428
|
+
# horz: Horizontal (4 or 6)
|
|
429
|
+
# vert: Vertical (2 or 8)
|
|
430
|
+
#--------------------------------------------------------------------------
|
|
431
|
+
def move_diagonal(horz, vert)
|
|
432
|
+
@move_succeed = diagonal_passable?(x, y, horz, vert)
|
|
433
|
+
if @move_succeed
|
|
434
|
+
@x = $game_map.round_x_with_direction(@x, horz)
|
|
435
|
+
@y = $game_map.round_y_with_direction(@y, vert)
|
|
436
|
+
@real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
|
|
437
|
+
@real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
|
|
438
|
+
increase_steps
|
|
439
|
+
end
|
|
440
|
+
set_direction(horz) if @direction == reverse_dir(horz)
|
|
441
|
+
set_direction(vert) if @direction == reverse_dir(vert)
|
|
442
|
+
end
|
|
443
|
+
end
|