View difference between Paste ID: CGfbK45n and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | #============================================================================== |
2 | # Vampyr - Verus Tempus Proelium | |
3 | #============================================================================== | |
4 | Vampyr_Kernel.register("Vampyr Verus Tempus Proelium", 1.0, "03/23/2010") | |
5 | #------------------------------------------------------------------------------ | |
6 | # Key to attack | |
7 | Attack_Key = Input::X | |
8 | ||
9 | # Key to use shield | |
10 | Defend_Key = Input::Y | |
11 | ||
12 | # Key used to cast skills (R = Letter W) | |
13 | Skills_Key = Input::R | |
14 | ||
15 | # Key used to cast items ( L = Letter Q) | |
16 | Items_Key = Input::L | |
17 | ||
18 | # Key used to change allies actions (Z = Letter D) | |
19 | Allies_Key = Input::Z | |
20 | ||
21 | # Index of the gold icon and drop % | |
22 | Gold_Properties = 147, 50 | |
23 | ||
24 | # Battle Area Variable (Used to open doors after kill X enemies, for example) | |
25 | Battle_Area_Variable = 0 | |
26 | ||
27 | # Hits Propertires | |
28 | Hit = {} | |
29 | Hit["show"] = true | |
30 | Hit["font"] = ["Georgia", 22, false, true] # Face, Size, Bold, Italic | |
31 | Hit["texts"] = ["Hits", "Total Damage"] | |
32 | Hit["position"] = [334, 175] | |
33 | ||
34 | # Damage Properties | |
35 | Damage = {} | |
36 | Damage["font"] = ["Georgia", 20, false, true] # Face, Size, Bold, Italic | |
37 | Damage["texts"] = ["Miss", "Critical", "Guard"] | |
38 | ||
39 | #------------------------------------------------------------------------------ | |
40 | class VerusTempusProelium | |
41 | ||
42 | attr_reader :attack_key | |
43 | attr_reader :defend_key | |
44 | attr_reader :skills_key | |
45 | attr_reader :items_key | |
46 | attr_reader :allies_key | |
47 | attr_reader :hit | |
48 | attr_reader :damage | |
49 | attr_reader :hits_total | |
50 | attr_reader :damage_total | |
51 | attr_reader :gold_properties | |
52 | attr_reader :battle_area_variable | |
53 | ||
54 | def initialize | |
55 | @hits_total = 0 | |
56 | @damage_total = 0 | |
57 | @hitcount_delay = 0 | |
58 | @attack_key = Attack_Key | |
59 | @defend_key = Defend_Key | |
60 | @skills_key = Skills_Key | |
61 | @items_key = Items_Key | |
62 | @allies_key = Allies_Key | |
63 | @hit = Hit | |
64 | @damage = Damage | |
65 | @gold_properties = Gold_Properties | |
66 | @battle_area_variable = Battle_Area_Variable | |
67 | end | |
68 | ||
69 | def update | |
70 | if @hitcount_delay > 0 | |
71 | @hitcount_delay -= 1 | |
72 | elsif @hitcount_delay <= 0 and @hits_total > 0 | |
73 | @hits_total = 0 | |
74 | @damage_total = 0 | |
75 | end | |
76 | end | |
77 | ||
78 | def melee_attack(attacker, target) | |
79 | attacker.attack_delay = attacker.actor.attack_speed | |
80 | attacker.animation_delay = 30 | |
81 | return unless valid_target?(target) | |
82 | return if guard?(attacker, target) | |
83 | target.actor.attack_effect(attacker.actor) | |
84 | target.animation_id = attacker.actor.atk_animation_id.to_i | |
85 | hit_count(attacker, target) | |
86 | target.target = attacker unless same_team?(attacker, target) | |
87 | end | |
88 | ||
89 | def melee_attack2(attacker, target) | |
90 | attacker.attack2_delay = attacker.actor.attack_speed | |
91 | attacker.animation_delay = 30 | |
92 | return unless valid_target?(target) | |
93 | return unless attacker.in_front?(target) | |
94 | return if guard?(attacker, target) | |
95 | target.actor.attack_effect(attacker.actor) | |
96 | target.animation_id = attacker.actor.atk_animation_id2 | |
97 | hit_count(attacker, target) | |
98 | target.target = attacker unless same_team?(attacker, target) | |
99 | end | |
100 | ||
101 | def range_attack(attacker, hand) | |
102 | weapon = attacker.actor.weapons[hand] | |
103 | return if weapon.ammo_list.empty? | |
104 | return if attacker.actor.ammos[weapon.id] == nil | |
105 | ammo = $data_items[attacker.actor.ammos[weapon.id]] | |
106 | return if ammo == nil | |
107 | return unless $game_party.has_item?(ammo) | |
108 | $game_party.consume_item(ammo) | |
109 | attacker.attack_delay = [(60-ammo.speed), 10].max if hand == 0 | |
110 | attacker.attack2_delay = [(60-ammo.speed), 10].max if hand == 1 | |
111 | attacker.animation_delay = 30 | |
112 | $game_projectiles << Game_Projectile.new(attacker, ammo) | |
113 | end | |
114 | ||
115 | def skill_attack(attacker, skill, parent=nil) | |
116 | return if attacker.actor.mp < skill.mp_cost | |
117 | attacker = (parent == nil ? attacker : parent) | |
118 | target = (attacker.heal_target == nil ? select_target(attacker, skill) : attacker.heal_target) | |
119 | if !target.empty? and parent == nil | |
120 | attacker.actor.mp -= attacker.actor.calc_mp_cost(skill) | |
121 | $game_temp.common_event_id = skill.common_event_id if skill.common_event_id > 0 | |
122 | attacker.skill_delay = [(60-skill.speed), 10].max | |
123 | attacker.animation_delay = 30 | |
124 | end | |
125 | for i in target.compact | |
126 | next if guard?(attacker, i) | |
127 | i.actor.skill_effect(attacker.actor, skill) | |
128 | i.animation_id = skill.animation_id | |
129 | hit_count(attacker, i) | |
130 | i.target = attacker.actor.character unless same_team?(attacker, i) | |
131 | end | |
132 | end | |
133 | ||
134 | def cast_skill(attacker, skill) | |
135 | return if attacker.actor.mp < skill.mp_cost | |
136 | attacker.actor.mp -= attacker.actor.calc_mp_cost(skill) | |
137 | $game_temp.common_event_id = skill.common_event_id if skill.common_event_id > 0 | |
138 | attacker.skill_delay = [(60-skill.speed), 10].max | |
139 | attacker.animation_delay = 30 | |
140 | $game_projectiles << Game_Projectile.new(attacker, skill) | |
141 | end | |
142 | ||
143 | def item_attack(attacker, item, parent=nil) | |
144 | attacker = (parent == nil ? attacker : parent) | |
145 | return unless $game_party.has_item?(item) | |
146 | target = (attacker.heal_target == nil ? select_target(attacker, item) : attacker.heal_target) | |
147 | if !target.empty? and parent == nil | |
148 | $game_party.consume_item(item) | |
149 | $game_temp.common_event_id = item.common_event_id if item.common_event_id > 0 | |
150 | attacker.item_delay = [(60-item.speed), 10].max | |
151 | attacker.animation_delay = 30 | |
152 | end | |
153 | for i in target.compact | |
154 | next if guard?(attacker, i) | |
155 | i.actor.item_effect(attacker.actor, item) | |
156 | i.animation_id = item.animation_id | |
157 | hit_count(attacker, i) | |
158 | i.target = attacker.actor.character unless same_team?(attacker, i) | |
159 | end | |
160 | end | |
161 | ||
162 | def cast_item(attacker, item) | |
163 | return unless $game_party.has_item?(item) | |
164 | $game_party.consume_item(item) | |
165 | $game_temp.common_event_id = item.common_event_id if item.common_event_id > 0 | |
166 | attacker.item_delay = [(60-item.speed), 10].max | |
167 | attacker.animation_delay = 30 | |
168 | $game_projectiles << Game_Projectile.new(attacker, item) | |
169 | end | |
170 | ||
171 | def select_target(attacker, object=nil) | |
172 | targets = [] | |
173 | targets << $game_player if $game_player.actor != nil | |
174 | for ally in $game_allies.compact | |
175 | next unless $game_map.in_range?(ally) | |
176 | next if ally.actor.dead? | |
177 | targets << ally | |
178 | end | |
179 | for monster in $game_monsters.compact | |
180 | next unless $game_map.in_range?(monster) | |
181 | next if monster.actor.dead? | |
182 | targets << monster | |
183 | end | |
184 | for event in $game_map.events.values.compact | |
185 | next unless $game_map.in_range?(event) | |
186 | next if event.actor == nil | |
187 | next if event.actor.dead? | |
188 | targets << event | |
189 | end | |
190 | return targets if object == nil | |
191 | case object.scope | |
192 | when 1 | |
193 | selected = [] | |
194 | for target in targets | |
195 | next if same_team?(attacker, target) | |
196 | selected << target if attacker.in_front?(target) | |
197 | end | |
198 | return selected | |
199 | when 2 | |
200 | selected = [] | |
201 | for target in targets | |
202 | next if same_team?(attacker, target) | |
203 | selected << target | |
204 | end | |
205 | return selected | |
206 | when 3 | |
207 | selected = [] | |
208 | for target in targets | |
209 | next if same_team?(attacker, target) | |
210 | selected << target if attacker.in_front?(target) | |
211 | end | |
212 | return selected | |
213 | when 4 | |
214 | selected = [] | |
215 | for target in targets | |
216 | next if same_team?(attacker, target) | |
217 | selected << target if attacker.in_front?(target) | |
218 | end | |
219 | return selected[rand(selected.size)] | |
220 | when 5 | |
221 | selected = [] | |
222 | for target in targets | |
223 | next if same_team?(attacker, target) | |
224 | selected << target if attacker.in_front?(target) | |
225 | end | |
226 | return selected | |
227 | a = selected[rand(selected.size)] | |
228 | b = targets - a | |
229 | c = b[rand(b.size)] | |
230 | return [a, c] | |
231 | when 6 | |
232 | selected = [] | |
233 | for target in targets | |
234 | next if same_team?(attacker, target) | |
235 | selected << target if attacker.in_front?(target) | |
236 | end | |
237 | return selected | |
238 | a = selected[rand(selected.size)] | |
239 | b = targets - a | |
240 | c = b[rand(b.size)] | |
241 | d = b - c | |
242 | e = d[rand(d.size)] | |
243 | return [a, c, e] | |
244 | when 7 | |
245 | selected = [] | |
246 | for target in targets | |
247 | next unless same_team?(attacker, target) | |
248 | selected << target | |
249 | end | |
250 | return [selected[rand(selected.size)]] | |
251 | when 8 | |
252 | selected = [] | |
253 | for target in targets | |
254 | next unless same_team?(attacker, target) | |
255 | selected << target | |
256 | end | |
257 | return selected | |
258 | when 9 | |
259 | selected = [] | |
260 | targets = [] | |
261 | for ally in $game_allies.compact | |
262 | next unless $game_map.in_range?(ally) | |
263 | targets << ally if ally.actor.dead? | |
264 | end | |
265 | for monster in $game_monsters.compact | |
266 | next unless $game_map.in_range?(monster) | |
267 | targets << monster if monster.actor.dead? | |
268 | end | |
269 | for event in $game_map.events.values.compact | |
270 | next unless $game_map.in_range?(event) | |
271 | next if event.is_object? | |
272 | next if event.actor == nil | |
273 | next if event.actor.dead? | |
274 | targets << event if event.actor.dead? | |
275 | end | |
276 | for target in targets | |
277 | next unless same_team?(attacker, target) | |
278 | selected << target | |
279 | end | |
280 | return [selected[rand(selected.size)]] | |
281 | when 10 | |
282 | selected = [] | |
283 | targets = [] | |
284 | for ally in $game_allies.compact | |
285 | next unless $game_map.in_range?(ally) | |
286 | targets << ally if ally.actor.dead? | |
287 | end | |
288 | for monster in $game_monsters.compact | |
289 | next unless $game_map.in_range?(monster) | |
290 | targets << monster if monster.actor.dead? | |
291 | end | |
292 | for event in $game_map.events.values.compact | |
293 | next unless $game_map.in_range?(event) | |
294 | next if event.is_object? | |
295 | next if event.actor == nil | |
296 | next if event.actor.dead? | |
297 | targets << event if event.actor.dead? | |
298 | end | |
299 | for target in targets | |
300 | next unless same_team?(attacker, target) | |
301 | selected << target | |
302 | end | |
303 | return selected | |
304 | when 11 | |
305 | return [attacker] | |
306 | end | |
307 | return [] | |
308 | end | |
309 | ||
310 | def enemy_actions(attacker) | |
311 | return if attacker.actor == nil | |
312 | return if attacker.actor.dead? | |
313 | for action in attacker.actor.enemy.actions | |
314 | next unless attacker.actor.conditions_met?(action) | |
315 | next if rand(11) > action.rating and (!action.kind == 1 and action.rating >= 10) | |
316 | case action.kind | |
317 | when 0 | |
318 | case action.basic | |
319 | when 0 | |
320 | next if blocked_by_state?(attacker, 0) | |
321 | next if attacker.attack_delay > 0 | |
322 | for target in select_target(attacker) | |
323 | next if same_team?(attacker, target) | |
324 | next unless attacker.in_front?(target) | |
325 | attacker.target = target | |
326 | melee_attack(attacker, target) | |
327 | end | |
328 | when 1 | |
329 | attacker.defend_delay = attacker.actor.attack_speed | |
330 | end | |
331 | when 1 | |
332 | next if blocked_by_state?(attacker, 1) | |
333 | skill = $data_skills[action.skill_id] | |
334 | next if attacker.skill_delay > 0 | |
335 | if skill.scope >= 7 | |
336 | targets = [] | |
337 | for monster in $game_monsters.compact | |
338 | next unless $game_map.in_range?(monster) | |
339 | next if monster.actor.dead? | |
340 | targets << monster | |
341 | end | |
342 | for event in $game_map.events.values.compact | |
343 | next unless $game_map.in_range?(event) | |
344 | next if event.erased | |
345 | next if event.actor == nil | |
346 | next if event.is_object? | |
347 | targets << event | |
348 | end | |
349 | for target in targets.compact | |
350 | next unless curable?(target, skill) | |
351 | attacker.heal_target = [target] | |
352 | skill_attack(attacker, skill) | |
353 | end | |
354 | else | |
355 | if skill.ranged? | |
356 | if action.rating >= 10 | |
357 | cast_skill(attacker, skill) | |
358 | else | |
359 | for target in select_target(attacker, skill) | |
360 | next if same_team?(self, target) | |
361 | next unless attacker.in_range?(target, skill.range) | |
362 | next unless attacker.in_direction?(target) | |
363 | attacker.target = target | |
364 | cast_skill(attacker, skill) | |
365 | end | |
366 | end | |
367 | else | |
368 | skill_attack(attacker, skill) | |
369 | end | |
370 | end | |
371 | end | |
372 | end | |
373 | end | |
374 | ||
375 | def make_drop(attacker) | |
376 | Sound.play_enemy_collapse | |
377 | for ally in $game_allies.compact | |
378 | ally.target = nil if ally.target == attacker | |
379 | end | |
380 | droped_items = [] | |
381 | for i in [attacker.actor.drop_item1, attacker.actor.drop_item2] | |
382 | next if i.kind <= 0 | |
383 | next if rand(i.denominator) != 0 | |
384 | case i.kind | |
385 | when 1; droped_items << $data_items[i.item_id] | |
386 | when 2; droped_items << $data_weapons[i.weapon_id] | |
387 | when 3; droped_items << $data_armors[i.armor_id] | |
388 | end | |
389 | end | |
390 | for actors in $game_party.members | |
391 | actors.gain_exp(attacker.actor.exp, true) | |
392 | end | |
393 | if rand(100) < @gold_properties[1] and attacker.actor.gold > 0 | |
394 | $game_items << Game_Item.new(attacker, attacker.actor.gold) | |
395 | end | |
396 | droped_items.compact.each { |i| $game_items << Game_Item.new(attacker, i) } | |
397 | if $game_system.enemies_defeated[attacker.target.actor.id][attacker.actor.enemy_id] == nil | |
398 | $game_system.enemies_defeated[attacker.target.actor.id][attacker.actor.enemy_id] = 1 | |
399 | else | |
400 | $game_system.enemies_defeated[attacker.target.actor.id][attacker.actor.enemy_id] += 1 | |
401 | end | |
402 | $game_variables[@battle_area_variable] += 1 if @battle_area_variable > 0 | |
403 | ||
404 | end | |
405 | ||
406 | def hit_count(attacker, target) | |
407 | return unless @hit["show"] | |
408 | return unless attacker.is_a?(Game_Player) | |
409 | return if target.is_a?(Game_Player) | |
410 | return if target.is_object? | |
411 | @hits_total += 1 | |
412 | @damage_total += target.damage.to_i | |
413 | @hitcount_delay = 60 | |
414 | end | |
415 | ||
416 | def valid_target?(target) | |
417 | return false if target == nil | |
418 | return false if target.actor == nil | |
419 | return false if target.actor.dead? | |
420 | return false if target.in_vehicle? | |
421 | return true if target.is_a?(Game_Player) | |
422 | return true if target.is_a?(Game_Ally) | |
423 | return true if target.is_a?(Game_Monster) | |
424 | return true if target.is_a?(Game_Event) and target.actor != nil | |
425 | return false | |
426 | end | |
427 | ||
428 | def guard?(attacker, target) | |
429 | return false if target == nil | |
430 | return false unless target.defending | |
431 | return false unless attacker.face_to_face?(target) | |
432 | if target.actor.is_a?(Game_Actor) | |
433 | return false unless target.actor.armors[0].is_a?(RPG::Armor) | |
434 | rate = target.actor.armors[0].guard_rate.to_i | |
435 | elsif target.actor.is_a?(Game_Enemy) | |
436 | rate = target.actor.guard_rate.to_i | |
437 | end | |
438 | if rand(101) <= rate | |
439 | target.damage = "Guard" | |
440 | return true | |
441 | end | |
442 | return false | |
443 | end | |
444 | ||
445 | def same_team?(attacker, target) | |
446 | if attacker.is_a?(Game_Ally) or attacker.is_a?(Game_Player) | |
447 | return true if target.is_a?(Game_Ally) or target.is_a?(Game_Player) | |
448 | end | |
449 | if attacker.is_a?(Game_Monster) or (attacker.is_a?(Game_Event) and attacker.actor != nil) | |
450 | return true if target.is_a?(Game_Monster) or (target.is_a?(Game_Event) and target.actor != nil) | |
451 | end | |
452 | if attacker.is_a?(Game_Projectile) | |
453 | if (attacker.parent.is_a?(Game_Ally) or attacker.parent.is_a?(Game_Player)) and | |
454 | (target.is_a?(Game_Ally) or target.is_a?(Game_Player)) | |
455 | return true | |
456 | end | |
457 | if (attacker.parent.is_a?(Game_Monster) or (attacker.is_a?(Game_Event) and attacker.actor != nil)) and | |
458 | (target.is_a?(Game_Monster) or (target.is_a?(Game_Event) and target.actor != nil)) | |
459 | return true | |
460 | end | |
461 | end | |
462 | return false | |
463 | end | |
464 | ||
465 | def curable?(target, object) | |
466 | return false if object.scope < 7 | |
467 | for state in target.actor.states.compact | |
468 | return true if object.minus_state_set.include?(state.id) | |
469 | end | |
470 | return false if target.actor.dead? | |
471 | if (target.actor.hp < (target.actor.maxhp*25/100)) and | |
472 | ((object.is_a?(RPG::Skill) and object.base_damage < 0) or | |
473 | (object.is_a?(RPG::Item) and (object.hp_recovery_rate > 0 or object.hp_recovery > 0))) | |
474 | return true | |
475 | end | |
476 | if (object.is_a?(RPG::Item) and target.actor.mp < (target.actor.maxmp*25/100)) and | |
477 | (object.mp_recovery_rate > 0 or object.mp_recovery > 0) | |
478 | return true | |
479 | end | |
480 | return false | |
481 | end | |
482 | ||
483 | def blocked_by_state?(attacker, kind) | |
484 | return if attacker.actor == nil | |
485 | for state in attacker.actor.states.compact | |
486 | return true if kind == 0 and state.restriction == 4 | |
487 | return true if kind == 1 and state.restriction == 1 | |
488 | return true if kind == 2 and state.restriction == 5 | |
489 | end | |
490 | return false | |
491 | end | |
492 | ||
493 | end | |
494 | ||
495 | #------------------------------------------------------------------------------ | |
496 | module RPG | |
497 | ||
498 | class State | |
499 | ||
500 | def animation_id | |
501 | self.note.read("Animation") | |
502 | end | |
503 | ||
504 | end | |
505 | ||
506 | class BaseItem | |
507 | ||
508 | def ranged? | |
509 | self.note.load("Ranged") | |
510 | end | |
511 | ||
512 | def character | |
513 | self.note.read("Character") | |
514 | end | |
515 | ||
516 | def index | |
517 | self.note.read("Index") | |
518 | end | |
519 | ||
520 | def move_speed | |
521 | self.note.read("Speed", 6) | |
522 | end | |
523 | ||
524 | def range | |
525 | self.note.read("Range", 5) | |
526 | end | |
527 | ||
528 | def guard_rate | |
529 | self.note.read("Guard Rate", 50) | |
530 | end | |
531 | ||
532 | def ammo? | |
533 | self.note.load("Ammo") | |
534 | end | |
535 | ||
536 | def ammo_list | |
537 | ammos = self.note.read("Ammos") | |
538 | return [] if ammos == nil | |
539 | list = [] | |
540 | for i in ammos.split(",") | |
541 | list << i.to_i | |
542 | end | |
543 | return list | |
544 | end | |
545 | ||
546 | end | |
547 | ||
548 | end | |
549 | ||
550 | #------------------------------------------------------------------------------ | |
551 | class Object | |
552 | ||
553 | def load(param) | |
554 | self.each_line { |i| return true if i =~ /#{param}/i } | |
555 | return false | |
556 | end | |
557 | ||
558 | def read(param, onfail=nil) | |
559 | self.each_line { |i| return i.gsub("#{param} = ", "").chomp if i =~ /#{param} = /i } | |
560 | return onfail | |
561 | end | |
562 | ||
563 | end | |
564 | ||
565 | #------------------------------------------------------------------------------ | |
566 | class Bitmap | |
567 | ||
568 | def draw_outlined_text(*args) | |
569 | if args[0].is_a?(Rect) | |
570 | x = args[0].x | |
571 | y = args[0].y | |
572 | w = args[0].width | |
573 | h = args[0].height | |
574 | s = args[1] | |
575 | a = (args[2].nil? ? 0 : args[2]) | |
576 | else | |
577 | x = args[0] | |
578 | y = args[1] | |
579 | w = args[2] | |
580 | h = args[3] | |
581 | s = args[4] | |
582 | a = (args[5].nil? ? 0 : args[5]) | |
583 | end | |
584 | color = font.color.clone | |
585 | font.shadow = false | |
586 | font.color = Color.new(0,0,0) | |
587 | draw_text(x-1, y-1, w, h, s, a) | |
588 | draw_text(x+1, y-1, w, h, s, a) | |
589 | draw_text(x-1, y+1, w, h, s, a) | |
590 | draw_text(x+1, y+1, w, h, s, a) | |
591 | font.color = color.clone | |
592 | draw_text(x, y, w, h, s, a) | |
593 | end | |
594 | ||
595 | end | |
596 | ||
597 | #------------------------------------------------------------------------------ | |
598 | class Game_System | |
599 | ||
600 | attr_accessor :enemies_defeated | |
601 | ||
602 | alias vtp_gsystem_initialize initialize | |
603 | ||
604 | def initialize | |
605 | vtp_gsystem_initialize | |
606 | @enemies_defeated = {} | |
607 | end | |
608 | ||
609 | end | |
610 | ||
611 | #------------------------------------------------------------------------------ | |
612 | class Game_Battler | |
613 | ||
614 | attr_accessor :character | |
615 | ||
616 | alias vtp_gbattler_execute_damage execute_damage | |
617 | ||
618 | def attack_effect(attacker) | |
619 | clear_action_results | |
620 | return if @character.unkileable? | |
621 | if @character.is_object? | |
622 | self.hp -= self.maxhp | |
623 | return | |
624 | end | |
625 | unless attack_effective?(attacker) | |
626 | @character.damage = $VTP.damage["texts"][0] | |
627 | @skipped = true | |
628 | return | |
629 | end | |
630 | if rand(100) >= calc_hit(attacker) | |
631 | @character.damage = $VTP.damage["texts"][0] | |
632 | @missed = true | |
633 | return | |
634 | end | |
635 | if rand(100) < calc_eva(attacker) | |
636 | @character.damage = $VTP.damage["texts"][0] | |
637 | @evaded = true | |
638 | return | |
639 | end | |
640 | make_attack_damage_value(attacker) | |
641 | execute_damage(attacker) | |
642 | if @hp_damage == 0 | |
643 | @character.damage = $VTP.damage["texts"][0] | |
644 | return | |
645 | end | |
646 | apply_state_changes(attacker) | |
647 | end | |
648 | ||
649 | def skill_effect(user, skill) | |
650 | clear_action_results | |
651 | return if @character.unkileable? | |
652 | if @character.is_object? | |
653 | self.hp -= self.maxhp | |
654 | return | |
655 | end | |
656 | unless skill_effective?(user, skill) | |
657 | @character.damage = $VTP.damage["texts"][0] | |
658 | @skipped = true | |
659 | return | |
660 | end | |
661 | if rand(100) >= calc_hit(user, skill) | |
662 | @character.damage = $VTP.damage["texts"][0] | |
663 | @missed = true | |
664 | return | |
665 | end | |
666 | if rand(100) < calc_eva(user, skill) | |
667 | @character.damage = $VTP.damage["texts"][0] | |
668 | @evaded = true | |
669 | return | |
670 | end | |
671 | make_obj_damage_value(user, skill) | |
672 | make_obj_absorb_effect(user, skill) | |
673 | execute_damage(user) | |
674 | if skill.physical_attack and @hp_damage == 0 | |
675 | return | |
676 | end | |
677 | apply_state_changes(skill) | |
678 | end | |
679 | ||
680 | def item_effect(user, item) | |
681 | clear_action_results | |
682 | return if @character.unkileable? | |
683 | if @character.is_object? | |
684 | self.hp -= self.maxhp | |
685 | return | |
686 | end | |
687 | unless item_effective?(user, item) | |
688 | @character.damage = $VTP.damage["texts"][0] | |
689 | @skipped = true | |
690 | return | |
691 | end | |
692 | if rand(100) >= calc_hit(user, item) | |
693 | @character.damage = $VTP.damage["texts"][0] | |
694 | @missed = true | |
695 | return | |
696 | end | |
697 | if rand(100) < calc_eva(user, item) | |
698 | @character.damage = $VTP.damage["texts"][0] | |
699 | @evaded = true | |
700 | return | |
701 | end | |
702 | hp_recovery = calc_hp_recovery(user, item) | |
703 | mp_recovery = calc_mp_recovery(user, item) | |
704 | make_obj_damage_value(user, item) | |
705 | @hp_damage -= hp_recovery | |
706 | @mp_damage -= mp_recovery | |
707 | make_obj_absorb_effect(user, item) | |
708 | execute_damage(user) | |
709 | item_growth_effect(user, item) | |
710 | if item.physical_attack and @hp_damage == 0 | |
711 | return | |
712 | end | |
713 | apply_state_changes(item) | |
714 | end | |
715 | ||
716 | def execute_damage(user) | |
717 | vtp_gbattler_execute_damage(user) | |
718 | @character.damage = @hp_damage | |
719 | @character.critical = @critical | |
720 | end | |
721 | ||
722 | def remove_state(state_id) | |
723 | return unless state?(state_id) | |
724 | @states.delete(state_id) | |
725 | @state_turns.delete(state_id) | |
726 | end | |
727 | ||
728 | end | |
729 | #------------------------------------------------------------------------------ | |
730 | class Game_Party < Game_Unit | |
731 | ||
732 | attr_accessor :reward | |
733 | ||
734 | alias vtp_gparty_setup_starting_members setup_starting_members | |
735 | alias vtp_gparty_add_actor add_actor | |
736 | alias vtp_gparty_remove_actor remove_actor | |
737 | alias vtp_gparty_gain_item gain_item | |
738 | alias vtp_gparty_gain_gold gain_gold | |
739 | ||
740 | def setup_starting_members | |
741 | vtp_gparty_setup_starting_members | |
742 | for i in 1...@actors.size | |
743 | next if @actors[i] == nil | |
744 | $game_allies[i] = Game_Ally.new(i) | |
745 | end | |
746 | for i in members | |
747 | $game_system.enemies_defeated[i.id] = {} | |
748 | end | |
749 | end | |
750 | ||
751 | def add_actor(actor_id) | |
752 | vtp_gparty_add_actor(actor_id) | |
753 | id = @actors.size-1 | |
754 | if @actors.size > 1 | |
755 | $game_allies[id] = Game_Ally.new(id) | |
756 | $game_allies[id].moveto($game_player.x, $game_player.y) | |
757 | $game_allies[id].move_random | |
758 | $game_player.refresh | |
759 | $scene.refresh_allies_sprites if $scene.is_a?(Scene_Map) | |
760 | end | |
761 | if $game_system.enemies_defeated[actor_id] == nil | |
762 | $game_system.enemies_defeated[actor_id] = {} | |
763 | end | |
764 | end | |
765 | ||
766 | def remove_actor(actor_id) | |
767 | vtp_gparty_remove_actor(actor_id) | |
768 | for ally in $game_allies.compact | |
769 | next if ally.actor.id != actor_id | |
770 | $game_allies.delete(ally) | |
771 | $game_player.refresh | |
772 | $scene.refresh_allies_sprites if $scene.is_a?(Scene_Map) | |
773 | end | |
774 | end | |
775 | ||
776 | def gain_item(item, n, include_equip = false) | |
777 | vtp_gparty_gain_item(item, n, include_equip) | |
778 | @reward = item.name if n > 0 and item != nil and $scene.is_a?(Scene_Map) | |
779 | end | |
780 | ||
781 | def gain_gold(n) | |
782 | vtp_gparty_gain_gold(n) | |
783 | @reward = "#{Vocab.gold} #{n}" if n > 0 and $scene.is_a?(Scene_Map) | |
784 | end | |
785 | ||
786 | def change_group_order | |
787 | availables = [] | |
788 | unavailables = [] | |
789 | for actor in members | |
790 | if actor.dead? | |
791 | unavailables << actor | |
792 | else | |
793 | availables << actor | |
794 | end | |
795 | end | |
796 | return if availables.empty? | |
797 | availables.reverse! | |
798 | @actors.clear | |
799 | for i in availables | |
800 | add_actor(i.id) | |
801 | end | |
802 | for i in unavailables | |
803 | add_actor(i.id) | |
804 | end | |
805 | $game_player.refresh | |
806 | $game_allies.compact.each { |i| i.refresh } | |
807 | end | |
808 | ||
809 | end | |
810 | ||
811 | #------------------------------------------------------------------------------ | |
812 | class Game_Actor < Game_Battler | |
813 | ||
814 | attr_accessor :ammos | |
815 | attr_accessor :skill_hotkeys | |
816 | attr_accessor :item_hotkeys | |
817 | ||
818 | alias vtp_gactor_setup setup | |
819 | alias vtp_gactor_forget_skill forget_skill | |
820 | ||
821 | def setup(actor_id) | |
822 | vtp_gactor_setup(actor_id) | |
823 | @ammos = {} | |
824 | @skill_hotkeys = {} | |
825 | @item_hotkeys = {} | |
826 | end | |
827 | ||
828 | def forget_skill(skill_id) | |
829 | vtp_gactor_forget_skill(skill_id) | |
830 | @skill_hotkeys.delete(@skill_hotkeys.index(skill_id)) | |
831 | end | |
832 | ||
833 | def atk_animation_id | |
834 | return (weapons[0] == nil ? 1 : weapons[0].animation_id) | |
835 | end | |
836 | ||
837 | def atk_animation_id2 | |
838 | return (weapons[1] == nil ? 1 : weapons[1].animation_id) | |
839 | end | |
840 | ||
841 | def display_level_up(new_skills) | |
842 | return if dead? | |
843 | @character.animation_id = 40 | |
844 | @damage = "Level Up" | |
845 | end | |
846 | ||
847 | def current_exp | |
848 | return (@exp - @exp_list[@level]) | |
849 | end | |
850 | ||
851 | def next_exp | |
852 | return (@exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0) | |
853 | end | |
854 | ||
855 | def attack_speed | |
856 | return 30 | |
857 | end | |
858 | ||
859 | end | |
860 | ||
861 | #------------------------------------------------------------------------------ | |
862 | class Game_Enemy < Game_Battler | |
863 | ||
864 | attr_accessor :level | |
865 | ||
866 | alias vtp_genemy_initialize initialize | |
867 | ||
868 | def initialize(index, enemy_id) | |
869 | vtp_genemy_initialize(index, enemy_id) | |
870 | @level = 1 | |
871 | end | |
872 | =begin | |
873 | def base_maxhp | |
874 | return enemy.maxhp * ([@level, 1].max * 1.25) | |
875 | end | |
876 | ||
877 | def base_maxmp | |
878 | return enemy.maxmp * ([@level, 1].max * 1.25) | |
879 | end | |
880 | ||
881 | def base_atk | |
882 | return enemy.atk * ([@level, 1].max * 1.25) | |
883 | end | |
884 | ||
885 | def base_def | |
886 | return enemy.def * ([@level, 1].max * 1.25) | |
887 | end | |
888 | ||
889 | def base_spi | |
890 | return enemy.spi * ([@level, 1].max * 1.25) | |
891 | end | |
892 | ||
893 | def base_agi | |
894 | return enemy.agi * ([@level, 1].max * 1.25) | |
895 | end | |
896 | =end | |
897 | def name | |
898 | return (@level > 1 ? "#{enemy.name} #{Vocab.level_a}#{@level}" : enemy.name) | |
899 | end | |
900 | ||
901 | def character_name | |
902 | enemy.note.read("Character") | |
903 | end | |
904 | ||
905 | def character_index | |
906 | enemy.note.read("Index") | |
907 | end | |
908 | ||
909 | def respawn | |
910 | enemy.note.read("Respawn") | |
911 | end | |
912 | ||
913 | def move_speed | |
914 | enemy.note.read("Move Speed", 3) | |
915 | end | |
916 | ||
917 | def atk_animation_id | |
918 | enemy.note.read("Attack Animation", 1) | |
919 | end | |
920 | ||
921 | def aggressiveness | |
922 | enemy.note.read("Aggressiveness", 3) | |
923 | end | |
924 | ||
925 | def weapon_icon | |
926 | enemy.note.read("Weapon Icon") | |
927 | end | |
928 | ||
929 | def shield_icon | |
930 | enemy.note.read("Shield Icon") | |
931 | end | |
932 | ||
933 | def guard_rate | |
934 | enemy.note.read("Guard Rate", 50) | |
935 | end | |
936 | ||
937 | def attack_speed | |
938 | return 60 | |
939 | end | |
940 | ||
941 | def on_enemy_walk | |
942 | if slip_damage? | |
943 | enemy.hp -= 1 if enemy.hp > 1 | |
944 | end | |
945 | end | |
946 | ||
947 | end | |
948 | ||
949 | #------------------------------------------------------------------------------ | |
950 | class Game_Map | |
951 | ||
952 | alias vtp_hmap_passable passable? | |
953 | alias vtp_gmap_setup_events setup_events | |
954 | ||
955 | def passable?(x, y, flag = 0x01) | |
956 | for monster in $game_monsters.compact | |
957 | next if monster.actor.dead? | |
958 | return false if x == monster.x and y == monster.y | |
959 | end | |
960 | vtp_hmap_passable(x, y, flag) | |
961 | end | |
962 | ||
963 | def passable2?(x, y, flag = 0x01) | |
964 | for ally in $game_allies.compact | |
965 | next if ally.actor.dead? | |
966 | next if ally.in_vehicle? | |
967 | return false if x == ally.x and y == ally.y | |
968 | end | |
969 | return passable?(x, y) | |
970 | end | |
971 | ||
972 | def range_passable?(x, y) | |
973 | return true if @passages[@map.data[x, y, 0]] == 9 | |
974 | return passable?(x, y) | |
975 | end | |
976 | ||
977 | def setup_events | |
978 | vtp_gmap_setup_events | |
979 | $game_monsters.clear | |
980 | for area in $data_areas.values | |
981 | next if area.map_id != @map_id | |
982 | for i in area.encounter_list | |
983 | read_level = $data_troops[i].name[/Lv\d+/i] | |
984 | level = (read_level == nil ? 1 : read_level[/\d+/].to_i) | |
985 | for m in $data_troops[i].members | |
986 | $game_monsters << Game_Monster.new(m.enemy_id, m.id, level, area) | |
987 | end | |
988 | end | |
989 | end | |
990 | for i in encounter_list | |
991 | read_level = $data_troops[i].name[/Lv\d+/i] | |
992 | level = (read_level == nil ? 1 : read_level[/\d+/].to_i) | |
993 | for m in $data_troops[i].members | |
994 | $game_monsters << Game_Monster.new(m.enemy_id, m.id, level, nil) | |
995 | end | |
996 | end | |
997 | end | |
998 | ||
999 | end | |
1000 | ||
1001 | #------------------------------------------------------------------------------ | |
1002 | class Game_Character | |
1003 | ||
1004 | attr_accessor :damage | |
1005 | attr_accessor :critical | |
1006 | attr_accessor :actor | |
1007 | attr_accessor :attack_delay | |
1008 | attr_accessor :attack2_delay | |
1009 | attr_accessor :skill_delay | |
1010 | attr_accessor :item_delay | |
1011 | attr_accessor :animation_delay | |
1012 | attr_accessor :balloon_delay | |
1013 | attr_accessor :right_attack | |
1014 | attr_accessor :left_attack | |
1015 | attr_accessor :defending | |
1016 | attr_accessor :target | |
1017 | attr_accessor :heal_target | |
1018 | ||
1019 | alias vtp_gcharacter_initialize initialize | |
1020 | alias vtp_gcharacter_update update | |
1021 | ||
1022 | def initialize | |
1023 | vtp_gcharacter_initialize | |
1024 | @attack_delay = 0 | |
1025 | @attack2_delay = 0 | |
1026 | @skill_delay = 0 | |
1027 | @item_delay = 0 | |
1028 | @defend_delay = 0 | |
1029 | @animation_delay = 0 | |
1030 | @state_delay = 0 | |
1031 | @balloon_delay = 0 | |
1032 | end | |
1033 | ||
1034 | def update | |
1035 | vtp_gcharacter_update | |
1036 | update_delay | |
1037 | update_actions | |
1038 | update_states | |
1039 | update_attack_movement if @animation_delay > 0 | |
1040 | end | |
1041 | ||
1042 | def update_delay | |
1043 | @attack_delay -= 1 if @attack_delay > 0 | |
1044 | @attack2_delay -= 1 if @attack2_delay > 0 | |
1045 | @skill_delay -= 1 if @skill_delay > 0 | |
1046 | @item_delay -= 1 if @item_delay > 0 | |
1047 | @defend_delay -= 1 if @defend_delay > 0 | |
1048 | @animation_delay -= 1 if @animation_delay > 0 | |
1049 | @balloon_delay -= 1 if @balloon_delay > 0 | |
1050 | end | |
1051 | ||
1052 | def update_attack_movement | |
1053 | return if is_object? | |
1054 | if @animation_delay >= 20 | |
1055 | @pattern = 0 | |
1056 | elsif @animation_delay.between?(10, 20) | |
1057 | @pattern = 1 | |
1058 | elsif @animation_delay.between?(1, 10) | |
1059 | @pattern = 2 | |
1060 | elsif @animation_delay.between?(0, 1) | |
1061 | @pattern = 1 | |
1062 | end | |
1063 | end | |
1064 | ||
1065 | def update_states | |
1066 | return if @actor == nil | |
1067 | return if @actor.dead? | |
1068 | return if is_object? | |
1069 | for state in @actor.states.compact | |
1070 | if @state_delay <= (state.hold_turn*Graphics.frame_rate) | |
1071 | @state_delay += 1 | |
1072 | elsif @state_delay > (state.hold_turn*Graphics.frame_rate) | |
1073 | if rand(101) <= state.auto_release_prob | |
1074 | @actor.remove_state(state.id) | |
1075 | end | |
1076 | @state_delay = 0 | |
1077 | end | |
1078 | end | |
1079 | end | |
1080 | ||
1081 | def step_back | |
1082 | old_speed = @move_speed | |
1083 | @move_speed = 6 | |
1084 | move_backward | |
1085 | move_backward | |
1086 | @move_speed = old_speed | |
1087 | end | |
1088 | ||
1089 | def update_actions | |
1090 | end | |
1091 | ||
1092 | def check_event_trigger_touch(x, y) | |
1093 | end | |
1094 | ||
1095 | def in_vehicle? | |
1096 | return false | |
1097 | end | |
1098 | ||
1099 | def is_object? | |
1100 | return false | |
1101 | end | |
1102 | ||
1103 | def unkileable? | |
1104 | return false | |
1105 | end | |
1106 | ||
1107 | end | |
1108 | ||
1109 | #------------------------------------------------------------------------------ | |
1110 | class Game_Event < Game_Character | |
1111 | ||
1112 | alias vtp_gevent_refresh refresh | |
1113 | alias vtp_gevent_update update | |
1114 | ||
1115 | def refresh | |
1116 | vtp_gevent_refresh | |
1117 | setup_enemy | |
1118 | end | |
1119 | ||
1120 | def update | |
1121 | vtp_gevent_update | |
1122 | update_enemy | |
1123 | end | |
1124 | ||
1125 | def setup_enemy | |
1126 | return if @erased | |
1127 | @enemy_id = check_comment("Enemy").to_i | |
1128 | return if @enemy_id <= 0 | |
1129 | @actor = Game_Enemy.new(0, @enemy_id) | |
1130 | @actor.character = self | |
1131 | @respawn_delay = @actor.respawn.to_i | |
1132 | @die_switch = check_comment("Die Switch").to_i | |
1133 | @die_selfswitch = check_comment("Die Self Switch").to_s.upcase | |
1134 | @die_variable = check_comment("Die Variable").to_i | |
1135 | @actor.recover_all | |
1136 | @opacity = 255 | |
1137 | @dead = false | |
1138 | @death_triggerd = false | |
1139 | end | |
1140 | ||
1141 | def update_enemy | |
1142 | return if @actor == nil | |
1143 | if !@actor.dead? | |
1144 | update_target_selection | |
1145 | elsif @actor.dead? | |
1146 | update_death unless @dead | |
1147 | @opacity -= 10 if @opacity > 0 and !@death_triggerd | |
1148 | end | |
1149 | if @dead and @respawn_delay.to_i > 0 | |
1150 | if @respawn_delay <= 1 | |
1151 | @erased = false | |
1152 | refresh | |
1153 | else | |
1154 | @respawn_delay -= 1 | |
1155 | end | |
1156 | end | |
1157 | end | |
1158 | ||
1159 | def update_target_selection | |
1160 | return if is_object? | |
1161 | return if @target != nil | |
1162 | for target in $VTP.select_target(self) | |
1163 | next if $VTP.same_team?(self, target) | |
1164 | next unless in_range?(target, 5) | |
1165 | @target = target | |
1166 | end | |
1167 | end | |
1168 | ||
1169 | def update_actions | |
1170 | return if $game_map.interpreter.running? | |
1171 | return if @target != nil and @target.in_vehicle? | |
1172 | $VTP.enemy_actions(self) | |
1173 | @heal_target = nil | |
1174 | @defending = (@defend_delay > 0) | |
1175 | end | |
1176 | ||
1177 | def update_death | |
1178 | if is_object? | |
1179 | update_triggers | |
1180 | @dead = true | |
1181 | return | |
1182 | end | |
1183 | $VTP.make_drop(self) | |
1184 | update_triggers | |
1185 | @dead = true | |
1186 | end | |
1187 | ||
1188 | def update_triggers | |
1189 | if @die_switch > 0 | |
1190 | $game_switches[@die_switch] = !$game_switches[@die_switch] | |
1191 | elsif @die_selfswitch != "" | |
1192 | key = [$game_map.map_id, @id, @die_selfswitch] | |
1193 | $game_self_switches[key] = !$game_self_switches[key] | |
1194 | elsif @die_variable > 0 | |
1195 | $game_variables[@die_variable] += 1 | |
1196 | else | |
1197 | erase | |
1198 | end | |
1199 | if @die_switch > 0 or @die_selfswitch != "" or @die_variable > 0 | |
1200 | @death_triggerd = true | |
1201 | $game_map.need_refresh = true | |
1202 | end | |
1203 | end | |
1204 | ||
1205 | def update_self_movement | |
1206 | return if @actor != nil and @actor.dead? | |
1207 | return if @attack_delay > 0 or @skill_delay > 0 | |
1208 | return if $VTP.blocked_by_state?(self, 2) | |
1209 | if follow_target? and @stop_count > 30 * (5 - @move_frequency) | |
1210 | move_toward(@target) | |
1211 | else | |
1212 | super | |
1213 | end | |
1214 | end | |
1215 | ||
1216 | def increase_steps | |
1217 | super | |
1218 | return if @actor == nil | |
1219 | return if @actor.dead? | |
1220 | @actor.on_enemy_walk | |
1221 | end | |
1222 | ||
1223 | def follow_target? | |
1224 | return false if is_object? | |
1225 | return false if @actor == nil | |
1226 | return false if @actor.dead? | |
1227 | return false if @target == nil | |
1228 | return true if in_range?(@target, 5) | |
1229 | return false | |
1230 | end | |
1231 | ||
1232 | def is_object? | |
1233 | return comment_exists?("Object") | |
1234 | end | |
1235 | ||
1236 | def unkileable? | |
1237 | return comment_exists?("Unkileable") | |
1238 | end | |
1239 | ||
1240 | def map_passable?(x, y) | |
1241 | return $game_map.passable2?(x, y) | |
1242 | end | |
1243 | ||
1244 | end | |
1245 | ||
1246 | #------------------------------------------------------------------------------ | |
1247 | class Game_Player < Game_Character | |
1248 | ||
1249 | attr_reader :selecting_skill | |
1250 | attr_reader :selecting_item | |
1251 | attr_reader :selecting_action | |
1252 | attr_reader :ally_action | |
1253 | ||
1254 | alias vtp_gplayer_refresh refresh | |
1255 | alias vtp_gplayer_update update | |
1256 | alias vtp_gplayer_move_by_input move_by_input | |
1257 | alias vtp_gplayer_perform_transfer perform_transfer | |
1258 | ||
1259 | def refresh | |
1260 | vtp_gplayer_refresh | |
1261 | @actor = $game_party.members[0] | |
1262 | @actor.character = self if @actor != nil | |
1263 | end | |
1264 | ||
1265 | def update | |
1266 | vtp_gplayer_update | |
1267 | return if @actor == nil | |
1268 | if $game_party.all_dead? | |
1269 | $game_temp.next_scene = "gameover" | |
1270 | elsif @actor.dead? | |
1271 | $game_party.change_group_order | |
1272 | end | |
1273 | end | |
1274 | ||
1275 | def update_actions | |
1276 | return if @actor == nil | |
1277 | return if in_vehicle? | |
1278 | return if $game_map.interpreter.running? | |
1279 | update_right_hand | |
1280 | update_left_hand | |
1281 | update_skills_items_usage | |
1282 | update_allies_actions | |
1283 | end | |
1284 | ||
1285 | def update_right_hand | |
1286 | if Input.trigger?($VTP.attack_key) | |
1287 | return if $VTP.blocked_by_state?(self, 0) | |
1288 | return if @defending | |
1289 | return if @attack_delay > 0 | |
1290 | @right_attack = true | |
1291 | if @actor.weapons[0] != nil and @actor.weapons[0].ranged? | |
1292 | $VTP.range_attack(self, 0) | |
1293 | else | |
1294 | @target = nil | |
1295 | for target in $VTP.select_target(self) | |
1296 | next if $VTP.same_team?(self, target) | |
1297 | next unless self.in_front?(target) | |
1298 | @target = target | |
1299 | end | |
1300 | $VTP.melee_attack(self, @target) | |
1301 | end | |
1302 | end | |
1303 | if @right_attack and @attack_delay <= 0 | |
1304 | @right_attack = false | |
1305 | @target = nil | |
1306 | end | |
1307 | end | |
1308 | ||
1309 | def update_left_hand | |
1310 | if @actor.two_swords_style | |
1311 | if Input.trigger?($VTP.defend_key) | |
1312 | return if $VTP.blocked_by_state?(self, 0) | |
1313 | return if @attack2_delay > 0 | |
1314 | @left_attack = true | |
1315 | if @actor.weapons[1] != nil and @actor.weapons[1].ranged? | |
1316 | $VTP.range_attack(self, 1) | |
1317 | else | |
1318 | @target = nil | |
1319 | for target in $VTP.select_target(self) | |
1320 | next if $VTP.same_team?(self, target) | |
1321 | next unless self.in_front?(target) | |
1322 | @target = target | |
1323 | end | |
1324 | $VTP.melee_attack2(self, @target) | |
1325 | end | |
1326 | end | |
1327 | else | |
1328 | if Input.press?($VTP.defend_key) | |
1329 | return if @actor.two_swords_style | |
1330 | return unless @actor.armors[0].is_a?(RPG::Armor) | |
1331 | @defending = true | |
1332 | else | |
1333 | @defending = false | |
1334 | end | |
1335 | end | |
1336 | if @left_attack and @attack2_delay <= 0 | |
1337 | @left_attack = false | |
1338 | @target = nil | |
1339 | end | |
1340 | end | |
1341 | ||
1342 | def update_skills_items_usage | |
1343 | @selecting_skill = Input.press?($VTP.skills_key) | |
1344 | @selecting_item = Input.press?($VTP.items_key) | |
1345 | if @selecting_skill | |
1346 | return if @selecting_item | |
1347 | return if @skill_delay > 0 | |
1348 | @actor.skill_hotkeys.each { |k, v| | |
1349 | next unless Input.trigger?(k) | |
1350 | next if $VTP.blocked_by_state?(self, 1) | |
1351 | if $data_skills[v].ranged? | |
1352 | $VTP.cast_skill(self, $data_skills[v]) | |
1353 | else | |
1354 | $VTP.skill_attack(self, $data_skills[v]) | |
1355 | end | |
1356 | } | |
1357 | end | |
1358 | if @selecting_item | |
1359 | return if @selecting_skill | |
1360 | return if @item_delay > 0 | |
1361 | @actor.item_hotkeys.each { |k, v| | |
1362 | next unless Input.trigger?(k) | |
1363 | if $data_items[v].ranged? | |
1364 | $VTP.cast_item(self, $data_items[v]) | |
1365 | else | |
1366 | $VTP.item_attack(self, $data_items[v]) | |
1367 | end | |
1368 | } | |
1369 | end | |
1370 | end | |
1371 | ||
1372 | def update_allies_actions | |
1373 | return if $game_party.members.size < 2 | |
1374 | @selecting_action = Input.press?($VTP.allies_key) | |
1375 | if !@selecting_action | |
1376 | @ally_action = nil | |
1377 | @old_action = nil | |
1378 | end | |
1379 | return unless @selecting_action | |
1380 | @action_delay -= 1 if @action_delay != nil and @action_delay > 0 | |
1381 | if Input.trigger?(Input::DOWN) | |
1382 | Sound.play_decision | |
1383 | $game_party.change_group_order | |
1384 | @action_delay = 5 | |
1385 | end | |
1386 | if @ally_action == nil | |
1387 | if Input.trigger?(8) | |
1388 | Sound.play_decision | |
1389 | @ally_action = $game_allies[1] | |
1390 | @action_delay = 5 | |
1391 | elsif Input.trigger?(4) | |
1392 | return if $game_party.members.size < 3 | |
1393 | Sound.play_decision | |
1394 | @ally_action = $game_allies[2] | |
1395 | @old_action = @ally_action.action | |
1396 | @action_delay = 5 | |
1397 | elsif Input.trigger?(6) | |
1398 | return if $game_party.members.size < 4 | |
1399 | Sound.play_decision | |
1400 | @ally_action = $game_allies[3] | |
1401 | @old_action = @ally_action.action | |
1402 | @action_delay = 5 | |
1403 | end | |
1404 | elsif @ally_action != nil and @action_delay <= 0 | |
1405 | if Input.trigger?(8) | |
1406 | Sound.play_equip | |
1407 | @ally_action.action = 0 | |
1408 | elsif Input.trigger?(4) | |
1409 | Sound.play_equip | |
1410 | @ally_action.action = 2 | |
1411 | elsif Input.trigger?(6) | |
1412 | Sound.play_equip | |
1413 | @ally_action.action = 1 | |
1414 | elsif Input.trigger?(2) | |
1415 | Sound.play_equip | |
1416 | @ally_action.action = 3 | |
1417 | end | |
1418 | end | |
1419 | end | |
1420 | ||
1421 | def move_by_input | |
1422 | return if $VTP.blocked_by_state?(self, 2) | |
1423 | return if @right_attack and @actor.weapons[0] != nil | |
1424 | return if @left_attack and @actor.weapons[1] != nil | |
1425 | return if @selecting_skill or @selecting_item or @selecting_action | |
1426 | vtp_gplayer_move_by_input | |
1427 | end | |
1428 | ||
1429 | def perform_transfer | |
1430 | vtp_gplayer_perform_transfer | |
1431 | for ally in $game_allies.compact | |
1432 | ally.target = nil | |
1433 | ally.moveto(@new_x, @new_y) | |
1434 | ally.move_random | |
1435 | end | |
1436 | $game_items.clear | |
1437 | if $game_variables[$VTP.battle_area_variable] > 0 | |
1438 | $game_variables[$VTP.battle_area_variable] = 0 | |
1439 | end | |
1440 | end | |
1441 | ||
1442 | end | |
1443 | ||
1444 | #------------------------------------------------------------------------------ | |
1445 | class Game_Ally < Game_Character | |
1446 | ||
1447 | attr_accessor :action | |
1448 | ||
1449 | def initialize(actor_id) | |
1450 | super() | |
1451 | @actor_id = actor_id | |
1452 | @action = 0 | |
1453 | @in_vehicle = false | |
1454 | @protect = false | |
1455 | refresh | |
1456 | end | |
1457 | ||
1458 | def refresh | |
1459 | @actor = $game_party.members[@actor_id] | |
1460 | @actor.character = self | |
1461 | if @actor.dead? or in_vehicle? | |
1462 | @character_name = "" | |
1463 | @character_index = 0 | |
1464 | else | |
1465 | @character_name = @actor.character_name | |
1466 | @character_index = @actor.character_index | |
1467 | end | |
1468 | end | |
1469 | ||
1470 | def update | |
1471 | super | |
1472 | update_death | |
1473 | return if @actor.dead? | |
1474 | update_on_off_vehicle | |
1475 | return if in_vehicle? | |
1476 | update_target_selection | |
1477 | end | |
1478 | ||
1479 | def update_actions | |
1480 | return if @actor.dead? | |
1481 | return if in_vehicle? | |
1482 | return if $game_map.interpreter.running? | |
1483 | case @action | |
1484 | when 0 | |
1485 | update_weapon_attack | |
1486 | when 1 | |
1487 | update_skill_attack | |
1488 | when 3 | |
1489 | update_cure | |
1490 | end | |
1491 | @defending = (@action == 2) | |
1492 | end | |
1493 | ||
1494 | def update_target_selection | |
1495 | for ally in $game_allies.compact | |
1496 | next if ally.action != 3 | |
1497 | next unless $game_map.in_range?(ally) | |
1498 | next if ally.balloon_delay <= 0 | |
1499 | next unless in_range?(ally, 2) | |
1500 | @target = ally | |
1501 | @protect = true | |
1502 | end | |
1503 | if @target.is_a?(Game_Ally) and in_range?(@target, 2) | |
1504 | @target = nil | |
1505 | @protect = false | |
1506 | end | |
1507 | if @target == nil and !@protect | |
1508 | for item in $game_items.compact | |
1509 | next unless $game_map.in_range?(item) | |
1510 | next if item.target != nil | |
1511 | @target = item | |
1512 | item.target = self | |
1513 | end | |
1514 | end | |
1515 | if @target == nil and @action < 2 and !@protect | |
1516 | for target in $VTP.select_target(self, nil) | |
1517 | next unless $game_map.in_range?(target) | |
1518 | next if target.is_object? | |
1519 | next if $VTP.same_team?(self, target) | |
1520 | next if target.actor.dead? | |
1521 | next unless in_range?(target, 5) | |
1522 | @target = target | |
1523 | end | |
1524 | end | |
1525 | @target = $game_player if @defending | |
1526 | end | |
1527 | ||
1528 | def update_weapon_attack | |
1529 | @right_attack = (@attack_delay > 0) | |
1530 | @left_attack = (@attack2_delay > 0) | |
1531 | return if $VTP.blocked_by_state?(self, 0) | |
1532 | if @actor.two_swords_style | |
1533 | hand = rand(2) | |
1534 | else | |
1535 | hand = 0 | |
1536 | end | |
1537 | return if @target == nil | |
1538 | return if @target.is_a?(Game_Item) | |
1539 | return if @target.is_object? | |
1540 | return if $VTP.same_team?(self, @target) | |
1541 | return if (hand == 0 and @attack_delay > 0) or (hand == 1 and @attack2_delay > 0) | |
1542 | return unless self.in_front?(@target) | |
1543 | weapon = @actor.weapons[hand] | |
1544 | if weapon != nil and weapon.ranged? | |
1545 | return unless (in_direction?(@target) and in_range?(@target, weapon.range)) | |
1546 | ammos = [] | |
1547 | weapon.ammo_list.each { |i| ammos << i if $game_party.has_item?($data_items[i]) } | |
1548 | @actor.ammos[weapon.id] = $data_items[ammos[rand(ammos.size)]] | |
1549 | $VTP.range_attack(self, hand) | |
1550 | else | |
1551 | if hand == 1 | |
1552 | $VTP.melee_attack2(self, @target) | |
1553 | else | |
1554 | $VTP.melee_attack(self, @target) | |
1555 | end | |
1556 | end | |
1557 | end | |
1558 | ||
1559 | def update_skill_attack | |
1560 | return if @skill_delay > 0 | |
1561 | return if $VTP.blocked_by_state?(self, 1) | |
1562 | return if @actor.skills.empty? | |
1563 | if @actor.skill_hotkeys.empty? | |
1564 | skill = @actor.skills[rand(@actor.skills.size)] | |
1565 | else | |
1566 | skill = $data_skills[@actor.skill_hotkeys[@actor.skill_hotkeys.keys[rand(@actor.skill_hotkeys.size)]]] | |
1567 | end | |
1568 | if skill.ranged? | |
1569 | for target in $VTP.select_target(self, skill) | |
1570 | next if target.is_object? | |
1571 | next if $VTP.same_team?(self, target) | |
1572 | next unless in_range?(target, skill.range) | |
1573 | next unless in_direction?(target) | |
1574 | @target = target | |
1575 | $VTP.cast_skill(self, skill) | |
1576 | end | |
1577 | else | |
1578 | $VTP.skill_attack(self, skill) | |
1579 | end | |
1580 | end | |
1581 | ||
1582 | def update_cure | |
1583 | if @target != nil and in_range?(@target, 2) and @balloon_delay <= 0 | |
1584 | @balloon_id = 1 | |
1585 | @balloon_delay = 60 | |
1586 | end | |
1587 | party = [] | |
1588 | $game_party.members.each { |i| party << i.character } | |
1589 | for target in party | |
1590 | next unless $game_map.in_range?(target) | |
1591 | for skill in @actor.skills.compact | |
1592 | next if @skill_delay > 0 | |
1593 | next unless $VTP.curable?(target, skill) | |
1594 | @heal_target = [target] | |
1595 | $VTP.skill_attack(self, skill) | |
1596 | end | |
1597 | for item in $game_party.items | |
1598 | next unless item.is_a?(RPG::Item) | |
1599 | next if @item_delay > 0 | |
1600 | next unless $VTP.curable?(target, item) | |
1601 | @heal_target = [target] | |
1602 | $VTP.item_attack(self, item) | |
1603 | end | |
1604 | end | |
1605 | @heal_target = nil | |
1606 | end | |
1607 | ||
1608 | def update_death | |
1609 | if @actor.dead? and !@dead | |
1610 | Sound.play_actor_collapse | |
1611 | for monster in $game_monsters.compact | |
1612 | monster.target = nil if monster.target == self | |
1613 | end | |
1614 | for event in $game_map.events.values.compact | |
1615 | event.target = nil if event.target == self | |
1616 | end | |
1617 | @dead = true | |
1618 | refresh | |
1619 | elsif !@actor.dead? and @dead | |
1620 | refresh | |
1621 | moveto($game_player.x, $game_player.y) | |
1622 | move_random | |
1623 | @dead = false | |
1624 | end | |
1625 | end | |
1626 | ||
1627 | def update_self_movement | |
1628 | return if moving? | |
1629 | return if @right_attack or @left_attack | |
1630 | return if $VTP.blocked_by_state?(self, 2) | |
1631 | if @target != nil | |
1632 | if @action == 3 and (!@target.is_a?(Game_Item) or @target == $game_player) | |
1633 | move_away_from(@target) | |
1634 | else | |
1635 | move_toward(@target) | |
1636 | end | |
1637 | else | |
1638 | move_toward($game_player) | |
1639 | end | |
1640 | if @target.is_a?(Game_Item) and over?(@target) | |
1641 | @target.get | |
1642 | @target = nil | |
1643 | end | |
1644 | end | |
1645 | ||
1646 | def update_on_off_vehicle | |
1647 | if $game_player.in_vehicle? and !@in_vehicle | |
1648 | @in_vehicle = true | |
1649 | refresh | |
1650 | elsif !$game_player.in_vehicle? and @in_vehicle | |
1651 | @in_vehicle = false | |
1652 | refresh | |
1653 | moveto($game_player.x, $game_player.y) | |
1654 | move_random | |
1655 | end | |
1656 | end | |
1657 | ||
1658 | def get_on_vehicle | |
1659 | @in_vehicle = true | |
1660 | refresh | |
1661 | end | |
1662 | ||
1663 | def get_off_vehicle | |
1664 | @in_vehicle = false | |
1665 | refresh | |
1666 | moveto($game_player.x, $game_player.y) | |
1667 | move_random | |
1668 | end | |
1669 | ||
1670 | def map_passable?(x, y) | |
1671 | return $game_map.passable2?(x, y) | |
1672 | end | |
1673 | ||
1674 | def dash? | |
1675 | return ($game_player.dash? and $game_player.moving?) | |
1676 | end | |
1677 | ||
1678 | def in_vehicle? | |
1679 | return @in_vehicle | |
1680 | end | |
1681 | ||
1682 | end | |
1683 | ||
1684 | #------------------------------------------------------------------------------ | |
1685 | class Game_Monster < Game_Character | |
1686 | ||
1687 | attr_reader :level | |
1688 | ||
1689 | def initialize(enemy_id, troop_id, level, area) | |
1690 | super() | |
1691 | @enemy_id = enemy_id | |
1692 | @troop_id = troop_id | |
1693 | @level = level | |
1694 | @area = area | |
1695 | setup_enemy | |
1696 | set_start_position | |
1697 | while(!map_passable?(@x_pos, @y_pos)) | |
1698 | set_start_position | |
1699 | end | |
1700 | moveto(@x_pos, @y_pos) | |
1701 | end | |
1702 | ||
1703 | def setup_enemy | |
1704 | @actor = Game_Enemy.new(0, @enemy_id) | |
1705 | @actor.level = @level | |
1706 | @actor.recover_all | |
1707 | @actor.character = self | |
1708 | @move_speed = @actor.move_speed.to_i | |
1709 | @respawn_delay = @actor.respawn.to_i | |
1710 | @dead = false | |
1711 | refresh | |
1712 | end | |
1713 | ||
1714 | def refresh | |
1715 | @character_name = @actor.character_name.to_s | |
1716 | @character_index = @actor.character_index.to_i | |
1717 | @opacity = 255 | |
1718 | end | |
1719 | ||
1720 | def update | |
1721 | super | |
1722 | if @actor.dead? | |
1723 | update_death unless @dead | |
1724 | @opacity -= 10 if @opacity > 0 | |
1725 | end | |
1726 | if @dead and @respawn_delay > 0 | |
1727 | if @respawn_delay <= 1 | |
1728 | setup_enemy | |
1729 | else | |
1730 | @respawn_delay -= 1 | |
1731 | end | |
1732 | end | |
1733 | end | |
1734 | ||
1735 | def update_actions | |
1736 | return if $game_map.interpreter.running? | |
1737 | return if @target != nil and @target.in_vehicle? | |
1738 | $VTP.enemy_actions(self) | |
1739 | @heal_target = nil | |
1740 | @defending = (@defend_delay > 0) | |
1741 | end | |
1742 | ||
1743 | def set_start_position | |
1744 | x = []; y = [] | |
1745 | if @area != nil | |
1746 | for a in (@area.rect.x)...(@area.rect.x+@area.rect.width) | |
1747 | for b in (@area.rect.y)...(@area.rect.y+@area.rect.height) | |
1748 | next unless $game_map.passable?(a, b) | |
1749 | x << a; y << b | |
1750 | end | |
1751 | end | |
1752 | else | |
1753 | for a in 0...$game_map.width | |
1754 | for b in 0...$game_map.height | |
1755 | next unless map_passable?(a, b) | |
1756 | x << a; y << b | |
1757 | end | |
1758 | end | |
1759 | end | |
1760 | @x_pos = x[rand(x.size)] | |
1761 | @y_pos = y[rand(y.size)] | |
1762 | end | |
1763 | ||
1764 | def update_death | |
1765 | $VTP.make_drop(self) | |
1766 | @dead = true | |
1767 | end | |
1768 | ||
1769 | def update_self_movement | |
1770 | return if @actor.dead? | |
1771 | return if moving? | |
1772 | return if @attack_delay > 0 | |
1773 | return if $VTP.blocked_by_state?(self, 2) | |
1774 | update_target_selection if @actor.aggressiveness.to_i != 2 | |
1775 | if @target != nil | |
1776 | move_by_aggressiveness | |
1777 | else | |
1778 | move_random | |
1779 | end | |
1780 | end | |
1781 | ||
1782 | def update_target_selection | |
1783 | return @target != nil | |
1784 | for target in $VTP.update_target_selection(self) | |
1785 | next if $VTP.same_team?(self, target) | |
1786 | next if @vision != nil and in_range?(target, @vision) | |
1787 | @target = target | |
1788 | end | |
1789 | end | |
1790 | ||
1791 | def move_by_aggressiveness | |
1792 | case @actor.aggressiveness.to_i | |
1793 | when 0 | |
1794 | if @target != nil and in_range?(@target, 5) | |
1795 | move_away_from(@target) | |
1796 | else | |
1797 | move_random | |
1798 | end | |
1799 | when 1 | |
1800 | if @target != nil and in_range?(@target, 5) | |
1801 | move_away_from(@target) | |
1802 | else | |
1803 | move_random | |
1804 | end | |
1805 | when 2 | |
1806 | if @target != nil and in_range?(@target, 5) | |
1807 | move_type_toward(@target) | |
1808 | else | |
1809 | move_random | |
1810 | end | |
1811 | when 3 | |
1812 | if @target != nil and in_range?(@target, 5) | |
1813 | move_type_toward(@target) | |
1814 | else | |
1815 | move_random | |
1816 | end | |
1817 | when 4 | |
1818 | if @target != nil and in_range?(@target, 7) | |
1819 | move_toward(@target) | |
1820 | else | |
1821 | move_random | |
1822 | end | |
1823 | when 5 | |
1824 | if @target != nil and in_range?(@target, 10) | |
1825 | move_toward(@target) | |
1826 | else | |
1827 | move_random | |
1828 | end | |
1829 | end | |
1830 | end | |
1831 | ||
1832 | def increase_steps | |
1833 | super | |
1834 | return if @actor == nil | |
1835 | return if @actor.dead? | |
1836 | @actor.on_enemy_walk | |
1837 | end | |
1838 | ||
1839 | def map_passable?(x, y) | |
1840 | return $game_map.passable2?(x, y) | |
1841 | end | |
1842 | ||
1843 | end | |
1844 | ||
1845 | #------------------------------------------------------------------------------ | |
1846 | class Game_Projectile < Game_Character | |
1847 | ||
1848 | attr_reader :parent | |
1849 | attr_accessor :draw | |
1850 | attr_accessor :destroy | |
1851 | ||
1852 | def initialize(parent, object) | |
1853 | super() | |
1854 | @parent = parent | |
1855 | @object = object | |
1856 | @actor = @parent.actor | |
1857 | @step = 0 | |
1858 | @direction = @parent.direction | |
1859 | @move_speed = @object.move_speed.to_i | |
1860 | @step_anime = true | |
1861 | moveto(@parent.x, @parent.y) | |
1862 | refresh | |
1863 | update | |
1864 | end | |
1865 | ||
1866 | def refresh | |
1867 | @character_name = @object.character.to_s | |
1868 | @character_index = @object.index.to_i | |
1869 | end | |
1870 | ||
1871 | def update | |
1872 | super | |
1873 | if @step > @object.range | |
1874 | @destroy = true | |
1875 | $game_projectiles.delete(self) | |
1876 | return | |
1877 | end | |
1878 | return if moving? | |
1879 | move_forward | |
1880 | @step += 1 | |
1881 | dx = (@direction == 4 ? -1 : @direction == 6 ? 1 : 0) | |
1882 | dy = (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) | |
1883 | end | |
1884 | ||
1885 | def check_event_trigger_touch(x, y) | |
1886 | if @object.is_a?(RPG::Skill) | |
1887 | $VTP.skill_attack(@parent, @object, self) | |
1888 | elsif @object.is_a?(RPG::Item) | |
1889 | $VTP.item_attack(@parent, @object, self) | |
1890 | end | |
1891 | @destroy = true | |
1892 | $game_projectiles.delete(self) | |
1893 | end | |
1894 | ||
1895 | def map_passable?(x, y) | |
1896 | return $game_map.range_passable?(x, y) | |
1897 | end | |
1898 | ||
1899 | end | |
1900 | ||
1901 | #------------------------------------------------------------------------------ | |
1902 | class Game_Item < Game_Character | |
1903 | ||
1904 | attr_reader :item | |
1905 | attr_accessor :draw | |
1906 | attr_accessor :destroy | |
1907 | ||
1908 | def initialize(parent, item) | |
1909 | super() | |
1910 | @item = item | |
1911 | if parent.is_a?(Array) | |
1912 | moveto(parent[0], parent[1]) | |
1913 | else | |
1914 | moveto(parent.x, parent.y) | |
1915 | a = [-1, 0, 1] | |
1916 | new_x = a[rand(a.size)] | |
1917 | new_y = a[rand(a.size)] | |
1918 | map_passable?(@x+new_x, @y+new_y) ? jump(new_x, new_y) : jump(0, 0) | |
1919 | end | |
1920 | end | |
1921 | ||
1922 | def update | |
1923 | super | |
1924 | return unless Input.trigger?(Input::C) | |
1925 | return unless $game_player.in_front?(self) or $game_player.over?(self) | |
1926 | get | |
1927 | end | |
1928 | ||
1929 | def get | |
1930 | $game_allies.compact { |ally| ally.target = nil if ally.target == self } | |
1931 | Sound.play_decision | |
1932 | @item.is_a?(Numeric) ? $game_party.gain_gold(@item) : $game_party.gain_item(@item, 1) | |
1933 | @destroy = true | |
1934 | $game_items.delete(self) | |
1935 | end | |
1936 | ||
1937 | def screen_z | |
1938 | return $game_player.screen_z - 1 | |
1939 | end | |
1940 | ||
1941 | end | |
1942 | ||
1943 | #------------------------------------------------------------------------------ | |
1944 | class Game_Interpreter | |
1945 | ||
1946 | attr_reader :id | |
1947 | ||
1948 | alias vtp_ginterpreter_setup setup | |
1949 | ||
1950 | def setup(list, event_id=0) | |
1951 | vtp_ginterpreter_setup(list, event_id) | |
1952 | @id = @original_event_id | |
1953 | end | |
1954 | ||
1955 | def create_item(object, kind, x, y) | |
1956 | case kind | |
1957 | when 0 | |
1958 | item = $data_items[object] | |
1959 | when 1 | |
1960 | item = $data_weapons[object] | |
1961 | when 2 | |
1962 | item = $data_armors[object] | |
1963 | when 3 | |
1964 | item = object | |
1965 | end | |
1966 | $game_items << Game_Item.new([x, y], item) | |
1967 | end | |
1968 | ||
1969 | end | |
1970 | ||
1971 | #------------------------------------------------------------------------------ | |
1972 | class Sprite | |
1973 | ||
1974 | def draw_face(actor, x, y) | |
1975 | char_name = actor.character_name | |
1976 | char_index = actor.character_index | |
1977 | bitmap = Cache.character(char_name) | |
1978 | sign = char_name[/^[\!\$]./] | |
1979 | if sign != nil and sign.include?('$') | |
1980 | cw = bitmap.width / 3 | |
1981 | ch = bitmap.height / 4 | |
1982 | else | |
1983 | cw = bitmap.width / 12 | |
1984 | ch = bitmap.height / 8 | |
1985 | end | |
1986 | src_rect = Rect.new((char_index%4*3+1)*cw, (char_index/4*4)*ch, cw, 20) | |
1987 | self.bitmap.blt(x, y+6, bitmap, src_rect) | |
1988 | end | |
1989 | ||
1990 | end | |
1991 | ||
1992 | #------------------------------------------------------------------------------ | |
1993 | class Sprite_Base | |
1994 | ||
1995 | attr_reader :character | |
1996 | ||
1997 | alias vtp_spbase_initialize initialize | |
1998 | alias vtp_spbase_update update | |
1999 | alias vtp_spbase_dispose dispose | |
2000 | ||
2001 | def initialize(viewport=nil) | |
2002 | vtp_spbase_initialize(viewport) | |
2003 | @damage_sprites = [] | |
2004 | @state_animation_delay = 0 | |
2005 | create_hits_sprite | |
2006 | end | |
2007 | ||
2008 | def update | |
2009 | vtp_spbase_update | |
2010 | @state_animation_delay -= 1 if @state_animation_delay > 0 | |
2011 | update_damage_sprites | |
2012 | update_hits_sprite | |
2013 | update_states_animations | |
2014 | end | |
2015 | ||
2016 | def dispose | |
2017 | vtp_spbase_dispose | |
2018 | dispose_damage_sprites | |
2019 | dispose_hits_sprite | |
2020 | end | |
2021 | ||
2022 | def update_damage_sprites | |
2023 | for i in @damage_sprites.compact | |
2024 | next if i[0].disposed? | |
2025 | i[0].x = self.x | |
2026 | i[0].y -= 0.25 | |
2027 | end | |
2028 | for i in @damage_sprites.compact | |
2029 | if i[1] > 0 | |
2030 | i[1] -= 1 | |
2031 | elsif !i[0].disposed? | |
2032 | if i[0].opacity > 0 | |
2033 | i[0].opacity -= 10 | |
2034 | else | |
2035 | i[0].dispose | |
2036 | @damage_sprites.delete(i[0]) | |
2037 | end | |
2038 | end | |
2039 | end | |
2040 | if @character != nil and @character.actor != nil and @character.damage != nil | |
2041 | @character.step_back if @character.critical | |
2042 | show_damage(@character.damage, @character.critical) | |
2043 | @character.damage = nil | |
2044 | @character.critical = false | |
2045 | end | |
2046 | end | |
2047 | ||
2048 | def dispose_damage_sprites | |
2049 | @damage_sprites.each { |i| i[0].dispose } | |
2050 | @damage_sprites.clear | |
2051 | end | |
2052 | ||
2053 | def show_damage(damage, critical) | |
2054 | string = (damage.is_a?(Numeric) ? damage.abs.to_i : damage) | |
2055 | if damage.to_i == 0 | |
2056 | color = Color.new(255,255,255) | |
2057 | elsif damage.to_i < 0 | |
2058 | color = Color.new(128,255,128) | |
2059 | else | |
2060 | if @character.is_a?(Game_Player) or @character.is_a?(Game_Ally) | |
2061 | color = Color.new(255,56,16) | |
2062 | else | |
2063 | color = Color.new(255,255,255) | |
2064 | end | |
2065 | end | |
2066 | bitmap = Bitmap.new(100, $VTP.damage["font"][1]*2) | |
2067 | bitmap.font.name = $VTP.damage["font"][0] | |
2068 | bitmap.font.size = $VTP.damage["font"][1] | |
2069 | bitmap.font.color = Color.new(255,204,32) | |
2070 | bitmap.draw_outlined_text(0, 0, 100, bitmap.font.size, $VTP.damage["texts"][1], 1) if critical | |
2071 | bitmap.font.color = color | |
2072 | bitmap.draw_outlined_text(0, bitmap.font.size, 100, bitmap.font.size, string.to_s, 1) | |
2073 | sprite = Sprite.new(self.viewport) | |
2074 | sprite.bitmap = bitmap | |
2075 | sprite.ox = bitmap.width/2 | |
2076 | sprite.oy = bitmap.height/2 | |
2077 | sprite.x = self.x | |
2078 | sprite.y = self.y-32 | |
2079 | sprite.z = 999999 | |
2080 | @damage_sprites << [sprite, 30] | |
2081 | end | |
2082 | ||
2083 | def create_hits_sprite | |
2084 | @hits_sprite = Sprite.new(self.viewport) | |
2085 | @hits_sprite.bitmap = Bitmap.new(200, $VTP.hit["font"][1]*3) | |
2086 | @hits_sprite.bitmap.font.name = $VTP.hit["font"][0] | |
2087 | @hits_sprite.bitmap.font.size = $VTP.hit["font"][1] | |
2088 | @hits_sprite.bitmap.font.bold = $VTP.hit["font"][2] | |
2089 | @hits_sprite.bitmap.font.italic = $VTP.hit["font"][3] | |
2090 | @hits_sprite.x = $VTP.hit["position"][0] | |
2091 | @hits_sprite.y = $VTP.hit["position"][1] | |
2092 | @hits_sprite.z = 999999 | |
2093 | @hits_sprite.opacity = 0 | |
2094 | @hits_delay = 0 | |
2095 | end | |
2096 | ||
2097 | def update_hits_sprite | |
2098 | @hits_delay -= 1 if @hits_delay > 0 | |
2099 | if $VTP.hits_total > 0 and @num_hits != $VTP.hits_total | |
2100 | @num_hits = $VTP.hits_total | |
2101 | w = @hits_sprite.bitmap.width | |
2102 | h = @hits_sprite.bitmap.font.size | |
2103 | @hits_sprite.bitmap.clear | |
2104 | @hits_sprite.bitmap.font.color = Color.new(255,255,255) | |
2105 | @hits_sprite.bitmap.draw_text($VTP.hits_total.getw+4, 0, w, h, $VTP.hit["texts"][0]) | |
2106 | @hits_sprite.bitmap.draw_text($VTP.damage_total.getw+4, h, w, h, $VTP.hit["texts"][1]) | |
2107 | @hits_sprite.bitmap.font.color = Color.new(255,204,32) | |
2108 | @hits_sprite.bitmap.draw_text(0, 0, w, h, $VTP.hits_total.to_s) | |
2109 | @hits_sprite.bitmap.font.color = Color.new(255,56,16) | |
2110 | @hits_sprite.bitmap.draw_text(0, h, w, h, $VTP.damage_total.to_s) | |
2111 | @hits_sprite.bitmap.fill_rect(0, h*2+1, w, 1, Color.new(0,0,0)) | |
2112 | @hits_sprite.bitmap.fill_rect(0, h*2, w, 1, Color.new(255,255,255)) | |
2113 | @hits_sprite.opacity = 255 | |
2114 | @hits_delay = 60 | |
2115 | end | |
2116 | @hits_sprite.opacity -= 10 if @hits_delay <= 0 and @hits_sprite.opacity > 0 | |
2117 | end | |
2118 | ||
2119 | def dispose_hits_sprite | |
2120 | @hits_sprite.dispose | |
2121 | end | |
2122 | ||
2123 | def update_states_animations | |
2124 | return if @character == nil | |
2125 | return if @character.actor == nil | |
2126 | return if @character.in_vehicle? | |
2127 | for state in @character.actor.states.compact | |
2128 | next if state.animation_id.to_i <= 0 | |
2129 | next if @state_animation_delay > 0 | |
2130 | @character.animation_id = state.animation_id.to_i | |
2131 | @state_animation_delay = ($data_animations[@character.animation_id].frame_max*4+1) | |
2132 | end | |
2133 | end | |
2134 | ||
2135 | def animation_set_sprites(frame) | |
2136 | cell_data = frame.cell_data | |
2137 | for i in 0..15 | |
2138 | sprite = @animation_sprites[i] | |
2139 | next if sprite == nil | |
2140 | pattern = cell_data[i, 0] | |
2141 | if pattern == nil or pattern == -1 | |
2142 | sprite.visible = false | |
2143 | next | |
2144 | end | |
2145 | if pattern < 100 | |
2146 | sprite.bitmap = @animation_bitmap1 | |
2147 | else | |
2148 | sprite.bitmap = @animation_bitmap2 | |
2149 | end | |
2150 | sprite.visible = true | |
2151 | sprite.src_rect.set(pattern % 5 * 192, | |
2152 | pattern % 100 / 5 * 192, 192, 192) | |
2153 | if @animation_mirror | |
2154 | sprite.x = @animation_ox - cell_data[i, 1] / 3 | |
2155 | sprite.y = @animation_oy + cell_data[i, 2] / 3 | |
2156 | sprite.angle = (360 - cell_data[i, 4]) | |
2157 | sprite.mirror = (cell_data[i, 5] == 0) | |
2158 | else | |
2159 | sprite.x = @animation_ox + cell_data[i, 1] / 3 | |
2160 | sprite.y = @animation_oy + cell_data[i, 2] / 3 | |
2161 | sprite.angle = cell_data[i, 4] | |
2162 | sprite.mirror = (cell_data[i, 5] == 1) | |
2163 | end | |
2164 | sprite.z = self.z + 300 + i | |
2165 | sprite.ox = 96 | |
2166 | sprite.oy = 96 | |
2167 | sprite.zoom_x = cell_data[i, 3] / 300.0 | |
2168 | sprite.zoom_y = cell_data[i, 3] / 300.0 | |
2169 | sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 | |
2170 | sprite.blend_type = cell_data[i, 7] | |
2171 | end | |
2172 | end | |
2173 | ||
2174 | end | |
2175 | #------------------------------------------------------------------------------ | |
2176 | class Sprite_Character < Sprite_Base | |
2177 | ||
2178 | alias vtp_spcharacter_update update | |
2179 | ||
2180 | def update | |
2181 | vtp_spcharacter_update | |
2182 | if @character.actor != nil | |
2183 | if @character.actor.dead? and !@flash | |
2184 | self.flash(Color.new(200,0,0), 10) | |
2185 | @flash = true | |
2186 | elsif @flash and !@character.actor.dead? | |
2187 | @flash = false | |
2188 | end | |
2189 | end | |
2190 | end | |
2191 | ||
2192 | end | |
2193 | ||
2194 | #------------------------------------------------------------------------------ | |
2195 | class Sprite_Weapon < Sprite | |
2196 | ||
2197 | attr_reader :character | |
2198 | ||
2199 | def initialize(viewport, character) | |
2200 | super(viewport) | |
2201 | @character = character | |
2202 | self.bitmap = Cache.system("Iconset") | |
2203 | self.ox = 12 | |
2204 | self.oy = 12 | |
2205 | self.zoom_x = 0.80 | |
2206 | self.zoom_y = 0.80 | |
2207 | @animation_delay = 0 | |
2208 | refresh | |
2209 | update | |
2210 | end | |
2211 | ||
2212 | def update | |
2213 | super | |
2214 | @animation_delay -= 1 if @animation_delay > 0 | |
2215 | @animation_delay = 20 if @animation_delay <= 0 and @character.animation_delay >= 30 | |
2216 | self.visible = (@animation_delay > 0 and show?) | |
2217 | return unless self.visible | |
2218 | refresh | |
2219 | update_movement | |
2220 | end | |
2221 | ||
2222 | def refresh | |
2223 | self.src_rect.set(icon_index%16*24, icon_index/16*24, 24, 24) | |
2224 | end | |
2225 | ||
2226 | def update_movement | |
2227 | case @character.direction | |
2228 | when 2 | |
2229 | self.x = @character.screen_x-12 | |
2230 | self.y = @character.screen_y | |
2231 | self.z = @character.screen_z+2 | |
2232 | self.mirror = false | |
2233 | change_angle(180, 135, 90) | |
2234 | when 4 | |
2235 | self.x = @character.screen_x-14 | |
2236 | self.y = @character.screen_y-10 | |
2237 | self.z = @character.screen_z-1 | |
2238 | self.mirror = false | |
2239 | change_angle(-45, 0, 45) | |
2240 | when 6 | |
2241 | self.x = @character.screen_x+14 | |
2242 | self.y = @character.screen_y-10 | |
2243 | self.z = @character.screen_z+2 | |
2244 | self.mirror = true | |
2245 | change_angle(45, 0, -45) | |
2246 | when 8 | |
2247 | self.x = @character.screen_x+16 | |
2248 | self.y = @character.screen_y-14 | |
2249 | self.z = @character.screen_z-1 | |
2250 | self.mirror = true | |
2251 | change_angle(45, 0, -45) | |
2252 | end | |
2253 | self.opacity = @character.opacity | |
2254 | self.blend_type = @character.blend_type | |
2255 | end | |
2256 | ||
2257 | def change_angle(a, b, c) | |
2258 | if @animation_delay >= 20 | |
2259 | self.angle = a | |
2260 | elsif @animation_delay >= 15 | |
2261 | self.angle = b | |
2262 | elsif @animation_delay >= 10 | |
2263 | self.angle = c | |
2264 | end | |
2265 | end | |
2266 | ||
2267 | def icon_index | |
2268 | return 0 if @character.actor == nil | |
2269 | return 0 if @character.in_vehicle? | |
2270 | return @character.actor.weapon_icon.to_i if (@character.is_a?(Game_Monster) or @character.is_a?(Game_Event)) | |
2271 | if @character.left_attack | |
2272 | return 0 if @character.actor.weapons[1] == nil | |
2273 | return @character.actor.weapons[1].icon_index | |
2274 | else | |
2275 | return 0 if @character.actor.weapons[0] == nil | |
2276 | return @character.actor.weapons[0].icon_index | |
2277 | end | |
2278 | end | |
2279 | ||
2280 | def show? | |
2281 | return false if @character.actor == nil | |
2282 | return false if @character.actor.dead? | |
2283 | return true if @character.is_a?(Game_Monster) or @character.is_a?(Game_Event) | |
2284 | return true if @character.right_attack | |
2285 | return true if @character.left_attack | |
2286 | return false | |
2287 | end | |
2288 | ||
2289 | end | |
2290 | ||
2291 | #------------------------------------------------------------------------------ | |
2292 | class Sprite_Shield < Sprite | |
2293 | ||
2294 | attr_reader :character | |
2295 | ||
2296 | def initialize(viewport, character) | |
2297 | super(viewport) | |
2298 | @character = character | |
2299 | self.bitmap = Cache.system("Iconset") | |
2300 | self.ox = 12 | |
2301 | self.oy = 12 | |
2302 | self.zoom_x = 0.80 | |
2303 | self.zoom_y = 0.80 | |
2304 | self.src_rect.set(icon_index%16*24, icon_index/16*24, 24, 24) | |
2305 | update | |
2306 | end | |
2307 | ||
2308 | def update | |
2309 | super | |
2310 | self.visible = (@character.defending and icon_index > 0 and !@character.actor.dead?) | |
2311 | return unless self.visible | |
2312 | update_movement | |
2313 | moving_with_shield | |
2314 | end | |
2315 | ||
2316 | def update_movement | |
2317 | case @character.direction | |
2318 | when 2 | |
2319 | self.mirror = true | |
2320 | self.x = @character.screen_x+6 | |
2321 | self.z = @character.screen_z+1 | |
2322 | when 4 | |
2323 | self.mirror = false | |
2324 | self.x = @character.screen_x-6 | |
2325 | self.z = @character.screen_z+1 | |
2326 | when 6 | |
2327 | self.mirror = true | |
2328 | self.x = @character.screen_x+6 | |
2329 | self.z = @character.screen_z-1 | |
2330 | when 8 | |
2331 | self.mirror = false | |
2332 | self.x = @character.screen_x-6 | |
2333 | self.z = @character.screen_z-1 | |
2334 | end | |
2335 | self.y = @character.screen_y-8 | |
2336 | self.opacity = @character.opacity | |
2337 | self.blend_type = @character.blend_type | |
2338 | self.bush_depth = @character.bush_depth | |
2339 | end | |
2340 | ||
2341 | def moving_with_shield | |
2342 | if @character.moving? | |
2343 | self.wave_amp = 1 | |
2344 | self.wave_length = 1 | |
2345 | self.wave_speed = 6 | |
2346 | else | |
2347 | self.wave_amp = 0 | |
2348 | end | |
2349 | end | |
2350 | ||
2351 | def icon_index | |
2352 | return 0 if @character.actor == nil | |
2353 | return 0 if @character.in_vehicle? | |
2354 | return @character.actor.shield_icon.to_i if (@character.is_a?(Game_Monster) or @character.is_a?(Game_Event)) | |
2355 | return 0 if @character.actor.armors[0] == nil | |
2356 | return 0 unless @character.actor.armors[0].is_a?(RPG::Armor) | |
2357 | return @character.actor.armors[0].icon_index | |
2358 | end | |
2359 | ||
2360 | end | |
2361 | #------------------------------------------------------------------------------ | |
2362 | class Sprite_Item < Sprite | |
2363 | ||
2364 | attr_reader :character | |
2365 | ||
2366 | def initialize(viewport, character) | |
2367 | super(viewport) | |
2368 | @character = character | |
2369 | self.bitmap = Cache.system("Iconset") | |
2370 | self.ox = 12 | |
2371 | self.oy = 24 | |
2372 | index = @character.item.is_a?(Numeric) ? $VTP.gold_properties[0] : @character.item.icon_index | |
2373 | self.src_rect.set(index%16*24, index/16*24, 24, 24) | |
2374 | update | |
2375 | end | |
2376 | ||
2377 | def update | |
2378 | super | |
2379 | self.x = @character.screen_x | |
2380 | self.y = @character.screen_y | |
2381 | self.z = @character.screen_z | |
2382 | self.bush_depth = @character.bush_depth | |
2383 | end | |
2384 | ||
2385 | end | |
2386 | ||
2387 | #------------------------------------------------------------------------------ | |
2388 | class Sprite_Reward < Sprite | |
2389 | ||
2390 | def initialize(viewport) | |
2391 | super(viewport) | |
2392 | self.visible = false | |
2393 | @duration = 0 | |
2394 | end | |
2395 | ||
2396 | def update | |
2397 | refresh if $game_party.reward != nil | |
2398 | return unless self.visible | |
2399 | super | |
2400 | @duration -= 1 if @duration > 0 | |
2401 | if @duration <= 0 and self.visible | |
2402 | self.opacity -= 10 | |
2403 | self.visible = false if self.opacity <= 0 | |
2404 | end | |
2405 | if @duration > 0 and self.visible and self.opacity < 200 | |
2406 | self.opacity += 10 | |
2407 | end | |
2408 | end | |
2409 | ||
2410 | def refresh | |
2411 | @text = $game_party.reward | |
2412 | $game_party.reward = nil | |
2413 | create_background | |
2414 | self.bitmap.draw_text(self.bitmap.rect, @text, 1) | |
2415 | self.x = Graphics.width - self.bitmap.width | |
2416 | self.y = Graphics.height - self.bitmap.height | |
2417 | self.visible = true | |
2418 | @duration = 150 | |
2419 | end | |
2420 | ||
2421 | def create_background | |
2422 | bitmap = Cache.system("Window") | |
2423 | w, h = @text.getw+16, Font.default_size+16 | |
2424 | self.bitmap = Bitmap.new(w, h) | |
2425 | self.bitmap.stretch_blt(Rect.new(4,4,w-8,h-8), bitmap, Rect.new(0,0,64,64)) | |
2426 | self.bitmap.stretch_blt(Rect.new(0,0,8,8), bitmap, Rect.new(64,0,8,8)) | |
2427 | self.bitmap.stretch_blt(Rect.new(8,0,w-16,8), bitmap, Rect.new(72,0,48,8)) | |
2428 | self.bitmap.stretch_blt(Rect.new(w-8,0,8,8), bitmap, Rect.new(120,0,8,8)) | |
2429 | self.bitmap.stretch_blt(Rect.new(0,8,8,h-16), bitmap, Rect.new(64,8,8,48)) | |
2430 | self.bitmap.stretch_blt(Rect.new(0,h-8,8,8), bitmap, Rect.new(64,56,8,8)) | |
2431 | self.bitmap.stretch_blt(Rect.new(8,h-8,w-16,8), bitmap, Rect.new(72,56,48,8)) | |
2432 | self.bitmap.stretch_blt(Rect.new(w-8,h-8,8,8), bitmap, Rect.new(120,56,8,8)) | |
2433 | self.bitmap.stretch_blt(Rect.new(w-8,8,8,h-16), bitmap, Rect.new(120,8,8,48)) | |
2434 | end | |
2435 | ||
2436 | end | |
2437 | ||
2438 | #------------------------------------------------------------------------------ | |
2439 | class Spriteset_Map | |
2440 | ||
2441 | alias vtp_spmap_create_characters create_characters | |
2442 | alias vtp_spmap_update_characters update_characters | |
2443 | alias vtp_spmap_dispose_characters dispose_characters | |
2444 | ||
2445 | def create_characters | |
2446 | @allies_sprites = [] | |
2447 | @monsters_sprites = [] | |
2448 | @projectiles_sprites = [] | |
2449 | @items_sprites = [] | |
2450 | @weapons_sprites = [] | |
2451 | @shields_sprites = [] | |
2452 | vtp_spmap_create_characters | |
2453 | @weapons_sprites << Sprite_Weapon.new(@viewport1, $game_player) | |
2454 | @shields_sprites << Sprite_Shield.new(@viewport1, $game_player) | |
2455 | for i in $game_map.events.values.compact | |
2456 | next if i.actor == nil | |
2457 | @weapons_sprites << Sprite_Weapon.new(@viewport1, i) | |
2458 | @shields_sprites << Sprite_Shield.new(@viewport1, i) | |
2459 | end | |
2460 | for i in $game_allies.compact | |
2461 | @allies_sprites << Sprite_Character.new(@viewport1, i) | |
2462 | @weapons_sprites << Sprite_Weapon.new(@viewport1, i) | |
2463 | @shields_sprites << Sprite_Shield.new(@viewport1, i) | |
2464 | end | |
2465 | for i in $game_monsters.compact | |
2466 | @monsters_sprites << Sprite_Character.new(@viewport1, i) | |
2467 | @weapons_sprites << Sprite_Weapon.new(@viewport1, i) | |
2468 | @shields_sprites << Sprite_Shield.new(@viewport1, i) | |
2469 | end | |
2470 | for i in $game_projectiles.compact | |
2471 | @projectiles_sprites << Sprite_Character.new(@viewport1, i) | |
2472 | end | |
2473 | for i in $game_items.compact | |
2474 | @items_sprites << Sprite_Item.new(@viewport1, i) | |
2475 | end | |
2476 | @sprite_reward = Sprite_Reward.new(@viewport3) | |
2477 | end | |
2478 | ||
2479 | def update_characters | |
2480 | vtp_spmap_update_characters | |
2481 | for i in @allies_sprites.compact | |
2482 | next if i.disposed? | |
2483 | i.update if $game_map.in_range?(i.character) | |
2484 | end | |
2485 | for i in @monsters_sprites.compact | |
2486 | next if i.disposed? | |
2487 | i.update if $game_map.in_range?(i.character) | |
2488 | end | |
2489 | for i in @weapons_sprites.compact | |
2490 | next if i.disposed? | |
2491 | i.update if $game_map.in_range?(i.character) | |
2492 | end | |
2493 | for i in @shields_sprites.compact | |
2494 | next if i.disposed? | |
2495 | i.update if $game_map.in_range?(i.character) | |
2496 | end | |
2497 | for i in @projectiles_sprites.compact | |
2498 | next if i.disposed? | |
2499 | if i.character.destroy | |
2500 | i.dispose | |
2501 | @projectiles_sprites.delete(i) | |
2502 | elsif $game_map.in_range?(i.character) | |
2503 | i.update | |
2504 | end | |
2505 | end | |
2506 | for i in $game_projectiles.compact | |
2507 | next if i.draw | |
2508 | @projectiles_sprites << Sprite_Character.new(@viewport1, i) | |
2509 | i.draw = true | |
2510 | end | |
2511 | for i in @items_sprites.compact | |
2512 | next if i.disposed? | |
2513 | if i.character.destroy | |
2514 | i.dispose | |
2515 | @items_sprites.delete(i) | |
2516 | elsif $game_map.in_range?(i.character) | |
2517 | i.update | |
2518 | end | |
2519 | end | |
2520 | for i in $game_items.compact | |
2521 | next if i.draw | |
2522 | @items_sprites << Sprite_Item.new(@viewport1, i) | |
2523 | i.draw = true | |
2524 | end | |
2525 | @sprite_reward.update | |
2526 | end | |
2527 | ||
2528 | def dispose_characters | |
2529 | vtp_spmap_dispose_characters | |
2530 | @allies_sprites.compact.each { |i| i.dispose } | |
2531 | @monsters_sprites.compact.each { |i| i.dispose } | |
2532 | @weapons_sprites.compact.each { |i| i.dispose } | |
2533 | @shields_sprites.compact.each { |i| i.dispose } | |
2534 | @items_sprites.compact.each { |i| i.dispose } | |
2535 | @sprite_reward.dispose | |
2536 | end | |
2537 | ||
2538 | def refresh_allies_sprites | |
2539 | @allies_sprites.compact.each { |i| i.dispose } | |
2540 | @weapons_sprites.compact.each { |i| i.dispose if i.character.is_a?(Game_Ally) } | |
2541 | @shields_sprites.compact.each { |i| i.dispose if i.character.is_a?(Game_Ally) } | |
2542 | @allies_sprites.clear | |
2543 | for i in $game_allies.compact | |
2544 | @allies_sprites << Sprite_Character.new(@viewport1, i) | |
2545 | @weapons_sprites << Sprite_Weapon.new(@viewport1, i) | |
2546 | @shields_sprites << Sprite_Shield.new(@viewport1, i) | |
2547 | end | |
2548 | end | |
2549 | ||
2550 | end | |
2551 | ||
2552 | #------------------------------------------------------------------------------ | |
2553 | class Scene_Title < Scene_Base | |
2554 | ||
2555 | alias vtp_stitle_command_new_game command_new_game | |
2556 | alias vtp_stitle_create_game_objects create_game_objects | |
2557 | ||
2558 | def create_game_objects | |
2559 | $game_allies = [] | |
2560 | $game_monsters = [] | |
2561 | $game_projectiles = [] | |
2562 | $game_items = [] | |
2563 | vtp_stitle_create_game_objects | |
2564 | $VTP = VerusTempusProelium.new | |
2565 | end | |
2566 | ||
2567 | def command_new_game | |
2568 | vtp_stitle_command_new_game | |
2569 | for ally in $game_allies.compact | |
2570 | ally.moveto($data_system.start_x, $data_system.start_y) | |
2571 | end | |
2572 | end | |
2573 | ||
2574 | end | |
2575 | ||
2576 | #------------------------------------------------------------------------------ | |
2577 | class Scene_File < Scene_Base | |
2578 | ||
2579 | alias vtp_stitle_do_load do_load | |
2580 | alias vtp_stitle_read_save_data read_save_data | |
2581 | alias vtp_stitle_write_save_data write_save_data | |
2582 | ||
2583 | def do_load | |
2584 | vtp_stitle_do_load | |
2585 | $game_player.refresh | |
2586 | $game_allies.compact.each { |i| i.refresh } | |
2587 | end | |
2588 | ||
2589 | def read_save_data(file) | |
2590 | vtp_stitle_read_save_data(file) | |
2591 | $game_allies = Marshal.load(file) | |
2592 | $game_monsters = Marshal.load(file) | |
2593 | $game_projectiles = Marshal.load(file) | |
2594 | $game_items = Marshal.load(file) | |
2595 | $VTP = Marshal.load(file) | |
2596 | end | |
2597 | ||
2598 | def write_save_data(file) | |
2599 | vtp_stitle_write_save_data(file) | |
2600 | Marshal.dump($game_allies, file) | |
2601 | Marshal.dump($game_monsters, file) | |
2602 | Marshal.dump($game_projectiles, file) | |
2603 | Marshal.dump($game_items, file) | |
2604 | Marshal.dump($VTP, file) | |
2605 | end | |
2606 | ||
2607 | end | |
2608 | ||
2609 | #------------------------------------------------------------------------------ | |
2610 | class Scene_Map < Scene_Base | |
2611 | ||
2612 | alias vtp_smap_update update | |
2613 | ||
2614 | def update | |
2615 | vtp_smap_update | |
2616 | $VTP.update | |
2617 | $game_allies.compact.each { |i| i.update if $game_map.in_range?(i) } | |
2618 | $game_monsters.compact.each { |i| i.update if $game_map.in_range?(i) } | |
2619 | $game_projectiles.compact.each { |i| i.update if $game_map.in_range?(i) } | |
2620 | $game_items.compact.each { |i| i.update if $game_map.in_range?(i) } | |
2621 | end | |
2622 | ||
2623 | def refresh_allies_sprites | |
2624 | @spriteset.refresh_allies_sprites if @spriteset != nil | |
2625 | end | |
2626 | ||
2627 | def update_encounter | |
2628 | end | |
2629 | ||
2630 | end | |
2631 | ||
2632 | #------------------------------------------------------------------------------ | |
2633 | class Window_Selectable < Window_Base | |
2634 | ||
2635 | alias vtp_wselectable_cursor_down cursor_down | |
2636 | alias vtp_wselectable_cursor_left cursor_left | |
2637 | alias vtp_wselectable_cursor_right cursor_right | |
2638 | alias vtp_wselectable_cursor_up cursor_up | |
2639 | ||
2640 | def cursor_down(wrap=false) | |
2641 | return if is_skill or is_item | |
2642 | vtp_wselectable_cursor_down(wrap) | |
2643 | end | |
2644 | ||
2645 | def cursor_left(wrap=false) | |
2646 | return if is_skill or is_item | |
2647 | vtp_wselectable_cursor_left(wrap) | |
2648 | end | |
2649 | ||
2650 | def cursor_right(wrap=false) | |
2651 | return if is_skill or is_item | |
2652 | vtp_wselectable_cursor_right(wrap) | |
2653 | end | |
2654 | ||
2655 | def cursor_up(wrap=false) | |
2656 | return if is_skill or is_item | |
2657 | vtp_wselectable_cursor_up(wrap) | |
2658 | end | |
2659 | ||
2660 | def is_skill | |
2661 | return true if self.is_a?(Window_Skill) and Input.press?($VTP.skills_key) | |
2662 | return false | |
2663 | end | |
2664 | ||
2665 | def is_item | |
2666 | return true if self.is_a?(Window_Item) and Input.press?($VTP.items_key) | |
2667 | return false | |
2668 | end | |
2669 | ||
2670 | end | |
2671 | ||
2672 | #------------------------------------------------------------------------------ | |
2673 | class Scene_Item < Scene_Base | |
2674 | ||
2675 | alias vtp_sitem_start start | |
2676 | alias vtp_sitem_update_item_selection update_item_selection | |
2677 | ||
2678 | def start | |
2679 | vtp_sitem_start | |
2680 | @actor = $game_party.members[0] | |
2681 | end | |
2682 | ||
2683 | def update_item_selection | |
2684 | vtp_sitem_update_item_selection | |
2685 | if Input.press?($VTP.items_key) | |
2686 | return unless Input.trigger?(Input.dir4) | |
2687 | Sound.play_use_item | |
2688 | @actor.item_hotkeys[Input.dir4] = @item_window.item.id | |
2689 | end | |
2690 | if Input.trigger?($VTP.attack_key) | |
2691 | return if @actor.weapons[0] == nil | |
2692 | return unless @actor.weapons[0].ranged? | |
2693 | return unless @actor.weapons[0].ammo_list.include?(@item_window.item.id) | |
2694 | @actor.ammos[@actor.weapons[0].id] = @item_window.item.id | |
2695 | Sound.play_equip | |
2696 | end | |
2697 | if Input.trigger?($VTP.defend_key) | |
2698 | return unless @actor.two_swords_style | |
2699 | return if @actor.weapons[1] == nil | |
2700 | return unless @actor.weapons[1].ranged? | |
2701 | return unless @actor.weapons[1].ammo_list.include?(@item_window.item.id) | |
2702 | @actor.ammos[@actor.weapons[1].id] = @item_window.item.id | |
2703 | Sound.play_equip | |
2704 | end | |
2705 | end | |
2706 | ||
2707 | end | |
2708 | ||
2709 | #------------------------------------------------------------------------------ | |
2710 | class Scene_Skill < Scene_Base | |
2711 | ||
2712 | def update_skill_selection | |
2713 | if Input.trigger?(Input::B) | |
2714 | Sound.play_cancel | |
2715 | return_scene | |
2716 | elsif Input.trigger?(Input::C) | |
2717 | @skill = @skill_window.skill | |
2718 | if @skill != nil | |
2719 | @actor.last_skill_id = @skill.id | |
2720 | end | |
2721 | if @actor.skill_can_use?(@skill) | |
2722 | Sound.play_decision | |
2723 | determine_skill | |
2724 | else | |
2725 | Sound.play_buzzer | |
2726 | end | |
2727 | end | |
2728 | if Input.press?($VTP.skills_key) | |
2729 | return unless Input.trigger?(Input.dir4) | |
2730 | Sound.play_use_skill | |
2731 | @actor.skill_hotkeys[Input.dir4] = @skill_window.skill.id | |
2732 | end | |
2733 | end | |
2734 | ||
2735 | end | |
2736 | ||
2737 | #============================================================================== | |
2738 | # End of Verus Tempus Proelium | |
2739 | #============================================================================== |