rgss3 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,41 @@
1
+ module Kernel
2
+
3
+ def rgss_main#(&block)
4
+ begin
5
+ yield
6
+ rescue RGSSReset
7
+ retry
8
+ end
9
+ end
10
+
11
+ def rgss_stop
12
+ loop { Graphics.update }
13
+ end
14
+
15
+ def load_data(filename)
16
+ RGSSAD.files {|a|
17
+ if a.filename == filename
18
+ return Marshal.load(a)
19
+ end
20
+ }
21
+ File.open(filename, "rb") { |f|
22
+ Marshal.load(f)
23
+ }
24
+ end
25
+
26
+ def save_data(obj, filename)
27
+ if RGSSAD.files.size != 0
28
+ RGSSAD.add_file(Marshal.dump(obj), filename)
29
+ else
30
+ File.open(filename, "wb") { |f|
31
+ Marshal.dump(obj, f)
32
+ }
33
+ end
34
+ end
35
+
36
+ def msgbox(*args)
37
+ end
38
+
39
+ def msgbox_p(*args)
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+
2
+ require_relative 'sprite_container'
3
+ class Plane
4
+ include RGSS3::SpriteContainer
5
+ def draw
6
+ return if !@visible || @opacity == 0 || @bitmap == nil
7
+ @bitmap.gosu_image.draw(-@ox, -@oy, @z, 1, 1, 0xff_ffffff, BLEND[@blend_type])
8
+ end
9
+ end
@@ -0,0 +1,49 @@
1
+ class Rect
2
+
3
+ attr_accessor :x, :y, :width, :height
4
+
5
+ def initialize(*args)
6
+ case args.size
7
+ when 0
8
+ empty
9
+ when 4
10
+ set(*args)
11
+ else
12
+ raise ArgumentError
13
+ end
14
+ end
15
+
16
+ def set(*args)
17
+ case args.size
18
+ when 1
19
+ rect, = args
20
+ @x, @y, @width, @height = *rect
21
+ when 4
22
+ @x, @y, @width, @height = *args
23
+ else
24
+ raise ArgumentError
25
+ end
26
+ end
27
+
28
+ def empty
29
+ @x = 0
30
+ @y = 0
31
+ @width = 0
32
+ @height = 0
33
+ end
34
+
35
+ def to_a
36
+ [x, y, width, height]
37
+ end
38
+
39
+ def ==(other)
40
+ self.class == other.class && x == other.x && y == other.y &&
41
+ width == other.width && height == other.height
42
+ end
43
+
44
+ alias_method :eql?, :==
45
+
46
+ def hash
47
+ [:rect, *to_a].hash
48
+ end
49
+ end
@@ -0,0 +1,129 @@
1
+ module RGSSAD
2
+
3
+ @@files = []
4
+ @@xor = 0xDEADCAFE
5
+ @@rgss3a_xor = 0
6
+ @@orig_xor = 0
7
+ ENC_FILE = Dir["Game.rgss{ad,2a,3a}"][0] || ""
8
+ RGSSAD_File = Struct.new('RGSSAD_File', :filename, :filename_size, :file, :file_size)
9
+
10
+ public
11
+
12
+ def self.decrypt
13
+ return unless File.exists?(ENC_FILE)
14
+ @@files.clear
15
+ rgssad = ''
16
+ File.open(ENC_FILE, 'rb') {|file|
17
+ file.read(8)
18
+ @@orig_xor = file.read(4).unpack('L*') * 9 + 3 if ENC_FILE == "Game.rgss3a"
19
+ rgssad = file.read
20
+ }
21
+ rgssad = self.parse_rgssad(rgssad, true)
22
+ offset = 0
23
+ while rgssad[offset] != nil
24
+ file = RGSSAD_File.new
25
+ file.filename_size = rgssad[offset, 4].unpack('L')[0]
26
+ offset += 4
27
+ file.filename = rgssad[offset, file.filename_size]
28
+ offset += file.filename_size
29
+ file.file_size = rgssad[offset, 4].unpack('L')[0]
30
+ offset += 4
31
+ file.file = rgssad[offset, file.file_size]
32
+ @@files << file
33
+ offset += file.file_size
34
+ end
35
+ end
36
+
37
+ def self.files
38
+ @@files
39
+ end
40
+
41
+ def self.add_file(file_contents, filename)
42
+ file = RGSSAD_File.new
43
+ file.filename = filename
44
+ file.filename_size = filename.size
45
+ file.file = file_contents
46
+ file.file_size = file_contents.size
47
+ @@files.delete_if {|f| f.filename == file.filename}
48
+ @@files << file
49
+ @@files.sort! {|a,b| a.filename <=> b.filename}
50
+ end
51
+
52
+ def self.encrypt
53
+ return if @@files.empty? && !File.exists?(ENC_FILE)
54
+ rgssad = ''
55
+ @@files.each do |file|
56
+ rgssad << [file.filename_size].pack('L')
57
+ rgssad << file.filename
58
+ rgssad << [file.file_size].pack('L')
59
+ rgssad << file.file
60
+ end
61
+ File.open(ENC_FILE, 'wb') do |file|
62
+ file.print("RGSSAD\0\1")
63
+ file.print(self.parse_rgssad(rgssad, false))
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def self.next_key
70
+ if ENC_FILE == "Game.rgss3a"
71
+ @@rgss3a_xor = (@@rgss3a_xor * 7 + 3) & 0xFFFFFFFF
72
+ else
73
+ @@xor = (@@xor * 7 + 3) & 0xFFFFFFFF
74
+ end
75
+ end
76
+
77
+ def self.used_xor
78
+ ENC_FILE == "Game.rgss3a" ? @@rgss3a_xor : @@xor
79
+ end
80
+
81
+ def self.parse_rgssad(string, decrypt)
82
+ @@xor = 0xDEADCAFE
83
+ @@rgss3a_xor = @@orig_xor
84
+ new_string = ''
85
+ offset = 0
86
+ remember_offsets = []
87
+ remember_keys = []
88
+ remember_size = []
89
+ while string[offset] != nil
90
+ namesize = string[offset, 4].unpack('L')[0]
91
+ new_string << [namesize ^ used_xor].pack('L')
92
+ namesize ^= used_xor if decrypt
93
+ offset += 4
94
+ self.next_key
95
+ filename = string[offset, namesize]
96
+ namesize.times do |i|
97
+ filename.setbyte(i, filename.getbyte(i) ^ used_xor & 0xFF)
98
+ self.next_key
99
+ end
100
+ new_string << filename
101
+ offset += namesize
102
+ datasize = string[offset, 4].unpack('L')[0]
103
+ new_string << [datasize ^ used_xor].pack('L')
104
+ datasize ^= used_xor if decrypt
105
+ remember_size << datasize
106
+ offset += 4
107
+ self.next_key
108
+ data = string[offset, datasize]
109
+ new_string << data
110
+ remember_offsets << offset
111
+ remember_keys << used_xor
112
+ offset += datasize
113
+ end
114
+ remember_offsets.size.times do |i|
115
+ offset = remember_offsets[i]
116
+ used_xor = remember_keys[i]
117
+ size = remember_size[i]
118
+ data = new_string[offset, size]
119
+ data = data.ljust(size + (4 - size % 4)) if size % 4 != 0
120
+ s = ''
121
+ data.unpack('L' * (data.size / 4)).each do |j|
122
+ s << ([j ^ used_xor].pack('L'))
123
+ self.next_key
124
+ end
125
+ new_string[offset, size] = s.slice(0, size)
126
+ end
127
+ return new_string
128
+ end
129
+ end
@@ -0,0 +1,2 @@
1
+ class RGSSError < StandardError
2
+ end
@@ -0,0 +1,2 @@
1
+ class RGSSReset < Exception
2
+ end
@@ -0,0 +1,997 @@
1
+ module RPG; end
2
+
3
+ class RPG::AudioFile
4
+ def initialize(name = '', volume = 100, pitch = 100)
5
+ @name = name
6
+ @volume = volume
7
+ @pitch = pitch
8
+ end
9
+ attr_accessor :name
10
+ attr_accessor :volume
11
+ attr_accessor :pitch
12
+ end
13
+
14
+
15
+ class RPG::BGM < RPG::AudioFile
16
+ @@last = RPG::BGM.new
17
+ def play(pos = 0)
18
+ if @name.empty?
19
+ Audio.bgm_stop
20
+ @@last = RPG::BGM.new
21
+ else
22
+ Audio.bgm_play('Audio/BGM/' + @name, @volume, @pitch, pos)
23
+ @@last = self.clone
24
+ end
25
+ end
26
+ def replay
27
+ play(@pos)
28
+ end
29
+ def self.stop
30
+ Audio.bgm_stop
31
+ @@last = RPG::BGM.new
32
+ end
33
+ def self.fade(time)
34
+ Audio.bgm_fade(time)
35
+ @@last = RPG::BGM.new
36
+ end
37
+ def self.last
38
+ @@last.pos = Audio.bgm_pos
39
+ @@last
40
+ end
41
+ attr_accessor :pos
42
+ end
43
+
44
+
45
+ class RPG::BGS < RPG::AudioFile
46
+ @@last = RPG::BGS.new
47
+ def play(pos = 0)
48
+ if @name.empty?
49
+ Audio.bgs_stop
50
+ @@last = RPG::BGS.new
51
+ else
52
+ Audio.bgs_play('Audio/BGS/' + @name, @volume, @pitch, pos)
53
+ @@last = self.clone
54
+ end
55
+ end
56
+ def replay
57
+ play(@pos)
58
+ end
59
+ def self.stop
60
+ Audio.bgs_stop
61
+ @@last = RPG::BGS.new
62
+ end
63
+ def self.fade(time)
64
+ Audio.bgs_fade(time)
65
+ @@last = RPG::BGS.new
66
+ end
67
+ def self.last
68
+ @@last.pos = Audio.bgs_pos
69
+ @@last
70
+ end
71
+ attr_accessor :pos
72
+ end
73
+
74
+
75
+ class RPG::ME < RPG::AudioFile
76
+ def play
77
+ if @name.empty?
78
+ Audio.me_stop
79
+ else
80
+ Audio.me_play('Audio/ME/' + @name, @volume, @pitch)
81
+ end
82
+ end
83
+ def self.stop
84
+ Audio.me_stop
85
+ end
86
+ def self.fade(time)
87
+ Audio.me_fade(time)
88
+ end
89
+ end
90
+
91
+
92
+ class RPG::SE < RPG::AudioFile
93
+ def play
94
+ unless @name.empty?
95
+ Audio.se_play('Audio/SE/' + @name, @volume, @pitch)
96
+ end
97
+ end
98
+ def self.stop
99
+ Audio.se_stop
100
+ end
101
+ end
102
+
103
+
104
+ class RPG::Tileset
105
+ def initialize
106
+ @id = 0
107
+ @mode = 1
108
+ @name = ''
109
+ @tileset_names = Array.new(9).collect{''}
110
+ @flags = Table.new(8192)
111
+ @flags[0] = 0x0010
112
+ (2048..2815).each {|i| @flags[i] = 0x000F}
113
+ (4352..8191).each {|i| @flags[i] = 0x000F}
114
+ @note = ''
115
+ end
116
+ attr_accessor :id
117
+ attr_accessor :mode
118
+ attr_accessor :name
119
+ attr_accessor :tileset_names
120
+ attr_accessor :flags
121
+ attr_accessor :note
122
+ end
123
+ class RPG::Map
124
+ def initialize(width, height)
125
+ @display_name = ''
126
+ @tileset_id = 1
127
+ @width = width
128
+ @height = height
129
+ @scroll_type = 0
130
+ @specify_battleback = false
131
+ @battleback_floor_name = ''
132
+ @battleback_wall_name = ''
133
+ @autoplay_bgm = false
134
+ @bgm = RPG::BGM.new
135
+ @autoplay_bgs = false
136
+ @bgs = RPG::BGS.new('', 80)
137
+ @disable_dashing = false
138
+ @encounter_list = []
139
+ @encounter_step = 30
140
+ @parallax_name = ''
141
+ @parallax_loop_x = false
142
+ @parallax_loop_y = false
143
+ @parallax_sx = 0
144
+ @parallax_sy = 0
145
+ @parallax_show = false
146
+ @note = ''
147
+ @data = Table.new(width, height, 4)
148
+ @events = {}
149
+ end
150
+ attr_accessor :display_name
151
+ attr_accessor :tileset_id
152
+ attr_accessor :width
153
+ attr_accessor :height
154
+ attr_accessor :scroll_type
155
+ attr_accessor :specify_battleback
156
+ attr_accessor :battleback1_name
157
+ attr_accessor :battleback2_name
158
+ attr_accessor :autoplay_bgm
159
+ attr_accessor :bgm
160
+ attr_accessor :autoplay_bgs
161
+ attr_accessor :bgs
162
+ attr_accessor :disable_dashing
163
+ attr_accessor :encounter_list
164
+ attr_accessor :encounter_step
165
+ attr_accessor :parallax_name
166
+ attr_accessor :parallax_loop_x
167
+ attr_accessor :parallax_loop_y
168
+ attr_accessor :parallax_sx
169
+ attr_accessor :parallax_sy
170
+ attr_accessor :parallax_show
171
+ attr_accessor :note
172
+ attr_accessor :data
173
+ attr_accessor :events
174
+ end
175
+
176
+ class RPG::Map::Encounter
177
+ def initialize
178
+ @troop_id = 1
179
+ @weight = 10
180
+ @region_set = []
181
+ end
182
+ attr_accessor :troop_id
183
+ attr_accessor :weight
184
+ attr_accessor :region_set
185
+ end
186
+
187
+
188
+ class RPG::MapInfo
189
+ def initialize
190
+ @name = ''
191
+ @parent_id = 0
192
+ @order = 0
193
+ @expanded = false
194
+ @scroll_x = 0
195
+ @scroll_y = 0
196
+ end
197
+ attr_accessor :name
198
+ attr_accessor :parent_id
199
+ attr_accessor :order
200
+ attr_accessor :expanded
201
+ attr_accessor :scroll_x
202
+ attr_accessor :scroll_y
203
+ end
204
+
205
+
206
+ class RPG::Event
207
+ def initialize(x, y)
208
+ @id = 0
209
+ @name = ''
210
+ @x = x
211
+ @y = y
212
+ @pages = [RPG::Event::Page.new]
213
+ end
214
+ attr_accessor :id
215
+ attr_accessor :name
216
+ attr_accessor :x
217
+ attr_accessor :y
218
+ attr_accessor :pages
219
+ end
220
+
221
+
222
+ class RPG::Event::Page
223
+ def initialize
224
+ @condition = RPG::Event::Page::Condition.new
225
+ @graphic = RPG::Event::Page::Graphic.new
226
+ @move_type = 0
227
+ @move_speed = 3
228
+ @move_frequency = 3
229
+ @move_route = RPG::MoveRoute.new
230
+ @walk_anime = true
231
+ @step_anime = false
232
+ @direction_fix = false
233
+ @through = false
234
+ @priority_type = 0
235
+ @trigger = 0
236
+ @list = [RPG::EventCommand.new]
237
+ end
238
+ attr_accessor :condition
239
+ attr_accessor :graphic
240
+ attr_accessor :move_type
241
+ attr_accessor :move_speed
242
+ attr_accessor :move_frequency
243
+ attr_accessor :move_route
244
+ attr_accessor :walk_anime
245
+ attr_accessor :step_anime
246
+ attr_accessor :direction_fix
247
+ attr_accessor :through
248
+ attr_accessor :priority_type
249
+ attr_accessor :trigger
250
+ attr_accessor :list
251
+ end
252
+
253
+
254
+ class RPG::Event::Page::Condition
255
+ def initialize
256
+ @switch1_valid = false
257
+ @switch2_valid = false
258
+ @variable_valid = false
259
+ @self_switch_valid = false
260
+ @item_valid = false
261
+ @actor_valid = false
262
+ @switch1_id = 1
263
+ @switch2_id = 1
264
+ @variable_id = 1
265
+ @variable_value = 0
266
+ @self_switch_ch = 'A'
267
+ @item_id = 1
268
+ @actor_id = 1
269
+ end
270
+ attr_accessor :switch1_valid
271
+ attr_accessor :switch2_valid
272
+ attr_accessor :variable_valid
273
+ attr_accessor :self_switch_valid
274
+ attr_accessor :item_valid
275
+ attr_accessor :actor_valid
276
+ attr_accessor :switch1_id
277
+ attr_accessor :switch2_id
278
+ attr_accessor :variable_id
279
+ attr_accessor :variable_value
280
+ attr_accessor :self_switch_ch
281
+ attr_accessor :item_id
282
+ attr_accessor :actor_id
283
+ end
284
+
285
+
286
+ class RPG::Event::Page::Graphic
287
+ def initialize
288
+ @tile_id = 0
289
+ @character_name = ''
290
+ @character_index = 0
291
+ @direction = 2
292
+ @pattern = 0
293
+ end
294
+ attr_accessor :tile_id
295
+ attr_accessor :character_name
296
+ attr_accessor :character_index
297
+ attr_accessor :direction
298
+ attr_accessor :pattern
299
+ end
300
+
301
+
302
+ class RPG::EventCommand
303
+ def initialize(code = 0, indent = 0, parameters = [])
304
+ @code = code
305
+ @indent = indent
306
+ @parameters = parameters
307
+ end
308
+ attr_accessor :code
309
+ attr_accessor :indent
310
+ attr_accessor :parameters
311
+ end
312
+
313
+
314
+ class RPG::MoveRoute
315
+ def initialize
316
+ @repeat = true
317
+ @skippable = false
318
+ @wait = false
319
+ @list = [RPG::MoveCommand.new]
320
+ end
321
+ attr_accessor :repeat
322
+ attr_accessor :skippable
323
+ attr_accessor :wait
324
+ attr_accessor :list
325
+ end
326
+ class RPG::MoveCommand
327
+ def initialize(code = 0, parameters = [])
328
+ @code = code
329
+ @parameters = parameters
330
+ end
331
+ attr_accessor :code
332
+ attr_accessor :parameters
333
+ end
334
+
335
+
336
+ class RPG::CommonEvent
337
+ def initialize
338
+ @id = 0
339
+ @name = ''
340
+ @trigger = 0
341
+ @switch_id = 1
342
+ @list = [RPG::EventCommand.new]
343
+ end
344
+ def autorun?
345
+ @trigger == 1
346
+ end
347
+ def parallel?
348
+ @trigger == 2
349
+ end
350
+ attr_accessor :id
351
+ attr_accessor :name
352
+ attr_accessor :trigger
353
+ attr_accessor :switch_id
354
+ attr_accessor :list
355
+ end
356
+ class RPG::BaseItem
357
+ def initialize
358
+ @id = 0
359
+ @name = ''
360
+ @icon_index = 0
361
+ @description = ''
362
+ @features = []
363
+ @note = ''
364
+ end
365
+ attr_accessor :id
366
+ attr_accessor :name
367
+ attr_accessor :icon_index
368
+ attr_accessor :description
369
+ attr_accessor :features
370
+ attr_accessor :note
371
+ end
372
+
373
+
374
+ class RPG::BaseItem::Feature
375
+ def initialize(code = 0, data_id = 0, value = 0)
376
+ @code = code
377
+ @data_id = data_id
378
+ @value = value
379
+ end
380
+ attr_accessor :code
381
+ attr_accessor :data_id
382
+ attr_accessor :value
383
+ end
384
+
385
+
386
+ class RPG::Actor < RPG::BaseItem
387
+ def initialize
388
+ super
389
+ @nickname = ''
390
+ @class_id = 1
391
+ @initial_level = 1
392
+ @max_level = 99
393
+ @character_name = ''
394
+ @character_index = 0
395
+ @face_name = ''
396
+ @face_index = 0
397
+ @equips = [0,0,0,0,0]
398
+ end
399
+ attr_accessor :nickname
400
+ attr_accessor :class_id
401
+ attr_accessor :initial_level
402
+ attr_accessor :max_level
403
+ attr_accessor :character_name
404
+ attr_accessor :character_index
405
+ attr_accessor :face_name
406
+ attr_accessor :face_index
407
+ attr_accessor :equips
408
+ end
409
+ class RPG::Class < RPG::BaseItem
410
+ def initialize
411
+ super
412
+ @exp_params = [30,20,30,30]
413
+ @params = Table.new(8,100)
414
+ (1..99).each do |i|
415
+ @params[0,i] = 400+i*50
416
+ @params[1,i] = 80+i*10
417
+ (2..5).each {|j| @params[j,i] = 15+i*5/4 }
418
+ (6..7).each {|j| @params[j,i] = 30+i*5/2 }
419
+ end
420
+ @learnings = []
421
+ @features.push(RPG::BaseItem::Feature.new(23, 0, 1))
422
+ @features.push(RPG::BaseItem::Feature.new(22, 0, 0.95))
423
+ @features.push(RPG::BaseItem::Feature.new(22, 1, 0.05))
424
+ @features.push(RPG::BaseItem::Feature.new(22, 2, 0.04))
425
+ @features.push(RPG::BaseItem::Feature.new(41, 1))
426
+ @features.push(RPG::BaseItem::Feature.new(51, 1))
427
+ @features.push(RPG::BaseItem::Feature.new(52, 1))
428
+ end
429
+ def exp_for_level(level)
430
+ lv = level.to_f
431
+ basis = @exp_params[0].to_f
432
+ extra = @exp_params[1].to_f
433
+ acc_a = @exp_params[2].to_f
434
+ acc_b = @exp_params[3].to_f
435
+ return (basis*((lv-1)**(0.9+acc_a/250))*lv*(lv+1)/
436
+ (6+lv**2/50/acc_b)+(lv-1)*extra).round.to_i
437
+ end
438
+ attr_accessor :exp_params
439
+ attr_accessor :params
440
+ attr_accessor :learnings
441
+ end
442
+
443
+
444
+ class RPG::Class::Learning
445
+ def initialize
446
+ @level = 1
447
+ @skill_id = 1
448
+ @note = ''
449
+ end
450
+ attr_accessor :level
451
+ attr_accessor :skill_id
452
+ attr_accessor :note
453
+ end
454
+
455
+
456
+ class RPG::UsableItem < RPG::BaseItem
457
+ def initialize
458
+ super
459
+ @scope = 0
460
+ @occasion = 0
461
+ @speed = 0
462
+ @success_rate = 100
463
+ @repeats = 1
464
+ @tp_gain = 0
465
+ @hit_type = 0
466
+ @animation_id = 0
467
+ @damage = RPG::UsableItem::Damage.new
468
+ @effects = []
469
+ end
470
+ def for_opponent?
471
+ [1, 2, 3, 4, 5, 6].include?(@scope)
472
+ end
473
+ def for_friend?
474
+ [7, 8, 9, 10, 11].include?(@scope)
475
+ end
476
+ def for_dead_friend?
477
+ [9, 10].include?(@scope)
478
+ end
479
+ def for_user?
480
+ @scope == 11
481
+ end
482
+ def for_one?
483
+ [1, 3, 7, 9, 11].include?(@scope)
484
+ end
485
+ def for_random?
486
+ [3, 4, 5, 6].include?(@scope)
487
+ end
488
+ def number_of_targets
489
+ for_random? ? @scope - 2 : 0
490
+ end
491
+ def for_all?
492
+ [2, 8, 10].include?(@scope)
493
+ end
494
+ def need_selection?
495
+ [1, 7, 9].include?(@scope)
496
+ end
497
+ def battle_ok?
498
+ [0, 1].include?(@occasion)
499
+ end
500
+ def menu_ok?
501
+ [0, 2].include?(@occasion)
502
+ end
503
+ def certain?
504
+ @hit_type == 0
505
+ end
506
+ def physical?
507
+ @hit_type == 1
508
+ end
509
+ def magical?
510
+ @hit_type == 2
511
+ end
512
+ attr_accessor :scope
513
+ attr_accessor :occasion
514
+ attr_accessor :speed
515
+ attr_accessor :animation_id
516
+ attr_accessor :success_rate
517
+ attr_accessor :repeats
518
+ attr_accessor :tp_gain
519
+ attr_accessor :hit_type
520
+ attr_accessor :damage
521
+ attr_accessor :effects
522
+ end
523
+
524
+
525
+ class RPG::UsableItem::Damage
526
+ def initialize
527
+ @type = 0
528
+ @element_id = 0
529
+ @formula = '0'
530
+ @variance = 20
531
+ @critical = false
532
+ end
533
+ def none?
534
+ @type == 0
535
+ end
536
+ def to_hp?
537
+ [1,3,5].include?(@type)
538
+ end
539
+ def to_mp?
540
+ [2,4,6].include?(@type)
541
+ end
542
+ def recover?
543
+ [3,4].include?(@type)
544
+ end
545
+ def drain?
546
+ [5,6].include?(@type)
547
+ end
548
+ def sign
549
+ recover? ? -1 : 1
550
+ end
551
+ def eval(a, b, v)
552
+ [Kernel.eval(@formula), 0].max * sign rescue 0
553
+ end
554
+ attr_accessor :type
555
+ attr_accessor :element_id
556
+ attr_accessor :formula
557
+ attr_accessor :variance
558
+ attr_accessor :critical
559
+ end
560
+
561
+
562
+ class RPG::UsableItem::Effect
563
+ def initialize(code = 0, data_id = 0, value1 = 0, value2 = 0)
564
+ @code = code
565
+ @data_id = data_id
566
+ @value1 = value1
567
+ @value2 = value2
568
+ end
569
+ attr_accessor :code
570
+ attr_accessor :data_id
571
+ attr_accessor :value1
572
+ attr_accessor :value2
573
+ end
574
+
575
+
576
+ class RPG::Skill < RPG::UsableItem
577
+ def initialize
578
+ super
579
+ @scope = 1
580
+ @stype_id = 1
581
+ @mp_cost = 0
582
+ @tp_cost = 0
583
+ @message1 = ''
584
+ @message2 = ''
585
+ @required_wtype_id1 = 0
586
+ @required_wtype_id2 = 0
587
+ end
588
+ attr_accessor :stype_id
589
+ attr_accessor :mp_cost
590
+ attr_accessor :tp_cost
591
+ attr_accessor :message1
592
+ attr_accessor :message2
593
+ attr_accessor :required_wtype_id1
594
+ attr_accessor :required_wtype_id2
595
+ end
596
+ class RPG::Item < RPG::UsableItem
597
+ def initialize
598
+ super
599
+ @scope = 7
600
+ @itype_id = 1
601
+ @price = 0
602
+ @consumable = true
603
+ end
604
+ def key_item?
605
+ @itype_id == 2
606
+ end
607
+ attr_accessor :itype_id
608
+ attr_accessor :price
609
+ attr_accessor :consumable
610
+ end
611
+
612
+
613
+ class RPG::EquipItem < RPG::BaseItem
614
+ def initialize
615
+ super
616
+ @price = 0
617
+ @etype_id = 0
618
+ @params = [0] * 8
619
+ end
620
+ attr_accessor :price
621
+ attr_accessor :etype_id
622
+ attr_accessor :params
623
+ end
624
+ class RPG::Weapon < RPG::EquipItem
625
+ def initialize
626
+ super
627
+ @wtype_id = 0
628
+ @animation_id = 0
629
+ @features.push(RPG::BaseItem::Feature.new(31, 1, 0))
630
+ @features.push(RPG::BaseItem::Feature.new(22, 0, 0))
631
+ end
632
+ def performance
633
+ params[2] + params[4] + params.inject(0) {|r, v| r += v }
634
+ end
635
+ attr_accessor :wtype_id
636
+ attr_accessor :animation_id
637
+ end
638
+
639
+
640
+ class RPG::Armor < RPG::EquipItem
641
+ def initialize
642
+ super
643
+ @atype_id = 0
644
+ @etype_id = 1
645
+ @features.push(RPG::BaseItem::Feature.new(22, 1, 0))
646
+ end
647
+ def performance
648
+ params[3] + params[5] + params.inject(0) {|r, v| r += v }
649
+ end
650
+ attr_accessor :atype_id
651
+ end
652
+
653
+
654
+ class RPG::Enemy < RPG::BaseItem
655
+ def initialize
656
+ super
657
+ @battler_name = ''
658
+ @battler_hue = 0
659
+ @params = [100,0,10,10,10,10,10,10]
660
+ @exp = 0
661
+ @gold = 0
662
+ @drop_items = Array.new(3) { RPG::Enemy::DropItem.new }
663
+ @actions = [RPG::Enemy::Action.new]
664
+ @features.push(RPG::BaseItem::Feature.new(22, 0, 0.95))
665
+ @features.push(RPG::BaseItem::Feature.new(22, 1, 0.05))
666
+ @features.push(RPG::BaseItem::Feature.new(31, 1, 0))
667
+ end
668
+ attr_accessor :battler_name
669
+ attr_accessor :battler_hue
670
+ attr_accessor :params
671
+ attr_accessor :exp
672
+ attr_accessor :gold
673
+ attr_accessor :drop_items
674
+ attr_accessor :actions
675
+ end
676
+
677
+
678
+ class RPG::Enemy::DropItem
679
+ def initialize
680
+ @kind = 0
681
+ @data_id = 1
682
+ @denominator = 1
683
+ end
684
+ attr_accessor :kind
685
+ attr_accessor :data_id
686
+ attr_accessor :denominator
687
+ end
688
+
689
+
690
+ class RPG::Enemy::Action
691
+ def initialize
692
+ @skill_id = 1
693
+ @condition_type = 0
694
+ @condition_param1 = 0
695
+ @condition_param2 = 0
696
+ @rating = 5
697
+ end
698
+ attr_accessor :skill_id
699
+ attr_accessor :condition_type
700
+ attr_accessor :condition_param1
701
+ attr_accessor :condition_param2
702
+ attr_accessor :rating
703
+ end
704
+
705
+
706
+ class RPG::State < RPG::BaseItem
707
+ def initialize
708
+ super
709
+ @restriction = 0
710
+ @priority = 50
711
+ @remove_at_battle_end = false
712
+ @remove_by_restriction = false
713
+ @auto_removal_timing = 0
714
+ @min_turns = 1
715
+ @max_turns = 1
716
+ @remove_by_damage = false
717
+ @chance_by_damage = 100
718
+ @remove_by_walking = false
719
+ @steps_to_remove = 100
720
+ @message1 = ''
721
+ @message2 = ''
722
+ @message3 = ''
723
+ @message4 = ''
724
+ end
725
+ attr_accessor :restriction
726
+ attr_accessor :priority
727
+ attr_accessor :remove_at_battle_end
728
+ attr_accessor :remove_by_restriction
729
+ attr_accessor :auto_removal_timing
730
+ attr_accessor :min_turns
731
+ attr_accessor :max_turns
732
+ attr_accessor :remove_by_damage
733
+ attr_accessor :chance_by_damage
734
+ attr_accessor :remove_by_walking
735
+ attr_accessor :steps_to_remove
736
+ attr_accessor :message1
737
+ attr_accessor :message2
738
+ attr_accessor :message3
739
+ attr_accessor :message4
740
+ end
741
+
742
+
743
+ class RPG::Troop
744
+ def initialize
745
+ @id = 0
746
+ @name = ''
747
+ @members = []
748
+ @pages = [RPG::Troop::Page.new]
749
+ end
750
+ attr_accessor :id
751
+ attr_accessor :name
752
+ attr_accessor :members
753
+ attr_accessor :pages
754
+ end
755
+
756
+
757
+ class RPG::Troop::Member
758
+ def initialize
759
+ @enemy_id = 1
760
+ @x = 0
761
+ @y = 0
762
+ @hidden = false
763
+ end
764
+ attr_accessor :enemy_id
765
+ attr_accessor :x
766
+ attr_accessor :y
767
+ attr_accessor :hidden
768
+ end
769
+
770
+
771
+ class RPG::Troop::Page
772
+ def initialize
773
+ @condition = RPG::Troop::Page::Condition.new
774
+ @span = 0
775
+ @list = [RPG::EventCommand.new]
776
+ end
777
+ attr_accessor :condition
778
+ attr_accessor :span
779
+ attr_accessor :list
780
+ end
781
+
782
+
783
+ class RPG::Troop::Page::Condition
784
+ def initialize
785
+ @turn_ending = false
786
+ @turn_valid = false
787
+ @enemy_valid = false
788
+ @actor_valid = false
789
+ @switch_valid = false
790
+ @turn_a = 0
791
+ @turn_b = 0
792
+ @enemy_index = 0
793
+ @enemy_hp = 50
794
+ @actor_id = 1
795
+ @actor_hp = 50
796
+ @switch_id = 1
797
+ end
798
+ attr_accessor :turn_ending
799
+ attr_accessor :turn_valid
800
+ attr_accessor :enemy_valid
801
+ attr_accessor :actor_valid
802
+ attr_accessor :switch_valid
803
+ attr_accessor :turn_a
804
+ attr_accessor :turn_b
805
+ attr_accessor :enemy_index
806
+ attr_accessor :enemy_hp
807
+ attr_accessor :actor_id
808
+ attr_accessor :actor_hp
809
+ attr_accessor :switch_id
810
+ end
811
+
812
+
813
+ class RPG::Animation
814
+ def initialize
815
+ @id = 0
816
+ @name = ''
817
+ @animation1_name = ''
818
+ @animation1_hue = 0
819
+ @animation2_name = ''
820
+ @animation2_hue = 0
821
+ @position = 1
822
+ @frame_max = 1
823
+ @frames = [RPG::Animation::Frame.new]
824
+ @timings = []
825
+ end
826
+ def to_screen?
827
+ @position == 3
828
+ end
829
+ attr_accessor :id
830
+ attr_accessor :name
831
+ attr_accessor :animation1_name
832
+ attr_accessor :animation1_hue
833
+ attr_accessor :animation2_name
834
+ attr_accessor :animation2_hue
835
+ attr_accessor :position
836
+ attr_accessor :frame_max
837
+ attr_accessor :frames
838
+ attr_accessor :timings
839
+ end
840
+
841
+
842
+ class RPG::Animation::Frame
843
+ def initialize
844
+ @cell_max = 0
845
+ @cell_data = Table.new(0, 0)
846
+ end
847
+ attr_accessor :cell_max
848
+ attr_accessor :cell_data
849
+ end
850
+
851
+
852
+ class RPG::Animation::Timing
853
+ def initialize
854
+ @frame = 0
855
+ @se = RPG::SE.new('', 80)
856
+ @flash_scope = 0
857
+ @flash_color = Color.new(255,255,255,255)
858
+ @flash_duration = 5
859
+ end
860
+ attr_accessor :frame
861
+ attr_accessor :se
862
+ attr_accessor :flash_scope
863
+ attr_accessor :flash_color
864
+ attr_accessor :flash_duration
865
+ end
866
+
867
+
868
+ class RPG::System
869
+ def initialize
870
+ @game_title = ''
871
+ @version_id = 0
872
+ @japanese = true
873
+ @party_members = [1]
874
+ @currency_unit = ''
875
+ @elements = [nil, '']
876
+ @skill_types = [nil, '']
877
+ @weapon_types = [nil, '']
878
+ @armor_types = [nil, '']
879
+ @switches = [nil, '']
880
+ @variables = [nil, '']
881
+ @boat = RPG::System::Vehicle.new
882
+ @ship = RPG::System::Vehicle.new
883
+ @airship = RPG::System::Vehicle.new
884
+ @title1_name = ''
885
+ @title2_name = ''
886
+ @opt_draw_title = true
887
+ @opt_use_midi = false
888
+ @opt_transparent = false
889
+ @opt_followers = true
890
+ @opt_slip_death = false
891
+ @opt_floor_death = false
892
+ @opt_display_tp = true
893
+ @opt_extra_exp = false
894
+ @window_tone = Tone.new(0,0,0)
895
+ @title_bgm = RPG::BGM.new
896
+ @battle_bgm = RPG::BGM.new
897
+ @battle_end_me = RPG::ME.new
898
+ @gameover_me = RPG::ME.new
899
+ @sounds = Array.new(24) { RPG::SE.new }
900
+ @test_battlers = []
901
+ @test_troop_id = 1
902
+ @start_map_id = 1
903
+ @start_x = 0
904
+ @start_y = 0
905
+ @terms = RPG::System::Terms.new
906
+ @battleback1_name = ''
907
+ @battleback2_name = ''
908
+ @battler_name = ''
909
+ @battler_hue = 0
910
+ @edit_map_id = 1
911
+ end
912
+ attr_accessor :game_title
913
+ attr_accessor :version_id
914
+ attr_accessor :japanese
915
+ attr_accessor :party_members
916
+ attr_accessor :currency_unit
917
+ attr_accessor :skill_types
918
+ attr_accessor :weapon_types
919
+ attr_accessor :armor_types
920
+ attr_accessor :elements
921
+ attr_accessor :switches
922
+ attr_accessor :variables
923
+ attr_accessor :boat
924
+ attr_accessor :ship
925
+ attr_accessor :airship
926
+ attr_accessor :title1_name
927
+ attr_accessor :title2_name
928
+ attr_accessor :opt_draw_title
929
+ attr_accessor :opt_use_midi
930
+ attr_accessor :opt_transparent
931
+ attr_accessor :opt_followers
932
+ attr_accessor :opt_slip_death
933
+ attr_accessor :opt_floor_death
934
+ attr_accessor :opt_display_tp
935
+ attr_accessor :opt_extra_exp
936
+ attr_accessor :window_tone
937
+ attr_accessor :title_bgm
938
+ attr_accessor :battle_bgm
939
+ attr_accessor :battle_end_me
940
+ attr_accessor :gameover_me
941
+ attr_accessor :sounds
942
+ attr_accessor :test_battlers
943
+ attr_accessor :test_troop_id
944
+ attr_accessor :start_map_id
945
+ attr_accessor :start_x
946
+ attr_accessor :start_y
947
+ attr_accessor :terms
948
+ attr_accessor :battleback1_name
949
+ attr_accessor :battleback2_name
950
+ attr_accessor :battler_name
951
+ attr_accessor :battler_hue
952
+ attr_accessor :edit_map_id
953
+ end
954
+
955
+
956
+ class RPG::System::Vehicle
957
+ def initialize
958
+ @character_name = ''
959
+ @character_index = 0
960
+ @bgm = RPG::BGM.new
961
+ @start_map_id = 0
962
+ @start_x = 0
963
+ @start_y = 0
964
+ end
965
+ attr_accessor :character_name
966
+ attr_accessor :character_index
967
+ attr_accessor :bgm
968
+ attr_accessor :start_map_id
969
+ attr_accessor :start_x
970
+ attr_accessor :start_y
971
+ end
972
+
973
+
974
+ class RPG::System::Terms
975
+ def initialize
976
+ @basic = Array.new(8) {''}
977
+ @params = Array.new(8) {''}
978
+ @etypes = Array.new(5) {''}
979
+ @commands = Array.new(23) {''}
980
+ end
981
+ attr_accessor :basic
982
+ attr_accessor :params
983
+ attr_accessor :etypes
984
+ attr_accessor :commands
985
+ end
986
+
987
+
988
+ class RPG::System::TestBattler
989
+ def initialize
990
+ @actor_id = 1
991
+ @level = 1
992
+ @equips = [0,0,0,0,0]
993
+ end
994
+ attr_accessor :actor_id
995
+ attr_accessor :level
996
+ attr_accessor :equips
997
+ end