├── LICENSE.txt ├── LeTBS.js ├── LeTBSConfig.js ├── LeTBSTurnOrderA.js ├── LeTBSWindows.js ├── LeTBS_AutoBattle.js ├── LeTBS_BattleLog.js ├── LeTBS_DamagePopupEX.js ├── LeTBS_EntityHud.js ├── LeTBS_RTPUse.js ├── LeTBS_RhymeSmoothMapScrolling.js ├── LeTBS_Summoning.js ├── LeTBS_TacticalMode.js ├── LeTBS_TilesMarksAuraEffects.js ├── LeTBS_WinConditions.js ├── LeTBS_YanflyPatch.js ├── LeUtilities.js └── README.md /LICENSE.txt: -------------------------------------------------------------------------------- 1 | TERMS OF USE 2 | 3 | Copyright (c) 2018 Lecode 4 | 5 | -Free for use in commercial and non commercial Rpg Maker MV projects with credit. 6 | -Keep the header of all my plugins. 7 | -You are allowed to edit my plugins. 8 | -Do not sell the plugins itself (even if the materials were edited, processed, or modified) 9 | as a whole or any of its parts. 10 | -Do not claim as your own work even when edited. 11 | -Contact me if you're using LeTBS in a commercial project. I want to 12 | know how my work is used. 13 | -------------------------------------------------------------------------------- /LeTBSConfig.js: -------------------------------------------------------------------------------- 1 | Lecode.S_TBS.Config = {}; 2 | 3 | 4 | /*------------------------------------------------------------------------- 5 | * Sprites Poses 6 | -------------------------------------------------------------------------*/ 7 | Lecode.S_TBS.Config.Battler_Sprites = { 8 | 9 | // Config_name: data 10 | "Default": [ 11 | // [pose_name,filename,frames] 12 | ["idle", "_idle", 3], 13 | ["dead", "_dead", 1] 14 | ], 15 | 16 | "Angela": [ 17 | ["idle", "_idle", 1], 18 | ["move", "_move", 4], 19 | ["cast", "_cast", 1], 20 | ["atk", "_atk", 4], 21 | ["hit", "_hit", 1], 22 | ["dead", "_dead", 1], 23 | ["turn_start", "_victory", 5], 24 | ["victory", "_victory", 5] 25 | ], 26 | 27 | "Duran": [ 28 | ["idle", "_idle", 1], 29 | ["move", "_move", 4], 30 | ["cast", "_cast", 3], 31 | ["atk", "_atk", 4], 32 | ["hit", "_hit", 1], 33 | ["dead", "_dead", 1] 34 | ], 35 | 36 | "Rabbit": [ 37 | ["idle", "_idle", 1], 38 | ["move", "_move", 3], 39 | ["atk", "_atk", 3], 40 | ["hit", "_hit", 1], 41 | ["dead", "_dead", 1] 42 | ], 43 | 44 | "Mago": [ 45 | ["idle", "_idle", 1], 46 | ["move", "_move", 3], 47 | ["cast", "_cast", 2], 48 | ["atk", "_atk", 4], 49 | ["hit", "_hit", 1], 50 | ["dead", "_dead", 1] 51 | ], 52 | 53 | "Evil Statue": [ 54 | ["idle", "_idle", 1], 55 | ["cast", "_cast", 3], 56 | ["atk", "_cast", 3], 57 | ["dead", "_dead", 1] 58 | ] 59 | 60 | }; 61 | 62 | /*------------------------------------------------------------------------- 63 | * Tile effects 64 | -------------------------------------------------------------------------*/ 65 | Lecode.S_TBS.Config.Tile_Effects = { 66 | 67 | 50: { 68 | "entering,turn_start,turn_end": { 69 | skill_effects: 50, 70 | play_anim: true, 71 | aoe: "circle(0)", 72 | stop_movement: true, 73 | wait: 40 74 | } 75 | }, 76 | 77 | 51: { 78 | "entering": { 79 | skill_effects: 51, 80 | play_anim: true, 81 | aoe: "circle(0)", 82 | stop_movement: true, 83 | wait: 40 84 | }, 85 | "leaving": { 86 | skill_effects: 52, 87 | play_anim: true, 88 | aoe: "circle(0)", 89 | stop_movement: false, 90 | wait: 40 91 | } 92 | }, 93 | 94 | 52: { 95 | "entering": { 96 | skill_effects: 50, 97 | play_anim: true, 98 | aoe: "circle(2)", 99 | stop_movement: true, 100 | wait: 40 101 | } 102 | }, 103 | 104 | 53: { 105 | "entering": { 106 | skill_effects: 53, 107 | play_anim: true, 108 | aoe: "circle(1)", 109 | stop_movement: true, 110 | wait: 40 111 | } 112 | } 113 | 114 | }; 115 | 116 | /*------------------------------------------------------------------------- 117 | * Marks 118 | -------------------------------------------------------------------------*/ 119 | Lecode.S_TBS.Config.Marks = { 120 | 121 | "explosive_mark": { 122 | body_anim: 139, 123 | disappearing_anim: 140, 124 | size: "square(1)", 125 | triggers: { 126 | "turn_end": { 127 | stop_movement: false, 128 | skill_effects: 32, 129 | effects_aoe: "circle(0)" 130 | } 131 | }, 132 | max: 1, 133 | duration: [3, "turn_end"] 134 | }, 135 | 136 | "volcano_cell": { 137 | body_anim: 143, 138 | size: "circle(0)", 139 | triggers: { 140 | "stepping, turn_start, turn_end": { 141 | stop_movement: false, 142 | skill_effects: 24, 143 | effects_aoe: "circle(0)" 144 | } 145 | }, 146 | duration: [3, "turn_end"] 147 | }, 148 | 149 | "magic_trap": { 150 | body_anim: 145, 151 | disappearing_anim: 146, 152 | size: "circle(0)", 153 | triggers: { 154 | "stepping": { 155 | stop_movement: true, 156 | skill_effects: 36, 157 | effects_aoe: "circle(0)" 158 | } 159 | }, 160 | max_triggers: 1, 161 | duration: [100, "turn_end"] 162 | }, 163 | 164 | "crystal_mark": { 165 | body_anim: 157, 166 | disappearing_anim: 158, 167 | size: "square(2)", 168 | triggers: { 169 | "stepping": { 170 | stop_movement: false, 171 | skill_effects: 45, 172 | effects_aoe: "circle(0)" 173 | } 174 | } 175 | }, 176 | 177 | "anti_crystal_mark": { 178 | body_anim: 160, 179 | disappearing_anim: 161, 180 | size: "square(2)", 181 | triggers: { 182 | "stepping": { 183 | stop_movement: false, 184 | skill_effects: 47, 185 | effects_aoe: "circle(0)" 186 | } 187 | } 188 | }, 189 | 190 | "mago_mark": { 191 | body_anim: 171, 192 | disappearing_anim: 172, 193 | size: "square(1)", 194 | triggers: { 195 | "turn_end": { 196 | stop_movement: false, 197 | skill_effects: 32, 198 | effects_aoe: "circle(0)" 199 | } 200 | }, 201 | max: 1, 202 | duration: [3, "turn_end"] 203 | }, 204 | 205 | }; 206 | 207 | /*------------------------------------------------------------------------- 208 | * Aura 209 | -------------------------------------------------------------------------*/ 210 | Lecode.S_TBS.Config.Aura = { 211 | 212 | "intimidating_aura": { 213 | size: "circle(1)", 214 | affect_caster: false, 215 | target_type: "enemy", 216 | states: [13], 217 | trigger_anim: 142 218 | } 219 | 220 | }; 221 | 222 | /*------------------------------------------------------------------------- 223 | * Projectiles 224 | -------------------------------------------------------------------------*/ 225 | Lecode.S_TBS.Config.Projectiles = { 226 | 227 | "bow_arrow": { 228 | filename: "Arrow", 229 | adapt_angle: true, 230 | speed: 5, 231 | jump: 150 232 | }, 233 | 234 | "ghost_arrow": { 235 | anim: [137, 36, 16], 236 | adapt_angle: true, 237 | speed: 9, 238 | jump: 0 239 | }, 240 | 241 | "fire_ball": { 242 | anim: [147, 45, 38], 243 | adapt_angle: true, 244 | speed: 9, 245 | jump: 0 246 | }, 247 | 248 | "fire_arrow": { 249 | anim: [152, 36, 16], 250 | adapt_angle: true, 251 | speed: 9, 252 | jump: 0 253 | }, 254 | 255 | "phantom_slash": { 256 | anim: [149, 56, 50], 257 | adapt_angle: true, 258 | speed: 9, 259 | jump: 0 260 | }, 261 | 262 | "great_wind": { 263 | anim: [168, 56, 50], 264 | adapt_angle: true, 265 | speed: 14, 266 | jump: 0 267 | }, 268 | 269 | }; 270 | 271 | /*------------------------------------------------------------------------- 272 | * Summons 273 | -------------------------------------------------------------------------*/ 274 | Lecode.S_TBS.Config.Summons = { 275 | 276 | "ice_block": { 277 | active: false, 278 | kind: "enemy", 279 | id: 12, 280 | body_anim: [163,164,165,166], 281 | tied_to_caster: false, 282 | stats: { 283 | mhp: "+30%" 284 | } 285 | }, 286 | 287 | "wind_spirit": { 288 | active: true, 289 | turn_order: "after_caster", 290 | visible_in_timeline: true, 291 | type: "user_playable", 292 | kind: "actor", 293 | id: 10, 294 | tied_to_caster: true, 295 | stats: { 296 | default: "90%", 297 | mhp: "70%", 298 | mmp: "+10%" 299 | } 300 | }, 301 | 302 | "pyra": { 303 | active: true, 304 | turn_order: "after_caster", 305 | visible_in_timeline: true, 306 | type: "ai_playable", 307 | kind: "enemy", 308 | id: 7, 309 | tied_to_caster: true, 310 | stats: { 311 | } 312 | }, 313 | 314 | "pixie": { 315 | active: true, 316 | turn_order: "after_caster", 317 | visible_in_timeline: true, 318 | type: "ai_playable", 319 | kind: "actor", 320 | id: 11, 321 | tied_to_caster: true, 322 | stats: { 323 | default: "90%", 324 | mhp: "60%", 325 | mmp: "+10%" 326 | } 327 | }, 328 | 329 | "fire_chicken": { 330 | active: true, 331 | turn_order: "after_caster", 332 | visible_in_timeline: true, 333 | type: "ai_playable", 334 | kind: "actor", 335 | id: 12, 336 | tied_to_caster: false, 337 | stats: { 338 | default: "90%", 339 | mhp: "15%" 340 | } 341 | }, 342 | }; 343 | 344 | /*------------------------------------------------------------------------- 345 | * Custom Scopes 346 | -------------------------------------------------------------------------*/ 347 | Lecode.S_TBS.Config.Custom_Scopes = { 348 | 349 | "fire_storm": { 350 | data: "[cx,cy-2],[cx-1,cy-1],[cx+1,cy-1],[cx-2,cy],[cx+2,cy],[cx-1,cy+1],[cx+1,cy+1],[cx,cy+2]" 351 | }, 352 | 353 | "rush": { 354 | data: "[cx+3,cy],[cx-3,cy],[cx,cy+3],[cx,cy-3]" 355 | }, 356 | 357 | "volcano_ground": { 358 | data: "[cx-2,cy-2],[cx,cy-2],[cx+2,cy-2],[cx-1,cy-1],[cx+1,cy-1],[cx-2,cy],[cx+2,cy],[cx-1,cy+1],[cx+1,cy+1],[cx-2,cy+2],[cx,cy+2],[cx+2,cy+2]" 359 | }, 360 | 361 | "fire_ball": { 362 | data: "[cx,cy+1],[cx-1,cy+2],[cx,cy+2],[cx+1,cy+2],[cx-2,cy+3],[cx-1,cy+3],[cx,cy+3],[cx+1,cy+3],[cx+2,cy+3],[cx-3,cy+4],[cx-2,cy+4],[cx-1,cy+4],[cx,cy+4],[cx+1,cy+4],[cx+2,cy+4],[cx+3,cy+4],[cx-4,cy+5],[cx-3,cy+5],[cx-2,cy+5],[cx-1,cy+5],[cx,cy+5],[cx+1,cy+5],[cx+2,cy+5],[cx+3,cy+5],[cx+4,cy+5],[cx-5,cy+6],[cx-4,cy+6],[cx-3,cy+6],[cx-2,cy+6],[cx-1,cy+6],[cx,cy+6],[cx+1,cy+6],[cx+2,cy+6],[cx+3,cy+6],[cx+4,cy+6],[cx+5,cy+6]" 363 | }, 364 | 365 | "ice_fury": { 366 | data_right: "[cx,cy],[cx+1,cy],[cx+2,cy]", 367 | data_left: "[cx-2,cy],[cx-1,cy],[cx,cy]", 368 | data_up: "[cx,cy-2],[cx,cy-1],[cx,cy]", 369 | data_down: "[cx,cy],[cx,cy+1],[cx,cy+2]" 370 | }, 371 | 372 | "fire_arrows": { 373 | data_right: "[cx+2,cy-2],[cx+1,cy-1],[cx+2,cy-1],[cx,cy],[cx+1,cy],[cx+2,cy],[cx+1,cy+1],[cx+2,cy+1],[cx+2,cy+2]", 374 | data_left: "[cx-2,cy-2],[cx-2,cy-1],[cx-1,cy-1],[cx-2,cy],[cx-1,cy],[cx,cy],[cx-2,cy+1],[cx-1,cy+1],[cx-2,cy+2]", 375 | data_up: "[cx-2,cy-2],[cx-1,cy-2],[cx,cy-2],[cx+1,cy-2],[cx+2,cy-2],[cx-1,cy-1],[cx,cy-1],[cx+1,cy-1],[cx,cy]", 376 | data_down: "[cx,cy],[cx-1,cy+1],[cx,cy+1],[cx+1,cy+1],[cx-2,cy+2],[cx-1,cy+2],[cx,cy+2],[cx+1,cy+2],[cx+2,cy+2]" 377 | }, 378 | 379 | "ice_wall": { 380 | data_right: "[cx,cy-1],[cx,cy],[cx,cy+1]", 381 | data_left: "[cx,cy-1],[cx,cy],[cx,cy+1]", 382 | data_up: "[cx-1,cy],[cx,cy],[cx+1,cy]", 383 | data_down: "[cx-1,cy],[cx,cy],[cx+1,cy]" 384 | }, 385 | 386 | "ice_prison": { 387 | data: "[cx-1,cy-1],[cx,cy-1],[cx+1,cy-1],[cx-1,cy],[cx+1,cy],[cx-1,cy+1],[cx,cy+1],[cx+1,cy+1]" 388 | } 389 | 390 | }; 391 | 392 | /*------------------------------------------------------------------------- 393 | * Sequences 394 | -------------------------------------------------------------------------*/ 395 | Lecode.S_TBS.Config.Sequences = { 396 | 397 | /*------------------------------------------------------------------------- 398 | * Events Sequences 399 | -------------------------------------------------------------------------*/ 400 | 401 | "battle_start": [ 402 | 403 | ], 404 | 405 | "turn_start": [ 406 | "play_pose: user, turn_start" 407 | ], 408 | 409 | "victory": [ 410 | "play_pose: user, victory, victory" 411 | ], 412 | 413 | "dead": [ 414 | "anim: user, collapse_anim", 415 | "play_pose: user, dead, dead", 416 | "wait: 40" 417 | //"perform_collapse: user" 418 | ], 419 | 420 | "dead_no_loop": [ 421 | "anim: user, collapse_anim", 422 | "play_pose: user, dead", 423 | "set_frame: user, dead, last", 424 | "wait: 40" 425 | ], 426 | 427 | "dead_vanish": [ 428 | "play_pose: user, dead", 429 | "anim: user, collapse_anim", 430 | "set_frame: user, dead, last", 431 | "wait: 20", 432 | "sprite_prop: user, opacity, 0" 433 | ], 434 | 435 | "revived": [ 436 | "sprite_prop: user, opacity, 255", 437 | "play_pose: user, idle, idle", 438 | ], 439 | 440 | "damaged": [ 441 | "sprite_shake: user, 6, 30", 442 | "play_pose: user, hit", 443 | "set_frame: user, hit, last", 444 | "wait: 5", 445 | "play_pose: user, idle" 446 | ], 447 | 448 | "evaded": [ 449 | 450 | ], 451 | 452 | "healed": [ 453 | 454 | ], 455 | 456 | "buffed": [ 457 | 458 | ], 459 | 460 | "weakened": [ 461 | 462 | ], 463 | 464 | /*------------------------------------------------------------------------- 465 | * Default Action Sequences 466 | -------------------------------------------------------------------------*/ 467 | 468 | "atk": [ 469 | "play_pose: user, atk", 470 | "wait: 10", 471 | "effects: {aoe}_battlers, current_obj, obj_anim", 472 | "wait: 60" 473 | ], 474 | 475 | "cast(loop)": [ 476 | "play_pose: user, cast, cast", 477 | "wait: 4", 478 | "map_anim: user_cell, 123, 0, true" 479 | ], 480 | 481 | "pre-skill": [ 482 | "call: cast(loop)", 483 | "wait: 4", 484 | "play_pose: user, atk, wait", 485 | "set_frame: user, atk, last", 486 | "wait: 2" 487 | ], 488 | 489 | "post-skill": [ 490 | "wait: 10", 491 | "play_pose: user, idle", 492 | "wait: 10" 493 | ], 494 | 495 | "skill": [ 496 | "call: pre-skill", 497 | "effects: {aoe}_battlers, current_obj, obj_anim, 0, true", 498 | "call: post-skill" 499 | ], 500 | 501 | "map_skill": [ 502 | "call: pre-skill", 503 | "map_effects: {aoe}, current_obj, obj_anim, 0, true", 504 | "call: post-skill" 505 | ], 506 | 507 | "item": [ 508 | "play_pose: user, item", 509 | "wait: 10", 510 | "effects: {aoe}_battlers, current_obj, obj_anim", 511 | "wait: 60" 512 | ], 513 | 514 | "skill_neutral": [ 515 | "play_pose: user, cast", 516 | "wait: 15", 517 | "effects: {aoe}_battlers, current_obj, obj_anim, 0, true", 518 | "play_pose: user, idle", 519 | "wait: 20" 520 | ], 521 | 522 | "map_skill_neutral": [ 523 | "play_pose: user, cast", 524 | "wait: 15", 525 | "map_effects: {aoe}, current_obj, obj_anim, 0, true", 526 | "play_pose: user, idle", 527 | "wait: 20" 528 | ], 529 | 530 | "bow": [ 531 | "play_pose: user, atk", 532 | "wait: 10", 533 | "projectile: bow_arrow, user_cell, cursor_cell", 534 | "effects: {aoe}_battlers, current_obj, obj_anim", 535 | "wait: 60" 536 | ], 537 | 538 | "projectile": [ 539 | "play_pose: user, atk", 540 | "wait: 10", 541 | "projectile: $1, user_cell, {aoe}", 542 | "effects: {aoe}_battlers, current_obj, obj_anim", 543 | "wait: 60" 544 | ], 545 | 546 | "counter": [ 547 | "anim: user, 177, 0, true", 548 | "wait: 15" 549 | ], 550 | 551 | "summon": [ 552 | "call: pre-skill", 553 | "map_anim: {aoe}, obj_anim", 554 | "wait: 15", 555 | "summon: $1, {aoe}", 556 | "call: post-skill" 557 | ], 558 | 559 | /*------------------------------------------------------------------------- 560 | * Your Sequences 561 | -------------------------------------------------------------------------*/ 562 | 563 | "repulsive_blow": [ 564 | "play_pose: user, atk", 565 | "wait: 10", 566 | "effects: {aoe}_battlers, current_obj, obj_anim", 567 | "set_speed: {aoe}_battlers, +6", 568 | "push: {aoe}_battlers, user_cell, 1", 569 | "set_speed: {aoe}_battlers, reset", 570 | "wait: 60" 571 | ], 572 | 573 | "bolt_jump": [ 574 | "set_frame: user, atk, 0", 575 | "wait: 15", 576 | "jump_to_cell: user, cursor_cell", 577 | "play_pose: user, atk", 578 | "map_effects: {aoe}-user_cell, current_obj, obj_anim" 579 | ], 580 | 581 | "rush": [ 582 | "wait: 10", 583 | "set_frame: user, atk, 0", 584 | "wait: 30", 585 | "play_pose: user, atk", 586 | "directional_anim: user, user, 131, 132, 133, 134", 587 | "look_at: user, cursor_cell", 588 | "set_speed: user, +6", 589 | "move_straight: user, 2", 590 | "set_speed: user, reset", 591 | "set_frame: user, atk, last", 592 | "wait: 12", 593 | "effects: {aoe}_battlers, current_obj, obj_anim", 594 | "wait: 20", 595 | "play_pose: user, idle", 596 | "wait: 10" 597 | ], 598 | 599 | "phantom_slash": [ 600 | "play_pose: user, atk", 601 | "wait: 10", 602 | "projectile: phantom_slash, user_cell, cursor_cell", 603 | "effects: {aoe}_battlers, current_obj, 153", 604 | "anim: user, 154", 605 | "wait: 20", 606 | "reach_target: user, {aoe}_battlers, back, true", 607 | "anim: user, 155", 608 | "look_at: user, {aoe}_battlers", 609 | "play_pose: user, atk", 610 | "wait: 10", 611 | "effects: {aoe}_battlers, current_obj, obj_anim", 612 | "wait: 60" 613 | ], 614 | 615 | //- 616 | 617 | "spark": [ 618 | "call: pre-skill", 619 | "map_anim: cursor_cell, obj_anim", 620 | "wait: 20", 621 | "effects: {aoe}_battlers, current_obj", 622 | "call: post-skill" 623 | ], 624 | 625 | "lightning_storm": [ 626 | "call: pre-skill", 627 | "call: lightning_storm_effects, 3", 628 | "call: post-skill" 629 | ], 630 | 631 | "lightning_storm_effects": [ 632 | "effects: 1_battlers_in_{aoe}, current_obj, obj_anim", 633 | "wait: 60" 634 | ], 635 | 636 | "fire_storm": [ 637 | "call: pre-skill", 638 | "call: fire_storm_effects, 6", 639 | "call: post-skill" 640 | ], 641 | 642 | "fire_storm_effects": [ 643 | "map_effects: 1_random_cells_in_{aoe}, current_obj, obj_anim", 644 | "wait: 60" 645 | ], 646 | 647 | "fire_support": [ 648 | "ask_call: fire_support_attack, {circle(1)}_allies -cursor_battler", 649 | "call: skill" 650 | ], 651 | 652 | "fire_support_attack": [ 653 | "look_at: user, cursor_cell", 654 | "call: cast(loop)", 655 | "wait: 4", 656 | "call: atk" 657 | ], 658 | 659 | "volcano_ground": [ 660 | "call: pre-skill", 661 | "map_anim: {aoe}, obj_anim", 662 | "wait: 20", 663 | "mark: volcano_cell, {aoe}", 664 | "wait: 60", 665 | "call: post-skill" 666 | ], 667 | 668 | "walking_fire": [ 669 | "call: pre-skill", 670 | "call_for_every_cell: walking_fire_dmg, {aoe}, close->far", 671 | "call: post-skill" 672 | ], 673 | 674 | "walking_fire_dmg": [ 675 | "map_anim: saved(every_cell), obj_anim", 676 | "map_effects: saved(every_cell), current_obj, obj_anim", 677 | "wait: 30" 678 | ], 679 | 680 | "ice_wall": [ 681 | "call: pre-skill", 682 | "map_anim: cursor_cell, obj_anim", 683 | "wait: 30", 684 | "summon: ice_block, {aoe}", 685 | "call: post-skill" 686 | ], 687 | 688 | "ice_prison": [ 689 | "call: pre-skill", 690 | "map_anim: cursor_cell, obj_anim", 691 | "wait: 30", 692 | "summon: ice_block, {aoe}", 693 | "call: post-skill" 694 | ], 695 | 696 | "witch_escape": [ 697 | "call: pre-skill", 698 | "anim: user, 129", 699 | "wait: 40", 700 | "save_cells: witch_escape_old, user_cell", 701 | "move_to_cell: user, cursor_cell, true", 702 | "anim: user, 130", 703 | "wait: 60", 704 | "set_cursor: saved(witch_escape_old)", 705 | "look_at: user, cursor_cell", 706 | "use_skill: user, 19" 707 | ], 708 | 709 | 710 | //- 711 | 712 | "heal": [ 713 | "call: pre-skill", 714 | "anim: {aoe}_battlers, obj_anim", 715 | "wait: 20", 716 | "effects: {aoe}_battlers, current_obj", 717 | "call: post-skill" 718 | ], 719 | 720 | "teleportation": [ 721 | "call: pre-skill", 722 | "anim: user, 129", 723 | "wait: 40", 724 | "move_to_cell: user, cursor_cell, true", 725 | "anim: user, 130", 726 | "wait: 60", 727 | "call: post-skill" 728 | ], 729 | 730 | "salvation": [ 731 | "call: pre-skill", 732 | "anim: user, obj_anim", 733 | "pull: {aoe}_all_allies-user, user_cell, 2, false", 734 | "wait: 20", 735 | "effects: {aoe}_all_allies-user, current_obj", 736 | "wait: 60", 737 | "call: post-skill" 738 | ], 739 | 740 | "teleportation_sup": [ 741 | "script: user.setDir(user._lastDir);", 742 | "call: pre-skill", 743 | "set_battler_targets: battler_toward_user", 744 | "anim: last_targets, 129", 745 | "wait: 40", 746 | "move_to_cell: last_targets, cursor_cell, true", 747 | "anim: last_targets, 130", 748 | "wait: 60", 749 | "call: post-skill" 750 | ], 751 | 752 | "explosive_mark": [ 753 | "call: pre-skill", 754 | "map_anim: cursor_cell, obj_anim", 755 | "wait: 20", 756 | "mark: explosive_mark, cursor_cell", 757 | "wait: 60", 758 | "call: post-skill" 759 | ], 760 | 761 | "ghost_arrow": [ 762 | "call: pre-skill", 763 | "projectile: ghost_arrow, user_cell, cursor_cell", 764 | "effects: {aoe}_battlers, current_obj, obj_anim", 765 | "wait: 60", 766 | "call: post-skill" 767 | ], 768 | 769 | "magic_trap": [ 770 | "call: pre-skill", 771 | "map_anim: cursor_cell, obj_anim", 772 | "wait: 20", 773 | "mark: magic_trap, cursor_cell", 774 | "wait: 60", 775 | "call: post-skill" 776 | ], 777 | 778 | "fire_arrows": [ 779 | "call: pre-skill", 780 | "call_for_every_entity: fire_arrow_dmg, {aoe}_battlers", 781 | "call: post-skill" 782 | ], 783 | 784 | "fire_arrow_dmg": [ 785 | "projectile: fire_arrow, user_cell, saved(every_entity)", 786 | "effects: saved(every_entity), current_obj, obj_anim" 787 | ], 788 | 789 | "wind_spirit": [ 790 | "call: pre-skill", 791 | "map_anim: cursor_cell, obj_anim", 792 | "wait: 15", 793 | "summon: wind_spirit, cursor_cell", 794 | "call: post-skill" 795 | ], 796 | 797 | "great_wind": [ 798 | "call: pre-skill", 799 | "projectile: great_wind, user_cell, cursor_cell", 800 | "effects: {aoe}_battlers, current_obj, obj_anim", 801 | "set_speed: {aoe}_battlers, +12", 802 | "push: {aoe}_battlers, user_cell, 3", 803 | "set_speed: {aoe}_battlers, reset", 804 | "call: post-skill" 805 | ], 806 | 807 | "transposition": [ 808 | "call: pre-skill", 809 | "anim: user, obj_anim", 810 | "anim: {aoe}_battlers, obj_anim", 811 | "wait: 40", 812 | "switch_cells: user, {aoe}_battlers", 813 | "call: post-skill" 814 | ], 815 | 816 | "summon_pixie": [ 817 | "call: pre-skill", 818 | "map_anim: cursor_cell, obj_anim", 819 | "wait: 15", 820 | "summon: pixie, cursor_cell", 821 | "call: post-skill" 822 | ], 823 | 824 | "shamanism": [ 825 | "call: pre-skill", 826 | "anim: {aoe}_dead_battlers, obj_anim", 827 | "wait: 20", 828 | "call_for_every_entity: shamanism_effects, {aoe}_dead_battlers", 829 | "call: post-skill" 830 | ], 831 | 832 | "shamanism_effects": [ 833 | "anim: allies, 127", 834 | "effects: allies, current_obj", 835 | "wait: 60", 836 | ], 837 | 838 | //- 839 | 840 | "fire_ball": [ 841 | "call: pre-skill", 842 | "projectile: fire_ball, user_cell, cursor_cell", 843 | "effects: {aoe}_battlers, current_obj, obj_anim", 844 | "wait: 60", 845 | "call: post-skill" 846 | ], 847 | 848 | "crystal_mark": [ 849 | "map_anim: cursor_cell, obj_anim", 850 | "wait: 20", 851 | "mark: crystal_mark, cursor_cell" 852 | ], 853 | 854 | "anti_crystal_mark": [ 855 | "map_anim: cursor_cell, obj_anim", 856 | "wait: 20", 857 | "mark: anti_crystal_mark, cursor_cell" 858 | ], 859 | 860 | "mago_mark": [ 861 | "call: pre-skill", 862 | "map_anim: cursor_cell, obj_anim", 863 | "wait: 20", 864 | "mark: mago_mark, cursor_cell", 865 | "wait: 60", 866 | "call: post-skill" 867 | ], 868 | 869 | "rabbit_jump": [ 870 | "set_frame: user, atk, 0", 871 | "wait: 8", 872 | "map_anim: user_cell, obj_anim", 873 | "jump_to_cell: user, cursor_cell", 874 | "play_pose: user, atk", 875 | "map_effects: user_cell, current_obj, obj_anim" 876 | ], 877 | 878 | "summon_pyra": [ 879 | "call: pre-skill", 880 | "map_anim: cursor_cell, obj_anim", 881 | "wait: 15", 882 | "summon: pyra, cursor_cell", 883 | "call: post-skill" 884 | ], 885 | 886 | //- 887 | 888 | "rush_sup": [ 889 | "wait: 20", 890 | "directional_anim: user, user, 131, 132, 133, 134", 891 | "look_at: user, cursor_cell", 892 | "move_straight: user, 2", 893 | "wait: 10", 894 | "effects: {aoe}_battlers, current_obj, obj_anim", 895 | "look_away: {aoe}_battlers, user_cell", 896 | "wait: 5", 897 | "delegate_call: rush_sup_action, {aoe}_battlers" 898 | ], 899 | 900 | "rush_sup_action": [ 901 | "directional_anim: user, user, 131, 132, 133, 134", 902 | "move_straight: user, 2", 903 | "wait: 10", 904 | "set_battler_targets: battler_toward_user", 905 | "effects: last_targets, current_obj, obj_anim", 906 | "look_away: last_targets, user_cell", 907 | "wait: 5", 908 | "end_delegated_call:", 909 | "delegate_call: rush_sup_action, last_targets" 910 | ], 911 | 912 | 913 | }; 914 | 915 | /*------------------------------------------------------------------------- 916 | * AI 917 | -------------------------------------------------------------------------*/ 918 | Lecode.S_TBS.Config.AI = { 919 | 920 | BehaviorsOrder: [ 921 | "healing", 922 | "escape", 923 | "summon", 924 | "support", 925 | "offense" // <- Keep offense at the end, for now 926 | ], 927 | 928 | "default": [ 929 | "process_behaviors", 930 | "call_behavior: end_of_turn" 931 | ], 932 | 933 | "end_of_turn": [ 934 | "wait: 5", 935 | "pass: look_closest_enemy" 936 | ], 937 | 938 | 939 | /*------------------------------------------------------------------------- 940 | * Default behaviors 941 | -------------------------------------------------------------------------*/ 942 | 943 | "use_healing": [ 944 | "search_target: self, 100%, healing", 945 | "if: !isTargetValid()", 946 | "search_target: lowest_ally, 100%, healing", 947 | "if: !isTargetValid()", 948 | "search_target: closest_ally, 100%, healing", 949 | "endif", 950 | "endif", 951 | "if: isTargetValid()", 952 | "set_action: healing, average", 953 | "move_for_action: null", 954 | "use: defined_action", 955 | "end", 956 | "call_behavior: after_healing" 957 | ], 958 | 959 | "after_healing": [ 960 | "if: user.hpRate() <= 0.3", 961 | "call_behavior: smart_move_away_enemies", 962 | "else", 963 | "call_behavior: after_offense", 964 | "endif" 965 | ], 966 | 967 | "use_support": [ 968 | "search_target: lowest_ally, 100%, support", 969 | "if: !isTargetValid()", 970 | "search_target: self, 100%, support", 971 | "if: !isTargetValid()", 972 | "search_target: closest_ally, 100%, support", 973 | "endif", 974 | "endif", 975 | "if: isTargetValid()", 976 | "set_action: support, average", 977 | "move_for_action: null", 978 | "use: defined_action", 979 | "call_behavior: after_support", 980 | "else", 981 | "move: toward_enemies, 20%", 982 | "endif" 983 | ], 984 | 985 | "after_support": [ 986 | "if: canUseEscape()", 987 | "call_behavior: escape", 988 | "else", 989 | "if: pattern('ranged_fighter')", 990 | "call_behavior: smart_move_away_enemies", 991 | "else", 992 | "move: toward_enemies, 100%", 993 | "endif", 994 | "endif" 995 | ], 996 | 997 | "use_summon": [ 998 | "if: distanceToEnemies() > entity.getMovePoints() + 1", 999 | "move: toward_enemies, 75%", 1000 | "endif", 1001 | "set_action: summon", 1002 | "move_for_action: null", 1003 | "use: defined_action", 1004 | "call_behavior: after_summon" 1005 | ], 1006 | 1007 | "after_summon": [ 1008 | "call_behavior: after_support" 1009 | ], 1010 | 1011 | "use_offense": [ 1012 | /*"if: chance(70)", 1013 | "search_target: lowest_enemy, 100%, offense", 1014 | "if: !isTargetValid()", 1015 | "search_target: closest_enemy, 100%, offense", 1016 | "endif", 1017 | "else", 1018 | "search_target: closest_enemy, 100%, offense", 1019 | "endif",*/ 1020 | "search_target: closest_enemy, 100%, offense", 1021 | "if: isTargetValid()", 1022 | "set_action: damage, average", 1023 | "move_for_action: null", 1024 | "use: defined_action", 1025 | "call_behavior: after_offense", 1026 | "else", 1027 | "script: console.log('TARGET NOT VALID')", 1028 | "move: toward_enemies, 100%", 1029 | "endif" 1030 | ], 1031 | 1032 | "cant_use_offense": [ 1033 | "if: failureCode() === 'out_of_range'", 1034 | "call_behavior: out_of_range", 1035 | "else", 1036 | "move: away_enemies, 100%", 1037 | "endif" 1038 | ], 1039 | 1040 | "after_offense": [ 1041 | "if: canUseEscape()", 1042 | "call_behavior: escape", 1043 | "else", 1044 | "if: pattern('ranged_fighter')", 1045 | "call_behavior: smart_move_away_enemies", 1046 | "else", 1047 | "if: !isInMeleeWith('defined_target')", 1048 | "move: toward_enemies, 100%", 1049 | "endif", 1050 | "endif", 1051 | "endif" 1052 | ], 1053 | 1054 | "out_of_range": [ 1055 | "if: canUseRush()", 1056 | "set_action: move, toward", 1057 | "move_for_action: null", 1058 | "use: defined_action", 1059 | "endif", 1060 | "if: chance(40)", 1061 | "move: toward_enemies, 80%", 1062 | "else", 1063 | "move: toward_enemies, 100%", 1064 | "endif" 1065 | ], 1066 | 1067 | "escape": [ 1068 | "set_action: move, away", 1069 | "move_for_action: null", 1070 | "use: defined_action", 1071 | "wait: 10", 1072 | "call_behavior: smart_move_away_enemies", 1073 | ], 1074 | 1075 | "smart_move_away_enemies": [ 1076 | "if: distanceToEnemies() >= entity.getMovePoints() * 2", 1077 | "move: toward_enemies, 75%", 1078 | "else", 1079 | "move: away_enemies, 100%", 1080 | "endif", 1081 | ] 1082 | 1083 | /*------------------------------------------------------------------------- 1084 | * Your behaviors 1085 | -------------------------------------------------------------------------*/ 1086 | }; -------------------------------------------------------------------------------- /LeTBSTurnOrderA.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # Turn Order Visual for Lecode's TBS 4 | # LeTBSTurnOrderA.js 5 | # By Lecode 6 | # Version A - 1.3 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | # - 1.2 : The visual is correctly updated when en entity is revived 16 | # - 1.3 : The tag sprite_name is correctly taken into account 17 | #============================================================================= 18 | */ 19 | var Lecode = Lecode || {}; 20 | if (!Lecode.S_TBS) 21 | throw new Error("LeTBSTurnOrder must be below LeTBS"); 22 | /*: 23 | * @plugindesc Version A Turn Order for LeTBS 24 | * @author Lecode 25 | * @version 1.3 26 | * 27 | * @help 28 | * ... 29 | */ 30 | //#============================================================================= 31 | 32 | 33 | /*------------------------------------------------------------------------- 34 | * Get Parameters 35 | -------------------------------------------------------------------------*/ 36 | var parameters = PluginManager.parameters('LeTBS'); 37 | 38 | Lecode.S_TBS.turnOrderPos = "right"; 39 | Lecode.S_TBS.turnOrderRightMargin = 20; 40 | Lecode.S_TBS.turnOrderLeftMargin = 20; 41 | Lecode.S_TBS.turnOrderTopMargin = 10; 42 | Lecode.S_TBS.turnOrderBottomMargin = 20; 43 | Lecode.S_TBS.turnOrderSize = 40; 44 | Lecode.S_TBS.turnOrderSpace = 6; 45 | Lecode.S_TBS.turnOrderSpeed = 12; 46 | 47 | /*------------------------------------------------------------------------- 48 | * TBSTurnOrderVisual 49 | -------------------------------------------------------------------------*/ 50 | TBSTurnOrderVisual.prototype.initialize = function (layer) { 51 | this._mainLayer = layer; 52 | this._order = []; 53 | this._turnOrder = []; 54 | this._activeIndex = 0; 55 | this.createVisualLayer(); 56 | this.loadBorderBitmaps(); 57 | }; 58 | 59 | TBSTurnOrderVisual.prototype.Turn = function (entity) { 60 | this.entity = entity; 61 | this.mainSprite = null; 62 | this.borderSprite = null; 63 | this.miniatureSprite = null; 64 | }; 65 | 66 | TBSTurnOrderVisual.prototype.createVisualLayer = function () { 67 | this._layer = new Sprite(); 68 | this._mainLayer.addChild(this._layer); 69 | }; 70 | 71 | TBSTurnOrderVisual.prototype.loadBorderBitmaps = function () { 72 | this._borderOn = ImageManager.loadLeTBSTurnOrder("TurnOrder__On"); 73 | this._borderAlly = ImageManager.loadLeTBSTurnOrder("TurnOrder__Actor"); 74 | this._borderEnemy = ImageManager.loadLeTBSTurnOrder("TurnOrder__Enemy"); 75 | }; 76 | 77 | TBSTurnOrderVisual.prototype.set = function (order) { 78 | this._turnOrder = []; 79 | for (var i = 0; i < order.length; i++) { 80 | var entity = order[i]; 81 | this._turnOrder.push(new this.Turn(entity)); 82 | } 83 | this._order = order; 84 | this._activeIndex = 0; 85 | this.makeSprites(); 86 | this.setPositions(); 87 | this.updateOrderState(); 88 | }; 89 | 90 | TBSTurnOrderVisual.prototype.update = function () { 91 | 92 | }; 93 | 94 | TBSTurnOrderVisual.prototype.updateOnNextTurn = function (newOrder, index) { 95 | if (this._order !== newOrder) 96 | this.set(newOrder); 97 | this._activeIndex = index; 98 | this.setPositions(); 99 | this.updateOrderState(); 100 | }; 101 | 102 | TBSTurnOrderVisual.prototype.updateOnEntityDeath = function (newOrder, index) { 103 | /*this.set(newOrder); 104 | this._activeIndex = index; 105 | this.setPositions();*/ 106 | this.updateOrderState(); 107 | }; 108 | 109 | TBSTurnOrderVisual.prototype.updateOnEntityRevive = function (newOrder, index) { 110 | this.updateOrderState(); 111 | }; 112 | 113 | TBSTurnOrderVisual.prototype.makeSprites = function () { 114 | var size = Lecode.S_TBS.turnOrderSize; 115 | while (this._layer.children.length > 0) 116 | this._layer.removeChildAt(0); 117 | for (var i = 0; i < this._turnOrder.length; i++) { 118 | var turn = this._turnOrder[i]; 119 | if (turn.mainSprite) { 120 | while (turn.mainSprite.children.length > 0) 121 | turn.mainSprite.removeChildAt(0); 122 | turn.mainSprite = null; 123 | } 124 | 125 | var entity = turn.entity; 126 | var main = new Sprite(new Bitmap(size, size)); 127 | var border = new Sprite(); 128 | var bitmap = this.getSpriteBitmap(entity); 129 | var miniature = new Sprite(bitmap); 130 | main.addChild(miniature); 131 | main.addChild(border); 132 | turn.mainSprite = main; 133 | turn.borderSprite = border; 134 | turn.miniatureSprite = miniature; 135 | this._layer.addChild(turn.mainSprite); 136 | } 137 | }; 138 | 139 | TBSTurnOrderVisual.prototype.getSpriteBitmap = function (entity) { 140 | return ImageManager.loadLeTBSTurnOrder(entity.filenameID()); 141 | }; 142 | 143 | TBSTurnOrderVisual.prototype.setPositions = function () { 144 | var pos = Lecode.S_TBS.turnOrderPos; 145 | var rightMargin = Lecode.S_TBS.turnOrderRightMargin; 146 | var leftMargin = Lecode.S_TBS.turnOrderLeftMargin; 147 | var topMargin = Lecode.S_TBS.turnOrderTopMargin; 148 | var bottomMargin = Lecode.S_TBS.turnOrderBottomMargin; 149 | var size = Lecode.S_TBS.turnOrderSize; 150 | var space = Lecode.S_TBS.turnOrderSpace; 151 | var sx, sy, dx, dy, shiftX, shiftY; 152 | switch (pos) { 153 | case "right": 154 | sx = Graphics.width - rightMargin - size; 155 | sy = topMargin; 156 | shiftX = 0; 157 | shiftY = size + space; 158 | } 159 | 160 | for (var i = 0; i < this._turnOrder.length; i++) { 161 | var sprite = this._turnOrder[i].mainSprite; 162 | sprite.x = sx + shiftX * i; 163 | sprite.y = sy + shiftY * i; 164 | } 165 | }; 166 | 167 | TBSTurnOrderVisual.prototype.updateOrderState = function () { 168 | if (this._turnOrder.length === 0) return; 169 | for (var i = 0; i < this._turnOrder.length; i++) { 170 | var turn = this._turnOrder[i]; 171 | turn.borderSprite._leU_loopFlash = false; 172 | turn.borderSprite.leU_clearFlash(); 173 | if (turn.entity._battler.isActor()) 174 | turn.borderSprite.bitmap = this._borderAlly; 175 | else 176 | turn.borderSprite.bitmap = this._borderEnemy; 177 | if (turn.entity._dead) { 178 | turn.miniatureSprite.setBlendColor([0, 0, 0, 255]); 179 | turn.borderSprite.setBlendColor([0, 0, 0, 255]); 180 | turn.mainSprite.setBlendColor([0, 0, 0, 255]); 181 | turn.mainSprite.opacity = 100; 182 | } else { 183 | turn.miniatureSprite.setBlendColor([255, 255, 255, 255]); 184 | turn.borderSprite.setBlendColor([255, 255, 255, 255]); 185 | turn.mainSprite.setBlendColor([255, 255, 255, 255]); 186 | turn.mainSprite.opacity = 255; 187 | } 188 | } 189 | 190 | var index = this._activeIndex; 191 | var sprite = this._turnOrder[index].mainSprite; 192 | var border = this._turnOrder[index].borderSprite; 193 | var size = Lecode.S_TBS.turnOrderSize; 194 | border.bitmap = this._borderOn; 195 | sprite.x -= size / 2; 196 | border._leU_loopFlash = true; 197 | border._leU_loopFlashData = { 198 | color: [255, 255, 255, 255], 199 | duration: 20 200 | }; 201 | }; 202 | -------------------------------------------------------------------------------- /LeTBSWindows.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # Windows for LeTBS 4 | # LeTBSWindows.js 5 | # By Lecode 6 | # Version A - 1.2 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | # - 1.1 : The tag sprite_name is correctly taken into account 16 | # - 1.2 : The status window is updated 17 | # - 1.3 : The command, skill and item windows can't be off the screen 18 | #============================================================================= 19 | */ 20 | var Lecode = Lecode || {}; 21 | if (!Lecode.S_TBS) 22 | throw new Error("LeTBSWindows must be below LeTBS"); 23 | Lecode.S_TBS.Windows = {}; 24 | /*: 25 | * @plugindesc (WIP)Version A Windows for LeTBS 26 | * @author Lecode 27 | * @version 1.2 28 | * 29 | * @help 30 | * ... 31 | */ 32 | //#============================================================================= 33 | 34 | 35 | /*------------------------------------------------------------------------- 36 | * Get Parameters 37 | -------------------------------------------------------------------------*/ 38 | var parameters = PluginManager.parameters('LeTBSWindows'); 39 | 40 | Lecode.S_TBS.Windows.positioningWindowFloatRange = 20; 41 | 42 | Lecode.S_TBS.Windows.hpTextColor = 2; // (): Color code of HP 43 | Lecode.S_TBS.Windows.mpTextColor = 3; // (): Color code of MP 44 | 45 | Lecode.S_TBS.Windows.statusWindowW = "270"; 46 | Lecode.S_TBS.Windows.statusWindowH = "window.fittingHeight(3);"; 47 | Lecode.S_TBS.Windows.statusWindowX = "0"; 48 | Lecode.S_TBS.Windows.statusWindowY = "Graphics.height - window.height"; 49 | Lecode.S_TBS.Windows.statusWindowSpriteBoxW = 100; 50 | Lecode.S_TBS.Windows.statusWindowSpriteBoxH = "window.lineHeight(2);"; 51 | Lecode.S_TBS.Windows.statusWindowMaxStates = 3; 52 | 53 | Lecode.S_TBS.Windows.commandWindowW = "200"; 54 | Lecode.S_TBS.Windows.commandWindowVisibleLines = "4"; 55 | Lecode.S_TBS.Windows.commands = "['Move','Attack','Skill','Item','Pass','Examine']"; 56 | Lecode.S_TBS.Windows.commandIcons = "[82,76,64,182,75,84]"; 57 | Lecode.S_TBS.Windows.commandWindowFloatRange = 20; 58 | 59 | Lecode.S_TBS.Windows.skillWindowW = "450"; 60 | Lecode.S_TBS.Windows.skillWindowH = "window.fittingHeight(4);"; 61 | Lecode.S_TBS.Windows.skillWindowFloatRange = 20; 62 | 63 | Lecode.S_TBS.Windows.itemWindowW = "300"; 64 | Lecode.S_TBS.Windows.itemWindowH = "window.fittingHeight(4);"; 65 | Lecode.S_TBS.Windows.itemWindowFloatRange = 20; 66 | 67 | Lecode.S_TBS.Windows.endCommandWindowW = "220"; 68 | Lecode.S_TBS.Windows.endCommandWindowVisibleLines = "3"; 69 | 70 | /*------------------------------------------------------------------------- 71 | * Window_TBSConfirm 72 | -------------------------------------------------------------------------*/ 73 | Window_TBSConfirm.prototype = Object.create(LeU_WindowConfirmation.prototype); 74 | Window_TBSConfirm.prototype.constructor = Window_TBSConfirm; 75 | 76 | Window_TBSConfirm.prototype.initialize = function () { 77 | LeU_WindowConfirmation.prototype.initialize.call(this); 78 | }; 79 | 80 | /*------------------------------------------------------------------------- 81 | * Window_TBSPositioning 82 | -------------------------------------------------------------------------*/ 83 | Window_TBSPositioning.prototype = Object.create(Window_Selectable.prototype); 84 | Window_TBSPositioning.prototype.constructor = Window_TBSPositioning; 85 | 86 | Window_TBSPositioning.prototype.initialize = function () { 87 | var w = this.windowWidth(); 88 | var h = this.windowHeight(); 89 | Window_Selectable.prototype.initialize.call(this, 0, 0, w, h); 90 | this._lastIndex = 0; 91 | this._disabled = {}; 92 | this._fixedIndexes = []; 93 | this.loadFaces(); 94 | }; 95 | 96 | Window_TBSPositioning.prototype.loadFaces = function () { 97 | $gameParty.members().forEach(function (actor) { 98 | ImageManager.loadFace(actor.faceName()); 99 | }); 100 | }; 101 | 102 | Window_TBSPositioning.prototype.actor = function () { 103 | return $gameParty.members()[this._index]; 104 | }; 105 | 106 | Window_TBSPositioning.prototype.selectLast = function () { 107 | this.select(this._lastIndex); 108 | }; 109 | 110 | Window_TBSPositioning.prototype.windowWidth = function () { 111 | return this.itemFrameWidth() + this.standardPadding() * 2; 112 | }; 113 | 114 | Window_TBSPositioning.prototype.windowHeight = function () { 115 | return this.fittingHeight(4 * 3); 116 | }; 117 | 118 | Window_TBSPositioning.prototype.itemFrameWidth = function () { 119 | return Window_Base._faceWidth + Window_Base._iconWidth * 5; 120 | }; 121 | 122 | Window_TBSPositioning.prototype.visibleItems = function () { 123 | return 3; 124 | }; 125 | 126 | Window_TBSPositioning.prototype.maxCols = function () { 127 | return 1; 128 | }; 129 | 130 | Window_TBSPositioning.prototype.maxItems = function () { 131 | return $gameParty.members().length; 132 | }; 133 | 134 | Window_TBSPositioning.prototype.spacing = function () { 135 | return 0; 136 | }; 137 | 138 | Window_TBSPositioning.prototype.itemWidth = function () { 139 | return this.itemFrameWidth(); 140 | }; 141 | 142 | Window_TBSPositioning.prototype.itemHeight = function () { 143 | return this.lineHeight() * 4; 144 | }; 145 | 146 | Window_TBSPositioning.prototype.disableSelection = function () { 147 | this._disabled[this._index] = true; 148 | }; 149 | 150 | Window_TBSPositioning.prototype.enableSelection = function () { 151 | this._disabled[this._index] = false; 152 | }; 153 | 154 | Window_TBSPositioning.prototype.setFixedActor = function (actor) { 155 | var i = 0; 156 | $gameParty.members().forEach(function (member) { 157 | if (member.actorId() === actor.actorId()) { 158 | this._disabled[i] = true; 159 | this._fixedIndexes.push(i); 160 | } 161 | i++; 162 | }.bind(this)); 163 | }; 164 | 165 | Window_TBSPositioning.prototype.isEnabled = function (index) { 166 | return !this._fixedIndexes.contains(index); 167 | }; 168 | 169 | Window_TBSPositioning.prototype.isCurrentItemEnabled = function () { 170 | return this.isEnabled(this.index()); 171 | }; 172 | 173 | Window_TBSPositioning.prototype.drawItem = function (index) { 174 | var actor = $gameParty.members()[index]; 175 | var rect = this.itemRect(index); 176 | var x = rect.x; 177 | var y = rect.y; 178 | var w; 179 | this.changePaintOpacity(!this._disabled[index]); 180 | this.drawActorFace(actor, x, y, Window_Base._faceWidth, Window_Base._faceHeight); 181 | x += Window_Base._faceWidth; 182 | this.drawText(actor.name(), x, y, this.contents.height); 183 | w = this.itemFrameWidth() - Window_Base._faceWidth - 2; 184 | y += this.lineHeight(); 185 | this.drawActorHp(actor, x, y, w); 186 | y += this.lineHeight(); 187 | this.drawActorMp(actor, x, y, w); 188 | y += this.lineHeight(); 189 | this.drawActorIcons(actor, x, y, Window_Base._iconWidth * 5); 190 | }; 191 | 192 | Window_TBSPositioning.prototype.drawFace = function (faceName, faceIndex, x, y, width, height) { 193 | width = width || Window_Base._faceWidth; 194 | height = height || Window_Base._faceHeight; 195 | var bitmap = ImageManager.loadFace(faceName); 196 | var pw = Window_Base._faceWidth; 197 | var ph = Window_Base._faceHeight; 198 | var sw = Math.min(width, pw); 199 | var sh = Math.min(height, ph); 200 | var dx = Math.floor(x + Math.max(width - pw, 0) / 2); 201 | var dy = Math.floor(y + Math.max(height - ph, 0) / 2); 202 | var sx = faceIndex % 4 * pw + (pw - sw) / 2; 203 | var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2; 204 | bitmap.smooth = true; 205 | this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy); 206 | }; 207 | 208 | Window_TBSPositioning.prototype._updateCursor = function () { 209 | var blinkCount = this._animationCount % 40; 210 | var cursorOpacity = 255; 211 | if (this.active) { 212 | if (blinkCount < 20) { 213 | cursorOpacity -= blinkCount * 8; 214 | } else { 215 | cursorOpacity -= (40 - blinkCount) * 8; 216 | } 217 | } 218 | this._windowCursorSprite.alpha = cursorOpacity / 255; 219 | this._windowCursorSprite.visible = this.isOpen(); 220 | }; 221 | 222 | Window_TBSPositioning.prototype.cursorUp = function (wrap) { 223 | Window_Selectable.prototype.cursorUp.call(this, wrap); 224 | if (this.index() === this.maxItems() - 1) 225 | this.callHandler("exit_up"); 226 | }; 227 | 228 | Window_TBSPositioning.prototype.processOk = function () { 229 | this._lastIndex = this.index(); 230 | Window_Selectable.prototype.processOk.call(this); 231 | }; 232 | 233 | 234 | /*------------------------------------------------------------------------- 235 | * Window_TBSPositioningConfirm 236 | -------------------------------------------------------------------------*/ 237 | Window_TBSPositioningConfirm.prototype = Object.create(Window_Command.prototype); 238 | Window_TBSPositioningConfirm.prototype.constructor = Window_TBSPositioningConfirm; 239 | 240 | Window_TBSPositioningConfirm.prototype.initialize = function (w) { 241 | this._goalWidth = w; 242 | Window_Command.prototype.initialize.call(this, 0, 0); 243 | this._enabled = false; 244 | this.deselect(); 245 | }; 246 | 247 | Window_TBSPositioningConfirm.prototype.setEnabled = function (bool) { 248 | this._enabled = !!bool; 249 | }; 250 | 251 | Window_TBSPositioningConfirm.prototype.makeCommandList = function () { 252 | this.addCommand(this.text(), 'ok', this._enabled); 253 | }; 254 | 255 | Window_TBSPositioningConfirm.prototype.text = function () { 256 | return "Start battle"; 257 | }; 258 | 259 | Window_TBSPositioningConfirm.prototype.windowWidth = function () { 260 | return this._goalWidth; 261 | }; 262 | 263 | Window_TBSPositioningConfirm.prototype.windowHeight = function () { 264 | return this.fittingHeight(1); 265 | }; 266 | 267 | Window_TBSPositioningConfirm.prototype.numVisibleRows = function () { 268 | return 1; 269 | }; 270 | 271 | Window_TBSPositioningConfirm.prototype.drawItem = function (index) { 272 | var w = this.textWidth(this.text()) + Window_Base._iconWidth + 2; 273 | var x = this.contentsWidth() / 2 - w / 2; 274 | this.changePaintOpacity(this._enabled); 275 | this.drawIcon(77, x, 0); 276 | x += Window_Base._iconWidth + 2; 277 | this.leU_drawText(this.text(), x, 0); 278 | }; 279 | 280 | Window_TBSPositioningConfirm.prototype.cursorDown = function (wrap) { 281 | Window_Command.prototype.cursorDown.call(this, wrap); 282 | this.callHandler("cursor_down"); 283 | }; 284 | 285 | Window_TBSPositioningConfirm.prototype.isCursorMovable = function () { 286 | return this.active; 287 | }; 288 | 289 | 290 | /*------------------------------------------------------------------------- 291 | * Window_TBSPositioningInfo 292 | -------------------------------------------------------------------------*/ 293 | Window_TBSPositioningInfo.prototype = Object.create(Window_Base.prototype); 294 | Window_TBSPositioningInfo.prototype.constructor = Window_TBSPositioningInfo; 295 | 296 | Window_TBSPositioningInfo.prototype.initialize = function (x, y) { 297 | var width = this.windowWidth(); 298 | var height = this.windowHeight(); 299 | Window_Base.prototype.initialize.call(this, x, y, width, height); 300 | this._battler = null; 301 | this.refresh(); 302 | this._leU_floatData = { 303 | range: [0, Lecode.S_TBS.Windows.positioningWindowFloatRange], 304 | sens: ["+", "+"], 305 | speed: 2 306 | }; 307 | }; 308 | 309 | Window_TBSPositioningInfo.prototype.windowWidth = function () { 310 | return 180; 311 | }; 312 | 313 | Window_TBSPositioningInfo.prototype.windowHeight = function () { 314 | return this.fittingHeight(3); 315 | }; 316 | 317 | Window_TBSPositioningInfo.prototype.refresh = function () { 318 | this.contents.clear(); 319 | this.resetFontSettings(); 320 | if (!this._battler) return; 321 | var x = 0; 322 | var y = 0; 323 | //- Character 324 | this.drawActorCharacter(this._battler, x, y); 325 | //- HP 326 | x = 48 + 2; 327 | this.drawIcon(84, x, y); 328 | x += 32; 329 | this.changeTextColor(this.normalColor()); 330 | this.leU_drawText(String(this._battler.hp), x, y); 331 | //- MP 332 | x = 48 + 2; 333 | y += this.lineHeight(); 334 | this.drawIcon(67, x, y); 335 | x += 32; 336 | this.changeTextColor(this.normalColor()); 337 | this.leU_drawText(String(this._battler.mp), x, y); 338 | //- TP 339 | x = 48 + 2; 340 | y += this.lineHeight(); 341 | this.drawIcon(78, x, y); 342 | x += 32; 343 | this.changeTextColor(this.normalColor()); 344 | this.leU_drawText(String(this._battler.tp), x, y); 345 | }; 346 | 347 | Window_TBSPositioningInfo.prototype.drawCharacter = function (characterName, characterIndex, x, y) { 348 | var bitmap = ImageManager.loadCharacter(characterName); 349 | var big = ImageManager.isBigCharacter(characterName); 350 | var pw = bitmap.width / (big ? 3 : 12); 351 | var ph = bitmap.height / (big ? 4 : 8); 352 | var n = characterIndex; 353 | var sx = (n % 4 * 3 + 1) * pw; 354 | var sy = (Math.floor(n / 4) * 4) * ph; 355 | this.contents.blt(bitmap, sx, sy, pw, ph, x, y); 356 | }; 357 | 358 | 359 | /*------------------------------------------------------------------------- 360 | * Window_TBSStatus 361 | -------------------------------------------------------------------------*/ 362 | Window_TBSStatus.prototype = Object.create(Window_Base.prototype); 363 | Window_TBSStatus.prototype.constructor = Window_TBSStatus; 364 | 365 | Window_TBSStatus.prototype.initialize = function () { 366 | var width = this.windowWidth(); 367 | var height = this.windowHeight(); 368 | Window_Base.prototype.initialize.call(this, 0, 0, width, height); 369 | var window = this; 370 | var x = eval(Lecode.S_TBS.Windows.statusWindowX); 371 | var y = eval(Lecode.S_TBS.Windows.statusWindowY); 372 | this.x = x; 373 | this.y = y; 374 | this._entity = null; 375 | this._sliding = false; 376 | this.refresh(); 377 | }; 378 | 379 | Window_TBSStatus.prototype.windowWidth = function () { 380 | var window = this; 381 | return eval(Lecode.S_TBS.Windows.statusWindowW); 382 | }; 383 | 384 | Window_TBSStatus.prototype.windowHeight = function () { 385 | var window = this; 386 | return eval(Lecode.S_TBS.Windows.statusWindowH); 387 | }; 388 | 389 | Window_TBSStatus.prototype.slide = function () { 390 | this._sliding = true; 391 | this.x = -this.width; 392 | }; 393 | 394 | Window_TBSStatus.prototype.update = function () { 395 | Window_Base.prototype.update.call(this); 396 | var speed = 8; 397 | var destX = eval(Lecode.S_TBS.Windows.statusWindowX); 398 | if (this._sliding) { 399 | this.x += speed; 400 | if (this.x >= destX) { 401 | this._sliding = false; 402 | this.x = destX; 403 | } 404 | } 405 | }; 406 | 407 | Window_TBSStatus.prototype.refresh = function () { 408 | this.contents.clear(); 409 | this.resetFontSettings(); 410 | if (!this._entity) return; 411 | var x, y, w, h; 412 | //- Face 413 | x = 20; 414 | y = this.lineHeight(); 415 | this.drawSprite(x, y); 416 | //- Name 417 | x = Lecode.S_TBS.Windows.statusWindowSpriteBoxW; 418 | y = 0; 419 | this.contents.fontSize += 2; 420 | this.changeTextColor(this.systemColor()); 421 | this.leU_drawText(this._entity.battler().name(), "center", y); 422 | this.contents.fontSize -= 4; 423 | //- HP and Gauge 424 | y += this.lineHeight(); 425 | this.drawActorHp(this._entity.battler(), x, y, 130); 426 | //- MP and Gauge 427 | y += this.lineHeight(); 428 | this.drawActorMp(this._entity.battler(), x, y, 130); 429 | // - States 430 | x = 2; 431 | var max = Lecode.S_TBS.Windows.statusWindowMaxStates; 432 | this.drawActorIcons(this._entity.battler(), x, y, Window_Base._iconWidth * max); 433 | }; 434 | 435 | Window_TBSStatus.prototype.drawSprite = function (x, y) { 436 | var bitmap = ImageManager.loadLeTBSStatus(this._entity.filenameID()); 437 | var window = this; 438 | bitmap.addLoadListener(function () { 439 | var dx = eval(Lecode.S_TBS.Windows.statusWindowSpriteBoxW) / 2 - bitmap.width / 2; 440 | var dy = 20 + eval(Lecode.S_TBS.Windows.statusWindowSpriteBoxH) / 2 - bitmap.height / 2; 441 | this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, dx, dy); 442 | }.bind(this)); 443 | }; 444 | 445 | 446 | /*------------------------------------------------------------------------- 447 | * Window_TBSCommand 448 | -------------------------------------------------------------------------*/ 449 | Window_TBSCommand.prototype = Object.create(Window_Command.prototype); 450 | Window_TBSCommand.prototype.constructor = Window_TBSCommand; 451 | 452 | Window_TBSCommand.prototype.initialize = function () { 453 | Window_Command.prototype.initialize.call(this, 0, 0); 454 | this.openness = 0; 455 | this.deactivate(); 456 | this._battler = null; 457 | this._entity = null; 458 | this.startFloat(); 459 | this.endFloat(); 460 | }; 461 | 462 | Window_TBSCommand.prototype.startFloat = function () { 463 | this._leU_floatData = { 464 | range: [0, Lecode.S_TBS.Windows.commandWindowFloatRange], 465 | sens: ["+", "+"], 466 | speed: 2 467 | }; 468 | }; 469 | 470 | Window_TBSCommand.prototype.endFloat = function () { 471 | this._leU_floatData.speed = 0; 472 | }; 473 | 474 | Window_TBSCommand.prototype.resumeFloat = function () { 475 | this._leU_floatData.speed = 2; 476 | }; 477 | 478 | Window_TBSCommand.prototype.windowWidth = function () { 479 | var window = this; 480 | return eval(Lecode.S_TBS.Windows.commandWindowW); 481 | }; 482 | 483 | Window_TBSCommand.prototype.numVisibleRows = function () { 484 | var window = this; 485 | return eval(Lecode.S_TBS.Windows.commandWindowVisibleLines); 486 | }; 487 | 488 | Window_TBSCommand.prototype.makeCommandList = function () { 489 | var window = this; 490 | if (this._battler) { 491 | var array = eval(Lecode.S_TBS.Windows.commands); 492 | array.forEach(function (com) { 493 | eval("window.add" + com + "Command();"); 494 | }.bind(this)); 495 | } 496 | }; 497 | 498 | Window_TBSCommand.prototype.addAttackCommand = function () { 499 | this.addCommand(TextManager.attack, 'attack', this._entity.canAttackCommand()); 500 | }; 501 | 502 | Window_TBSCommand.prototype.addSkillCommand = function () { 503 | this.addSkillCommands(); 504 | }; 505 | 506 | Window_TBSCommand.prototype.addSkillCommands = function () { 507 | var skillTypes = this._battler.addedSkillTypes(); 508 | skillTypes.sort(function (a, b) { 509 | return a - b; 510 | }); 511 | skillTypes.forEach(function (stypeId) { 512 | var name = $dataSystem.skillTypes[stypeId]; 513 | this.addCommand(name, 'skill', this._entity.canSkillCommand(), stypeId); 514 | }, this); 515 | }; 516 | 517 | Window_TBSCommand.prototype.addGuardCommand = function () { 518 | this.addCommand(TextManager.guard, 'guard', this._entity.canGuard()); 519 | }; 520 | 521 | Window_TBSCommand.prototype.addItemCommand = function () { 522 | this.addCommand(TextManager.item, 'item', this._entity.canItemCommand()); 523 | }; 524 | 525 | Window_TBSCommand.prototype.addMoveCommand = function () { 526 | this.addCommand("Move", "move", this._entity.canMoveCommand()); 527 | }; 528 | 529 | Window_TBSCommand.prototype.addPassCommand = function () { 530 | this.addCommand("Pass", "pass"); 531 | }; 532 | 533 | Window_TBSCommand.prototype.addExamineCommand = function () { 534 | this.addCommand("Examine", "examine"); 535 | }; 536 | 537 | Window_TBSCommand.prototype.setup = function (actor, entity) { 538 | this._battler = actor; 539 | this._entity = entity; 540 | this.clearCommandList(); 541 | this.makeCommandList(); 542 | this.refresh(); 543 | this.selectLast(); 544 | this.activate(); 545 | this.show(); 546 | this.open(); 547 | }; 548 | 549 | Window_TBSCommand.prototype.update = function () { 550 | Window_Command.prototype.update.call(this); 551 | if (this._entity) { 552 | var x = this._entity._posX - this.windowWidth() / 2; 553 | var y = this._entity._posY - this.windowHeight(); 554 | this.x = x + this._entity.width() / 2; 555 | this.y = y; 556 | if (this.y < 0) 557 | this.y += this.windowHeight(); 558 | while (this.x < 0) 559 | this.x++; 560 | while ((this.x + this.width) > Graphics.width) 561 | this.x--; 562 | } 563 | }; 564 | 565 | Window_TBSCommand.prototype.processOk = function () { 566 | if (this._battler) { 567 | if (ConfigManager.commandRemember) { 568 | this._battler.setLastCommandSymbol(this.currentSymbol()); 569 | } else { 570 | this._battler.setLastCommandSymbol(''); 571 | } 572 | } 573 | Window_Command.prototype.processOk.call(this); 574 | }; 575 | 576 | Window_TBSCommand.prototype.selectLast = function () { 577 | this.select(0); 578 | if (this._battler && ConfigManager.commandRemember) { 579 | this.selectSymbol(this._battler.lastCommandSymbol()); 580 | } 581 | }; 582 | 583 | Window_TBSCommand.prototype.drawItem = function (index) { 584 | var rect = this.itemRectForText(index); 585 | var align = this.itemTextAlign(); 586 | this.resetTextColor(); 587 | this.changePaintOpacity(this.isCommandEnabled(index)); 588 | this.drawIcon(this.commandIcon(index), rect.x, rect.y + 2); 589 | rect.x += Window_Base._iconWidth + 2; 590 | this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align); 591 | }; 592 | 593 | Window_TBSCommand.prototype.commandIcon = function (index) { 594 | var array = eval(Lecode.S_TBS.Windows.commandIcons); 595 | return array[index]; 596 | }; 597 | 598 | /*------------------------------------------------------------------------- 599 | * Window_TBSSkillList 600 | -------------------------------------------------------------------------*/ 601 | function Window_TBSSkillList() { 602 | this.initialize.apply(this, arguments); 603 | } 604 | Window_TBSSkillList.prototype = Object.create(Window_BattleSkill.prototype); 605 | Window_TBSSkillList.prototype.constructor = Window_TBSSkillList; 606 | 607 | Window_TBSSkillList.prototype.initialize = function () { 608 | var w = this.windowWidth(); 609 | var h = this.windowHeight(); 610 | Window_BattleSkill.prototype.initialize.call(this, 0, 0, w, h); 611 | this._entity = null; 612 | }; 613 | 614 | Window_TBSSkillList.prototype.includes = function (item) { 615 | return item; 616 | }; 617 | 618 | Window_TBSSkillList.prototype.windowWidth = function () { 619 | var window = this; 620 | return eval(Lecode.S_TBS.Windows.skillWindowW); 621 | }; 622 | 623 | Window_TBSSkillList.prototype.windowHeight = function () { 624 | var window = this; 625 | return eval(Lecode.S_TBS.Windows.skillWindowH); 626 | }; 627 | 628 | Window_TBSSkillList.prototype.maxCols = function () { 629 | return 1; 630 | }; 631 | 632 | Window_TBSSkillList.prototype.update = function () { 633 | Window_BattleSkill.prototype.update.call(this); 634 | if (this._entity) { 635 | var x = this._entity._posX - this.windowWidth() / 2; 636 | var y = this._entity._posY - this.windowHeight(); 637 | this.x = x + this._entity.width() / 2; 638 | this.y = y; 639 | if (this.y < 0) 640 | this.y += this.windowHeight(); 641 | while (this.x < 0) 642 | this.x++; 643 | while ((this.x + this.width) > Graphics.width) 644 | this.x--; 645 | } 646 | }; 647 | 648 | /*------------------------------------------------------------------------- 649 | * Window_TBSItemList 650 | -------------------------------------------------------------------------*/ 651 | function Window_TBSItemList() { 652 | this.initialize.apply(this, arguments); 653 | } 654 | Window_TBSItemList.prototype = Object.create(Window_BattleItem.prototype); 655 | Window_TBSItemList.prototype.constructor = Window_TBSItemList; 656 | 657 | Window_TBSItemList.prototype.initialize = function () { 658 | var w = this.windowWidth(); 659 | var h = this.windowHeight(); 660 | Window_BattleItem.prototype.initialize.call(this, 0, 0, w, h); 661 | this._entity = null; 662 | }; 663 | 664 | Window_TBSItemList.prototype.windowWidth = function () { 665 | var window = this; 666 | return eval(Lecode.S_TBS.Windows.itemWindowW); 667 | }; 668 | 669 | Window_TBSItemList.prototype.windowHeight = function () { 670 | var window = this; 671 | return eval(Lecode.S_TBS.Windows.itemWindowH); 672 | }; 673 | 674 | Window_TBSItemList.prototype.maxCols = function () { 675 | return 1; 676 | }; 677 | 678 | Window_TBSItemList.prototype.update = function () { 679 | Window_ItemList.prototype.update.call(this); 680 | if (this._entity) { 681 | var x = this._entity._posX - this.windowWidth() / 2; 682 | var y = this._entity._posY - this.windowHeight(); 683 | this.x = x + this._entity.width() / 2; 684 | this.y = y; 685 | if (this.y < 0) 686 | this.y += this.windowHeight(); 687 | while (this.x < 0) 688 | this.x++; 689 | while ((this.x + this.width) > Graphics.width) 690 | this.x--; 691 | } 692 | }; 693 | 694 | 695 | /*------------------------------------------------------------------------- 696 | * Window_TBSEndCommand 697 | -------------------------------------------------------------------------*/ 698 | Window_TBSEndCommand.prototype = Object.create(Window_Command.prototype); 699 | Window_TBSEndCommand.prototype.constructor = Window_TBSEndCommand; 700 | 701 | Window_TBSEndCommand.prototype.initialize = function () { 702 | var x = Graphics.width / 2 - this.windowWidth() / 2; 703 | var y = Graphics.height / 2 - this.windowHeight() / 2; 704 | Window_Command.prototype.initialize.call(this, x, y); 705 | this.openness = 0; 706 | this.deactivate(); 707 | }; 708 | 709 | Window_TBSEndCommand.prototype.windowWidth = function () { 710 | var window = this; 711 | return eval(Lecode.S_TBS.Windows.endCommandWindowW); 712 | }; 713 | 714 | Window_TBSEndCommand.prototype.numVisibleRows = function () { 715 | var window = this; 716 | return eval(Lecode.S_TBS.Windows.endCommandWindowVisibleLines); 717 | }; 718 | 719 | Window_TBSEndCommand.prototype.makeCommandList = function () { 720 | this.addCommand("Options", "options", false); 721 | this.addCommand("Escape", "escape", BattleManager.canEscape()); 722 | }; -------------------------------------------------------------------------------- /LeTBS_AutoBattle.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Auto Battle Mode 4 | # LeTBS_AutoBattle.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Imported = Imported || {}; 18 | Imported.LeTBS_AutoMode = true; 19 | 20 | var Lecode = Lecode || {}; 21 | Lecode.S_TBS.AutoMode = {}; 22 | /*: 23 | * @plugindesc Add an auto battle mode 24 | * @author Lecode 25 | * @version 1.0 26 | * 27 | * 28 | * @param Command Text 29 | * @desc ... 30 | * @default Auto Battle 31 | * 32 | * @param Input 33 | * @desc Touch to activate/deactivate auto mode 34 | * @default tab 35 | * 36 | * 37 | * @help 38 | * See the documentation 39 | */ 40 | //#============================================================================= 41 | 42 | 43 | /*------------------------------------------------------------------------- 44 | * Get Parameters 45 | -------------------------------------------------------------------------*/ 46 | var parameters = PluginManager.parameters('LeTBS_AutoBattle'); 47 | 48 | Lecode.S_TBS.AutoMode.commandText = String(parameters["Command Text"] || "Auto Battle"); 49 | Lecode.S_TBS.AutoMode.input = String(parameters["Input"] || "tab"); // (): Touch to activate/deactivate auto mode 50 | 51 | 52 | /*------------------------------------------------------------------------- 53 | * Window_TBSEndCommand 54 | -------------------------------------------------------------------------*/ 55 | Lecode.S_TBS.AutoMode.oldWindowTBSEndCommand_makeCommandList = Window_TBSEndCommand.prototype.makeCommandList; 56 | Window_TBSEndCommand.prototype.makeCommandList = function () { 57 | Lecode.S_TBS.AutoMode.oldWindowTBSEndCommand_makeCommandList.call(this); 58 | this.addCommand(Lecode.S_TBS.AutoMode.commandText, "auto_mode", true); 59 | }; 60 | 61 | 62 | /*------------------------------------------------------------------------- 63 | * Scene_Battle 64 | -------------------------------------------------------------------------*/ 65 | Lecode.S_TBS.AutoMode.oldSB_createAllWindows = Scene_Battle.prototype.createAllWindows; 66 | Scene_Battle.prototype.createAllWindows = function () { 67 | Lecode.S_TBS.AutoMode.oldSB_createAllWindows.call(this); 68 | if (Lecode.S_TBS.commandOn) { 69 | this.createAutoModeWindow(); 70 | } 71 | }; 72 | 73 | Scene_Battle.prototype.createAutoModeWindow = function () { 74 | this._windowAutoMode = new Window_TBSAutoMode(); 75 | this._windowAutoMode.hide(); 76 | this.addWindow(this._windowAutoMode); 77 | }; 78 | 79 | Lecode.S_TBS.AutoMode.oldSB_createEndCommandWindow = Scene_Battle.prototype.createEndCommandWindow; 80 | Scene_Battle.prototype.createEndCommandWindow = function () { 81 | Lecode.S_TBS.AutoMode.oldSB_createEndCommandWindow.call(this); 82 | this._windowEndCommand.setHandler('auto_mode', this.setAutoMode.bind(this)); 83 | }; 84 | 85 | Scene_Base.prototype.setAutoMode = function () { 86 | BattleManagerTBS._autoModePending = !BattleManagerTBS._autoModePending; 87 | if (BattleManagerTBS._autoModePending) { 88 | this._windowAutoMode.show(); 89 | } else { 90 | this._windowAutoMode.hide(); 91 | } 92 | this._windowEndCommand.activate(); 93 | this._windowAutoMode.refresh(); 94 | }; 95 | 96 | Lecode.S_TBS.AutoMode.oldSB_start = Scene_Battle.prototype.start; 97 | Scene_Battle.prototype.start = function () { 98 | Lecode.S_TBS.AutoMode.oldSB_start.call(this); 99 | if (Lecode.S_TBS.commandOn) { 100 | if (BattleManagerTBS._autoModePending) { 101 | BattleManagerTBS._autoModePending = false; 102 | this.setAutoMode(); 103 | } 104 | } 105 | }; 106 | 107 | 108 | /*------------------------------------------------------------------------- 109 | * TBSEntity 110 | -------------------------------------------------------------------------*/ 111 | Lecode.S_TBS.AutoMode.oldTBSEntity_playableByAI = TBSEntity.prototype.playableByAI; 112 | TBSEntity.prototype.playableByAI = function () { 113 | if (BattleManagerTBS._autoMode) return true; 114 | return Lecode.S_TBS.AutoMode.oldTBSEntity_playableByAI.call(this); 115 | }; 116 | 117 | 118 | /*------------------------------------------------------------------------- 119 | * Window_TBSAutoMode 120 | -------------------------------------------------------------------------*/ 121 | function Window_TBSAutoMode() { 122 | this.initialize.apply(this, arguments); 123 | } 124 | Window_TBSAutoMode.prototype = Object.create(Window_Base.prototype); 125 | Window_TBSAutoMode.prototype.constructor = Window_TBSAutoMode; 126 | 127 | Window_TBSAutoMode.prototype.initialize = function () { 128 | var width = this.windowWidth(); 129 | var height = this.windowHeight(); 130 | Window_Base.prototype.initialize.call(this, 0, 0, width, height); 131 | this.x = Graphics.width - width; 132 | this.y = Graphics.height - height; 133 | this.opacity = 0; 134 | this.contentsOpacity = 175; 135 | }; 136 | 137 | Window_TBSAutoMode.prototype.windowWidth = function () { 138 | return 300; 139 | }; 140 | 141 | Window_TBSAutoMode.prototype.windowHeight = function () { 142 | return this.fittingHeight(1); 143 | }; 144 | 145 | Window_TBSAutoMode.prototype.refresh = function () { 146 | this.contents.clear(); 147 | this.resetFontSettings(); 148 | var text = BattleManagerTBS._autoMode ? "Auto Mode ON" : (BattleManagerTBS._autoModePending ? "Pending Auto Mode" : ""); 149 | this.leU_drawText(text, "center", 0); 150 | }; 151 | 152 | 153 | /*------------------------------------------------------------------------- 154 | * BattleManagerTBS 155 | -------------------------------------------------------------------------*/ 156 | Lecode.S_TBS.AutoMode.oldBattleManagerTBS_turnEnd = BattleManagerTBS.turnEnd; 157 | BattleManagerTBS.turnEnd = function() { 158 | Lecode.S_TBS.AutoMode.oldBattleManagerTBS_turnEnd.call(this); 159 | this._autoMode = !!this._autoModePending; 160 | LeUtilities.getScene()._windowAutoMode.refresh(); 161 | }; 162 | 163 | Lecode.S_TBS.AutoMode.oldBattleManagerTBS_startTurn = BattleManagerTBS.startTurn; 164 | BattleManagerTBS.startTurn = function() { 165 | Lecode.S_TBS.AutoMode.oldBattleManagerTBS_startTurn.call(this); 166 | this._autoMode = !!this._autoModePending; 167 | LeUtilities.getScene()._windowAutoMode.refresh(); 168 | }; 169 | 170 | Lecode.S_TBS.AutoMode.oldBattleManagerTBS_stopBattle = BattleManagerTBS.stopBattle; 171 | BattleManagerTBS.stopBattle = function() { 172 | Lecode.S_TBS.AutoMode.oldBattleManagerTBS_stopBattle.call(this); 173 | LeUtilities.getScene()._windowAutoMode.hide(); 174 | }; 175 | 176 | 177 | /*------------------------------------------------------------------------- 178 | * InputHandlerTBS 179 | -------------------------------------------------------------------------*/ 180 | Lecode.S_TBS.AutoMode.oldInputHandlerTBS_update = InputHandlerTBS.update; 181 | InputHandlerTBS.update = function () { 182 | if (!this.isActive()) return; 183 | if (BattleManagerTBS.isWaiting()) return; 184 | 185 | if (Input.isTriggered(Lecode.S_TBS.AutoMode.input)) { 186 | LeUtilities.getScene().setAutoMode(); 187 | } 188 | Lecode.S_TBS.AutoMode.oldInputHandlerTBS_update.call(this); 189 | }; -------------------------------------------------------------------------------- /LeTBS_BattleLog.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # BattleLog Support for LeTBS 4 | # LeTBS_BattleLog.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Lecode = Lecode || {}; 18 | Lecode.S_TBS.LogWin = {}; 19 | /*: 20 | * @plugindesc BattleLog Support for LeTBS 21 | * @author Lecode 22 | * @version 1.0 23 | * 24 | * @help 25 | * ... 26 | */ 27 | //#============================================================================= 28 | 29 | 30 | /*------------------------------------------------------------------------- 31 | * Get Parameters 32 | -------------------------------------------------------------------------*/ 33 | var parameters = PluginManager.parameters('LeTBS'); 34 | 35 | Lecode.S_TBS.LogWin.useEXVersion = false; 36 | 37 | 38 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_onNewTurnOrder = BattleManagerTBS.onNewTurnOrder; 39 | BattleManagerTBS.onNewTurnOrder = function () { 40 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_onNewTurnOrder.call(this); 41 | this._logWindow.startTurn(); 42 | }; 43 | 44 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_processAction = BattleManagerTBS.processAction; 45 | BattleManagerTBS.processAction = function () { 46 | this._logWindow.push('pushBaseLine'); 47 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_processAction.call(this); 48 | var subject = this.activeEntity().battler(); 49 | this._logWindow.displayAction(subject, this.activeAction().item()); 50 | this._logWindow.push('popBaseLine'); 51 | }; 52 | 53 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_invokeObjEffects = BattleManagerTBS.invokeObjEffects; 54 | BattleManagerTBS.invokeObjEffects = function (user, item, targets, hitAnim, animDelay) { 55 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_invokeObjEffects.call(this, user, item, targets, hitAnim, animDelay); 56 | targets.forEach(function (target) { 57 | this._logWindow.displayActionResults(user.battler(),target.battler()); 58 | }.bind(this)); 59 | }; 60 | 61 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_invokeObjEffectsOnMap = BattleManagerTBS.invokeObjEffectsOnMap; 62 | BattleManagerTBS.invokeObjEffectsOnMap = function (user, item, cellTargets, hitAnim, animDelay) { 63 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_invokeObjEffectsOnMap.call(this, user, item, cellTargets, hitAnim, animDelay); 64 | cellTargets.forEach(function (cell) { 65 | var target = cell.getEntity(); 66 | if (target) 67 | this._logWindow.displayActionResults(user.battler(),target.battler()); 68 | }.bind(this)); 69 | }; 70 | 71 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_onActionEnd = BattleManagerTBS.onActionEnd; 72 | BattleManagerTBS.onActionEnd = function() { 73 | Lecode.S_TBS.LogWin.oldBattleManagerTBS_onActionEnd.call(this); 74 | this._logWindow.clear(); 75 | }; -------------------------------------------------------------------------------- /LeTBS_DamagePopupEX.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Damage Popup EX 4 | # LeTBS_DamagePopupEX.js 5 | # By Lecode 6 | # Version 1.1 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | # - 1.1 : Support move points popup 16 | #============================================================================= 17 | */ 18 | var Imported = Imported || {}; 19 | Imported["LeTBS_DamagePopupEX"] = true; 20 | 21 | var Lecode = Lecode || {}; 22 | Lecode.S_TBS.DamagePopupEX = {}; 23 | /*: 24 | * @plugindesc Improve popups and show states alterations 25 | * @author Lecode 26 | * @version 1.1 27 | * 28 | * @help 29 | * ... 30 | */ 31 | //#============================================================================= 32 | 33 | 34 | /*------------------------------------------------------------------------- 35 | * Get Parameters 36 | -------------------------------------------------------------------------*/ 37 | Lecode.S_TBS.DamagePopupEX.shiftY = 34; 38 | 39 | 40 | 41 | /*------------------------------------------------------------------------- 42 | * TBSEntity 43 | -------------------------------------------------------------------------*/ 44 | TBSEntity.prototype.prepareExtraPopups = function () { 45 | var sprite = this._sprite; 46 | sprite._popupsInfo.movePoints = this.getMovePoints(); 47 | }; 48 | 49 | Lecode.S_TBS.DamagePopupEX.oldTBSEntity_onTurnEnd = TBSEntity.prototype.onTurnEnd; 50 | TBSEntity.prototype.onTurnEnd = function () { 51 | this.prepareExtraPopups(); 52 | Lecode.S_TBS.DamagePopupEX.oldTBSEntity_onTurnEnd.call(this); 53 | }; 54 | 55 | /*------------------------------------------------------------------------- 56 | * TBSEntity_Sprite 57 | -------------------------------------------------------------------------*/ 58 | Lecode.S_TBS.DamagePopupEX.oldTBSEntitySprite_initialize = TBSEntity_Sprite.prototype.initialize; 59 | TBSEntity_Sprite.prototype.initialize = function (battler, entity) { 60 | Lecode.S_TBS.DamagePopupEX.oldTBSEntitySprite_initialize.call(this, battler, entity); 61 | this._popupsInfo = {}; 62 | }; 63 | 64 | Lecode.S_TBS.DamagePopupEX.oldTBSEntitySprite_addPopup = TBSEntity_Sprite.prototype.addPopup; 65 | TBSEntity_Sprite.prototype.addPopup = function () { 66 | var result = this._battler.result(); 67 | this.shiftPreviousPopups(); 68 | Lecode.S_TBS.DamagePopupEX.oldTBSEntitySprite_addPopup.call(this); 69 | var addedStates = result.addedStateObjects(); 70 | var removedStates = result.removedStateObjects(); 71 | var diffMovePts = this._popupsInfo.movePoints ? this._entity.getMovePoints() - this._popupsInfo.movePoints : 0; 72 | if (diffMovePts !== 0) 73 | this.addExtraPopup("movePoints", [diffMovePts]); 74 | while (addedStates.length > 0) { 75 | this.addExtraPopup("addedState", [addedStates.shift()]); 76 | } 77 | while (removedStates.length > 0) { 78 | this.addExtraPopup("removedState", [removedStates.shift()]); 79 | } 80 | this._popupsInfo.movePoints = this._entity.getMovePoints(); 81 | }; 82 | 83 | TBSEntity_Sprite.prototype.addExtraPopup = function (type, args) { 84 | this.shiftPreviousPopups(); 85 | var sprite = new Sprite_Damage(); 86 | sprite.x = this.x + this.width / 2; 87 | sprite.y = this.y; 88 | sprite.extraSetup(type, args); 89 | this._popups.push(sprite); 90 | BattleManagerTBS.getLayer("movableInfo").addChild(sprite); 91 | }; 92 | 93 | TBSEntity_Sprite.prototype.shiftPreviousPopups = function (sign) { 94 | sign = 1 || sign; 95 | if (!this._popups.length > 0) return; 96 | var delta = Math.abs(this._popups[0].y - this.y); 97 | var shift = delta > Lecode.S_TBS.DamagePopupEX.shiftY ? 0 : Lecode.S_TBS.DamagePopupEX.shiftY; 98 | for (var i = 0; i < this._popups.length; i++) { 99 | var popup = this._popups[i]; 100 | popup.y -= shift * sign; 101 | } 102 | }; 103 | 104 | 105 | /*------------------------------------------------------------------------- 106 | * Sprite_Damage 107 | -------------------------------------------------------------------------*/ 108 | Lecode.S_TBS.DamagePopupEX.oldSpriteDamage_setup = Sprite_Damage.prototype.setup; 109 | Sprite_Damage.prototype.setup = function (target) { 110 | Lecode.S_TBS.DamagePopupEX.oldSpriteDamage_setup.call(this, target); 111 | if (this.children.length === 0) 112 | this._duration = 0; 113 | }; 114 | 115 | Sprite_Damage.prototype.extraSetup = function (type, args) { 116 | if (type === "addedState") 117 | this.createAddedStates(args[0]); 118 | else if (type === "removedState") 119 | this.createRemovedStates(args[0]); 120 | else if (type === "movePoints") 121 | this.createMovePoints(args[0]); 122 | }; 123 | 124 | Sprite_Damage.prototype.createAddedStates = function (state) { 125 | var text = "+"; 126 | var textW = this._damageBitmap.measureTextWidth(text); 127 | var w = Window_Base._iconWidth + 2 + textW; 128 | var h = Window_Base._iconHeight; 129 | var sprite = this.createExtraChildSprite(w, h); 130 | this.drawIcon(sprite, state.iconIndex, 0, 0); 131 | var y = h / 2 - sprite.bitmap.fontSize / 2; 132 | this.drawText(sprite, text, Window_Base._iconWidth + 2, y, w); 133 | }; 134 | 135 | Sprite_Damage.prototype.createRemovedStates = function (state) { 136 | var text = "-"; 137 | var textW = this._damageBitmap.measureTextWidth(text); 138 | var w = Window_Base._iconWidth + 2 + textW; 139 | var h = Window_Base._iconHeight; 140 | var sprite = this.createExtraChildSprite(w, h); 141 | this.drawIcon(sprite, state.iconIndex, 0, 0); 142 | var y = h / 2 - sprite.bitmap.fontSize / 2; 143 | this.drawText(sprite, text, Window_Base._iconWidth + 2, y, w); 144 | }; 145 | 146 | Sprite_Damage.prototype.createMovePoints = function (value) { 147 | var text = value < 0 ? "-" : "+"; 148 | var textW = this._damageBitmap.measureTextWidth(text); 149 | this.createDigits(0, value); 150 | var digits = this.children[this.children.length-1]; 151 | var w = textW + digits.width + 2; 152 | var h = digits.height; 153 | var sprite = this.createExtraChildSprite(w, h); 154 | sprite.dy = 1; 155 | sprite.x = - this.digitWidth() * 0.8; 156 | var y = h / 2 - sprite.bitmap.fontSize / 2; 157 | var x = textW; 158 | this.drawText(sprite, text, 12, y, w); 159 | this._flashColor = [175, 175, 0, 160]; 160 | this._flashDuration = 90; 161 | 162 | }; 163 | 164 | Sprite_Damage.prototype.createExtraChildSprite = function (w, h) { 165 | var sprite = new Sprite(); 166 | sprite.bitmap = new Bitmap(w, h); 167 | sprite.anchor.x = 0.5; 168 | sprite.anchor.y = 1; 169 | sprite.y = -40; 170 | sprite.ry = sprite.y; 171 | sprite.dy = 0; 172 | this.addChild(sprite); 173 | return sprite; 174 | }; 175 | 176 | Sprite_Damage.prototype.drawText = function (sprite, text, x, y, maxWidth, align, color) { 177 | if (color) 178 | sprite.bitmap.textColor = color; 179 | sprite.bitmap.drawText(text, x, y, maxWidth, 28, align); 180 | }; 181 | 182 | Sprite_Damage.prototype.drawIcon = function (sprite, iconIndex, x, y) { 183 | var bitmap = ImageManager.loadSystem('IconSet'); 184 | var pw = Window_Base._iconWidth; 185 | var ph = Window_Base._iconHeight; 186 | var sx = iconIndex % 16 * pw; 187 | var sy = Math.floor(iconIndex / 16) * ph; 188 | sprite.bitmap.blt(bitmap, sx, sy, pw, ph, x, y); 189 | }; 190 | -------------------------------------------------------------------------------- /LeTBS_EntityHud.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Entity Hud 4 | # LeTBS_EntityHud.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Lecode = Lecode || {}; 18 | Lecode.S_TBS.EntityHud = {}; 19 | /*: 20 | * @plugindesc Draw a mini hud for each entity 21 | * @author Lecode 22 | * @version 1.0 23 | * 24 | * @help 25 | * ... 26 | */ 27 | //#============================================================================= 28 | 29 | /*------------------------------------------------------------------------- 30 | * Get Parameters 31 | -------------------------------------------------------------------------*/ 32 | var parameters = PluginManager.parameters('LeTBS_EntityHud'); 33 | 34 | 35 | 36 | 37 | /*------------------------------------------------------------------------- 38 | * TBSEntity 39 | -------------------------------------------------------------------------*/ 40 | Lecode.S_TBS.EntityHud.oldTBSEntity_createComponents = TBSEntity.prototype.createComponents; 41 | TBSEntity.prototype.createComponents = function () { 42 | Lecode.S_TBS.EntityHud.oldTBSEntity_createComponents.call(this); 43 | this._miniHud = new Window_TBSEntityHud(this); 44 | BattleManagerTBS.getLayer("movableInfo").addChild(this._miniHud); 45 | }; 46 | 47 | Lecode.S_TBS.EntityHud.oldTBSEntity_update = TBSEntity.prototype.update; 48 | TBSEntity.prototype.update = function() { 49 | Lecode.S_TBS.EntityHud.oldTBSEntity_update.call(this); 50 | this._miniHud.updatePosition(); 51 | }; 52 | 53 | Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOver = TBSEntity.prototype.onMouseOver; 54 | TBSEntity.prototype.onMouseOver = function () { 55 | Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOver.call(this); 56 | this.showMiniHud(); 57 | }; 58 | 59 | Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOut = TBSEntity.prototype.onMouseOut; 60 | TBSEntity.prototype.onMouseOut = function () { 61 | Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOut.call(this); 62 | this.hideMiniHud(); 63 | }; 64 | 65 | Lecode.S_TBS.EntityHud.oldTBSEntity_onTurnEnd = TBSEntity.prototype.onTurnEnd; 66 | TBSEntity.prototype.onTurnEnd = function () { 67 | Lecode.S_TBS.EntityHud.oldTBSEntity_onTurnEnd.call(this); 68 | this._miniHud.refresh(); 69 | }; 70 | 71 | Lecode.S_TBS.EntityHud.oldTBSEntity_onDamage = TBSEvent.prototype.onDamage; 72 | TBSEvent.prototype.onDamage = function () { 73 | Lecode.S_TBS.EntityHud.oldTBSEntity_onDamage.call(this); 74 | this._miniHud.refresh(); 75 | }; 76 | 77 | TBSEntity.prototype.showMiniHud = function () { 78 | this._miniHud.contentsOpacity = 255; 79 | this._miniHud.refresh(); 80 | }; 81 | 82 | TBSEntity.prototype.hideMiniHud = function () { 83 | this._miniHud.contentsOpacity = 0; 84 | }; 85 | 86 | 87 | /*------------------------------------------------------------------------- 88 | * Window_TBSEntityHud 89 | -------------------------------------------------------------------------*/ 90 | function Window_TBSEntityHud() { 91 | this.initialize.apply(this, arguments); 92 | } 93 | Window_TBSEntityHud.prototype = Object.create(Window_Base.prototype); 94 | Window_TBSEntityHud.prototype.constructor = Window_TBSEntityHud; 95 | 96 | Window_TBSEntityHud.prototype.initialize = function (entity) { 97 | this._entity = entity; 98 | var width = this.windowWidth(); 99 | var height = this.windowHeight(); 100 | Window_Base.prototype.initialize.call(this, 0, 0, width, height); 101 | this.opacity = 0; 102 | this.contentsOpacity = 0; 103 | this.refresh(); 104 | this.updatePosition(); 105 | }; 106 | 107 | Window_TBSEntityHud.prototype.minWindowWidth = function () { 108 | return 300; 109 | }; 110 | 111 | Window_TBSEntityHud.prototype.minWindowHeight = function () { 112 | return 200; 113 | }; 114 | 115 | Window_TBSEntityHud.prototype.windowWidth = function () { 116 | return 300; 117 | }; 118 | 119 | Window_TBSEntityHud.prototype.windowHeight = function () { 120 | return 200; 121 | }; 122 | 123 | Window_TBSEntityHud.prototype.updatePosition = function () { 124 | var x = this._entity._posX - this.windowWidth() / 2; 125 | var y = this._entity._posY; 126 | this.x = x + this._entity.width() / 2; 127 | this.y = y; 128 | }; 129 | 130 | Window_TBSEntityHud.prototype.refresh = function () { 131 | this.contents.clear(); 132 | this.resetFontSettings(); 133 | var battler = this._entity.battler(); 134 | //- Name 135 | var x = 0; 136 | var y = 0; 137 | var w = 46; 138 | this.contents.fontSize -= 4; 139 | this.changeTextColor(this.systemColor()); 140 | this.leU_drawText(battler.name(), "center", y); 141 | //y += this.contents.fontSize; 142 | x = this.contentsWidth() / 2 - w / 2; 143 | var color1 = this.hpGaugeColor1(); 144 | var color2 = this.hpGaugeColor2(); 145 | this.drawGauge(x, y, w, battler.hpRate(), color1, color2); 146 | }; 147 | 148 | Window_TBSEntityHud.prototype.gaugeHeight = function() { 149 | return 5; 150 | }; -------------------------------------------------------------------------------- /LeTBS_RTPUse.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: RTP Use 4 | # LeTBS_RTPUse.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Lecode = Lecode || {}; 18 | Lecode.S_TBS.RTPUse = {}; 19 | /*: 20 | * @plugindesc Automatically use RPT ressources for LeTBS 21 | * @author Lecode 22 | * @version 1.0 23 | * 24 | * @help 25 | * ... 26 | */ 27 | //#============================================================================= 28 | 29 | /*------------------------------------------------------------------------- 30 | * Get Parameters 31 | -------------------------------------------------------------------------*/ 32 | var parameters = PluginManager.parameters('LeTBS_RTPUse'); 33 | 34 | 35 | /*------------------------------------------------------------------------- 36 | * TBSEntity 37 | -------------------------------------------------------------------------*/ 38 | TBSEntity.prototype.getCharacterName = function () { 39 | return this.battler().isActor() && this.rpgObject().leTbs_useCharacter ? this.battler().characterName() 40 | : this.rpgObject().leTbs_characterName; 41 | }; 42 | 43 | TBSEntity.prototype.getCharacterIndex = function () { 44 | return this.battler().isActor() && this.rpgObject().leTbs_useCharacter ? this.battler().characterIndex() 45 | : this.rpgObject().leTbs_characterIndex; 46 | }; 47 | 48 | 49 | /*------------------------------------------------------------------------- 50 | * TBSEntity_Sprite 51 | -------------------------------------------------------------------------*/ 52 | Lecode.S_TBS.RTPUse.oldTBSEntitySprite_initialize = TBSEntity_Sprite.prototype.initialize; 53 | TBSEntity_Sprite.prototype.initialize = function (battler, entity) { 54 | Lecode.S_TBS.RTPUse.oldTBSEntitySprite_initialize.call(this, battler, entity); 55 | this._frameOrder = [0, 1, 2, 1]; 56 | this._frameOrderIndex = 0; 57 | }; 58 | 59 | Lecode.S_TBS.RTPUse.oldTBSEntitySprite_updateFrameCount = TBSEntity_Sprite.prototype.updateFrameCount; 60 | TBSEntity_Sprite.prototype.updateFrameCount = function () { 61 | var charaName = this._entity.getCharacterName(); 62 | if (charaName && this._pose === "idle") { 63 | this._frameOrderIndex++; 64 | if (this._frameOrderIndex > this._frameOrder.length) { 65 | this._frameOrderIndex = 0; 66 | this.onPosePlayed(); 67 | } 68 | this._frameCount = this._frameOrder[this._frameOrderIndex]; 69 | return; 70 | } 71 | Lecode.S_TBS.RTPUse.oldTBSEntitySprite_updateFrameCount.call(this); 72 | }; 73 | 74 | Lecode.S_TBS.RTPUse.oldTBSEntitySprite_processBitmapsConfig = TBSEntity_Sprite.prototype.processBitmapsConfig; 75 | TBSEntity_Sprite.prototype.processBitmapsConfig = function (info, hue) { 76 | var charaName = this._entity.getCharacterName(); 77 | var pose = info[0]; 78 | if (charaName && pose === "idle") { 79 | this._poses.push(pose); 80 | var fullBitmap = ImageManager.loadCharacter(charaName, hue); 81 | fullBitmap.addLoadListener(this.createCharaBitmap.bind(this, fullBitmap)); 82 | return; 83 | } 84 | Lecode.S_TBS.RTPUse.oldTBSEntitySprite_processBitmapsConfig.call(this, info, hue); 85 | }; 86 | 87 | TBSEntity_Sprite.prototype.createCharaBitmap = function (fbitmap) { 88 | var charaName = this._entity.getCharacterName(); 89 | var charaIndex = this._entity.getCharacterIndex(); 90 | var big = ImageManager.isBigCharacter(charaName); 91 | if (big) { 92 | throw new Error("LeTBS_RTPUse: Doesn't handle big characters for now"); 93 | } 94 | var bitmap = new Bitmap(48 * 3, 48 * 4); 95 | var pw = fbitmap.width / 4; 96 | var ph = fbitmap.height / 2; 97 | var n = charaIndex; 98 | var sx = (n % 4) * pw; 99 | var sy = Math.floor(n / 4) * ph; 100 | bitmap.blt(fbitmap, sx, sy, pw, ph, 0, 0); 101 | this._maxFrame["idle"] = 2; 102 | this._bitmaps["idle"] = bitmap; 103 | this._frameLoaded++; 104 | }; 105 | 106 | 107 | /*------------------------------------------------------------------------- 108 | * TBSTurnOrderVisual 109 | -------------------------------------------------------------------------*/ 110 | Lecode.S_TBS.RTPUse.oldTBSTurnOrderVisual_getSpriteBitmap = TBSTurnOrderVisual.prototype.getSpriteBitmap; 111 | TBSTurnOrderVisual.prototype.getSpriteBitmap = function (entity) { 112 | var auto = entity.rpgObject().leTbs_autoTurnOrderFace; 113 | if (auto) { 114 | var sprite = entity._sprite; 115 | var fbitmap = sprite._bitmaps["idle"]; 116 | var bitmap = new Bitmap(40, 40); 117 | var pw = fbitmap.width / (sprite._maxFrame["idle"] + 1); 118 | var ph = fbitmap.height / 4; 119 | var y = ph <= 40 ? 0 : 6; 120 | bitmap.blt(fbitmap, pw / 2 - 20, y, 40, 40, 0, 0); 121 | return bitmap; 122 | } 123 | return Lecode.S_TBS.RTPUse.oldTBSTurnOrderVisual_getSpriteBitmap.call(this, entity); 124 | }; 125 | 126 | 127 | /*------------------------------------------------------------------------- 128 | * Window_TBSStatus 129 | -------------------------------------------------------------------------*/ 130 | Lecode.S_TBS.RTPUse.oldWindowTBSStatus_drawSprite = Window_TBSStatus.prototype.drawSprite; 131 | Window_TBSStatus.prototype.drawSprite = function (x, y) { 132 | var auto = this._entity.rpgObject().leTbs_autoTurnOrderFace; 133 | if (auto) { 134 | var sprite = this._entity._sprite; 135 | var fbitmap = sprite._bitmaps["idle"]; 136 | var pw = fbitmap.width / (sprite._maxFrame["idle"] + 1); 137 | var ph = fbitmap.height / 4; 138 | var window = this; 139 | var dx = eval(Lecode.S_TBS.Windows.statusWindowSpriteBoxW) / 2 - pw / 2; 140 | var dy = 20 + eval(Lecode.S_TBS.Windows.statusWindowSpriteBoxH) / 2 - ph / 2; 141 | this.contents.blt(fbitmap, 0, 0, pw, ph, dx, dy); 142 | /*var pw = fbitmap.width / (sprite._maxFrame["idle"] + 1); 143 | var ph = fbitmap.height / 4; 144 | var bitmap = new Bitmap(pw, ph); 145 | bitmap.blt(fbitmap, pw / 2 - 20, 0, pw, ph); 146 | var window = this; 147 | var dx = eval(Lecode.S_TBS.Windows.statusWindowSpriteBoxW) / 2 - bitmap.width / 2; 148 | var dy = 20 + eval(Lecode.S_TBS.Windows.statusWindowSpriteBoxH) / 2 - bitmap.height / 2; 149 | this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, dx, dy);*/ 150 | return; 151 | } 152 | Lecode.S_TBS.RTPUse.oldWindowTBSStatus_drawSprite.call(this, x, y); 153 | }; 154 | 155 | 156 | /*------------------------------------------------------------------------- 157 | * DataManager 158 | -------------------------------------------------------------------------*/ 159 | Lecode.S_TBS.RTPUse.oldDataManager_processLeTBSTags = DataManager.processLeTBSTags; 160 | DataManager.processLeTBSTags = function () { 161 | Lecode.S_TBS.RTPUse.oldDataManager_processLeTBSTags.call(this); 162 | this.processLeTBS_RTPUseTagsForBattlers(); 163 | }; 164 | 165 | DataManager.processLeTBS_RTPUseTagsForBattlers = function () { 166 | var groups = [$dataActors, $dataEnemies, $dataClasses]; 167 | for (var i = 0; i < groups.length; i++) { 168 | var group = groups[i]; 169 | for (var j = 1; j < group.length; j++) { 170 | var obj = group[j]; 171 | var notedata = obj.note.split(/[\r\n]+/); 172 | var letbs = false; 173 | 174 | obj.leTbs_characterName = null; 175 | obj.leTbs_characterIndex = null; 176 | obj.leTbs_useCharacter = false; 177 | obj.leTbs_autoTurnOrderFace = false; 178 | obj.leTbs_autoStatusSprite = false; 179 | 180 | for (var k = 0; k < notedata.length; k++) { 181 | var line = notedata[k]; 182 | if (line.match(//i)) 183 | letbs = true; 184 | else if (line.match(/<\/letbs>/i)) 185 | letbs = false; 186 | 187 | if (letbs) { 188 | if (line.match(/character_name\s?:\s?(.+)/i)) 189 | obj.leTbs_characterName = String(RegExp.$1); 190 | else if (line.match(/character_index\s?:\s?(.+)/i)) 191 | obj.leTbs_characterIndex = Number(RegExp.$1); 192 | else if (line.match(/use_character/i)) 193 | obj.leTbs_useCharacter = true; 194 | else if (line.match(/auto_turn_order_face/i)) 195 | obj.leTbs_autoTurnOrderFace = true; 196 | else if (line.match(/auto_status_sprite/i)) 197 | obj.leTbs_autoStatusSprite = true; 198 | } 199 | } 200 | } 201 | } 202 | }; 203 | -------------------------------------------------------------------------------- /LeTBS_RhymeSmoothMapScrolling.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Rhyme Smooth Map Scrolling Support 4 | # LeTBS_RhymeSmoothMapScrolling.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Imported = Imported || {}; 18 | Imported["LeTBS_RhymeSmoothMapScrolling"] = true; 19 | 20 | var Lecode = Lecode || {}; 21 | Lecode.S_TBS.RhymeSmoothMapScrolling = {}; 22 | /*: 23 | * @plugindesc Scroll smoothly the map 24 | * @author Lecode 25 | * @version 1.0 26 | * 27 | * @help 28 | * ... 29 | */ 30 | //#============================================================================= 31 | 32 | BattleManagerTBS.centerCell = function (cell) { 33 | $gameMap.scrollTowardsPos(cell.x, cell.y, 4, 90); 34 | }; 35 | 36 | Game_Map.prototype.scrollTowardsPos = function(x, y, speed, frames) { 37 | var centerX = this._tDisplayX + this.screenTileX() / 2; 38 | var centerY = this._tDisplayY + this.screenTileY() / 2; 39 | if (!this.isLoopHorizontal()) { 40 | if (centerX < this.screenTileX() / 2) { 41 | centerX = this.screenTileX() / 2; 42 | } 43 | if (centerX > this.width() - this.screenTileX() / 2) { 44 | centerX = this.width() - this.screenTileX() / 2; 45 | } 46 | } 47 | if (!this.isLoopVertical()) { 48 | if (centerY < this.screenTileY() / 2) { 49 | centerY = this.screenTileY() / 2; 50 | } 51 | if (centerY > this.height() - this.screenTileY() / 2) { 52 | centerY = this.height() - this.screenTileY() / 2; 53 | } 54 | } 55 | var distanceX = (x + 0.5) - centerX; 56 | var distanceY = (y + 0.5) - centerY; 57 | this.startQuasiScroll(distanceX, distanceY, speed || 4, frames); 58 | }; -------------------------------------------------------------------------------- /LeTBS_Summoning.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Summoning 4 | # LeTBS_Summoning.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Imported = Imported || {}; 18 | Imported.LeTBS_Summoning = true; 19 | 20 | var Lecode = Lecode || {}; 21 | Lecode.S_TBS.Summoning = {}; 22 | /*: 23 | * @plugindesc Adds a summoning system 24 | * @author Lecode 25 | * @version 1.0 26 | * 27 | * @help 28 | * See the documentation 29 | */ 30 | //#============================================================================= 31 | 32 | 33 | /*------------------------------------------------------------------------- 34 | * Get Parameters 35 | -------------------------------------------------------------------------*/ 36 | var parameters = PluginManager.parameters('LeTBS_Summoning'); 37 | 38 | 39 | 40 | 41 | /*------------------------------------------------------------------------- 42 | * BattleManagerTBS 43 | -------------------------------------------------------------------------*/ 44 | Lecode.S_TBS.Summoning.oldBattleManagerTBS_initMembers = BattleManagerTBS.initMembers; 45 | BattleManagerTBS.initMembers = function () { 46 | this._nonActiveSummons = []; 47 | this._activeSummons = []; 48 | Lecode.S_TBS.Summoning.oldBattleManagerTBS_initMembers.call(this); 49 | }; 50 | 51 | BattleManagerTBS.summonEntities = function () { 52 | return this._nonActiveSummons.concat(this._activeSummons); 53 | }; 54 | 55 | Lecode.S_TBS.Summoning.oldBattleManagerTBS_allEntities = BattleManagerTBS.allEntities; 56 | BattleManagerTBS.allEntities = function () { 57 | return Lecode.S_TBS.Summoning.oldBattleManagerTBS_allEntities.call(this) 58 | .concat(this.summonEntities()); 59 | }; 60 | 61 | Lecode.S_TBS.Summoning.oldBattleManagerTBS_allPlayableEntities = BattleManagerTBS.allPlayableEntities; 62 | BattleManagerTBS.allPlayableEntities = function () { 63 | return Lecode.S_TBS.Summoning.oldBattleManagerTBS_allPlayableEntities.call(this) 64 | .concat(this._activeSummons); 65 | }; 66 | 67 | Lecode.S_TBS.Summoning.oldBattleManagerTBS_destroyEntity = BattleManagerTBS.destroyEntity; 68 | BattleManagerTBS.destroyEntity = function (entity) { 69 | Lecode.S_TBS.Summoning.oldBattleManagerTBS_destroyEntity.call(this, entity); 70 | LeUtilities.removeInArray(this._nonActiveSummons, entity); 71 | LeUtilities.removeInArray(this._activeSummons, entity); 72 | }; 73 | 74 | BattleManagerTBS.newSummon = function (caster, summonId, cell) { 75 | var summonData = Lecode.S_TBS.Config.Summons[summonId]; 76 | summonData.caster = caster; 77 | var layer = this.getLayer("battlers"); 78 | var id = summonData.id; 79 | var battler = summonData.kind === "actor" ? new Game_Actor(id) : new Game_Enemy(id, 0, 0); 80 | var summon; 81 | if (summonData.active) { 82 | summon = new TBSActiveSummon(battler, layer, cell, summonData); 83 | this._activeSummons.push(summon); 84 | this.updateTurnOrderForSummon(caster, summon, summonData.turn_order); 85 | } else { 86 | summon = new TBSNonActiveSummon(battler, layer, cell, summonData); 87 | this._nonActiveSummons.push(summon); 88 | } 89 | summon.onSummoned(caster, summonData.stats); 90 | }; 91 | 92 | BattleManagerTBS.updateTurnOrderForSummon = function (caster, summon, type) { 93 | if (type === "remake") { 94 | var activeEntity = this.activeEntity(); 95 | this.determineTurnOrder(); 96 | for (var i = 0; i < this._turnOrder.length; i++) { 97 | var entity = this._turnOrder[i]; 98 | if (entity === caster) 99 | this._activeIndex = i; 100 | } 101 | } else if (type === "after_caster") { 102 | var indexToInsert = null; 103 | for (var i = 0; i < this._turnOrder.length; i++) { 104 | var entity = this._turnOrder[i]; 105 | if (entity === caster) 106 | indexToInsert = i; 107 | } 108 | if (indexToInsert >= 0) { 109 | this._turnOrder.splice(indexToInsert + 1, 0, summon); 110 | } 111 | } 112 | setTimeout(this._turnOrderVisual.updateOnSummon.bind(this._turnOrderVisual, 113 | this._turnOrder, this._activeIndex), 300); 114 | }; 115 | 116 | BattleManagerTBS.onActiveSummonDeath = function (entity) { 117 | var summonData = entity._summonData; 118 | var summonIndex; 119 | for (var i = 0; i < this._turnOrder.length; i++) { 120 | var e = this._turnOrder[i]; 121 | if (entity === e) 122 | summonIndex = i; 123 | } 124 | if (summonData.turn_order === "remake") 125 | this.determineTurnOrder(); 126 | else 127 | LeUtilities.removeInArray(this._turnOrder, entity); 128 | if (this._activeIndex >= summonIndex) 129 | this._activeIndex--; 130 | this._turnOrderVisual.updateOnSummon(this._turnOrder, this._activeIndex); 131 | LeUtilities.removeInArray(this._activeSummons, entity); 132 | }; 133 | 134 | BattleManagerTBS.checkTiedSummonsonDeath = function (entity) { 135 | this.summonEntities().forEach(function (summon) { 136 | if (summon._summonData.caster === entity) { 137 | summon.battler().addState(1); 138 | summon.checkDeath(); 139 | } 140 | }) 141 | }; 142 | 143 | 144 | /*------------------------------------------------------------------------- 145 | * TBSTurnOrderVisual 146 | -------------------------------------------------------------------------*/ 147 | TBSTurnOrderVisual.prototype.updateOnSummon = function (newOrder, oldIndex) { 148 | this.set(newOrder); 149 | this._activeIndex = oldIndex; 150 | this.setPositions(); 151 | this.updateOrderState(); 152 | }; 153 | 154 | 155 | /*------------------------------------------------------------------------- 156 | * TBSSequenceManager 157 | -------------------------------------------------------------------------*/ 158 | TBSSequenceManager.prototype.commandSummon = function (param) { 159 | var id = param[0]; 160 | var cellTargets = param[1]; 161 | var cells = this.readCellTargets(cellTargets); 162 | 163 | cells.forEach(function (cell) { 164 | BattleManagerTBS.newSummon(this.getUser(), id, cell); 165 | }.bind(this)); 166 | }; 167 | 168 | 169 | /*------------------------------------------------------------------------- 170 | * TBSNonActiveSummon 171 | -------------------------------------------------------------------------*/ 172 | function TBSNonActiveSummon() { 173 | this.initialize.apply(this, arguments); 174 | } 175 | TBSNonActiveSummon.prototype = Object.create(TBSEntity.prototype); 176 | TBSNonActiveSummon.prototype.constructor = TBSNonActiveSummon; 177 | 178 | TBSNonActiveSummon.prototype.initialize = function (battler, layer, cell, summonData) { 179 | TBSEntity.prototype.initialize.call(this, battler, layer); 180 | this.setCell(cell); 181 | this._summonData = summonData; 182 | this.startAnimation(); 183 | }; 184 | 185 | TBSNonActiveSummon.prototype.createSprite = function (battler, layer) { 186 | this._sprite = new TBSNonActiveSummon_Sprite(battler, this); 187 | this._layer = layer; 188 | layer.addChild(this._sprite); 189 | }; 190 | 191 | TBSNonActiveSummon.prototype.startAnimation = function () { 192 | var animId; 193 | if (this._summonData.body_anim instanceof Array) 194 | animId = LeUtilities.getRandomValueInArray(this._summonData.body_anim); 195 | else 196 | animId = this._summonData.body_anim; 197 | var animation = $dataAnimations[animId]; 198 | var sprite = new TBSNonActiveSummon_Animation(); 199 | sprite.setup(this, animation, false, 0, this.getCell()); 200 | this._layer.addChild(sprite); 201 | this._animationSprite = sprite; 202 | }; 203 | 204 | TBSNonActiveSummon.prototype.stopAnimation = function () { 205 | this._animationSprite._loop = false; 206 | this._animationSprite._duration = 0; 207 | this._layer.removeChild(this._animationSprite); 208 | }; 209 | 210 | TBSNonActiveSummon.prototype.onDeath = function () { 211 | TBSEntity.prototype.onDeath.call(this); 212 | this.stopAnimation(); 213 | BattleManagerTBS.getLayer("animations").newAnimation(this.getCollapseAnimation(), false, 0, this.getCell()); 214 | BattleManagerTBS.destroyEntity(this); 215 | }; 216 | 217 | TBSNonActiveSummon.prototype.startSequence = function (id, action) { 218 | }; 219 | 220 | 221 | /*------------------------------------------------------------------------- 222 | * TBSNonActiveSummon_Animation 223 | -------------------------------------------------------------------------*/ 224 | function TBSNonActiveSummon_Sprite() { 225 | this.initialize.apply(this, arguments); 226 | } 227 | 228 | TBSNonActiveSummon_Sprite.prototype = Object.create(TBSEntity_Sprite.prototype); 229 | TBSNonActiveSummon_Sprite.prototype.constructor = TBSNonActiveSummon_Sprite; 230 | 231 | TBSNonActiveSummon_Sprite.prototype.createBitmaps = function () { 232 | var config = this.getConfig(); 233 | config.forEach(function (info) { 234 | var pose = info[0]; 235 | this._maxFrame[pose] = 0; 236 | this._bitmaps[pose] = new Bitmap(48, 48); 237 | }.bind(this)); 238 | if (!this.isValidPose("dead")) { 239 | this._maxFrame["dead"] = 0; 240 | this._bitmaps["dead"] = new Bitmap(48, 48); 241 | } 242 | }; 243 | 244 | TBSNonActiveSummon_Sprite.prototype.isReady = function () { 245 | return true; 246 | }; 247 | 248 | 249 | /*------------------------------------------------------------------------- 250 | * TBSNonActiveSummon_Animation 251 | -------------------------------------------------------------------------*/ 252 | function TBSNonActiveSummon_Animation() { 253 | this.initialize.apply(this, arguments); 254 | } 255 | TBSNonActiveSummon_Animation.prototype = Object.create(Sprite_TBSAnimation.prototype); 256 | TBSNonActiveSummon_Animation.prototype.constructor = TBSNonActiveSummon_Animation; 257 | 258 | TBSNonActiveSummon_Animation.prototype.initialize = function () { 259 | Sprite_TBSAnimation.prototype.initialize.call(this, arguments); 260 | this._loop = true; 261 | }; 262 | 263 | TBSNonActiveSummon_Animation.prototype.update = function () { 264 | Sprite_TBSAnimation.prototype.update.call(this); 265 | if (!this.isPlaying() && this._animation && this._loop) { 266 | this.setupDuration(); 267 | } 268 | }; 269 | 270 | 271 | /*------------------------------------------------------------------------- 272 | * TBSActiveSummon 273 | -------------------------------------------------------------------------*/ 274 | function TBSActiveSummon() { 275 | this.initialize.apply(this, arguments); 276 | } 277 | TBSActiveSummon.prototype = Object.create(TBSEntity.prototype); 278 | TBSActiveSummon.prototype.constructor = TBSActiveSummon; 279 | 280 | TBSActiveSummon.prototype.initialize = function (battler, layer, cell, summonData) { 281 | TBSEntity.prototype.initialize.call(this, battler, layer); 282 | this.setCell(cell); 283 | this._summonData = summonData; 284 | }; 285 | 286 | TBSActiveSummon.prototype.playableByAI = function () { 287 | return TBSEntity.prototype.playableByAI.call(this) || this._summonData.type === "ai_playable"; 288 | }; 289 | 290 | TBSActiveSummon.prototype.onDeath = function () { 291 | TBSEntity.prototype.onDeath.call(this); 292 | this.destroy(); 293 | BattleManagerTBS.onActiveSummonDeath(this); 294 | }; 295 | 296 | 297 | /*------------------------------------------------------------------------- 298 | * TBSEntity 299 | -------------------------------------------------------------------------*/ 300 | TBSEntity.prototype.onSummoned = function (caster, statesData) { 301 | this.getCasterStats(caster, statesData); 302 | }; 303 | 304 | TBSEntity.prototype.getCasterStats = function (caster, statesData) { 305 | var base = {}; 306 | var plus = {}; 307 | if (statesData.default) { 308 | var value = statesData.default.replace("%", ""); 309 | for (var i = 0; i <= 7; i++) { 310 | if (value.match(/\+/i)) { 311 | plus[i] = caster.battler().param(i) * value * 0.01; 312 | base[i] = null; 313 | } else 314 | base[i] = caster.battler().param(i) * value * 0.01; 315 | } 316 | } 317 | var tags = ["mhp", "mmp", "atk", "def", "mat", "mdf", "agi", "luk"]; 318 | for (var i = 0; i <= 7; i++) { 319 | var value = statesData[tags[i]]; 320 | if (value) { 321 | value = value.replace("%", ""); 322 | if (value.match(/\+/i)) { 323 | plus[i] = caster.battler().param(i) * value * 0.01; 324 | base[i] = null; 325 | } else 326 | base[i] = caster.battler().param(i) * value * 0.01; 327 | } 328 | } 329 | this.battler().setSummonParamBase(base); 330 | this.battler().setSummonParamPlus(plus); 331 | this.battler().refresh(); 332 | this.battler().recoverAll(); 333 | }; 334 | 335 | Lecode.S_TBS.Summoning.oldTBSEntity_onDeath = TBSEntity.prototype.onDeath; 336 | TBSEntity.prototype.onDeath = function () { 337 | Lecode.S_TBS.Summoning.oldTBSEntity_onDeath.call(this); 338 | BattleManagerTBS.checkTiedSummonsonDeath(this); 339 | }; 340 | 341 | 342 | /*------------------------------------------------------------------------- 343 | * Game_Battler 344 | -------------------------------------------------------------------------*/ 345 | Lecode.S_TBS.Summoning.oldGameActor_paramBase = Game_Actor.prototype.paramBase; 346 | Game_Actor.prototype.paramBase = function (paramId) { 347 | var value = Lecode.S_TBS.Summoning.oldGameActor_paramBase.call(this, paramId); 348 | return this.summonParamBase(paramId) ? this.summonParamBase(paramId) : value; 349 | }; 350 | 351 | Lecode.S_TBS.Summoning.oldGameActor_paramPlus = Game_Actor.prototype.paramPlus; 352 | Game_Actor.prototype.paramPlus = function (paramId) { 353 | return Lecode.S_TBS.Summoning.oldGameActor_paramPlus.call(this, paramId) + this.summonParamPlus(paramId); 354 | }; 355 | 356 | Lecode.S_TBS.Summoning.oldGameEnemy_paramBase = Game_Enemy.prototype.paramBase; 357 | Game_Enemy.prototype.paramBase = function (paramId) { 358 | var value = Lecode.S_TBS.Summoning.oldGameEnemy_paramBase.call(this, paramId); 359 | return this.summonParamBase(paramId) ? this.summonParamBase(paramId) : value; 360 | }; 361 | 362 | Lecode.S_TBS.Summoning.oldGameEnemy_paramPlus = Game_Enemy.prototype.paramPlus; 363 | Game_Enemy.prototype.paramPlus = function (paramId) { 364 | return Lecode.S_TBS.Summoning.oldGameEnemy_paramPlus.call(this, paramId) + this.summonParamPlus(paramId); 365 | }; 366 | 367 | Game_Battler.prototype.summonParamBase = function (paramId) { 368 | if (this._summonParamBase) 369 | return Math.floor(this._summonParamBase[paramId]) || 0; 370 | return 0; 371 | }; 372 | 373 | Game_Battler.prototype.setSummonParamBase = function (paramBase) { 374 | this._summonParamBase = paramBase; 375 | }; 376 | 377 | Game_Battler.prototype.summonParamPlus = function (paramId) { 378 | if (this._summonParamPlus) 379 | return Math.floor(this._summonParamPlus[paramId]) || 0; 380 | return 0; 381 | }; 382 | 383 | Game_Battler.prototype.setSummonParamPlus = function (paramPlus) { 384 | this._summonParamPlus = paramPlus; 385 | }; -------------------------------------------------------------------------------- /LeTBS_TacticalMode.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Tactical Mode 4 | # LeTBS_TacticalMode.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Lecode = Lecode || {}; 18 | Lecode.S_TBS.TacticalMode = {}; 19 | /*: 20 | * @plugindesc Render the map following the "tactical mode" of Dofus 21 | * @author Lecode 22 | * @version 1.0 23 | * 24 | * @param Hard Obstacle Color 25 | * @desc Color for obstacles that blocks the LOS 26 | * @default #2E2E2E 27 | * 28 | * @param Light Obstacle Color 29 | * @desc Color for obstacles that doesn't block the LOS 30 | * @default #0 31 | * 32 | * @param Free Cell Color 33 | * @desc Color for free cells 34 | * @default #898989 35 | * 36 | * @param Opacity 37 | * @desc Drawing Opacity 38 | * @default 175 39 | * 40 | * @param Command Text 41 | * @desc Command Text 42 | * @default Tactical Mode 43 | * 44 | * 45 | * @help 46 | * ... 47 | */ 48 | //#============================================================================= 49 | 50 | /*------------------------------------------------------------------------- 51 | * Get Parameters 52 | -------------------------------------------------------------------------*/ 53 | var parameters = PluginManager.parameters('LeTBS_TacticalMode'); 54 | Lecode.S_TBS.TacticalMode.hardObstacleColor = String(parameters["Hard Obstacle Color"] || "#2E2E2E"); // (): Color for obstacles that blocks the LOS 55 | Lecode.S_TBS.TacticalMode.lightObstacleColor = String(parameters["Light Obstacle Color"] || "#0"); // (): Color for obstacles that doesn't block the LOS 56 | Lecode.S_TBS.TacticalMode.freeCellColor = String(parameters["Free Cell Color"] || "#898989"); // (): Color for free cells 57 | Lecode.S_TBS.TacticalMode.opacity = Number(parameters["Opacity"] || 175); // (): Drawing Opacity 58 | Lecode.S_TBS.TacticalMode.commandText = String(parameters["Command Text"] || "Tactical Mode"); // (): Command Text 59 | 60 | 61 | /*------------------------------------------------------------------------- 62 | * Scene_Battle 63 | -------------------------------------------------------------------------*/ 64 | Lecode.S_TBS.TacticalMode.oldSB_createEndCommandWindow = Scene_Battle.prototype.createEndCommandWindow; 65 | Scene_Battle.prototype.createEndCommandWindow = function () { 66 | Lecode.S_TBS.TacticalMode.oldSB_createEndCommandWindow.call(this); 67 | this._windowEndCommand.setHandler('tactical_mode', this.setTacticalMode.bind(this)); 68 | }; 69 | 70 | Lecode.S_TBS.TacticalMode.oldSB_start = Scene_Battle.prototype.start; 71 | Scene_Battle.prototype.start = function () { 72 | Lecode.S_TBS.TacticalMode.oldSB_start.call(this); 73 | if (Lecode.S_TBS.commandOn) { 74 | if (BattleManagerTBS._tacticalMode) { 75 | BattleManagerTBS._tacticalMode = false; 76 | this.setTacticalMode(); 77 | } 78 | } 79 | }; 80 | 81 | Scene_Base.prototype.setTacticalMode = function () { 82 | BattleManagerTBS._tacticalMode = !BattleManagerTBS._tacticalMode; 83 | var spriteset = this._spriteset; 84 | if (BattleManagerTBS._tacticalMode) { 85 | if (Graphics.isWebGL()) { 86 | spriteset._tilemap.lowerZLayer.renderable = false; 87 | spriteset._tilemap.upperZLayer.renderable = false; 88 | spriteset._parallax.renderable = false; 89 | } 90 | spriteset._TacticalLayer.show(); 91 | } else { 92 | if (Graphics.isWebGL()) { 93 | spriteset._tilemap.lowerZLayer.renderable = true; 94 | spriteset._tilemap.upperZLayer.renderable = true; 95 | spriteset._parallax.renderable = true; 96 | } 97 | spriteset._TacticalLayer.clear(); 98 | } 99 | this._windowEndCommand.activate(); 100 | }; 101 | 102 | 103 | /*------------------------------------------------------------------------- 104 | * Spriteset_BattleTBS 105 | -------------------------------------------------------------------------*/ 106 | Lecode.S_TBS.TacticalMode.oldSpritesetBattle_createBattleLayers = Spriteset_BattleTBS.prototype.createBattleLayers; 107 | Spriteset_BattleTBS.prototype.createBattleLayers = function () { 108 | this._TacticalLayer = new TBSTacticalLayer(); 109 | this._TacticalLayer.z = 1; 110 | this._tbsLayer.addChild(this._TacticalLayer); 111 | Lecode.S_TBS.TacticalMode.oldSpritesetBattle_createBattleLayers.call(this); 112 | }; 113 | 114 | 115 | /*------------------------------------------------------------------------- 116 | * TBSTacticalLayer 117 | -------------------------------------------------------------------------*/ 118 | function TBSTacticalLayer() { 119 | this.initialize.apply(this, arguments); 120 | } 121 | TBSTacticalLayer.prototype = Object.create(Sprite.prototype); 122 | TBSTacticalLayer.prototype.constructor = TBSTacticalLayer; 123 | 124 | TBSTacticalLayer.prototype.initialize = function () { 125 | var w = $gameMap.width() * $gameMap.tileWidth(); 126 | var h = $gameMap.height() * $gameMap.tileHeight(); 127 | var bitmap = new Bitmap(w, h); 128 | Sprite.prototype.initialize.call(this, bitmap); 129 | }; 130 | 131 | TBSTacticalLayer.prototype.show = function () { 132 | for (var y = 0; y < $gameMap.height(); y++) { 133 | for (var x = 0; x < $gameMap.width(); x++) { 134 | var cell = BattleManagerTBS.getCellAt(x, y); 135 | if (!cell || cell.regionId() === Lecode.S_TBS.obstacleRegionId) 136 | this.drawCell(x, y, "bold"); 137 | else if (cell.regionId() === Lecode.S_TBS.freeObstacleRegionId) 138 | this.drawCell(x, y, "light"); 139 | else 140 | this.drawCell(x, y, "free"); 141 | } 142 | } 143 | }; 144 | 145 | TBSTacticalLayer.prototype.clear = function () { 146 | this.bitmap.clear(); 147 | }; 148 | 149 | TBSTacticalLayer.prototype.drawCell = function (x, y, type) { 150 | var w = Lecode.S_TBS.scopeCellWidth; 151 | var h = Lecode.S_TBS.scopeCellHeight; 152 | var sx = $gameMap.tileWidth() - w; 153 | var sy = $gameMap.tileHeight() - h; 154 | w -= sx; 155 | h -= sy; 156 | sx += x * $gameMap.tileWidth(); 157 | sy += y * $gameMap.tileHeight(); 158 | var color = type === "bold" ? Lecode.S_TBS.TacticalMode.hardObstacleColor 159 | : (type === "light" ? Lecode.S_TBS.TacticalMode.lightObstacleColor : Lecode.S_TBS.TacticalMode.freeCellColor); 160 | this.bitmap.paintOpacity = Lecode.S_TBS.TacticalMode.opacity; 161 | this.bitmap.fillRect(sx, sy, w, h, color); 162 | }; 163 | 164 | 165 | /*------------------------------------------------------------------------- 166 | * TBSTacticalLayer 167 | -------------------------------------------------------------------------*/ 168 | Lecode.S_TBS.TacticalMode.oldWindowTBSEndCommand_makeCommandList = Window_TBSEndCommand.prototype.makeCommandList; 169 | Window_TBSEndCommand.prototype.makeCommandList = function () { 170 | Lecode.S_TBS.TacticalMode.oldWindowTBSEndCommand_makeCommandList.call(this); 171 | this.addCommand(Lecode.S_TBS.TacticalMode.commandText, "tactical_mode", true); 172 | }; -------------------------------------------------------------------------------- /LeTBS_TilesMarksAuraEffects.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Tiles, Marks and Aura effects 4 | # LeTBS_TilesMarksAuraEffects.js 5 | # By Lecode 6 | # Version 1.3 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | # - 1.1 : Fixed a bug where triggering a tile effect or a mark causes an error 16 | # - 1.2 : Fixed a bug where marks and tile effects don't stop battlers movement 17 | # : When an ally dead, tied marks are removed 18 | # : Added a tag for battlers to be immune to tile, mark and aura effects 19 | # - 1.3 : Supports the summoning system 20 | # : Fixed a bug where triggering tiles and mark effects change the next 21 | # action damage 22 | #============================================================================= 23 | */ 24 | var Imported = Imported || {}; 25 | Imported["LeTBS_TilesMarksAuraEffects"] = true; 26 | 27 | var Lecode = Lecode || {}; 28 | Lecode.S_TBS.TilesMarksAura = {}; 29 | /*: 30 | * @plugindesc Adds tiles, marks and aura effects to the core system 31 | * @author Lecode 32 | * @version 1.3 33 | * 34 | * @param Tile Effect Launcher 35 | * @desc ID of the enemy who launch terrain effects. 36 | * @default 10 37 | * 38 | * @help 39 | * See the documentation 40 | */ 41 | //#============================================================================= 42 | 43 | 44 | /*------------------------------------------------------------------------- 45 | * Get Parameters 46 | -------------------------------------------------------------------------*/ 47 | var parameters = PluginManager.parameters('LeTBS_TilesMarksAuraEffects'); 48 | 49 | Lecode.S_TBS.TilesMarksAura.tileEffectLauncher = Number(parameters["Tile Effect Launcher"] || 10); // (): ID of the enemy who launch terrain effects. 50 | 51 | 52 | 53 | 54 | /*------------------------------------------------------------------------- 55 | * BattleManagerTBS 56 | -------------------------------------------------------------------------*/ 57 | Lecode.S_TBS.TilesMarksAura.oldBMTBS_createTBSObjects = BattleManagerTBS.createTBSObjects; 58 | BattleManagerTBS.createTBSObjects = function () { 59 | Lecode.S_TBS.TilesMarksAura.oldBMTBS_createTBSObjects.apply(this, arguments); 60 | this.createMarksManager(); 61 | this.createAurasManager(); 62 | }; 63 | 64 | BattleManagerTBS.createMarksManager = function () { 65 | var layer = this.getLayer("groundEntities"); 66 | this._marksManager = new TBSMarksManager(layer); 67 | }; 68 | 69 | BattleManagerTBS.createAurasManager = function () { 70 | this._aurasManager = new TBSAurasManager(); 71 | }; 72 | 73 | Lecode.S_TBS.TilesMarksAura.oldBMTBS_updateTBSObjects = BattleManagerTBS.updateTBSObjects; 74 | BattleManagerTBS.updateTBSObjects = function () { 75 | Lecode.S_TBS.TilesMarksAura.oldBMTBS_updateTBSObjects.apply(this, arguments); 76 | this._marksManager.update(); 77 | }; 78 | 79 | BattleManagerTBS.processTileEffectsWhenMovement = function (entity) { 80 | var effects = Lecode.S_TBS.Config.Tile_Effects; 81 | var cell = entity.getCell(); 82 | var effect; 83 | var stopMovement = 0; 84 | effect = effects[entity._lastTileEffect]; 85 | stopMovement += this.executeTileEffects(entity, effect, "leaving", entity._lastTileEffect); 86 | effect = effects[cell.regionId()]; 87 | stopMovement += this.executeTileEffects(entity, effect, "entering", entity._lastTileEffect); 88 | entity._lastTileEffect = cell.regionId(); 89 | return stopMovement >= 1; 90 | }; 91 | 92 | BattleManagerTBS.processTileEffectsWhenTurn = function (entity, occasion) { 93 | var effects = Lecode.S_TBS.Config.Tile_Effects; 94 | var cell = entity.getCell(); 95 | var effect; 96 | effect = effects[cell.regionId()]; 97 | this.executeTileEffects(entity, effect, "turn_" + occasion, cell.regionId()); 98 | entity._lastTileEffect = cell.regionId(); 99 | }; 100 | 101 | BattleManagerTBS.executeTileEffects = function (entity, effect, occasion, code) { 102 | if (entity.rpgObject().leTbs_tileEffectsImmune.includes(String(code))) return 0; 103 | if (effect) { 104 | var occasionFound = false; 105 | for (var property in effect) { 106 | if (effect.hasOwnProperty(property)) { 107 | if (String(property).includes(occasion)) { 108 | effect = effect[property]; 109 | occasionFound = true; 110 | break; 111 | } 112 | } 113 | } 114 | if (!occasionFound) return 0; 115 | var battlerId = Lecode.S_TBS.TilesMarksAura.tileEffectLauncher; 116 | var center = entity.getCell().toCoords(); 117 | var scope = this.getScopeFromData(effect.aoe, center, {}); 118 | var targets = this.getEntitiesInScope(scope); 119 | var stopMovement = effect.stop_movement || false; 120 | var wait = effect.wait || 0; 121 | if (effect.skill_effects) { 122 | var id = effect.skill_effects; 123 | var battler = new Game_Enemy(battlerId, 0, 0); 124 | var obj = $dataSkills[id]; 125 | var anim = effect.play_anim ? obj.animationId : null; 126 | var oldActiveAction = this._activeAction; 127 | this.newAction(battler, true); 128 | this.invokeObjEffects(entity, obj, targets, anim, 0); 129 | this._activeAction = oldActiveAction; 130 | } 131 | this.wait(wait); 132 | return stopMovement ? 1 : 0; 133 | } 134 | return 0; 135 | }; 136 | 137 | BattleManagerTBS.processMarkEffectsWhenPlaced = function (mark) { 138 | var aoe = mark.getSizeArea(); 139 | var entities = this.getEntitiesInScope(aoe); 140 | for (var i = 0; i < entities.length; i++) { 141 | var entity = entities[i]; 142 | entity._lastMarks.push(mark); 143 | this.executeMarkEffects(mark, entity, "laid"); 144 | } 145 | }; 146 | 147 | BattleManagerTBS.processMarkEffectsWhenMovement = function (entity) { 148 | var stopMovement = 0; 149 | var marksUnderEntity = []; 150 | for (var i = 0; i < this._marksManager._marks.length; i++) { 151 | var mark = this._marksManager._marks[i]; 152 | var aoe = mark.getSizeArea(); 153 | if (this.isCellInScope(entity.getCell(), aoe)) { 154 | marksUnderEntity.push(mark); 155 | } 156 | } 157 | 158 | for (var i = 0; i < entity._lastMarks.length; i++) { 159 | var mark = entity._lastMarks[i]; 160 | if (!marksUnderEntity.contains(mark)) 161 | stopMovement += this.executeMarkEffects(mark, entity, "leaving"); 162 | } 163 | 164 | for (var i = 0; i < marksUnderEntity.length; i++) { 165 | var mark = marksUnderEntity[i]; 166 | stopMovement += this.executeMarkEffects(mark, entity, "stepping"); 167 | if (!entity._lastMarks.contains(mark)) 168 | stopMovement += this.executeMarkEffects(mark, entity, "entering"); 169 | } 170 | entity._lastMarks = marksUnderEntity; 171 | return stopMovement >= 1; 172 | }; 173 | 174 | BattleManagerTBS.processMarkEffectsWhenTurn = function (entity, occasion) { 175 | var marksUnderEntity = []; 176 | var marks = this._marksManager._marks; 177 | for (var i = 0; i < marks.length; i++) { 178 | var mark = marks[i]; 179 | var aoe = mark.getSizeArea(); 180 | if (this.isCellInScope(entity.getCell(), aoe)) { 181 | marksUnderEntity.push(mark); 182 | this.executeMarkEffects(mark, entity, "turn_" + occasion); 183 | } 184 | } 185 | entity._lastMarks = marksUnderEntity; 186 | }; 187 | 188 | BattleManagerTBS.processMarkEffectsWhenCasterTurn = function (entity, occasion) { 189 | var marks = this._marksManager._marks; 190 | for (var i = 0; i < marks.length; i++) { 191 | var mark = marks[i]; 192 | if (mark._user === entity) { 193 | var aoe = mark.getSizeArea(); 194 | var entities = this.getEntitiesInScope(aoe); 195 | for (var j = 0; j < entities.length; j++) { 196 | var entity = entities[j]; 197 | this.executeMarkEffects(mark, entity, "caster_turn_" + occasion); 198 | } 199 | 200 | } 201 | } 202 | }; 203 | 204 | BattleManagerTBS.executeMarkEffects = function (mark, entity, occasion) { 205 | if (entity.isImmuneToMark(mark._id)) return 0; 206 | var data; 207 | var occasionFound = false; 208 | 209 | for (var property in mark._data.triggers) { 210 | if (mark._data.triggers.hasOwnProperty(property)) { 211 | if (String(property).includes(occasion)) { 212 | data = mark._data.triggers[property]; 213 | occasionFound = true; 214 | break; 215 | } 216 | } 217 | } 218 | 219 | if (!occasionFound) return 0; 220 | var center = entity.getCell().toCoords(); 221 | var scope = this.getScopeFromData(data.effects_aoe, center, {}); 222 | var targets = this.getEntitiesInScope(scope); 223 | var stopMovement = data.stop_movement || false; 224 | var wait = mark._data.wait || 0; 225 | if (data.skill_effects) { 226 | var id = data.skill_effects; 227 | var battler = mark._user._battler; 228 | var obj = $dataSkills[id]; 229 | var anim = obj.animationId; 230 | var oldActiveAction = this._activeAction; 231 | this.newAction(mark._user.battler(), true); 232 | this.invokeObjEffects(mark._user, obj, targets, anim, 0); 233 | this._marksManager.onMarkTriggered(mark); 234 | this._activeAction = oldActiveAction; 235 | } 236 | this.wait(wait); 237 | return stopMovement ? 1 : 0; 238 | }; 239 | 240 | BattleManagerTBS.updateMarksDuration = function (entity, occasion) { 241 | this._marksManager.updateDuration(entity, occasion); 242 | }; 243 | 244 | BattleManagerTBS.removeMarksByDeath = function (entity) { 245 | this._marksManager.removeMarksOfEntity(entity); 246 | }; 247 | 248 | BattleManagerTBS.processAurasEffectsWhenApplied = function () { 249 | var entities = this.allEntities(); 250 | for (var i = 0; i < entities.length; i++) { 251 | var entity = entities[i]; 252 | this.processAurasEffects(entity); 253 | } 254 | }; 255 | 256 | BattleManagerTBS.processAurasEffectsWhenRemoved = function () { 257 | BattleManagerTBS.processAurasEffectsWhenApplied(); 258 | }; 259 | 260 | BattleManagerTBS.processAurasEffectsWhenMovement = function () { 261 | BattleManagerTBS.processAurasEffectsWhenApplied(); 262 | }; 263 | 264 | BattleManagerTBS.processAurasEffects = function (entity) { 265 | var currentAuras = []; 266 | var auras = this._aurasManager._auras; 267 | for (var i = 0; i < auras.length; i++) { 268 | var aura = auras[i]; 269 | var aoe = aura.getSizeArea(); 270 | if (this.isCellInScope(entity.getCell(), aoe)) { 271 | currentAuras.push(aura); 272 | } 273 | } 274 | 275 | for (var i = 0; i < entity._lastAuras.length; i++) { 276 | var aura = entity._lastAuras[i]; 277 | if (currentAuras.indexOf(aura) === -1) { 278 | BattleManagerTBS.executeAurasEffects(aura, entity, "leaving"); 279 | } 280 | } 281 | 282 | for (var i = 0; i < currentAuras.length; i++) { 283 | var aura = currentAuras[i]; 284 | if (entity._lastAuras.indexOf(aura) === -1) { 285 | BattleManagerTBS.executeAurasEffects(aura, entity, "entering"); 286 | var anim = aura._data.trigger_anim; 287 | var cell = aura._caster.getCell(); 288 | if (anim) 289 | BattleManagerTBS.getLayer("animations").newAnimation(anim, false, 0, cell); 290 | } 291 | } 292 | 293 | entity._lastAuras = currentAuras; 294 | }; 295 | 296 | BattleManagerTBS.executeAurasEffects = function (aura, entity, occasion) { 297 | if (entity.rpgObject().leTbs_aurasImmune.includes(aura._id)) return; 298 | var states = aura._data.states; 299 | if (!aura._data.affect_caster && aura._caster === entity) 300 | return; 301 | if (aura._caster.battler().isActor()) { 302 | if (aura._data.target_type === "enemy" && entity.battler().isActor()) 303 | return; 304 | if (aura._data.target_type === "ally" && !entity.battler().isActor()) 305 | return; 306 | } else { 307 | if (aura._data.target_type === "enemy" && !entity.battler().isActor()) 308 | return; 309 | if (aura._data.target_type === "ally" && entity.battler().isActor()) 310 | return; 311 | } 312 | for (var i = 0; i < states.length; i++) { 313 | entity.battler().result().clear(); 314 | if (occasion === "entering") { 315 | entity.battler().addState(states[i]); 316 | } else if (occasion === "leaving") { 317 | entity.battler().removeState(states[i]); 318 | } 319 | } 320 | entity.addPopup(); 321 | }; 322 | 323 | 324 | /*------------------------------------------------------------------------- 325 | * TBSEntity 326 | -------------------------------------------------------------------------*/ 327 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_initialize = TBSEntity.prototype.initialize; 328 | TBSEntity.prototype.initialize = function () { 329 | this._lastTileEffect = -1; 330 | this._lastMarks = []; 331 | this._lastAuras = []; 332 | this._castingAuras = []; 333 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_initialize.apply(this, arguments); 334 | }; 335 | 336 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onTurnStart = TBSEntity.prototype.onTurnStart; 337 | TBSEntity.prototype.onTurnStart = function () { 338 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onTurnStart.apply(this, arguments); 339 | BattleManagerTBS.processTileEffectsWhenTurn(this, "start"); 340 | BattleManagerTBS.processMarkEffectsWhenTurn(this, "start"); 341 | BattleManagerTBS.processMarkEffectsWhenCasterTurn(this, "start"); 342 | BattleManagerTBS.updateMarksDuration(this, "start"); 343 | }; 344 | 345 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onTurnEnd = TBSEntity.prototype.onTurnEnd; 346 | TBSEntity.prototype.onTurnEnd = function () { 347 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onTurnEnd.apply(this, arguments); 348 | BattleManagerTBS.processTileEffectsWhenTurn(this, "end"); 349 | BattleManagerTBS.processMarkEffectsWhenTurn(this, "end"); 350 | BattleManagerTBS.processMarkEffectsWhenCasterTurn(this, "end"); 351 | BattleManagerTBS.updateMarksDuration(this, "end"); 352 | }; 353 | 354 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_teleport = TBSEntity.prototype.teleport; 355 | TBSEntity.prototype.teleport = function (cell) { 356 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_teleport.apply(this, arguments); 357 | BattleManagerTBS.processTileEffectsWhenMovement(this); 358 | BattleManagerTBS.processMarkEffectsWhenMovement(this); 359 | BattleManagerTBS.processAurasEffectsWhenMovement(); 360 | }; 361 | 362 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onSummoned = TBSEntity.prototype.onSummoned; 363 | TBSEntity.prototype.onSummoned = function (caster, stats) { 364 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onSummoned.call(this, caster, stats); 365 | BattleManagerTBS.processTileEffectsWhenMovement(this); 366 | BattleManagerTBS.processMarkEffectsWhenMovement(this); 367 | BattleManagerTBS.processAurasEffectsWhenMovement(); 368 | }; 369 | 370 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onCellCovered = TBSEntity.prototype.onCellCovered; 371 | TBSEntity.prototype.onCellCovered = function () { 372 | var result = Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onCellCovered.apply(this, arguments); 373 | var stop1 = BattleManagerTBS.processTileEffectsWhenMovement(this); 374 | var stop2 = BattleManagerTBS.processMarkEffectsWhenMovement(this); 375 | BattleManagerTBS.processAurasEffectsWhenMovement(); 376 | return result || stop1 || stop2; 377 | }; 378 | 379 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onDeath = TBSEntity.prototype.onDeath; 380 | TBSEntity.prototype.onDeath = function () { 381 | Lecode.S_TBS.TilesMarksAura.oldTBSEntity_onDeath.call(this); 382 | BattleManagerTBS.removeMarksByDeath(this); 383 | }; 384 | 385 | TBSEntity.prototype.isImmuneToMark = function (markId) { 386 | var str = this.rpgObject().leTbs_marksImmune; 387 | for (var i = 0; i < this._battler.states().length; i++) { 388 | var state = this._battler.states()[i]; 389 | if (state) 390 | str += state.leTbs_marksImmune; 391 | } 392 | if (this._battler.isActor()) { 393 | for (var i = 0; i < this._battler.equips().length; i++) { 394 | var equip = this._battler.equips()[i]; 395 | if (equip) 396 | str += equip.leTbs_marksImmune; 397 | } 398 | } 399 | return str.includes(markId); 400 | }; 401 | 402 | 403 | /*------------------------------------------------------------------------- 404 | * TBSSequenceManager 405 | -------------------------------------------------------------------------*/ 406 | TBSSequenceManager.prototype.commandMark = function (param) { 407 | var id = param[0]; 408 | var cellTargetData = param[1]; 409 | var cellTargets = this.readCellTargets(cellTargetData); 410 | 411 | for (var i = 0; i < cellTargets.length; i++) { 412 | var cell = cellTargets[i]; 413 | BattleManagerTBS._marksManager.newMark(id, this.getUser(), cell); 414 | } 415 | }; 416 | 417 | 418 | /*------------------------------------------------------------------------- 419 | * TBSMarksManager 420 | -------------------------------------------------------------------------*/ 421 | function TBSMarksManager() { 422 | this.initialize.apply(this, arguments); 423 | } 424 | 425 | TBSMarksManager.prototype.initialize = function (layer) { 426 | this._layer = layer; 427 | this._marks = []; 428 | }; 429 | 430 | TBSMarksManager.prototype.update = function () { 431 | for (var i = 0; i < this._marks.length; i++) { 432 | this._marks[i].update(); 433 | } 434 | }; 435 | 436 | TBSMarksManager.prototype.updateDuration = function (entity, occasion) { 437 | var marksToRemove = []; 438 | for (var i = 0; i < this._marks.length; i++) { 439 | var mark = this._marks[i]; 440 | if (mark._user === entity && mark.durationOccasion() === "turn_" + occasion) { 441 | if ((++mark._turn) >= mark.maxTurns()) 442 | marksToRemove.push(mark); 443 | } 444 | } 445 | marksToRemove.forEach(function (mark) { 446 | this.removeMark(mark._id); 447 | }.bind(this)); 448 | }; 449 | 450 | TBSMarksManager.prototype.removeMarksOfEntity = function (entity) { 451 | var marksToRemove = []; 452 | for (var i = 0; i < this._marks.length; i++) { 453 | var mark = this._marks[i]; 454 | if (mark._user === entity) { 455 | marksToRemove.push(mark); 456 | } 457 | } 458 | marksToRemove.forEach(function (mark) { 459 | this.removeMark(mark._id); 460 | }.bind(this)); 461 | }; 462 | 463 | TBSMarksManager.prototype.onMarkTriggered = function (mark) { 464 | mark._triggered += 1; 465 | var maxTriggers = mark._data.max_triggers; 466 | if (maxTriggers && mark._triggered >= maxTriggers) { 467 | this.removeMark(mark._id); 468 | } 469 | }; 470 | 471 | TBSMarksManager.prototype.newMark = function (id, user, cell) { 472 | var data = Lecode.S_TBS.Config.Marks[id]; 473 | if (data) { 474 | if (!this.canAddMark(id, data)) { 475 | this.removeMark(id); 476 | } 477 | var mark = new TBSMark(id, data, user, cell); 478 | this._layer.addChild(mark); 479 | this._marks.push(mark); 480 | mark.startAnimation(this._layer); 481 | BattleManagerTBS.processMarkEffectsWhenPlaced(mark); 482 | } 483 | }; 484 | 485 | TBSMarksManager.prototype.canAddMark = function (id, data) { 486 | var max = data.max; 487 | if (max) { 488 | var count = 0; 489 | for (var i = 0; i < this._marks.length; i++) { 490 | if (this._marks[i]._id == id) 491 | count++; 492 | if (count >= max) 493 | return false; 494 | } 495 | } 496 | return true; 497 | }; 498 | 499 | TBSMarksManager.prototype.removeMark = function (id) { 500 | this._marks = this._marks.filter(function (mark) { 501 | if (mark._id === id) { 502 | mark.stopAnimation(this._layer); 503 | var anim = mark._data.disappearing_anim; 504 | var cell = mark._cell; 505 | BattleManagerTBS.getLayer("animations").newAnimation(anim, false, 0, cell); 506 | return false; 507 | } 508 | return true; 509 | }.bind(this)); 510 | }; 511 | 512 | 513 | /*------------------------------------------------------------------------- 514 | * TBSMark 515 | -------------------------------------------------------------------------*/ 516 | function TBSMark() { 517 | this.initialize.apply(this, arguments); 518 | } 519 | TBSMark.prototype = Object.create(Sprite_Base.prototype); 520 | TBSMark.prototype.constructor = TBSMark; 521 | 522 | TBSMark.prototype.initialize = function (id, data, user, cell) { 523 | Sprite_Base.prototype.initialize.call(this); 524 | this._id = id; 525 | this._data = data; 526 | this._user = user; 527 | this._cell = cell; 528 | this._turn = 0; 529 | this._triggered = 0; 530 | }; 531 | 532 | TBSMark.prototype.maxTurns = function () { 533 | return this._data.duration[0]; 534 | }; 535 | 536 | TBSMark.prototype.durationOccasion = function () { 537 | return this._data.duration[1]; 538 | }; 539 | 540 | TBSMark.prototype.startAnimation = function (layer) { 541 | var animation = $dataAnimations[this._data.body_anim]; 542 | var sprite = new TBSMark_Animation(); 543 | sprite.setup(this, animation, false, 0, this._cell); 544 | layer.addChild(sprite); 545 | this._animationSprites.push(sprite); 546 | }; 547 | 548 | TBSMark.prototype.stopAnimation = function () { 549 | this._animationSprites[0]._loop = false; 550 | this._animationSprites[0]._duration = 0; 551 | }; 552 | 553 | TBSMark.prototype.getSizeArea = function () { 554 | var center = this._cell.toCoords(); 555 | return BattleManagerTBS.getScopeFromData(this._data.size, center, {}); 556 | }; 557 | 558 | /*------------------------------------------------------------------------- 559 | * TBSMark_Animation 560 | -------------------------------------------------------------------------*/ 561 | function TBSMark_Animation() { 562 | this.initialize.apply(this, arguments); 563 | } 564 | TBSMark_Animation.prototype = Object.create(Sprite_TBSAnimation.prototype); 565 | TBSMark_Animation.prototype.constructor = TBSMark_Animation; 566 | 567 | TBSMark_Animation.prototype.initialize = function () { 568 | Sprite_TBSAnimation.prototype.initialize.call(this, arguments); 569 | this._loop = true; 570 | }; 571 | 572 | TBSMark_Animation.prototype.update = function () { 573 | Sprite_TBSAnimation.prototype.update.call(this); 574 | if (!this.isPlaying() && this._animation && this._loop) { 575 | this.setupDuration(); 576 | } 577 | }; 578 | 579 | 580 | /*------------------------------------------------------------------------- 581 | * TBSAurasManager 582 | -------------------------------------------------------------------------*/ 583 | function TBSAurasManager() { 584 | this.initialize.apply(this, arguments); 585 | } 586 | 587 | TBSAurasManager.prototype.initialize = function () { 588 | this._auras = []; 589 | }; 590 | 591 | TBSAurasManager.prototype.newAura = function (id, caster) { 592 | var data = Lecode.S_TBS.Config.Aura[id]; 593 | if (data) 594 | this._auras.push(new TBSAura(id, caster, data)); 595 | }; 596 | 597 | TBSAurasManager.prototype.removeAura = function (id) { 598 | this._auras = this._auras.filter(function (aura) { 599 | if (aura._id === id) { 600 | return false; 601 | } 602 | return true; 603 | }.bind(this)); 604 | }; 605 | 606 | 607 | /*------------------------------------------------------------------------- 608 | * TBSAura 609 | -------------------------------------------------------------------------*/ 610 | function TBSAura() { 611 | this.initialize.apply(this, arguments); 612 | } 613 | 614 | TBSAura.prototype.initialize = function (id, caster, data) { 615 | this._id = id; 616 | this._caster = caster; 617 | this._data = data; 618 | }; 619 | 620 | TBSAura.prototype.getSizeArea = function () { 621 | var center = this._caster.getCell().toCoords(); 622 | return BattleManagerTBS.getScopeFromData(this._data.size, center, {}); 623 | }; 624 | 625 | 626 | /*------------------------------------------------------------------------- 627 | * Game_Battler 628 | -------------------------------------------------------------------------*/ 629 | Lecode.S_TBS.TilesMarksAura.oldGameBattler_addNewState = Game_Battler.prototype.addNewState; 630 | Game_Battler.prototype.addNewState = function (stateId) { 631 | if (LeUtilities.isScene("Scene_Battle") && Lecode.S_TBS.commandOn) { 632 | var state = $dataStates[stateId]; 633 | var entity = BattleManagerTBS.getEntityByBattler(this); 634 | for (var i = 0; i < state.leTbs_auras.length; i++) { 635 | var auraId = state.leTbs_auras[i]; 636 | BattleManagerTBS._aurasManager.newAura(auraId, entity); 637 | } 638 | if (state.leTbs_auras.length > 0) 639 | BattleManagerTBS.processAurasEffectsWhenApplied(); 640 | } 641 | Lecode.S_TBS.TilesMarksAura.oldGameBattler_addNewState.call(this, stateId); 642 | }; 643 | 644 | Lecode.S_TBS.TilesMarksAura.oldGameBattler_removeState = Game_Battler.prototype.removeState; 645 | Game_Battler.prototype.removeState = function (stateId) { 646 | if (LeUtilities.isScene("Scene_Battle") && Lecode.S_TBS.commandOn) { 647 | var state = $dataStates[stateId]; 648 | for (var i = 0; i < state.leTbs_auras.length; i++) { 649 | var auraId = state.leTbs_auras[i]; 650 | BattleManagerTBS._aurasManager.removeAura(auraId); 651 | } 652 | if (state.leTbs_auras.length > 0) 653 | BattleManagerTBS.processAurasEffectsWhenRemoved(); 654 | } 655 | Lecode.S_TBS.TilesMarksAura.oldGameBattler_removeState.call(this, stateId); 656 | }; 657 | 658 | 659 | /*------------------------------------------------------------------------- 660 | * DataManager 661 | -------------------------------------------------------------------------*/ 662 | Lecode.S_TBS.TilesMarksAura.oldDataManager_processLeTBSTags = DataManager.processLeTBSTags; 663 | DataManager.processLeTBSTags = function () { 664 | Lecode.S_TBS.TilesMarksAura.oldDataManager_processLeTBSTags.call(this); 665 | this.processLeTBS_TilesMarksAuraTagsForBattlers(); 666 | this.processLeTBS_TilesMarksAuraTagsForEquipmentsAndStates(); 667 | }; 668 | 669 | DataManager.processLeTBS_TilesMarksAuraTagsForBattlers = function () { 670 | var groups = [$dataActors, $dataEnemies, $dataClasses]; 671 | for (var i = 0; i < groups.length; i++) { 672 | var group = groups[i]; 673 | for (var j = 1; j < group.length; j++) { 674 | var obj = group[j]; 675 | var notedata = obj.note.split(/[\r\n]+/); 676 | var letbs = false; 677 | 678 | obj.leTbs_marksImmune = ""; 679 | obj.leTbs_aurasImmune = ""; 680 | obj.leTbs_tileEffectsImmune = ""; 681 | 682 | for (var k = 0; k < notedata.length; k++) { 683 | var line = notedata[k]; 684 | if (line.match(//i)) 685 | letbs = true; 686 | else if (line.match(/<\/letbs>/i)) 687 | letbs = false; 688 | 689 | if (letbs) { 690 | if (line.match(/immune_to_marks\s?:\s?(.+)/i)) 691 | obj.leTbs_marksImmune = String(RegExp.$1); 692 | else if (line.match(/immune_to_auras\s?:\s?(.+)/i)) 693 | obj.leTbs_aurasImmune = String(RegExp.$1); 694 | else if (line.match(/immune_to_tile_effects\s?:\s?(.+)/i)) 695 | obj.leTbs_tileEffectsImmune = String(RegExp.$1); 696 | } 697 | } 698 | } 699 | } 700 | }; 701 | 702 | DataManager.processLeTBS_TilesMarksAuraTagsForEquipmentsAndStates = function () { 703 | var groups = [$dataWeapons, $dataArmors, $dataStates]; 704 | for (var i = 0; i < groups.length; i++) { 705 | var group = groups[i]; 706 | for (var j = 1; j < group.length; j++) { 707 | var obj = group[j]; 708 | var notedata = obj.note.split(/[\r\n]+/); 709 | var letbs = false; 710 | 711 | obj.leTbs_auras = []; 712 | obj.leTbs_marksImmune = ""; 713 | obj.leTbs_aurasImmune = ""; 714 | obj.leTbs_tileEffectsImmune = ""; 715 | 716 | for (var k = 0; k < notedata.length; k++) { 717 | var line = notedata[k]; 718 | if (line.match(//i)) 719 | letbs = true; 720 | else if (line.match(/<\/letbs>/i)) 721 | letbs = false; 722 | 723 | if (letbs) { 724 | if (line.match(/aura\s?:\s?(.+)/i)) 725 | obj.leTbs_auras.push(String(RegExp.$1)); 726 | else if (line.match(/immune_to_marks\s?:\s?(.+)/i)) 727 | obj.leTbs_marksImmune = String(RegExp.$1); 728 | else if (line.match(/immune_to_auras\s?:\s?(.+)/i)) 729 | obj.leTbs_aurasImmune = String(RegExp.$1); 730 | else if (line.match(/immune_to_tile_effects\s?:\s?(.+)/i)) 731 | obj.leTbs_tileEffectsImmune = String(RegExp.$1); 732 | } 733 | } 734 | } 735 | } 736 | }; 737 | -------------------------------------------------------------------------------- /LeTBS_WinConditions.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Win Conditions 4 | # LeTBS_WinConditions.js 5 | # By Lecode 6 | # Version 1.01 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | # - 1.01 : Defeat is now based on actors in battle and not the whole party (bugfix) 16 | #============================================================================= 17 | */ 18 | var Imported = Imported || {}; 19 | Imported["LeTBS_WinConditions"] = true; 20 | 21 | var Lecode = Lecode || {}; 22 | Lecode.S_TBS.WinConditions = {}; 23 | /*: 24 | * @plugindesc Add a win condition system 25 | * @author Lecode 26 | * @version 1.01 27 | * 28 | * @help 29 | * See the documentation 30 | */ 31 | //#============================================================================= 32 | 33 | 34 | /*------------------------------------------------------------------------- 35 | * DataManager 36 | -------------------------------------------------------------------------*/ 37 | Lecode.S_TBS.WinConditions.oldDataManager_createGameObjects = DataManager.createGameObjects; 38 | DataManager.createGameObjects = function() { 39 | Lecode.S_TBS.WinConditions.oldDataManager_createGameObjects.call(); 40 | LeTBSWinCds.setup(); 41 | }; 42 | 43 | 44 | /*------------------------------------------------------------------------- 45 | * Game_Interpreter 46 | -------------------------------------------------------------------------*/ 47 | Lecode.S_TBS.WinConditions.old_pluginCommand = Game_Interpreter.prototype.pluginCommand; 48 | Game_Interpreter.prototype.pluginCommand = function(command, args) { 49 | Lecode.S_TBS.WinConditions.old_pluginCommand.call(this, command, args); 50 | if (command === 'LeTBSWinCds') { 51 | switch (args[0]) { 52 | case 'Clear': 53 | LeTBSWinCds.clear(); 54 | break; 55 | case 'Add': 56 | switch (args[1]) { 57 | case "Defeat": 58 | if (args[2] === "All") { 59 | LeTBSWinCds.addDefeatAll(); 60 | } else if (args[2] === "Enemies") { 61 | var nbrStr = args[3]; 62 | var enemyId = Number(args[4]); 63 | if (nbrStr === "All") 64 | LeTBSWinCds.addDefeatAllEnemies(enemyId); 65 | else 66 | LeTBSWinCds.addDefeatXEnemies(Number(nbrStr), enemyId); 67 | } else if (args[2] === "FlaggedEntity") { 68 | var flagId = args[3]; 69 | LeTBSWinCds.addDefeatFlaggedEntity(flagId); 70 | } 71 | break; 72 | case "Prevent": 73 | if (args[2] === "ActorDeath") { 74 | var actorId = Number(args[3]); 75 | LeTBSWinCds.addPreventActorDeath(actorId); 76 | } else if (args[2] === "EntityDeath") { 77 | var flagId = args[3]; 78 | var flagName = ""; 79 | for (var i = 3; i < args.length; i++) 80 | flagName += args[i]; 81 | LeTBSWinCds.addPreventEntityDeath(flagId, flagName); 82 | } 83 | break; 84 | case "Flag": 85 | var flagId = args[2]; 86 | var flagName = ""; 87 | for (var i = 3; i < args.length; i++) 88 | flagName += args[i] + " "; 89 | LeTBSWinCds.addFlag(flagId, flagName); 90 | break; 91 | } 92 | break; 93 | case "ActivateFlag": 94 | var flagId = args[1]; 95 | LeTBSWinCds.setFlag(flagId, true); 96 | break; 97 | case "DeactivateFlag": 98 | var flagId = args[1]; 99 | LeTBSWinCds.setFlag(flagId, false); 100 | break; 101 | } 102 | } 103 | }; 104 | 105 | 106 | /*------------------------------------------------------------------------- 107 | * Scene_Battle 108 | -------------------------------------------------------------------------*/ 109 | Lecode.S_TBS.WinConditions.oldSB_start = Scene_Battle.prototype.start; 110 | Scene_Battle.prototype.start = function() { 111 | if (Lecode.S_TBS.commandOn) { 112 | if (LeTBSWinCds.noConditions()) { 113 | throw new Error('[LeTBS]There is no win condition !!'); 114 | } 115 | } 116 | Lecode.S_TBS.WinConditions.oldSB_start.call(this); 117 | }; 118 | 119 | Lecode.S_TBS.WinConditions.oldSceneBattle_createAllWindows = Scene_Battle.prototype.createAllWindows; 120 | Scene_Battle.prototype.createAllWindows = function() { 121 | Lecode.S_TBS.WinConditions.oldSceneBattle_createAllWindows.call(this); 122 | if (Lecode.S_TBS.commandOn) { 123 | this.createWinConditionsWindow(); 124 | } 125 | }; 126 | 127 | Scene_Battle.prototype.createWinConditionsWindow = function() { 128 | this._windowWinCds = new Window_TBSWinConditions(); 129 | this._windowWinCds.hide(); 130 | this.addWindow(this._windowWinCds); 131 | }; 132 | 133 | Scene_Battle.prototype.showWinConditionsWindow = function(sprite) { 134 | this._windowWinCds._startSprite = sprite; 135 | this._windowWinCds.x = 0; 136 | this._windowWinCds.y = sprite.y + sprite.height - this._windowWinCds.standardPadding(); 137 | this._windowWinCds.show(); 138 | }; 139 | 140 | Scene_Battle.prototype.hideWinConditionsWindow = function(sprite) { 141 | this._windowWinCds.hide(); 142 | }; 143 | 144 | 145 | /*------------------------------------------------------------------------- 146 | * Window_TBSWinConditions 147 | -------------------------------------------------------------------------*/ 148 | function Window_TBSWinConditions() { 149 | this.initialize.apply(this, arguments); 150 | } 151 | 152 | Window_TBSWinConditions.prototype = Object.create(Window_Base.prototype); 153 | Window_TBSWinConditions.prototype.constructor = Window_TBSWinConditions; 154 | 155 | Window_TBSWinConditions.prototype.initialize = function() { 156 | this._texts = LeTBSWinCds.getConditionTexts(); 157 | var width = this.windowWidth(); 158 | var height = this.windowHeight(); 159 | Window_Base.prototype.initialize.call(this, 0, 0, width, height); 160 | this.opacity = 0; 161 | this.refresh(); 162 | }; 163 | 164 | Window_TBSWinConditions.prototype.windowWidth = function() { 165 | return Graphics.width; 166 | }; 167 | 168 | Window_TBSWinConditions.prototype.windowHeight = function() { 169 | return this.fittingHeight(this._texts.length); 170 | }; 171 | 172 | Window_TBSWinConditions.prototype.refresh = function() { 173 | this.contents.clear(); 174 | this.resetFontSettings(); 175 | this.contents.fontSize += 3; 176 | var y = 0; 177 | this._texts.forEach(function(text) { 178 | this.leU_drawText(text, "center", y); 179 | y += this.lineHeight(); 180 | }.bind(this)); 181 | }; 182 | 183 | Lecode.S_TBS.oldWindow_TBSWinConditions_update = Window_TBSWinConditions.prototype.update; 184 | Window_TBSWinConditions.prototype.update = function() { 185 | Lecode.S_TBS.oldWindow_TBSWinConditions_update.call(this); 186 | if (this._startSprite) { 187 | this.contentsOpacity = this._startSprite.opacity; 188 | } 189 | }; 190 | 191 | 192 | /*------------------------------------------------------------------------- 193 | * LeTBSWinCds 194 | -------------------------------------------------------------------------*/ 195 | function LeTBSWinCds() { 196 | throw new Error('This is a static class'); 197 | } 198 | 199 | LeTBSWinCds.setup = function() { 200 | this._defeatAll = false; 201 | this._defeatAllEnemies = []; 202 | this._defeatXEnemies = []; 203 | this._defeatFlaggedEntities = []; 204 | this._preventActorsDeath = []; 205 | this._preventEntitiesDeath = []; 206 | this._flagCds = []; 207 | this._flags = {}; 208 | this._startupFlags = {}; 209 | }; 210 | 211 | LeTBSWinCds.clear = function() { 212 | this.setup(); 213 | }; 214 | 215 | LeTBSWinCds.addDefeatAll = function() { 216 | this._defeatAll = true; 217 | }; 218 | 219 | LeTBSWinCds.addDefeatAllEnemies = function(enemyId) { 220 | this._defeatAllEnemies.push(enemyId); 221 | }; 222 | 223 | LeTBSWinCds.addDefeatXEnemies = function(nbr, enemyId) { 224 | this._defeatXEnemies.push([nbr, enemyId]); 225 | }; 226 | 227 | LeTBSWinCds.addDefeatFlaggedEntity = function(flagId, flagName) { 228 | this._defeatFlaggedEntities.push(flagId, flagName); 229 | }; 230 | 231 | LeTBSWinCds.addPreventActorDeath = function(actorId) { 232 | this._preventActorsDeath.push(actorId); 233 | }; 234 | 235 | LeTBSWinCds.addPreventEntityDeath = function(flagId, flagName) { 236 | this._preventEntitiesDeath.push([flagId, flagName]); 237 | }; 238 | 239 | LeTBSWinCds.addFlag = function(flagId, flagName) { 240 | this._flagCds.push([flagId, flagName]); 241 | this._flags[flagId] = false; 242 | }; 243 | 244 | LeTBSWinCds.getConditionTexts = function() { 245 | var texts = []; 246 | if (this._defeatAll) 247 | texts.push("Defeat all enemies"); 248 | this._defeatAllEnemies.forEach(function(enemyId) { 249 | texts.push("Defeat all " + $dataEnemies[enemyId].name + "s"); 250 | }.bind(this)); 251 | this._defeatXEnemies.forEach(function(info) { 252 | var nbr = info[0]; 253 | var enemyId = info[1]; 254 | if (nbr > 1) 255 | texts.push("Defeat " + nbr + " " + $dataEnemies[enemyId].name + "s"); 256 | else 257 | texts.push("Defeat " + $dataEnemies[enemyId].name); 258 | }.bind(this)); 259 | this._defeatFlaggedEntities.forEach(function(info) { 260 | var flagName = info[1]; 261 | texts.push("Defeat " + flagName); 262 | }.bind(this)); 263 | this._preventActorsDeath.forEach(function(actorId) { 264 | texts.push("Keep " + $dataActors[actorId].name + " alive"); 265 | }.bind(this)); 266 | this._preventEntitiesDeath.forEach(function(info) { 267 | var flagName = info[1]; 268 | texts.push("Keep " + flagName + " alive"); 269 | }.bind(this)); 270 | this._flagCds.forEach(function(info) { 271 | var flagName = info[1]; 272 | texts.push(flagName); 273 | }); 274 | return texts; 275 | }; 276 | 277 | LeTBSWinCds.noConditions = function() { 278 | return this.getConditionTexts().length === 0; 279 | }; 280 | 281 | LeTBSWinCds.checkVictory = function() { 282 | var nbrSuccess = 0; 283 | var goalSuccess = this.getConditionTexts().length; 284 | if (this._defeatAll && $gameTroop.isAllDead()) 285 | nbrSuccess++; 286 | this._defeatAllEnemies.forEach(function(enemyId) { 287 | var entities = BattleManagerTBS.getEntitiesWithEnemyId(enemyId); 288 | if (entities.every(function(ent) { return ent.battler().isDead(); }.bind(this))) { 289 | nbrSuccess++; 290 | } 291 | }.bind(this)); 292 | this._defeatXEnemies.forEach(function(info) { 293 | var nbr = info[0]; 294 | var enemyId = info[1]; 295 | var nbrDeath = 0; 296 | var entities = BattleManagerTBS.getEntitiesWithEnemyId(enemyId); 297 | entities.forEach(function(ent) { 298 | if (ent && ent.battler().isDead()) 299 | nbrDeath++; 300 | }.bind(this)); 301 | if (nbrDeath >= nbr) 302 | nbrSuccess++; 303 | }.bind(this)); 304 | this._defeatFlaggedEntities.forEach(function(info) { 305 | var flagId = info[0]; 306 | var entity = BattleManagerTBS.getFlaggedEntity(flagId); 307 | if (entity && entity.battler().isDead()) 308 | nbrSuccess++; 309 | }.bind(this)); 310 | this._flagCds.forEach(function(info) { 311 | var flagId = info[0]; 312 | if (this._flags[flagId]) 313 | nbrSuccess++; 314 | }.bind(this)); 315 | return nbrSuccess === goalSuccess; 316 | }; 317 | 318 | LeTBSWinCds.checkDefeat = function() { 319 | this._preventActorsDeath.forEach(function(actorId) { 320 | var entity = BattleManagerTBS.getEntityWithActorId(actorId); 321 | if (entity && entity.battler().isDead()) 322 | return true; 323 | }.bind(this)); 324 | this._preventEntitiesDeath.forEach(function(info) { 325 | var flagId = info[0]; 326 | var entity = BattleManagerTBS.getFlaggedEntity(flagId); 327 | if (entity && entity.battler().isDead()) 328 | return true; 329 | }.bind(this)); 330 | return false; 331 | }; 332 | 333 | LeTBSWinCds.setFlag = function(flagId, on) { 334 | this._flags[flagId] = on; 335 | BattleManagerTBS.checkDefeatAndVictory(); 336 | }; 337 | 338 | 339 | /*------------------------------------------------------------------------- 340 | * BattleManagerTBS 341 | -------------------------------------------------------------------------*/ 342 | BattleManagerTBS.canPrepareDefeat = function() { 343 | return this.allyEntities().every(function(entity) { 344 | return entity.battler().isDead(); 345 | }) || LeTBSWinCds.checkDefeat(); 346 | }; 347 | 348 | BattleManagerTBS.canPrepareVictory = function() { 349 | return LeTBSWinCds.checkVictory(); 350 | }; 351 | 352 | Lecode.S_TBS.WinConditions.oldBattleManagerTBS_battleBeginning = BattleManagerTBS.battleBeginning; 353 | BattleManagerTBS.battleBeginning = function() { 354 | Lecode.S_TBS.WinConditions.oldBattleManagerTBS_battleBeginning.call(this); 355 | LeUtilities.getScene().showWinConditionsWindow(this._startSprite); 356 | }; 357 | 358 | Lecode.S_TBS.WinConditions.oldBattleManagerTBS_beginningPhaseEnd = BattleManagerTBS.beginningPhaseEnd; 359 | BattleManagerTBS.beginningPhaseEnd = function() { 360 | Lecode.S_TBS.WinConditions.oldBattleManagerTBS_beginningPhaseEnd.call(this); 361 | LeUtilities.getScene().hideWinConditionsWindow(); 362 | }; 363 | -------------------------------------------------------------------------------- /LeTBS_YanflyPatch.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # LeTBS: Patch for Yanfly's plugins 4 | # LeTBS_YanflyPatch.js 5 | # By Lecode 6 | # Version 1.0 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 11 | #----------------------------------------------------------------------------- 12 | # Version History 13 | #----------------------------------------------------------------------------- 14 | # - 1.0 : Initial release 15 | #============================================================================= 16 | */ 17 | var Imported = Imported || {}; 18 | Imported["LeTBS_YanflyPatch"] = true; 19 | 20 | var Lecode = Lecode || {}; 21 | Lecode.S_TBS.YanflyPatch = {}; 22 | /*: 23 | * @plugindesc Fix compatibility issues with Yanfly's plugins 24 | * @author Lecode 25 | * @version 1.0 26 | * 27 | * @help 28 | * ... 29 | */ 30 | //#============================================================================= 31 | 32 | if (Imported.YEP_BattleEngineCore) { 33 | 34 | Lecode.S_TBS.YanflyPatch.oldGameBattler_startDamagePopup = Game_Battler.prototype.startDamagePopup; 35 | Game_Battler.prototype.startDamagePopup = function () { 36 | if (!Lecode.S_TBS.commandOn) { 37 | Lecode.S_TBS.YanflyPatch.oldGameBattler_startDamagePopup.call(this); 38 | } 39 | }; 40 | 41 | Sprite_Damage.prototype.setup = function (target) { 42 | this._result = Lecode.S_TBS.commandOn ? target.result() : target.shiftDamagePopup(); 43 | var result = this._result; 44 | if (result.missed || result.evaded) { 45 | this.createMiss(); 46 | } else if (result.hpAffected) { 47 | this.createDigits(0, result.hpDamage); 48 | } else if (target.isAlive() && result.mpDamage !== 0) { 49 | this.createDigits(2, result.mpDamage); 50 | } 51 | if (result.critical) { 52 | this.setupCriticalEffect(); 53 | } 54 | }; 55 | 56 | BattleManager.processVictory = function() { 57 | this._victoryPhase = true; 58 | if (this._windowLayer) this._windowLayer.x = 0; 59 | Yanfly.BEC.BattleManager_processVictory.call(this); 60 | }; 61 | 62 | } //- YEP_BattleEngineCore 63 | 64 | if (Imported.YEP_X_SkillCooldowns) { 65 | Lecode.S_TBS.YanflyPatch.oldBattleManagerTBS_stopBattle = BattleManagerTBS.stopBattle; 66 | BattleManagerTBS.stopBattle = function () { 67 | Lecode.S_TBS.YanflyPatch.oldBattleManagerTBS_stopBattle.call(this); 68 | $gameParty.endBattleCooldowns(); 69 | }; 70 | 71 | if (Imported.LeTBS_Summoning) { 72 | Lecode.S_TBS.YanflyPatch.oldGameTroop_increaseTurn = Game_Troop.prototype.increaseTurn; 73 | Game_Troop.prototype.increaseTurn = function () { 74 | Lecode.S_TBS.YanflyPatch.oldGameTroop_increaseTurn.call(this); 75 | BattleManagerTBS._activeSummons.forEach(function (entity) { 76 | entity.battler().updateCooldowns(); 77 | entity.battler().updateWarmups(); 78 | }); 79 | }; 80 | } 81 | } 82 | 83 | Lecode.S_TBS.YanflyPatch.oldTBSEntity_onTurnStart = TBSEntity.prototype.onTurnStart; 84 | TBSEntity.prototype.onTurnStart = function () { 85 | if (this._battler.onTurnStart) 86 | this._battler.onTurnStart(); 87 | Lecode.S_TBS.YanflyPatch.oldTBSEntity_onTurnStart.call(this); 88 | }; -------------------------------------------------------------------------------- /LeUtilities.js: -------------------------------------------------------------------------------- 1 | /* 2 | #============================================================================= 3 | # Lecode's Utilities 4 | # LeUtilities.js 5 | # By Lecode 6 | # Version 2.4 7 | #----------------------------------------------------------------------------- 8 | # TERMS OF USE 9 | #----------------------------------------------------------------------------- 10 | # - Credit required 11 | # - Keep this header 12 | # - Free for commercial use 13 | #============================================================================= 14 | */ 15 | var Imported = Imported || {}; 16 | Imported["LE - Utilities"] = true; 17 | /*: 18 | * @plugindesc Lecode's utilities plugin. 19 | * @author Lecode 20 | * @version 2.4 21 | * 22 | * @help 23 | * ( Nothing :B ) 24 | */ 25 | //#============================================================================= 26 | 27 | /*------------------------------------------------------------------------- 28 | * Version 1.0 29 | -------------------------------------------------------------------------*/ 30 | 31 | function LeUtilities() { 32 | throw new Error('This is a static class'); 33 | } 34 | 35 | LeUtilities.findBattlerSprite = function(battler) { 36 | if (LeUtilities.isScene("Scene_Battle")) { 37 | if (battler.isActor()) { 38 | var sprites = LeUtilities.getScene()._spriteset._actorSprites; 39 | } else { 40 | var sprites = LeUtilities.getScene()._spriteset._enemySprites; 41 | } 42 | for (var i = 0; i < sprites.length; i++) { 43 | var sprite = sprites[i]; 44 | if (sprite._battler === battler) return sprite; 45 | } 46 | } else { 47 | return null; 48 | } 49 | }; 50 | 51 | LeUtilities.getScene = function() { 52 | return SceneManager._scene; 53 | }; 54 | 55 | LeUtilities.isScene = function(str) { 56 | var scene = this.getScene(); 57 | var bool = eval("scene instanceof " + str); 58 | return bool; 59 | }; 60 | 61 | /*------------------------------------------------------------------------- 62 | * Version 1.1 63 | -------------------------------------------------------------------------*/ 64 | 65 | LeUtilities.stringAppendWithSym = function(str, toAppend, sym) { 66 | toAppend = String(toAppend); 67 | sym = String(sym); 68 | if (toAppend === "") return str; 69 | return (str === "") ? toAppend : str + sym + toAppend; 70 | }; 71 | 72 | LeUtilities.stringAppendWithComma = function(str, toAppend) { 73 | return this.stringAppendWithSym(str, toAppend, ","); 74 | }; 75 | 76 | LeUtilities.stringSplit = function(str, sym) { 77 | str = String(str); 78 | if (str === "") { 79 | return []; 80 | } else if (!str.match(sym)) { 81 | return [str]; 82 | } else { 83 | return str.split(sym); 84 | } 85 | }; 86 | 87 | LeUtilities.CommandGetTextAsArg = function(args, start) { 88 | var text = ""; 89 | for (var i = start; i < args.length; i++) { 90 | text += args[i]; 91 | if (i != args.length - 1) { 92 | text += " "; 93 | } 94 | } 95 | return text; 96 | }; 97 | 98 | /*------------------------------------------------------------------------- 99 | * Version 1.2 100 | -------------------------------------------------------------------------*/ 101 | 102 | LeUtilities.getRandomValueInArray = function(array) { 103 | var index = Math.floor((Math.random() * array.length)); 104 | return array[index]; 105 | }; 106 | 107 | LeUtilities.getXRandomValuesInArray = function(array, x) { 108 | var finalArray = []; 109 | if (x >= array.length) return array; 110 | for (var i = 0; i < x; i++) { 111 | var obj = this.getRandomValueInArray(array); 112 | this.removeInArray(array, obj); 113 | finalArray.push(obj); 114 | } 115 | return finalArray; 116 | }; 117 | 118 | LeUtilities.removeInArray = function(array, element) { 119 | var index = array.indexOf(element); 120 | if (index > -1) { 121 | array.splice(index, 1); 122 | } 123 | }; 124 | 125 | /*------------------------------------------------------------------------- 126 | * Version 1.3 127 | -------------------------------------------------------------------------*/ 128 | 129 | LeUtilities.removeAllChildren = function(holder) { 130 | while (holder.children[0]) { 131 | holder.removeChild(holder.children[0]); 132 | } 133 | }; 134 | 135 | /*------------------------------------------------------------------------- 136 | * Version 1.4 137 | -------------------------------------------------------------------------*/ 138 | 139 | LeUtilities.rectRectCollision = function(rect1, rect2) { 140 | return !(rect2.leU_left() > rect1.leU_right() || 141 | rect2.leU_right() < rect1.leU_left() || 142 | rect2.leU_top() > rect1.leU_bottom() || 143 | rect2.leU_bottom() < rect1.leU_top()); 144 | }; 145 | 146 | /*------------------------------------------------------------------------- 147 | * Version 1.5 148 | -------------------------------------------------------------------------*/ 149 | 150 | LeUtilities.isMyFriend = function(battler, test) { 151 | return (battler.isActor() && test.isActor()) || (!battler.isActor() && !test.isActor()); 152 | }; 153 | 154 | LeUtilities.isMyEnemy = function(battler, test) { 155 | return !this.isMyFriend(battler, test); 156 | }; 157 | 158 | /*------------------------------------------------------------------------- 159 | * Version 1.6 160 | -------------------------------------------------------------------------*/ 161 | 162 | LeUtilities.uniqArray = function(array) { 163 | /*var holder = {}; 164 | return array.filter(function(item) { 165 | return holder.hasOwnProperty(item) ? false : (holder[item] = true); 166 | });*/ 167 | var func = function(value, index, self) { 168 | return self.indexOf(value) === index; 169 | }; 170 | return array.filter(func); 171 | }; 172 | 173 | /*------------------------------------------------------------------------- 174 | * Version 1.7 175 | -------------------------------------------------------------------------*/ 176 | 177 | Sprite.prototype.leU_left = function() { 178 | return this.x - Math.floor(this.leU_trueWidth() * (this.anchor ? this.anchor.x : 0)); 179 | }; 180 | 181 | Sprite.prototype.leU_right = function() { 182 | return this.leU_left() + this.leU_trueWidth(); 183 | } 184 | 185 | Sprite.prototype.leU_top = function() { 186 | return this.y - Math.floor(this.leU_trueHeight() * (this.anchor ? this.anchor.y : 0)); 187 | } 188 | 189 | Sprite.prototype.leU_bottom = function() { 190 | return this.leU_top() + this.leU_trueHeight(); 191 | } 192 | 193 | Sprite.prototype.leU_trueWidth = function() { 194 | return Math.floor(this.width * (this.scale ? this.scale.x : 1)); 195 | } 196 | 197 | Sprite.prototype.leU_trueHeight = function() { 198 | return Math.floor(this.height * (this.scale ? this.scale.y : 1)); 199 | } 200 | 201 | Sprite.prototype.leU_halfWidth = function() { 202 | return Math.floor(this.leU_trueWidth() / 2); 203 | } 204 | 205 | Sprite.prototype.leU_halfHeight = function() { 206 | return Math.floor(this.leU_trueHeight() / 2); 207 | } 208 | 209 | Sprite.prototype.leU_center = function() { 210 | return { 211 | x: this.leU_left() + this.leU_halfWidth(), 212 | y: this.leU_top() + this.leU_halfHeight() 213 | }; 214 | } 215 | 216 | LeUtilities.AToBRelation = function(x, x1, x2, y1, y2, s) { 217 | s = s || 1.0; 218 | return ((y2 - y1) / Math.pow((x2 - x1), s) * 1.0) * Math.pow((x - x1), s) + y1; 219 | }; 220 | 221 | /*------------------------------------------------------------------------- 222 | * Version 1.8 223 | -------------------------------------------------------------------------*/ 224 | 225 | var oldSpriteIni1 = Sprite.prototype.initialize; 226 | Sprite.prototype.initialize = function(bitmap) { 227 | oldSpriteIni1.call(this, bitmap); 228 | this._leU_flashColor = [0, 0, 0, 0]; 229 | this._leU_flashDuration = 0; 230 | this._leU_loopFlash = false; 231 | this._leU_loopFlashData = { 232 | color: [0, 0, 0, 0], 233 | duration: 0 234 | }; 235 | this._leU_flashMode = "blend"; 236 | }; 237 | 238 | Sprite.prototype.leU_startFlash = function(color, duration) { 239 | this._leU_flashColor = LeUtilities.cloneArray(color); 240 | this._leU_flashDuration = duration; 241 | }; 242 | 243 | Sprite.prototype.leU_startLoopFlash = function(color, duration) { 244 | this._leU_loopFlash = true; 245 | this._leU_loopFlashData = { 246 | color: LeUtilities.cloneArray(color), 247 | duration: duration 248 | }; 249 | }; 250 | 251 | Sprite.prototype.leU_setFlashMode = function(mode) { 252 | this._leU_flashMode = mode; 253 | }; 254 | 255 | Sprite.prototype.leU_endLoopFlash = function() { 256 | this._leU_loopFlash = false; 257 | }; 258 | 259 | var oldSpriteUpdate1 = Sprite.prototype.update; 260 | Sprite.prototype.update = function() { 261 | oldSpriteUpdate1.call(this); 262 | this.leU_updateFlash(); 263 | }; 264 | 265 | Sprite.prototype.leU_updateFlash = function() { 266 | if (this._leU_flashDuration > 0) { 267 | var d = this._leU_flashDuration--; 268 | this._leU_flashColor[3] *= (d - 1) / d; 269 | } 270 | if (this._leU_loopFlash && this._leU_flashDuration === 0) 271 | this.leU_startFlash(this._leU_loopFlashData.color, this._leU_loopFlashData.duration); 272 | switch (this._leU_flashMode) { 273 | case "blend": 274 | this.setBlendColor(this._leU_flashColor); 275 | break; 276 | case "tone": 277 | this.setColorTone(this._leU_flashColor); 278 | break; 279 | case "opacity": 280 | this.opacity = this._leU_flashColor[3]; 281 | break; 282 | } 283 | }; 284 | 285 | Sprite.prototype.leU_clearFlash = function() { 286 | this.setBlendColor([0, 0, 0, 0]); 287 | this.setColorTone([0, 0, 0, 0]); 288 | }; 289 | 290 | /*------------------------------------------------------------------------- 291 | * Version 1.9 292 | -------------------------------------------------------------------------*/ 293 | 294 | LeUtilities.cloneArray = function(array) { 295 | return array.slice(0); 296 | } 297 | 298 | Window_Base.prototype.leU_drawText = function(text, x, y) { 299 | if (x === "center") { 300 | x = this.contentsWidth() / 2 - (this.textWidth(text) + 1) / 2; 301 | } 302 | if (y === "center") { 303 | y = this.contentsHeight() / 2 - (this.contents.fontSize + 1) / 2; 304 | } 305 | var rect = { 306 | x: x, 307 | y: y, 308 | w: this.textWidth(text) + 1, 309 | h: this.contents.fontSize + 1 310 | }; 311 | this.drawText(text, x, y, this.contentsWidth(), this.lineHeight()); 312 | return rect; 313 | }; 314 | 315 | /*------------------------------------------------------------------------- 316 | * Version 2.0 317 | -------------------------------------------------------------------------*/ 318 | 319 | var oldWB_initialize1 = Window_Base.prototype.initialize; 320 | Window_Base.prototype.initialize = function(x, y, width, height) { 321 | oldWB_initialize1.call(this, x, y, width, height); 322 | this._leU_float = false; 323 | this._leU_floatData = { 324 | ini_pos: [x, y], 325 | range: [0, 0], 326 | sens: ["+", "+"], 327 | speed: 3 328 | }; 329 | }; 330 | 331 | var oldWB_update1 = Window_Base.prototype.update; 332 | Window_Base.prototype.update = function() { 333 | oldWB_update1.call(this); 334 | this.leU_updateFloat(); 335 | }; 336 | 337 | Window_Base.prototype.leU_updateFloat = function() { 338 | if (!this._leU_float) return; 339 | var data = this._leU_floatData; 340 | //- X 341 | var op = data.sens[0] === "+" ? "this.x+data.speed" : "this.x-data.speed"; 342 | var fx = eval(op); 343 | var dist = Math.abs(fx - data.ini_pos[0]); 344 | if (dist >= data.range[0]) { 345 | fx = this.x; 346 | data.sens[0] = data.sens[0] === "+" ? "-" : "+"; 347 | } 348 | this.move(fx, this.y, this.width, this.height); 349 | //- Y 350 | var op = data.sens[1] === "+" ? "this.y+data.speed" : "this.y-data.speed"; 351 | var fy = eval(op); 352 | var dist = Math.abs(fy - data.ini_pos[1]); 353 | if (dist >= data.range[1]) { 354 | fy = this.y; 355 | data.sens[1] = data.sens[1] === "+" ? "-" : "+"; 356 | } 357 | this.move(this.x, fy, this.width, this.height); 358 | }; 359 | 360 | /*------------------------------------------------------------------------- 361 | * Version 2.1 362 | -------------------------------------------------------------------------*/ 363 | function LeU_WindowConfirmation() { 364 | this.initialize.apply(this, arguments); 365 | } 366 | 367 | LeU_WindowConfirmation.prototype = Object.create(Window_HorzCommand.prototype); 368 | LeU_WindowConfirmation.prototype.constructor = LeU_WindowConfirmation; 369 | 370 | LeU_WindowConfirmation.prototype.initialize = function(width, texts) { 371 | this._okText = "Ok"; 372 | this._cancelText = "Cancel"; 373 | this._headerTexts = texts || ["Are you sure ?"]; 374 | this._windowWidth = width || 300; 375 | var x = Graphics.width / 2 - this.windowWidth() / 2; 376 | var y = Graphics.height / 2 - this.windowHeight() / 2; 377 | Window_HorzCommand.prototype.initialize.call(this, x, y); 378 | }; 379 | 380 | LeU_WindowConfirmation.prototype.windowWidth = function() { 381 | return this._windowWidth; 382 | }; 383 | 384 | LeU_WindowConfirmation.prototype.headerHeight = function() { 385 | return this._headerTexts.length * this.lineHeight(); 386 | }; 387 | 388 | LeU_WindowConfirmation.prototype.windowHeight = function() { 389 | return Window_HorzCommand.prototype.windowHeight.call(this) + this.headerHeight(); 390 | }; 391 | 392 | LeU_WindowConfirmation.prototype.maxCols = function() { 393 | return 2; 394 | }; 395 | 396 | LeU_WindowConfirmation.prototype.makeCommandList = function() { 397 | this.addCommand(this._okText, 'ok'); 398 | this.addCommand(this._cancelText, 'cancel'); 399 | }; 400 | 401 | LeU_WindowConfirmation.prototype.drawHeader = function() { 402 | this.changeTextColor(this.systemColor()); 403 | for (var i = 0; i < this._headerTexts.length; i++) { 404 | var text = this._headerTexts[i]; 405 | this.leU_drawText(text, 0, this.lineHeight() * i, "x"); 406 | } 407 | }; 408 | 409 | LeU_WindowConfirmation.prototype.itemRect = function(index) { 410 | var rect = new Rectangle(); 411 | var maxCols = this.maxCols(); 412 | rect.width = this.itemWidth(); 413 | rect.height = this.itemHeight(); 414 | rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX; 415 | rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY; 416 | rect.y += this.headerHeight(); 417 | return rect; 418 | }; 419 | 420 | var oldLeU_WC_drawAllItems = LeU_WindowConfirmation.prototype.drawAllItems; 421 | LeU_WindowConfirmation.prototype.drawAllItems = function() { 422 | this.resetFontSettings(); 423 | this.drawHeader(); 424 | this.contents.fontSize -= 4; 425 | this.changeTextColor(this.normalColor()); 426 | oldLeU_WC_drawAllItems.call(this); 427 | }; 428 | 429 | /*------------------------------------------------------------------------- 430 | * Version 2.2 431 | -------------------------------------------------------------------------*/ 432 | LeUtilities.getMinInArray = function(array) { 433 | return array.sort(function(a, b) { 434 | return (a > b) ? 1 : ((a < b) ? -1 : 0); 435 | }.bind(this))[0]; 436 | }; 437 | 438 | LeUtilities.getMaxInArray = function(array) { 439 | return array.sort(function(a, b) { 440 | return (a > b) ? 1 : ((a < b) ? -1 : 0); 441 | }.bind(this)).pop(); 442 | }; 443 | 444 | LeUtilities.distanceBetween = function(a, b) { 445 | var dx = a.x - b.x; 446 | var dy = a.y - b.y; 447 | return Math.sqrt(dx * dx + dy * dy); 448 | }; 449 | 450 | LeUtilities.distanceBetweenCells = function(a, b) { 451 | return Math.abs(a.x - b.x) + Math.abs(a.y - b.y); 452 | }; 453 | 454 | LeUtilities.closestByDistance = function(obj, array) { 455 | return array.sort(function(a, b) { 456 | var obj_aDist = this.distanceBetween(a, obj); 457 | var obj_bDist = this.distanceBetween(b, obj); 458 | return (obj_aDist > obj_bDist) ? 1 : ((obj_aDist < obj_bDist) ? -1 : 0); 459 | }.bind(this))[0]; 460 | }; 461 | 462 | LeUtilities.farthestByDistance = function(obj, array) { 463 | return array.sort(function(a, b) { 464 | var obj_aDist = this.distanceBetween(a, obj); 465 | var obj_bDist = this.distanceBetween(b, obj); 466 | return (obj_aDist > obj_bDist) ? 1 : ((obj_aDist < obj_bDist) ? -1 : 0); 467 | }.bind(this)).pop(); 468 | }; 469 | 470 | Array.prototype.leU_find = function(func) { 471 | for (var i = 0; i < this.length; i++) 472 | if (func(this[i])) 473 | return this[i]; 474 | return null; 475 | }; 476 | 477 | Sprite.prototype.leU_move = function(speed, destX, destY, callback) { 478 | if (this.x == destX && this.y == destY) return; 479 | this.leU_moveX(speed, destX); 480 | this.leU_moveY(speed, destY); 481 | if (this.x == destX && this.y == destY && callback) 482 | callback(); 483 | }; 484 | 485 | Sprite.prototype.leU_moveX = function(speed, destX) { 486 | if (this.x == destX) return; 487 | var dir = (this.x > destX) ? -1 : 1; 488 | this.x += speed * dir; 489 | if (dir == 1 && this.x >= destX || dir == -1 && this.x <= destX) 490 | this.x = destX; 491 | }; 492 | 493 | Sprite.prototype.leU_moveY = function(speed, destY) { 494 | if (this.y == destY) return; 495 | var dir = (this.y > destY) ? -1 : 1; 496 | this.y += speed * dir; 497 | if (dir == 1 && this.y >= destY || dir == -1 && this.y <= destY) 498 | this.y = destY; 499 | }; 500 | 501 | Array.prototype.leU_last = function() { 502 | return this[this.length - 1]; 503 | }; 504 | 505 | LeUtilities.getPixelsOfLine = function(x0, y0, x1, y1, sprite) { 506 | var pixels = []; 507 | var dx = Math.abs(x1 - x0); 508 | var dy = Math.abs(y1 - y0); 509 | var sx = (x0 < x1) ? 1 : -1; 510 | var sy = (y0 < y1) ? 1 : -1; 511 | var err = dx - dy; 512 | 513 | while (true) { 514 | pixels.push([x0, y0]); 515 | if (sprite) 516 | sprite.bitmap.fillRect(x0, y0, 1, 1, "#000000"); 517 | 518 | if ((x0 == x1) && (y0 == y1)) break; 519 | var e2 = 2 * err; 520 | if (e2 > -dy) { 521 | err -= dy; 522 | x0 += sx; 523 | } 524 | if (e2 < dx) { 525 | err += dx; 526 | y0 += sy; 527 | } 528 | } 529 | return pixels; 530 | }; 531 | 532 | LeUtilities.EXP_getPixelsOfParabola = function(x0, y0, x1, y1, height) { 533 | if (x0 == x1) return this.getPixelsOfLine(x0, y0, x1, y1); 534 | var pixels = []; 535 | var top_y, top_x, start_x, start_y, dest_x, dest_y; 536 | 537 | top_y = (y0 + y1) / 2 - height; 538 | if (y0 > y1) { 539 | start_y = y1; 540 | dest_y = y0; 541 | } else { 542 | start_y = y0; 543 | dest_y = y1; 544 | } 545 | if (x0 > x1) { 546 | start_x = x1; 547 | dest_x = x0; 548 | } else { 549 | dest_x = x1; 550 | start_x = x0; 551 | } 552 | var k = -Math.sqrt((top_y - start_y) / (top_y - dest_y)); 553 | var v = (k * dest_x - start_x) / (k - 1); 554 | var u = (top_y - start_y) / ((start_x - v) * (start_x - v)); 555 | for (var x = start_x; x <= dest_x; x++) { 556 | var y = top_y - u * (x - v) * (x - v); 557 | pixels.push([parseInt(x), parseInt(y)]); 558 | } 559 | if (x0 > x1) 560 | pixels.reverse(); 561 | return pixels; 562 | }; 563 | 564 | LeUtilities.doesRectIncludeCoord = function(cx, cy, w, h, coords) { 565 | var x = coords[0], 566 | y = coords[1]; 567 | if (x > cx && x < (cx + w) && y > cy && y < (cy + h)) 568 | return true; 569 | return false; 570 | }; 571 | 572 | LeUtilities.isNumeric = function(n) { 573 | return !isNaN(parseFloat(n)) && isFinite(n); 574 | }; 575 | 576 | /*------------------------------------------------------------------------- 577 | * Version 2.3 578 | -------------------------------------------------------------------------*/ 579 | LeUtilities.getPixelsOfParabola = function(x1, y1, x2, y2, x3, y3) { 580 | var pixels = []; 581 | var a = (x1 * (y3 - y2) - x2 * y3 + y2 * x3 + y1 * (x2 - x3)) / (x1 * ((x3 * x3) - (x2 * x2)) - x2 * (x3 * x3) + (x2 * x2) * x3 + (x1 * x1) * (x2 - x3)); 582 | var b = -((x1 * x1) * (y3 - y2) - (x2 * x2) * y3 + y2 * (x3 * x3) + y1 * ((x2 * x2) - (x3 * x3))) / (x1 * ((x3 * x3) - (x2 * x2)) - x2 * (x3 * x3) + (x2 * x2) * x3 + (x1 * x1) * (x2 - x3)); 583 | var c = (x1 * (y2 * (x3 * x3) - (x2 * x2) * y3) + (x1 * x1) * (x2 * y3 - y2 * x3) + y1 * ((x2 * x2) * x3 - x2 * (x3 * x3))) / (x1 * ((x3 * x3) - (x2 * x2)) - x2 * (x3 * x3) + (x2 * x2) * x3 + (x1 * x1) * (x2 - x3)); 584 | var start_x; 585 | var end_x; 586 | if (x1 <= x3) { 587 | start_x = x1; 588 | end_x = x3; 589 | } else { 590 | start_x = x3; 591 | end_x = x1; 592 | } 593 | for (var x = start_x; x <= end_x; x++) { 594 | var y = a * x * x + b * x + c; 595 | pixels.push([x, y]); 596 | } 597 | return pixels; 598 | }; 599 | 600 | LeUtilities.getPixelsOfJump = function(sx, sy, dx, dy, h) { 601 | var mx = sx + (sx - dx) / 2; 602 | var my = sy + (sy - dy) / 2 + h; 603 | return this.getPixelsOfParabola(sx, sy, mx, my, dx, dy); 604 | }; 605 | 606 | LeUtilities.randValueBetween = function(min, max) { 607 | return Math.floor(Math.random() * (max - min + 1) + min); 608 | }; 609 | 610 | /*------------------------------------------------------------------------- 611 | * Version 2.4 612 | -------------------------------------------------------------------------*/ 613 | var oldTI_onMouseMove = TouchInput._onMouseMove; 614 | TouchInput._onMouseMove = function (event) { 615 | oldTI_onMouseMove.call(this, event); 616 | this._leMouseX = event.pageX; 617 | this._leMouseY = event.pageY; 618 | }; 619 | 620 | Window_Base.prototype.isMouseInsideFrame = function() { 621 | return this.getBounds().contains(TouchInput._leMouseX, TouchInput._leMouseY); 622 | /*var x = this.canvasToLocalX(TouchInput._leMouseX || -1); 623 | var y = this.canvasToLocalY(TouchInput._leMouseY || -1); 624 | return x >= 0 && y >= 0 && x < this.width && y < this.height;*/ 625 | }; 626 | 627 | function LeU_WindowScrollable() { 628 | this.initialize.apply(this, arguments); 629 | } 630 | 631 | LeU_WindowScrollable.prototype = Object.create(Window_Base.prototype); 632 | LeU_WindowScrollable.prototype.constructor = LeU_WindowScrollable; 633 | 634 | LeU_WindowScrollable.prototype.initialize = function(x, y, w, h) { 635 | Window_Base.prototype.initialize.call(this, x, y, w, h); 636 | }; 637 | 638 | LeU_WindowScrollable.prototype.lineHeight = function() { 639 | return Window_Base.prototype.lineHeight.call(this); 640 | }; 641 | 642 | LeU_WindowScrollable.prototype.contentsHeight = function() { 643 | return this._lines * this.lineHeight() + this.standardPadding() * 2; 644 | }; 645 | 646 | LeU_WindowScrollable.prototype.visibleLines = function() { 647 | return 1; 648 | }; 649 | 650 | LeU_WindowScrollable.prototype.refresh = function() { 651 | this.contents.clear(); 652 | this.makeLineNumbers.apply(this, arguments); 653 | this.createContents(); 654 | this.drawConcents.apply(this, arguments); 655 | }; 656 | 657 | LeU_WindowScrollable.prototype.makeLineNumbers = function() { 658 | if (!this._lines) this._lines = 1; 659 | this._hiddenLines = this._lines - this.visibleLines(); 660 | }; 661 | 662 | LeU_WindowScrollable.prototype.drawConcents = function() { 663 | 664 | }; 665 | 666 | LeU_WindowScrollable.prototype.update = function() { 667 | Window_Base.prototype.update.call(this); 668 | this.downArrowVisible = this.needScroll(); 669 | if (this.isMouseInsideFrame()) 670 | this.processWheel(); 671 | }; 672 | 673 | LeU_WindowScrollable.prototype.needScroll = function() { 674 | return this._hiddenLines > 0; 675 | }; 676 | 677 | LeU_WindowScrollable.prototype.processWheel = function() { 678 | var threshold = 20; 679 | if (TouchInput.wheelY >= threshold && this.needScroll()) { 680 | this.scrollDown(); 681 | } 682 | if (TouchInput.wheelY <= -threshold && this.origin.y > 0) { 683 | this.scrollUp(); 684 | } 685 | }; 686 | 687 | LeU_WindowScrollable.prototype.scrollDown = function() { 688 | this.origin.y += this.scrollSpeed(); 689 | this._hiddenLines--; 690 | }; 691 | 692 | LeU_WindowScrollable.prototype.scrollUp = function() { 693 | this.origin.y -= this.scrollSpeed(); 694 | this._hiddenLines++; 695 | }; 696 | 697 | LeU_WindowScrollable.prototype.scrollSpeed = function() { 698 | return this.lineHeight(); 699 | }; 700 | 701 | 702 | /*------------------------------------------------------------------------- 703 | * Version 2.5 704 | -------------------------------------------------------------------------*/ 705 | LeUtilities.rectCoordCollision = function(rect1, x, y) { 706 | var sprite = new Sprite(); 707 | sprite.x = x; 708 | sprite.y = y; 709 | return this.rectRectCollision(rect1, sprite); 710 | }; 711 | 712 | LeUtilities.getWrappedLines = function(text, window) { 713 | var words = text.split(" "); 714 | var lines = []; 715 | var line = ""; 716 | var lineWidth = 0; 717 | for (var i = 0; i < words.length; i++) { 718 | var word = (i === words.length - 1) ? words[i] : words[i] + " "; 719 | lineWidth += window.textWidth(word); 720 | if (lineWidth > window.contentsWidth()) { 721 | i--; 722 | lineWidth = 0; 723 | lines.push(line); 724 | line = ""; 725 | continue; 726 | } 727 | line += word; 728 | if (i === words.length - 1) 729 | lines.push(line); 730 | } 731 | return lines; 732 | }; 733 | 734 | LeUtilities.shrinkTextWithUnderscores = function(text) { 735 | return text.replace(/\_(.)/ig, function(word) { 736 | return word[1].toUpperCase(); 737 | }).replace(/\b(.)/i, function(word) { 738 | return word.toUpperCase(); 739 | }); 740 | }; 741 | 742 | 743 | /*------------------------------------------------------------------------- 744 | * Version 2.6 745 | -------------------------------------------------------------------------*/ 746 | LeUtilities.directionCodeToText = function(dirCode) { 747 | switch (dirCode) { 748 | case 2: 749 | return "down"; 750 | case 4: 751 | return "left"; 752 | case 6: 753 | return "right"; 754 | case 8: 755 | return "up"; 756 | } 757 | return ""; 758 | }; 759 | 760 | LeUtilities.resetMapEvents = function() { 761 | var letters = ["A", "B", "C", "D"]; 762 | var events = $gameMap.events(); 763 | for (var i = 0; i < events.length; i++) { 764 | var id = events[i].eventId(); 765 | var mapId = events[i]._mapId; 766 | for (var j = 0; j < letters.length; j++) { 767 | var key = [mapId, id, letters[j]]; 768 | $gameSelfSwitches.setValue(key, 0); 769 | } 770 | events[i].refresh(); 771 | } 772 | }; 773 | 774 | 775 | /*------------------------------------------------------------------------- 776 | * Version 2.7 777 | -------------------------------------------------------------------------*/ 778 | LeUtilities.sumOfArray = function (array) { 779 | if (array.length === 0) return 0; 780 | return array.reduce(function(a,b){ 781 | return a + b; 782 | }); 783 | }; 784 | 785 | LeUtilities.avgOfArray = function (array) { 786 | return this.sumOfArray(array) / array.length; 787 | }; 788 | LeUtilities.getMinInArrayBy = function(array,prop) { 789 | return array.sort(function(a, b) { 790 | return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0); 791 | }.bind(this))[0]; 792 | }; 793 | 794 | LeUtilities.getMaxInArrayBy = function(array,prop) { 795 | return array.sort(function(a, b) { 796 | return (a[prop] > b[prop]) ? 1 : ((a[prop] < b[prop]) ? -1 : 0); 797 | }.bind(this)).pop(); 798 | }; 799 | 800 | 801 | /*------------------------------------------------------------------------- 802 | * Version 2.8 803 | -------------------------------------------------------------------------*/ 804 | LeUtilities.hexToRgb = function(hex) { 805 | var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 806 | return result ? { 807 | r: parseInt(result[1], 16), 808 | g: parseInt(result[2], 16), 809 | b: parseInt(result[3], 16) 810 | } : null; 811 | }; 812 | 813 | LeUtilities.doesResourceExist = function(path) { 814 | var bitmap = Bitmap.load(path); 815 | return !bitmap.isError(); 816 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LeTBS 2 | A tactical battle system for the game engine RPG Maker MV. 3 | More information there: https://lecodemv.github.io/leTBS/. 4 | 5 | # Terms of Use 6 | https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt 7 | --------------------------------------------------------------------------------