diff --git a/data/System.json b/data/System.json index cf99325..d3999e7 100644 --- a/data/System.json +++ b/data/System.json @@ -1 +1 @@ -{"airship":{"bgm":{"name":"Ship3","pan":0,"pitch":100,"volume":90},"characterIndex":3,"characterName":"Vehicle","startMapId":0,"startX":0,"startY":0},"armorTypes":["","General Armor","Magic Armor","Light Armor","Heavy Armor","Small Shield","Large Shield"],"attackMotions":[{"type":0,"weaponImageId":0},{"type":1,"weaponImageId":1},{"type":1,"weaponImageId":2},{"type":1,"weaponImageId":3},{"type":1,"weaponImageId":4},{"type":1,"weaponImageId":5},{"type":1,"weaponImageId":6},{"type":2,"weaponImageId":7},{"type":2,"weaponImageId":8},{"type":2,"weaponImageId":9},{"type":0,"weaponImageId":10},{"type":0,"weaponImageId":11},{"type":0,"weaponImageId":12}],"battleBgm":{"name":"Battle1","pan":0,"pitch":100,"volume":90},"battleback1Name":"Grassland","battleback2Name":"Grassland","battlerHue":0,"battlerName":"Dragon","boat":{"bgm":{"name":"Ship1","pan":0,"pitch":100,"volume":90},"characterIndex":0,"characterName":"Vehicle","startMapId":0,"startX":0,"startY":0},"currencyUnit":"G","defeatMe":{"name":"Defeat1","pan":0,"pitch":100,"volume":90},"editMapId":4,"elements":["","Physical","Fire","Ice","Thunder","Water","Earth","Wind","Light","Darkness"],"equipTypes":["","Weapon","Shield","Head","Body","Accessory"],"gameTitle":"Superproject1","gameoverMe":{"name":"Gameover1","pan":0,"pitch":100,"volume":90},"locale":"en_US","magicSkills":[1],"menuCommands":[true,true,true,true,true,true],"optDisplayTp":true,"optDrawTitle":true,"optExtraExp":false,"optFloorDeath":false,"optFollowers":true,"optSideView":false,"optSlipDeath":false,"optTransparent":false,"partyMembers":[1,2,3,4],"ship":{"bgm":{"name":"Ship2","pan":0,"pitch":100,"volume":90},"characterIndex":1,"characterName":"Vehicle","startMapId":0,"startX":0,"startY":0},"skillTypes":["","Magic","Special"],"sounds":[{"name":"Cursor2","pan":0,"pitch":100,"volume":90},{"name":"Decision1","pan":0,"pitch":100,"volume":90},{"name":"Cancel2","pan":0,"pitch":100,"volume":90},{"name":"Buzzer1","pan":0,"pitch":100,"volume":90},{"name":"Equip1","pan":0,"pitch":100,"volume":90},{"name":"Save","pan":0,"pitch":100,"volume":90},{"name":"Load","pan":0,"pitch":100,"volume":90},{"name":"Battle1","pan":0,"pitch":100,"volume":90},{"name":"Run","pan":0,"pitch":100,"volume":90},{"name":"Attack3","pan":0,"pitch":100,"volume":90},{"name":"Damage4","pan":0,"pitch":100,"volume":90},{"name":"Collapse1","pan":0,"pitch":100,"volume":90},{"name":"Collapse2","pan":0,"pitch":100,"volume":90},{"name":"Collapse3","pan":0,"pitch":100,"volume":90},{"name":"Damage5","pan":0,"pitch":100,"volume":90},{"name":"Collapse4","pan":0,"pitch":100,"volume":90},{"name":"Recovery","pan":0,"pitch":100,"volume":90},{"name":"Miss","pan":0,"pitch":100,"volume":90},{"name":"Evasion1","pan":0,"pitch":100,"volume":90},{"name":"Evasion2","pan":0,"pitch":100,"volume":90},{"name":"Reflection","pan":0,"pitch":100,"volume":90},{"name":"Shop1","pan":0,"pitch":100,"volume":90},{"name":"Item3","pan":0,"pitch":100,"volume":90},{"name":"Item3","pan":0,"pitch":100,"volume":90}],"startMapId":4,"startX":4,"startY":9,"switches":["","","","","","","","","","","","","","","","","","","","",""],"terms":{"basic":["Level","Lv","HP","HP","MP","MP","TP","TP","EXP","EXP"],"commands":["Fight","Escape","Attack","Guard","Item","Skill","Equip","Status","Formation","Save","Game End","Options","Weapon","Armor","Key Item","Equip","Optimize","Clear","New Game","Continue",null,"To Title","Cancel",null,"Buy","Sell"],"params":["Max HP","Max MP","Attack","Defense","M.Attack","M.Defense","Agility","Luck","Hit","Evasion"],"messages":{"actionFailure":"There was no effect on %1!","actorDamage":"%1 took %2 damage!","actorDrain":"%1 was drained of %2 %3!","actorGain":"%1 gained %2 %3!","actorLoss":"%1 lost %2 %3!","actorNoDamage":"%1 took no damage!","actorNoHit":"Miss! %1 took no damage!","actorRecovery":"%1 recovered %2 %3!","alwaysDash":"Always Dash","bgmVolume":"BGM Volume","bgsVolume":"BGS Volume","buffAdd":"%1's %2 went up!","buffRemove":"%1's %2 returned to normal!","commandRemember":"Command Remember","counterAttack":"%1 counterattacked!","criticalToActor":"A painful blow!!","criticalToEnemy":"An excellent hit!!","debuffAdd":"%1's %2 went down!","defeat":"%1 was defeated.","emerge":"%1 emerged!","enemyDamage":"%1 took %2 damage!","enemyDrain":"%1 was drained of %2 %3!","enemyGain":"%1 gained %2 %3!","enemyLoss":"%1 lost %2 %3!","enemyNoDamage":"%1 took no damage!","enemyNoHit":"Miss! %1 took no damage!","enemyRecovery":"%1 recovered %2 %3!","escapeFailure":"However, it was unable to escape!","escapeStart":"%1 has started to escape!","evasion":"%1 evaded the attack!","expNext":"To Next %1","expTotal":"Current %1","file":"File","levelUp":"%1 is now %2 %3!","loadMessage":"Load which file?","magicEvasion":"%1 nullified the magic!","magicReflection":"%1 reflected the magic!","meVolume":"ME Volume","obtainExp":"%1 %2 received!","obtainGold":"%1\\G found!","obtainItem":"%1 found!","obtainSkill":"%1 learned!","partyName":"%1's Party","possession":"Possession","preemptive":"%1 got the upper hand!","saveMessage":"Save to which file?","seVolume":"SE Volume","substitute":"%1 protected %2!","surprise":"%1 was surprised!","useItem":"%1 uses %2!","victory":"%1 was victorious!"}},"testBattlers":[{"actorId":1,"equips":[1,1,2,3,0],"level":1},{"actorId":2,"equips":[2,1,2,3,0],"level":1},{"actorId":3,"equips":[3,0,2,3,4],"level":1},{"actorId":4,"equips":[4,0,2,3,4],"level":1}],"testTroopId":4,"title1Name":"Castle","title2Name":"","titleBgm":{"name":"Theme6","pan":0,"pitch":100,"volume":90},"variables":["","","","","","","","","","","","","","","","","","","","",""],"versionId":58281197,"victoryMe":{"name":"Victory1","pan":0,"pitch":100,"volume":90},"weaponTypes":["","Dagger","Sword","Flail","Axe","Whip","Cane","Bow","Crossbow","Gun","Claw","Glove","Spear"],"windowTone":[0,0,0,0]} \ No newline at end of file +{"airship":{"bgm":{"name":"Ship3","pan":0,"pitch":100,"volume":90},"characterIndex":3,"characterName":"Vehicle","startMapId":0,"startX":0,"startY":0},"armorTypes":["","General Armor","Magic Armor","Light Armor","Heavy Armor","Small Shield","Large Shield"],"attackMotions":[{"type":0,"weaponImageId":0},{"type":1,"weaponImageId":1},{"type":1,"weaponImageId":2},{"type":1,"weaponImageId":3},{"type":1,"weaponImageId":4},{"type":1,"weaponImageId":5},{"type":1,"weaponImageId":6},{"type":2,"weaponImageId":7},{"type":2,"weaponImageId":8},{"type":2,"weaponImageId":9},{"type":0,"weaponImageId":10},{"type":0,"weaponImageId":11},{"type":0,"weaponImageId":12}],"battleBgm":{"name":"Battle1","pan":0,"pitch":100,"volume":90},"battleback1Name":"Grassland","battleback2Name":"Grassland","battlerHue":0,"battlerName":"Dragon","boat":{"bgm":{"name":"Ship1","pan":0,"pitch":100,"volume":90},"characterIndex":0,"characterName":"Vehicle","startMapId":0,"startX":0,"startY":0},"currencyUnit":"G","defeatMe":{"name":"Defeat1","pan":0,"pitch":100,"volume":90},"editMapId":4,"elements":["","Physical","Fire","Ice","Thunder","Water","Earth","Wind","Light","Darkness"],"equipTypes":["","Weapon","Shield","Head","Body","Accessory"],"gameTitle":"Superproject1","gameoverMe":{"name":"Gameover1","pan":0,"pitch":100,"volume":90},"locale":"en_US","magicSkills":[1],"menuCommands":[true,true,true,true,true,true],"optDisplayTp":true,"optDrawTitle":true,"optExtraExp":false,"optFloorDeath":false,"optFollowers":true,"optSideView":false,"optSlipDeath":false,"optTransparent":false,"partyMembers":[1,2,3,4],"ship":{"bgm":{"name":"Ship2","pan":0,"pitch":100,"volume":90},"characterIndex":1,"characterName":"Vehicle","startMapId":0,"startX":0,"startY":0},"skillTypes":["","Magic","Special"],"sounds":[{"name":"Cursor2","pan":0,"pitch":100,"volume":90},{"name":"Decision1","pan":0,"pitch":100,"volume":90},{"name":"Cancel2","pan":0,"pitch":100,"volume":90},{"name":"Buzzer1","pan":0,"pitch":100,"volume":90},{"name":"Equip1","pan":0,"pitch":100,"volume":90},{"name":"Save","pan":0,"pitch":100,"volume":90},{"name":"Load","pan":0,"pitch":100,"volume":90},{"name":"Battle1","pan":0,"pitch":100,"volume":90},{"name":"Run","pan":0,"pitch":100,"volume":90},{"name":"Attack3","pan":0,"pitch":100,"volume":90},{"name":"Damage4","pan":0,"pitch":100,"volume":90},{"name":"Collapse1","pan":0,"pitch":100,"volume":90},{"name":"Collapse2","pan":0,"pitch":100,"volume":90},{"name":"Collapse3","pan":0,"pitch":100,"volume":90},{"name":"Damage5","pan":0,"pitch":100,"volume":90},{"name":"Collapse4","pan":0,"pitch":100,"volume":90},{"name":"Recovery","pan":0,"pitch":100,"volume":90},{"name":"Miss","pan":0,"pitch":100,"volume":90},{"name":"Evasion1","pan":0,"pitch":100,"volume":90},{"name":"Evasion2","pan":0,"pitch":100,"volume":90},{"name":"Reflection","pan":0,"pitch":100,"volume":90},{"name":"Shop1","pan":0,"pitch":100,"volume":90},{"name":"Item3","pan":0,"pitch":100,"volume":90},{"name":"Item3","pan":0,"pitch":100,"volume":90}],"startMapId":4,"startX":4,"startY":9,"switches":["","","","","","","","","","","","","","","","","","","","",""],"terms":{"basic":["Level","Lv","HP","HP","MP","MP","TP","TP","EXP","EXP"],"commands":["Fight","Escape","Attack","Guard","Item","Skill","Equip","Status","Formation","Save","Game End","Options","Weapon","Armor","Key Item","Equip","Optimize","Clear","New Game","Continue",null,"To Title","Cancel",null,"Buy","Sell"],"params":["Max HP","Max MP","Attack","Defense","M.Attack","M.Defense","Agility","Luck","Hit","Evasion"],"messages":{"actionFailure":"There was no effect on %1!","actorDamage":"%1 took %2 damage!","actorDrain":"%1 was drained of %2 %3!","actorGain":"%1 gained %2 %3!","actorLoss":"%1 lost %2 %3!","actorNoDamage":"%1 took no damage!","actorNoHit":"Miss! %1 took no damage!","actorRecovery":"%1 recovered %2 %3!","alwaysDash":"Always Dash","bgmVolume":"BGM Volume","bgsVolume":"BGS Volume","buffAdd":"%1's %2 went up!","buffRemove":"%1's %2 returned to normal!","commandRemember":"Command Remember","counterAttack":"%1 counterattacked!","criticalToActor":"A painful blow!!","criticalToEnemy":"An excellent hit!!","debuffAdd":"%1's %2 went down!","defeat":"%1 was defeated.","emerge":"%1 emerged!","enemyDamage":"%1 took %2 damage!","enemyDrain":"%1 was drained of %2 %3!","enemyGain":"%1 gained %2 %3!","enemyLoss":"%1 lost %2 %3!","enemyNoDamage":"%1 took no damage!","enemyNoHit":"Miss! %1 took no damage!","enemyRecovery":"%1 recovered %2 %3!","escapeFailure":"However, it was unable to escape!","escapeStart":"%1 has started to escape!","evasion":"%1 evaded the attack!","expNext":"To Next %1","expTotal":"Current %1","file":"File","levelUp":"%1 is now %2 %3!","loadMessage":"Load which file?","magicEvasion":"%1 nullified the magic!","magicReflection":"%1 reflected the magic!","meVolume":"ME Volume","obtainExp":"%1 %2 received!","obtainGold":"%1\\G found!","obtainItem":"%1 found!","obtainSkill":"%1 learned!","partyName":"%1's Party","possession":"Possession","preemptive":"%1 got the upper hand!","saveMessage":"Save to which file?","seVolume":"SE Volume","substitute":"%1 protected %2!","surprise":"%1 was surprised!","useItem":"%1 uses %2!","victory":"%1 was victorious!"}},"testBattlers":[{"actorId":1,"equips":[1,1,2,3,0],"level":1},{"actorId":2,"equips":[2,1,2,3,0],"level":1},{"actorId":3,"equips":[3,0,2,3,4],"level":1},{"actorId":4,"equips":[4,0,2,3,4],"level":1}],"testTroopId":4,"title1Name":"Castle","title2Name":"","titleBgm":{"name":"Theme6","pan":0,"pitch":100,"volume":90},"variables":["","","","","","","","","","","","","","","","","","","","",""],"versionId":70595416,"victoryMe":{"name":"Victory1","pan":0,"pitch":100,"volume":90},"weaponTypes":["","Dagger","Sword","Flail","Axe","Whip","Cane","Bow","Crossbow","Gun","Claw","Glove","Spear"],"windowTone":[0,0,0,0]} \ No newline at end of file diff --git a/js/plugins.js b/js/plugins.js index c20430d..f99bf9b 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -17,5 +17,41 @@ var $plugins = {"name":"SRD_EquipCompareUpgrade","status":true,"description":"Allows for developers to customize all the visible parameters that can be seen on the Equip Screen.","parameters":{"Default Pos Color":"#80ff80","Default Neg Color":"#c08080","Window Width":"356","Font Size":"24","Line Padding":"8","== Stat 1 ==":"","Stat 1 Name":"Max HP","Stat 1 Eval":"actor.mhp","Stat 1 Format":"val","== Stat 2 ==":"","Stat 2 Name":"Max MP","Stat 2 Eval":"actor.mmp","Stat 2 Format":"val","== Stat 3 ==":"","Stat 3 Name":"Attack","Stat 3 Eval":"actor.atk","Stat 3 Format":"val","== Stat 4 ==":"","Stat 4 Name":"Defense","Stat 4 Eval":"actor.def","Stat 4 Format":"val","== Stat 5 ==":"","Stat 5 Name":"M. Attack","Stat 5 Eval":"actor.mat","Stat 5 Format":"val","== Stat 6 ==":"","Stat 6 Name":"M. Defense","Stat 6 Eval":"actor.mdf","Stat 6 Format":"val","== Stat 7 ==":"","Stat 7 Name":"Agility","Stat 7 Eval":"actor.agi","Stat 7 Format":"val","== Stat 8 ==":"","Stat 8 Name":"Luck","Stat 8 Eval":"actor.luk","Stat 8 Format":"val","== Stat 9 ==":"","Stat 9 Name":"Hit Rate","Stat 9 Eval":"Math.floor(actor.hit * 100)","Stat 9 Format":"val%","== Stat 10 ==":"","Stat 10 Name":"Evade Rate","Stat 10 Eval":"Math.floor(actor.eva * 100)","Stat 10 Format":"val%","== Stat 11 ==":"","Stat 11 Name":"Critical Rate","Stat 11 Eval":"Math.floor(actor.cri * 100)","Stat 11 Format":"val%","== Stat 12 ==":"","Stat 12 Name":"Critical Evade","Stat 12 Eval":"Math.floor(actor.cev * 100)","Stat 12 Format":"val%","== Stat 13 ==":"","Stat 13 Name":"M. Evasion","Stat 13 Eval":"Math.floor(actor.mev * 100)","Stat 13 Format":"val%","== Stat 14 ==":"","Stat 14 Name":"M. Reflect","Stat 14 Eval":"Math.floor(actor.mrf * 100)","Stat 14 Format":"val%","== Stat 15 ==":"","Stat 15 Name":"Counter Rate","Stat 15 Eval":"Math.floor(actor.cnt * 100)","Stat 15 Format":"val%","== Stat 16 ==":"","Stat 16 Name":"HP Regen","Stat 16 Eval":"Math.floor(actor.hrg * 100)","Stat 16 Format":"val%","== Stat 17 ==":"","Stat 17 Name":"MP Regen","Stat 17 Eval":"Math.floor(actor.mrg * 100)","Stat 17 Format":"val%","== Stat 18 ==":"","Stat 18 Name":"TP Regen","Stat 18 Eval":"Math.floor(actor.trg * 100)","Stat 18 Format":"val%","== Stat 19 ==":"","Stat 19 Name":"Target Rate","Stat 19 Eval":"Math.floor(actor.tgr * 100)","Stat 19 Format":"val%","== Stat 20 ==":"","Stat 20 Name":"Guard Effect","Stat 20 Eval":"Math.floor(actor.grd * 100)","Stat 20 Format":"val%","== Stat 21 ==":"","Stat 21 Name":"Recover Rate","Stat 21 Eval":"Math.floor(actor.rec * 100)","Stat 21 Format":"val%","== Stat 22 ==":"","Stat 22 Name":"Pharmacology","Stat 22 Eval":"Math.floor(actor.pha * 100)","Stat 22 Format":"val%","== Stat 23 ==":"","Stat 23 Name":"MP Cost Rate","Stat 23 Eval":"Math.floor(actor.mcr * 100)","Stat 23 Format":"val%","== Stat 24 ==":"","Stat 24 Name":"TP Cost Rate","Stat 24 Eval":"Math.floor(actor.tcr * 100)","Stat 24 Format":"val%","== Stat 25 ==":"","Stat 25 Name":"Damage Rate","Stat 25 Eval":"Math.floor(actor.pdr * 100)","Stat 25 Format":"val%","== Stat 26 ==":"","Stat 26 Name":"M. Damage Rate","Stat 26 Eval":"Math.floor(actor.mdr * 100)","Stat 26 Format":"val%","== Stat 27 ==":"","Stat 27 Name":"Floor Damage Rate","Stat 27 Eval":"Math.floor(actor.fdr * 100)","Stat 27 Format":"val%","== Stat 28 ==":"","Stat 28 Name":"EXP Rate","Stat 28 Eval":"Math.floor(actor.exr * 100)","Stat 28 Format":"val%","== Stat 29 ==":"","Stat 29 Name":"","Stat 29 Eval":"","Stat 29 Format":"val","== Stat 30 ==":"","Stat 30 Name":"","Stat 30 Eval":"","Stat 30 Format":"val","== Stat 31 ==":"","Stat 31 Name":"","Stat 31 Eval":"","Stat 31 Format":"val","== Stat 32 ==":"","Stat 32 Name":"","Stat 32 Eval":"","Stat 32 Format":"val","== Stat 33 ==":"","Stat 33 Name":"","Stat 33 Eval":"","Stat 33 Format":"val","== Stat 34 ==":"","Stat 34 Name":"","Stat 34 Eval":"","Stat 34 Format":"val","== Stat 35 ==":"","Stat 35 Name":"","Stat 35 Eval":"","Stat 35 Format":"val","== Stat 36 ==":"","Stat 36 Name":"","Stat 36 Eval":"","Stat 36 Format":"val","== Stat 37 ==":"","Stat 37 Name":"","Stat 37 Eval":"","Stat 37 Format":"val","== Stat 38 ==":"","Stat 38 Name":"","Stat 38 Eval":"","Stat 38 Format":"val","== Stat 39 ==":"","Stat 39 Name":"","Stat 39 Eval":"","Stat 39 Format":"val","== Stat 40 ==":"","Stat 40 Name":"","Stat 40 Eval":"","Stat 40 Format":"val","== Stat 41 ==":"","Stat 41 Name":"","Stat 41 Eval":"","Stat 41 Format":"val","== Stat 42 ==":"","Stat 42 Name":"","Stat 42 Eval":"","Stat 42 Format":"val","== Stat 43 ==":"","Stat 43 Name":"","Stat 43 Eval":"","Stat 43 Format":"val","== Stat 44 ==":"","Stat 44 Name":"","Stat 44 Eval":"","Stat 44 Format":"val","== Stat 45 ==":"","Stat 45 Name":"","Stat 45 Eval":"","Stat 45 Format":"val","== Stat 46 ==":"","Stat 46 Name":"","Stat 46 Eval":"","Stat 46 Format":"val","== Stat 47 ==":"","Stat 47 Name":"","Stat 47 Eval":"","Stat 47 Format":"val","== Stat 48 ==":"","Stat 48 Name":"","Stat 48 Eval":"","Stat 48 Format":"val","== Stat 49 ==":"","Stat 49 Name":"","Stat 49 Eval":"","Stat 49 Format":"val","== Stat 50 ==":"","Stat 50 Name":"","Stat 50 Eval":"","Stat 50 Format":"val","== Stat 51 ==":"","Stat 51 Name":"","Stat 51 Eval":"","Stat 51 Format":"val","== Stat 52 ==":"","Stat 52 Name":"","Stat 52 Eval":"","Stat 52 Format":"val","== Stat 53 ==":"","Stat 53 Name":"","Stat 53 Eval":"","Stat 53 Format":"val","== Stat 54 ==":"","Stat 54 Name":"","Stat 54 Eval":"","Stat 54 Format":"val","== Stat 55 ==":"","Stat 55 Name":"","Stat 55 Eval":"","Stat 55 Format":"val","== Stat 56 ==":"","Stat 56 Name":"","Stat 56 Eval":"","Stat 56 Format":"val","== Stat 57 ==":"","Stat 57 Name":"","Stat 57 Eval":"","Stat 57 Format":"val","== Stat 58 ==":"","Stat 58 Name":"","Stat 58 Eval":"","Stat 58 Format":"val","== Stat 59 ==":"","Stat 59 Name":"","Stat 59 Eval":"","Stat 59 Format":"val","== Stat 60 ==":"","Stat 60 Name":"","Stat 60 Eval":"","Stat 60 Format":"val","== Stat 61 ==":"","Stat 61 Name":"","Stat 61 Eval":"","Stat 61 Format":"val","== Stat 62 ==":"","Stat 62 Name":"","Stat 62 Eval":"","Stat 62 Format":"val","== Stat 63 ==":"","Stat 63 Name":"","Stat 63 Eval":"","Stat 63 Format":"val","== Stat 64 ==":"","Stat 64 Name":"","Stat 64 Eval":"","Stat 64 Format":"val","== Stat 65 ==":"","Stat 65 Name":"","Stat 65 Eval":"","Stat 65 Format":"val","== Stat 66 ==":"","Stat 66 Name":"","Stat 66 Eval":"","Stat 66 Format":"val","== Stat 67 ==":"","Stat 67 Name":"","Stat 67 Eval":"","Stat 67 Format":"val","== Stat 68 ==":"","Stat 68 Name":"","Stat 68 Eval":"","Stat 68 Format":"val","== Stat 69 ==":"","Stat 69 Name":"","Stat 69 Eval":"","Stat 69 Format":"val","== Stat 70 ==":"","Stat 70 Name":"","Stat 70 Eval":"","Stat 70 Format":"val","== Stat 71 ==":"","Stat 71 Name":"","Stat 71 Eval":"","Stat 71 Format":"val","== Stat 72 ==":"","Stat 72 Name":"","Stat 72 Eval":"","Stat 72 Format":"val","== Stat 73 ==":"","Stat 73 Name":"","Stat 73 Eval":"","Stat 73 Format":"val","== Stat 74 ==":"","Stat 74 Name":"","Stat 74 Eval":"","Stat 74 Format":"val","== Stat 75 ==":"","Stat 75 Name":"","Stat 75 Eval":"","Stat 75 Format":"val","== Stat 76 ==":"","Stat 76 Name":"","Stat 76 Eval":"","Stat 76 Format":"val","== Stat 77 ==":"","Stat 77 Name":"","Stat 77 Eval":"","Stat 77 Format":"val","== Stat 78 ==":"","Stat 78 Name":"","Stat 78 Eval":"","Stat 78 Format":"val","== Stat 79 ==":"","Stat 79 Name":"","Stat 79 Eval":"","Stat 79 Format":"val","== Stat 80 ==":"","Stat 80 Name":"","Stat 80 Eval":"","Stat 80 Format":"val","== Stat 81 ==":"","Stat 81 Name":"","Stat 81 Eval":"","Stat 81 Format":"val","== Stat 82 ==":"","Stat 82 Name":"","Stat 82 Eval":"","Stat 82 Format":"val","== Stat 83 ==":"","Stat 83 Name":"","Stat 83 Eval":"","Stat 83 Format":"val","== Stat 84 ==":"","Stat 84 Name":"","Stat 84 Eval":"","Stat 84 Format":"val","== Stat 85 ==":"","Stat 85 Name":"","Stat 85 Eval":"","Stat 85 Format":"val","== Stat 86 ==":"","Stat 86 Name":"","Stat 86 Eval":"","Stat 86 Format":"val","== Stat 87 ==":"","Stat 87 Name":"","Stat 87 Eval":"","Stat 87 Format":"val","== Stat 88 ==":"","Stat 88 Name":"","Stat 88 Eval":"","Stat 88 Format":"val","== Stat 89 ==":"","Stat 89 Name":"","Stat 89 Eval":"","Stat 89 Format":"val","== Stat 90 ==":"","Stat 90 Name":"","Stat 90 Eval":"","Stat 90 Format":"val","== Stat 91 ==":"","Stat 91 Name":"","Stat 91 Eval":"","Stat 91 Format":"val","== Stat 92 ==":"","Stat 92 Name":"","Stat 92 Eval":"","Stat 92 Format":"val","== Stat 93 ==":"","Stat 93 Name":"","Stat 93 Eval":"","Stat 93 Format":"val","== Stat 94 ==":"","Stat 94 Name":"","Stat 94 Eval":"","Stat 94 Format":"val","== Stat 95 ==":"","Stat 95 Name":"","Stat 95 Eval":"","Stat 95 Format":"val","== Stat 96 ==":"","Stat 96 Name":"","Stat 96 Eval":"","Stat 96 Format":"val","== Stat 97 ==":"","Stat 97 Name":"","Stat 97 Eval":"","Stat 97 Format":"val","== Stat 98 ==":"","Stat 98 Name":"","Stat 98 Eval":"","Stat 98 Format":"val","== Stat 99 ==":"","Stat 99 Name":"","Stat 99 Eval":"","Stat 99 Format":"val","== Stat 100 ==":"","Stat 100 Name":"","Stat 100 Eval":"","Stat 100 Format":"val"}}, {"name":"SRD_StatDistribution","status":true,"description":"Allows players to distribute points to different stats of the Actors at his or her discretion.","parameters":{"Default Stats":"mhp, mmp, atk, def, mat, mdf, agi, luk","Default Formula":"Math.ceil(level / 10)","Show on Menu":"true","== Stat Reset ==":"","Allow Stat Resets":"true","Reset Gold Cost":"points * 100","== Custom Texts ==":"","Level Up Message":"Got %1 stat points!","Command Name":"Stat Boost","Points Text":"Stat Points:","Upgrade Text":"Upgrade Cost:","Spend Text":"Spend","Reset Text":"Reset","Finish Text":"Finish","== Gauge Options ==":"","Use Gauges":"true","Gauge Height":"14","== Points Label ==":"","Point Icon":"87","Point Text":"Points","Point Color":"#66ff66"}}, {"name":"SRD_SummonCore","status":true,"description":"Allows developers to create skills that summon Actors into the player's party using various parameters.","parameters":{"Battlelog Message":"%1 has been summoned!","Max Summons":"4","Restrict Per Skill":"true","Restrict Per Position":"true","== Defaults ==":"","Default Actor ID":"1","Default Level":"1","Default Animation":"51","Default Exit Ani.":"51","Default Turns":"-1","Default X Pos":"master._homeX - 120","Default Y Pos":"master._homeY"}}, -{"name":"charcreator","status":true,"description":"Allows players to create their own custom characters.","parameters":{"Layers":"Tail Part2, Wing Part2, Body, Eyes, Eyebrows, Nose, Mouth, Rear Hair Part1, Front Hair Part2, Rear Hair Part2, Clothing, Accessory A, Glasses, Front Hair Part1, Beast Ears, Accessory B, Tail Part1, Wing Part1","Order":"Body, Eyes, Eyebrows, Nose, Mouth, Clothing, Front Hair, Rear Hair, Accessory A, Accessory B, Glasses, Beast Ears, Wing, Tail","Mandatory":"Body, Eyes, Eyebrows, Nose, Mouth","Mandatory Color":"#FFFF44","Print to Console":"false","== Visual Options ==":"","Use Fade Transition":"true","Use Piece Background":"true","Use Scene Background":"true","Background X Scroll":"1","Background Y Scroll":"0","Small Piece Cols":"3","Big Piece Cols":"1","== Dialogues ==":"","Leave Dialogue":"Are you sure you want\\n to save this character?","Mandatory Dialogue":"You need to have all the mandatory sections \\nfilled out before exiting.","== Size Options ==":"","Character Width":"48","Character Height":"48","SV Char Width":"64","SV Char Height":"64","Face Width":"144","Face Height":"144","== Localization ==":"","Yes Text":"Yes!","No Text":"Nope","Color Mouse/Touch Input":"true"}} +{"name":"charcreator","status":true,"description":"Allows players to create their own custom characters.","parameters":{"Layers":"Tail Part2, Wing Part2, Body, Eyes, Eyebrows, Nose, Mouth, Rear Hair Part1, Front Hair Part2, Rear Hair Part2, Clothing, Accessory A, Glasses, Front Hair Part1, Beast Ears, Accessory B, Tail Part1, Wing Part1","Order":"Body, Eyes, Eyebrows, Nose, Mouth, Clothing, Front Hair, Rear Hair, Accessory A, Accessory B, Glasses, Beast Ears, Wing, Tail","Mandatory":"Body, Eyes, Eyebrows, Nose, Mouth","Mandatory Color":"#FFFF44","Print to Console":"false","== Visual Options ==":"","Use Fade Transition":"true","Use Piece Background":"true","Use Scene Background":"true","Background X Scroll":"1","Background Y Scroll":"0","Small Piece Cols":"3","Big Piece Cols":"1","== Dialogues ==":"","Leave Dialogue":"Are you sure you want\\n to save this character?","Mandatory Dialogue":"You need to have all the mandatory sections \\nfilled out before exiting.","== Size Options ==":"","Character Width":"48","Character Height":"48","SV Char Width":"64","SV Char Height":"64","Face Width":"144","Face Height":"144","== Localization ==":"","Yes Text":"Yes!","No Text":"Nope","Color Mouse/Touch Input":"true"}}, +{"name":"--------------------","status":true,"description":"------------------------------------------------------------","parameters":{}}, +{"name":"YEP_AnimateTilesOption","status":true,"description":"v1.03 Because some computers and devices lag with animated\ntiles on the map, an option is added to disable them.","parameters":{"Command Name":"Animated Tiles","Default Setting":"auto"}}, +{"name":"YEP_AutoPassiveStates","status":true,"description":"v1.17 This plugin allows for some states to function as\npassives for actors, enemies, skills, and equips.","parameters":{"---Basic---":"","Actor Passives":"0","Enemy Passives":"0","Global Passives":"0","---List---":"...Requires RPG Maker MV 1.5.0+...","Actor Passives List":"[]","Enemy Passives List":"[]","Global Passives List":"[]"}}, +{"name":"YEP_BaseTroopEvents","status":true,"description":"v1.01 Enabling this plugin will cause all troops to have\r\nevents occur in every fight.","parameters":{"Base Troop ID":"1"}}, +{"name":"YEP_BattleAICore","status":true,"description":"v1.15 This plugin allows you to structure battle A.I.\npatterns with more control.","parameters":{"Dynamic Actions":"true","Dynamic Turn Count":"false","Element Testing":"true","Default AI Level":"80"}}, +{"name":"YEP_BattleEngineCore","status":true,"description":"v1.51 Have more control over the flow of the battle system\nwith this plugin and alter various aspects to your liking.","parameters":{"---General---":"","Action Speed":"agi","Default System":"dtb","---Escape---":"","Escape Ratio":"0.5 * $gameParty.agility() / $gameTroop.agility()","Fail Escape Boost":"0.10","---Animation---":"","Animation Base Delay":"0","Animation Next Delay":"0","Certain Hit Animation":"0","Physical Animation":"52","Magical Animation":"51","Enemy Attack Animation":"39","Reflect Animation":"42","Motion Waiting":"false","---Frontview---":"","Front Position X":"Graphics.boxWidth / 8 + Graphics.boxWidth / 4 * index","Front Position Y":"Graphics.boxHeight - 180","Front Actor Sprite":"false","Front Sprite Priority":"1","---Sideview---":"","Home Position X":"screenWidth - 16 - (maxSize + 2) * 32 + index * 32","Home Position Y":"screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 32","Side Sprite Priority":"1","---Sprites---":"","Default X Anchor":"0.50","Default Y Anchor":"1.00","Step Distance":"48","Flinch Distance":"12","Show Shadows":"true","---Damage Popups---":"","Popup Duration":"128","Newest Popup Bottom":"true","Popup Overlap Rate":"0.9","Critical Popup":"255, 0, 0, 160","Critical Duration":"60","---Tick-Settings---":"","Timed States":"false","Timed Buffs":"false","Turn Time":"100","AI Self Turns":"true","---Window Settings---":"","Lower Windows":"true","Window Rows":"4","Command Window Rows":"4","Command Alignment":"center","Start Actor Command":"true","Current Max":"false","---Selection Help---":"","Mouse Over":"true","Select Help Window":"true","User Help Text":"User","Ally Help Text":"Ally","Allies Help Text":"Allies","Enemy Help Text":"Enemy","Enemies Help Text":"Enemies","All Help Text":"All %1","Random Help Text":"%2 Random %1","---Enemy Select---":"","Visual Enemy Select":"true","Show Enemy Name":"true","Show Select Box":"false","Enemy Font Size":"20","Enemy Auto Select":"this.furthestRight()","---Actor Select---":"","Visual Actor Select":"true","---Battle Log---":"","Show Emerge Text":"false","Show Pre-Emptive Text":"true","Show Surprise Text":"true","Optimize Speed":"true","Show Action Text":"false","Show State Text":"false","Show Buff Text":"false","Show Counter Text":"true","Show Reflect Text":"true","Show Substitute Text":"true","Show Fail Text":"false","Show Critical Text":"false","Show Miss Text":"false","Show Evasion Text":"false","Show HP Text":"false","Show MP Text":"false","Show TP Text":"false"}}, +{"name":"YEP_BuffsStatesCore","status":true,"description":"v1.16 Alter the basic mechanics behind buffs and states\nthat aren't adjustable within the RPG Maker editor.","parameters":{"---Turn Indicator---":"","Show Turns":"true","Font Size":"16","Turn Alignment":"right","Turn Buffer X":"-3","Turn Buffer Y":"-6","State Color":"0","Buff Color":"24","Debuff Color":"2","---Enemy Icons---":"","Show Enemy Icons":"true","Enemy Buff Turn":"true","Enemy State Turn":"true","Enemy State Counter":"true","---Buff Settings---":"","Default Limit":"4","Maximum Limit":"8","Buff Formula":"this._buffs[paramId] * 0.25 + 1.0","Show Buff Rate":"false","---State Settings---":"","Reapply Rules":"1","Show Enemy Turns":"true","---Counter Settings---":"","Counter Font Size":"16","Counter Alignment":"center","Counter Buffer X":"0","Counter Buffer Y":"8","Counter Color":"0"}}, +{"name":"YEP_CoreEngine","status":true,"description":"v1.32 Needed for the majority of Yanfly Engine Scripts. Also\r\ncontains bug fixes found inherently in RPG Maker.","parameters":{"---Screen---":"","Screen Width":"816","Screen Height":"624","Scale Battlebacks":"true","Scale Title":"true","Scale Game Over":"true","Open Console":"false","Reposition Battlers":"true","GameFont Load Timer":"0","Update Real Scale":"false","Collection Clear":"true","---Gold---":"","Gold Max":"99999999","Gold Font Size":"20","Gold Icon":"313","Gold Overlap":"A lotta","---Items---":"","Default Max":"99","Quantity Text Size":"20","---Parameters---":"","Max Level":"99","Actor MaxHP":"9999","Actor MaxMP":"9999","Actor Parameter":"999","Enemy MaxHP":"999999","Enemy MaxMP":"9999","Enemy Parameter":"999","---Battle---":"","Animation Rate":"4","Flash Target":"false","Show Events Transition":"true","Show Events Snapshot":"true","---Map Optimization---":"","Refresh Update HP":"true","Refresh Update MP":"true","Refresh Update TP":"false","---Font---":"","Chinese Font":"SimHei, Heiti TC, sans-serif","Korean Font":"Dotum, AppleGothic, sans-serif","Default Font":"GameFont, Verdana, Arial, Courier New","Font Size":"28","Text Align":"left","---Windows---":"","Digit Grouping":"true","Line Height":"36","Icon Width":"32","Icon Height":"32","Face Width":"144","Face Height":"144","Window Padding":"18","Text Padding":"6","Window Opacity":"192","Gauge Outline":"true","Gauge Height":"18","Menu TP Bar":"true","---Window Colors---":"","Color: Normal":"0","Color: System":"16","Color: Crisis":"17","Color: Death":"18","Color: Gauge Back":"19","Color: HP Gauge 1":"20","Color: HP Gauge 2":"21","Color: MP Gauge 1":"22","Color: MP Gauge 2":"23","Color: MP Cost":"23","Color: Power Up":"24","Color: Power Down":"25","Color: TP Gauge 1":"28","Color: TP Gauge 2":"29","Color: TP Cost Color":"29"}}, +{"name":"YEP_ElementCore","status":true,"description":"v1.02 Manage the way elements work in this game from\nabsorbing elements, reflecting elements, and more!","parameters":{"Multi-Element Rulings":"2"}}, +{"name":"YEP_EquipCore","status":true,"description":"v1.18 Allows for the equipment system to be more flexible to\nallow for unique equipment slots per class.","parameters":{"---General---":"","Text Align":"center","Finish Command":"Finish","Remove Text":"Remove","Remove Icon":"16","Empty Text":"","Empty Icon":"16","---Rules---":"","Non-Removable Types":"1","Non-Optimized Types":"5"}}, +{"name":"YEP_EventChasePlayer","status":true,"description":"v1.07 When a player is in the proximity of a certain event,\nthe event will start chasing or fleeing from the player.","parameters":{"Sight Lock":"300","See Player":"true","Alert Timer":"120","Alert Balloon":"1","Alert Sound":"Attack1","Alert Common Event":"0","Return After":"true","Return Wait":"180"}}, +{"name":"YEP_FpsSynchOption","status":true,"description":"v1.03 Adds a new command to Options menu for synching\nthe FPS of moniters with higher FPS rates.","parameters":{"Command Name":"Synch Monitor FPS","Default Setting":"false"}}, +{"name":"YEP_ItemCore","status":true,"description":"v1.30 Changes the way Items are handled for your game\nand the Item Scene, too.","parameters":{"---General---":"","Max Items":"0","Max Weapons":"100","Max Armors":"100","Starting ID":"3000","Random Variance":"0","Negative Variance":"false","Name Format":"%1%2%3%4","Name Spacing":"true","Boost Format":"(+%1)","---Item Scene---":"","Updated Scene Item":"true","List Equipped Items":"true","Show Icon":"true","Icon Size":"128","Font Size":"20","Command Alignment":"center","Recovery Format":"%1 Heal","Add State":"+State","Add Buff":"+Buff","Remove State":"-State","Remove Buff":"-Buff","Maximum Icons":"4","Use Command":"Use %1","Carry Format":"%1/%2","--Independent Items--":"","Midgame Note Parsing":"false"}}, +{"name":"YEP_LevelUpGrowthEffects","status":true,"description":"v1.01 Equip an item that upon leveling up will raise stats?\nThis plugin will let you do just that!","parameters":{}}, +{"name":"YEP_MainMenuManager","status":true,"description":"v1.03 This plugin allows you to manage the various aspects\nof your main menu.","parameters":{"---General---":"","Hide Actor Window":"false","Hide Gold Window":"false","Blurry Background":"true","---Command---":"","Command Alignment":"left","Command Position":"left","Command Columns":"1","Command Rows":"Math.min(10, Math.ceil(this.maxItems() / this.maxCols()))","Command Width":"240","---Menu Items---":"","---Menu 1---":"","Menu 1 Name":"","Menu 1 Symbol":"","Menu 1 Show":"","Menu 1 Enabled":"","Menu 1 Ext":"","Menu 1 Main Bind":"","Menu 1 Actor Bind":"","---Menu 2---":"","Menu 2 Name":"","Menu 2 Symbol":"","Menu 2 Show":"","Menu 2 Enabled":"","Menu 2 Ext":"","Menu 2 Main Bind":"","Menu 2 Actor Bind":"","---Menu 3---":"","Menu 3 Name":"","Menu 3 Symbol":"","Menu 3 Show":"","Menu 3 Enabled":"","Menu 3 Ext":"","Menu 3 Main Bind":"","Menu 3 Actor Bind":"","---Menu 4---":"","Menu 4 Name":"","Menu 4 Symbol":"","Menu 4 Show":"","Menu 4 Enabled":"","Menu 4 Ext":"","Menu 4 Main Bind":"","Menu 4 Actor Bind":"","---Menu 5---":"","Menu 5 Name":"","Menu 5 Symbol":"","Menu 5 Show":"","Menu 5 Enabled":"","Menu 5 Ext":"","Menu 5 Main Bind":"","Menu 5 Actor Bind":"","---Menu 6---":"","Menu 6 Name":"","Menu 6 Symbol":"","Menu 6 Show":"","Menu 6 Enabled":"","Menu 6 Ext":"","Menu 6 Main Bind":"","Menu 6 Actor Bind":"","---Menu 7---":"","Menu 7 Name":"","Menu 7 Symbol":"","Menu 7 Show":"","Menu 7 Enabled":"","Menu 7 Ext":"","Menu 7 Main Bind":"","Menu 7 Actor Bind":"","---Menu 8---":"","Menu 8 Name":"","Menu 8 Symbol":"","Menu 8 Show":"","Menu 8 Enabled":"","Menu 8 Ext":"","Menu 8 Main Bind":"","Menu 8 Actor Bind":"","---Menu 9---":"","Menu 9 Name":"","Menu 9 Symbol":"","Menu 9 Show":"","Menu 9 Enabled":"","Menu 9 Ext":"","Menu 9 Main Bind":"","Menu 9 Actor Bind":"","---Menu 10---":"","Menu 10 Name":"TextManager.item","Menu 10 Symbol":"item","Menu 10 Show":"this.needsCommand('item')","Menu 10 Enabled":"this.areMainCommandsEnabled()","Menu 10 Ext":"","Menu 10 Main Bind":"this.commandItem.bind(this)","Menu 10 Actor Bind":"","---Menu 11---":"","Menu 11 Name":"","Menu 11 Symbol":"","Menu 11 Show":"","Menu 11 Enabled":"","Menu 11 Ext":"","Menu 11 Main Bind":"","Menu 11 Actor Bind":"","---Menu 12---":"","Menu 12 Name":"","Menu 12 Symbol":"","Menu 12 Show":"","Menu 12 Enabled":"","Menu 12 Ext":"","Menu 12 Main Bind":"","Menu 12 Actor Bind":"","---Menu 13---":"","Menu 13 Name":"","Menu 13 Symbol":"","Menu 13 Show":"","Menu 13 Enabled":"","Menu 13 Ext":"","Menu 13 Main Bind":"","Menu 13 Actor Bind":"","---Menu 14---":"","Menu 14 Name":"","Menu 14 Symbol":"","Menu 14 Show":"","Menu 14 Enabled":"","Menu 14 Ext":"","Menu 14 Main Bind":"","Menu 14 Actor Bind":"","---Menu 15---":"","Menu 15 Name":"TextManager.skill","Menu 15 Symbol":"skill","Menu 15 Show":"this.needsCommand('skill')","Menu 15 Enabled":"this.areMainCommandsEnabled()","Menu 15 Ext":"","Menu 15 Main Bind":"this.commandPersonal.bind(this)","Menu 15 Actor Bind":"SceneManager.push(Scene_Skill)","---Menu 16---":"","Menu 16 Name":"","Menu 16 Symbol":"","Menu 16 Show":"","Menu 16 Enabled":"","Menu 16 Ext":"","Menu 16 Main Bind":"","Menu 16 Actor Bind":"","---Menu 17---":"","Menu 17 Name":"","Menu 17 Symbol":"","Menu 17 Show":"","Menu 17 Enabled":"","Menu 17 Ext":"","Menu 17 Main Bind":"","Menu 17 Actor Bind":"","---Menu 18---":"","Menu 18 Name":"","Menu 18 Symbol":"","Menu 18 Show":"","Menu 18 Enabled":"","Menu 18 Ext":"","Menu 18 Main Bind":"","Menu 18 Actor Bind":"","---Menu 19---":"","Menu 19 Name":"","Menu 19 Symbol":"","Menu 19 Show":"","Menu 19 Enabled":"","Menu 19 Ext":"","Menu 19 Main Bind":"","Menu 19 Actor Bind":"","---Menu 20---":"","Menu 20 Name":"TextManager.equip","Menu 20 Symbol":"equip","Menu 20 Show":"this.needsCommand('equip')","Menu 20 Enabled":"this.areMainCommandsEnabled()","Menu 20 Ext":"","Menu 20 Main Bind":"this.commandPersonal.bind(this)","Menu 20 Actor Bind":"SceneManager.push(Scene_Equip)","---Menu 21---":"","Menu 21 Name":"","Menu 21 Symbol":"","Menu 21 Show":"","Menu 21 Enabled":"","Menu 21 Ext":"","Menu 21 Main Bind":"","Menu 21 Actor Bind":"","---Menu 22---":"","Menu 22 Name":"","Menu 22 Symbol":"","Menu 22 Show":"","Menu 22 Enabled":"","Menu 22 Ext":"","Menu 22 Main Bind":"","Menu 22 Actor Bind":"","---Menu 23---":"","Menu 23 Name":"","Menu 23 Symbol":"","Menu 23 Show":"","Menu 23 Enabled":"","Menu 23 Ext":"","Menu 23 Main Bind":"","Menu 23 Actor Bind":"","---Menu 24---":"","Menu 24 Name":"","Menu 24 Symbol":"","Menu 24 Show":"","Menu 24 Enabled":"","Menu 24 Ext":"","Menu 24 Main Bind":"","Menu 24 Actor Bind":"","---Menu 25---":"","Menu 25 Name":"Yanfly.Param.CCCCmdName","Menu 25 Symbol":"class","Menu 25 Show":"Imported.YEP_ClassChangeCore && $gameSystem.isShowClass()","Menu 25 Enabled":"$gameSystem.isEnableClass() && this.areMainCommandsEnabled()","Menu 25 Ext":"","Menu 25 Main Bind":"this.commandPersonal.bind(this)","Menu 25 Actor Bind":"SceneManager.push(Scene_Class)","---Menu 26---":"","Menu 26 Name":"","Menu 26 Symbol":"","Menu 26 Show":"","Menu 26 Enabled":"","Menu 26 Ext":"","Menu 26 Main Bind":"","Menu 26 Actor Bind":"","---Menu 27---":"","Menu 27 Name":"","Menu 27 Symbol":"","Menu 27 Show":"","Menu 27 Enabled":"","Menu 27 Ext":"","Menu 27 Main Bind":"","Menu 27 Actor Bind":"","---Menu 28---":"","Menu 28 Name":"","Menu 28 Symbol":"","Menu 28 Show":"","Menu 28 Enabled":"","Menu 28 Ext":"","Menu 28 Main Bind":"","Menu 28 Actor Bind":"","---Menu 29---":"","Menu 29 Name":"","Menu 29 Symbol":"","Menu 29 Show":"","Menu 29 Enabled":"","Menu 29 Ext":"","Menu 29 Main Bind":"","Menu 29 Actor Bind":"","---Menu 30---":"","Menu 30 Name":"","Menu 30 Symbol":"","Menu 30 Show":"","Menu 30 Enabled":"","Menu 30 Ext":"","Menu 30 Main Bind":"","Menu 30 Actor Bind":"","---Menu 31---":"","Menu 31 Name":"","Menu 31 Symbol":"","Menu 31 Show":"","Menu 31 Enabled":"","Menu 31 Ext":"","Menu 31 Main Bind":"","Menu 31 Actor Bind":"","---Menu 32---":"","Menu 32 Name":"","Menu 32 Symbol":"","Menu 32 Show":"","Menu 32 Enabled":"","Menu 32 Ext":"","Menu 32 Main Bind":"","Menu 32 Actor Bind":"","---Menu 33---":"","Menu 33 Name":"","Menu 33 Symbol":"","Menu 33 Show":"","Menu 33 Enabled":"","Menu 33 Ext":"","Menu 33 Main Bind":"","Menu 33 Actor Bind":"","---Menu 34---":"","Menu 34 Name":"","Menu 34 Symbol":"","Menu 34 Show":"","Menu 34 Enabled":"","Menu 34 Ext":"","Menu 34 Main Bind":"","Menu 34 Actor Bind":"","---Menu 35---":"","Menu 35 Name":"","Menu 35 Symbol":"","Menu 35 Show":"","Menu 35 Enabled":"","Menu 35 Ext":"","Menu 35 Main Bind":"","Menu 35 Actor Bind":"","---Menu 36---":"","Menu 36 Name":"","Menu 36 Symbol":"","Menu 36 Show":"","Menu 36 Enabled":"","Menu 36 Ext":"","Menu 36 Main Bind":"","Menu 36 Actor Bind":"","---Menu 37---":"","Menu 37 Name":"","Menu 37 Symbol":"","Menu 37 Show":"","Menu 37 Enabled":"","Menu 37 Ext":"","Menu 37 Main Bind":"","Menu 37 Actor Bind":"","---Menu 38---":"","Menu 38 Name":"","Menu 38 Symbol":"","Menu 38 Show":"","Menu 38 Enabled":"","Menu 38 Ext":"","Menu 38 Main Bind":"","Menu 38 Actor Bind":"","---Menu 39---":"","Menu 39 Name":"","Menu 39 Symbol":"","Menu 39 Show":"","Menu 39 Enabled":"","Menu 39 Ext":"","Menu 39 Main Bind":"","Menu 39 Actor Bind":"","---Menu 40---":"","Menu 40 Name":"","Menu 40 Symbol":"","Menu 40 Show":"","Menu 40 Enabled":"","Menu 40 Ext":"","Menu 40 Main Bind":"","Menu 40 Actor Bind":"","---Menu 41---":"","Menu 41 Name":"","Menu 41 Symbol":"","Menu 41 Show":"","Menu 41 Enabled":"","Menu 41 Ext":"","Menu 41 Main Bind":"","Menu 41 Actor Bind":"","---Menu 42---":"","Menu 42 Name":"","Menu 42 Symbol":"","Menu 42 Show":"","Menu 42 Enabled":"","Menu 42 Ext":"","Menu 42 Main Bind":"","Menu 42 Actor Bind":"","---Menu 43---":"","Menu 43 Name":"","Menu 43 Symbol":"","Menu 43 Show":"","Menu 43 Enabled":"","Menu 43 Ext":"","Menu 43 Main Bind":"","Menu 43 Actor Bind":"","---Menu 44---":"","Menu 44 Name":"","Menu 44 Symbol":"","Menu 44 Show":"","Menu 44 Enabled":"","Menu 44 Ext":"","Menu 44 Main Bind":"","Menu 44 Actor Bind":"","---Menu 45---":"","Menu 45 Name":"","Menu 45 Symbol":"","Menu 45 Show":"","Menu 45 Enabled":"","Menu 45 Ext":"","Menu 45 Main Bind":"","Menu 45 Actor Bind":"","---Menu 46---":"","Menu 46 Name":"","Menu 46 Symbol":"","Menu 46 Show":"","Menu 46 Enabled":"","Menu 46 Ext":"","Menu 46 Main Bind":"","Menu 46 Actor Bind":"","---Menu 47---":"","Menu 47 Name":"","Menu 47 Symbol":"","Menu 47 Show":"","Menu 47 Enabled":"","Menu 47 Ext":"","Menu 47 Main Bind":"","Menu 47 Actor Bind":"","---Menu 48---":"","Menu 48 Name":"","Menu 48 Symbol":"","Menu 48 Show":"","Menu 48 Enabled":"","Menu 48 Ext":"","Menu 48 Main Bind":"","Menu 48 Actor Bind":"","---Menu 49---":"","Menu 49 Name":"","Menu 49 Symbol":"","Menu 49 Show":"","Menu 49 Enabled":"","Menu 49 Ext":"","Menu 49 Main Bind":"","Menu 49 Actor Bind":"","---Menu 50---":"","Menu 50 Name":"TextManager.status","Menu 50 Symbol":"status","Menu 50 Show":"this.needsCommand('status')","Menu 50 Enabled":"this.areMainCommandsEnabled()","Menu 50 Ext":"","Menu 50 Main Bind":"this.commandPersonal.bind(this)","Menu 50 Actor Bind":"SceneManager.push(Scene_Status)","---Menu 51---":"","Menu 51 Name":"","Menu 51 Symbol":"","Menu 51 Show":"","Menu 51 Enabled":"","Menu 51 Ext":"","Menu 51 Main Bind":"","Menu 51 Actor Bind":"","---Menu 52---":"","Menu 52 Name":"","Menu 52 Symbol":"","Menu 52 Show":"","Menu 52 Enabled":"","Menu 52 Ext":"","Menu 52 Main Bind":"","Menu 52 Actor Bind":"","---Menu 53---":"","Menu 53 Name":"","Menu 53 Symbol":"","Menu 53 Show":"","Menu 53 Enabled":"","Menu 53 Ext":"","Menu 53 Main Bind":"","Menu 53 Actor Bind":"","---Menu 54---":"","Menu 54 Name":"","Menu 54 Symbol":"","Menu 54 Show":"","Menu 54 Enabled":"","Menu 54 Ext":"","Menu 54 Main Bind":"","Menu 54 Actor Bind":"","---Menu 55---":"","Menu 55 Name":"TextManager.formation","Menu 55 Symbol":"formation","Menu 55 Show":"this.needsCommand('formation')","Menu 55 Enabled":"this.isFormationEnabled()","Menu 55 Ext":"","Menu 55 Main Bind":"this.commandFormation.bind(this)","Menu 55 Actor Bind":"","---Menu 56---":"","Menu 56 Name":"","Menu 56 Symbol":"","Menu 56 Show":"","Menu 56 Enabled":"","Menu 56 Ext":"","Menu 56 Main Bind":"","Menu 56 Actor Bind":"","---Menu 57---":"","Menu 57 Name":"","Menu 57 Symbol":"","Menu 57 Show":"","Menu 57 Enabled":"","Menu 57 Ext":"","Menu 57 Main Bind":"","Menu 57 Actor Bind":"","---Menu 58---":"","Menu 58 Name":"","Menu 58 Symbol":"","Menu 58 Show":"","Menu 58 Enabled":"","Menu 58 Ext":"","Menu 58 Main Bind":"","Menu 58 Actor Bind":"","---Menu 59---":"","Menu 59 Name":"","Menu 59 Symbol":"","Menu 59 Show":"","Menu 59 Enabled":"","Menu 59 Ext":"","Menu 59 Main Bind":"","Menu 59 Actor Bind":"","---Menu 60---":"","Menu 60 Name":"","Menu 60 Symbol":"","Menu 60 Show":"","Menu 60 Enabled":"","Menu 60 Ext":"","Menu 60 Main Bind":"","Menu 60 Actor Bind":"","---Menu 61---":"","Menu 61 Name":"","Menu 61 Symbol":"","Menu 61 Show":"","Menu 61 Enabled":"","Menu 61 Ext":"","Menu 61 Main Bind":"","Menu 61 Actor Bind":"","---Menu 62---":"","Menu 62 Name":"","Menu 62 Symbol":"","Menu 62 Show":"","Menu 62 Enabled":"","Menu 62 Ext":"","Menu 62 Main Bind":"","Menu 62 Actor Bind":"","---Menu 63---":"","Menu 63 Name":"","Menu 63 Symbol":"","Menu 63 Show":"","Menu 63 Enabled":"","Menu 63 Ext":"","Menu 63 Main Bind":"","Menu 63 Actor Bind":"","---Menu 64---":"","Menu 64 Name":"","Menu 64 Symbol":"","Menu 64 Show":"","Menu 64 Enabled":"","Menu 64 Ext":"","Menu 64 Main Bind":"","Menu 64 Actor Bind":"","---Menu 65---":"","Menu 65 Name":"","Menu 65 Symbol":"","Menu 65 Show":"","Menu 65 Enabled":"","Menu 65 Ext":"","Menu 65 Main Bind":"","Menu 65 Actor Bind":"","---Menu 66---":"","Menu 66 Name":"","Menu 66 Symbol":"","Menu 66 Show":"","Menu 66 Enabled":"","Menu 66 Ext":"","Menu 66 Main Bind":"","Menu 66 Actor Bind":"","---Menu 67---":"","Menu 67 Name":"","Menu 67 Symbol":"","Menu 67 Show":"","Menu 67 Enabled":"","Menu 67 Ext":"","Menu 67 Main Bind":"","Menu 67 Actor Bind":"","---Menu 68---":"","Menu 68 Name":"","Menu 68 Symbol":"","Menu 68 Show":"","Menu 68 Enabled":"","Menu 68 Ext":"","Menu 68 Main Bind":"","Menu 68 Actor Bind":"","---Menu 69---":"","Menu 69 Name":"","Menu 69 Symbol":"","Menu 69 Show":"","Menu 69 Enabled":"","Menu 69 Ext":"","Menu 69 Main Bind":"","Menu 69 Actor Bind":"","---Menu 70---":"","Menu 70 Name":"","Menu 70 Symbol":"","Menu 70 Show":"","Menu 70 Enabled":"","Menu 70 Ext":"","Menu 70 Main Bind":"","Menu 70 Actor Bind":"","---Menu 71---":"","Menu 71 Name":"","Menu 71 Symbol":"","Menu 71 Show":"","Menu 71 Enabled":"","Menu 71 Ext":"","Menu 71 Main Bind":"","Menu 71 Actor Bind":"","---Menu 72---":"","Menu 72 Name":"","Menu 72 Symbol":"","Menu 72 Show":"","Menu 72 Enabled":"","Menu 72 Ext":"","Menu 72 Main Bind":"","Menu 72 Actor Bind":"","---Menu 73---":"","Menu 73 Name":"","Menu 73 Symbol":"","Menu 73 Show":"","Menu 73 Enabled":"","Menu 73 Ext":"","Menu 73 Main Bind":"","Menu 73 Actor Bind":"","---Menu 74---":"","Menu 74 Name":"","Menu 74 Symbol":"","Menu 74 Show":"","Menu 74 Enabled":"","Menu 74 Ext":"","Menu 74 Main Bind":"","Menu 74 Actor Bind":"","---Menu 75---":"","Menu 75 Name":"","Menu 75 Symbol":"","Menu 75 Show":"","Menu 75 Enabled":"","Menu 75 Ext":"","Menu 75 Main Bind":"","Menu 75 Actor Bind":"","---Menu 76---":"","Menu 76 Name":"","Menu 76 Symbol":"","Menu 76 Show":"","Menu 76 Enabled":"","Menu 76 Ext":"","Menu 76 Main Bind":"","Menu 76 Actor Bind":"","---Menu 77---":"","Menu 77 Name":"","Menu 77 Symbol":"","Menu 77 Show":"","Menu 77 Enabled":"","Menu 77 Ext":"","Menu 77 Main Bind":"","Menu 77 Actor Bind":"","---Menu 78---":"","Menu 78 Name":"","Menu 78 Symbol":"","Menu 78 Show":"","Menu 78 Enabled":"","Menu 78 Ext":"","Menu 78 Main Bind":"","Menu 78 Actor Bind":"","---Menu 79---":"","Menu 79 Name":"","Menu 79 Symbol":"","Menu 79 Show":"","Menu 79 Enabled":"","Menu 79 Ext":"","Menu 79 Main Bind":"","Menu 79 Actor Bind":"","---Menu 80---":"","Menu 80 Name":"","Menu 80 Symbol":"","Menu 80 Show":"","Menu 80 Enabled":"","Menu 80 Ext":"","Menu 80 Main Bind":"","Menu 80 Actor Bind":"","---Menu 81---":"","Menu 81 Name":"'Common Event 1'","Menu 81 Symbol":"common event","Menu 81 Show":"false","Menu 81 Enabled":"true","Menu 81 Ext":"1","Menu 81 Main Bind":"this.callCommonEvent.bind(this)","Menu 81 Actor Bind":"","---Menu 82---":"","Menu 82 Name":"'Common Event 2'","Menu 82 Symbol":"common event","Menu 82 Show":"false","Menu 82 Enabled":"true","Menu 82 Ext":"2","Menu 82 Main Bind":"this.callCommonEvent.bind(this)","Menu 82 Actor Bind":"","---Menu 83---":"","Menu 83 Name":"'Common Event 3'","Menu 83 Symbol":"common event","Menu 83 Show":"false","Menu 83 Enabled":"true","Menu 83 Ext":"3","Menu 83 Main Bind":"this.callCommonEvent.bind(this)","Menu 83 Actor Bind":"","---Menu 84---":"","Menu 84 Name":"","Menu 84 Symbol":"","Menu 84 Show":"","Menu 84 Enabled":"","Menu 84 Ext":"","Menu 84 Main Bind":"","Menu 84 Actor Bind":"","---Menu 85---":"","Menu 85 Name":"","Menu 85 Symbol":"","Menu 85 Show":"","Menu 85 Enabled":"","Menu 85 Ext":"","Menu 85 Main Bind":"","Menu 85 Actor Bind":"","---Menu 86---":"","Menu 86 Name":"","Menu 86 Symbol":"","Menu 86 Show":"","Menu 86 Enabled":"","Menu 86 Ext":"","Menu 86 Main Bind":"","Menu 86 Actor Bind":"","---Menu 87---":"","Menu 87 Name":"","Menu 87 Symbol":"","Menu 87 Show":"","Menu 87 Enabled":"","Menu 87 Ext":"","Menu 87 Main Bind":"","Menu 87 Actor Bind":"","---Menu 88---":"","Menu 88 Name":"","Menu 88 Symbol":"","Menu 88 Show":"","Menu 88 Enabled":"","Menu 88 Ext":"","Menu 88 Main Bind":"","Menu 88 Actor Bind":"","---Menu 89---":"","Menu 89 Name":"","Menu 89 Symbol":"","Menu 89 Show":"","Menu 89 Enabled":"","Menu 89 Ext":"","Menu 89 Main Bind":"","Menu 89 Actor Bind":"","---Menu 90---":"","Menu 90 Name":"TextManager.options","Menu 90 Symbol":"options","Menu 90 Show":"this.needsCommand('options')","Menu 90 Enabled":"this.isOptionsEnabled()","Menu 90 Ext":"","Menu 90 Main Bind":"this.commandOptions.bind(this)","Menu 90 Actor Bind":"","---Menu 91---":"","Menu 91 Name":"","Menu 91 Symbol":"","Menu 91 Show":"","Menu 91 Enabled":"","Menu 91 Ext":"","Menu 91 Main Bind":"","Menu 91 Actor Bind":"","---Menu 92---":"","Menu 92 Name":"","Menu 92 Symbol":"","Menu 92 Show":"","Menu 92 Enabled":"","Menu 92 Ext":"","Menu 92 Main Bind":"","Menu 92 Actor Bind":"","---Menu 93---":"","Menu 93 Name":"","Menu 93 Symbol":"","Menu 93 Show":"","Menu 93 Enabled":"","Menu 93 Ext":"","Menu 93 Main Bind":"","Menu 93 Actor Bind":"","---Menu 94---":"","Menu 94 Name":"","Menu 94 Symbol":"","Menu 94 Show":"","Menu 94 Enabled":"","Menu 94 Ext":"","Menu 94 Main Bind":"","Menu 94 Actor Bind":"","---Menu 95---":"","Menu 95 Name":"TextManager.save","Menu 95 Symbol":"save","Menu 95 Show":"this.needsCommand('save')","Menu 95 Enabled":"this.isSaveEnabled()","Menu 95 Ext":"","Menu 95 Main Bind":"this.commandSave.bind(this)","Menu 95 Actor Bind":"","---Menu 96---":"","Menu 96 Name":"","Menu 96 Symbol":"","Menu 96 Show":"","Menu 96 Enabled":"","Menu 96 Ext":"","Menu 96 Main Bind":"","Menu 96 Actor Bind":"","---Menu 97---":"","Menu 97 Name":"","Menu 97 Symbol":"","Menu 97 Show":"","Menu 97 Enabled":"","Menu 97 Ext":"","Menu 97 Main Bind":"","Menu 97 Actor Bind":"","---Menu 98---":"","Menu 98 Name":"","Menu 98 Symbol":"","Menu 98 Show":"","Menu 98 Enabled":"","Menu 98 Ext":"","Menu 98 Main Bind":"","Menu 98 Actor Bind":"","---Menu 99---":"","Menu 99 Name":"'Debug'","Menu 99 Symbol":"debug","Menu 99 Show":"$gameTemp.isPlaytest()","Menu 99 Enabled":"true","Menu 99 Ext":"","Menu 99 Main Bind":"this.commandDebug.bind(this)","Menu 99 Actor Bind":"","---Menu 100---":"","Menu 100 Name":"TextManager.gameEnd","Menu 100 Symbol":"gameEnd","Menu 100 Show":"true","Menu 100 Enabled":"this.isGameEndEnabled()","Menu 100 Ext":"","Menu 100 Main Bind":"this.commandGameEnd.bind(this)","Menu 100 Actor Bind":""}}, +{"name":"YEP_MessageCore","status":true,"description":"v1.19 Adds more features to the Message Window to customized\nthe way your messages appear and functions.","parameters":{"---General---":"","Default Rows":"4","Default Width":"Graphics.boxWidth","Face Indent":"Window_Base._faceWidth + 24","Fast Forward Key":"pagedown","Enable Fast Forward":"true","Word Wrapping":"false","Description Wrap":"false","Word Wrap Space":"false","Tight Wrap":"false","---Font---":"","Font Name":"GameFont","Font Name CH":"SimHei, Heiti TC, sans-serif","Font Name KR":"Dotum, AppleGothic, sans-serif","Font Size":"28","Font Size Change":"12","Font Changed Max":"96","Font Changed Min":"12","Font Outline":"4","Maintain Font":"false","---Name Box---":"","Name Box Buffer X":"-28","Name Box Buffer Y":"0","Name Box Padding":"this.standardPadding() * 4","Name Box Color":"0","Name Box Clear":"false","Name Box Added Text":"\\c[6]","Name Box Auto Close":"false"}}, +{"name":"YEP_MoveRouteCore","status":true,"description":"v1.04 Expand the number of movement options for the move\nroute events using this plugin.","parameters":{}}, +{"name":"YEP_PictureSpritesheets","status":true,"description":"v1.00 Another function from RPG Maker 2003 is back. You can now\nuse spritesheets in your pictures folder and change them to specific frames.","parameters":{}}, +{"name":"YEP_QuestJournal","status":true,"description":"v1.02 Insert a quest journal system into your game!","parameters":{"---Main Menu---":"","Quest Command":"Quest","Show Command":"true","Enable Command":"true","Auto Place Command":"true","---Quest Menu---":"","Quest Category Window":"{\"---Categories---\":\"\",\"Category Order\":\"[\\\"available\\\",\\\"completed\\\",\\\"failed\\\",\\\"all\\\"]\",\"Available Text\":\"\\\\i[192]Available (%1)\",\"Completed Text\":\"\\\\i[191]Completed (%1)\",\"Failed Text\":\"\\\\i[194]Failed (%1)\",\"All Text\":\"\\\\i[189]All Quests (%1)\",\"Cancel Text\":\"\\\\i[161]Close\",\"---Window Settings---\":\"\",\"X\":\"0\",\"Y\":\"0\",\"Width\":\"Graphics.boxWidth / 3\",\"Height\":\"this.fittingHeight(this.numVisibleRows())\",\"Rows\":\"4\",\"Columns\":\"1\",\"Line Height\":\"36\",\"Font Face\":\"GameFont\",\"Font Size\":\"28\",\"Standard Padding\":\"18\",\"Text Padding\":\"6\",\"Text Alignment\":\"left\",\"Standard Opacity\":\"255\",\"Back Opacity\":\"192\",\"Window Skin\":\"Window\"}","Quest List Window":"{\"---Types---\":\"\",\"Show Types\":\"true\",\"Type Order\":\"[\\\"\\\\\\\\c[6]Main Quests\\\",\\\"\\\\\\\\c[4]Side Quests\\\",\\\"\\\\\\\\c[3]Character Quests\\\",\\\"\\\\\\\\c[5]Tutorial Quests\\\"]\",\"List Open Symbol\":\"-\",\"List Closed Symbol\":\"+\",\"Type Text Format\":\"%1%2 (%3)\",\"Quest Indent\":\"0\",\"Show Empty\":\"false\",\"Read Quest\":\"\\\\i[121]Read Quest\",\"Cancel\":\"\\\\i[16]Cancel\",\"---Window Settings---\":\"\",\"X\":\"0\",\"Y\":\"Graphics.boxHeight - height\",\"Width\":\"Graphics.boxWidth / 3\",\"Height\":\"Graphics.boxHeight - this.fittingHeight(4)\",\"Line Height\":\"36\",\"Font Face\":\"GameFont\",\"Font Size\":\"28\",\"Standard Padding\":\"18\",\"Text Padding\":\"6\",\"Standard Opacity\":\"255\",\"Back Opacity\":\"192\",\"Type Alignment\":\"left\",\"Quest Alignment\":\"left\",\"Window Skin\":\"Window\"}","Quest Title Window":"{\"---Window Settings---\":\"\",\"No Quest Title\":\"\\\\c[4]Quest Journal\",\"X\":\"Graphics.boxWidth - width\",\"Y\":\"0\",\"Width\":\"Graphics.boxWidth * 2 / 3\",\"Height\":\"this.fittingHeight(1)\",\"Line Height\":\"36\",\"Font Face\":\"GameFont\",\"Font Size\":\"28\",\"Standard Padding\":\"18\",\"Text Padding\":\"6\",\"Text Alignment\":\"center\",\"Standard Opacity\":\"255\",\"Back Opacity\":\"192\",\"Window Skin\":\"Window\"}","Quest Data Window":"{\"---Data Settings---\":\"\",\"No Data Text\":\"\\\"Welcome to the \\\\\\\\c[4]Quest Journal\\\\\\\\c[0].\\\\n\\\\nHere, you can review over the various\\\\nquests given to you by people from all\\\\nover the world.\\\"\",\"Quest Data Format\":\"\\\"\\\\\\\\{%1\\\\\\\\}\\\\n
\\\\\\\\c[4]Level:\\\\\\\\c[0] %2\\\\n
\\\\\\\\c[4]From:\\\\\\\\c[0] %3\\\\n
\\\\\\\\c[4]Location:\\\\\\\\c[0] %4\\\\n
\\\\n
\\\\\\\\c[4]Description:\\\\\\\\c[0]\\\\n
%5\\\\n
\\\\n
\\\\\\\\c[4]Objectives:\\\\\\\\c[0]\\\\n
%6\\\\n
\\\\n
\\\\\\\\c[4]Rewards:\\\\\\\\c[0]\\\\n
%7\\\\n
\\\\n
%8\\\"\",\"Uncleared Objective\":\"\\\\i[160]%1\",\"Completed Objective\":\"\\\\i[165]%1\",\"Failed Objective\":\"\\\\i[162]%1\",\"Unclaimed Reward\":\"\\\\i[160]%1\",\"Claimed Reward\":\"\\\\i[163]%1\",\"Denied Reward\":\"\\\\i[161]%1\",\"Load Delay\":\"30\",\"---Window Settings---\":\"\",\"X\":\"Graphics.boxWidth - width\",\"Y\":\"Graphics.boxHeight - height\",\"Width\":\"Graphics.boxWidth * 2 / 3\",\"Height\":\"Graphics.boxHeight - this.fittingHeight(1)\",\"Line Height\":\"36\",\"Font Face\":\"GameFont\",\"Font Size\":\"28\",\"Standard Padding\":\"18\",\"Text Padding\":\"6\",\"Standard Opacity\":\"255\",\"Back Opacity\":\"192\",\"Window Skin\":\"Window\",\"Scroll Speed\":\"4\"}","Lunatic Mode":"{\"---Quest Menu---\":\"\",\"Before Create Windows\":\"\\\"// Variables\\\\n// background - background image used for the menu\\\\n// windowLayer - sprite layer that contains all windows\\\\n//\\\\n// background.bitmap = ImageManager.loadTitle1(\\\\\\\"Book\\\\\\\");\\\\n// this.fitScreen(background);\\\"\",\"After Create Windows\":\"\\\"// Variables\\\\n// background - background image used for the menu\\\\n// windowLayer - sprite layer that contains all windows\\\"\",\"Close Quest Menu\":\"\\\"// Variables\\\\n// background - background image used for the menu\\\\n// windowLayer - sprite layer that contains all windows\\\"\",\"---Quest Status---\":\"\",\"Quest Add\":\"\\\"// Variables:\\\\n// questId - ID of the quest being added\\\\n//\\\\n// console.log('Quest ' + questId + ' successfully added!')\\\"\",\"Quest Remove\":\"\\\"// Variables:\\\\n// questId - ID of the quest being removed\\\\n//\\\\n// console.log('Quest ' + questId + ' successfully removed!')\\\"\",\"Quest Complete\":\"\\\"// Variables:\\\\n// questId - ID of the quest set to completed\\\\n//\\\\n// console.log('Quest ' + questId + ' status changed to Completed!')\\\"\",\"Quest Fail\":\"\\\"// Variables:\\\\n// questId - ID of the quest set to failed\\\\n//\\\\n// console.log('Quest ' + questId + ' status changed to Failed!')\\\"\",\"Quest Available\":\"\\\"// Variables:\\\\n// questId - ID of the quest set to available\\\\n//\\\\n// console.log('Quest ' + questId + ' status changed to Available!')\\\"\",\"---Description---\":\"\",\"Change Description\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose description is changed\\\\n// index - Description index being changed to\\\\n//\\\\n// console.log('Quest ' + questId + ' description index changed to ' + index)\\\"\",\"---Objectives---\":\"\",\"Show Objective\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose objectives are altered\\\\n// objectiveId - ID of the objective being shown\\\\n//\\\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to shown!')\\\"\",\"Hide Objective\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose objectives are altered\\\\n// objectiveId - ID of the objective being hidden\\\\n//\\\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to hidden!')\\\"\",\"Complete Objective\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose objectives are altered\\\\n// objectiveId - ID of the objective being completed\\\\n//\\\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to completed!')\\\"\",\"Fail Objective\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose objectives are altered\\\\n// objectiveId - ID of the objective having failed\\\\n//\\\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to failed!')\\\"\",\"Normalize Objective\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose objectives are altered\\\\n// objectiveId - ID of the objective normalized\\\\n//\\\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to normal!')\\\"\",\"---Rewards---\":\"\",\"Show Reward\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose rewards are altered\\\\n// rewardId - ID of the reward being shown\\\\n//\\\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' becomes shown!')\\\"\",\"Hide Reward\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose rewards are altered\\\\n// rewardId - ID of the reward being hidden\\\\n//\\\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' becomes hidden!')\\\"\",\"Claim Reward\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose rewards are altered\\\\n// rewardId - ID of the reward becoming claimed\\\\n//\\\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is now claimed!')\\\"\",\"Deny Reward\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose rewards are altered\\\\n// rewardId - ID of the reward becoming denied\\\\n//\\\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is now denied!')\\\"\",\"Normalize Reward\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose rewards are altered\\\\n// rewardId - ID of the reward normalized\\\\n//\\\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is normalized!')\\\"\",\"---Subtext---\":\"\",\"Change Subtext\":\"\\\"// Variables:\\\\n// questId - ID of the quest whose subtext is changed\\\\n// index - Subtext index being changed to\\\\n//\\\\n// console.log('Quest ' + questId + ' subtext index changed to ' + index)\\\"\"}","---Quest List---":"","Quest 1":"","Quest 2":"","Quest 3":"","Quest 4":"","Quest 5":"","Quest 6":"","Quest 7":"","Quest 8":"","Quest 9":"","Quest 10":"","Quest 11":"","Quest 12":"","Quest 13":"","Quest 14":"","Quest 15":"","Quest 16":"","Quest 17":"","Quest 18":"","Quest 19":"","Quest 20":"","Quest 21":"","Quest 22":"","Quest 23":"","Quest 24":"","Quest 25":"","Quest 26":"","Quest 27":"","Quest 28":"","Quest 29":"","Quest 30":"","Quest 31":"","Quest 32":"","Quest 33":"","Quest 34":"","Quest 35":"","Quest 36":"","Quest 37":"","Quest 38":"","Quest 39":"","Quest 40":"","Quest 41":"","Quest 42":"","Quest 43":"","Quest 44":"","Quest 45":"","Quest 46":"","Quest 47":"","Quest 48":"","Quest 49":"","Quest 50":"","Quest 51":"","Quest 52":"","Quest 53":"","Quest 54":"","Quest 55":"","Quest 56":"","Quest 57":"","Quest 58":"","Quest 59":"","Quest 60":"","Quest 61":"","Quest 62":"","Quest 63":"","Quest 64":"","Quest 65":"","Quest 66":"","Quest 67":"","Quest 68":"","Quest 69":"","Quest 70":"","Quest 71":"","Quest 72":"","Quest 73":"","Quest 74":"","Quest 75":"","Quest 76":"","Quest 77":"","Quest 78":"","Quest 79":"","Quest 80":"","Quest 81":"","Quest 82":"","Quest 83":"","Quest 84":"","Quest 85":"","Quest 86":"","Quest 87":"","Quest 88":"","Quest 89":"","Quest 90":"","Quest 91":"","Quest 92":"","Quest 93":"","Quest 94":"","Quest 95":"","Quest 96":"","Quest 97":"","Quest 98":"","Quest 99":"","Quest 100":""}}, +{"name":"YEP_RegionEvents","status":true,"description":"v1.03 Make it so that whenever players step on certain\nRegion ID's, the game will play certain common events.","parameters":{"---Regions 1 to 20---":"","Region 1":"0","Region 2":"0","Region 3":"0","Region 4":"0","Region 5":"0","Region 6":"0","Region 7":"0","Region 8":"0","Region 9":"0","Region 10":"0","Region 11":"0","Region 12":"0","Region 13":"0","Region 14":"0","Region 15":"0","Region 16":"0","Region 17":"0","Region 18":"0","Region 19":"0","Region 20":"0","---Regions 21 to 40---":"","Region 21":"0","Region 22":"0","Region 23":"0","Region 24":"0","Region 25":"0","Region 26":"0","Region 27":"0","Region 28":"0","Region 29":"0","Region 30":"0","Region 31":"0","Region 32":"0","Region 33":"0","Region 34":"0","Region 35":"0","Region 36":"0","Region 37":"0","Region 38":"0","Region 39":"0","Region 40":"0","---Regions 41 to 60---":"","Region 41":"0","Region 42":"0","Region 43":"0","Region 44":"0","Region 45":"0","Region 46":"0","Region 47":"0","Region 48":"0","Region 49":"0","Region 50":"0","Region 51":"0","Region 52":"0","Region 53":"0","Region 54":"0","Region 55":"0","Region 56":"0","Region 57":"0","Region 58":"0","Region 59":"0","Region 60":"0","---Regions 61 to 80---":"","Region 61":"0","Region 62":"0","Region 63":"0","Region 64":"0","Region 65":"0","Region 66":"0","Region 67":"0","Region 68":"0","Region 69":"0","Region 70":"0","Region 71":"0","Region 72":"0","Region 73":"0","Region 74":"0","Region 75":"0","Region 76":"0","Region 77":"0","Region 78":"0","Region 79":"0","Region 80":"0","---Regions 81 to 100---":"","Region 81":"0","Region 82":"0","Region 83":"0","Region 84":"0","Region 85":"0","Region 86":"0","Region 87":"0","Region 88":"0","Region 89":"0","Region 90":"0","Region 91":"0","Region 92":"0","Region 93":"0","Region 94":"0","Region 95":"0","Region 96":"0","Region 97":"0","Region 98":"0","Region 99":"0","Region 100":"0","---Regions 101 to 120---":"","Region 101":"0","Region 102":"0","Region 103":"0","Region 104":"0","Region 105":"0","Region 106":"0","Region 107":"0","Region 108":"0","Region 109":"0","Region 110":"0","Region 111":"0","Region 112":"0","Region 113":"0","Region 114":"0","Region 115":"0","Region 116":"0","Region 117":"0","Region 118":"0","Region 119":"0","Region 120":"0","---Regions 121 to 140---":"","Region 121":"0","Region 122":"0","Region 123":"0","Region 124":"0","Region 125":"0","Region 126":"0","Region 127":"0","Region 128":"0","Region 129":"0","Region 130":"0","Region 131":"0","Region 132":"0","Region 133":"0","Region 134":"0","Region 135":"0","Region 136":"0","Region 137":"0","Region 138":"0","Region 139":"0","Region 140":"0","---Regions 141 to 160---":"","Region 141":"0","Region 142":"0","Region 143":"0","Region 144":"0","Region 145":"0","Region 146":"0","Region 147":"0","Region 148":"0","Region 149":"0","Region 150":"0","Region 151":"0","Region 152":"0","Region 153":"0","Region 154":"0","Region 155":"0","Region 156":"0","Region 157":"0","Region 158":"0","Region 159":"0","Region 160":"0","---Regions 161 to 180---":"","Region 161":"0","Region 162":"0","Region 163":"0","Region 164":"0","Region 165":"0","Region 166":"0","Region 167":"0","Region 168":"0","Region 169":"0","Region 170":"0","Region 171":"0","Region 172":"0","Region 173":"0","Region 174":"0","Region 175":"0","Region 176":"0","Region 177":"0","Region 178":"0","Region 179":"0","Region 180":"0","---Regions 181 to 200---":"","Region 181":"0","Region 182":"0","Region 183":"0","Region 184":"0","Region 185":"0","Region 186":"0","Region 187":"0","Region 188":"0","Region 189":"0","Region 190":"0","Region 191":"0","Region 192":"0","Region 193":"0","Region 194":"0","Region 195":"0","Region 196":"0","Region 197":"0","Region 198":"0","Region 199":"0","Region 200":"0","---Regions 201 to 220---":"","Region 201":"0","Region 202":"0","Region 203":"0","Region 204":"0","Region 205":"0","Region 206":"0","Region 207":"0","Region 208":"0","Region 209":"0","Region 210":"0","Region 211":"0","Region 212":"0","Region 213":"0","Region 214":"0","Region 215":"0","Region 216":"0","Region 217":"0","Region 218":"0","Region 219":"0","Region 220":"0","---Regions 221 to 240---":"","Region 221":"0","Region 222":"0","Region 223":"0","Region 224":"0","Region 225":"0","Region 226":"0","Region 227":"0","Region 228":"0","Region 229":"0","Region 230":"0","Region 231":"0","Region 232":"0","Region 233":"0","Region 234":"0","Region 235":"0","Region 236":"0","Region 237":"0","Region 238":"0","Region 239":"0","Region 240":"0","---Regions 241 to 255---":"","Region 241":"0","Region 242":"0","Region 243":"0","Region 244":"0","Region 245":"0","Region 246":"0","Region 247":"0","Region 248":"0","Region 249":"0","Region 250":"0","Region 251":"0","Region 252":"0","Region 253":"0","Region 254":"0","Region 255":"0"}}, +{"name":"YEP_SaveCore","status":true,"description":"v1.06 Alter the save menu for a more aesthetic layout\nand take control over the file system's rules.","parameters":{"---General---":"","Max Files":"24","Saved Icon":"231","Empty Icon":"230","Return After Saving":"false","Auto New Index":"true","---Action Window---":"","Load Command":"Load","Save Command":"Save","Delete Command":"Delete","---Help Window---":"","Select Help":"Please select a file slot.","Load Help":"Loads the data from the saved game.","Save Help":"Saves the current progress in your game.","Delete Help":"Deletes all data from this save file.","---Delete---":"","Delete Filename":"Damage2","Delete Volume":"100","Delete Pitch":"150","Delete Pan":"0","---Info Window---":"","Show Game Title":"true","Invalid Game Text":"This save is for a different game.","Empty Game Text":"Empty","Map Display Name":"true","Party Display":"2","Party Y Position":"this.lineHeight() + Window_Base._faceHeight","Show Actor Names":"true","Name Font Size":"20","Show Actor Level":"true","Level Font Size":"20","Level Format":"\\c[16]%1 \\c[0]%3","Data Font Size":"20","Data Column 1":"empty, playtime, save count, gold count","Data Column 2":"location, variable 1, variable 2, variable 3","Data Column 3":"empty, variable 4, variable 5, variable 6","Data Column 4":"","---Vocabulary---":"","Map Location":"","Playtime":"Playtime:","Save Count":"Total Saves:","Gold Count":"%1:","---Technical---":"","Save Mode":"auto","Local Config":"config.rpgsave","Local Global":"global.rpgsave","Local Save":"file%1.rpgsave","Web Config":"RPG %1 Config","Web Global":"RPG %1 Global","Web Save":"RPG %1 File%2","---Confirmation---":"","Load Confirmation":"true","Load Text":"Do you wish to load this save file?","Save Confirmation":"true","Save Text":"Do you wish to overwrite this save file?","Delete Confirmation":"true","Delete Text":"Do you wish to delete this save file?","Confirm Yes":"Yes","Confirm No":"No"}}, +{"name":"YEP_SaveEventLocations","status":true,"description":"v1.06 Enable specified maps to memorize the locations of\nevents when leaving and loading them upon reentering map.","parameters":{}}, +{"name":"YEP_ScriptCallPluginCmd","status":true,"description":"v1.00 (Req YEP_MessageCore.js) Allows you to create your own\ncustom text codes and determine what they do.","parameters":{}}, +{"name":"YEP_SkillCore","status":true,"description":"v1.13 Skills are now given more functions and the ability\r\nto require different types of costs.","parameters":{"---General---":"","Cost Padding":"4","Command Alignment":"center","Window Columns":"2","---HP Costs---":"","HP Format":"%1%2","HP Font Size":"20","HP Text Color":"18","HP Icon":"162","---MP Costs---":"","MP Format":"%1%2","MP Font Size":"20","MP Text Color":"23","MP Icon":"165","---TP Costs---":"","TP Format":"%1%2","TP Font Size":"20","TP Text Color":"29","TP Icon":"164"}}, +{"name":"YEP_VictoryAftermath","status":true,"description":"v1.07 Display an informative window after a battle is over\ninstead of message box text stating what the party earned.","parameters":{"---General---":"","Victory Order":"exp custom drops","---BGM---":"","Victory BGM":"Ship3","BGM Volume":"90","BGM Pitch":"100","BGM Pan":"0","---Battle Results---":"","Cheer Wait":"90","Battle Results Text":"Battle Results","Battle Drops Text":"Battle Spoils","---EXP Window---":"","Font Size":"28","Level Up Text":"LEVEL UP!","Max Level Text":"MAX LEVEL","Show Skills Learned":"false","Gained EXP Text":"Gained EXP","Gained EXP Format":"+%1","EXP Gauge Color 1":"30","EXP Gauge Color 2":"31","Level Gauge Color 1":"14","Level Gauge Color 2":"6","Gauge Ticks":"15","Tick SE":"Absorb2","Tick Volume":"90","Tick Pitch":"150","Tick Pan":"0"}}, +{"name":"YEP_X_ActSeqPack1","status":true,"description":"v1.13 (Requires YEP_BattleEngineCore.js) Basic functions are\nadded to the Battle Engine Core's action sequences.","parameters":{"Default Volume":"90","Default Pitch":"100","Default Pan":"0"}}, +{"name":"YEP_X_ActSeqPack2","status":true,"description":"v1.13 (Requires YEP_BattleEngineCore.js) Visual functions\nare added to the Battle Engine Core's action sequences.","parameters":{}}, +{"name":"YEP_X_ActSeqPack3","status":true,"description":"v1.05 (Requires YEP_BattleEngineCore.js) Camera control is\nadded to the Battle Engine Core's action sequences.","parameters":{"Camera Option":"Battle Camera"}}, +{"name":"YEP_X_AnimatedSVEnemies","status":true,"description":"v1.20 (Requires YEP_BattleEngineCore.js) This plugin lets\nyou use Animated Sideview Actors for enemies!","parameters":{"---General---":"","Anchor X":"0.5","Anchor Y":"1.0","Sprite Smoothing":"true","Sprite Width":"auto","Sprite Height":"auto","Collapse":"false","Frame Speed":"12","Show State Overlay":"true","---Shadows---":"","Show Shadow":"false","Shadow Scale X":"auto","Shadow Scale Y":"auto","---Breathing---":"","Enable Breathing":"1","Breathing Speed":"20","Breathing X Rate":"0.001","Breathing Y Rate":"0.020","HP Link Breathing":"false","---Floating---":"","Floating Speed":"20","Floating Rate":"0.3","Floating Height":"50","Floating Death":"true","---Motions---":"","Attack Motion":"thrust","Idle Motion":"walk","Damage Motion":"damage","Evade Motion":"evade","Escape Motion":"escape","Guard Motion":"guard","Abnormal Motion":"abnormal","Sleep Motion":"sleep","Dying Motion":"dying","Dead Motion":"dead","---Weapons---":"","Weapon Image Index":"0","Weapon 1 Motion":"swing","Weapon 1 Animation":"6","Weapon 2 Motion":"swing","Weapon 2 Animation":"6","Weapon 3 Motion":"swing","Weapon 3 Animation":"1","Weapon 4 Motion":"swing","Weapon 4 Animation":"6","Weapon 5 Motion":"swing","Weapon 5 Animation":"6","Weapon 6 Motion":"swing","Weapon 6 Animation":"1","Weapon 7 Motion":"missile","Weapon 7 Animation":"11","Weapon 8 Motion":"missile","Weapon 8 Animation":"11","Weapon 9 Motion":"missile","Weapon 9 Animation":"111","Weapon 10 Motion":"thrust","Weapon 10 Animation":"16","Weapon 11 Motion":"thrust","Weapon 11 Animation":"1","Weapon 12 Motion":"thrust","Weapon 12 Animation":"11","Weapon 13 Motion":"swing","Weapon 13 Animation":"1","Weapon 14 Motion":"swing","Weapon 14 Animation":"1","Weapon 15 Motion":"swing","Weapon 15 Animation":"1","Weapon 16 Motion":"swing","Weapon 16 Animation":"6","Weapon 17 Motion":"swing","Weapon 17 Animation":"7","Weapon 18 Motion":"swing","Weapon 18 Animation":"1","Weapon 19 Motion":"missile","Weapon 19 Animation":"11","Weapon 20 Motion":"missile","Weapon 20 Animation":"111","Weapon 21 Motion":"missile","Weapon 21 Animation":"111","Weapon 22 Motion":"thrust","Weapon 22 Animation":"7","Weapon 23 Motion":"missile","Weapon 23 Animation":"15","Weapon 24 Motion":"thrust","Weapon 24 Animation":"15","Weapon 25 Motion":"swing","Weapon 25 Animation":"1","Weapon 26 Motion":"thrust","Weapon 26 Animation":"1","Weapon 27 Motion":"thrust","Weapon 27 Animation":"1","Weapon 28 Motion":"thrust","Weapon 28 Animation":"1","Weapon 29 Motion":"thrust","Weapon 29 Animation":"1","Weapon 30 Motion":"thrust","Weapon 30 Animation":"1"}}, +{"name":"YEP_X_BattleSysATB","status":true,"description":"v1.28 (Requires YEP_BattleEngineCore.js) Add ATB (Active\nTurn Battle) into your game using this plugin!","parameters":{"---ATB Settings---":"","Per Tick":"user.agi","Initial Speed":"0","Full Gauge":"Math.max(5000, BattleManager.highestBaseAgi() * 100)","Charge Gauge":"Math.max(2000, BattleManager.highestBaseAgi() * 20)","Pre-Emptive Bonuses":"0.8","Surprise Bonuses":"0.8","---Escape---":"","Escape Ratio":"0.125 * $gameParty.agility() / $gameTroop.agility()","Fail Escape Boost":"0.025","Full Turn":"Math.min(200, BattleManager.lowestBaseAgi() * 8)","Flash Enemy":"true","---Turn---":"","---Rubberband---":"","Enable Rubberband":"true","Minimum Speed":"0.5 * BattleManager.highestBaseAgi()","Maximum Speed":"1.5 * BattleManager.highestBaseAgi()","---Sound---":"","Ready Sound":"Decision1","Ready Volume":"90","Ready Pitch":"120","Ready Pan":"0","---Options---":"","ATB Speed Text":"ATB Speed","Default ATB Speed":"10","---Windows---":"","Lock Status Window":"true","Gauge Style":"1","Gauge Text":"Turn","Gauge Text Align":"center","ATB Gauge Color 1":"13","ATB Gauge Color 2":"5","Slow Gauge Color 1":"12","Slow Gauge Color 2":"4","Fast Gauge Color 1":"26","Fast Gauge Color 2":"27","Stop Gauge Color 1":"7","Stop Gauge Color 2":"8","Full Gauge Color 1":"14","Full Gauge Color 2":"6","Charge Gauge Color 1":"2","Charge Gauge Color 2":"10"}}, +{"name":"YEP_X_BattleSysCTB","status":true,"description":"v1.17 (Requires YEP_BattleEngineCore.js) Add CTB (Charge\nTurn Battle) into your game using this plugin!","parameters":{"---CTB Settings---":"","Per Tick":"user.agi","Initial Speed":"0","Full Gauge":"Math.max(7000, BattleManager.highestBaseAgi() * 120)","Pre-Emptive Bonuses":"0.8","Surprise Bonuses":"0.8","---Escape---":"","Escape Ratio":"0.125 * $gameParty.agility() / $gameTroop.agility()","Fail Escape Boost":"0.025","---Turn---":"","Full Turn":"Math.min(200, BattleManager.lowestBaseAgi() * 8)","---Rubberband---":"","Enable Rubberband":"true","Minimum Speed":"0.5 * BattleManager.highestBaseAgi()","Maximum Speed":"1.5 * BattleManager.highestBaseAgi()","---Sound---":"","Ready Sound":"Decision1","Ready Volume":"90","Ready Pitch":"120","Ready Pan":"0","---Turn Order---":"","Show Turn Order":"true","Icon Size":"32","Position Y":"54","Position X":"right","Turn Direction":"left","Ally Border Color":"4","Ally Back Color":"22","Ally Icon":"0","Enemy Border Color":"2","Enemy Back Color":"19","Enemy Icon":"0","Enemy SV Battlers":"false"}}, +{"name":"YEP_X_BattleSysSTB","status":true,"description":"v1.05 (Requires YEP_BattleEngineCore.js) Add STB (Standard\nTurn Battle) into your game using this plugin!","parameters":{"---General---":"","Action Speed":"agi","Delay Status Adjust":"true","---Escape---":"","Escape Ratio":"0.125 * $gameParty.agility() / $gameTroop.agility()","Fail Escape Boost":"0.025","---Turn Order---":"","Show Turn Window":"false","Turn Window X":"Graphics.boxWidth - width","Turn Window Y":"this.fittingHeight(2)","Turn Window Width":"200","Turn Window Height":"Graphics.boxHeight - statusHeight - this.fittingHeight(2)","Current Battler Color":"6","Actor Battler Color":"4","Enemy Battler Color":"2"}}, +{"name":"YEP_X_CoreUpdatesOpt","status":true,"description":"v1.62 (Req YEP_CoreEngine.js) Update your game without needing\nto change your base rpg_x.js files and optimize it for desktop.","parameters":{"---Official Updates---":"","110_Updates":"true","120_Updates":"true","130_Updates":"true","131_Updates":"true","132_Updates":"true","133_Updates":"true","134_Updates":"true","140_Updates":"true","150_Updates":"true","151_Updates":"true","152_Updates":"true","162_Updates":"true","---Custom---":"","Desktop_Updates":"true"}}, +{"name":"YEP_X_ExtMovePack1","status":true,"description":"v1.01 (Requires YEP_MoveRouteCore.js) Adds extra movement\noptions to create specific behaviors in movement patterns.","parameters":{}}, +{"name":"YEP_X_ItemUpgradeSlots","status":true,"description":"v1.10 (Requires YEP_ItemCore.js) Allows independent items to\nbe upgradeable and gain better stats.","parameters":{"Default Slots":"3","Slot Variance":"1","Upgrade Command":"Upgrade %1","Show Only":"true","Slots Available":"Slots Available","Show Slot Upgrades":"true","Slot Upgrade Format":"\\}Slot%1: %2\\{","Default Sound":"Heal2"}}, +{"name":"YEP_X_SkillCooldowns","status":true,"description":"v1.12 (Requires YEP_SkillCore.js) Cooldowns can be applied\nto skills to prevent them from being used continuously.","parameters":{"---Cooldown---":"","Cooldown Format":"%1CD","Cooldown Font Size":"20","Cooldown Text Color":"6","Cooldown Icon":"75","Cooldown After Battle":"-10","Cooldown Steps":"5","Cooldown Bypass":"1 2 3 4 5 6 7","Cooldown Bypass List":"[]","---Warmup---":"","Warmup Format":"%1WU","Warmup Font Size":"20","Warmup Text Color":"4","Warmup Icon":"75","---Battle Core---":"","Time Based":"false","Turn Time":"100"}} ]; diff --git a/js/plugins/--------------------.js b/js/plugins/--------------------.js new file mode 100644 index 0000000..58aa3b6 --- /dev/null +++ b/js/plugins/--------------------.js @@ -0,0 +1,6 @@ +//============================================================================= + /*: + * @plugindesc ------------------------------------------------------------ + * @author Yanfly Engine Plugins + */ +//============================================================================= diff --git a/js/plugins/KELYEP_DragonBones.js b/js/plugins/KELYEP_DragonBones.js new file mode 100644 index 0000000..04b33b7 --- /dev/null +++ b/js/plugins/KELYEP_DragonBones.js @@ -0,0 +1,1513 @@ +//============================================================================= +// Yanfly Engine Plugins + TheGreenKel - DragonBones Battle Integration +// KELYEP_DragonBones.js +//============================================================================= + +var Imported = Imported || {}; +Imported.KELYEP_DragonBones = true; + +var Yanfly = Yanfly || {}; +Yanfly.KelBattle = Yanfly.KelBattle || {}; +Yanfly.KelBattle.version = 1.09; + +//============================================================================= + /*: + * @plugindesc v1.09 DragonBones Integration with YEP library compatibility! + * Use DragonBones assets with your battlers! + * @author Yanfly Engine Plugins + TheGreenKel Collaboration + * + * @param ---General--- + * @default + * + * @param Assets Path + * @parent ---General--- + * @desc The folder that store all of the files exported from + * DragonBones Software 5.2 (or greater) + * @default ./dragonbones_assets/ + * + * @param Support UpperCase Animation Names + * @text UpperCase Animation Names + * @parent ---General--- + * @type boolean + * @on Support + * @off Don't + * @desc If your animation names are all lowercase, then turn this + * off for much better performance. ON - true OFF - false + * @default true + * + * @param Debug Console Text + * @parent ---General--- + * @type boolean + * @on Show + * @off Hide + * @desc Show various status updates on the console? + * SHOW - true HIDE - false + * @default false + * + * @param ---Preload--- + * @default + * + * @param Preload Assets + * @parent ---Preload--- + * @type text[] + * @desc This is a list of all DragonBones assets to be preloaded at + * game launch after the database is fully loaded. + * @default [] + * + * @param Auto-Preload Battlers + * @parent ---Preload--- + * @type boolean + * @on Auto-Preload + * @off Manual-Preload + * @desc Automatically preload battlers when assigned an asset from + * notetags? Recommended: true YES - true NO - false + * @default true + * + * @param ---Defaults--- + * @default + * + * @param Replace Battler Sprite + * @parent ---Defaults--- + * @type boolean + * @on Replace + * @off Keep + * @desc Fully replace the battler's sprite if it has an associated + * DragonBones asset? REPLACE - true KEEP - false + * @default true + * + * @param Default ScaleX + * @parent ---Defaults--- + * @type number + * @decimals 1 + * @desc The default amount to scale a DragonBones battler's X property. + * @default 0.5 + * + * @param Default ScaleY + * @parent ---Defaults--- + * @type number + * @decimals 1 + * @desc The default amount to scale a DragonBones battler's Y property. + * @default 0.5 + * + * @param Default Width + * @parent ---Defaults--- + * @type number + * @desc The default amount to set a DragonBones battler's width. + * @default 100 + * + * @param Default Height + * @parent ---Defaults--- + * @type number + * @desc The default amount to scale a DragonBones battler's height. + * @default 100 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * DragonBones allows your games to use skeletal animation, a type of computer + * animation in which a character (or object) is represented by skins/textures + * and a digital set of interconnected bones (called the skeleton). Using a set + * of instructions, the game will create animations based off these skins, + * skeletons, and instructions to create beautifully smooth and light-weight + * movements. + * + * This plugin, made by TheGreenKel, and collaborated with Yanfly, will allow + * you to use skeletal animations made by DragonBones for your battle system! + * This means that with skeletal animation, you can make your battles look + * extremely fluid, more flexible animations outside of only 3 frames per + * motion, more than 18 possible motions, get rid of sprite based resources for + * faster loading times, and smaller file sizes for your games! In other words, + * there's practically no drawback to using it provided you have the resources. + * + * This is a collaboration plugin by TheGreenKel and Yanfly to ensure + * compatibility with the Yanfly Engine Plugins library. + * + * ============================================================================ + * MIT License and Terms of Use + * ============================================================================ + * + * MIT License for the remaining code of the Plugin + * + * Copyright 2017 TheGreenKel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Yanfly Engine Plugins Terms of Use + * + * Any original material made by Yanfly is free for use with both free and + * commercial RPG Maker games unless specified otherwise. I do not demand + * royalties or special liberties if you choose to use Yanfly original content + * in your commercial games. (Although a free copy of your game would be nice!) + * I only ask that you provide 'Yanfly' or 'Yanfly Engine' a spot in your + * game’s credits. + * + * Any edits made to Yanfly original material are okay as long as you still + * provide the proper credit. Any non-Original content posted, linked, or + * shared on my website and channel will still require you to contact the + * respective parties for permission of use. + * + * ============================================================================ + * Installation Instructions + * ============================================================================ + * + * Follow these instructions to integrate DragonBones into your game: + * + * 1. Make sure you have at least RPG Maker MV version 1.4.0 or above. + * Recommended version is 1.5.0 and above! + * + * 2. Download the Installation Pack from Yanfly.moe or from: + * https://thegreenkel.itch.io/dragonbones-rpg-maker-mv-plugin + * + * 3. Extract the Installation Pack using WinZip or WinRar. + * + * 4. Copy the contents of the 'js' folder into your project's folder matching + * the directory structure and files. + * + * 5. Open up your game project's index.html file with Notepad/HTML editor + * + * 6. Find + * + * + * 7. Install this plugin by adding it through your Plugin Manager. + * + * 8. Make sure this plugin is located UNDER the following plugins: + * YEP_BattleEngineCore + * YEP_X_ActSeqPack1 + * YEP_X_ActSeqPack2 + * YEP_X_ActSeqPack3 + * YEP_X_AnimatedSVEnemies + * + * 9. Copy the DragonBone assets from the Installation pack into the respective + * folder you wish for your game project. Adjust the 'Assets Path' plugin + * parameter to match the folder path. + * + * 10. Save your game project! + * + * ============================================================================ + * General Usage by TheGreenKel + * ============================================================================ + * + * The plugin is only tested on DragonBones 5.2 & 5.3. I rewrote a chunk of the + * plugin to make it compatible with Yanfly plugins, and possibly more. + * + * Usage: + * 1) After confirming your DragonBones Armature/Skeleton shares the name of + * your Battler, export DragonBones data (with Data Version set to 5.0) + * into the 'Assets Path' parameter. Default is 'dragonbones_assets' + * + * 2) Add the new armature data into 'Preload Assets' parameter + * + * 3) This plugin will automatically look for the 18 default + * animations inside the dragonbones armature. + * [walk, swing, damage, dead, wait, chant, guard, etc.] + * + * 4) You can overwrite default animation by using + * 'dragonbone_ani_' notes. + * Example: 'dragonbone_ani_walk:steady', the 'steady' animation + * will be played inplace of the 'walk' + * + * 5) Vanilla actor/enemies now show up by default. You need to + * replace it with a blank image. Check the demo project to see + * what a blank image would look like. This change will make this + * plugin more compatible with plugins that changes UI. + * + * 6) If you are using Yanfly Action Sequence 2, you can now play any + * dragonbones' animation using the 'motion' command. + * Example: "motion dance". The game will look into the dragonbones + * armature to see if it has the 'dance' animation. If the animation + * is there then the animation will be played. + * + * 7) You can now control whether an animation is looping or not + * by setting the 'Play Times' variable inside the Dragonbones Editor. + * + * 8) Get more info/tutorial at forum link: + * https://forums.rpgmakerweb.com/index.php?threads/rmmv-dragonbones-2d-animation-integration.81027/ + * + * Important DragonBones Animation note: + * A limitation of DragonBones Data version 5.0 is that you must use + * the same animation curves for position/rotation/scale keys. + * Below is an example of how the DragonBones and exported version + * differ because it prioritized the positions animation curve. + * https://gyazo.com/fd3539028c0ecadd2a727b99ac8398a4 + * https://gyazo.com/e79427f5f5b5e4b56a15dfc2bf76253f + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * Use the following notetags to make full use of your DragonBone battler + * integration for your RPG Maker MV game! + * + * Actor and Enemy Notetags: + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * + * + * - Sets the DragonBones associated with this actor/enemy to be "name". The + * name will be associated with the assets used. It will be used to check for + * associated filenames that end with _ske.json, _tex.json, and _tex.png. The + * listed assets must be found in your assets folder. + * + * * Note: The name is case sensitive. + * * Note: If the plugin parameter 'Auto-Preload Battlers' is set to 'true', + * then this will add the battler to the list of assets to be preloaded. + * + * **EXAMPLES** + * + * + * + * + * + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * If a DragonBones battler is not detected here, it will not be able to + * utilize the following notetags and their effects. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * + * + * - Replace 'n' with a number. It can be positive or negative, whole or + * decimal number. This will affect how much the battler will be scaled by. + * A number less than 1 will be smaller than the base asset itself while a + * number larger than 1 will be larger than the base asset. If the number is + * negative, it will be mirrored horizontally or vertically depending if + * ScaleX or ScaleY is used respectively. + * + * * Note: This will overwrite the setting set in the plugin parameters for + * 'Default ScaleX' and 'Default ScaleY'. + * + * **EXAMPLES** + * + * + * + * + * + * + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * + * + * - This allows you to set the 'width' and 'height' of the DragonBones + * battler by replacing 'x' with an integar value. This value is mostly used + * for collision purposes as well as mouse click activation. These values can + * be adjusted because each battler can be a dynamic width/height so it is + * important for you to adjust them properly. If not adjusted, they will take + * on the default width/height values found in the plugin parameters. + * + * **EXAMPLES** + * + * + * + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * + * + * - Lets you decide if you want to keep the original sprite used for the + * actor/enemy or have the DragonBone battler replace it altogether. If you + * opt to replace the sprite, then the sprite will be hidden during battle + * as long as there is a DragonBone battler in place of it. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * + * - Replace 'motion' with a proper battler motion name. 'animation' is to be + * replaced with a skeletal animation name from DragonBones. This is for any + * motion that doesn't have a specified skeletal animation of the same name + * in DragonBones. + * + * Replace 'motion' with one of the following: + * attack + * walk thrust escape + * wait swing victory + * chant missile dying + * guard skill abnormal + * damage spell sleep + * evade item dead + * + * * Note: The 'animation' to be replaced is case sensitive. + * + * **EXAMPLES** + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * For those who want a more condensed way to adjust the DragonBone battler + * settings, you can use the following notetag format: + * + * + * Battler: name // The name used for the DB battler + * + * ScaleX: 0.3 // Scale X used for the DB battler + * ScaleY: 0.3 // Scale Y used for the DB battler + * Width: 150 // Width used for the DB battler + * Height: 180 // Height used for the DB battler + * + * // Below are a bunch of battler motions tied to skeletal animations + * + * Ani Attack: normalAttack + * Ani Walk: steady + * Ani Damage: hit + * Ani Dead: dead + * Ani Wait: steady + * Ani Chant: stun + * Ani Swing: stun + * Ani Evade: stun + * Ani Thrust: stun + * Ani Missile: stun + * Ani Skill: stun + * Ani Spell: stun + * Ani Item: stun + * Ani Victory: stun + * Ani Dying: stun + * Ani Abnormal: stun + * Ani Sleep: stun + * + * Keep Sprite // Allow the sprite to show alongside DB battler + * Replace Sprite // Hide the sprite while the DB battler is active + * + * + * - Anything placed in between the notetags: and + * will be used to determine the properties set for + * the DragonBone battler used for the actor/enemy. With the exception of the + * 'name' property, all other properties are optional and can be omitted from + * the list of properties to sandwich inbetween your notetags. + * + * **EXAMPLES** + * + * + * Battler: Ubbie + * Replace Sprite + * ScaleX: -0.2 + * ScaleY: 0.2 + * Width: 150 + * Height: 100 + * + * + * + * Battler: Demon + * Replace Sprite + * ScaleX: 0.3 + * ScaleY: 0.3 + * Width: 140 + * Height: 140 + * + * + * + * Battler: Swordsman + * Replace Sprite + * ScaleX: -0.4 + * ScaleY: 0.4 + * Width: 150 + * Height: 180 + * + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.09; + * - Bugfix updated by SwiftIllusion to make sure blend color are inherited + * by actor Dragonbones sprites. + * + * Version 1.08: + * - Bugfix by Irina & SwiftIllusion for Flash Colors on Dragonbones battlers + * + * Version 1.07: + * - Bugfixed for animation height rate for Dragonbones battlers. + * + * Version 1.06: + * - Bugfix for Action Sequences for Jump and Float not affecting units with + * DragonBones battlers. + * + * Version 1.05: + * - Bugfix provided for crashes made by animations played on non-battler + * sprites. + * + * Version 1.04: + * - Bugfix provided by SwiftIllusion regarding the animation positioning on + * DragonBones battlers. + * + * Version 1.03: + * - Fixed an issue with state sprites appearing behind DragonBones assets. + * + * Version 1.02: + * - Change to collapse effect occuring after death animation is completed so + * that it fades away like normal instead of being stuck on the field. + * Credits: Swift Illusion + * + * Version 1.01: + * - If using YEP_X_AnimatedSVEnemies, enemies with DragonBones battlers will + * be considered animated enemies, too. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.3.5") { + +//============================================================================= +// Parameter Variables +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel and Yanfly +//============================================================================= + +var dragonBonesIntegration = []; + +dragonBonesIntegration.ArmatureDatabaseEnemy = []; +dragonBonesIntegration.ArmatureDatabaseActor = []; + +dragonBonesIntegration.currentLoadIndex = 0; +dragonBonesIntegration.lastFileName = ''; +dragonBonesIntegration.bIsPreloading = false; + +Yanfly.Parameters = PluginManager.parameters('KELYEP_DragonBones'); + +dragonBonesIntegration.AssetsPath = String(Yanfly.Parameters['Assets Path']); +dragonBonesIntegration.supportUpperCaseNames = + JSON.parse(Yanfly.Parameters['Support UpperCase Animation Names']); +dragonBonesIntegration.consoleDebug = + JSON.parse(Yanfly.Parameters['Debug Console Text']); + +dragonBonesIntegration.AssetsArray = + JSON.parse(Yanfly.Parameters['Preload Assets']); +dragonBonesIntegration.autoPreloadBattlers = + JSON.parse(Yanfly.Parameters['Auto-Preload Battlers']); + +dragonBonesIntegration.ReplaceBattleSprite = + JSON.parse(Yanfly.Parameters['Replace Battler Sprite']); +dragonBonesIntegration.DefaultScaleX = + Number(Yanfly.Parameters['Default ScaleX']); +dragonBonesIntegration.DefaultScaleY = + Number(Yanfly.Parameters['Default ScaleY']); +dragonBonesIntegration.DefaultWidth = + Number(Yanfly.Parameters['Default Width']); +dragonBonesIntegration.DefaultHeight = + Number(Yanfly.Parameters['Default Height']); + +//============================================================================= +// DataManager +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel and Yanfly +//============================================================================= + +Yanfly.KelBattle.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.KelBattle.DataManager_isDatabaseLoaded.call(this)) return false; + + if (!Yanfly._loaded_KELYEP_DragonBones) { + this.processDragonBonesBattleIntegrationNotetags1($dataActors); + this.processDragonBonesBattleIntegrationNotetags1($dataEnemies); + dragonBonesIntegration.PreLoadAllArmatures(); + Yanfly._loaded_KELYEP_DragonBones = true; + } + + if (dragonBonesIntegration.bIsPreloading === true) { + //console.log('Running isDatabaseLoaded'); + return false; + } + return true; +}; + +DataManager.processDragonBonesBattleIntegrationNotetags1 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + this.processDragonBonesDefaults(obj); + var evalMode = 'none'; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + // Standard Notetags + if (line.match(/<(?:DB|DRAGONBONE)[ ](?:BATTLER|SKIN|NAME):[ ]*(.*)>/i)) { + obj.meta.dragonbone = String(RegExp.$1).trim(); + } else if (line.match(/<(?:DB|DRAGONBONE):[ ]*(.*)>/i)) { + obj.meta.dragonbone = String(RegExp.$1).trim(); + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]SCALEX:[ ](.*)>/i)) { + obj.meta.dragonbone_scalex = Number(RegExp.$1); + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]SCALEY:[ ](.*)>/i)) { + obj.meta.dragonbone_scaley = Number(RegExp.$1); + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]WIDTH:[ ](.*)>/i)) { + obj.meta.dragonbone_width = Number(RegExp.$1); + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]HEIGHT:[ ](.*)>/i)) { + obj.meta.dragonbone_height = Number(RegExp.$1); + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]ANI[ ](.*):[ ](.*)>/i)) { + var ani1 = String(RegExp.$1).trim().toLowerCase(); + var ani2 = String(RegExp.$2).trim(); + obj.meta['dragonbone_ani_' + ani1] = ani2; + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]REPLACE SPRITE>/i)) { + obj.meta.dragonbone_replace = true; + } else if (line.match(/<(?:DB|DRAGONBONE)[ ]KEEP SPRITE>/i)) { + obj.meta.dragonbone_replace = false; + // Grouped Notetags + } else if (line.match(/<(?:DB|DRAGONBONE)[ ](?:SETTINGS|SETTING)>/i)) { + evalMode = 'dragonbone settings'; + } else if (line.match(/<\/(?:DB|DRAGONBONE)[ ](?:SETTINGS|SETTING)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'dragonbone settings') { + if (line.match(/(?:BATTLER|SKIN|NAME):[ ]*(.*)/i)) { + obj.meta.dragonbone = String(RegExp.$1).trim(); + } else if (line.match(/SCALEX:[ ](.*)/i)) { + obj.meta.dragonbone_scalex = Number(RegExp.$1); + } else if (line.match(/SCALEY:[ ](.*)/i)) { + obj.meta.dragonbone_scaley = Number(RegExp.$1); + } else if (line.match(/ANI[ ](.*):[ ](.*)/i)) { + var ani1 = String(RegExp.$1).trim().toLowerCase(); + var ani2 = String(RegExp.$2).trim(); + obj.meta['dragonbone_ani_' + ani1] = ani2; + } else if (line.match(/WIDTH:[ ](.*)/i)) { + obj.meta.dragonbone_width = Number(RegExp.$1); + } else if (line.match(/HEIGHT:[ ](.*)/i)) { + obj.meta.dragonbone_height = Number(RegExp.$1); + } else if (line.match(/REPLACE SPRITE/i)) { + obj.meta.dragonbone_replace = true; + } else if (line.match(/KEEP SPRITE/i)) { + obj.meta.dragonbone_replace = false; + } + } + } + DataManager.processDragonBonesData(obj); + } +}; + +DataManager.processDragonBonesDefaults = function(obj) { + obj.meta.dragonbone = obj.meta.dragonbone || ''; + obj.meta.dragonbone_scalex = obj.meta.dragonbone_scalex || + dragonBonesIntegration.DefaultScaleX; + obj.meta.dragonbone_scaley = obj.meta.dragonbone_scaley || + dragonBonesIntegration.DefaultScaleY; + obj.meta.dragonbone_width = obj.meta.dragonbone_width || + dragonBonesIntegration.DefaultWidth; + obj.meta.dragonbone_height = obj.meta.dragonbone_height || + dragonBonesIntegration.DefaultHeight; + + obj.meta.dragonbone_replace = dragonBonesIntegration.ReplaceBattleSprite; +}; + +DataManager.processDragonBonesData = function(obj) { + if (!obj.meta.dragonbone) return; + if (!dragonBonesIntegration.AssetsArray.contains(obj.meta.dragonbone)) { + dragonBonesIntegration.AssetsArray.push(obj.meta.dragonbone); + } +}; + +//============================================================================= +// dragonBonesIntegration +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel +//============================================================================= + +//create a bunch of 'DragonBoy' armature to test performance +dragonBonesIntegration.Performance = function(iMax, jMax) { + if (iMax === undefined || iMax === null) { + iMax = 10; + } + if (!jMax === undefined || jMax === null) { + jMax = 10; + } + for (var i = 0; i < iMax; i++) { + for (var j = 0; j < jMax; j++) { + var myArmature = + dragonBones.PixiFactory.factory.buildArmatureDisplay("DragonBoy"); + myArmature.animation.play("walk"); + SceneManager._scene.addChild(myArmature); + myArmature.x = i*40 + 200; + myArmature.y = j*40 + 200; + myArmature.scale.x = 0.3; + myArmature.scale.y = 0.3; + } + } +}; + +//Load complete +dragonBonesIntegration.LoadComplete = function(loader, resources) { + var lastFileName = dragonBonesIntegration.lastFileName; + //console.log("DragonBone Load Complete: " + lastFileName); + + //load dragon bone armature into memory ready for use by + //dragonBonesIntegration.CreateArmature() + dragonBones.PixiFactory.factory.parseDragonBonesData(resources[lastFileName + + "dragonBonesData"].data); + dragonBones.PixiFactory.factory.parseTextureAtlasData(resources[lastFileName + + "textureDataA"].data, resources[lastFileName + "textureA"].texture); + + //load next dragonbone armature if not done + if (dragonBonesIntegration.bIsPreloading) { + dragonBonesIntegration.currentLoadIndex++; + dragonBonesIntegration.PreLoadAllArmatures(); + } + +}; + +//Load DragonBone data for use by dragonBonesIntegration.CreateArmature() +dragonBonesIntegration.Load = function(filename) { + if (filename) { + filename = filename.trim(); + dragonBonesIntegration.lastFileName = filename; + + PIXI.loader + .add(filename + "dragonBonesData", dragonBonesIntegration.AssetsPath + + filename + "_ske.json") + .add(filename + "textureDataA", dragonBonesIntegration.AssetsPath + + filename + "_tex.json") + .add(filename + "textureA", dragonBonesIntegration.AssetsPath + filename + + "_tex.png"); + PIXI.loader.once("complete", dragonBonesIntegration.LoadComplete, this, + filename); + PIXI.loader.load(); + } +}; + +//Preload all DragonBones data assigned in 'Preload Assets' parameter +//This is done when this plugin is loaded. +dragonBonesIntegration.PreLoadAllArmatures = function() { + //only load what is inside of dragonBoneAssetsArray + var index = dragonBonesIntegration.currentLoadIndex; + if (index < dragonBonesIntegration.AssetsArray.length) { + dragonBonesIntegration.bIsPreloading = true; + dragonBonesIntegration.Load(dragonBonesIntegration.AssetsArray[index]); + } else { + dragonBonesIntegration.bIsPreloading = false; + //SceneManager.run(Scene_Boot); + } +}; + +//Create DragonBones armature ready for display on Scene. +//DragonBones armature must be already loaded by dragonBonesIntegration.Load() +dragonBonesIntegration.CreateArmature = function(armatureName, x, y) { + var tempArmature = + dragonBones.PixiFactory.factory.buildArmatureDisplay(armatureName); + if (tempArmature) { + tempArmature.x = x; + tempArmature.y = y; + } + return tempArmature; +} + +//Play animation on actor/enemies. This also handle default and overwrite +//animation behavior +dragonBonesIntegration.PlayAnimationOnBattler = function(battler, aniName) { + //console.log("PlayAnimationOnBattler: " + battler.name() + " animation = + //" + aniName); + var armature; + var result = false; + + if (battler && aniName) { + if (battler.hasDragonBone === true) { + //select armature depending on enemy or actor + var index = battler.dragonboneIndex + if (battler.isActor()) { + armature = dragonBonesIntegration.ArmatureDatabaseActor[index]; + } else { + armature = dragonBonesIntegration.ArmatureDatabaseEnemy[index]; + } + + //check for overwrite animation from dragonbone_ani Note tag + var cmd = aniName.toLowerCase(); + var dragonBoneaniName = battler.dragonboneAnimation[cmd]; + if (dragonBoneaniName) { + //console.log("Overwriting Animation: " + cmd + " with " + + //dragonBoneaniName); + cmd = dragonBoneaniName; + } + + //play animation if armature is valid + if (armature) { + //if animation is found then play it + if (armature.animation.animationList.contains(cmd)) { + //if animation name match exactly then play + armature.animation.play(cmd); + result = true; + } else if (dragonBonesIntegration.supportUpperCaseNames === true) { + //search for animation name with case-insensitive. Higher memory + // cost + performance + //Prefer method is to have all dragonbones animation be lower case. + //console.log("supportUpperCaseNames: Search for animation with + //case-insensitive"); + for (var i = 0; i < armature.animation.animationList.length; i++) { + var element = armature.animation.animationList[i]; + if (cmd === element.toLowerCase()) { + //console.log("actionMotionTarget: Found lower case match for + //" + cmd + " with " + element); + armature.animation.play(element); + result = true; + break; + } + } + } else { + if (dragonBonesIntegration.consoleDebug) { + console.log("PlayAnimationOnBattler: " + battler.name() + + " Animation '" + aniName + "' not found."); + } + } + } + } + } + + return result; +}; + +//============================================================================= +// SceneManager +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel +//============================================================================= + +//(Must have for animation) Tick function required for dragonbone animations +dragonBonesIntegration.SceneManager_update = SceneManager.update; +SceneManager.update = function() { + dragonBonesIntegration.SceneManager_update.call(this); + + if (dragonBones.PixiFactory._clock) { + dragonBones.PixiFactory._clock.advanceTime(-1); + } +}; + +//============================================================================= +// Spriteset_Battle +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel +//============================================================================= + +// CREATE DRAGONBONES ARMATURE DURING SPRITESET_BATTLE +Spriteset_Battle.prototype.createEnemies = function() { + //enemies is an array of Game_Enemy + var enemies = $gameTroop.members(); + var sprites = []; + + for (var i = 0; i < enemies.length; i++) { + sprites[i] = new Sprite_Enemy(enemies[i]); + + var enemyId = enemies[i]._enemyId; + + var tempArmatureName = $dataEnemies[enemyId].meta.dragonbone; + var tempScaleX = $dataEnemies[enemyId].meta.dragonbone_scalex; + var tempScaleY = $dataEnemies[enemyId].meta.dragonbone_scaley; + var tempStartAnimation = $dataEnemies[enemyId].meta.dragonbone_ani_walk; + + if (tempArmatureName) { + //Delete last battle armature + if (dragonBonesIntegration.ArmatureDatabaseEnemy[i]) { + dragonBonesIntegration.ArmatureDatabaseEnemy[i].dispose(); + } + + //create new armature + dragonBonesIntegration.ArmatureDatabaseEnemy[i] = + dragonBonesIntegration.CreateArmature(tempArmatureName, 0, 0); + + if (dragonBonesIntegration.ArmatureDatabaseEnemy[i]) { + //tell whether a battler has a dragonbone armature + enemies[i].hasDragonBone = true; + + //Store index of armature for later use + //Can't store armature on enemy directly because of potential memory + //leak issue + enemies[i].dragonboneIndex = i; + enemies[i].dragonboneAnimation = []; + + //parse meta data into animation + for (var key in $dataEnemies[enemyId].meta) { + if ($dataEnemies[enemyId].meta.hasOwnProperty(key)) { + var animationIndex = key.split("dragonbone_ani_"); + //console.log("animationIndex = " + animationIndex); + if (animationIndex[1]) { + enemies[i].dragonboneAnimation[animationIndex[1]] = + $dataEnemies[enemyId].meta[key]; + } + } + } + + //set up auto transition to idle + //transition to idle when animation finish playing. + //This should stop most animation hitches. + enemies[i].AutoTransitionToIdle = function(event) { + if (dragonBonesIntegration.consoleDebug) { + console.log("Enemy AutoTransitionToIdle"); + } + switch (event.type) { + case dragonBones.EventObject.COMPLETE: + //if actor is not knocked out + if (this._states.contains(1) === false) { + //var idleAnimation = this.dragonboneAnimation['walk']; + //dragonBonesIntegration.ArmatureDatabaseEnemy + //[this.dragonboneIndex].animation.play(idleAnimation); + dragonBonesIntegration.PlayAnimationOnBattler(this, "walk"); + } else { + dragonBonesIntegration.Game_Enemy_prototype_performCollapse.call(this); + }; + break; + default: + //nothing + } + } + + //Automatically transition to idle when animation is complete by using + //Event + var enemyData = dragonBonesIntegration.ArmatureDatabaseEnemy[i]; + enemyData.addEvent(dragonBones.EventObject.COMPLETE, + enemies[i].AutoTransitionToIdle, + enemies[i]); + + //play default idle animation on creation + dragonBonesIntegration.PlayAnimationOnBattler(enemies[i], "walk"); + + //set custom scale + if (tempScaleX) { + dragonBonesIntegration.ArmatureDatabaseEnemy[i].scale.x = tempScaleX; + } + + //set custom scale + if (tempScaleY) { + dragonBonesIntegration.ArmatureDatabaseEnemy[i].scale.y = tempScaleY; + } + + sprites[i].addChild(dragonBonesIntegration.ArmatureDatabaseEnemy[i]); + sprites[i]._dragonboneSprite = dragonBonesIntegration.ArmatureDatabaseEnemy[i]; + } + + } else { + enemies[i].dragonboneIndex = null; + } + } + + sprites.sort(this.compareEnemySprite.bind(this)); + + for (var i = 0; i < sprites.length; i++) { + this._battleField.addChild(sprites[i]); + } + + this._enemySprites = sprites; +} + +Spriteset_Battle.prototype.createActors = function() { + this._actorSprites = []; + for (var i = 0; i < $gameParty.maxBattleMembers(); i++) { + this._actorSprites[i] = new Sprite_Actor(); + + var actorId = $gameParty._actors[i]; + if (actorId) { + //console.log($dataActors[actorId]); + var tempArmatureName = $dataActors[actorId].meta.dragonbone; + var tempScaleX = $dataActors[actorId].meta.dragonbone_scalex; + var tempScaleY = $dataActors[actorId].meta.dragonbone_scaley; + + if (tempArmatureName) { + //Delete last battle armature + if (dragonBonesIntegration.ArmatureDatabaseActor[i]) { + dragonBonesIntegration.ArmatureDatabaseActor[i].dispose(); + } + + //create new armature + dragonBonesIntegration.ArmatureDatabaseActor[i] = + dragonBonesIntegration.CreateArmature(tempArmatureName, 0, 0); + + //initialize dragon data inside the game actor in order to handle + //animation state changes + if (dragonBonesIntegration.ArmatureDatabaseActor[i]) { + //tell whether a battler has a dragonbone armature + $gameActors.actor(actorId).hasDragonBone = true; + $gameActors.actor(actorId).dragonboneIndex = i; + $gameActors.actor(actorId).dragonboneAnimation = []; + + //transition to idle when animation finish playing. This should stop + //most animation hitches. + $gameActors.actor(actorId).AutoTransitionToIdle = function(event) { + switch (event.type) { + case dragonBones.EventObject.COMPLETE: + //if actor is not knocked out + if (this._states.contains(1) === false) { + //var idleAnimation = this.dragonboneAnimation['walk']; + //dragonBonesIntegration.ArmatureDatabaseActor + //[this.dragonboneIndex].animation.play(idleAnimation); + this.lastMotionType = null; + dragonBonesIntegration.PlayAnimationOnBattler(this, "walk"); + } + break; + default: + //nothing + } + } + + //Automatically transition to idle when animation is complete by using + //Event + var actorData = dragonBonesIntegration.ArmatureDatabaseActor[i]; + actorData.addEvent(dragonBones.EventObject.COMPLETE, + $gameActors.actor(actorId).AutoTransitionToIdle, + $gameActors.actor(actorId)); + + //parse meta data into animation + for (var key in $dataActors[actorId].meta) { + if ($dataActors[actorId].meta.hasOwnProperty(key)) { + var animationIndex = key.split("dragonbone_ani_"); + if (animationIndex[1]) { + var actor = $gameActors.actor(actorId) + actor.dragonboneAnimation[animationIndex[1]] = + $dataActors[actorId].meta[key]; + } + //console.log('Key = ' + key + ' :: ' + animationIndex + " = " + + //$dataActors[actorId].meta[key]); + //console.log(key + " -> " + $dataActors[actorId].meta[key]); + } + } + + //set scale + if (tempScaleX) { + dragonBonesIntegration.ArmatureDatabaseActor[i].scale.x = + tempScaleX; + } + if (tempScaleY) { + dragonBonesIntegration.ArmatureDatabaseActor[i].scale.y = + tempScaleY; + } + var actorData = dragonBonesIntegration.ArmatureDatabaseActor[i]; + this._actorSprites[i].addChild(actorData); + this._actorSprites[i]._dragonboneSprite = actorData; + } + } + } + + this._battleField.addChild(this._actorSprites[i]); + } +}; + +//============================================================================= +// Sprite_Animation +// ---------------------------------------------------------------------------- +// Code provided by SwiftIllusion +//============================================================================= + +dragonBonesIntegration.Sprite_Animation_updatePosition = + Sprite_Animation.prototype.updatePosition; +Sprite_Animation.prototype.updatePosition = function() { + dragonBonesIntegration.Sprite_Animation_updatePosition.call(this); + this.updateDragonBonesPosition(); +}; + +Sprite_Animation.prototype.updateDragonBonesPosition = function() { + var position = this._animation.position; + if (position === 3) return; + var battler = this._target._battler; + if (!this._target) return; + if (!this._target._battler && (this._target._battler !== undefined)) return; + if (battler !== undefined) { + var data = battler.isActor() ? battler.actor() : battler.enemy(); + if (position === 0) { + this.y -= data.meta.dragonbone_height; + } else if (position === 1) { + this.y -= data.meta.dragonbone_height / 2; + } + var heightRate = battler.battler().getFloatHeight() + battler.battler().getJumpHeight(); + var height = heightRate * data.meta.dragonbone_height; + this.y -= height; + } else { + var battler = this._target.parent._battler; + if (battler && battler.hasDragonBone) { + var data = battler.isActor() ? battler.actor() : battler.enemy(); + if (position === 0) { + this.y -= data.meta.dragonbone_height; + } else if (position === 1) { + this.y -= data.meta.dragonbone_height / 2; + } + var heightRate = battler.battler().getFloatHeight() + battler.battler().getJumpHeight(); + var height = heightRate * data.meta.dragonbone_height; + this.y -= height; + } + } +}; + +//============================================================================= +// Sprite_Battler +// ---------------------------------------------------------------------------- +// Code provided by Yanfly +//============================================================================= + +dragonBonesIntegration.Sprite_Battler_update = Sprite_Battler.prototype.update; +Sprite_Battler.prototype.update = function() { + dragonBonesIntegration.Sprite_Battler_update.call(this); + if (this._battler) this.updateStateIconSpritePosition() +}; + +dragonBonesIntegration.Sprite_Battler_updatePosition = Sprite_Battler.prototype.updatePosition; +Sprite_Battler.prototype.updatePosition = function() { + dragonBonesIntegration.Sprite_Battler_updatePosition.call(this); + if (Imported.YEP_X_ActSeqPack2 && this._battler.hasDragonBone) { + var battler = this._battler.isActor() ? this._battler.actor() : this._battler.enemy(); + var heightRate = this.getFloatHeight() + this.getJumpHeight(); + var height = battler.meta.dragonbone_height * heightRate; + this.anchor.y += height; + this.y -= height; + } +}; + +Sprite_Battler.prototype.updateStateIconSpritePosition = function() { + if (this._dbStateSpritesUpdated !== undefined) return; + this._dbStateSpritesUpdated = true; + if (this._stateSprite) { + this.removeChild(this._stateSprite); + this.addChild(this._stateSprite); + } + if (this._stateIconSprite) { + this.removeChild(this._stateIconSprite); + this.addChild(this._stateIconSprite); + } +}; + +// Code provided by Swift Illusion +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n(t.__filters={},t.PIXI)}(this,function(t,n){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform float gamma;\nuniform float contrast;\nuniform float saturation;\nuniform float brightness;\nuniform float red;\nuniform float green;\nuniform float blue;\nuniform float alpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (c.a > 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / gamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);\n rgb.r *= red;\n rgb.g *= green;\n rgb.b *= blue;\n c.rgb = rgb * brightness;\n\n c.rgb *= c.a;\n }\n\n gl_FragColor = c * alpha;\n}\n",i=function(t){function n(n){t.call(this,r,e),Object.assign(this,{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},n)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.apply=function(t,n,r,e){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,t.applyFilter(this,n,r,e)},n}(n.Filter);t.DragonbonesFilter=i}),Object.assign(PIXI.filters,this.__filters); + +// Code provided by Irina and Swift Illusion +Sprite_Base.prototype.setBlendColor = function(color) { + if (this._battler) { + if (this._dragonboneSprite) this.setDragonbonesSpriteFlashColor(color); + } else if (this.parent._battler) { + if (this.parent._dragonboneSprite) this.parent.setDragonbonesSpriteFlashColor(color); + } +}; + +Sprite_Battler.prototype.setDragonbonesSpriteFlashColor = function(color) { + this.setupDragonbonesSpriteFlashFilter(); + this.updateDragonbonesSpriteFlashFilter(color); +}; + +Sprite_Battler.prototype.setupDragonbonesSpriteFlashFilter = function() { + var sprite = this._dragonboneSprite; + sprite._filters = sprite._filters || []; + if (sprite._flashFilter) return; + sprite._flashFilter = new PIXI.filters.DragonbonesFilter(); + sprite._filters.push(sprite._flashFilter); +}; + +// Code provided by Irina, numbers by Swift Illusion +Sprite_Battler.prototype.updateDragonbonesSpriteFlashFilter = function(color) { + var filter = this._dragonboneSprite._flashFilter; + if (!filter) return; + var baseline = 127.5; // 255 / 2 + var intensity = (Math.max(0, color[3]) / 255); + filter.red = 1 + intensity * ((color[0] / baseline) - 1); + filter.green = 1 + intensity * ((color[1] / baseline) - 1); + filter.blue = 1 + intensity * ((color[2] / baseline) - 1); + filter.contrast = 1- intensity; + filter.brightness = 1; +}; + +//============================================================================= +// Spriteset_Actor +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel +//============================================================================= + +// SPRITE REPLACEMENT: ENEMY, ACTOR, WEAPON +//Hide default weapon sprite for Actor when there is a DragonBones armature +//assigned +dragonBonesIntegration.Sprite_Actor_prototype_setupWeaponAni = + Sprite_Actor.prototype.setupWeaponAnimation; +Sprite_Actor.prototype.setupWeaponAnimation = function() { + if (this._actor.dragonboneIndex !== null && + this._actor.dragonboneIndex !== undefined) { + //do nothing for weapon animation + } else { + dragonBonesIntegration.Sprite_Actor_prototype_setupWeaponAni.call(this); + } +}; + +//============================================================================= +// YEP_X_ActSeqPack2 +// ---------------------------------------------------------------------------- +// Compatibility Update +//============================================================================= + +if (Imported.YEP_X_ActSeqPack2) { + +dragonBonesIntegration.BattleManager_actionMotionTarget = + BattleManager.actionMotionTarget; +BattleManager.actionMotionTarget = function(name, actionArgs) { + //console.log("BattleManager.actionMotionTarget: DB") + + if (name.toUpperCase() === 'WAIT') return this.actionMotionWait(actionArgs); + if (name.toUpperCase() === 'STANDBY') name = 'WAIT'; + + //get affected battlers + var movers = this.makeActionTargets(actionArgs[0]); + + //continue if 1 or more battler are targeted + if (movers.length < 1) return true; + + //console.log("DB actionMotionTarget: " + movers[0].name() + " = " + name); + + var cmd = name.toLowerCase(); + var motion = 'wait'; + + //check for weapons + if (actionArgs[1] && actionArgs[1].toUpperCase() === 'NO WEAPON') { + var showWeapon = false; + } else { + var showWeapon = true; + } + + if (['wait', 'chant', 'guard', 'evade', 'skill', 'spell', 'item', 'escape', + 'victory', 'dying', 'abnormal', 'sleep', 'dead'].contains(cmd)) { + motion = cmd; + } else if (['walk', 'move'].contains(cmd)) { + motion = 'walk'; + } else if (['damage', 'hit'].contains(cmd)) { + motion = 'damage'; + } else if (['attack'].contains(cmd)) { + movers.forEach(function(mover) { + //console.log("Action Motion: Performing Attack"); + if (mover.isActor()) { + mover.performAttack(); + } else { + dragonBonesIntegration.PlayAnimationOnBattler(mover, "attack"); + } + }); + return false; + } else if (['thrust', 'swing', 'missile'].contains(cmd)) { + motion = cmd; + movers.forEach(function(mover) { + if (mover.hasDragonBone === true) { + //play animation through force motion for actor, + //play animation directly for enemy + if (mover.isActor()) { + mover.forceMotion(motion); + } else { + dragonBonesIntegration.PlayAnimationOnBattler(mover, motion); + } + } else { + mover.forceMotion(motion); + if (mover.isActor() && showWeapon) { + var weapons = mover.weapons(); + var wtypeId = weapons[0] ? weapons[0].wtypeId : 0; + var attackMotion = $dataSystem.attackMotions[wtypeId]; + if (attackMotion && [0, 1, 2].contains(attackMotion.type)) { + mover.startWeaponAnimation(attackMotion.weaponImageId); + } + } + if (Imported.YEP_X_AnimatedSVEnemies) { + if (mover.isEnemy() && mover.hasSVBattler() && showWeapon) { + var attackMotion = $dataSystem.attackMotions[wtypeId]; + mover.startWeaponAnimation(mover.weaponImageId()); + } + } + } + }); + return false; + } + + //all other animations + movers.forEach(function(mover) { + if (mover.hasDragonBone === true) { + motion = cmd; + if (mover.isActor()) { + mover.forceMotion(motion); + } else { + dragonBonesIntegration.PlayAnimationOnBattler(mover, motion); + } + } else { + mover.forceMotion(motion); + } + }); + return false; +}; + +//play animation with the 'motion' command on actor +//this will overwrite the previous animation +var Sprite_Actor_prototype_forceMotion = Sprite_Actor.prototype.forceMotion; +Sprite_Actor.prototype.forceMotion = function(motionType) { + //play dragonbone animation if there is a valid armature + if (this._actor.hasDragonBone === true) { + //console.log("DB forceMotion: "); + if (dragonBonesIntegration.consoleDebug) { + console.log("DB forceMotion: Play actor motion = " + motionType); + } + dragonBonesIntegration.PlayAnimationOnBattler(this._actor, motionType); + //this.startMotion(motionType); + } else { + Sprite_Actor_prototype_forceMotion.call(this, motionType); + } +}; + +}; // Imported.YEP_X_ActSeqPack2 + +// REPLACE ACTOR/ENEMIES ANIMATIONS +//Replace the default 18 sprite animations with DragonBones animation if +//assigned in the Note section +//if the previous animation is the same as the new one, then start motion will +//let the previous animation complete +dragonBonesIntegration.Sprite_Actor_prototype_startMotion = + Sprite_Actor.prototype.startMotion; +Sprite_Actor.prototype.startMotion = function(motionType) { + //only play dragonbone animation if dragonboneIndex variable is valid + if (this._actor.hasDragonBone === true) { + if (this._actor.lastMotionType !== motionType) { + dragonBonesIntegration.PlayAnimationOnBattler(this._actor, motionType); + this._actor.lastMotionType = motionType; + } + } else { + //console.log("Vanilla startMotion: " + this._actor._name + " motion = " + + //motionType); + dragonBonesIntegration.Sprite_Actor_prototype_startMotion.call(this, + motionType); + } +}; + +//============================================================================= +// Game_Enemy +// ---------------------------------------------------------------------------- +// Code provided by TheGreenKel +//============================================================================= + +//Replace Enemy default attack animation +Game_Enemy.prototype.performActionStart = function(action) { + //Game_Battler.prototype.performActionStart.call(this, action); + this.requestEffect('whiten'); + if (dragonBonesIntegration.consoleDebug) { + console.log("DB performActionStart: " + this.battlerName() + " type = " + + action.type); + } + //console.log("DragonBoneIndex = " + this.dragonboneIndex); + + var result = false; + if (this.hasDragonBone === true && action.isAttack()) { + result = dragonBonesIntegration.PlayAnimationOnBattler(this, "swing"); + } + if (result === false) { + Game_Battler.prototype.performActionStart.call(this, action); + } +}; + +//Replace Enemy default take damage animation +Game_Enemy.prototype.performDamage = function() { + Game_Battler.prototype.performDamage.call(this); + SoundManager.playEnemyDamage(); + + var result = false; + if (this.hasDragonBone === true) { + result = dragonBonesIntegration.PlayAnimationOnBattler(this, "damage"); + } + + //if dragonbones animation fail to play then run default + if (result === false) { + this.requestEffect('blink'); + } +}; + +//Replace Enemy default death animation +dragonBonesIntegration.Game_Enemy_prototype_performCollapse = + Game_Enemy.prototype.performCollapse; +Game_Enemy.prototype.performCollapse = function() { + //console.log("DB collapse: Game_Enemy"); + var result = false; + if (this.hasDragonBone === true) { + //console.log("DB collapse: skeletal animation"); + result = dragonBonesIntegration.PlayAnimationOnBattler(this, "dead"); + SoundManager.playBossCollapse1(); + } + + if (result === false) { + dragonBonesIntegration.Game_Enemy_prototype_performCollapse.call(this); + } +}; + +//============================================================================= +// Game_Battler +// ---------------------------------------------------------------------------- +// Code provided by Yanfly +//============================================================================= + +Game_Battler.prototype.isReplacedByDragonBonesBattler = function() { + if (!$gameParty.inBattle()) return false; + if (this.isActor()) { + var data = this.actor(); + } else if (this.isEnemy()) { + var data = this.enemy(); + } else { + return false; + } + if (data.meta.dragonbone_replace === false) return false; + return this.hasDragonBone; +}; + +if (Imported.YEP_BattleEngineCore) { + +dragonBonesIntegration.Game_Battler_spriteWidth = + Game_Battler.prototype.spriteWidth; +Game_Battler.prototype.spriteWidth = function() { + if (this.isReplacedByDragonBonesBattler()) { + if (this.isActor()) { + return this.actor().meta.dragonbone_width; + } else if (this.isEnemy()) { + return this.enemy().meta.dragonbone_width; + } else { + return 100; + } + } + return dragonBonesIntegration.Game_Battler_spriteWidth.call(this); +}; + +dragonBonesIntegration.Game_Battler_spriteHeight = + Game_Battler.prototype.spriteHeight; +Game_Battler.prototype.spriteHeight = function() { + if (this.isReplacedByDragonBonesBattler()) { + if (this.isActor()) { + return this.actor().meta.dragonbone_height; + } else if (this.isEnemy()) { + return this.enemy().meta.dragonbone_height; + } else { + return 100; + } + } + return dragonBonesIntegration.Game_Battler_spriteHeight.call(this); +}; + +}; // Imported.YEP_BattleEngineCore + +//============================================================================= +// Game_Actor +// ---------------------------------------------------------------------------- +// Code provided by Yanfly +//============================================================================= + +dragonBonesIntegration.Game_Actor_battlerName = + Game_Actor.prototype.battlerName; +Game_Actor.prototype.battlerName = function() { + if (this.isReplacedByDragonBonesBattler()) return ''; + return dragonBonesIntegration.Game_Actor_battlerName.call(this); +}; + +dragonBonesIntegration.Game_Actor_spriteWidth = + Game_Actor.prototype.spriteWidth; +Game_Actor.prototype.spriteWidth = function() { + if (this.isReplacedByDragonBonesBattler()) { + if (this.isActor()) { + return this.actor().meta.dragonbone_width; + } else if (this.isEnemy()) { + return this.enemy().meta.dragonbone_width; + } else { + return 100; + } + } + return dragonBonesIntegration.Game_Actor_spriteWidth.call(this); +}; + +dragonBonesIntegration.Game_Actor_spriteHeight = + Game_Actor.prototype.spriteHeight; +Game_Actor.prototype.spriteHeight = function() { + if (this.isReplacedByDragonBonesBattler()) { + if (this.isActor()) { + return this.actor().meta.dragonbone_height; + } else if (this.isEnemy()) { + return this.enemy().meta.dragonbone_height; + } else { + return 100; + } + } + return dragonBonesIntegration.Game_Actor_spriteHeight.call(this); +}; + +//============================================================================= +// Game_Enemy +// ---------------------------------------------------------------------------- +// Code provided by Yanfly +//============================================================================= + +dragonBonesIntegration.Game_Enemy_battlerName = + Game_Enemy.prototype.battlerName; +Game_Enemy.prototype.battlerName = function() { + if (this.isReplacedByDragonBonesBattler()) return ''; + return dragonBonesIntegration.Game_Enemy_battlerName.call(this); +}; + +//============================================================================= +// YEP_X_AnimatedSVEnemies Compatibility +// ---------------------------------------------------------------------------- +// Code provided by Yanfly +//============================================================================= + +if (Imported.YEP_X_AnimatedSVEnemies) { + +dragonBonesIntegration.Game_Enemy_hasSVBattler = + Game_Enemy.prototype.hasSVBattler; +Game_Enemy.prototype.hasSVBattler = function() { + if (this._hasSvBattler === undefined) { + this._hasSvBattler = + dragonBonesIntegration.Game_Enemy_hasSVBattler.call(this) || + this.hasDragonBone; + } + return this._hasSvBattler; +}; + +dragonBonesIntegration.Game_Enemy_spriteScaleX = + Game_Enemy.prototype.spriteScaleX; +Game_Enemy.prototype.spriteScaleX = function() { + if (this.hasDragonBone && this.hasSVBattler()) { + return this.enemy().spriteScaleX; + } else { + return dragonBonesIntegration.Game_Enemy_spriteScaleX.call(this); + } +}; + +}; // YEP_X_AnimatedSVEnemies + +//============================================================================= +// End of Main Functions +//============================================================================= +} else { + +var text = ''; +text += 'You are getting this error because you are trying to run DragonBones '; +text += 'Integration while your project files are lower than version 1.4.0.\n'; +text += '\nPlease visit this thread for instructions on how to update your '; +text += 'project files to 1.4.0 or higher: \n\n'; +text += 'https://forums.rpgmakerweb.com/index.php?threads/'; +text += 'rpg-maker-mv-1-5-0-update.79677/'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.1.0') +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_AnimateTilesOption.js b/js/plugins/YEP_AnimateTilesOption.js new file mode 100644 index 0000000..451f0cb --- /dev/null +++ b/js/plugins/YEP_AnimateTilesOption.js @@ -0,0 +1,308 @@ +//============================================================================= +// Yanfly Engine Plugins - Animate Tiles Option +// YEP_AnimateTilesOption.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_StaticTilesOption = true; + +var Yanfly = Yanfly || {}; +Yanfly.AniTile = Yanfly.AniTile || {}; +Yanfly.AniTile.version = 1.03; + +//============================================================================= + /*: + * @plugindesc v1.03 Because some computers and devices lag with animated + * tiles on the map, an option is added to disable them. + * @author Yanfly Engine Plugins + * + * @param Command Name + * @desc The name that appears in the options menu. + * @default Animated Tiles + * + * @param Default Setting + * @type combo + * @option true + * @option false + * @option auto + * @desc Default setting for this option. + * ON - true OFF - false AUTO - auto + * @default auto + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * Some players may experience lag when walking near animated tiles. This is + * due to the fact that animated tiles constantly draw, delete, and redraw the + * tiles every few frames. Unfortunately, due to Pixi2's drawing method, there + * exists some memory leaks when this kind of drawing occurs. On mobile devices + * or weak computers with little memory to spare, this can potentially cause + * some games to crash. The option to enable/disable animated tiles is now in + * the options menu for players to toggle. + * + * For those who decide to make the default settings for the plugin to 'auto', + * any player who is playing on mobile or browser will default to having the + * setting off while local players will have the setting default to on. + * + * ============================================================================ + * Options Core Settings - Adding the New Options + * ============================================================================ + * + * If you are using YEP_OptionsCore.js, you can add a new Option using this + * plugin. Here's the following code/parameter settings you can use with it. + * + * --------- + * Settings: + * --------- + * + * Name: + * \i[302]Animated Tiles + * + * Help Description: + * Turns animated tiles ON or OFF. + * + * Symbol: + * animateTiles + * + * Show/Hide: + * show = Imported.YEP_StaticTilesOption; + * + * Enable: + * enabled = true; + * + * Ext: + * ext = 0; + * + * ---------- + * Functions: + * ---------- + * + * Make Option Code: + * this.addCommand(name, symbol, enabled, ext); + * + * Draw Option Code: + * var rect = this.itemRectForText(index); + * var statusWidth = this.statusWidth(); + * var titleWidth = rect.width - statusWidth; + * this.resetTextColor(); + * this.changePaintOpacity(this.isCommandEnabled(index)); + * this.drawOptionsName(index); + * this.drawOptionsOnOff(index); + * + * Process OK Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, !value); + * + * Cursor Right Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, true); + * + * Cursor Left Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, false); + * + * Default Config Code: + * // Empty. Provided by this plugin. + * + * Save Config Code: + * // Empty. Provided by this plugin. + * + * Load Config Code: + * // Empty. Provided by this plugin. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.03: + * - Compatibility update with YEP_OptionsCore.js. + * + * Version 1.02: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.01: + * - Updated for RPG Maker MV version 1.3.0. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_AnimateTilesOption'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.STOCommandName = String(Yanfly.Parameters['Command Name']); +Yanfly.Param.STODefault = String(Yanfly.Parameters['Default Setting']); + +//============================================================================= +// ConfigManager +//============================================================================= + +Yanfly.getDefaultAnimateTilesOption = function() { + if (Yanfly.Param.STODefault.match(/true/i)) { + return true; + } else if (Yanfly.Param.STODefault.match(/false/i)) { + return false; + } else { + return Utils.isNwjs(); + } +}; + +ConfigManager.animateTiles = Yanfly.getDefaultAnimateTilesOption(); + +Yanfly.AniTile.ConfigManager_makeData = ConfigManager.makeData; +ConfigManager.makeData = function() { + var config = Yanfly.AniTile.ConfigManager_makeData.call(this); + config.animateTiles = this.animateTiles; + return config; +}; + +Yanfly.AniTile.ConfigManager_applyData = ConfigManager.applyData; +ConfigManager.applyData = function(config) { + Yanfly.AniTile.ConfigManager_applyData.call(this, config); + this.animateTiles = this.readConfigAnimateTiles(config, 'animateTiles'); +}; + +ConfigManager.readConfigAnimateTiles = function(config, name) { + var value = config[name]; + if (value !== undefined) { + return value; + } else { + return Yanfly.getDefaultAnimateTilesOption(); + } +}; + +//============================================================================= +// Tilemap +//============================================================================= + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.0') { + +Yanfly.AniTile.Tilemap_update = Tilemap.prototype.update; +Tilemap.prototype.update = function() { + Yanfly.AniTile.Tilemap_update.call(this); + if (!ConfigManager.animateTiles) { + this.animationFrame = 0; + }; +}; + +} else { + +Tilemap.prototype._paintTiles = function(startX, startY, x, y) { + var tableEdgeVirtualId = 10000; + var mx = startX + x; + var my = startY + y; + var dx = (mx * this._tileWidth).mod(this._layerWidth); + var dy = (my * this._tileHeight).mod(this._layerHeight); + var lx = dx / this._tileWidth; + var ly = dy / this._tileHeight; + var tileId0 = this._readMapData(mx, my, 0); + var tileId1 = this._readMapData(mx, my, 1); + var tileId2 = this._readMapData(mx, my, 2); + var tileId3 = this._readMapData(mx, my, 3); + var shadowBits = this._readMapData(mx, my, 4); + var upperTileId1 = this._readMapData(mx, my - 1, 1); + var lowerTiles = []; + var upperTiles = []; + + if (this._isHigherTile(tileId0)) { + upperTiles.push(tileId0); + } else { + lowerTiles.push(tileId0); + } + if (this._isHigherTile(tileId1)) { + upperTiles.push(tileId1); + } else { + lowerTiles.push(tileId1); + } + + lowerTiles.push(-shadowBits); + + if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) { + if (!Tilemap.isShadowingTile(tileId0)) { + lowerTiles.push(tableEdgeVirtualId + upperTileId1); + } + } + + if (this._isOverpassPosition(mx, my)) { + upperTiles.push(tileId2); + upperTiles.push(tileId3); + } else { + if (this._isHigherTile(tileId2)) { + upperTiles.push(tileId2); + } else { + lowerTiles.push(tileId2); + } + if (this._isHigherTile(tileId3)) { + upperTiles.push(tileId3); + } else { + lowerTiles.push(tileId3); + } + } + + if (ConfigManager.animateTiles) { + var count = 1000 + this.animationCount - my; + var frameUpdated = (count % 30 === 0); + this._animationFrame = Math.floor(count / 30); + } else { + var frameUpdated = false; + this._animationFrame = 0; + } + + var lastLowerTiles = this._readLastTiles(0, lx, ly); + if (!lowerTiles.equals(lastLowerTiles) || + (Tilemap.isTileA1(tileId0) && frameUpdated)) { + this._lowerBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight); + for (var i = 0; i < lowerTiles.length; i++) { + var lowerTileId = lowerTiles[i]; + if (lowerTileId < 0) { + this._drawShadow(this._lowerBitmap, shadowBits, dx, dy); + } else if (lowerTileId >= tableEdgeVirtualId) { + this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy); + } else { + this._drawTile(this._lowerBitmap, lowerTileId, dx, dy); + } + } + this._writeLastTiles(0, lx, ly, lowerTiles); + } + + var lastUpperTiles = this._readLastTiles(1, lx, ly); + if (!upperTiles.equals(lastUpperTiles)) { + this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight); + for (var j = 0; j < upperTiles.length; j++) { + this._drawTile(this._upperBitmap, upperTiles[j], dx, dy); + } + this._writeLastTiles(1, lx, ly, upperTiles); + } +}; + +} //(Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.0') + +//============================================================================= +// Window_Options +//============================================================================= + +Yanfly.AniTile.Window_Options_addGeneralOptions = + Window_Options.prototype.addGeneralOptions; +Window_Options.prototype.addGeneralOptions = function() { + Yanfly.AniTile.Window_Options_addGeneralOptions.call(this); + if (!Imported.YEP_OptionsCore) { + this.addCommand(Yanfly.Param.STOCommandName, 'animateTiles'); + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_AutoPassiveStates.js b/js/plugins/YEP_AutoPassiveStates.js new file mode 100644 index 0000000..d05aa74 --- /dev/null +++ b/js/plugins/YEP_AutoPassiveStates.js @@ -0,0 +1,686 @@ +//============================================================================= +// Yanfly Engine Plugins - Auto Passive States +// YEP_AutoPassiveStates.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_AutoPassiveStates = true; + +var Yanfly = Yanfly || {}; +Yanfly.APS = Yanfly.APS || {}; +Yanfly.APS.version = 1.17; + +//============================================================================= + /*: + * @plugindesc v1.17 This plugin allows for some states to function as + * passives for actors, enemies, skills, and equips. + * @author Yanfly Engine Plugins + * + * @param ---Basic--- + * @default + * + * @param Actor Passives + * @parent ---Basic--- + * @desc These states will always appear on actors as passives. + * Place a space in between each state ID. + * @default 0 + * + * @param Enemy Passives + * @parent ---Basic--- + * @desc These states will always appear on enemies as passives. + * Place a space in between each state ID. + * @default 0 + * + * @param Global Passives + * @parent ---Basic--- + * @desc These states will always appear on all battlers as passives. + * Place a space in between each state ID. + * @default 0 + * + * @param ---List--- + * @default ...Requires RPG Maker MV 1.5.0+... + * + * @param Actor Passives List + * @parent ---List--- + * @type state[] + * @desc These states will always appear on actors as passives. + * Use with RPG Maker MV 1.5.0+. + * @default [] + * + * @param Enemy Passives List + * @parent ---List--- + * @type state[] + * @desc These states will always appear on enemies as passives. + * Use with RPG Maker MV 1.5.0+. + * @default [] + * + * @param Global Passives List + * @parent ---List--- + * @type state[] + * @desc These states will always appear on all battlers as passives. + * Use with RPG Maker MV 1.5.0+. + * @default [] + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * Passive states are states that are automatically active. You can think of + * them as an extension of traits but with more flexibility. They will always + * be there as long as the actor or enemy has auto passive state notetags. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * For those who would like to allocate passive states to your battlers, use + * the notetags below: + * + * Actor, Class, Skills, Weapon, Armor, Enemy Notetags: + * + * + * This will allow the actor or enemy to have state x as a passive state. + * If placed inside a weapon or armor notebox, the user will have that + * passive state. + * + * + * This will add the states x through y (in a sequence) for the actor or + * enemy to have as a passive state. If placed inside a weapon or armor + * notebox, the user will have that passive state. + * + * For those who don't want their passive states to always be on, you can use + * the following notetags to introduce conditions for your passive states. All + * conditions must be fulfilled in order for the passive state to appear. + * + * State Notetags: + * + * + * + * + * If the user's HP or MP is above/below x% of the MaxHP or MaxMP, this + * condition will be met for the passive state to appear. + * + * + * + * Replace 'stat' with 'HP', 'MP', 'TP', 'MAXHP', 'MAXMP', 'ATK', 'DEF', + * 'MAT', 'MDF', 'AGI', 'LUK'. If the above stat is above/below x, then the + * condition is met for the passive state to appear. + * + * + * + * If switch x is either ON/OFF, then the condition is met for the passive + * state to appear. + * + * + * + * Replace x with the variable you wish to check to see if it's above/below + * y, then the condition is met for the passive state to appear. + * + * ============================================================================ + * Lunatic Mode - Conditional Passives + * ============================================================================ + * + * For those who understand a bit of JavaScript and would like for their + * passive states to appear under specific conditions, you can use this notetag + * to accomplish conditional factors. + * + * State Notetags: + * + * if (user.hp / user.mhp <= 0.25) { + * condition = true; + * } else { + * condition = false; + * } + * + * This enables you to input conditions to be met in order for the passive + * state to appear. If the 'condition' variable returns true, the passive + * state will appear. If the 'condition' returns false, it won't appear. If + * condition is not defined, it will return true and the passive state will + * appear on the battler. + * * Note: All non-custom passive conditions must be met before this one can + * be fulfilled and allow the custom condition to appear. + * * Note: If you decide to use a condition that requires the actor to have a + * particular state, it cannot be a passive state to prevent infinite loops. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.17: + * - Optimization update. There should be less lag spikes if there are more + * passive conditions present on a battler. + * + * Version 1.16: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.15: + * - Bug fixed that made global passives not apply to actors. + * + * Version 1.14: + * - Updated for RPG Maker MV version 1.5.0. + * - Added parameters: Actor Passives List, Enemy Passives List, and + * Global Passives List + * + * Version 1.13: + * - Lunatic Mode fail safes added. + * + * Version 1.12: + * - Implemented to now affect passive state ID's + * added by Equip Battle Skills. + * + * Version 1.11: + * - Added 'Global Passives' that encompass both actors and enemies. + * + * Version 1.10: + * - Added compatibility functionality for Equip Battle Skills to add the + * equipped passive states during battle test. + * + * Version 1.09: + * - Added 'Actor Passives' and 'Enemy Passives' plugin parameters. This will + * cause all actors and enemies respectively to be affected by the listed + * states as passives. + * + * Version 1.08: + * - Fixed conditional checks to make sure all states are being checked + * properly without conflict with other conditional states. + * + * Version 1.07: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.06: + * - Added a mass member refresh whenever $gamePlayer is refreshed. + * + * Version 1.05a: + * - Added Lunatic Mode - notetag for states. + * - Fixed a bug that would cause infinite loops. + * + * Version 1.04: + * - Added a lot of passive condition notetags for states. + * --- + * --- + * --- + * --- + * + * Version 1.03: + * - Added refreshing whenever a new skill is learned to update passives. + * + * Version 1.02: + * - Optimized passive state calculations to reduce lag. + * + * Version 1.01: + * - Fixed a bug with having multiple passive states of the same ID. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.SetupParameters = function() { + Yanfly.Parameters = PluginManager.parameters('YEP_AutoPassiveStates'); + Yanfly.Param = Yanfly.Param || {}; + Yanfly.Param.APSActorPas = String(Yanfly.Parameters['Actor Passives']); + Yanfly.Param.APSActorPas = Yanfly.Param.APSActorPas.split(' '); + for (var i = 0; i < Yanfly.Param.APSActorPas.length; ++i) { + Yanfly.Param.APSActorPas[i] = parseInt(Yanfly.Param.APSActorPas[i]); + Yanfly.Param.APSActorPas[i] = Yanfly.Param.APSActorPas[i] || 0; + } + var data = JSON.parse(Yanfly.Parameters['Actor Passives List']); + for (var i = 0; i < data.length; ++i) { + var stateId = parseInt(data[i]); + if (stateId <= 0) continue; + if (Yanfly.Param.APSActorPas.contains(stateId)) continue; + Yanfly.Param.APSActorPas.push(stateId); + } + Yanfly.Param.APSEnemyPas = String(Yanfly.Parameters['Enemy Passives']); + Yanfly.Param.APSEnemyPas = Yanfly.Param.APSEnemyPas.split(' '); + for (var i = 0; i < Yanfly.Param.APSEnemyPas.length; ++i) { + Yanfly.Param.APSEnemyPas[i] = parseInt(Yanfly.Param.APSEnemyPas[i]); + Yanfly.Param.APSEnemyPas[i] = Yanfly.Param.APSEnemyPas[i] || 0; + } + var data = JSON.parse(Yanfly.Parameters['Enemy Passives List']); + for (var i = 0; i < data.length; ++i) { + var stateId = parseInt(data[i]); + if (stateId <= 0) continue; + if (Yanfly.Param.APSEnemyPas.contains(stateId)) continue; + Yanfly.Param.APSEnemyPas.push(stateId); + } + Yanfly.Param.APSGlobalPas = String(Yanfly.Parameters['Global Passives']); + Yanfly.Param.APSGlobalPas = Yanfly.Param.APSGlobalPas.split(' '); + for (var i = 0; i < Yanfly.Param.APSGlobalPas.length; ++i) { + id = parseInt(Yanfly.Param.APSGlobalPas[i]); + Yanfly.Param.APSActorPas.push(id); + Yanfly.Param.APSEnemyPas.push(id); + } + var data = JSON.parse(Yanfly.Parameters['Global Passives List']); + for (var i = 0; i < data.length; ++i) { + var stateId = parseInt(data[i]); + if (stateId <= 0) continue; + if (!Yanfly.Param.APSActorPas.contains(stateId)) { + Yanfly.Param.APSActorPas.push(stateId); + } + if (!Yanfly.Param.APSEnemyPas.contains(stateId)) { + Yanfly.Param.APSEnemyPas.push(stateId); + } + } +}; +Yanfly.SetupParameters(); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.APS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.APS.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_AutoPassiveStates) { + this.processAPSNotetags1($dataActors, Yanfly.Param.APSActorPas); + this.processAPSNotetags1($dataClasses); + this.processAPSNotetags1($dataEnemies, Yanfly.Param.APSEnemyPas); + this.processAPSNotetags1($dataSkills); + this.processAPSNotetags1($dataWeapons); + this.processAPSNotetags1($dataArmors); + this.processAPSNotetags2($dataStates); + Yanfly._loaded_YEP_AutoPassiveStates = true; + } + return true; +}; + +DataManager.processAPSNotetags1 = function(group, inheritArray) { + var note1 = /<(?:PASSIVE STATE):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note2 = /<(?:PASSIVE STATE):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.passiveStates = []; + if (inheritArray) { + obj.passiveStates = obj.passiveStates.concat(inheritArray); + } + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + obj.passiveStates = obj.passiveStates.concat(array); + } else if (line.match(note2)) { + var range = Yanfly.Util.getRange(parseInt(RegExp.$1), + parseInt(RegExp.$2)); + obj.passiveStates = obj.passiveStates.concat(range); + } + } + } +}; + +DataManager.processAPSNotetags2 = function(group) { + var note1a = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:ABOVE)[ ](\d+)([%%])>/i; + var note1b = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:BELOW)[ ](\d+)([%%])>/i; + var note2a = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:ABOVE)[ ](\d+)>/i; + var note2b = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:BELOW)[ ](\d+)>/i; + var note3a = /<(?:PASSIVE CONDITION):[ ]SWITCH[ ](\d+)[ ](.*)>/i; + var notez1 = /<(?:CUSTOM PASSIVE CONDITION)>/i; + var notez2 = /<\/(?:CUSTOM PASSIVE CONDITION)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.passiveCondition = ''; + obj.passiveConditionEval = ''; + var evalMode = 'none'; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1a)) { + var rate = parseFloat(RegExp.$2) * 0.01; + var param = this.getPassiveConditionParamRate(String(RegExp.$1)); + var pass = 'if (' + param + ' <= ' + rate + ') condition = false;'; + obj.passiveCondition = obj.passiveCondition + pass + '\n'; + } else if (line.match(note1b)) { + var rate = parseFloat(RegExp.$2) * 0.01; + var param = this.getPassiveConditionParamRate(String(RegExp.$1)); + var pass = 'if (' + param + ' >= ' + rate + ') condition = false;'; + obj.passiveCondition = obj.passiveCondition + pass + '\n'; + } else if (line.match(note2a)) { + var rate = parseInt(RegExp.$2); + var param = this.getPassiveConditionParam(String(RegExp.$1)); + var pass = 'if (' + param + ' <= ' + rate + ') condition = false;'; + obj.passiveCondition = obj.passiveCondition + pass + '\n'; + } else if (line.match(note2b)) { + var rate = parseInt(RegExp.$2); + var param = this.getPassiveConditionParam(String(RegExp.$1)); + var pass = 'if (' + param + ' >= ' + rate + ') condition = false;'; + obj.passiveCondition = obj.passiveCondition + pass + '\n'; + } else if (line.match(note3a)) { + var id = parseInt(RegExp.$1); + var value = String(RegExp.$2).toUpperCase(); + var pass = '' + if (['ON', 'TRUE', 'ENABLE', 'ENABLED'].contains(value)) { + pass = 'if (!$gameSwitches.value(' + id + ')) condition = false;' + } + if (['OFF', 'FALSE', 'DISABLE', 'DISABLED'].contains(value)) { + pass = 'if ($gameSwitches.value(' + id + ')) condition = false;' + } + if (pass === '') continue; + obj.passiveCondition = obj.passiveCondition + pass + '\n'; + } else if (line.match(notez1)) { + evalMode = 'custom passive condition'; + } else if (line.match(notez2)) { + evalMode = 'none'; + } else if (evalMode === 'custom passive condition') { + obj.passiveConditionEval = obj.passiveConditionEval + line + '\n'; + } + } + + obj.passiveCondition = new Function('condition','a','user','subject','b', + 'target','s','v', obj.passiveCondition + '\nreturn condition;'); + obj.passiveConditionEval = new Function('condition','a','user','subject', + 'b','target','s','v', obj.passiveConditionEval + '\nreturn condition;'); + } +}; + +DataManager.getPassiveConditionParam = function(string) { + string = string.toUpperCase(); + var text = 'user.'; + if (['HP'].contains(string)) text += 'hp'; + if (['MP', 'SP'].contains(string)) text += 'mp'; + if (['TP'].contains(string)) text += 'tp'; + if (['ATK'].contains(string)) text += 'param(2)'; + if (['DEF'].contains(string)) text += 'param(3)'; + if (['MAT', 'INT'].contains(string)) text += 'param(4)'; + if (['MDF', 'RES'].contains(string)) text += 'param(5)'; + if (['AGI'].contains(string)) text += 'param(6)'; + if (['LUK'].contains(string)) text += 'param(7)'; + if (['MAX HP', 'MAXHP'].contains(string)) text += 'mhp'; + if (['MAX MP', 'MAX SP', 'MAXMP', 'MAXSP'].contains(string)) text += 'mmp'; + if (string.match(/VARIABLE[ ](\d+)/i)) { + text = '$gameVariables.value(' + parseInt(RegExp.$1) + ')'; + } + return text; +}; + +DataManager.getPassiveConditionParamRate = function(string) { + string = string.toUpperCase(); + var text = '0'; + if (['HP'].contains(string)) return 'user.hpRate()'; + if (['MP'].contains(string)) return 'user.mpRate()'; + return text; +}; + +//============================================================================= +// Game_BattlerBase +//============================================================================= + +Yanfly.APS.Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh; +Game_BattlerBase.prototype.refresh = function() { + this._passiveStatesRaw = undefined; + Yanfly.APS.Game_BattlerBase_refresh.call(this); +}; + +Yanfly.APS.Game_BattlerBase_states = Game_BattlerBase.prototype.states; +Game_BattlerBase.prototype.states = function() { + var array = Yanfly.APS.Game_BattlerBase_states.call(this); + array = array.concat(this.passiveStates()); + this.sortPassiveStates(array); + return array; +}; + +Yanfly.APS.Game_BattlerBase_isStateAffected = + Game_BattlerBase.prototype.isStateAffected; +Game_BattlerBase.prototype.isStateAffected = function(stateId) { + if (this.isPassiveStateAffected(stateId)) return true; + return Yanfly.APS.Game_BattlerBase_isStateAffected.call(this, stateId); +}; + +Game_BattlerBase.prototype.passiveStates = function() { + var array = []; + var raw = this.passiveStatesRaw(); + for (var i = 0; i < raw.length; ++i) { + var state = $dataStates[raw[i]]; + if (state && array.contains(state)) continue; + array.push(state); + } + return array; +}; + +Game_BattlerBase.prototype.passiveStatesRaw = function() { + var array = []; + return array.filter(Yanfly.Util.onlyUnique); +}; + +Game_BattlerBase.prototype.getPassiveStateData = function(obj) { + if (!obj) return []; + if (!obj.passiveStates) return []; + var array = []; + for (var i = 0; i < obj.passiveStates.length; ++i) { + var stateId = obj.passiveStates[i]; + if (!this.meetPassiveStateCondition(stateId)) continue; + array.push(stateId); + } + var added = this.addEquipBattleTestSkillPassives(obj); + if (added.length > 0) { + for (var i = 0; i < added.length; ++i) { + var stateId = added[i]; + if (!this.meetPassiveStateCondition(stateId)) continue; + array.push(stateId); + } + } + return array; +}; + +Game_BattlerBase.prototype.addEquipBattleTestSkillPassives = function(obj) { + if (!Imported.YEP_EquipBattleSkills) return []; + if (!DataManager.isBattleTest()) return []; + if (!DataManager.isSkill(obj)) return []; + return obj.equipStates; +}; + +Game_BattlerBase.prototype.meetPassiveStateCondition = function(stateId) { + this._checkPassiveStateCondition = this._checkPassiveStateCondition || []; + if (this._checkPassiveStateCondition.contains(stateId)) return false; + var state = $dataStates[stateId]; + if (!state) return false; + if (state.passiveCondition !== '') { + if (!this.passiveStateConditions(state)) return false; + } + if (state.passiveConditionEval === '') return true; + return this.passiveStateConditionEval(state); +}; + +Game_BattlerBase.prototype.passiveStateConditions = function(state) { + this._checkPassiveStateCondition = this._checkPassiveStateCondition || []; + this._checkPassiveStateCondition.push(state.id); + var condition = true; + var a = this; + var user = this; + var subject = this; + var b = this; + var target = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = state.passiveCondition; + try { + condition = state.passiveCondition.call(this, condition, a, user, subject, + b, target, s, v); + } catch (e) { + Yanfly.Util.displayError(e, code, 'PASSIVE STATE CUSTOM CONDITION ERROR'); + } + var index = this._checkPassiveStateCondition.indexOf(state.id); + this._checkPassiveStateCondition.splice(index, 1); + return condition; +}; + +Game_BattlerBase.prototype.passiveStateConditionEval = function(state) { + this._checkPassiveStateCondition = this._checkPassiveStateCondition || []; + this._checkPassiveStateCondition.push(state.id); + var condition = true; + var a = this; + var user = this; + var subject = this; + var b = this; + var target = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = state.passiveConditionEval; + try { + condition = state.passiveConditionEval.call(this, condition, a, user, + subject, b, target, s, v); + } catch (e) { + Yanfly.Util.displayError(e, code, 'PASSIVE STATE CUSTOM CONDITION ERROR'); + } + var index = this._checkPassiveStateCondition.indexOf(state.id); + this._checkPassiveStateCondition.splice(index, 1); + return condition; +}; + +Game_BattlerBase.prototype.sortPassiveStates = function(array) { + array.sort(function(a, b) { + var p1 = a.priority; + var p2 = b.priority; + if (p1 !== p2) return p2 - p1; + return a - b; + }); +}; + +Game_BattlerBase.prototype.isPassiveStateAffected = function(stateId) { + return this.passiveStatesRaw().contains(stateId); +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Yanfly.APS.Game_Battler_isStateAddable = Game_Battler.prototype.isStateAddable; +Game_Battler.prototype.isStateAddable = function(stateId) { + if (this.isPassiveStateAffected(stateId)) return false; + return Yanfly.APS.Game_Battler_isStateAddable.call(this, stateId); +}; + +Yanfly.APS.Game_Battler_removeState = Game_Battler.prototype.removeState; +Game_Battler.prototype.removeState = function(stateId) { + if (this.isPassiveStateAffected(stateId)) return; + Yanfly.APS.Game_Battler_removeState.call(this, stateId); +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.passiveStatesRaw = function() { + if (this._passiveStatesRaw !== undefined) return this._passiveStatesRaw; + var array = Game_BattlerBase.prototype.passiveStatesRaw.call(this); + array = array.concat(this.getPassiveStateData(this.actor())); + array = array.concat(this.getPassiveStateData(this.currentClass())); + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + array = array.concat(this.getPassiveStateData(equip)); + } + for (var i = 0; i < this._skills.length; ++i) { + var skill = $dataSkills[this._skills[i]]; + array = array.concat(this.getPassiveStateData(skill)); + } + this._passiveStatesRaw = array.filter(Yanfly.Util.onlyUnique) + return this._passiveStatesRaw; +}; + +Yanfly.APS.Game_Actor_learnSkill = Game_Actor.prototype.learnSkill; +Game_Actor.prototype.learnSkill = function(skillId) { + Yanfly.APS.Game_Actor_learnSkill.call(this, skillId); + this._passiveStatesRaw = undefined; +}; + +Yanfly.APS.Game_Actor_forgetSkill = Game_Actor.prototype.forgetSkill; +Game_Actor.prototype.forgetSkill = function(skillId) { + Yanfly.APS.Game_Actor_forgetSkill.call(this, skillId); + this._passiveStatesRaw = undefined; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.passiveStatesRaw = function() { + if (this._passiveStatesRaw !== undefined) return this._passiveStatesRaw; + var array = Game_BattlerBase.prototype.passiveStatesRaw.call(this); + array = array.concat(this.getPassiveStateData(this.enemy())); + for (var i = 0; i < this.skills().length; ++i) { + var skill = this.skills()[i]; + array = array.concat(this.getPassiveStateData(skill)); + } + this._passiveStatesRaw = array.filter(Yanfly.Util.onlyUnique) + return this._passiveStatesRaw; +}; + +if (!Game_Enemy.prototype.skills) { + Game_Enemy.prototype.skills = function() { + var skills = [] + for (var i = 0; i < this.enemy().actions.length; ++i) { + var skill = $dataSkills[this.enemy().actions[i].skillId]; + if (skill) skills.push(skill); + } + return skills; + } +}; + +//============================================================================= +// Game_Unit +//============================================================================= + +Game_Unit.prototype.refreshMembers = function() { + var group = this.allMembers(); + var length = group.length; + for (var i = 0; i < length; ++i) { + var member = group[i]; + if (member) member.refresh(); + } +}; + +Game_Unit.prototype.allMembers = function() { + return this.members(); +}; + +//============================================================================= +// Game_Player +//============================================================================= + +Yanfly.APS.Game_Player_refresh = Game_Player.prototype.refresh; +Game_Player.prototype.refresh = function() { + $gameParty.refreshMembers(); + Yanfly.APS.Game_Player_refresh.call(this); +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +Yanfly.Util.getRange = function(n, m) { + var result = []; + for (var i = n; i <= m; ++i) result.push(i); + return result; +}; + +Yanfly.Util.onlyUnique = function(value, index, self) { + return self.indexOf(value) === index; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_BaseTroopEvents.js b/js/plugins/YEP_BaseTroopEvents.js new file mode 100644 index 0000000..743be15 --- /dev/null +++ b/js/plugins/YEP_BaseTroopEvents.js @@ -0,0 +1,93 @@ +//============================================================================= +// Yanfly Engine Plugins - Base Troop Events +// YEP_BaseTroopEvents.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_BaseTroopEvents = true; + +var Yanfly = Yanfly || {}; +Yanfly.BTE = Yanfly.BTE || {}; +Yanfly.BTE.version = 1.01 + +//============================================================================= +/*: + * @plugindesc v1.01 Enabling this plugin will cause all troops to have + * events occur in every fight. + * @author Yanfly Engine Plugins + * + * @param Base Troop ID + * @type troop + * @desc Change this value to the Troop ID you want all of the recurring + * troop events to draw from. + * @default 1 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * For all the eventers out there who love to customize their battles through + * custom event pages, you can now save yourself some time by drawing all the + * event pages from a base troop event to occur in every fight. All of the + * events will be present in every single battle. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.01: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_BaseTroopEvents'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.BaseTroopID = Number(Yanfly.Parameters['Base Troop ID']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.BTE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.BTE.DataManager_isDatabaseLoaded.call(this)) return false; + this.processBTEPages(); + return true; +}; + +DataManager.processBTEPages = function() { + for (var n = 1; n < $dataTroops.length; n++) { + var base_troop = $dataTroops[Yanfly.Param.BaseTroopID]; + var troop = $dataTroops[n]; + if (n !== Yanfly.Param.BaseTroopID && Yanfly.Param.BaseTroopID > 0) { + if (troop._baseTroopEventsMade) continue; + Yanfly.Util.extend(troop.pages, base_troop.pages); + troop._baseTroopEventsMade = true; + } + } +}; + +//============================================================================= +// New Function +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.extend = function (mainArray, otherArray) { + otherArray.forEach(function(i) { + mainArray.push(i) + }, this); +} + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_BattleAICore.js b/js/plugins/YEP_BattleAICore.js new file mode 100644 index 0000000..0176851 --- /dev/null +++ b/js/plugins/YEP_BattleAICore.js @@ -0,0 +1,1690 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle Artificial Intelligence Core +// YEP_BattleAICore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_BattleAICore = true; + +var Yanfly = Yanfly || {}; +Yanfly.CoreAI = Yanfly.CoreAI || {}; +Yanfly.CoreAI.version = 1.15; + +//============================================================================= + /*: + * @plugindesc v1.15 This plugin allows you to structure battle A.I. + * patterns with more control. + * @author Yanfly Engine Plugins + * + * @param Dynamic Actions + * @type boolean + * @on YES + * @off NO + * @desc If enabled, enemy actions are decided on the spot instead + * of at the start of turn. NO - false YES - true + * @default true + * + * @param Dynamic Turn Count + * @type boolean + * @on YES + * @off NO + * @desc Decide if the turn count dynamic is counted for earlier or later. + * true - Current Turn + 1 false - Current Turn + * @default false + * + * @param Element Testing + * @type boolean + * @on YES + * @off NO + * @desc If enabled, enemies will test actors on their elements by + * setting them to match first. NO - false YES - true + * @default true + * + * @param Default AI Level + * @type number + * @min 0 + * @max 100 + * @desc This is the default AI level of all enemies. + * Level 0: Very Random Level 100: Very Strict + * @default 80 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * RPG Maker MV's default enemy AI is a bit lackluster even if you managed to + * have it based completely on the rates and switches. There is no way to + * control the way the enemy chooses targets by default, nor are the conditions + * imposed by the default editor enough to satisfy the majority of checks. This + * plugin enables you to set a priority list of conditions, actions, and the + * targets selected for the enemy to go through before making a decision on how + * to participate in battle. + * + * These conditions contain all of the default editor's conditions plus more, + * such as determining the parameter values of a target, whether or not a state + * exists on a target, the target's elemental weakness (or resistances), and + * more before deciding an action. Furthermore, you can set an AI level for the + * enemies to make them more consistent in the way they go about fighting your + * players or more random in the way the enemies treat the priority list, too. + * + * ============================================================================ + * Parameters + * ============================================================================ + * + * Dynamic Actions + * By default, the enemy's actions are determined at the start of the turn. + * While this works in its own right, enabling Dynamic Actions allow enemies + * to make a decision when the enemy's turn comes up instead. This prompts + * enemies to be more flexible and to appear more intelligent in battle, thus, + * giving your players a bit more of a challenge. + * + * Element Testing + * If this is disabled, enemies will automatically know the elemental weakness, + * resistance, etc. about all actors. If enabled, enemies will need to test out + * the skills on various actors first before making a decision. Until the enemy + * learns about the actor's elemental rates, the enemy is always willing to try + * using the skill on the target actor. However, if the skill itself does not + * possess an element, then no information will be registered. All elemental + * data is reset at the start of each battle for all enemy parties. + * + * Default AI Level + * Not all enemies are intelligent. In fact, some of them are dumb or random. + * Setting the AI Level of a foe at a low number means the foe is more random + * while a higher AI Level foe is more consistent. How the AI Level works is, + * a random number will be checked from 0 to 99. If that enemy's AI Level is + * higher than that number, that action is checked to see if the condition is + * fulfilled or not. If the AI Level is lower than that number, the condition + * is automatically deemed false and continues on to the next action. The check + * is ran each time a new action is checked upon. This random factor is only + * applied to lists and do not apply to default actions. + * + * ============================================================================ + * Enemy AI Level + * ============================================================================ + * + * Enemy AI levels do not determine how difficult they are. Instead, they + * determine how strictly they will follow the lists. An AI Level + * of 80 means it has an 80% chance of following the prioritized action on the + * AI Priority list before moving onto the next one where there will be another + * 80% chance and so on. If the AI level is lower, the chance is lower, making + * the AI to be more random. + * + * Enemy Notetag: + * + * Sets the enemy's AI level to x. The lower x, the more random the enemy. + * The higher for x, the more strict the enemy is about following the AI + * Priority list found in its notebox, too. + * + * ============================================================================ + * Enemy AI Priority + * ============================================================================ + * + * If an enemy has an AI Priority list, the enemy will go down that list from + * top to bottom (giving the actions at the top more priority than the ones at + * the bottom) looking for any actions whose conditions are fulfilled. If that + * condition is fulfilled, then that action will be the action the enemy will + * partake in. + * + * To set up a Priority List for the enemy, you must place inside the enemy's + * notebox notetags that match the following format: + * + * + * condition: SKILL x, target or condition: skill name, target + * condition: SKILL x, target condition: skill name, target + * + * + * Any number of conditions and skills can be placed in between the two + * tags. You can choose to use skill ID's or the skill names. + * However, if you use the skill names, keep in mind that it is not case + * sensitive and if any skills in your database have matching names, the skill + * with the larger skill ID will be the action used. + * + * ============================================================================ + * Conditions + * ============================================================================ + * + * The following is a list of ways you can format your conditions for the enemy + * to choose the right skill. In addition to deciding whether or not the skill + * will be used, the condition also selects the enemy target. The following + * list will tell you how the conditions are met and what targets will be + * selected for battle. + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * ALWAYS + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This condition will always be fulfilled. The valid target group is all + * targets within scope. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Always: Skill 10, Lowest HP% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * ELEMENT X case + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This allows you to match the element rate of element X (use either a number + * or the name of the element in place of 'X') to see whether or not the + * conditions for the action are fulfilled. Replace 'case' with 'Neutral' for + * normal element rate (under 110% and above 90%), 'Weakness' for anything + * above 100% element rate, 'Resistant' for below 100% element rate, 'Null' for + * 0% element rate, and 'Absorb' for below 0% element rate. Valid targets will + * be those with the matching element rates. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Element Fire Weakness: Fireball, Lowest HP% + * Element Water Resistant: Water Cancel, Highest MAT + * Element 4 Null: Earthquake, Lowest MDF + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * EVAL eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This allows you to use any kind of code to check and fulfill a condition. + * This condition uses all alive members of the skill's scope as valid targets. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Eval user.name() === 'Bat A': Skill 10, Highest HP% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * group ALIVE MEMBERS eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Replace 'group' with either 'party' for the player's party or 'troop' for + * the enemy party. This runs the number of party alive members or troop alive + * members in a check to see if the conditions can be fulfilled. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Party Alive Members > 2: Skill 10, Lowest HP% + * Troop Alive Members <= 4: Skill 11, Highest HP% + * Troop Alive Members === $gameVariables.value(3): Skill 12, Random + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * group DEAD MEMBERS eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Replace 'group' with either 'party' for the player's party or 'troop' for + * the enemy party. This runs the number of party dead members or troop dead + * members in a check to see if the conditions can be fulfilled. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Party Dead Members > 2: Undead, Highest ATK + * Troop Dead Members <= 4: Life, Highest ATK + * Troop Dead Members === $gameVariables.value(3): Skill 12, Random + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * stat PARAM eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Replace 'stat' with either 'atk', 'def', 'mat', 'mdf', 'agi', 'luk', + * 'maxhp', 'maxmp', 'hp', 'mp', 'hp%', 'mp%', or 'level' to run it in a + * condition check again to see if the action gets passed. The group that it + * checks will be based on the skill's scope. If the skill targets foes, then + * all foes will take a check to see if they fulfill the conditions. Likewise + * for party members if the skill is for allies. The valid targets will be + * those who pass the condition check. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: HP% param <= 50%: Heal, Lowest HP% + * MP param > 90: Mana Drain, Highest MP + * ATK param > user.atk: Power Break, Highest ATK + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * type PARTY LEVEL eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Replace 'type' with either 'highest', 'lowest', or 'average' to get the + * respective party level for the skill's scope. This will reference the entire + * party's level. If this condition is fulfilled, all targets would become + * valid targets. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Highest Party Level > 10: Skill 10, Lowest MP% + * Lowest Party Level < 12: Skill 11, Lowest HP% + * Average Party Level > 15: Skill 12, Highest HP% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * RANDOM x% + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the condition based on a random x percent chance. This + * condition allows all possible targets to be valid for targeting. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Random 50%: Skill 10, Lowest HP% + * Random 75%: Skill 11, Highest HP% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * STATE === state x + * STATE === state name + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will detect if the target scope has state x (or state name if you use + * that instead). If the target does, that target is added into the pool of + * valid targets. Any targets not affected by the state will be ignored. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: State === State 5: DeBlind, Highest ATK + * State === Knockout: Life, Random + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * STATE !== state x + * STATE !== state name + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will detect if the target scope does not have state x (or state name if + * you use that instead). If the target doesn't, that target is added into the + * pool of valid targets. Any targets affected by the state will be ignored. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: State !== State 12: Haste, Random + * State !== Courage: Cowardice, Highest ATK + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * SWITCH X case + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Replace 'x' with the ID of the switch you wish to check. Replace 'case' with + * either 'on' or 'off' (you may also use 'true' or 'false'). If the switch + * matches the case, the condition is fulfilled and all skill targets become + * valid targets. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Switch 5 On: Skill 10, Lowest HP% + * Switch 6 Off: Skill 11, Highest HP% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * TURN eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the condition based on the turn count to be fulfilled by an + * eval statement. This condition allows all possible targets to be valid for + * targeting. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Turn > 3: Skill 10, Lowest hp% + * Turn === 4: Skill 11, Highest hp% + * Turn <= $gameVariables.value(2): Skill 12, Random + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * USER stat PARAM eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Replace 'stat' with either 'atk', 'def', 'mat', 'mdf', 'agi', 'luk', + * 'maxhp', 'maxmp', 'hp', 'mp', 'hp%', 'mp%', or 'level' to run it in a + * condition check again to see if the action gets passed. If the user's param + * matches the conditions, the check is fulfilled. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: User HP% param <= 50%: Heal, Lowest HP% + * User MP param > 90: Mana Drain, Highest MP + * User ATK param > user.atk: Power Break, Highest ATK + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * VARIABLE X eval + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will call forth the value of variable 'x' to partake in an eval + * comparison to see if the condition is fulfilled. If it is, all skill targets + * become valid targets. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Variable 3 > 10: Skill 10, Lowest HP% + * Variable 5 <= 100: Skill 11, Highest HP% + * Variable 2 === user.atk: Skill 12 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * ============================================================================ + * Multiple Conditions + * ============================================================================ + * + * As of the version 1.11 update, the Battle A.I. Core is now able to support + * multiple conditions. Setting up multiple conditions is relatively simple to + * do and still follows the 'condition: SKILL x, target' format. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * To add multiple conditions, simply insert a +++ between each condition like + * the following examples: + * + * Switch 1 on +++ Switch 2 on: Fire, Lowest HP% + * Turn 3 > 1 +++ Variable 5 <= 100 +++ Switch 3 on: Ice, Lowest HP% + * Random 50% +++ Highest Party Level > 50: Thunder, Highest HP% + * + * In the above examples, all the conditions must be met in order for the + * selected skills to be considered for use. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * For conditions that have strict targeting groups, the targeting group will + * end up becoming the combination of all of the strict targeting groups. For + * example: + * + * STATE === Blind +++ STATE === Fear: Dark, Lowest HP% + * + * In this example, the enemy will only use the 'Dark' skill on a target that + * is both affected by 'Blind' and 'Fear'. If there are multiple targets, then + * the target with the lowest HP% will become the target the enemy will cast + * the 'Dark' on. + * + * STATE !== Blind +++ ATK param >= 150: Darkness, Highest ATK + * + * In the above example, the enemy will use the 'Darkness' skill against any + * target that isn't blinded and has an ATK parameter of at least 150. If there + * are multiple targets, then the enemy will first cast 'Darkness' on the + * target with the highest ATK before casting it on a target with a lower ATK. + * + * ============================================================================ + * Targeting + * ============================================================================ + * + * Targeting is optional but can be done via a small change to the condition. + * All you have to do is add a ',' after the skill to indicate which target in + * the valid target group you would like to target. For example: + * + * Random 50%: Fire, Highest HP% + * + * The condition to be met is the 50% random chance, but if it is fulfilled, + * the target selected will be the member on the targeting scope's team with + * the highest HP percentage. When that happens, the 'Fire' skill will be used + * upon that target. + * + * If no target is specified, a random target will be selected amongst the + * group of valid targets. Otherwise, refer to the following list: + * + * ---------------------------------------------------------------------------- + * <> Selects a random member of the valid target group. + * First Selects first member of the valid target group. + * User Selects the user itself. + * Highest MaxHP Selects highest MaxHP valid target. + * Highest HP Selects highest HP valid target. + * Highest HP% Selects highest HP% valid target. *Note1 + * Highest MaxMP Selects highest MaxMP valid target. + * Highest MP Selects highest MP valid target. + * Highest MP% Selects highest MP% valid target. *Note1 + * Highest MaxTP Selects highest MaxTP valid target. + * Highest TP Selects highest TP valid target. + * Highest TP% Selects highest TP% valid target. *Note1 + * Highest ATK Selects highest ATK valid target. + * Highest DEF Selects highest DEF valid target. + * Highest MAT Selects highest MAT valid target. + * Highest MDF Selects highest MDF valid target. + * Highest AGI Selects highest AGI valid target. + * Highest LUK Selects highest LUK valid target. + * Highest Level Selects highest Level valid target. *Note2 + * Lowest MaxHP Selects lowest MaxHP valid target. + * Lowest HP Selects lowest HP valid target. + * Lowest HP% Selects lowest HP% valid target. *Note1 + * Lowest MaxMP Selects lowest MaxMP valid target. + * Lowest MP Selects lowest MP valid target. + * Lowest MP% Selects lowest MP% valid target. *Note1 + * Lowest MaxTP Selects lowest MaxMP valid target. + * Lowest TP Selects lowest MP valid target. + * Lowest TP% Selects lowest MP% valid target. *Note1 + * Lowest ATK Selects lowest ATK valid target. + * Lowest DEF Selects lowest DEF valid target. + * Lowest MAT Selects lowest MAT valid target. + * Lowest MDF Selects lowest MDF valid target. + * Lowest AGI Selects lowest AGI valid target. + * Lowest LUK Selects lowest LUK valid target. + * Lowest Level Selects lowest Level valid target. *Note2 + * + * Note1: This is calculated by dividing the current HP with the MaxHP or the + * current MP with the MaxMP. + * + * Note2: If this is used on an enemy without a proper enemy level plugin + * installed, this will return the player party's highest level. + * + * ---------------------------------------------------------------------------- + * + * ============================================================================ + * Special Notes + * ============================================================================ + * + * If you are using YEP_Taunt.js, enemies will automatically not factor in + * taunts by default. For that matter, targets can be protected by taunts + * effects, which can effectively shut down an enemy's AI performance. However, + * if you want some enemies to consider the taunt effects of an opponent, + * place this notetag inside of the enemy's notebox: + * + * + * + * This will make it that when an enemy makes a decision, it will make a right + * decision while thinking of the taunted enemies, too. You can use this for + * smarter enemies while keep this notetag disabled for less intelligent foes. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.15: + * - Fixed a bug that caused some TP conditions to not work properly. + * + * Version 1.14: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.13: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.12: + * - Added 'Dynamic Turn Count' plugin parameter for those who wish to push the + * turn count further by 1 turn in order to adjust for Dynamic Actions. Code + * provided by Talonos. + * + * Version 1.11: + * - Adding the ability to support multiple conditions. Please Read the + * 'Multiple Conditions' section in the help file for more details. + * + * Version 1.10: + * - Lunatic Mode fail safes added. + * + * Version 1.09: + * - Added 'user' to the list of valid skill targets. + * - Added 'USER stat PARAM eval' to valid conditions. + * + * Version 1.08: + * - Neutral elemental resistance is now considered to be above 90% and under + * 110% for a better range of activation. + * - Optimization update. + * + * Version 1.07: + * - Fixed a compatibility bug that caused certain conditions to bypass taunts. + * + * Version 1.06: + * - Fixed a bug that caused 'Highest TP' and 'Lowest TP' target searches to + * crash the game. + * + * Version 1.05: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.04a: + * - Fixed a bug that would cause a crash with the None scope for skills. + * - Switched over a function to operate in another for better optimization. + * + * Version 1.03: + * - Fixed a bug that returned the wrong MP% rate. + * + * Version 1.02: + * - Fixed a bug that targeted the highest parameter enemy instead of lowest. + * + * Version 1.01: + * - Added 'MaxTP' and 'TP' to targets. + * - Compatibility update with Battle Engine Core v1.19+. Turn settings are now + * based 'AI Self Turns' if the enabled. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_BattleAICore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.CoreAIDynamic = String(Yanfly.Parameters['Dynamic Actions']); +Yanfly.Param.CoreAIDynamic = eval(Yanfly.Param.CoreAIDynamic); +Yanfly.Param.CoreAIDynTurnCnt = String(Yanfly.Parameters['Dynamic Turn Count']); +Yanfly.Param.CoreAIDynTurnCnt = eval(Yanfly.Param.CoreAIDynTurnCnt); +Yanfly.Param.CoreAIElementTest = String(Yanfly.Parameters['Element Testing']); +Yanfly.Param.CoreAIElementTest = eval(Yanfly.Param.CoreAIElementTest); +Yanfly.Param.CoreAIDefaultLevel = Number(Yanfly.Parameters['Default AI Level']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.CoreAI.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.CoreAI.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_BattleAICore) { + this.processCoreAINotetags1($dataEnemies); + this.processCoreAINotetags2($dataSkills); + this.processCoreAINotetags3($dataStates); + this.processCoreAINotetags4($dataSystem); + Yanfly._loaded_YEP_BattleAICore = true; + } + return true; +}; + +DataManager.processCoreAINotetags1 = function(group) { + var note1 = /<(?:AI PRIORITY)>/i; + var note2 = /<\/(?:AI PRIORITY)>/i; + var note3 = /<(?:AI CONSIDER TAUNT|ai considers taunts)>/i; + var note4 = /<(?:AI LEVEL):[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.aiPattern = []; + var aiPatternFlag = false; + obj.aiConsiderTaunt = false; + obj.aiLevel = Yanfly.Param.CoreAIDefaultLevel * 0.01; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + aiPatternFlag = true; + } else if (line.match(note2)) { + aiPatternFlag = false; + } else if (aiPatternFlag) { + obj.aiPattern.push(line); + } else if (line.match(note3)) { + obj.aiConsiderTaunt = true; + } else if (line.match(note4)) { + obj.aiLevel = parseFloat(RegExp.$1 * 0.01); + } + } + } +}; + +DataManager.processCoreAINotetags2 = function(group) { + if (Yanfly.SkillIdRef) return; + Yanfly.SkillIdRef = {}; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + if (obj.name.length <= 0) continue; + Yanfly.SkillIdRef[obj.name.toUpperCase()] = n; + } +}; + +DataManager.processCoreAINotetags3 = function(group) { + if (Yanfly.StateIdRef) return; + Yanfly.StateIdRef = {}; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + if (obj.name.length <= 0) continue; + Yanfly.StateIdRef[obj.name.toUpperCase()] = n; + } +}; + +DataManager.processCoreAINotetags4 = function(group) { + if (Yanfly.ElementIdRef) return; + Yanfly.ElementIdRef = {}; + for (var i = 0; i < group.elements.length; ++i) { + var obj = group.elements[i].toUpperCase(); + if (typeof obj === 'string' && obj !== '') Yanfly.ElementIdRef[obj] = i; + } +}; + +//============================================================================= +// BattleManager +//============================================================================= + +if (Yanfly.Param.CoreAIDynamic) { + Yanfly.CoreAI.BattleManager_getNextSubject = + BattleManager.getNextSubject; + BattleManager.getNextSubject = function() { + //this.updateAIPatterns(); + var battler = Yanfly.CoreAI.BattleManager_getNextSubject.call(this); + if (battler && battler.isEnemy()) battler.setAIPattern(); + return battler; + }; +}; + +BattleManager.updateAIPatterns = function() { + $gameTroop.updateAIPatterns() +}; + +Yanfly.CoreAI.BattleManager_isInputting = BattleManager.isInputting; +BattleManager.isInputting = function() { + if ($gameTemp._tauntMode) return false; + return Yanfly.CoreAI.BattleManager_isInputting.call(this); +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Object.defineProperty(Game_Battler.prototype, 'level', { + get: function() { + return this.getLevel(); + }, + configurable: true +}); + +if (!Game_Battler.prototype.getLevel) { + Game_Battler.prototype.getLevel = function() { + return $gameTroop.highestLevel(); + }; +}; + +Game_Battler.prototype.setAIPattern = function() { + Game_Battler.prototype.makeActions.call(this); +}; + +Game_Battler.prototype.aiConsiderTaunt = function() { + return false; +}; + +Game_Battler.prototype.hasSkill = function(skillId) { + return this.skills().contains($dataSkills[skillId]); +}; + +Game_Battler.prototype.hasState = function(stateId) { + return this.states().contains($dataStates[stateId]); +}; + +Game_Battler.prototype.notState = function(stateId) { + return !this.isStateAffected(stateId); +}; + +Game_Battler.prototype.aiLevel = function() { + return Yanfly.Param.CoreAIDefaultLevel * 0.01; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.skills = function() { + var skills = [] + for (var i = 0; i < this.enemy().actions.length; ++i) { + var skill = $dataSkills[this.enemy().actions[i].skillId] + if (skill) skills.push(skill); + } + skills = AIManager.getPatternSkills(skills, this.enemy().aiPattern); + return skills; +}; + +Yanfly.CoreAI.Game_Enemy_makeActions = Game_Enemy.prototype.makeActions; +Game_Enemy.prototype.makeActions = function() { + if (this.enemy().aiPattern.length > 0) { + this.setAIPattern(); + this.setActionState('waiting'); + } else { + Yanfly.CoreAI.Game_Enemy_makeActions.call(this); + } +}; + +Game_Enemy.prototype.aiConsiderTaunt = function() { + if (!Imported.YEP_Taunt) return false; + return this.enemy().aiConsiderTaunt; +}; + +Game_Enemy.prototype.setAIPattern = function() { + Game_Battler.prototype.setAIPattern.call(this); + if (this.numActions() <= 0) return; + AIManager.setBattler(this); + for (var i = 0; i < this.enemy().aiPattern.length; ++i) { + if (Math.random() > this.aiLevel()) continue; + var line = this.enemy().aiPattern[i]; + if (AIManager.isDecidedActionAI(line)) return; + } + Yanfly.CoreAI.Game_Enemy_makeActions.call(this); +}; + +Game_Enemy.prototype.aiLevel = function() { + return this.enemy().aiLevel; +}; + +//============================================================================= +// Game_Unit +//============================================================================= + +Game_Unit.prototype.highestLevel = function() { + return $gameParty.highestLevel(); +}; + +Game_Unit.prototype.lowestLevel = function() { + return $gameParty.lowestLevel(); +}; + +Game_Unit.prototype.averageLevel = function() { + return $gameParty.averageLevel(); +}; + +Yanfly.CoreAI.Game_Unit_onBattleStart = Game_Unit.prototype.onBattleStart; +Game_Unit.prototype.onBattleStart = function() { + Yanfly.CoreAI.Game_Unit_onBattleStart.call(this); +}; + +Game_Unit.prototype.aiElementRateKnown = function(target, elementId) { + return true; +}; + +Game_Unit.prototype.aiRegisterElementRate = function(target, elementId) { +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Game_Party.prototype.lowestLevel = function() { + return Math.min.apply(null, this.members().map(function(actor) { + return actor.level; + })); +}; + +Game_Party.prototype.averageLevel = function() { + var level = 0; + for (var i = 0; i < this.members().length; ++i) { + var member = this.members()[i]; + if (member) level += member.level; + } + level /= this.members().length; + return level; +}; + +//============================================================================= +// Game_Troop +//============================================================================= + +Game_Troop.prototype.updateAIPatterns = function() { + for (var i = 0; i < this.aliveMembers().length; ++i) { + var member = this.aliveMembers()[i]; + if (member) member.setAIPattern(); + } +}; + +Yanfly.CoreAI.Game_Troop_setup = Game_Troop.prototype.setup; +Game_Troop.prototype.setup = function(troopId) { + Yanfly.CoreAI.Game_Troop_setup.call(this, troopId); + this._aiKnownElementRates = {}; +}; + +Game_Troop.prototype.aiElementRateKnown = function(target, elementId) { + if (target.isEnemy()) return true; + if (!Yanfly.Param.CoreAIElementTest) return true; + var index = target.index(); + if (this._aiKnownElementRates[index] === undefined) { + this._aiKnownElementRates[index] = []; + } + return this._aiKnownElementRates[index].contains(elementId); +}; + +Game_Troop.prototype.aiRegisterElementRate = function(target, elementId) { + if (!Yanfly.Param.CoreAIElementTest) return; + var index = target.index(); + if (this._aiKnownElementRates[index] === undefined) { + this._aiKnownElementRates[index] = []; + } + if (!this._aiKnownElementRates[index].contains(elementId)) { + this._aiKnownElementRates[index].push(elementId); + } +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.CoreAI.Game_Action_apply = Game_Action.prototype.apply; +Game_Action.prototype.apply = function(target) { + Yanfly.CoreAI.Game_Action_apply.call(this, target); + this.aiRegisterElementRate(target); +}; + +Game_Action.prototype.aiRegisterElementRate = function(target) { + if (this.item().damage.elementId < 0) return; + var elementId = this.item().damage.elementId; + if (this.subject().isActor()) { + $gameParty.aiRegisterElementRate(target, elementId); + } else { + $gameTroop.aiRegisterElementRate(target, elementId); + } +}; + +//============================================================================= +// AIManager +//============================================================================= + +function AIManager() { + throw new Error('This is a static class'); +} + +AIManager.setBattler = function(battler) { + this._battler = battler; + this._action = battler.action(0); +}; + +AIManager.battler = function() { + return this._battler; +}; + +AIManager.action = function() { + return this._action; +}; + +AIManager.isDecidedActionAI = function(line) { + if (line.match(/[ ]*(.*):[ ](?:SKILL)[ ](\d+),[ ](.*)/i)) { + this._origCondition = String(RegExp.$1); + var condition = String(RegExp.$1); + this._aiSkillId = parseInt(RegExp.$2); + this._aiTarget = String(RegExp.$3); + } else if (line.match(/[ ]*(.*):[ ](?:SKILL)[ ](\d+)/i)) { + this._origCondition = String(RegExp.$1); + var condition = String(RegExp.$1); + this._aiSkillId = parseInt(RegExp.$2); + this._aiTarget = 'RANDOM'; + } else if (line.match(/[ ]*(.*):[ ](.*),[ ](.*)/i)) { + this._origCondition = String(RegExp.$1); + var condition = String(RegExp.$1); + this._aiSkillId = Yanfly.SkillIdRef[String(RegExp.$2).toUpperCase()]; + this._aiTarget = String(RegExp.$3); + } else if (line.match(/[ ]*(.*):[ ](.*)/i)) { + this._origCondition = String(RegExp.$1); + var condition = String(RegExp.$1); + this._aiSkillId = Yanfly.SkillIdRef[String(RegExp.$2).toUpperCase()]; + this._aiTarget = 'RANDOM'; + } else { + return false; + } + if (!this.initialCheck(this._aiSkillId)) return false; + if (!this.meetCustomAIConditions(this._aiSkillId)) return false; + this.action().setSkill(this._aiSkillId); + if (!this.passAllAIConditions(condition)) return false; + return true; +}; + +AIManager.getPatternSkills = function(array, patterns) { + for (var i = 0; i < patterns.length; ++i) { + var line = patterns[i]; + if (line.match(/[ ]*(.*):[ ](?:SKILL)[ ](\d+),[ ](.*)/i)) { + var skillId = parseInt(RegExp.$2); + } else if (line.match(/[ ]*(.*):[ ](?:SKILL)[ ](\d+)/i)) { + var skillId = parseInt(RegExp.$2); + } else if (line.match(/[ ]*(.*):[ ](.*),[ ](.*)/i)) { + var skillId = Yanfly.SkillIdRef[String(RegExp.$2).toUpperCase()]; + } else if (line.match(/[ ]*(.*):[ ](.*)/i)) { + var skillId = Yanfly.SkillIdRef[String(RegExp.$2).toUpperCase()]; + } else { + continue; + } + if ($dataSkills[skillId]) array.push($dataSkills[skillId]); + } + return array; +}; + +AIManager.initialCheck = function(skillId) { + if (!$dataSkills[skillId]) return false; + if (!this.hasSkill(skillId)) return false; + return this.battler().meetsSkillConditions($dataSkills[skillId]); +}; + +AIManager.hasSkill = function(skillId) { + return this.battler().hasSkill(skillId); +}; + +AIManager.meetCustomAIConditions = function(skillId) { + return true; +}; + +AIManager.getActionGroup = function() { + var action = this.action(); + if (Imported.YEP_X_SelectionControl) action.setSelectionFilter(true); + if (!action) return []; + if (action.isForUser()) { + var group = [this.battler()]; + } else if (action.isForDeadFriend()) { + var group = action.friendsUnit().deadMembers(); + } else if (action.isForFriend()) { + var group = action.friendsUnit().aliveMembers(); + } else if (action.isForOpponent()) { + if (this.battler().aiConsiderTaunt()) { + $gameTemp._tauntMode = true; + $gameTemp._tauntAction = action; + var group = action.opponentsUnit().tauntMembers(); + $gameTemp._tauntMode = false; + $gameTemp._tauntAction = undefined; + } else { + var group = action.opponentsUnit().aliveMembers(); + } + } else { + var group = []; + } + if (this._setActionGroup !== undefined) { + group = Yanfly.Util.getCommonElements(this._setActionGroup, group); + } + this._setActionGroup = group; + return this._setActionGroup; +}; + +AIManager.setActionGroup = function(group) { + this._setActionGroup = group; +}; + +AIManager.setProperTarget = function(group) { + this.setActionGroup(group); + var action = this.action(); + var randomTarget = group[Math.floor(Math.random() * group.length)]; + if (!randomTarget) return action.setTarget(0); + if (group.length <= 0) return action.setTarget(randomTarget.index()); + var line = this._aiTarget.toUpperCase(); + if (line.match(/FIRST/i)) { + action.setTarget(0); + } else if (line.match(/USER/i)) { + var index = group.indexOf(); + action.setTarget(action.subject().index()); + } else if (line.match(/HIGHEST[ ](.*)/i)) { + var param = this.getParamId(String(RegExp.$1)); + if (param < 0) return action.setTarget(randomTarget.index()); + if (param === 8) return this.setHighestHpFlatTarget(group); + if (param === 9) return this.setHighestMpFlatTarget(group); + if (param === 10) return this.setHighestHpRateTarget(group); + if (param === 11) return this.setHighestMpRateTarget(group); + if (param === 12) return this.setHighestLevelTarget(group); + if (param === 13) return this.setHighestMaxTpTarget(group); + if (param === 14) return this.setHighestTpTarget(group); + if (param > 15) return action.setTarget(randomTarget.index()); + this.setHighestParamTarget(group, param); + } else if (line.match(/LOWEST[ ](.*)/i)) { + var param = this.getParamId(String(RegExp.$1)); + if (param < 0) return action.setTarget(randomTarget.index()); + if (param === 8) return this.setLowestHpFlatTarget(group); + if (param === 9) return this.setLowestMpFlatTarget(group); + if (param === 10) return this.setLowestHpRateTarget(group); + if (param === 11) return this.setLowestMpRateTarget(group); + if (param === 12) return this.setLowestLevelTarget(group); + if (param === 13) return this.setLowestMaxTpTarget(group); + if (param === 14) return this.setLowestTpTarget(group); + if (param > 15) return action.setTarget(randomTarget.index()); + this.setLowestParamTarget(group, param); + } else { + this.setRandomTarget(group); + } +}; + +AIManager.getParamId = function(string) { + string = string.toUpperCase() + switch (string) { + case 'MAXHP': + case 'MAX HP': + return 0; + break; + case 'MAXMP': + case 'MAX MP': + case 'MAXSP': + case 'MAX SP': + return 1; + break; + case 'ATK': + case 'STR': + return 2; + break; + case 'DEF': + return 3; + break; + case 'MAT': + case 'INT': + case 'SPI': + return 4; + break; + case 'MDF': + case 'RES': + return 5; + break; + case 'AGI': + case 'SPD': + return 6; + break; + case 'LUK': + return 7; + break; + case 'HP': + return 8; + break; + case 'MP': + case 'SP': + return 9; + break; + case 'HP%': + return 10; + break; + case 'MP%': + case 'SP%': + return 11; + break; + case 'LEVEL': + case 'LV': + case 'LVL': + return 12; + break; + case 'MAXTP': + return 13; + break; + case 'TP': + return 14; + break; + } + return -1; +}; + +AIManager.setHighestHpRateTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.hp / target.mhp > maintarget.hp / maintarget.mhp) { + maintarget = target; + } + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestHpFlatTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.hp > maintarget.hp) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestHpRateTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.hp / target.mhp < maintarget.hp / maintarget.mhp) { + maintarget = target; + } + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestHpFlatTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.hp < maintarget.hp) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestMpRateTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.mp / target.mmp > maintarget.mp / maintarget.mmp) { + maintarget = target; + } + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestMpFlatTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.mp > maintarget.mp) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestMpRateTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.mp / target.mmp < maintarget.mp / maintarget.mmp) { + maintarget = target; + } + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestMpFlatTarget = function(group) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.mp < maintarget.mp) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestParamTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.param(id) > maintarget.param(id)) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestParamTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.param(id) < maintarget.param(id)) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestLevelTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.level > maintarget.level) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestLevelTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.level < maintarget.level) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestMaxTpTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.tp > maintarget.maxTp()) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestMaxTpTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.tp < maintarget.maxTp()) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setHighestTpTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.tp > maintarget.tp) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setLowestTpTarget = function(group, id) { + var maintarget = group[Math.floor(Math.random() * group.length)]; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target.tp < maintarget.tp) maintarget = target; + } + this.action().setTarget(maintarget.index()) +}; + +AIManager.setRandomTarget = function(group) { + var target = group[Math.floor(Math.random() * group.length)]; + this.action().setTarget(target.index()) +}; + +AIManager.convertIntegerPercent = function(n) { + n *= 0.01 + return String(n); +}; + +AIManager.elementRateMatch = function(target, elementId, type) { + var rate = target.elementRate(elementId).toFixed(2); + if (this.battler().isActor()) { + if (!$gameParty.aiElementRateKnown(target, elementId)) return true; + } else { + if (!$gameTroop.aiElementRateKnown(target, elementId)) return true; + } + if (['NEUTRAL', 'NORMAL'].contains(type)) { + return rate >= 0.90 && rate <= 1.10; + } else if (['WEAK', 'WEAKNESS', 'VULNERABLE'].contains(type)) { + return rate > 1.00; + } else if (['RESIST', 'RESISTANT', 'STRONG'].contains(type)) { + return rate < 1.00; + } else if (['NULL', 'CANCEL', 'NO EFFECT'].contains(type)) { + return rate === 0.00; + } else if (['ABSORB', 'HEAL'].contains(type)) { + return rate < 0.00; + } + return false; +}; + +AIManager.passAllAIConditions = function(line) { + this._setActionGroup = undefined; + var conditions = line.split('+++'); + if (conditions.length <= 0) return false; + while (conditions.length > 0) { + var condition = conditions.shift().trim(); + if (!this.passAIConditions(condition)) return false; + } + return true; +}; + +AIManager.passAIConditions = function(line) { + // ALWAYS + if (line.match(/ALWAYS/i)) { + return this.conditionAlways(); + } + // ELEMENT + if (line.match(/ELEMENT[ ](.*)/i)) { + return this.conditionElement(); + } + // EVAL + if (line.match(/EVAL[ ](.*)/i)) { + var condition = String(RegExp.$1); + return this.conditionEval(condition); + } + // GROUP ALIVE MEMBERS EVAL + if (line.match(/(.*)[ ]ALIVE[ ]MEMBERS[ ](.*)/i)) { + var members = String(RegExp.$1); + var condition = String(RegExp.$2); + return this.conditionGroupAlive(members, condition); + } + // GROUP DEAD MEMBERS EVAL + if (line.match(/(.*)[ ]DEAD[ ]MEMBERS[ ](.*)/i)) { + var members = String(RegExp.$1); + var condition = String(RegExp.$2); + return this.conditionGroupDead(members, condition); + } + // USER PARAM EVAL + if (line.match(/USER[ ](.*)[ ]PARAM[ ](.*)/i)) { + var paramId = this.getParamId(String(RegExp.$1)); + var condition = String(RegExp.$2); + return this.conditionUserParamEval(paramId, condition); + } + // PARAM EVAL + if (line.match(/(.*)[ ]PARAM[ ](.*)/i)) { + var paramId = this.getParamId(String(RegExp.$1)); + var condition = String(RegExp.$2); + return this.conditionParamEval(paramId, condition); + } + // PARTY LEVEL + if (line.match(/(.*)[ ]PARTY[ ]LEVEL[ ](.*)/i)) { + var type = String(RegExp.$1); + var condition = String(RegExp.$2); + return this.conditionPartyLevel(type, condition); + } + // RANDOM x% + if (line.match(/RANDOM[ ](\d+)([%%])/i)) { + return this.conditionRandom(parseFloat(RegExp.$1 * 0.01)); + } + // STATE === X + if (line.match(/STATE[ ]===[ ](.*)/i)) { + return this.conditionStateHas(String(RegExp.$1)); + } + // STATE !== X + if (line.match(/STATE[ ]!==[ ](.*)/i)) { + return this.conditionStateNot(String(RegExp.$1)); + } + // SWITCH X case + if (line.match(/SWITCH[ ](\d+)[ ](.*)/i)) { + var switchId = parseInt(RegExp.$1); + var value = String(RegExp.$2) + return this.conditionSwitch(switchId, value); + } + // TURN EVAL + if (line.match(/TURN[ ](.*)/i)) { + return this.conditionTurnCount(String(RegExp.$1)); + } + // VARIABLE X eval + if (line.match(/VARIABLE[ ](\d+)[ ](.*)/i)) { + var variableId = parseInt(RegExp.$1); + var condition = String(RegExp.$2) + return this.conditionVariable(variableId, condition); + } + return false; +}; + +AIManager.conditionAlways = function() { + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +AIManager.conditionElement = function() { + var line = this._origCondition; + if (line.match(/ELEMENT[ ](\d+)[ ](.*)/i)) { + var elementId = parseInt(RegExp.$1); + var type = String(RegExp.$2).toUpperCase(); + } else if (line.match(/ELEMENT[ ](.*)[ ](.*)/i)) { + var elementId = Yanfly.ElementIdRef[String(RegExp.$1).toUpperCase()]; + var type = String(RegExp.$2).toUpperCase(); + } else { + return false; + } + var group = this.getActionGroup(); + var validTargets = []; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (!target) continue; + if (this.elementRateMatch(target, elementId, type)) { + validTargets.push(target); + } + } + if (validTargets.length <= 0) return false; + this.setProperTarget(validTargets); + return true; +}; + +AIManager.conditionEval = function(condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. EVAL ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +AIManager.conditionGroupAlive = function(members, condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + members = members.toUpperCase(); + if (['TROOP', 'TROOPS', 'ENEMY', 'ENEMIES'].contains(members)) { + members = $gameTroop.aliveMembers(); + } else if (['PARTY', 'PLAYER'].contains(members)) { + members = $gameParty.aliveMembers(); + } else { + return false; + } + if (members.length <= 0) return false; + condition = 'members.length ' + condition; + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. GROUP ALIVE ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +AIManager.conditionGroupDead = function(members, condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + members = members.toUpperCase(); + if (['TROOP', 'TROOPS', 'ENEMY', 'ENEMIES'].contains(members)) { + members = $gameTroop.deadMembers(); + } else if (['PARTY', 'PLAYER'].contains(members)) { + members = $gameParty.deadMembers(); + } else { + return false; + } + if (members.length <= 0) return false; + condition = 'members.length ' + condition; + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. GROUP DEAD ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +AIManager.conditionPartyLevel = function(type, condition) { + if (type.match(/HIGHEST/i)) { + condition = '.highestLevel() ' + condition; + } else if (type.match(/LOWEST/i)) { + condition = '.lowestLevel() ' + condition; + } else if (type.match(/AVERAGE/i)) { + condition = '.averageLevel() ' + condition; + } else { + return false; + } + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + if (action.isForFriend()) { + condition = 'action.friendsUnit()' + condition; + } else if (action.isForOpponent()) { + condition = 'action.opponentsUnit()' + condition; + } + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. PARTY LEVEL ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +AIManager.conditionUserParamEval = function(paramId, condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + condition = condition.replace(/(\d+)([%%])/g, function() { + return this.convertIntegerPercent(parseInt(arguments[1])); + }.bind(this)); + if (paramId < 0) return false; + if (paramId >= 0 && paramId <= 7) { + condition = 'user.param(paramId) ' + condition; + } else if (paramId === 8) { + condition = 'user.hp ' + condition; + } else if (paramId === 9) { + condition = 'user.mp ' + condition; + } else if (paramId === 10) { + condition = 'user.hp / user.mhp ' + condition; + } else if (paramId === 11) { + condition = 'user.mp / user.mmp ' + condition; + } else if (paramId === 12) { + condition = 'user.level ' + condition; + } + var group = this.getActionGroup(); + var validTargets = []; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (!target) continue; + try { + if (eval(condition)) validTargets.push(target); + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. USER PARAM ERROR') + } + } + if (validTargets.length <= 0) return false; + this.setProperTarget(validTargets); + return true; +}; + +AIManager.conditionParamEval = function(paramId, condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + condition = condition.replace(/(\d+)([%%])/g, function() { + return this.convertIntegerPercent(parseInt(arguments[1])); + }.bind(this)); + if (paramId < 0) return false; + if (paramId >= 0 && paramId <= 7) { + condition = 'target.param(paramId) ' + condition; + } else if (paramId === 8) { + condition = 'target.hp ' + condition; + } else if (paramId === 9) { + condition = 'target.mp ' + condition; + } else if (paramId === 10) { + condition = 'target.hp / target.mhp ' + condition; + } else if (paramId === 11) { + condition = 'target.mp / target.mmp ' + condition; + } else if (paramId === 12) { + condition = 'target.level ' + condition; + } + var group = this.getActionGroup(); + var validTargets = []; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (!target) continue; + try { + if (eval(condition)) validTargets.push(target); + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. PARAM ERROR') + } + } + if (validTargets.length <= 0) return false; + this.setProperTarget(validTargets); + return true; +}; + +AIManager.conditionRandom = function(rate) { + if (Math.random() >= rate) return false; + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +AIManager.conditionStateHas = function(condition) { + if (condition.match(/STATE[ ](\d+)/i)) { + var stateId = parseInt(RegExp.$1); + } else { + var stateId = Yanfly.StateIdRef[condition.toUpperCase()]; + if (!stateId) return false; + } + if (!$dataStates[stateId]) return false; + var group = this.getActionGroup(); + var validTargets = []; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (!target) continue; + if (target.hasState(stateId)) validTargets.push(target); + } + if (validTargets.length <= 0) return false; + this.setProperTarget(validTargets); + return true; +}; + +AIManager.conditionStateNot = function(condition) { + if (condition.match(/STATE[ ](\d+)/i)) { + var stateId = parseInt(RegExp.$1); + } else { + var stateId = Yanfly.StateIdRef[condition.toUpperCase()]; + if (!stateId) return false; + } + if (!$dataStates[stateId]) return false; + var group = this.getActionGroup(); + var validTargets = []; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (!target) continue; + if (target.notState(stateId)) validTargets.push(target); + } + if (validTargets.length <= 0) return false; + this.setProperTarget(validTargets); + return true; +}; + +AIManager.conditionSwitch = function(switchId, value) { + if (['ON', 'TRUE', 'YES'].contains(value.toUpperCase())) { + value = true; + } else if (['OFF', 'FALSE', 'NO'].contains(value.toUpperCase())) { + value = false; + } else { + return false; + } + if ($gameSwitches.value(switchId) !== value) return false; + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +if (!Yanfly.Param.CoreAIDynTurnCnt) { + +AIManager.conditionTurnCount = function(condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + if (Imported.YEP_BattleEngineCore) { + condition = 'user.turnCount() ' + condition; + } else { + condition = '$gameTroop.turnCount() ' + condition; + } + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. TURN COUNT ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +} else { +// Alternative provided by Talonos + +AIManager.conditionTurnCount = function(condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + if (Imported.YEP_BattleEngineCore) { + if (BattleManager._phase === "input" && BattleManager.isTurnBased()) { + condition = '(user.turnCount() + 1) ' + condition; + } else { + condition = 'user.turnCount() ' + condition; + } + } else { + if (BattleManager._phase === "input") { + condition = '($gameTroop.turnCount() + 1) ' + condition; + } else { + condition = '$gameTroop.turnCount() ' + condition; + } + } + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. TURN COUNT ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +} // Yanfly.Param.CoreAIDynamic + + +AIManager.conditionVariable = function(variableId, condition) { + var action = this.action(); + var item = action.item(); + var user = this.battler(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + condition = '$gameVariables.value(' + variableId + ') ' + condition; + try { + if (!eval(condition)) return false; + } catch (e) { + Yanfly.Util.displayError(e, condition, 'A.I. VARIABLE ERROR'); + return false; + } + var group = this.getActionGroup(); + this.setProperTarget(group); + return true; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +Yanfly.Util.getCommonElements = function(array1, array2) { + var elements = []; + var length = array1.length; + for (var i = 0; i < length; ++i) { + var element = array1[i]; + if (array2.contains(element)) elements.push(element); + } + return elements; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_BattleEngineCore.js b/js/plugins/YEP_BattleEngineCore.js new file mode 100644 index 0000000..1b4ab7e --- /dev/null +++ b/js/plugins/YEP_BattleEngineCore.js @@ -0,0 +1,5655 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle Engine Core +// YEP_BattleEngineCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_BattleEngineCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.BEC = Yanfly.BEC || {}; +Yanfly.BEC.version = 1.51; + +//============================================================================= + /*: + * @plugindesc v1.51 Have more control over the flow of the battle system + * with this plugin and alter various aspects to your liking. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Action Speed + * @parent ---General--- + * @desc This is the formula used for an action's base speed. + * Default: agi + Math.randomInt(Math.floor(5 + agi / 4)) + * @default agi + * + * @param Default System + * @parent ---General--- + * @type select + * @option Default Turn Battle + * @value dtb + * @option Active Turn Battle (plugin required) + * @value atb + * @option Charge Turn Battle (plugin required) + * @value ctb + * @option Standard Turn Battle (plugin required) + * @value stb + * @desc This is the default battle system your game uses. + * Default: dtb + * @default dtb + * + * @param ---Escape--- + * @default + * + * @param Escape Ratio + * @parent ---Escape--- + * @desc This is the formula used to determine escape success. + * Default: 0.5 * $gameParty.agility() / $gameTroop.agility() + * @default 0.5 * $gameParty.agility() / $gameTroop.agility() + * + * @param Fail Escape Boost + * @parent ---Escape--- + * @type number + * @decimals 2 + * @desc Each time the player fails escape, increase the success + * rate by this much. Default: 0.10 + * @default 0.10 + * + * @param ---Animation--- + * @default + * + * @param Animation Base Delay + * @parent ---Animation--- + * @type number + * @min 0 + * @desc This sets the base delay in between animations. + * Default: 8 + * @default 0 + * + * @param Animation Next Delay + * @parent ---Animation--- + * @type number + * @min 0 + * @desc This sets the sequential delay in between animations. + * Default: 12 + * @default 0 + * + * @param Certain Hit Animation + * @parent ---Animation--- + * @type number + * @min 0 + * @desc Default animation to play for certain hit skills. + * Use 0 if you wish for no animation. + * @default 0 + * + * @param Physical Animation + * @parent ---Animation--- + * @type number + * @min 0 + * @desc Default animation to play for physical skills. + * Use 0 if you wish for no animation. + * @default 52 + * + * @param Magical Animation + * @parent ---Animation--- + * @type number + * @min 0 + * @desc Default animation to play for magical skills. + * Use 0 if you wish for no animation. + * @default 51 + * + * @param Enemy Attack Animation + * @parent ---Animation--- + * @type number + * @min 0 + * @desc This is the default attack animation played by enemies. + * Default: 0 + * @default 39 + * + * @param Reflect Animation + * @parent ---Animation--- + * @type number + * @min 0 + * @desc The animation used when magic attacks are reflected. + * @default 42 + * + * @param Motion Waiting + * @parent ---Animation--- + * @type boolean + * @on After + * @off During + * @desc Play animations after performing an action or during? + * During - false After - true Default: false + * @default false + * + * @param ---Frontview--- + * @default + * + * @param Front Position X + * @parent ---Frontview--- + * @desc This formula determines the actor's home X position. + * Default: 0 + * @default Graphics.boxWidth / 8 + Graphics.boxWidth / 4 * index + * + * @param Front Position Y + * @parent ---Frontview--- + * @desc This formula determines the actor's home Y position. + * Default: 0 + * @default Graphics.boxHeight - 180 + * + * @param Front Actor Sprite + * @parent ---Frontview--- + * @type boolean + * @on YES + * @off NO + * @desc Show the actor battle sprite in frontview? + * NO - false YES - true Default - false + * @default false + * + * @param Front Sprite Priority + * @parent ---Frontview--- + * @type select + * @option Normal + * @value 0 + * @option Actors on Top + * @value 1 + * @option Enemies on Top + * @value 2 + * @desc Give actor sprites the priority of always being on top? + * 0 - Normal 1 - Actors on Top 2 - Enemies on Top + * @default 1 + * + * @param ---Sideview--- + * @default + * + * @param Home Position X + * @parent ---Sideview--- + * @desc This formula determines the actor's home X position. + * Default: 600 + index * 32 + * @default screenWidth - 16 - (maxSize + 2) * 32 + index * 32 + * + * @param Home Position Y + * @parent ---Sideview--- + * @desc This formula determines the actor's home Y position. + * Default: 280 + index * 48 + * @default screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 32 + * + * @param Side Sprite Priority + * @parent ---Sideview--- + * @type select + * @option Normal + * @value 0 + * @option Actors on Top + * @value 1 + * @option Enemies on Top + * @value 2 + * @desc Give actor sprites the priority of always being on top? + * 0 - Normal 1 - Actors on Top 2 - Enemies on Top + * @default 1 + * + * @param ---Sprites--- + * @default + * + * @param Default X Anchor + * @parent ---Sprites--- + * @type number + * @decimals 2 + * @desc Default value used for your sprites's X Anchor. + * Default: 0.50 + * @default 0.50 + * + * @param Default Y Anchor + * @parent ---Sprites--- + * @type number + * @decimals 2 + * @desc Default value used for your sprites's Y Anchor. + * Default: 1.00 + * @default 1.00 + * + * @param Step Distance + * @parent ---Sprites--- + * @type number + * @desc This is the distance a unit steps forward for actions. + * Default: 48 + * @default 48 + * + * @param Flinch Distance + * @parent ---Sprites--- + * @type number + * @desc In sideview, when a unit takes damage or dodges, it will + * flinch a certain distance in pixels. + * @default 12 + * + * @param Show Shadows + * @parent ---Sprites--- + * @type boolean + * @on Show Shadows + * @off Hide Shadows + * @desc Do you wish to have shadows appear under actors? + * NO - false YES - true + * @default true + * + * @param ---Damage Popups--- + * @default + * + * @param Popup Duration + * @parent ---Damage Popups--- + * @type number + * @min 1 + * @desc Adjusts how many frames a popup will stay visible for. + * Default: 90 + * @default 128 + * + * @param Newest Popup Bottom + * @parent ---Damage Popups--- + * @type boolean + * @on Newest at bottom + * @off Newest at top + * @desc Places the newest popup at the bottom of a group. + * NO - false YES - true + * @default true + * + * @param Popup Overlap Rate + * @parent ---Damage Popups--- + * @type number + * @decimals 1 + * @desc When multiple damage popups appear, they cover each other. + * Use this to change the buffer rate amount for each sprite. + * @default 0.9 + * + * @param Critical Popup + * @parent ---Damage Popups--- + * @desc Adjusts the popup's flashing color for critical hits. + * Default: 255, 0, 0, 160 + * @default 255, 0, 0, 160 + * + * @param Critical Duration + * @parent ---Damage Popups--- + * @type number + * @min 1 + * @desc How many frames the flashing will remain for a critical. + * Default: 60 + * @default 60 + * + * @param ---Tick-Settings--- + * @default + * + * @param Timed States + * @parent ---Tick-Settings--- + * @type boolean + * @on Time-Based States + * @off Turn-Based States + * @desc If the battle system is Tick-based, use time instead of + * turns for states? NO - false YES - true + * @default false + * + * @param Timed Buffs + * @parent ---Tick-Settings--- + * @type boolean + * @on Time-Based Buffs + * @off Turn-Based Buffs + * @desc If the battle system is Tick-based, use time instead of + * turns for buffs? NO - false YES - true + * @default false + * + * @param Turn Time + * @parent ---Tick-Settings--- + * @type number + * @min 1 + * @desc How many ticks must past to equal 1 turn? + * @default 100 + * + * @param AI Self Turns + * @parent ---Tick-Settings--- + * @type boolean + * @on YES + * @off NO + * @desc Set AI to be based on their own individual turns? + * NO - false YES - true + * @default true + * + * @param ---Window Settings--- + * @default + * + * @param Lower Windows + * @parent ---Window Settings--- + * @type boolean + * @on Bottom Layout + * @off Default Layout + * @desc Places the skill and item windows at the screen's bottom. + * OFF - false ON - true + * @default true + * + * @param Window Rows + * @parent ---Window Settings--- + * @number + * @min 1 + * @desc For lower windows, how many rows of items do you wish for + * the windows to display? + * @default 4 + * + * @param Command Window Rows + * @parent ---Window Settings--- + * @type number + * @min 1 + * @desc Sets the number of rows for each command window to display. + * Default: 4 + * @default 4 + * + * @param Command Alignment + * @parent ---Window Settings--- + * @type combo + * @option left + * @option center + * @option right + * @desc Sets the text alignment for the Party/Actor Commands. + * Default: left + * @default center + * + * @param Start Actor Command + * @parent ---Window Settings--- + * @type boolean + * @on Actor Command Window + * @off Party Command Window + * @desc Starts turn with the Actor Command Window instead of Party. + * OFF - false ON - true + * @default true + * + * @param Current Max + * @parent ---Window Settings--- + * @type boolean + * @on Current / Max + * @off Just Current + * @desc Display the entire current / max value of HP/MP? + * NO - false YES - true Default: true + * @default false + * + * @param ---Selection Help--- + * @default + * + * @param Mouse Over + * @parent ---Selection Help--- + * @type boolean + * @on YES + * @off NO + * @desc Allows you to mouse over the enemies to auto-select them. + * OFF - false ON - true + * @default true + * + * @param Select Help Window + * @parent ---Selection Help--- + * @type boolean + * @on YES + * @off NO + * @desc When selecting actors and enemies, show the help window? + * NO - false YES - true + * @default true + * + * @param User Help Text + * @parent ---Selection Help--- + * @desc The singular form of 'User' used in a help window. + * @default User + * + * @param Ally Help Text + * @parent ---Selection Help--- + * @desc The singular form of 'Ally' used in a help window. + * @default Ally + * + * @param Allies Help Text + * @parent ---Selection Help--- + * @desc The plural form of 'Allies' used in a help window. + * @default Allies + * + * @param Enemy Help Text + * @parent ---Selection Help--- + * @desc The singular form of 'Enemy' used in a help window. + * @default Enemy + * + * @param Enemies Help Text + * @parent ---Selection Help--- + * @desc The plural form of 'Enemy' used in a help window. + * @default Enemies + * + * @param All Help Text + * @parent ---Selection Help--- + * @desc When selecting a entire group of targets. + * %1 - Target Group (Allies or Enemies) + * @default All %1 + * + * @param Random Help Text + * @parent ---Selection Help--- + * @desc When selecting a random selection of targets. + * %1 - Target Group (Allies or Enemies) %2 - Number + * @default %2 Random %1 + * + * @param ---Enemy Select--- + * @default + * + * @param Visual Enemy Select + * @parent ---Enemy Select--- + * @type boolean + * @on YES + * @off NO + * @desc Replaces the enemy selection screen with a more visual one. + * OFF - false ON - true + * @default true + * + * @param Show Enemy Name + * @parent ---Enemy Select--- + * @type boolean + * @on YES + * @off NO + * @desc Show enemy names with Visual Enemy Select. + * OFF - false ON - true + * @default true + * + * @param Show Select Box + * @parent ---Enemy Select--- + * @type boolean + * @on YES + * @off NO + * @desc Show a selection box when selecting enemies. + * OFF - false ON - true + * @default false + * + * @param Enemy Font Size + * @parent ---Enemy Select--- + * @type number + * @min 1 + * @desc Changes the font size used to display enemy names. + * Default: 28 + * @default 20 + * + * @param Enemy Auto Select + * @parent ---Enemy Select--- + * @desc Changes what enemy is automatically selected at first. + * LEFT - 0 RIGHT - this.furthestRight() + * @default this.furthestRight() + * + * @param ---Actor Select--- + * @default + * + * @param Visual Actor Select + * @parent ---Actor Select--- + * @type boolean + * @on YES + * @off NO + * @desc Allows you to click the actor on screen to select it. + * OFF - false ON - true + * @default true + * + * @param ---Battle Log--- + * @default + * + * @param Show Emerge Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows the battle start text for enemies appearing. + * OFF - false ON - true + * @default false + * + * @param Show Pre-Emptive Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows the text for getting a pre-emptive attack. + * OFF - false ON - true + * @default true + * + * @param Show Surprise Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows the text for getting a surprise attack. + * OFF - false ON - true + * @default true + * + * @param Optimize Speed + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Cuts log base line process to optimize the battle speed. + * OFF - false ON - true + * @default true + * + * @param Show Action Text + * @parent ---Battle Log--- + * @type boolean + * @on Full + * @off Simple + * @desc Displays full action text or a simplified version of it. + * SIMPLE - false FULL - true + * @default false + * + * @param Show State Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows all text regarding states. + * OFF - false ON - true + * @default false + * + * @param Show Buff Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows all text regarding buffs. + * OFF - false ON - true + * @default false + * + * @param Show Counter Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding counter attacks. + * OFF - false ON - true + * @default true + * + * @param Show Reflect Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding reflected spells. + * OFF - false ON - true + * @default true + * + * @param Show Substitute Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding substituted damage. + * OFF - false ON - true + * @default true + * + * @param Show Fail Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding failed attacks. + * OFF - false ON - true + * @default false + * + * @param Show Critical Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding critical hits. + * OFF - false ON - true + * @default false + * + * @param Show Miss Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding missed attacks. + * OFF - false ON - true + * @default false + * + * @param Show Evasion Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding evaded attacks. + * OFF - false ON - true + * @default false + * + * @param Show HP Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding HP damage or heals. + * OFF - false ON - true + * @default false + * + * @param Show MP Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding MP damage or heals. + * OFF - false ON - true + * @default false + * + * @param Show TP Text + * @parent ---Battle Log--- + * @type boolean + * @on YES + * @off NO + * @desc Shows text regarding TP damage or heals. + * OFF - false ON - true + * @default false + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin alters the various aspects of the default battle system, + * allowing it to be more streamlined like most modern RPG's and less clunky + * like older RPG's. This ranges from choosing what text will appear in the + * battle log window at the top and how it will be displayed. + * + * ============================================================================ + * Battle Messages + * ============================================================================ + * + * When changing "Terms" and the "Messages" that appear in battle, inserting + * the following tag anywhere in the message will cause the message to center + * itself in the battle log. + * + *
+ * This tag must be all caps in order for the battle log window to recognize + * it as an instruction to center the displayed battle text message. + * + * There are a couple of notetags you can use to change the way certain skills + * and items will show up incase you don't want a name like 'Harold's Attack' + * to appear in the name. + * + * Skill and Item Notetags: + * + * + * This will change the text displayed to x. + * + * + * This will change the icon displayed to x. + * + * ============================================================================ + * Battle Windows + * ============================================================================ + * + * There's various options to adjust the window settings found in the battle + * system to make navigating the battle system more intuitive. Such options + * include starting the turns with the Actor Command Window instead of the + * Party Command Window (the Fight/Escape Window). The Party Command Window is + * still accessible but only by pressing cancel on the first actor's window. + * + * ============================================================================ + * Battle Order + * ============================================================================ + * + * The battle turn order is also fixed, too. This way, any battlers that Have + * their AGI value changed over the course of battle will reflect those changes + * during the current turn rather than the following turn. The action speed + * calculation can also be adjusted and finetuned to have the random factor of + * its speed calculation formula removed, too, making AGI actually worthwhile + * as a tactical parameter. + * + * Skill and Item Notetag: + * + * + * This lets you break past the editor's limit of -2000 and 2000 allowing you + * to set the speed of your actions with more control. + * + * ============================================================================ + * Multiple Hits + * ============================================================================ + * + * Multi-hit action will no longer end prematurely if the target dies midway + * through the action. This is done through toggling immortal states. To make + * use of feature, make sure your database has an Immortal State somewhere. If + * you do not wish to use this feature, set the Parameter for Immortal State ID + * to 0 instead. + * + * ============================================================================ + * Popup Revamp + * ============================================================================ + * + * Although the damage popups may still look the same as the default ones from + * MV, the process in which they're created is now different to streamline the + * damage popup process. Before, popups would only appear one a time with a + * frame's different at minimum in order for them to show. Now, any actions + * that occur at the same frame will now all show popups at the same frame, + * making for smoother and less clunky damage popups. + * + * ============================================================================ + * Common Events + * ============================================================================ + * + * Common Events will now occur at the end of each action regardless of whether + * or not the enemy party is still alive. With proper placing of the action + * sequence tags, you can make the skill's common event occur in the middle of + * an action, too. However, keep in mind if you force an action in the middle + * of another action, the remainder of the former action's sequence list will + * become null and void in favor of the new forced action. + * + * ============================================================================ + * Casting Animations + * ============================================================================ + * + * Casting Animations help provide visual hints for players either by letting + * them know which battler is going to perform an action or what type of skill + * that action will be. This plugin enables skills to have casting animations + * that can be modified universally or customized for each individual skill. + * + * Skill Notetag: + * + * Sets the skill's cast animation to animation ID x. Setting x to zero will + * cause the skill to not have any animaton at all. + * + * ============================================================================ + * Changing Battle Systems + * ============================================================================ + * + * While the player is not in battle, you can change the battle system using a + * Plugin Command. With only this plugin, there is only one battle system + * included: the default battle system. + * + * Plugin Command: + * setBattleSys DTB Sets battle system to Default Turn Battle. + * + * Other future plugins may include other battle systems that may utilize the + * Battle Engine Core. + * + * ============================================================================ + * Sideview Actions + * ============================================================================ + * + * In RPG Maker MV's default battle system, both the sideview and the frontview + * settings do not display counterattacks, reflected magic attacks, nor any + * case of substituting for battle members. The Battle Engine Core provides + * games that are using the sideview settings small amounts of animations to + * relay information to the player in a more visual sense. + * + * Magic Reflection will also display a reflection animation to indicate the + * battler has reflection properties. This animation can be changed in the + * parameters, but certain actors, classes, enemies, weapons, armors, and + * states can display a unique kind of animation for reflection if desired. + * + * Actor, Class, Enemy, Weapon, Armor, and State Notetag: + * + * Changes the user's reflect animation to x. This will take priority in the + * following order: Actor, Class, Enemy, Weapon, Armor, State, Default. + * + * Sometimes, you don't want your enemies to be able to move. Or you don't want + * certain actors to be able to move. They're just stationary for whatever + * reason. To accomplish that, you can use this notetag to forbid the battler + * from moving. + * + * Actor, Class, Enemy, Weapon, Armor, and State Notetag: + * + * Prevents the battler's sprite from moving. This will take priority in the + * following order: Actor, Class, Enemy, Weapon, Armor, and State. If an + * enemy is unable to move when it performs an action, it will flash white as + * if it normally does in front view. + * + * ============================================================================ + * Custom Sideview Battler Anchor + * ============================================================================ + * + * Sideview battlers are generally centered horizontally, and grounded at their + * feet. However, not all sideview battler spritesheets work this way. In the + * event you have a sideview battler that doesn't conform to those standards, + * you can 'anchor' them a different way. + * + * Actor, Class, Weapon, Armor, State Notetags: + * + * + * This sets the anchor location for the actor's sideview battler at y.z. + * By default, the X anchor is 0.5 while the Y anchor is 1.0. If you want + * the X anchor to be a bit more to the left, make it less than 0.5. Make it + * more than 0.5 to make the X anchor more towards the right. To raise the + * Y anchor, set the number value to less than 1.0. Keep adjusting until you + * find that perfect anchor setting. + * + * If an anchor has multiple traits that yield different anchors, it will be + * used in a priority list akin to this order: + * + * States + * Weapons + * Armors + * Class + * Actor + * Default + * + * The higher it is on the priority list, the higher its priority. + * + * ============================================================================ + * Enemy Attack Animation + * ============================================================================ + * + * To give your enemies unique attack animations, you can use this notetag: + * + * Enemy Notetag: + * + * Replace x with the ID of the battle animation you wish to set as the + * enemy's default attack animation. + * + * ============================================================================ + * Automatic State Removal Conditions + * ============================================================================ + * + * By default, RPG Maker MV's battle system has automatic state removal under + * three different conditions: none, action end, turn end. + * + * None and Turn End are working as intended. However, Action End, however, had + * the states removed at the start of the battler's action rather than the end. + * This is changed and updated to occur only at the end of a battler's action. + * + * Two more automatic conditions are now added: Action Start and Turn Start. + * These can be added and implemented using the following notetags: + * + * State Notetags: + * + * + * This will cause this state to update its turns remaining at the start of + * an action. x is the number of turns it will last. If you use x to y, upon + * applying the state, the state will be removed a random number of turns + * from x to y. + * + * + * + * This will cause the state to update its turns remaining at the start of a + * battle turn. x is the number of turns it will last. If you use x to y, + * upon applying the state, the state will be removed a random number of + * turns from x to y. + * + * States with Action End have a unique trait to them where if the caster of + * the state is the current active battler (subject) and if the state is then + * applied on the user itself, they will gain a 'free turn'. The 'free turn' is + * to mitigate the user from losing 1 duration of the turn since with an Action + * End timing, they would lose the benefit of being under the state for that + * turn's timing. + * + * ============================================================================ + * Action Sequences + * ============================================================================ + * + * The Yanfly Engine Plugins - Battle Engine Core includes the capability of + * using custom action sequences. Action sequences are basic instructions for + * the game to creating a customized skill both visually and mechanically. + * The Battle Engine Core, however, will only include the most basic of action + * sequences so the instructions on how to create a custom action sequence will + * be included in the Help file on future extension plugins for this plugin. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.51: + * - Fixed updateBattlerName function. Thanks to ZServ. + * + * Version 1.50: + * - Action sequences allow for unlimited arguments now. + * + * Version 1.49: + * - Added failsafe for 'furthestRight()' errors. + * + * Version 1.48: + * - Optimization update. + * + * Version 1.47: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.46: + * - Updated for RPG Maker MV version 1.6.1. + * + * Version 1.45: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.44: + * - Fixed a bug where the enemy name windows disappear if you change scenes + * mid-way through battle and return to it. + * + * Version 1.43b: + * - Bug fixed to prevent crash if non-existent actions are used. + * - Optimization update. + * + * Version 1.42: + * - Optimization update. + * + * Version 1.41: + * - Fixed a bug that allowed certain sprites to remain in the active pool + * while party members were removed midway through battle. + * + * Version 1.40: + * - Updated for RPG Maker MV version 1.3.2. + * + * Version 1.39c: + * - Fixed a bug that caused dead actors to not be a part of action sequence + * targeting for "Not Focus". + * - Optimization update. + * - Updated "queueForceAction" to utilize both numbers and actual targets. + * + * Version 1.38a: + * - Optimization update. + * - Compatibility update for Selection Control v1.08. + * - Bug fixed for mirrored animations on enemies. + * + * Version 1.37: + * - Fixed a bug where if the enemy's size is too small, the enemy's name + * during selection will be cut off. + * + * Version 1.36d: + * - Made an update for the battle background image snaps when there is no + * battleback being used. This will prevent the player party and enemy troop + * from appearing in the background snapshot when entering menus mid-battle. + * - 'Death Break' action sequence now only triggers upon dead status and not + * an 'or 0 HP' condition. + * - Updated Forced Action sequencing for more efficiency. + * - 'Action Times+' traits now work properly for DTB again. + * - Optimized message displaying for battle log. + * - Optimized z sorting algorithm for sprites. + * + * Verison 1.35d: + * - Scopes that target a dead ally will automatically target the first dead + * ally now. Scopes that target all dead allies will lock onto the first dead + * ally. This will hopefully provide less confusion amongst playing. + * - Added anti-crash measure for sprite bitmaps. + * - Added anti-crash measure for faux actions. + * - Added anti-crash measure to prevent non-existant animations from playing. + * - Added a check that prevents hidden battlers from appearing when using + * certain action sequences. + * + * Version 1.34a: + * - Fixed a bug where 'NOT FOCUS' targets were not including dead members. + * - Fixed a bug where using NOT FOCUS would cause dead targets to be visible. + * + * Version 1.33: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.32d: + * - Fixed a bug that caused a crash when an actor died. + * - Added a motion engine to be used for future plugins. + * - Preparation for a future plugin. + * - and notetags for actors are now extended + * to actors, classes, weapons, armors, and states. + * - Added and notetags for skills and + * items. These notetags will alter the display name shown and icon shown + * respectively while performing a skill. + * - Switched Magic Reflect checking order with Counterattack checking order. + * This is to give priority to reflected actions over countered actions. + * + * Version 1.31b: + * - States with Action End now have a unique trait to them where if the caster + * of the state is the current active battler (subject) and if the state is + * then applied on the user itself, they will gain a 'free turn'. The 'free + * turn' is to mitigate the user from losing 1 duration of the turn since with + * an Action End timing, they would lose the benefit of being under the state + * for that turn's timing. + * - Added failsafes for Free Turns in case other plugins have overwritten the + * on battle start functions. + * - Added a compatibility update to Animated SV Enemies for dead motion. + * + * Version 1.30: + * - Optimization update. + * - Fixed a bug that prevented added state effects be unable to apply if they + * are an added Death state. + * - Battlelog lines are now able to display text codes. + * + * Version 1.29: + * - Fixed a bug with the 'else if' action sequences not working in the right + * order of sequence conditions. + * + * Version 1.28d: + * - Fixed a bug if instant casting a skill that would make an opponent battler + * to force an action to end incorrectly. Thanks to DoubleX for the fix. + * - Fixed a bug with mouse over not working properly. + * - Fixed a bug regarding forced actions that will cause the battle to freeze + * if the forced action causes the main active subject to leave the battle. + * - Fixed a bug with timed states not updating their turns properly. + * - Changed priority of IF action sequences to higher to no longer interfere + * other action sequences. + * + * Version 1.27: + * - Mechanic change. This will only affect those using turn-based state timing + * mechanics. Turn End state updates are now shifted from Turn End to occur at + * Regeneration timing to have a more synchronized aspect. The timings are very + * close so there's next to no notice in difference. Buff turn updates are also + * moved to the regeneration timing, too. + * + * Version 1.26: + * - Added 'Mouse Over' parameter to Selection Help. This parameter enables + * mouse users to simply hover over the enemy to select them rather than having + * to click an enemy twice to select them. + * + * Version 1.25f: + * - Added failsafes for Forced Action queues. + * - Added 'Show Select Box' parameter when selecting enemies. + * - Fixed a bug that caused End Turn events to not function properly. + * - Battle animations, by default, are positioned relative to the base bitmap + * for its target sprite. However, actor sprites do not have a base bitmap and + * therefore, battle animations, regardless of position, will always target the + * actor sprite's feet. This update now gives actor sprites a base bitmap. + * - Readjusted sprite width and sprite height calculations. + * - Added a failsafe for when no sideview actor graphics are used. + * + * Version 1.24: + * - Implemented a Forced Action queue list. This means if a Forced Action + * takes place in the middle of an action, the action will resume after the + * forced action finishes rather than cancels it out like MV does. + * + * Version 1.23: + * - Fixed a bug that didn't regenerate HP/MP/TP properly for tick-based. + * + * Version 1.22: + * - Fixed a bug within MV that caused Forced Actions at Turn End to prompt and + * trigger all turn-end related activities (such as regeneration and state turn + * updating). + * - Made a mechanic change so that Action Start and Action End state turns do + * not update their turns through forced actions. + * + * Version 1.21: + * - Fixed a bug where states Action End weren't going down properly with DTB. + * + * Version 1.20: + * - Fixed a bug where revived actors using instant cast aren't properly set to + * use actions immediately. + * + * Version 1.19: + * - Added notetag for enemies. + * - Added 'AI Self Turns' for Tick-Based Battles. Enemies can now have their + * A.I. revolve around their own individual turns rather than the battle's. + * - Mechanic change for states. Following suit with the change to Action End + * removal, there are now two more conditions added: Action Start, Turn Start. + * - Added , , , and + * notetags for automatic state removal. + * + * Version 1.18: + * - Fixed a bug with irregular targeting scopes. + * - Fixed an MV-related bug with Recover All event not refreshing battlers. + * + * Version 1.17b: + * - Fixed a bug with action end states to remove multiple at once. + * - Fixed a visual error with flinching sprites. + * - Added 'Current Max' parameter to change HP current/max display in battle. + * - Mechanic change for states that update on Action End to end at the end of + * a battler's turn instead of at the start. + * - Began preparations for another battle system. + * + * Version 1.16: + * - Fixed an issue with mirrored enemies having mirrored state icons. + * + * Version 1.15a: + * - Fixed a bug revolving the status window not updating. + * - Updated default home position formula to better fit other party sizes. + * New Home Position X: + * screenWidth - 16 - (maxSize + 2) * 32 + index * 32 + * New Home Position Y: + * screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 16 + * + * Version 1.14: + * - Fixed a bug with Forced Actions locking out the battle. + * - New mechanic: For tick-based battle systems, states with action-end will + * go down in turns based on how many actions took place for the actor instead. + * Previously, they were indistinguishable from states with Turn End removal. + * - New mechanic: Using Instant Skills/Items from YEP_InstantCast.js will also + * cause states with action-end to go down in turns upon using actions. + * + * Version 1.13a: + * - Fixed a bug that made battlebacks disappear. + * - Reworked visual enemy selection. + * - Victory phase doesn't immediately display level up changes in battle + * status window. + * - Fixed a bug with the visual enemy select showing dead enemy names. + * + * Version 1.12b: + * - If the Battle HUD has been hidden for whatever reason during the victory + * sequence, it will be returned. + * - Added and notetags to break past editor limits. + * - Added new conditions where the battle won't end until all action sequences + * have been fulfilled. + * + * Version 1.11: + * - Fixed a bug that didn't show HP/MP Regeneration. + * + * Version 1.10: + * - Removed immortal state dependancy. Immortality is now its own setting. + * - Added more abbreviated variables for action speed calculation. + * - Fixed a bug where all-scope attacks would reveal Appear-Halfway enemies. + * - Fixed a bug where the battle wouldn't end if the final enemy was killed + * by state damage. + * + * Version 1.09: + * - Fixed a undefined actor bug for refreshing the status window. + * - Added 'Show Shadows' parameter to the plugin settings. + * - Reworked the default action sequences so that forced actions do not appear + * on top of each other and party-heal animations occur simultaneously. + * + * Version 1.08: + * - Fixed a bug where battlers gaining HP/MP in the damage formula for + * themselves wouldn't trigger popups. + * - Fixed a bug where if the party failed to escape from battle, states that + * would be removed by battle still get removed. *Fixed by Emjenoeg* + * - Fixed a bug where instant death skills didn't work. + * - Changed Sprite Priority settings to decide whether actors, enemies, or + * neither would always be on top. + * + * Version 1.07: + * - Optimized status window to refresh at a minimum. + * - Set up frame work for future plugins: + * - Added 'Escape Ratio' and 'Fail Escape Boost' to parameters to allow users + * to set the escape ratio they want. + * - Added 'Front Sprite Priority' and 'Side Sprite Priority' to parameters to + * dictate if actor sprites are always on top. + * - Added 'Tick-Settings' category for tick-based battle systems. + * + * Version 1.06: + * - Fixed a bug that causes dead actors at the start of battle to not spawn. + * - Fixed a bug where the help window on an empty slot would show the + * previous skill's message. + * + * Version 1.05: + * - Added new target typing: Character X, which allows you to select + * specifically the actor with an actor ID of X if he/she/it is in the party. + * - Fixed a bug that prevented Miss and Evade popups from showing. + * + * Version 1.04: + * - Fixed a bug where popups didn't show under certain animation types. + * - Fixed certain battler motions from not refreshing correctly. + * - Actions with no scope will not trigger the confirmation selection window. + * + * Version 1.03: + * - Added 'Wait for Effect' action sequence. + * - Actions now wait for effects (such as collapsing) to be done before + * continuing on with battle or to end battle. + * + * Version 1.02: + * - Fixed a bug where the help window would retain descriptions on no skills. + * - Synched up weapons with actor sprites so they would occur simultaneously. + * - Fixed an issue where requesting certain motions from enemies that don't + * exist would cause them to crash. + * + * Version 1.01: + * - Skills and items that affect both HP and MP will now show popups for both. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_BattleEngineCore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.BECSystem = String(Yanfly.Parameters['Default System']); +Yanfly.Param.BECEscRatio = String(Yanfly.Parameters['Escape Ratio']); +Yanfly.Param.BECEscFail = String(Yanfly.Parameters['Fail Escape Boost']); +Yanfly.Param.CastCertHit = Number(Yanfly.Parameters['Certain Hit Animation']); +Yanfly.Param.CastPhysical = Number(Yanfly.Parameters['Physical Animation']); +Yanfly.Param.CastMagical = Number(Yanfly.Parameters['Magical Animation']); +Yanfly.Param.EnemyAtkAni = Number(Yanfly.Parameters['Enemy Attack Animation']); +Yanfly.Param.BECOptSpeed = String(Yanfly.Parameters['Optimize Speed']); +Yanfly.Param.BECOptSpeed = eval(Yanfly.Param.BECOptSpeed); +Yanfly.Param.BECEmergeText = String(Yanfly.Parameters['Show Emerge Text']); +Yanfly.Param.BECEmergeText = eval(Yanfly.Param.BECEmergeText); +Yanfly.Param.BECPreEmpText = String(Yanfly.Parameters['Show Pre-Emptive Text']); +Yanfly.Param.BECPreEmpText = eval(Yanfly.Param.BECPreEmpText); +Yanfly.Param.BECSurpText = String(Yanfly.Parameters['Show Surprise Text']); +Yanfly.Param.BECSurpText = eval(Yanfly.Param.BECSurpText); +Yanfly.Param.BECPopupOverlap = String(Yanfly.Parameters['Popup Overlap Rate']); +Yanfly.Param.BECPopupOverlap = eval(Yanfly.Param.BECPopupOverlap); +Yanfly.Param.BECNewPopBottom = String(Yanfly.Parameters['Newest Popup Bottom']); +Yanfly.Param.BECNewPopBottom = eval(Yanfly.Param.BECNewPopBottom); +Yanfly.Param.BECStartActCmd = String(Yanfly.Parameters['Start Actor Command']); +Yanfly.Param.BECStartActCmd = eval(Yanfly.Param.BECStartActCmd); +Yanfly.Param.BECCurMax = eval(String(Yanfly.Parameters['Current Max'])); +Yanfly.Param.BECSelectHelp = String(Yanfly.Parameters['Select Help Window']); +Yanfly.Param.BECSelectHelp = eval(Yanfly.Param.BECSelectHelp); +Yanfly.Param.BECHelpUserTx = String(Yanfly.Parameters['User Help Text']); +Yanfly.Param.BECHelpAllyTx = String(Yanfly.Parameters['Ally Help Text']); +Yanfly.Param.BECHelpAlliesTx = String(Yanfly.Parameters['Allies Help Text']); +Yanfly.Param.BECHelpEnemyTx = String(Yanfly.Parameters['Enemy Help Text']); +Yanfly.Param.BECHelpEnemiesTx = String(Yanfly.Parameters['Enemies Help Text']); +Yanfly.Param.BECHelpAllTx = String(Yanfly.Parameters['All Help Text']); +Yanfly.Param.BECHelpRandTx = String(Yanfly.Parameters['Random Help Text']); +Yanfly.Param.BECFrontPosX = String(Yanfly.Parameters['Front Position X']); +Yanfly.Param.BECFrontPosY = String(Yanfly.Parameters['Front Position Y']); +Yanfly.Param.BECFrontSprite = String(Yanfly.Parameters['Front Actor Sprite']); +Yanfly.Param.BECFrontSprite = eval(Yanfly.Param.BECFrontSprite); +Yanfly.Param.BECFrSpPrio = String(Yanfly.Parameters['Front Sprite Priority']); +Yanfly.Param.BECHomePosX = String(Yanfly.Parameters['Home Position X']); +Yanfly.Param.BECHomePosY = String(Yanfly.Parameters['Home Position Y']); +Yanfly.Param.BECSideSpPrio = String(Yanfly.Parameters['Side Sprite Priority']); +Yanfly.Param.BECSideSpPrio = eval(Yanfly.Param.BECSideSpPrio); +Yanfly.Param.BECAnchorX = Number(Yanfly.Parameters['Default X Anchor']); +Yanfly.Param.BECAnchorY = Number(Yanfly.Parameters['Default Y Anchor']); +Yanfly.Param.BECStepDist = Number(Yanfly.Parameters['Step Distance']); +Yanfly.Param.BECFlinchDist = Number(Yanfly.Parameters['Flinch Distance']); +Yanfly.Param.BECShowShadows = String(Yanfly.Parameters['Show Shadows']); +Yanfly.Param.BECShowShadows = eval(Yanfly.Param.BECShowShadows); +Yanfly.Param.BECPopupDur = Number(Yanfly.Parameters['Popup Duration']); +Yanfly.Param.BECCritPopup = String(Yanfly.Parameters['Critical Popup']); +Yanfly.Param.BECCritDur = Number(Yanfly.Parameters['Critical Duration']); +Yanfly.Param.BECActionSpeed = String(Yanfly.Parameters['Action Speed']); +Yanfly.Param.BECReflectAni = Number(Yanfly.Parameters['Reflect Animation']); +Yanfly.Param.BECMotionWait = String(Yanfly.Parameters['Motion Waiting']); +Yanfly.Param.BECMotionWait = eval(Yanfly.Param.BECMotionWait); +Yanfly.Param.BECTimeStates = String(Yanfly.Parameters['Timed States']); +Yanfly.Param.BECTimeStates = eval(Yanfly.Param.BECTimeStates); +Yanfly.Param.BECTimeBuffs = String(Yanfly.Parameters['Timed Buffs']); +Yanfly.Param.BECTimeBuffs = eval(Yanfly.Param.BECTimeBuffs); +Yanfly.Param.BECTurnTime = Number(Yanfly.Parameters['Turn Time']); +Yanfly.Param.BECAISelfTurn = eval(String(Yanfly.Parameters['AI Self Turns'])); +Yanfly.Param.BECLowerWindows = String(Yanfly.Parameters['Lower Windows']); +Yanfly.Param.BECLowerWindows = eval(Yanfly.Param.BECLowerWindows); +Yanfly.Param.BECSelectMouseOver = eval(String(Yanfly.Parameters['Mouse Over'])); +Yanfly.Param.BECEnemySelect = String(Yanfly.Parameters['Visual Enemy Select']); +Yanfly.Param.BECEnemySelect = eval(Yanfly.Param.BECEnemySelect); +Yanfly.Param.BECActorSelect = String(Yanfly.Parameters['Visual Actor Select']); +Yanfly.Param.BECActorSelect = eval(Yanfly.Param.BECActorSelect); +Yanfly.Param.BECWindowRows = Number(Yanfly.Parameters['Window Rows']); +Yanfly.Param.BECEnemyFontSize = Number(Yanfly.Parameters['Enemy Font Size']); +Yanfly.Param.BECShowEnemyName = String(Yanfly.Parameters['Show Enemy Name']); +Yanfly.Param.BECShowEnemyName = eval(Yanfly.Param.BECShowEnemyName); +Yanfly.Param.BECShowSelectBox = String(Yanfly.Parameters['Show Select Box']); +Yanfly.Param.BECShowSelectBox = eval(Yanfly.Param.BECShowSelectBox); +Yanfly.Param.BECEnemyAutoSel = String(Yanfly.Parameters['Enemy Auto Select']); +Yanfly.Param.BECEnemyAutoSel = Yanfly.Param.BECEnemyAutoSel; +Yanfly.Param.BECCommandAlign = String(Yanfly.Parameters['Command Alignment']); +Yanfly.Param.BECCommandRows = Number(Yanfly.Parameters['Command Window Rows']); +Yanfly.Param.BECAniBaseDel = Number(Yanfly.Parameters['Animation Base Delay']); +Yanfly.Param.BECAniNextDel = Number(Yanfly.Parameters['Animation Next Delay']); + +Yanfly.Param.BECFullActText = String(Yanfly.Parameters['Show Action Text']); +Yanfly.Param.BECFullActText = eval(Yanfly.Param.BECFullActText); +Yanfly.Param.BECShowCntText = String(Yanfly.Parameters['Show Counter Text']); +Yanfly.Param.BECShowCntText = eval(Yanfly.Param.BECShowCntText); +Yanfly.Param.BECShowRflText = String(Yanfly.Parameters['Show Reflect Text']); +Yanfly.Param.BECShowRflText = eval(Yanfly.Param.BECShowRflText); +Yanfly.Param.BECShowSubText = String(Yanfly.Parameters['Show Substitute Text']); +Yanfly.Param.BECShowSubText = eval(Yanfly.Param.BECShowSubText); +Yanfly.Param.BECShowFailText = String(Yanfly.Parameters['Show Fail Text']); +Yanfly.Param.BECShowFailText = eval(Yanfly.Param.BECShowFailText); +Yanfly.Param.BECShowCritText = String(Yanfly.Parameters['Show Critical Text']); +Yanfly.Param.BECShowCritText = eval(Yanfly.Param.BECShowCritText); +Yanfly.Param.BECShowMissText = String(Yanfly.Parameters['Show Miss Text']); +Yanfly.Param.BECShowMissText = eval(Yanfly.Param.BECShowMissText); +Yanfly.Param.BECShowEvaText = String(Yanfly.Parameters['Show Evasion Text']); +Yanfly.Param.BECShowEvaText = eval(Yanfly.Param.BECShowEvaText); +Yanfly.Param.BECShowHpText = String(Yanfly.Parameters['Show HP Text']); +Yanfly.Param.BECShowHpText = eval(Yanfly.Param.BECShowHpText); +Yanfly.Param.BECShowMpText = String(Yanfly.Parameters['Show MP Text']); +Yanfly.Param.BECShowMpText = eval(Yanfly.Param.BECShowMpText); +Yanfly.Param.BECShowTpText = String(Yanfly.Parameters['Show TP Text']); +Yanfly.Param.BECShowTpText = eval(Yanfly.Param.BECShowTpText); +Yanfly.Param.BECShowStateText = String(Yanfly.Parameters['Show State Text']); +Yanfly.Param.BECShowStateText = eval(Yanfly.Param.BECShowStateText); +Yanfly.Param.BECShowBuffText = String(Yanfly.Parameters['Show Buff Text']); +Yanfly.Param.BECShowBuffText = eval(Yanfly.Param.BECShowBuffText); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.BEC.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.BEC.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_BattleEngineCore) { + this.processMELODYNotetags($dataSkills); + this.processMELODYNotetags($dataItems); + this.processBECNotetags1($dataSkills); + this.processBECNotetags2($dataSkills); + this.processBECNotetags2($dataItems); + this.processBECNotetags3($dataEnemies); + this.processBECNotetags4($dataActors); + this.processBECNotetags4($dataClasses); + this.processBECNotetags4($dataWeapons); + this.processBECNotetags4($dataArmors); + this.processBECNotetags4($dataEnemies); + this.processBECNotetags4($dataStates); + this.processBECNotetags5($dataActors, true); + this.processBECNotetags5($dataClasses, false); + this.processBECNotetags5($dataWeapons, false); + this.processBECNotetags5($dataArmors, false); + this.processBECNotetags5($dataStates, false); + this.processBECNotetags6($dataStates); + Yanfly._loaded_YEP_BattleEngineCore = true; + } + return true; +}; + +DataManager.processMELODYNotetags = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + if (obj.actionsMade) continue; + obj.actionsMade = true; + var notedata = obj.note.split(/[\r\n]+/); + + var actionType = 0; + this.setDefaultActions(obj); + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SETUP ACTION|setup)>/i)) { + actionType = 1; + obj.setupActions = []; + } else if (line.match(/<\/(?:SETUP ACTION|setup)>/i)) { + var actionType = 0; + } else if (line.match(/<(?:WHOLE ACTION|whole)>/i)) { + actionType = 2; + obj.wholeActions = []; + } else if (line.match(/<\/(?:WHOLE ACTION|whole)>/i)) { + var actionType = 0; + } else if (line.match(/<(?:TARGET ACTION|target)>/i)) { + actionType = 3; + obj.targetActions = []; + } else if (line.match(/<\/(?:TARGET ACTION|target)>/i)) { + var actionType = 0; + } else if (line.match(/<(?:FOLLOW ACTION|follow)>/i)) { + actionType = 4; + obj.followActions = []; + } else if (line.match(/<\/(?:FOLLOW ACTION|follow)>/i)) { + var actionType = 0; + } else if (line.match(/<(?:FINISH ACTION|finish)>/i)) { + actionType = 5; + obj.finishActions = []; + } else if (line.match(/<\/(?:FINISH ACTION|finish)>/i)) { + var actionType = 0; + } else { + this.convertSequenceLine(obj, line, actionType); + } + } + } +}; + +Yanfly.BEC.DefaultActionSetup = [ + ['CLEAR BATTLE LOG'], + ['DISPLAY ACTION'], + ['IMMORTAL', ['TARGETS', 'TRUE']], + ['PERFORM START'], + ['WAIT FOR MOVEMENT'], + ['CAST ANIMATION'], + ['WAIT FOR ANIMATION'] +]; +Yanfly.BEC.DefaultActionWhole = [ + ['PERFORM ACTION'], +]; +Yanfly.BEC.DefaultActionTarget = [ + ['PERFORM ACTION'], +]; +if (Yanfly.Param.BECMotionWait) { + Yanfly.BEC.DefaultActionWhole.push(['MOTION WAIT', ['USER']]); + Yanfly.BEC.DefaultActionTarget.push(['MOTION WAIT', ['USER']]); +} else { + Yanfly.BEC.DefaultActionWhole.push(['WAIT', [10]]); + Yanfly.BEC.DefaultActionTarget.push(['WAIT', [10]]); +}; +Yanfly.BEC.DefaultActionWhole.push(['ACTION ANIMATION']); +Yanfly.BEC.DefaultActionWhole.push(['WAIT FOR ANIMATION']); +Yanfly.BEC.DefaultActionTarget.push(['ACTION ANIMATION']); +Yanfly.BEC.DefaultActionTarget.push(['WAIT FOR ANIMATION']); +Yanfly.BEC.DefaultActionFollow = [ +]; +Yanfly.BEC.DefaultActionFinish = [ + ['IMMORTAL', ['TARGETS', 'FALSE']], + ['WAIT FOR NEW LINE'], + ['CLEAR BATTLE LOG'], + ['PERFORM FINISH'], + ['WAIT FOR MOVEMENT'], + ['WAIT FOR EFFECT'], + ['ACTION COMMON EVENT'], +]; +DataManager.setDefaultActions = function(obj) { + obj.setupActions = Yanfly.BEC.DefaultActionSetup.slice(); + if (this.isWholeAction(obj)) { + obj.wholeActions = Yanfly.BEC.DefaultActionWhole.slice(); + this.addActionEffects(obj, obj.wholeActions); + obj.targetActions = []; + } else { + obj.wholeActions = []; + obj.targetActions = Yanfly.BEC.DefaultActionTarget.slice(); + this.addActionEffects(obj, obj.targetActions); + } + obj.followActions = Yanfly.BEC.DefaultActionFollow.slice(); + obj.finishActions = Yanfly.BEC.DefaultActionFinish.slice(); +}; + +DataManager.isWholeAction = function(obj) { + if (obj.animationId > 0 && $dataAnimations[obj.animationId]) { + var animation = $dataAnimations[obj.animationId]; + if (animation.position === 3) return true; + if (animation.position !== 3 && [2, 8, 10].contains(obj.scope)) return true; + } + return false; +}; + +DataManager.addActionEffects = function(obj, array) { + for (;;) { + array[array.length] = ['ACTION EFFECT']; + array[array.length] = ['DEATH BREAK']; + obj.repeats -= 1; + if (obj.repeats <= 0) break; + array[array.length] = ['WAIT', [8]]; + } + obj.repeats = 1; +}; + +DataManager.convertSequenceLine = function(obj, line, actionType) { + if (actionType <= 0 || actionType > 5) return; + Yanfly.BEC.SeqType; + var seqArgs; + if (line.match(/[ ]*(.*):[ ](.*)/i)) { + Yanfly.BEC.SeqType = RegExp.$1.trim(); + seqArgs = RegExp.$2.split(','); + var length = seqArgs.length; + for (var i = 0; i < length; ++i) { + seqArgs[i] = seqArgs[i].trim(); + } + } else { + Yanfly.BEC.SeqType = line.trim(); + seqArgs = []; + } + var array = [Yanfly.BEC.SeqType, seqArgs]; + if (actionType === 1) obj.setupActions[obj.setupActions.length] = array; + if (actionType === 2) obj.wholeActions[obj.wholeActions.length] = array; + if (actionType === 3) obj.targetActions[obj.targetActions.length] = array; + if (actionType === 4) obj.followActions[obj.followActions.length] = array; + if (actionType === 5) obj.finishActions[obj.finishActions.length] = array; +}; + +DataManager.processBECNotetags1 = function(group) { + var note1 = /<(?:CAST ANIMATION|cast ani):[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.castAnimation = 0; + if (obj.hitType === 0) obj.castAnimation = Yanfly.Param.CastCertHit; + if (obj.hitType === 1) obj.castAnimation = Yanfly.Param.CastPhysical; + if (obj.hitType === 2) obj.castAnimation = Yanfly.Param.CastMagical; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + obj.castAnimation = parseInt(RegExp.$1); + } + } + } +}; + +DataManager.processBECNotetags2 = function(group) { + var note1 = /<(?:ACTION COPY):[ ](.*):[ ]*(\d+)>/i; + var note2 = /<(?:SPEED):[ ]([\+\-]\d+)>/i; + var note3 = /<(?:DISPLAY NAME|DISPLAY TEXT):[ ](.*)>/i; + var note4 = /<(?:DISPLAY ICON):[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.battleDisplayText = obj.name; + obj.battleDisplayIcon = obj.iconIndex; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + var text = String(RegExp.$1).toUpperCase(); + var target; + if (['I', 'ITEM'].contains(text)) { + target = $dataItems[parseInt(RegExp.$2)]; + } else if (['S', 'SKILL'].contains(text)) { + target = $dataSkills[parseInt(RegExp.$2)]; + } + if (target) { + obj.setupActions = target.setupActions.slice(); + obj.wholeActions = target.wholeActions.slice(); + obj.targetActions = target.targetActions.slice(); + obj.followActions = target.followActions.slice(); + obj.finishActions = target.finishActions.slice(); + } + } else if (line.match(note2)) { + obj.speed = parseInt(RegExp.$1); + } else if (line.match(note3)) { + obj.battleDisplayText = String(RegExp.$1); + } else if (line.match(note4)) { + obj.battleDisplayIcon = parseInt(RegExp.$1); + } + } + } +}; + +DataManager.processBECNotetags3 = function(group) { + var note1 = /<(?:ATTACK ANIMATION|attack ani):[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.attackAnimationId = Yanfly.Param.EnemyAtkAni; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + obj.attackAnimationId = parseInt(RegExp.$1); + } + } + } +}; + +DataManager.processBECNotetags4 = function(group) { + var note1 = /<(?:REFLECT ANIMATION|reflect ani):[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.reflectAnimationId = 0; + obj.spriteCannotMove = false; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + obj.reflectAnimationId = parseInt(RegExp.$1); + } else if (line.match(/<(?:SPRITE CANNOT MOVE)>/i)) { + obj.spriteCannotMove = true; + } + } + } +}; + +DataManager.processBECNotetags5 = function(group, isActor) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + if (isActor) { + obj.anchorX = Yanfly.Param.BECAnchorX; + obj.anchorY = Yanfly.Param.BECAnchorY; + } + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:ANCHOR X):[ ](\d+)[.](\d+)>/i)) { + obj.anchorX = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + } else if (line.match(/<(?:ANCHOR Y):[ ](\d+)[.](\d+)>/i)) { + obj.anchorY = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + } + } + } +}; + +DataManager.processBECNotetags6 = function(group) { + var note1a = /<(?:ACTION START):[ ](\d+)>/i; + var note1b = /<(?:ACTION START):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i; + var note2a = /<(?:TURN START):[ ](\d+)>/i; + var note2b = /<(?:TURN START):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1a)) { + var turns = parseInt(RegExp.$1); + obj.autoRemovalTiming = 3; + obj.maxTurns = turns; + obj.minTurns = turns; + } else if (line.match(note1b)) { + var turns1 = parseInt(RegExp.$1); + var turns2 = parseInt(RegExp.$2); + obj.autoRemovalTiming = 3; + obj.maxTurns = turns1; + obj.minTurns = turns2; + } else if (line.match(note2a)) { + var turns = parseInt(RegExp.$1); + obj.autoRemovalTiming = 4; + obj.maxTurns = turns; + obj.minTurns = turns; + } else if (line.match(note2b)) { + var turns1 = parseInt(RegExp.$1); + var turns2 = parseInt(RegExp.$2); + obj.autoRemovalTiming = 4; + obj.maxTurns = turns1; + obj.minTurns = turns2; + } + } + } +}; + +//============================================================================= +// TouchInput +//============================================================================= + +Yanfly.BEC.TouchInput_onMouseMove = TouchInput._onMouseMove; +TouchInput._onMouseMove = function(event) { + Yanfly.BEC.TouchInput_onMouseMove.call(this, event); + this._mouseOverX = Graphics.pageToCanvasX(event.pageX); + this._mouseOverY = Graphics.pageToCanvasY(event.pageY); +}; + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.BEC.BattleManager_initMembers = BattleManager.initMembers; +BattleManager.initMembers = function() { + Yanfly.BEC.BattleManager_initMembers.call(this); + this._forceSelection = false; + this._allSelection = false; + this._victoryPhase = false; + this._forceActionQueue = []; +}; + +BattleManager.isBattleSystem = function(value) { + return value.toLowerCase() === $gameSystem.getBattleSystem(); +}; + +BattleManager.isDTB = function() { + return this.isBattleSystem('dtb'); +}; + +BattleManager.isTurnBased = function() { + if (this.isDTB()) return true; + return false; +}; + +BattleManager.isTickBased = function() { + return !this.isTurnBased(); +}; + +BattleManager.tickRate = function() { + return 1; +}; + +BattleManager.forceSelection = function() { + this._forceSelection = true; +}; + +BattleManager.isForceSelection = function() { + return this._forceSelection; +}; + +BattleManager.resetSelection = function() { + this._forceSelection = false; +}; + +BattleManager.startAllSelection = function() { + this._allSelection = true; +}; + +BattleManager.isAllSelection = function() { + return this._allSelection && BattleManager.isInputting(); +}; + +BattleManager.stopAllSelection = function() { + this._allSelection = false; +}; + +Yanfly.BEC.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio; +BattleManager.makeEscapeRatio = function() { + if (this.isDTB()) { + var code = Yanfly.Param.BECEscRatio; + try { + this._escapeRatio = eval(code); + } catch (e) { + this._escapeRatio = 0; + Yanfly.Util.displayError(e, code, 'ESCAPE RATIO FORMULA ERROR'); + } + var code = Yanfly.Param.BECEscFail; + try { + this._escapeFailBoost = eval(code); + } catch (e) { + this._escapeFailBoost = 0; + Yanfly.Util.displayError(e, code, 'ESCAPE FAIL BOOST FORMULA ERROR'); + } + } else { + this._escapeFailBoost = 0.1; + Yanfly.BEC.BattleManager_makeEscapeRatio.call(this); + } +}; + +BattleManager.timeBasedStates = function() { + if (!$gameParty.inBattle()) return false; + if (this.isTurnBased()) return false; + if (this._timeBasedStates !== undefined) return this._timeBasedStates; + this._timeBasedStates = Yanfly.Param.BECTimeStates; + return this._timeBasedStates; +}; + +BattleManager.timeBasedBuffs = function() { + if (!$gameParty.inBattle()) return false; + if (this.isTurnBased()) return false; + if (this._timeBasedBuffs !== undefined) return this._timeBasedBuffs; + this._timeBasedBuffs = Yanfly.Param.BECTimeBuffs; + return this._timeBasedBuffs; +}; + +BattleManager.displayStartMessages = function() { + if (Yanfly.Param.BECEmergeText) { + $gameTroop.enemyNames().forEach(function(name) { + $gameMessage.add(TextManager.emerge.format(name)); + }); + } + if (this._preemptive && Yanfly.Param.BECPreEmpText) { + $gameMessage.add(TextManager.preemptive.format($gameParty.name())); + } else if (this._surprise && Yanfly.Param.BECSurpText) { + $gameMessage.add(TextManager.surprise.format($gameParty.name())); + } +}; + +BattleManager.registerSprite = function(battler, sprite) { + if (!this._registeredSprites) this._registeredSprites = {}; + if (battler.isActor()) var id = 100000 + battler.actorId(); + if (battler.isEnemy()) var id = 200000 + battler.index(); + this._registeredSprites[id] = sprite; +}; + +BattleManager.getSprite = function(battler) { + if (!this._registeredSprites) this._registeredSprites = {}; + if (battler.isActor()) var id = 100000 + battler.actorId(); + if (battler.isEnemy()) var id = 200000 + battler.index(); + return this._registeredSprites[id]; +}; + +BattleManager.setSpritePriority = function() { + if ($gameSystem.isSideView()) { + this._spritePriority = Yanfly.Param.BECSideSpPrio; + } else { + this._spritePriority = Yanfly.Param.BECFrontSprite; + } + if (this._spritePriority === false) this._spritePriority = 0; + if (this._spritePriority === true) this._spritePriority = 1; +}; + +BattleManager.getSpritePriority = function() { + if (!this._spritePriority) this.setSpritePriority(); + return this._spritePriority; +}; + +BattleManager.changeActor = function(newActorIndex, lastActorActionState) { + var lastActor = this.actor(); + this._actorIndex = newActorIndex; + var newActor = this.actor(); + if (lastActor) { + lastActor.setActionState(lastActorActionState); + lastActor.spriteReturnHome(); + } + if (newActor) { + newActor.setActionState('inputting'); + newActor.spriteStepForward(); + } +}; + +BattleManager.createActions = function() { + $gameParty.createActions(); + $gameTroop.createActions(); +}; + +BattleManager.clearInputtingAction = function() { + if (this.inputtingAction()) this.inputtingAction().clear(); +}; + +Yanfly.BEC.BattleManager_checkBattleEnd = BattleManager.checkBattleEnd; +BattleManager.checkBattleEnd = function() { + if (this._phase === 'actionList') return false; + if (this._phase === 'actionTargetList') return false; + if (this._phase === 'action') return false; + if (this._phase === 'phaseChange') return false; + if ($gameTroop.isEventRunning()) return false; + return Yanfly.BEC.BattleManager_checkBattleEnd.call(this); +}; + +Yanfly.BEC.BattleManager_processTurn = BattleManager.processTurn; +BattleManager.processTurn = function() { + this._processTurn = true; + Yanfly.BEC.BattleManager_processTurn.call(this); + this._processTurn = false; +}; + +Yanfly.BEC.BattleManager_processVictory = BattleManager.processVictory; +BattleManager.processVictory = function() { + this._logWindow.clear(); + this._victoryPhase = true; + if (this._windowLayer) this._windowLayer.x = 0; + Yanfly.BEC.BattleManager_processVictory.call(this); +}; + +BattleManager.processEscape = function() { + $gameParty.performEscape(); + SoundManager.playEscape(); + var success = this._preemptive ? true : (Math.random() < this._escapeRatio); + if ($gamePlayer.isDebugThrough()) success = true; + if (success) { + $gameParty.performEscapeSuccess(); + this.displayEscapeSuccessMessage(); + this._escaped = true; + this.processAbort(); + } else { + this.displayEscapeFailureMessage(); + this._escapeRatio += this._escapeFailBoost; + $gameParty.clearActions(); + this.startTurn(); + } + return success; +}; + +Yanfly.BEC.BattleManager_processAbort = BattleManager.processAbort; +BattleManager.processAbort = function() { + $gameParty.removeBattleStates(); + Yanfly.BEC.BattleManager_processAbort.call(this); +}; + +BattleManager.refreshAllMembers = function() { + $gameParty.refreshMembers(); + $gameTroop.refreshMembers(); +}; + +BattleManager.startTurn = function() { + this._enteredEndPhase = false; + this._phase = 'turn'; + this.clearActor(); + $gameTroop.increaseTurn(); + $gameParty.onTurnStart(); + $gameTroop.onTurnStart(); + this._performedBattlers = []; + this.makeActionOrders(); + $gameParty.requestMotionRefresh(); + this._logWindow.startTurn(); + this._subject = this.getNextSubject(); +}; + +Yanfly.BEC.BattleManager_endTurn = BattleManager.endTurn; +BattleManager.endTurn = function() { + if (this.isTurnBased() && this._spriteset.isPopupPlaying()) return; + if (this.isTurnBased() && this._enteredEndPhase) { + this._phase = 'turnEnd'; + this._preemptive = false; + this._surprise = false; + return; + } + this._enteredEndPhase = true; + Yanfly.BEC.BattleManager_endTurn.call(this); + BattleManager.refreshAllMembers(); +}; + +BattleManager.getNextSubject = function() { + if ($gameTroop.turnCount() <= 0) return; + this._performedBattlers = this._performedBattlers || []; + this.makeActionOrders(); + for (;;) { + var battlerArray = []; + for (var i = 0; i < this._actionBattlers.length; ++i) { + var obj = this._actionBattlers[i]; + if (!this._performedBattlers.contains(obj)) battlerArray.push(obj); + } + this._actionBattlers = battlerArray; + var battler = this._actionBattlers.shift(); + if (!battler) return null; + if (battler.isBattleMember() && battler.isAlive()) { + this.pushPerformedBattler(battler); + return battler; + } + } +}; + +BattleManager.pushPerformedBattler = function(battler) { + this._performedBattlers.push(battler); +}; + +BattleManager.update = function() { + if (!this.isBusy() && !this.updateEvent()) { + switch (this._phase) { + case 'start': + this.startInput(); + break; + case 'turn': + this.updateTurn(); + break; + case 'action': + this.updateAction(); + break; + case 'phaseChange': + this.updatePhase(); + break; + case 'actionList': + this.updateActionList() + break; + case 'actionTargetList': + this.updateActionTargetList() + break; + case 'turnEnd': + this.updateTurnEnd(); + break; + case 'battleEnd': + this.updateBattleEnd(); + break; + } + } +}; + +BattleManager.updateEvent = function() { + if (this._processingForcedAction) return false; + switch (this._phase) { + case 'start': + case 'turn': + case 'turnEnd': + case 'actionList': + case 'actionTargetList': + if (this.isActionForced()) { + this.processForcedAction(); + return true; + } else { + return this.updateEventMain(); + } + } + return this.checkAbort(); +}; + +BattleManager.queueForceAction = function(user, skillId, target) { + if (target === undefined) { + var targetIndex = 0; + } else if (typeof target === 'number') { + var targetIndex = target; + } else { + var targetIndex = target.index(); + } + var param = [ + user.isEnemy() ? 0 : 1, + user.isActor() ? user.actorId() : user.index(), + skillId, + targetIndex + ]; + var command = { + code: 339, + indent: 0, + parameters: param + } + $gameTemp.forceActionQueue(command); + this.clearResults(); + if (this.isTickBased()) this._phase = 'action'; +}; + +BattleManager.addText = function(text, wait) { + if (!SceneManager._scene._logWindow) return; + wait = wait || 0; + SceneManager._scene._logWindow.addText(text); + if (wait <= 0) return; + var last = this._actionList[this._actionList.length - 1]; + if (last && last[0] === 'WAIT') return; + this._actionList.push(['WAIT', [wait]]); +}; + +BattleManager.clearResults = function() { + var group = this.allBattleMembers(); + var length = group.length; + for (var i = 0; i < length; ++i) { + var member = group[i]; + if (member) member.clearResult(); + } + this._allTargets = []; + this._targets = []; + this._target = undefined; +}; + +Yanfly.BEC.BattleManager_forceAction = BattleManager.forceAction; +BattleManager.forceAction = function(battler) { + if (this._subject) this._subject.clearResult(); + this.createForceActionFailSafes(); + this.savePreForceActionSettings(); + Yanfly.BEC.BattleManager_forceAction.call(this, battler); +}; + +BattleManager.createForceActionFailSafes = function() { + this._actionList = this._actionList || []; + this._targets = this._targets || []; + this._allTargets = this._allTargets || []; + this._individualTargets = this._individualTargets || []; + this._phaseSteps = this._phaseSteps || []; + this._conditionFlags = this._conditionFlags || []; + this._trueFlags = this._trueFlags || []; +}; + +BattleManager.savePreForceActionSettings = function() { + var settings = this.setPreForceActionSettings(); + this._forceActionQueue.push(settings); +}; + +BattleManager.setPreForceActionSettings = function() { + return { + subject: this._subject, + action: JsonEx.makeDeepCopy(this._action), + actionList: JsonEx.makeDeepCopy(this._actionList), + targets: this._targets.slice(), + allTargets: this._allTargets.slice(), + indTargets: this._individualTargets.slice(), + phaseSteps: JsonEx.makeDeepCopy(this._phaseSteps), + returnPhase: this._returnPhase, + phase: this._phase, + conditionFlags: JsonEx.makeDeepCopy(this._conditionFlags), + trueFlags: JsonEx.makeDeepCopy(this._trueFlags) + } +}; + +BattleManager.loadPreForceActionSettings = function() { + var settings = this._forceActionQueue[0]; + if (settings) { + this._forceActionQueue.shift(); + this.resetPreForceActionSettings(settings); + return this._subject && this._subject.isAppeared(); + } else { + return false; + } +}; + +BattleManager.resetPreForceActionSettings = function(settings) { + this._subject = settings['subject']; + this._action = settings['action']; + this._actionList = settings['actionList']; + this._targets = settings['targets']; + this._allTargets = settings['allTargets']; + this._individualTargets = settings['indTargets']; + this._phaseSteps = settings['phaseSteps']; + this._returnPhase = settings['returnPhase']; + this._conditionFlags = settings['conditionFlags']; + this._trueFlags = settings['trueFlags']; + this._phase = settings['phase']; +}; + +Yanfly.BEC.BattleManager_processForcedAction = + BattleManager.processForcedAction; +BattleManager.processForcedAction = function() { + if (this._actionForcedBattler) { + this._preForcePhase = this._phase; + this._processingForcedAction = true; + } + Yanfly.BEC.BattleManager_processForcedAction.call(this); +}; + +BattleManager.setTargets = function(array) { + this._targets = []; + var max = array.length; + for (var i = 0; i < max; ++i) { + var target = array[i]; + if (target) this._targets.push(target); + } +}; + +BattleManager.updateAction = function() { + var target = this._targets.shift(); + if (target) { + this.invokeAction(this._subject, target); + } else { + if (this._returnPhase === 'target') { + this.setTargets([this._individualTargets[0]]); + this._phase = 'actionTargetList'; + } else { + this.setTargets(this._allTargets.slice()); + this._phase = 'actionList'; + } + } +}; + +BattleManager.invokeAction = function(subject, target) { + if (!Yanfly.Param.BECOptSpeed) this._logWindow.push('pushBaseLine'); + var normal = true; + if (Math.random() < this._action.itemMrf(target)) { + this.invokeMagicReflection(subject, target); + } else if (Math.random() < this._action.itemCnt(target)) { + this.invokeCounterAttack(subject, target); + } else { + this.invokeNormalAction(subject, target); + } + if (subject) subject.setLastTarget(target); + if (!Yanfly.Param.BECOptSpeed) this._logWindow.push('popBaseLine'); +}; + +BattleManager.invokeCounterAttack = function(subject, target) { + var action = new Game_Action(target); + this._logWindow.displayCounter(target); + action.setAttack(); + action.apply(subject); + this._logWindow.displayActionResults(target, subject); + if (subject.isDead()) subject.performCollapse(); +}; + +Yanfly.BEC.BattleManager_invokeMagicReflection = + BattleManager.invokeMagicReflection; +BattleManager.invokeMagicReflection = function(subject, target) { + Yanfly.BEC.BattleManager_invokeMagicReflection.call(this, subject, target); + if (subject.isDead()) subject.performCollapse(); +}; + +BattleManager.updatePhase = function() { + var phase = this._phaseSteps.shift(); + if (phase) this.createPhaseChanges(); + switch (phase) { + case 'setup': + this.createSetupActions(); + break; + case 'whole': + this.createWholeActions(); + break; + case 'target': + this.createTargetActions(); + break; + case 'follow': + this.createFollowActions(); + break; + case 'finish': + this.createFinishActions(); + break; + default: + this.endAction(); + break; + } +}; + +BattleManager.createPhaseChanges = function() { + this._phase = 'actionList'; + this.setTargets(this._allTargets.slice()); + this._conditionFlags = []; + this._trueFlags = []; +}; + +BattleManager.createSetupActions = function() { + $gameTemp.clearActionSequenceSettings(); + this._returnPhase = 'setup'; + this._actionList = this._action.item().setupActions.slice(); +}; + +BattleManager.createWholeActions = function() { + this._returnPhase = 'whole'; + this._actionList = this._action.item().wholeActions.slice(); +}; + +BattleManager.createTargetActions = function() { + this._returnPhase = 'target'; + this._phase = 'actionTargetList'; + this.setTargets([this._individualTargets[0]]); + this._actionList = this._action.item().targetActions.slice(); +}; + +BattleManager.createFollowActions = function() { + this._returnPhase = 'follow'; + this._actionList = this._action.item().followActions.slice(); +}; + +BattleManager.createFinishActions = function() { + this._returnPhase = 'finish'; + this._actionList = this._action.item().finishActions.slice(); +}; + +Yanfly.BEC.BattleManager_endAction = BattleManager.endAction; +BattleManager.endAction = function() { + if (this._subject) { + this._subject.onAllActionsEnd(); + } + if (this._processingForcedAction) { + this._subject.removeCurrentAction(); + this._phase = this._preForcePhase; + } + this._processingForcedAction = false; + if (this.loadPreForceActionSettings()) return; + Yanfly.BEC.BattleManager_endAction.call(this); +}; + +BattleManager.updateActionList = function() { + for (;;) { + this._actSeq = this._actionList.shift(); + if (this._actSeq) { + if (!this.actionConditionsMet(this._actSeq)) continue; + var seqName = this._actSeq[0].toUpperCase(); + if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) { + break; + } + } else { + this._phase = 'phaseChange'; + break; + } + } +}; + +BattleManager.updateActionTargetList = function() { + for (;;) { + this._actSeq = this._actionList.shift(); + if (this._actSeq) { + if (!this.actionConditionsMet(this._actSeq)) continue; + var seqName = this._actSeq[0].toUpperCase(); + if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) { + break; + } + } else if (this._individualTargets.length > 0) { + this._individualTargets.shift(); + if (this._individualTargets.length > 0) { + this.setTargets([this._individualTargets[0]]); + this._actionList = this._action.item().targetActions.slice(); + } else { + this._phase = 'phaseChange'; + break; + } + } else { + this._phase = 'phaseChange'; + break; + } + } +}; + +BattleManager.updateActionTargetList = function() { + for (;;) { + this._actSeq = this._actionList.shift(); + if (this._actSeq) { + if (!this.actionConditionsMet(this._actSeq)) continue; + var seqName = this._actSeq[0].toUpperCase(); + if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) { + break; + } + } else if (this._individualTargets.length > 0) { + this._individualTargets.shift(); + if (this._individualTargets.length > 0) { + this.setTargets([this._individualTargets[0]]); + this._actionList = this._action.item().targetActions.slice(); + } else { + this._phase = 'phaseChange'; + break; + } + } else { + this._phase = 'phaseChange'; + break; + } + } +}; + +BattleManager.startAction = function() { + var subject = this._subject; + if (!subject) return this.endAction(); + var action = subject.currentAction(); + this._action = action; + if (!this._action) return this.endAction(); + if (!this._action.item()) return this.endAction(); + var targets = action.makeTargets(); + this.setTargets(targets); + this._allTargets = targets.slice(); + this._individualTargets = targets.slice(); + this._phase = 'phaseChange'; + this._phaseSteps = ['setup', 'whole', 'target', 'follow', 'finish']; + this._returnPhase = ''; + this._actionList = []; + subject.useItem(this._action.item()); + this._action.applyGlobal(); + this._logWindow.startAction(this._subject, this._action, this._targets); +}; + +BattleManager.processActionSequenceCheck = function(actionName, actionArgs) { + // IF condition + if (actionName.match(/IF[ ](.*)/i)) { + return this.actionIfConditions(actionName, actionArgs); + } + return this.processActionSequence(actionName, actionArgs) +}; + +BattleManager.processActionSequence = function(actionName, actionArgs) { + // NO ACTION + if (actionName === '') { + return true; + } + // ACTION ANIMATION + if (actionName === 'ACTION ANIMATION') { + return this.actionActionAnimation(actionArgs); + } + // ACTION EFFECT + if (actionName === 'ACTION COMMON EVENT') { + return this.actionActionCommonEvent(); + } + // ACTION EFFECT + if (actionName === 'ACTION EFFECT') { + return this.actionActionEffect(actionArgs); + } + // ANI WAIT: frames + if (['ANI WAIT', 'ANIWAIT', 'ANIMATION WAIT'].contains(actionName)) { + return this.actionAniWait(actionArgs[0]); + } + // CAST ANIMATION + if (actionName === 'CAST ANIMATION') { + return this.actionCastAnimation(); + } + // CLEAR BATTLE LOG + if (actionName === 'CLEAR BATTLE LOG') { + return this.actionClearBattleLog(); + } + // DEATH BREAK + if (actionName === 'DEATH BREAK') { + return this.actionDeathBreak(); + } + // DISPLAY ACTION + if (actionName === 'DISPLAY ACTION') { + return this.actionDisplayAction(); + } + // IMMORTAL: targets, true/false + if (actionName === 'IMMORTAL') { + return this.actionImmortal(actionArgs); + } + // MOTION WAIT + if (actionName === 'MOTION WAIT') { + return this.actionMotionWait(actionArgs); + } + // PERFORM ACTION + if (actionName === 'PERFORM ACTION') { + return this.actionPerformAction(); + } + // PERFORM FINISH + if (actionName === 'PERFORM FINISH') { + return this.actionPerformFinish(); + } + // PERFORM START + if (actionName === 'PERFORM START') { + return this.actionPerformStart(); + } + // WAIT: frames + if (actionName === 'WAIT') { + return this.actionWait(actionArgs[0]); + } + // WAIT FOR ANIMATION + if (actionName === 'WAIT FOR ANIMATION') { + return this.actionWaitForAnimation(); + } + // WAIT FOR EFFECT + if (actionName === 'WAIT FOR EFFECT') { + return this.actionWaitForEffect(); + } + // WAIT FOR MOVEMENT + if (actionName === 'WAIT FOR MOVEMENT') { + return this.actionWaitForMovement(); + } + // WAIT FOR NEW LINE + if (actionName === 'WAIT FOR NEW LINE') { + return this.actionWaitForNewLine(); + } + // WAIT FOR POPUPS + if (actionName === 'WAIT FOR POPUPS') { + return this.actionWaitForPopups(); + } + return false; +}; + +BattleManager.makeActionTargets = function(string) { + var targets = [] + string = string.toUpperCase() + if (['SUBJECT', 'USER'].contains(string)) { + return [this._subject]; + } + if (['TARGET', 'TARGETS'].contains(string)) { + var group = this._targets; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ACTORS', 'EXISTING ACTORS', 'ALIVE ACTORS'].contains(string)) { + var group = $gameParty.aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ACTORS ALL', 'ALL ACTORS', 'PARTY'].contains(string)) { + var group = $gameParty.battleMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['DEAD ACTORS', 'DEAD ACTOR'].contains(string)) { + var group = $gameParty.deadMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target) targets.push(target); + } + return targets; + } + if (['ACTORS NOT USER', 'ACTORS NOT SUBJECT'].contains(string)) { + var group = $gameParty.aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target !== this._subject && target.isAppeared()) { + targets.push(target); + } + } + return targets; + } + if (['ENEMIES', 'EXISTING ENEMIES', 'ALIVE ENEMIES', 'TROOP', + 'TROOPS'].contains(string)) { + var group = $gameTroop.aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ENEMIES ALL', 'ALL ENEMIES'].contains(string)) { + var group = $gameTroop.members(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['DEAD ENEMIES', 'DEAD ENEMY'].contains(string)) { + var group = $gameTroop.deadMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target) targets.push(target); + } + return targets; + } + if (['ENEMIES NOT USER', 'ENEMIES NOT SUBJECT', 'TROOP NOT USER', + 'TROOP NOT SUBJECT'].contains(string)) { + var group = $gameTroop.aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target !== this._subject && target.isAppeared()) { + targets.push(target); + } + } + return targets; + } + if (string.match(/ACTOR[ ](\d+)/i)) { + var target = $gameParty.battleMembers()[parseInt(RegExp.$1)]; + if (target && target.isAppeared()) return [target]; + } + if (string.match(/ENEMY[ ](\d+)/i)) { + var target = $gameTroop.members()[parseInt(RegExp.$1)]; + if (target && target.isAppeared()) return [target]; + } + if (['FRIEND', 'FRIENDS', 'ALLIES'].contains(string)) { + var group = this._action.friendsUnit().aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ALL FRIENDS', 'ALL ALLIES'].contains(string)) { + var group = this._action.friendsUnit().members(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['DEAD FRIEND', 'DEAD FRIENDS', 'DEAD ALLIES'].contains(string)) { + var group = this._action.friendsUnit().deadMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['OPPONENT', 'OPPONENTS', 'RIVALS', 'FOES'].contains(string)) { + var group = this._action.opponentsUnit().aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ALL OPPONENTS', 'ALL RIVALS', 'ALL FOES'].contains(string)) { + var group = this._action.opponentsUnit().members(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['DEAD OPPONENT', 'DEAD OPPONENTS', 'DEAD RIVALS', + 'DEAD FOES'].contains(string)) { + var group = this._action.opponentsUnit().deadMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target) targets.push(target); + } + return targets; + } + if (['FRIENDS NOT USER', 'ALLIES NOT USER'].contains(string)) { + var group = this._action.friendsUnit().aliveMembers(); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target !== this._subject && target.isAppeared()) { + targets.push(target); + } + } + return targets; + } + if (string.match(/(?:FRIEND|ALLY)[ ](\d+)/i)) { + var target = this._action.friendsUnit().members()[parseInt(RegExp.$1)]; + if (target && target.isAppeared()) return [target]; + } + if (string.match(/(?:OPPONENT|FOE|RIVAL)[ ](\d+)/i)) { + var target = this._action.opponentsUnit().members()[parseInt(RegExp.$1)] + if (target && target.isAppeared()) return [target]; + } + if (['ALL ALIVE'].contains(string)) { + var group = this._action.friendsUnit().aliveMembers(); + group = group.concat(this._action.opponentsUnit().aliveMembers()); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ALL MEMBERS'].contains(string)) { + var group = this._action.friendsUnit().members(); + group = group.concat(this._action.opponentsUnit().members()); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + return targets; + } + if (['ALL DEAD'].contains(string)) { + var group = this._action.friendsUnit().deadMembers(); + group = group.concat(this._action.opponentsUnit().deadMembers()); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target) targets.push(target); + } + return targets; + } + if (['ALL NOT USER'].contains(string)) { + var group = this._action.friendsUnit().aliveMembers(); + group = group.concat(this._action.opponentsUnit().aliveMembers()); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target !== this._subject && target.isAppeared()) { + targets.push(target); + } + } + return targets; + } + if (['FOCUS', 'PARTICIPANTS'].contains(string)) { + var group = this._targets; + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target && target.isAppeared()) targets.push(target); + } + if (!targets.contains(this._subject)) targets.push(this._subject); + return targets; + } + if (['NOT FOCUS', 'NONPARTICIPANTS'].contains(string)) { + var group = this._action.friendsUnit().members(); + group = group.concat(this._action.opponentsUnit().members()); + for (var i = 0; i < group.length; ++i) { + var target = group[i]; + if (target) { + if (target === this._subject) continue; + if (target.isHidden()) continue; + if (this._targets.contains(target)) continue; + + if (target.isDead()) { + if (Imported.KELYEP_DragonBones && target.isEnemy() && target.hasDragonBone) { + continue; + } else if (Imported.YEP_X_AnimatedSVEnemies && target.isEnemy()) { + if (target.hasSVBattler() && !target.sideviewCollapse()) { + // Ignore + } else { + continue; + } + } else if (target.isActor()) { + // Ignore + } else { + continue; + } + } + + targets.push(target); + } + } + return targets; + } + if (string.match(/(?:CHAR|CHARA|CHARACTER)[ ](\d+)/i)) { + var actorId = parseInt(RegExp.$1); + var actor = $gameActors.actor(actorId); + if (actor && $gameParty.battleMembers().contains(actor)) { + return [actor]; + } + } + if ('FIRST' === string.toUpperCase()) { + return [this._targets[0]]; + } + return targets; +}; + +BattleManager.actionConditionsMet = function(actSeq) { + var ci = this._conditionFlags.length - 1; + var actionName = actSeq[0]; + var actionArgs = actSeq[1]; + var subject = this._subject; + var user = this._subject; + var target = this._targets[0]; + var targets = this._targets; + var action = this._action; + var item = this._action.item(); + if (actionName.match(/ELSE[ ]IF[ ](.*)/i)) { + if (this._conditionFlags.length <= 0) return false; + if (this._conditionFlags[ci]) { + this._conditionFlags[ci] = false; + this._trueFlags[ci] = true; + } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) { + var text = String(RegExp.$1); + try { + this._conditionFlags[ci] = eval(text); + this._trueFlags[ci] = eval(text); + } catch (e) { + Yanfly.Util.displayError(e, text, 'ACTION SEQUENCE IF CONDITION ERROR'); + this._conditionFlags[ci] = false; + this._trueFlags[ci] = false; + } + } + return false; + } else if (actionName.match(/ELSE[ ]*(.*)/i)) { + if (this._conditionFlags.length <= 0) return false; + if (this._conditionFlags[ci]) { + this._conditionFlags[ci] = false; + this._trueFlags[ci] = true; + } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) { + this._conditionFlags[ci] = true; + this._trueFlags[ci] = true; + } + return false; + } else if (actionName.toUpperCase() === 'END') { + if (this._conditionFlags.length <= 0) return false; + this._conditionFlags.pop(); + this._trueFlags.pop(); + return false; + } + if (this._conditionFlags.length > 0) return this._conditionFlags[ci]; + return true +}; + +BattleManager.actionActionAnimation = function(actionArgs) { + if (actionArgs && actionArgs[0]) { + var targets = this.makeActionTargets(actionArgs[0]); + } else { + var targets = this._targets; + } + var mirror = false; + if (actionArgs && actionArgs[1]) { + if (actionArgs[1].toUpperCase() === 'MIRROR') mirror = true; + } + var subject = this._subject; + var group = targets.filter(Yanfly.Util.onlyUnique); + var aniId = this._action.item().animationId; + if (aniId < 0) { + if (mirror) { + this._logWindow.showActorAtkAniMirror(subject, group); + } else { + this._logWindow.showAttackAnimation(subject, group); + } + } else { + this._logWindow.showNormalAnimation(group, aniId, mirror); + } + return true; +}; + +BattleManager.actionActionCommonEvent = function() { + this._action.item().effects.forEach(function(effect) { + if (effect.code === Game_Action.EFFECT_COMMON_EVENT) { + $gameTemp.reserveCommonEvent(effect.dataId); + } + }, this); + return false; +}; + +BattleManager.actionActionEffect = function(actionArgs) { + if (actionArgs && actionArgs[0]) { + var targets = this.makeActionTargets(actionArgs[0]); + } else { + var targets = this._targets; + } + targets.forEach(function(target) { + if (target !== undefined) { + var alreadyDead = target.isDead(); + this.invokeAction(this._subject, target); + if (target.isDead() && !alreadyDead) { + target.performCollapse(); + } + } + }, this); + return true; +}; + +BattleManager.actionAniWait = function(frames) { + frames *= Yanfly.Param.AnimationRate || 4; + this._logWindow._waitCount = parseInt(frames); + return false; +}; + +BattleManager.actionCastAnimation = function() { + if (!$gameSystem.isSideView() && this._subject.isActor()) return true; + if (!this._action.isAttack() && !this._action.isGuard() && + this._action.isSkill()) { + if (this._action.item().castAnimation > 0) { + var ani = $dataAnimations[this._action.item().castAnimation] + this._logWindow.showAnimation(this._subject, [this._subject], + this._action.item().castAnimation); + } + } + return true; +}; + + +BattleManager.actionClearBattleLog = function() { + this._logWindow.clear(); + return false; +}; + +BattleManager.actionDeathBreak = function() { + if (this._subject.isDead()) { + this._targets = []; + this._actionList = []; + this._individualTargets = []; + this._phase = 'phaseChange'; + return false; + } + return true; +}; + +BattleManager.actionDisplayAction = function() { + this._logWindow.displayAction(this._subject, this._action.item()); + return false; +}; + +BattleManager.actionIfConditions = function(actionName, actionArgs) { + var subject = this._subject; + var user = this._subject; + var target = this._targets[0]; + var critical = false; + if (target && target.result()) critical = target.result().critical; + var targets = this._targets; + var action = this._action; + var item = this._action.item(); + var actionName = this._actSeq[0]; + if (actionName.match(/IF[ ](.*)/i)) { + var text = String(RegExp.$1); + try { + this._conditionFlags.push(eval(text)); + } catch (e) { + this._conditionFlags.push(false); + Yanfly.Util.displayError(e, text, 'ACTION SEQUENCE IF CONDITION ERROR'); + } + this._trueFlags.push(false); + var ci = this._conditionFlags.length; + } + return true; +}; + +BattleManager.actionImmortal = function(actionArgs) { + var targets = + this.makeActionTargets(actionArgs[0]).filter(Yanfly.Util.onlyUnique); + try { + var value = eval(String(actionArgs[1]).toLowerCase()); + } catch (e) { + var value = false; + } + targets.forEach(function (target) { + if (value) { + target.addImmortal(); + } else { + var alreadyDead = target.isDead(); + target.removeImmortal(); + } + }, this); + return true; +}; + +BattleManager.actionMotionWait = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets[0].isActor() && targets[0].isSpriteVisible()) { + this._logWindow._waitCount += 12; + return false; + } + return true; +}; + +BattleManager.actionPerformAction = function() { + this._logWindow.performAction(this._subject, this._action); + if (this._subject.isActor() && this._subject.isSpriteVisible) { + this._logWindow._waitCount += 20; + return false; + } + return true; +}; + +BattleManager.actionPerformFinish = function() { + this._logWindow.performActionEnd(this._subject); + $gameParty.aliveMembers().forEach(function(member) { + member.spriteReturnHome(); + }); + $gameTroop.aliveMembers().forEach(function(member) { + member.spriteReturnHome(); + }); + return true; +}; + +BattleManager.actionPerformStart = function() { + this._logWindow.performActionStart(this._subject, this._action); + return true; +}; + +BattleManager.actionWait = function(frames) { + this._logWindow._waitCount = parseInt(frames); + return false; +}; + +BattleManager.actionWaitForAnimation = function() { + this._logWindow.waitForAnimation(); + return false; +}; + +BattleManager.actionWaitForEffect = function() { + this._logWindow.waitForEffect(); + return false; +}; + +BattleManager.actionWaitForMovement = function() { + this._logWindow.waitForMovement(); + return false; +}; + +BattleManager.actionWaitForNewLine = function() { + this._logWindow.waitForNewLine(); + return false; +}; + +BattleManager.actionWaitForPopups = function() { + this._logWindow.waitForPopups(); + return false; +}; + +//============================================================================= +// SceneManager +//============================================================================= + +Yanfly.BEC.SceneManager_snapForBackground = SceneManager.snapForBackground; +SceneManager.snapForBackground = function() { + if ($gameParty.inBattle()) { + var spriteset = this._scene._spriteset; + if (spriteset.battleback1Name() === '' && + spriteset.battleback2Name() === '') { + return; + } + } + Yanfly.BEC.SceneManager_snapForBackground.call(this); +}; + +//============================================================================= +// Sprite_Battler +//============================================================================= + +Yanfly.BEC.Sprite_Battler_initialize = Sprite_Battler.prototype.initialize; +Sprite_Battler.prototype.initialize = function(battler) { + this.preSpriteInitialize(battler); + Yanfly.BEC.Sprite_Battler_initialize.call(this, battler); +}; + +Sprite_Battler.prototype.preSpriteInitialize = function(battler) { +}; + +Yanfly.BEC.Sprite_Battler_update = Sprite_Battler.prototype.update; +Sprite_Battler.prototype.update = function() { + Yanfly.BEC.Sprite_Battler_update.call(this); + if (this._postSpriteInitialized) return; + this.postSpriteInitialize(); +}; + +Sprite_Battler.prototype.postSpriteInitialize = function() { + this._postSpriteInitialized = true; +}; + +Yanfly.BEC.Sprite_Battler_initMembers = Sprite_Battler.prototype.initMembers; +Sprite_Battler.prototype.initMembers = function() { + Yanfly.BEC.Sprite_Battler_initMembers.call(this); + this.adjustAnchor(); + this.setZ(); +}; + +Sprite_Battler.prototype.adjustAnchor = function() { + this.anchor.x = 0.5; + this.anchor.y = 1.0; +}; + +Sprite_Battler.prototype.setZ = function() { + this.z = 1; +}; + +Sprite_Battler.prototype.setupDamagePopup = function() { + if (this._battler.isDamagePopupRequested()) { + if (this._battler.isSpriteVisible()) { + var sprite = new Sprite_Damage(); + sprite.x = this.x + this.damageOffsetX(); + sprite.y = this.y + this.damageOffsetY(); + sprite.setup(this._battler); + this.pushDamageSprite(sprite); + BattleManager._spriteset.addChild(sprite); + this._battler.clearResult(); + } + } else { + this._battler.clearDamagePopup(); + } +}; + +Sprite_Battler.prototype.pushDamageSprite = function(sprite) { + var heightBuffer = Yanfly.Param.BECPopupOverlap; + if (Yanfly.Param.BECNewPopBottom) { + this._damages.push(sprite); + this._damages.forEach(function(spr) { + for (var i = 0; i < spr.children.length; i++) { + childSprite = spr.children[i]; + childSprite.anchor.y += heightBuffer; + } + }, this); + } else { + this._damages.push(sprite); + heightBuffer *= this._damages.length + for (var i = 0; i < sprite.children.length; i++) { + childSprite = sprite.children[i]; + childSprite.anchor.y += heightBuffer; + } + } +}; + +Yanfly.BEC.Sprite_Battler_setBattler = Sprite_Battler.prototype.setBattler; +Sprite_Battler.prototype.setBattler = function(battler) { + Yanfly.BEC.Sprite_Battler_setBattler.call(this, battler); + if (battler) battler.setBattler(this); +}; + +Yanfly.BEC.Sprite_Battler_startMove = Sprite_Battler.prototype.startMove; +Sprite_Battler.prototype.startMove = function(x, y, duration) { + if (this._battler && !this._battler.spriteCanMove()) return; + Yanfly.BEC.Sprite_Battler_startMove.call(this, x, y, duration); +}; + +Sprite_Battler.prototype.stepForward = function() { + this.startMove(Yanfly.Param.BECStepDist, 0, 12); +}; + +Sprite_Battler.prototype.stepBack = function() { + this.startMove(0, 0, 12); +}; + +Sprite_Battler.prototype.stepFlinch = function() { + var flinchX = this.x - this._homeX - Yanfly.Param.BECFlinchDist; + var flinchY = this.y - this._homeY; + this.startMove(flinchX, flinchY, 6); +}; + +Sprite_Battler.prototype.stepSubBack = function() { + var backX = -1 * this.width / 2; + this.startMove(backX, 0, 6); +}; + +Sprite_Battler.prototype.stepToSubstitute = function(focus) { + var target = focus.battler(); + var targetX = (this.x - this._homeX) + (target._homeX - this._homeX); + var targetY = (this.y - this._homeY) + (target._homeY - this._homeY);; + if (focus.isActor()) targetX -= this._mainSprite.width / 2; + if (focus.isEnemy()) targetX += this.width / 2; + this.startMove(targetX, targetY, 1); +}; + +Sprite_Battler.prototype.startMotion = function(motionType) { +}; + +Sprite_Battler.prototype.forceMotion = function(motionType) { +}; + +Sprite_Battler.prototype.refreshMotion = function() { +}; + +Sprite_Battler.prototype.startActionMotion = function() { +}; + +Sprite_Battler.prototype.moveForward = function(distance, frames) { + distance = parseInt(distance); + frames = parseInt(frames); + if (this._battler.isActor()) distance *= -1; + var moveX = this.x - this._homeX + distance; + var moveY = this.y - this._homeY; + this.startMove(moveX, moveY, frames); +}; + +Sprite_Battler.prototype.moveToPoint = function(pointX, pointY, frames) { + pointX = parseInt(pointX); + pointY = parseInt(pointY); + var targetX = pointX - this._homeX; + var targetY = pointY - this._homeY; + this.startMove(targetX, targetY, frames); +}; + +Sprite_Battler.prototype.setMirror = function(value) { + if (this.scale.x > 0 && value) this.scale.x *= -1; + if (this.scale.x < 0 && !value) this.scale.x *= -1; +}; + +Sprite_Battler.prototype.isPopupPlaying = function() { + if (this._damages.length > 0) { + for (var i = 0; i < this._damages.length; ++i) { + return this._damages[i].isPlaying(); + } + } + return false; +}; + +//============================================================================= +// Sprite_Actor +//============================================================================= + +Sprite_Actor.prototype.preSpriteInitialize = function(battler) { + Sprite_Battler.prototype.preSpriteInitialize.call(this, battler); +}; + +Sprite_Actor.prototype.postSpriteInitialize = function() { + Sprite_Battler.prototype.postSpriteInitialize.call(this); +}; + +Yanfly.BEC.Sprite_Actor_updateShadow = Sprite_Actor.prototype.updateShadow; +Sprite_Actor.prototype.updateShadow = function() { + if (this._hideShadows === undefined) { + this._hideShadows = Yanfly.Param.BECShowShadows; + } + if (!this._hideShadows) return this._shadowSprite.visible = false; + Yanfly.BEC.Sprite_Actor_updateShadow.call(this); +}; + +Sprite_Actor.prototype.setActorHome = function(index) { + var screenWidth = Graphics.boxWidth; + var screenHeight = Graphics.boxHeight; + var maxSize = $gameParty.maxBattleMembers(); + var partySize = $gameParty.battleMembers().length; + var statusHeight = eval(Yanfly.Param.BECCommandRows); + statusHeight *= Window_Base.prototype.lineHeight.call(this); + statusHeight += Window_Base.prototype.standardPadding.call(this) * 2; + if ($gameSystem.isSideView()) { + var code = Yanfly.Param.BECHomePosX; + try { + var homeX = eval(code); + } catch (e) { + var homeX = 0; + Yanfly.Util.displayError(e, code, 'SIDE VIEW HOME X FORMULA ERROR'); + } + var code = Yanfly.Param.BECHomePosY; + try { + var homeY = eval(code); + } catch (e) { + var homeY = 0; + Yanfly.Util.displayError(e, code, 'SIDE VIEW HOME Y FORMULA ERROR'); + } + } else { + var code = Yanfly.Param.BECFrontPosX; + try { + var homeX = eval(code); + } catch (e) { + var homeX = 0; + Yanfly.Util.displayError(e, code, 'FRONT VIEW HOME X FORMULA ERROR'); + } + var code = Yanfly.Param.BECFrontPosY; + try { + var homeY = eval(code); + } catch (e) { + var homeY = 0; + Yanfly.Util.displayError(e, code, 'FRONT VIEW HOME Y FORMULA ERROR'); + } + } + this._checkAliveStatus = false; + if ($gameParty.battleMembers()[index]) { + var actor = $gameParty.battleMembers()[index]; + if (actor.isAlive()) this._checkAliveStatus = true; + } + this.setHome(homeX, homeY); + this.moveToStartPosition(); +}; + +Sprite_Actor.prototype.moveToStartPosition = function() { + if (BattleManager._bypassMoveToStartLocation) return; + if ($gameSystem.isSideView() && this._checkAliveStatus) { + this.startMove(300, 0, 0); + } +}; + +Sprite_Actor.prototype.setupMotion = function() { +}; + +Sprite_Actor.prototype.forceMotion = function(motionType) { + var newMotion = Sprite_Actor.MOTIONS[motionType]; + this._motion = newMotion; + this._motionCount = 0; + this._pattern = 0; +}; + +Sprite_Actor.prototype.updateTargetPosition = function() { +}; + +Sprite_Actor.prototype.updateMotion = function() { + this.updateMotionCount(); +}; + +Sprite_Actor.prototype.onMoveEnd = function() { + Sprite_Battler.prototype.onMoveEnd.call(this); +}; + +Sprite_Actor.prototype.stepForward = function() { + this.startMove(-Yanfly.Param.BECStepDist, 0, 12); +}; + +Sprite_Actor.prototype.stepFlinch = function() { + var flinchX = this.x - this._homeX + Yanfly.Param.BECFlinchDist; + var flinchY = this.y - this._homeY; + this.startMove(flinchX, flinchY, 6); +}; + +Sprite_Actor.prototype.stepSubBack = function() { + var backX = this._mainSprite.width / 2; + this.startMove(backX, 0, 6); +}; + +Yanfly.BEC.Sprite_Actor_updateBitmap = Sprite_Actor.prototype.updateBitmap; +Sprite_Actor.prototype.updateBitmap = function() { + var name = this._actor.battlerName(); + var needUpdate = false; + if (this._battlerName !== name) needUpdate = true; + Yanfly.BEC.Sprite_Actor_updateBitmap.call(this); + if (needUpdate) this.adjustAnchor(); +}; + +Sprite_Actor.prototype.adjustAnchor = function() { + if (!this._mainSprite) return; + this._mainSprite.anchor.x = this._actor.anchorX(); + this._mainSprite.anchor.y = this._actor.anchorY(); +}; + +Yanfly.BEC.Sprite_Actor_updateFrame = Sprite_Actor.prototype.updateFrame; +Sprite_Actor.prototype.updateFrame = function() { + Yanfly.BEC.Sprite_Actor_updateFrame.call(this); + if (!this._mainSprite) return; + if (!this._mainSprite.bitmap) return; + if (this._mainSprite.bitmap.width > 0 && !this.bitmap) { + var sw = this._mainSprite.bitmap.width / 9; + var sh = this._mainSprite.bitmap.height / 6; + this.bitmap = new Bitmap(sw, sh); + } +}; + +Yanfly.BEC.Sprite_Actor_refreshMotion = Sprite_Actor.prototype.refreshMotion; +Sprite_Actor.prototype.refreshMotion = function() { + var actor = this._actor; + if (!actor) return; + var motionGuard = Sprite_Actor.MOTIONS['guard']; + if (this._motion === motionGuard && !BattleManager.isInputting()) return; + var stateMotion = actor.stateMotionIndex(); + if (actor.isInputting() || actor.isActing()) { + this.startMotion(actor.idleMotion()); + } else if (stateMotion === 3) { + this.startMotion(actor.deadMotion()); + } else if (stateMotion === 2) { + this.startMotion(actor.sleepMotion()); + } else if (actor.isChanting()) { + this.startMotion(actor.chantMotion()); + } else if (actor.isGuard() || actor.isGuardWaiting()) { + this.startMotion(actor.guardMotion()); + } else if (stateMotion === 1) { + this.startMotion(actor.abnormalMotion()); + } else if (actor.isDying()) { + this.startMotion(actor.dyingMotion()); + } else if (actor.isUndecided()) { + this.startMotion(actor.idleMotion()); + } else { + this.startMotion(actor.waitMotion()); + } +}; + +//============================================================================= +// Sprite_Enemy +//============================================================================= + +Sprite_Enemy.prototype.preSpriteInitialize = function(battler) { + Sprite_Battler.prototype.preSpriteInitialize.call(this, battler); + this._visualSelect = Yanfly.Param.BECEnemySelect; + if (this._visualSelect) this.createVisualSelectWindow(); +}; + +Yanfly.BEC.Sprite_Enemy_update = Sprite_Enemy.prototype.update; +Sprite_Enemy.prototype.update = function() { + Yanfly.BEC.Sprite_Enemy_update.call(this); + this.addVisualSelectWindow(); + this.checkExistInSceneChildren() +}; + +Sprite_Enemy.prototype.addVisualSelectWindow = function() { + if (!this._visualSelect) return; + if (this._addedVisualSelect) return; + if (!SceneManager._scene) return; + var scene = SceneManager._scene; + if (!scene._windowLayer) return; + this._addedVisualSelect = true; + scene.addChild(this._visualSelectWindow); +}; + +Sprite_Enemy.prototype.createVisualSelectWindow = function() { + this._visualSelectWindow = new Window_EnemyVisualSelect(); +}; + +Yanfly.BEC.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler; +Sprite_Enemy.prototype.setBattler = function(battler) { + Yanfly.BEC.Sprite_Enemy_setBattler.call(this, battler); + if (this._visualSelectWindow) this._visualSelectWindow.setBattler(battler); +}; + +Sprite_Enemy.prototype.checkExistInSceneChildren = function() { + if (!this._visualSelect) return; + if (!SceneManager._scene) return; + var scene = SceneManager._scene; + if (!scene._windowLayer) return; + if (!scene.children.contains(this._visualSelectWindow)) { + this._addedVisualSelect = true; + scene.addChild(this._visualSelectWindow); + } +}; + +//============================================================================= +// Sprite_Weapon +//============================================================================= + +Yanfly.BEC.Sprite_Weapon_setup = Sprite_Weapon.prototype.setup; +Sprite_Weapon.prototype.setup = function(weaponImageId) { + Yanfly.BEC.Sprite_Weapon_setup.call(this, weaponImageId); + this._animationCount -= 1; // Synch with sprite +}; + +//============================================================================= +// Sprite_Damage +//============================================================================= + +Yanfly.BEC.Sprite_Damage_initialize = Sprite_Damage.prototype.initialize; +Sprite_Damage.prototype.initialize = function() { + Yanfly.BEC.Sprite_Damage_initialize.call(this); + this._duration = Yanfly.Param.BECPopupDur; +}; + +Sprite_Damage.prototype.setup = function(target) { + this._result = target.shiftDamagePopup(); + var result = this._result; + if (result.missed || result.evaded) { + this.createMiss(); + } else if (result.hpAffected) { + this.createDigits(0, result.hpDamage); + } else if (target.isAlive() && result.mpDamage !== 0) { + this.createDigits(2, result.mpDamage); + } + if (result.critical) { + this.setupCriticalEffect(); + } +}; + +Sprite_Damage.prototype.setupCriticalEffect = function() { + this._flashColor = eval('[' + Yanfly.Param.BECCritPopup + ']'); + this._flashDuration = Yanfly.Param.BECCritDur; +}; + +Yanfly.BEC.Sprite_Damage_update = Sprite_Damage.prototype.update; +Sprite_Damage.prototype.update = function() { + Yanfly.BEC.Sprite_Damage_update.call(this); + if (this._duration <= 0 && this.parent) { + this.parent.removeChild(this); + } +}; + +//============================================================================= +// Sprite_StateIcon +//============================================================================= + +Yanfly.BEC.Sprite_StateIcon_update = Sprite_StateIcon.prototype.update; +Sprite_StateIcon.prototype.update = function() { + Yanfly.BEC.Sprite_StateIcon_update.call(this); + this.updateMirror(); +}; + +Sprite_StateIcon.prototype.updateMirror = function() { + if (this.parent.scale.x < 0) this.scale.x = -1 * Math.abs(this.scale.x); + if (this.parent.scale.x > 0) this.scale.x = Math.abs(this.scale.x); +}; + +//============================================================================= +// Sprite_StateOverlay +//============================================================================= + +Yanfly.BEC.Sprite_StateOverlay_update = Sprite_StateOverlay.prototype.update; +Sprite_StateOverlay.prototype.update = function() { + Yanfly.BEC.Sprite_StateOverlay_update.call(this); + this.updateMirror(); +}; + +Sprite_StateOverlay.prototype.updateMirror = function() { + if (this.parent.scale.x < 0) this.scale.x = -1 * Math.abs(this.scale.x); + if (this.parent.scale.x > 0) this.scale.x = Math.abs(this.scale.x); +}; + +//============================================================================= +// Spriteset_Battle +//============================================================================= + +Spriteset_Battle.prototype.isBusy = function() { + return false; +}; + +Yanfly.BEC.Spriteset_Battle_update = Spriteset_Battle.prototype.update; +Spriteset_Battle.prototype.update = function() { + Yanfly.BEC.Spriteset_Battle_update.call(this); + this.updateZCoordinates(); +}; + +Spriteset_Battle.prototype.updateZCoordinates = function() { + if (Imported.YEP_ImprovedBattlebacks) { + this.updateBattlebackGroupRemove(); + } else { + this._battleField.removeChild(this._back1Sprite); + this._battleField.removeChild(this._back2Sprite); + } + this._battleField.children.sort(this.battleFieldDepthCompare); + if (Imported.YEP_ImprovedBattlebacks) { + this.updateBattlebackGroupAdd(); + } else { + this._battleField.addChildAt(this._back2Sprite, 0); + this._battleField.addChildAt(this._back1Sprite, 0); + } +}; + +Spriteset_Battle.prototype.battleFieldDepthCompare = function(a, b) { + var priority = BattleManager.getSpritePriority(); + if (a._battler && b._battler && priority !== 0) { + if (priority === 1) { + if (a._battler.isActor() && b._battler.isEnemy()) return 1; + if (a._battler.isEnemy() && b._battler.isActor()) return -1; + } else if (priority === 2) { + if (a._battler.isActor() && b._battler.isEnemy()) return -1; + if (a._battler.isEnemy() && b._battler.isActor()) return 1; + } + } + if (a.z < b.z) return -1; + if (a.z > b.z) return 1; + if (a.y < b.y) return -1; + if (a.y > b.y) return 1; + return 0; +}; + +Spriteset_Battle.prototype.isPopupPlaying = function() { + return this.battlerSprites().some(function(sprite) { + return sprite.isPopupPlaying(); + }); +}; + +Yanfly.BEC.Spriteset_Battle_battlerSprites = + Spriteset_Battle.prototype.battlerSprites; +Spriteset_Battle.prototype.battlerSprites = function() { + var sprites = Yanfly.BEC.Spriteset_Battle_battlerSprites.call(this); + var length = sprites.length; + var result = []; + for (var i = 0; i < length; ++i) { + var sprite = sprites[i]; + if (!sprite) continue; + if (!sprite._battler) continue; + result.push(sprite); + } + return result; +}; + +//============================================================================= +// Game_Temp +//============================================================================= + +Game_Temp.prototype.clearActionSequenceSettings = function() { +}; + +Game_Temp.prototype.forceActionQueue = function(command) { + if (!this._forceActionQueue) { + this._forceActionQueue = JsonEx.makeDeepCopy($dataCommonEvents[1]); + this._forceActionQueue.list = []; + } + this._forceActionQueue.list.push(command); +}; + +Yanfly.BEC.Game_Temp_clearCommonEvent = Game_Temp.prototype.clearCommonEvent; +Game_Temp.prototype.clearCommonEvent = function() { + this._forceActionQueue = undefined; + Yanfly.BEC.Game_Temp_clearCommonEvent.call(this); +}; + +Yanfly.BEC.Game_Temp_isCommonEventReserved = + Game_Temp.prototype.isCommonEventReserved; +Game_Temp.prototype.isCommonEventReserved = function() { + if (this._forceActionQueue) return true; + return Yanfly.BEC.Game_Temp_isCommonEventReserved.call(this); +}; + +Yanfly.BEC.Game_Temp_reservedCommonEvent = + Game_Temp.prototype.reservedCommonEvent; +Game_Temp.prototype.reservedCommonEvent = function() { + if (this._forceActionQueue) { + return this._forceActionQueue; + } + return Yanfly.BEC.Game_Temp_reservedCommonEvent.call(this); +}; + +//============================================================================= +// Game_System +//============================================================================= + +Yanfly.BEC.Game_System_initialize = Game_System.prototype.initialize; +Game_System.prototype.initialize = function() { + Yanfly.BEC.Game_System_initialize.call(this); + this.initBattleSystem(); +}; + +Game_System.prototype.initBattleSystem = function() { + this._battleSystem = Yanfly.Param.BECSystem.toLowerCase(); +}; + +Game_System.prototype.getBattleSystem = function() { + if (this._battleSystem === undefined) this.initBattleSystem(); + return this._battleSystem; +}; + +Game_System.prototype.setBattleSystem = function(type) { + this._battleSystem = type.toLowerCase(); +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.BEC.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.BEC.Game_Interpreter_pluginCommand.call(this, command, args); + if (command === 'setBattleSys' && !$gameParty.inBattle()) { + this.setBattleSystem(args[0]); + } +}; + +Game_Interpreter.prototype.setBattleSystem = function(value) { + $gameSystem.setBattleSystem(value); +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Game_Action.prototype.speed = function() { + var user = this.subject(); var a = user; + var maxhp = user.mhp; var mhp = user.mhp; var hp = user.hp; + var maxmp = user.mmp; var mmp = user.mmp; var mp = user.mp; + var maxtp = user.maxTp(); var mtp = user.maxTp(); var tp = user.tp; + var atk = user.atk; var def = user.def; var mat = user.mat; + var int = user.mat; var mdf = user.mdf; var res = user.res; + var agi = user.agi; var luk = user.luk; + var code = Yanfly.Param.BECActionSpeed; + try { + var speed = eval(code); + } catch (e) { + var speed = 0; + Yanfly.Util.displayError(e, code, 'ACTION SPEED FORMULA ERROR'); + } + if (this.item()) speed += this.item().speed; + if (this.isAttack()) speed += this.subject().attackSpeed(); + return speed; +}; + +Yanfly.BEC.Game_Action_apply = Game_Action.prototype.apply; +Game_Action.prototype.apply = function(target) { + target._result = null; + target._result = new Game_ActionResult(); + this.subject()._result = null; + this.subject()._result = new Game_ActionResult(); + Yanfly.BEC.Game_Action_apply.call(this, target); + if ($gameParty.inBattle()) { + target.startDamagePopup(); + target.performResultEffects(); + if (target !== this.subject()) this.subject().startDamagePopup(); + } +}; + +Game_Action.prototype.itemEffectAddAttackState = function(target, effect) { + this.subject().attackStates().forEach(function(stateId) { + var chance = effect.value1; + chance *= target.stateRate(stateId); + chance *= this.subject().attackStatesRate(stateId); + chance *= this.lukEffectRate(target); + if (Math.random() < chance) { + if (stateId === target.deathStateId()) { + if (target.isImmortal()) target.removeImmortal(); + } + target.addState(stateId); + this.makeSuccess(target); + } + }.bind(this), target); +}; + +Game_Action.prototype.itemEffectAddNormalState = function(target, effect) { + var stateId = effect.dataId; + var chance = effect.value1; + if (!this.isCertainHit()) { + chance *= target.stateRate(stateId); + chance *= this.lukEffectRate(target); + } + if (Math.random() < chance) { + if (stateId === target.deathStateId()) { + if (target.isImmortal()) target.removeImmortal(); + } + target.addState(stateId); + this.makeSuccess(target); + } +}; + +Yanfly.BEC.Game_Action_applyGlobal = Game_Action.prototype.applyGlobal; +Game_Action.prototype.applyGlobal = function() { + if ($gameParty.inBattle()) return; + Yanfly.BEC.Game_Action_applyGlobal.call(this); +}; + +Yanfly.BEC.Game_Action_needsSelection = Game_Action.prototype.needsSelection; +Game_Action.prototype.needsSelection = function() { + if ($gameParty.inBattle() && this.item().scope === 0) return false; + if ($gameParty.inBattle() && BattleManager.isForceSelection()) return true; + return Yanfly.BEC.Game_Action_needsSelection.call(this); +}; + +//============================================================================= +// Game_BattlerBase +//============================================================================= + +Yanfly.BEC.Game_BattlerBase_recoverAll = Game_BattlerBase.prototype.recoverAll; +Game_BattlerBase.prototype.recoverAll = function() { + Yanfly.BEC.Game_BattlerBase_recoverAll.call(this); + this.refresh(); + if ($gameParty.inBattle()) this.forceMotionRefresh(); +}; + +Game_BattlerBase.prototype.requestStatusRefresh = function() { + this._statusRefreshRequested = true; +}; + +Game_BattlerBase.prototype.isStatusRefreshRequested = function() { + return this._statusRefreshRequested; +}; + +Game_BattlerBase.prototype.completetStatusRefreshRequest = function() { + this._statusRefreshRequested = false; +}; + +Game_BattlerBase.prototype.updateStateTicks = function() { + var needRefresh = false; + for (var i = 0; i < this._states.length; ++i) { + var stateId = this._states[i]; + var state = $dataStates[stateId]; + if (!state) continue; + if (state.autoRemovalTiming !== 2) continue; + if (!this._stateTurns[stateId]) continue; + var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime; + var shown1 = Math.ceil(this._stateTurns[stateId]); + this._stateTurns[stateId] -= value; + var shown2 = Math.ceil(this._stateTurns[stateId]); + if (shown1 !== shown2) needRefresh = true; + if (this._stateTurns[stateId] <= 0) this.removeState(stateId); + } + if (needRefresh) this.refresh(); +}; + +Game_BattlerBase.prototype.isBypassUpdateTurns = function() { + if ($gameTroop.isEventRunning()) return true; + return false; +}; + +Game_BattlerBase.prototype.updateStateTurns = function() { + this.updateStateTurnEnd(); +}; + +Game_BattlerBase.prototype.updateStateTurnTiming = function(timing) { + if (this.isBypassUpdateTurns()) return; + var statesRemoved = []; + this._freeStateTurn = this._freeStateTurn || []; + for (var i = 0; i < this._states.length; ++i) { + var stateId = this._states[i]; + var state = $dataStates[stateId]; + if (!state) continue; + if (state.autoRemovalTiming !== timing) continue; + if (!this._stateTurns[stateId]) continue; + if (this._freeStateTurn.contains(stateId)) { + var index = this._freeStateTurn.indexOf(stateId); + this._freeStateTurn.splice(index, 1); + } else { + this._stateTurns[stateId] -= 1; + } + if (this._stateTurns[stateId] <= 0) statesRemoved.push(stateId); + } + for (var i = 0; i < statesRemoved.length; ++i) { + var stateId = statesRemoved[i]; + this.removeState(stateId); + } +}; + +Game_BattlerBase.prototype.updateStateActionStart = function() { + this.updateStateTurnTiming(3); +}; + +Game_BattlerBase.prototype.updateStateActionEnd = function() { + this.updateStateTurnTiming(1); +}; + +Game_BattlerBase.prototype.updateStateTurnStart = function() { + this.updateStateTurnTiming(4); +}; + +Game_BattlerBase.prototype.updateStateTurnEnd = function() { + this.updateStateTurnTiming(2); +}; + +Game_BattlerBase.prototype.updateBuffTicks = function() { + var needRefresh = false; + for (var i = 0; i < this._buffTurns.length; i++) { + if (this._buffTurns[i] <= 0) continue; + var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime; + var shown1 = Math.ceil(this._buffTurns[i]); + this._buffTurns[i] -= value; + var shown2 = Math.ceil(this._buffTurns[i]); + if (shown1 !== shown2) needRefresh = true; + if (this._buffTurns[i] <= 0) this.removeBuff(i); + } + if (needRefresh) this.refresh(); +}; + +Game_BattlerBase.prototype.timedTick = function() { + return 1 * BattleManager.tickRate(); +}; + +Yanfly.BEC.Game_BattlerBase_isStateResist = + Game_BattlerBase.prototype.isStateResist; +Game_BattlerBase.prototype.isStateResist = function(stateId) { + if (stateId === this.deathStateId() && this.isImmortal()) return true; + return Yanfly.BEC.Game_BattlerBase_isStateResist.call(this, stateId); +}; + +Game_BattlerBase.prototype.isImmortal = function() { + return this._immortalState; +}; + +Yanfly.BEC.Game_BattlerBase_paySkillCost = + Game_BattlerBase.prototype.paySkillCost; +Game_BattlerBase.prototype.paySkillCost = function(skill) { + this.requestStatusRefresh(); + Yanfly.BEC.Game_BattlerBase_paySkillCost.call(this, skill); +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Yanfly.BEC.Game_Battler_useItem = Game_Battler.prototype.useItem; +Game_Battler.prototype.useItem = function(item) { + Yanfly.BEC.Game_Battler_useItem.call(this, item); + this.refresh(); + if (!$gameParty.inBattle()) return; + this.increaseSelfTurnCount(); + this.updateStateActionStart(); +}; + +Yanfly.BEC.Game_Battler_onBattleStart = Game_Battler.prototype.onBattleStart; +Game_Battler.prototype.onBattleStart = function() { + Yanfly.BEC.Game_Battler_onBattleStart.call(this); + this._freeStateTurn = []; + this._immortalState = false; + this._selfTurnCount = 0; +}; + +Yanfly.BEC.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd; +Game_Battler.prototype.onBattleEnd = function() { + Yanfly.BEC.Game_Battler_onBattleEnd.call(this); + this._freeStateTurn = []; + this._immortalState = false; +}; + +Yanfly.BEC.Game_Battler_isSelected = Game_Battler.prototype.isSelected; +Game_Battler.prototype.isSelected = function() { + if ($gameParty.inBattle() && BattleManager.isAllSelection()) { + if (!this.isAppeared()) return false; + var action = BattleManager.inputtingAction(); + if (action && action.item()) { + if (this.isDead() && this.isEnemy()) return false; + if (this.isDead() && this.isActor()) return action.isForDeadFriend(); + if (action.isForFriend() && this.isActor()) return true; + if (action.isForOpponent() && this.isEnemy()) return true; + } + } + return Yanfly.BEC.Game_Battler_isSelected.call(this); +}; + +Yanfly.BEC.Game_Battler_regenerateAll = Game_Battler.prototype.regenerateAll; +Game_Battler.prototype.regenerateAll = function() { + this.clearResult(); + var lifeState = this.isAlive(); + Yanfly.BEC.Game_Battler_regenerateAll.call(this); + if ($gameParty.inBattle()) { + if (!BattleManager.timeBasedStates()) this.updateStateTurns(); + if (!BattleManager.timeBasedBuffs()) { + this.updateBuffTurns(); + this.removeBuffsAuto(); + } + if (this.isDead() && lifeState === true) { + this.performCollapse(); + } + this.startDamagePopup(); + } +}; + +Game_Battler.prototype.addImmortal = function() { + this._immortalState = true; +}; + +Game_Battler.prototype.removeImmortal = function() { + var alreadyDead = this.isDead(); + this._immortalState = false; + this.refresh(); + if (this.isDead() && !alreadyDead) this.performCollapse(); +}; + +Yanfly.BEC.Game_Battler_removeState = Game_Battler.prototype.removeState; +Game_Battler.prototype.removeState = function(stateId) { + Yanfly.BEC.Game_Battler_removeState.call(this, stateId); +}; + +Game_Battler.prototype.clearDamagePopup = function() { + this._damagePopup = []; +}; + +Game_Battler.prototype.isDamagePopupRequested = function() { + if (!this._damagePopup) this.clearDamagePopup(); + return this._damagePopup.length > 0; +}; + +Game_Battler.prototype.startDamagePopup = function() { + var result = this.result(); + if (result.missed || result.evaded) { + var copyResult = JsonEx.makeDeepCopy(result); + copyResult.hpAffected = false; + copyResult.mpDamage = 0; + this._damagePopup.push(copyResult); + } + if (result.hpAffected) { + var copyResult = JsonEx.makeDeepCopy(result); + copyResult.mpDamage = 0; + this._damagePopup.push(copyResult); + } + if (result.mpDamage !== 0) { + var copyResult = JsonEx.makeDeepCopy(result); + copyResult.hpAffected = false; + this._damagePopup.push(copyResult); + } +}; + +Game_Battler.prototype.shiftDamagePopup = function() { + if (!this._damagePopup) this.clearDamagePopup(); + return this._damagePopup.shift(); +}; + +Yanfly.BEC.Game_Battler_performCollapse = + Game_Battler.prototype.performCollapse; +Game_Battler.prototype.performCollapse = function() { + Yanfly.BEC.Game_Battler_performCollapse.call(this); + if ($gameParty.inBattle()) this.forceMotion(this.deadMotion()); +}; + +Game_Battler.prototype.performResultEffects = function() { + var result = this.result(); + if (result.missed && result.physical) this.performMiss(); + if (result.evaded) { + if (result.physical) { + this.performEvasion(); + } else { + this.performMagicEvasion(); + } + } + if (result.hpAffected) { + if (result.hpDamage > 0 && !result.drain) { + this.performDamage(); + } + if (result.hpDamage < 0) { + this.performRecovery(); + } + } + if (this.isAlive() && result.mpDamage !== 0 && result.mpDamage < 0) { + this.performRecovery(); + } + if (this.isAlive() && result.tpDamage !== 0 && result.tpDamage < 0) { + this.performRecovery(); + } +}; + +Yanfly.BEC.Game_Battler_performDamage = + Game_Battler.prototype.performDamage; +Game_Battler.prototype.performDamage = function() { + Yanfly.BEC.Game_Battler_performDamage.call(this); + this.performFlinch(); +}; + +Yanfly.BEC.Game_Battler_performMiss = Game_Battler.prototype.performMiss; +Game_Battler.prototype.performMiss = function() { + Yanfly.BEC.Game_Battler_performMiss.call(this); + this.performFlinch(); +}; + +Yanfly.BEC.Game_Battler_performEvasion = + Game_Battler.prototype.performEvasion; +Game_Battler.prototype.performEvasion = function() { + Yanfly.BEC.Game_Battler_performEvasion.call(this); + this.performFlinch(); +}; + +Yanfly.BEC.Game_Battler_performMagicEvasion = + Game_Battler.prototype.performMagicEvasion; +Game_Battler.prototype.performMagicEvasion = function() { + Yanfly.BEC.Game_Battler_performMagicEvasion.call(this); + this.performFlinch(); +}; + +Game_Battler.prototype.performFlinch = function() { + if (this._flinched || !$gameSystem.isSideView()) return; + this._flinched = true; + this.spriteStepFlinch(); +}; + +Yanfly.BEC.Game_Battler_performReflection = + Game_Battler.prototype.performReflection; +Game_Battler.prototype.performReflection = function() { + Yanfly.BEC.Game_Battler_performReflection.call(this); + if (!$gameSystem.isSideView() && this.isActor()) return; + var animationId = this.reflectAnimationId(); + var mirror = this.isActor(); + this.startAnimation(animationId, mirror, 0); +}; + +Yanfly.BEC.Game_Battler_performSubstitute = + Game_Battler.prototype.performSubstitute; +Game_Battler.prototype.performSubstitute = function(target) { + Yanfly.BEC.Game_Battler_performSubstitute.call(this, target); + if (!$gameSystem.isSideView()) return; + this._flinched = true; + if (BattleManager._action.isForAll()) { + this.spriteStepForward(); + target.spriteStepSubBack(); + } else { + this.spriteStepToSubstitute(target); + target.spriteStepSubBack(); + } +}; + +Game_Battler.prototype.setBattler = function(sprite) { + BattleManager.registerSprite(this, sprite); +}; + +Game_Battler.prototype.battler = function() { + return BattleManager.getSprite(this); +}; + +Game_Battler.prototype.requestMotion = function(motionType) { + this._motionType = motionType; + if (this.battler()) { + this.battler().startMotion(motionType); + } +}; + +Game_Battler.prototype.forceMotion = function(motionType) { + this._motionType = motionType; + if (this.battler()) { + this.battler().forceMotion(motionType); + } +}; + +Game_Battler.prototype.startWeaponAnimation = function(weaponImageId) { + this._weaponImageId = weaponImageId; + if (this.battler()) { + this.battler().setupWeaponAnimation(); + } +}; + +Game_Battler.prototype.performActionStart = function(action) { + if (!action.isGuard()) { + this.setActionState('acting'); + this.spriteStepForward(); + } +}; + +Yanfly.BEC.Game_Battler_performActionEnd = + Game_Battler.prototype.performActionEnd; +Game_Battler.prototype.performActionEnd = function() { + Yanfly.BEC.Game_Battler_performActionEnd.call(this); + this.spriteReturnHome(); +}; + +Game_Battler.prototype.spriteStepForward = function() { + if ($gameSystem.isSideView() && this.battler()) { + this.battler().stepForward(); + } +}; + +Game_Battler.prototype.spriteStepBack = function() { + if ($gameSystem.isSideView() && this.battler()) { + this.battler().stepBack(); + } +}; + +Game_Battler.prototype.spriteStepSubBack = function() { + if ($gameSystem.isSideView() && this.battler()) { + this.battler().stepSubBack(); + } +}; + +Game_Battler.prototype.spriteStepToSubstitute = function(target) { + if ($gameSystem.isSideView() && this.battler()) { + this.battler().stepToSubstitute(target); + } +}; + +Game_Battler.prototype.spriteStepFlinch = function() { + if ($gameSystem.isSideView() && this.battler()) { + this.battler().stepFlinch(); + } +}; + +Game_Battler.prototype.spriteReturnHome = function() { + if ($gameSystem.isSideView() && this.battler()) { + this._flinched = false; + this.spriteFaceForward(); + this.battler().stepBack(); + if (this.numActions() <= 0) { + this.setActionState('undecided'); + } + this.battler().refreshMotion(); + } +}; + +Game_Battler.prototype.reflectAnimationId = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state.reflectAnimationId > 0) return state.reflectAnimationId; + } + return Yanfly.Param.BECReflectAni; +}; + +Game_Battler.prototype.spriteCanMove = function() { + if (!$gameSystem.isSideView()) return false; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state.spriteCannotMove) return false; + } + return this.canMove(); +}; + +Game_Battler.prototype.spritePosX = function() { + if ($gameSystem.isSideView() && this.battler()) { + return this.battler().x; + } else if (this.battler()) { + return this.battler().x; + } else { + return 0; + } +}; + +Game_Battler.prototype.spritePosY = function() { + if ($gameSystem.isSideView() && this.battler()) { + return this.battler().y; + } else if (this.battler()) { + return this.battler().y; + } else { + return 0; + } +}; + +Game_Battler.prototype.spriteWidth = function() { + if ($gameSystem.isSideView() && this.battler() && this.battler().bitmap) { + return this.battler().bitmap.width; + } else if (this.battler() && this.battler().bitmap) { + return this.battler().bitmap.width; + } else { + return 1; + } +}; + +Game_Battler.prototype.spriteHeight = function() { + if ($gameSystem.isSideView() && this.battler() && this.battler().bitmap) { + return this.battler().bitmap.height; + } else if (this.battler() && this.battler().bitmap) { + return this.battler().bitmap.height; + } else { + return 1; + } +}; + +Game_Battler.prototype.anchorX = function() { + return Yanfly.Param.BECAnchorX; +}; + +Game_Battler.prototype.anchorY = function() { + return Yanfly.Param.BECAnchorY; +}; + +Game_Battler.prototype.spriteHomeX = function() { + if ($gameSystem.isSideView() && this.battler()) { + return this.battler()._homeX; + } else { + return 0; + } +}; + +Game_Battler.prototype.spriteHomeY = function() { + if ($gameSystem.isSideView() && this.battler()) { + return this.battler()._homeY; + } else { + return 0; + } +}; + +Game_Battler.prototype.setMirror = function(value) { + if ($gameSystem.isSideView() && this.battler() && this.spriteCanMove()) { + this.battler().setMirror(value); + } +}; + +Game_Battler.prototype.spriteFaceForward = function() { + this.setMirror(false); +}; + +Game_Battler.prototype.spriteFaceBackward = function() { + this.setMirror(true); +}; + +Game_Battler.prototype.spriteFacePoint = function(pointX, pointY) { + if (this.spritePosX() > pointX) { + this.spriteFaceBackward(); + } else { + this.spriteFaceForward(); + } +}; + +Game_Battler.prototype.spriteFaceAwayPoint = function(pointX, pointY) { + if (this.spritePosX() > pointX) { + this.spriteFaceForward(); + } else { + this.spriteFaceBackward(); + } +}; + +Game_Battler.prototype.spriteFaceTarget = function(target) { + if (!target) return; + var pointX = target.spritePosX(); + var pointY = target.spritePosY(); + this.spriteFacePoint(pointX, pointY); +}; + +Game_Battler.prototype.spriteFaceAwayTarget = function(target) { + if (!target) return; + var pointX = target.spritePosX(); + var pointY = target.spritePosY(); + this.spriteFaceAwayPoint(pointX, pointY); +}; + +Game_Battler.prototype.spriteFaceHome = function() { + var pointX = this.spriteHomeX(); + var pointY = this.spriteHomeY(); + this.spriteFacePoint(pointX, pointY); +}; + +Game_Battler.prototype.spriteFaceAwayHome = function() { + var pointX = target.spriteHomeX(); + var pointY = target.spriteHomeY(); + this.spriteFaceAwayPoint(pointX, pointY); +}; + +Game_Battler.prototype.attackMotion = function() { + return 'thrust'; +}; + +Game_Battler.prototype.performAttack = function() { +}; + +Game_Battler.prototype.forceMotionRefresh = function() { + if (!$gameParty.inBattle()) return; + if (this.battler()) this.battler().refreshMotion(); +}; + +Game_Battler.prototype.requestMotionRefresh = function() { + var deadMotion = this.deadMotion(); + if (this.isDead() && this._motionType !== deadMotion) { + this.requestMotion(deadMotion); + } + if (this.isDead() && this._motionType === deadMotion) return; + if (this._motionType === 'victory') return; + if (this._motionType === 'escape' && !BattleManager.isInputting()) return; + if (this._motionType === 'guard' && !BattleManager.isInputting()) return; + this.clearMotion(); + if (this.battler() && BattleManager.isInputting()) { + this.battler().refreshMotion(); + } +}; + +Game_Battler.prototype.onTurnStart = function() { + this.updateStateTurnStart(); +}; + +Game_Battler.prototype.onTurnEnd = function() { + this.clearResult(); + if (BattleManager.isTurnBased()) { + this.regenerateAll(); + } else if (BattleManager.isTickBased() && !BattleManager.isTurnEnd()) { + this.regenerateAll(); + } + this.removeStatesAuto(2); +}; + +Yanfly.BEC.Game_Battler_onAllActionsEnd = + Game_Battler.prototype.onAllActionsEnd; +Game_Battler.prototype.onAllActionsEnd = function() { + Yanfly.BEC.Game_Battler_onAllActionsEnd.call(this); + if (!BattleManager._processTurn) this.updateStateActionEnd(); +}; + +Game_Battler.prototype.updateTick = function() { + if (BattleManager.timeBasedStates()) this.updateStateTicks(); + if (BattleManager.timeBasedBuffs()) this.updateBuffTicks(); +}; + +Game_Battler.prototype.increaseSelfTurnCount = function() { + if (this._selfTurnCount === undefined) this._selfTurnCount = 0; + this._selfTurnCount += 1; +}; + +Game_Battler.prototype.turnCount = function() { + if (BattleManager.isTurnBased()) return $gameTroop.turnCount(); + if (BattleManager.isTickBased() && Yanfly.Param.BECAISelfTurn) { + return this._selfTurnCount; + } + return $gameTroop.turnCount(); +}; + +Game_Battler.prototype.createActions = function() { + if (this.currentAction()) return; + this.makeActions(); +}; + +Yanfly.BEC.Game_Battler_addState = Game_Battler.prototype.addState; +Game_Battler.prototype.addState = function(stateId) { + Yanfly.BEC.Game_Battler_addState.call(this, stateId); + if (this.canAddStateFreeTurn(stateId)) this.setStateFreeTurn(stateId); +}; + +Game_Battler.prototype.canAddStateFreeTurn = function(stateId) { + if (!$gameParty.inBattle()) return false; + if (BattleManager._subject !== this) return false; + if ($dataStates[stateId].autoRemovalTiming !== 1) return false; + if (Imported.YEP_BuffsStatesCore) { + if ($dataStates[stateId].reapplyRules === 0) return false; + } + return true; +}; + +Game_Battler.prototype.setStateFreeTurn = function(stateId) { + this._freeStateTurn = this._freeStateTurn || []; + this._freeStateTurn.push(stateId); +}; + +Game_Battler.prototype.idleMotion = function() { + return 'walk'; +}; + +Game_Battler.prototype.deadMotion = function() { + return 'dead'; +}; + +Game_Battler.prototype.sleepMotion = function() { + return 'sleep'; +}; + +Game_Battler.prototype.chantMotion = function() { + return 'chant'; +}; + +Game_Battler.prototype.guardMotion = function() { + return 'guard'; +}; + +Game_Battler.prototype.abnormalMotion = function() { + return 'abnormal'; +}; + +Game_Battler.prototype.dyingMotion = function() { + return 'dying'; +}; + +Game_Battler.prototype.waitMotion = function() { + return 'wait'; +}; + +Yanfly.BEC.Game_Battler_startAnimation = Game_Battler.prototype.startAnimation; +Game_Battler.prototype.startAnimation = function(animationId, mirror, delay) { + if (!$dataAnimations[animationId]) return; + Yanfly.BEC.Game_Battler_startAnimation.call(this, animationId, mirror, delay); +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Yanfly.BEC.Game_Actor_refresh = Game_Actor.prototype.refresh; +Game_Actor.prototype.refresh = function() { + this._anchorX = undefined; + this._anchorY = undefined; + Yanfly.BEC.Game_Actor_refresh.call(this); + if ($gameParty.inBattle()) this.requestStatusRefresh(); +}; + +Game_Actor.prototype.isSpriteVisible = function() { + if ($gameSystem.isSideView()) return true; + return Yanfly.Param.BECFrontSprite; +}; + +Game_Actor.prototype.reflectAnimationId = function() { + if (this.actor().reflectAnimationId > 0) { + return this.actor().reflectAnimationId; + } + if (this.currentClass().reflectAnimationId > 0) { + return this.currentClass().reflectAnimationId; + } + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.reflectAnimationId > 0) { + return equip.reflectAnimationId; + } + } + return Game_Battler.prototype.reflectAnimationId.call(this); +}; + +Game_Actor.prototype.spriteCanMove = function() { + if (this.actor().spriteCannotMove) return false; + if (this.currentClass().spriteCannotMove) return false; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.spriteCannotMove) return false; + } + return Game_Battler.prototype.spriteCanMove.call(this); +}; + +Game_Actor.prototype.spriteWidth = function() { + if ($gameSystem.isSideView() && this.battler()) { + return this.battler()._mainSprite.width; + } else { + return 1; + } +}; + +Game_Actor.prototype.spriteHeight = function() { + if ($gameSystem.isSideView() && this.battler()) { + return this.battler()._mainSprite.height; + } else { + return 1; + } +}; + +Game_Actor.prototype.anchorX = function() { + if (this._anchorX !== undefined) return this._anchorX; + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var obj = this.states()[i]; + if (obj && obj.anchorX !== undefined) { + this._anchorX = obj.anchorX; + return this._anchorX; + } + } + length = this.equips().length; + for (var i = 0; i < length; ++i) { + var obj = this.equips()[i]; + if (obj && obj.anchorX !== undefined) { + this._anchorX = obj.anchorX; + return this._anchorX; + } + } + if (this.currentClass().anchorX !== undefined) { + this._anchorX = this.currentClass().anchorX; + return this._anchorX; + } + this._anchorX = this.actor().anchorX; + return this._anchorX; +}; + +Game_Actor.prototype.anchorY = function() { + if (this._anchorY !== undefined) return this._anchorY; + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var obj = this.states()[i]; + if (obj && obj.anchorY !== undefined) { + this._anchorY = obj.anchorY; + return this._anchorY; + } + } + length = this.equips().length; + for (var i = 0; i < length; ++i) { + var obj = this.equips()[i]; + if (obj && obj.anchorY !== undefined) { + this._anchorY = obj.anchorY; + return this._anchorY; + } + } + if (this.currentClass().anchorY !== undefined) { + this._anchorY = this.currentClass().anchorY; + return this._anchorY; + } + this._anchorY = this.actor().anchorY; + return this._anchorY; +}; + +Game_Actor.prototype.spriteFacePoint = function(pointX, pointY) { + if (this.spritePosX() > pointX) { + this.spriteFaceForward(); + } else { + this.spriteFaceBackward(); + } +}; + +Game_Actor.prototype.spriteFaceAwayPoint = function(pointX, pointY) { + if (this.spritePosX() > pointX) { + this.spriteFaceBackward(); + } else { + this.spriteFaceForward(); + } +}; + +Game_Actor.prototype.performAttack = function() { + var weapons = this.weapons(); + var wtypeId = weapons[0] ? weapons[0].wtypeId : 0; + var attackMotion = $dataSystem.attackMotions[wtypeId]; + if (attackMotion) { + if (attackMotion.type === 0) { + this.forceMotion('thrust'); + } else if (attackMotion.type === 1) { + this.forceMotion('swing'); + } else if (attackMotion.type === 2) { + this.forceMotion('missile'); + } + this.startWeaponAnimation(attackMotion.weaponImageId); + } +}; + +Game_Actor.prototype.attackMotion = function() { + var weapons = this.weapons(); + var wtypeId = weapons[0] ? weapons[0].wtypeId : 0; + var attackMotion = $dataSystem.attackMotions[wtypeId]; + if (attackMotion) { + if (attackMotion.type === 0) { + return 'thrust'; + } else if (attackMotion.type === 1) { + return 'swing'; + } else if (attackMotion.type === 2) { + return 'missile'; + } + }; + return 'thrust'; +}; + +Game_Actor.prototype.performEscapeSuccess = function() { + if (this.battler()) { + this.performEscape(); + this.battler().startMove(300, 0, 60); + } +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +if (!Game_Enemy.prototype.skills) { +Game_Enemy.prototype.skills = function() { + var skills = [] + for (var i = 0; i < this.enemy().actions.length; ++i) { + var skill = $dataSkills[this.enemy().actions[i].skillId] + if (skill) skills.push(skill); + } + return skills; +} +}; // (!Game_Enemy.prototype.skills) + +Game_Enemy.prototype.performActionStart = function(action) { + Game_Battler.prototype.performActionStart.call(this, action); + if (!$gameSystem.isSideView() || !this.spriteCanMove()) { + this.requestEffect('whiten'); + } +}; + +Yanfly.BEC.Game_Enemy_performDamage = Game_Enemy.prototype.performDamage; +Game_Enemy.prototype.performDamage = function() { + if ($gameSystem.isSideView()) { + Game_Battler.prototype.performDamage.call(this); + SoundManager.playEnemyDamage(); + } else { + Yanfly.BEC.Game_Enemy_performDamage.call(this); + } +}; + +Game_Enemy.prototype.attackAnimationId = function() { + return this.enemy().attackAnimationId; +}; + +Game_Enemy.prototype.attackAnimationId1 = function() { + return this.attackAnimationId(); +}; + +Game_Enemy.prototype.attackAnimationId2 = function() { + return this.attackAnimationId(); +}; + +Game_Enemy.prototype.reflectAnimationId = function() { + if (this.enemy().reflectAnimationId > 0) { + return this.enemy().reflectAnimationId; + } + return Game_Battler.prototype.reflectAnimationId.call(this); +}; + +Game_Enemy.prototype.spriteCanMove = function() { + if (this.enemy().spriteCannotMove) return false; + return Game_Battler.prototype.spriteCanMove.call(this); +}; + +Game_Enemy.prototype.meetsTurnCondition = function(param1, param2) { + var n = this.turnCount(); + if (param2 === 0) { + return n === param1; + } else { + return n > 0 && n >= param1 && n % param2 === param1 % param2; + } +}; + +//============================================================================= +// Game_Unit +//============================================================================= + +Game_Unit.prototype.createActions = function() { + var max = this.members().length; + for (var i = 0; i < max; ++i) { + var member = this.members()[i]; + if (member) member.createActions(); + } +}; + +Game_Unit.prototype.requestMotionRefresh = function() { + var max = this.members().length; + for (var i = 0; i < max; ++i) { + var member = this.members()[i]; + if (member) member.requestMotionRefresh(); + } +}; + +Game_Unit.prototype.onTurnStart = function() { + var max = this.members().length; + for (var i = 0; i < max; ++i) { + var member = this.members()[i]; + if (member) { + member.onTurnStart(); + member.refresh(); + } + } +}; + +Game_Unit.prototype.updateTick = function() { + var max = this.members().length; + for (var i = 0; i < max; ++i) { + var member = this.members()[i]; + if (member) member.updateTick(); + } +}; + +Game_Unit.prototype.refreshMembers = function() { + var group = this.allMembers(); + var length = group.length; + for (var i = 0; i < length; ++i) { + var member = group[i]; + if (member) member.refresh(); + } +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Game_Party.prototype.performEscapeSuccess = function() { + for (var i = 0; i < this.members().length; ++i) { + var member = this.members()[i]; + if (member) member.performEscapeSuccess(); + } +}; + +//============================================================================= +// Game_Troop +//============================================================================= + +Game_Troop.prototype.allMembers = function() { + return this.members(); +}; + +//============================================================================= +// Scene_Battle +//============================================================================= + +Yanfly.BEC.Scene_Battle_update = Scene_Battle.prototype.update; +Scene_Battle.prototype.update = function() { + Yanfly.BEC.Scene_Battle_update.call(this); + this.updateStatusWindowRequests(); +}; + +Scene_Battle.prototype.updateStatusWindowRequests = function() { + if (!this._statusWindow) return; + if (this._statusWindow.isClosed()) return; + this._statusWindow.updateStatusRequests(); +}; + +Yanfly.BEC.Scene_Battle_createSkillWindow = + Scene_Battle.prototype.createSkillWindow; +Scene_Battle.prototype.createSkillWindow = function() { + Yanfly.BEC.Scene_Battle_createSkillWindow.call(this); + if (Yanfly.Param.BECLowerWindows) { + this.adjustLowerWindow(this._skillWindow); + } +}; + +Yanfly.BEC.Scene_Battle_createItemWindow = + Scene_Battle.prototype.createItemWindow; +Scene_Battle.prototype.createItemWindow = function() { + Yanfly.BEC.Scene_Battle_createItemWindow.call(this); + if (Yanfly.Param.BECLowerWindows) { + this.adjustLowerWindow(this._itemWindow); + } +}; + +Yanfly.BEC.Scene_Battle_createActorWindow = + Scene_Battle.prototype.createActorWindow; +Scene_Battle.prototype.createActorWindow = function() { + Yanfly.BEC.Scene_Battle_createActorWindow.call(this); + this._actorWindow.x = Graphics.boxWidth - this._actorWindow.width; + if (Yanfly.Param.BECSelectHelp) { + this._actorWindow.setHelpWindow(this._helpWindow); + } +}; + +Yanfly.BEC.Scene_Battle_createEnemyWindow = + Scene_Battle.prototype.createEnemyWindow; +Scene_Battle.prototype.createEnemyWindow = function() { + Yanfly.BEC.Scene_Battle_createEnemyWindow.call(this); + if (Yanfly.Param.BECSelectHelp) { + this._enemyWindow.setHelpWindow(this._helpWindow); + } +}; + +Scene_Battle.prototype.adjustLowerWindow = function(win) { + win.height = win.fittingHeight(Yanfly.Param.BECWindowRows); + win.y = Graphics.boxHeight - win.height; +}; + +Yanfly.BEC.Scene_Battle_startPartyCommandSelection = + Scene_Battle.prototype.startPartyCommandSelection; +Scene_Battle.prototype.startPartyCommandSelection = function() { + if (this.isStartActorCommand()) { + this.selectNextCommand(); + } else { + Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this); + } +}; + +Scene_Battle.prototype.isStartActorCommand = function() { + if (this._isStartActorCommand === undefined) { + this._isStartActorCommand = Yanfly.Param.BECStartActCmd; + } + return this._isStartActorCommand; +}; + +Yanfly.BEC.Scene_Battle_selectPreviousCommand = + Scene_Battle.prototype.selectPreviousCommand; +Scene_Battle.prototype.selectPreviousCommand = function() { + if (this.isStartActorCommand()) { + BattleManager.selectPreviousCommand(); + if (BattleManager.isInputting() && BattleManager.actor()) { + this.startActorCommandSelection(); + } else { + Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this); + } + } else { + Yanfly.BEC.Scene_Battle_selectPreviousCommand.call(this); + } +}; + +Yanfly.BEC.Scene_Battle_selectNextCommand = + Scene_Battle.prototype.selectNextCommand; +Scene_Battle.prototype.selectNextCommand = function() { + Yanfly.BEC.Scene_Battle_selectNextCommand.call(this); + this._helpWindow.clear(); + BattleManager.stopAllSelection(); +}; + +Yanfly.BEC.Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill; +Scene_Battle.prototype.commandSkill = function() { + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_commandSkill.call(this); +}; + +Yanfly.BEC.Scene_Battle_commandItem = Scene_Battle.prototype.commandItem; +Scene_Battle.prototype.commandItem = function() { + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_commandItem.call(this); +}; + +Yanfly.BEC.Scene_Battle_startActorCommandSelection = + Scene_Battle.prototype.startActorCommandSelection; +Scene_Battle.prototype.startActorCommandSelection = function() { + BattleManager.createActions(); + Yanfly.BEC.Scene_Battle_startActorCommandSelection.call(this); + this._statusWindow.refresh(); +}; + +Yanfly.BEC.Scene_Battle_selectActorSelection = + Scene_Battle.prototype.selectActorSelection; +Scene_Battle.prototype.selectActorSelection = function() { + if (Yanfly.Param.BECSelectHelp) this._helpWindow.show(); + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_selectActorSelection.call(this); + this._actorWindow.autoSelect(); +}; + +Yanfly.BEC.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel; +Scene_Battle.prototype.onActorCancel = function() { + if (Yanfly.Param.BECSelectHelp) this._helpWindow.hide(); + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onActorCancel.call(this); + BattleManager.stopAllSelection(); + BattleManager.clearInputtingAction(); +}; + +Yanfly.BEC.Scene_Battle_selectEnemySelection = + Scene_Battle.prototype.selectEnemySelection; +Scene_Battle.prototype.selectEnemySelection = function() { + if (Yanfly.Param.BECSelectHelp) this._helpWindow.show(); + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_selectEnemySelection.call(this); + this._enemyWindow.autoSelect(); +}; + +Yanfly.BEC.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel; +Scene_Battle.prototype.onEnemyCancel = function() { + if (Yanfly.Param.BECSelectHelp) this._helpWindow.hide(); + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onEnemyCancel.call(this); + BattleManager.stopAllSelection(); + BattleManager.clearInputtingAction(); +}; + +Yanfly.BEC.Scene_Battle_onSelectAction = Scene_Battle.prototype.onSelectAction; +Scene_Battle.prototype.onSelectAction = function() { + if (Yanfly.Param.BECSelectHelp) BattleManager.forceSelection(); + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onSelectAction.call(this); + if (Yanfly.Param.BECSelectHelp) BattleManager.resetSelection(); +}; + +Yanfly.BEC.Scene_Battle_onSkillOk = + Scene_Battle.prototype.onSkillOk; +Scene_Battle.prototype.onSkillOk = function() { + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onSkillOk.call(this); +}; + +Yanfly.BEC.Scene_Battle_onSkillCancel = + Scene_Battle.prototype.onSkillCancel; +Scene_Battle.prototype.onSkillCancel = function() { + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onSkillCancel.call(this); + BattleManager.clearInputtingAction(); +}; + +Yanfly.BEC.Scene_Battle_onItemOk = + Scene_Battle.prototype.onItemOk; +Scene_Battle.prototype.onItemOk = function() { + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onItemOk.call(this); +}; + +Yanfly.BEC.Scene_Battle_onItemCancel = + Scene_Battle.prototype.onItemCancel; +Scene_Battle.prototype.onItemCancel = function() { + this._helpWindow.clear(); + Yanfly.BEC.Scene_Battle_onItemCancel.call(this); + BattleManager.clearInputtingAction(); +}; + +//============================================================================= +// Window_Selectable +//============================================================================= + +Yanfly.BEC.Window_Selectable_isCursorMovable = + Window_Selectable.prototype.isCursorMovable; +Window_Selectable.prototype.isCursorMovable = function() { + if (this._inputLock) return false; + return Yanfly.BEC.Window_Selectable_isCursorMovable.call(this); +}; + +//============================================================================= +// Window_Help +//============================================================================= + +Yanfly.BEC.Window_Help_clear = Window_Help.prototype.clear; +Window_Help.prototype.clear = function() { + Yanfly.BEC.Window_Help_clear.call(this); + this.contents.clear(); +}; + +Window_Help.prototype.setBattler = function(battler) { + this.contents.clear(); + this.clear(); + this.resetFontSettings(); + if (!$gameParty.inBattle()) return; + if (!battler) return; + var action = BattleManager.inputtingAction(); + if (this.specialSelectionText(action)) { + this.drawSpecialSelectionText(action); + } else { + this.drawBattler(battler); + } +}; + +Window_Help.prototype.specialSelectionText = function(action) { + BattleManager.resetSelection(); + if (!action) return false; + return !action.needsSelection(); +}; + +Window_Help.prototype.drawBattler = function(battler) { + var text = battler.name(); + var wx = 0; + var wy = (this.contents.height - this.lineHeight()) / 2; + this.drawText(text, wx, wy, this.contents.width, 'center'); +}; + +Window_Help.prototype.drawSpecialSelectionText = function(action) { + var wx = 0; + var wy = (this.contents.height - this.lineHeight()) / 2; + var text = ''; + if (action.isForUser()) { + text = Yanfly.Param.BECHelpUserTx; + } else if (action.isForRandom()) { + BattleManager.startAllSelection(); + var fmt = Yanfly.Param.BECHelpRandTx; + if (action.isForOpponent() && action.numTargets() !== 1) { + var target = Yanfly.Param.BECHelpEnemiesTx; + } else if (action.isForOpponent() && action.numTargets() === 1) { + var target = Yanfly.Param.BECHelpEnemyTx; + } else if (action.isForFriend() && action.numTargets() !== 1) { + var target = Yanfly.Param.BECHelpAlliesTx; + } else { + var target = Yanfly.Param.BECHelpAllyTx; + } + text = fmt.format(target, Yanfly.Util.toGroup(action.numTargets())); + } else if (action.isForAll()) { + BattleManager.startAllSelection(); + var fmt = Yanfly.Param.BECHelpAllTx; + if (action.isForOpponent()) { + var target = Yanfly.Param.BECHelpEnemiesTx; + } else { + var target = Yanfly.Param.BECHelpAlliesTx; + } + text = fmt.format(target); + } + this.drawText(text, wx, wy, this.contents.width, 'center'); +}; + +//============================================================================= +// Window_BattleActor +//============================================================================= + +Window_BattleActor.prototype.autoSelect = function() { + var action = BattleManager.inputtingAction(); + if (!action) return; + this._inputLock = false; + this._selectDead = false; + this.setCursorAll(false); + if (action.isForUser()) { + this.select(BattleManager.actor().index()); + this._inputLock = true; + } else if (action.isForAll()) { + this._inputLock = true; + this.setCursorAll(true); + } else if (action.isForDeadFriend()) { + this._selectDead = true; + this.autoSelectFirstDeadActor(); + } + this.updateCursor(); +}; + +Window_BattleActor.prototype.updateCursor = function() { + if (this._cursorAll) { + var allRowsHeight = this.maxRows() * this.itemHeight(); + this.setCursorRect(0, 0, this.contents.width, allRowsHeight); + this.setTopRow(0); + } else if (this.isCursorVisible()) { + var rect = this.itemRect(this.index()); + this.setCursorRect(rect.x, rect.y, rect.width, rect.height); + } else { + this.setCursorRect(0, 0, 0, 0); + } +}; + +Window_BattleActor.prototype.autoSelectFirstDeadActor = function() { + var length = $gameParty.members().length; + for (var i = 0; i < length; ++i) { + var member = $gameParty.members()[i]; + if (member && member.isDead()) return this.select(i); + } +}; + +Window_BattleActor.prototype.isOkEnabled = function() { + if (this._selectDead) return this.actor().isDead(); + return Window_Selectable.prototype.isOkEnabled.call(this); +}; + +Window_BattleActor.prototype.updateHelp = function() { + if (!this._helpWindow) return; + this._helpWindow.setBattler(this.actor()); +}; + +Yanfly.BEC.Window_BattleActor_processTouch = + Window_BattleActor.prototype.processTouch; +Window_BattleActor.prototype.processTouch = function() { + if (Yanfly.Param.BECActorSelect && this.isOpenAndActive()) { + if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) { + if (this.getClickedActor() >= 0) { + var index = this.getClickedActor(); + if (this.index() === index) { + return this.processOk(); + } else { + SoundManager.playCursor(); + return this.select(index); + } + } + } + if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) { + if (this.getClickedActor() >= 0) { + var index = this.getClickedActor(); + if (this.index() !== index) { + SoundManager.playCursor(); + return this.select(index); + } + } + } + if (Yanfly.Param.BECSelectMouseOver) { + var index = this.getMouseOverActor(); + if (index >= 0 && this.index() !== index) { + SoundManager.playCursor(); + return this.select(index); + } + } + } + Yanfly.BEC.Window_BattleActor_processTouch.call(this); +}; + +Window_BattleActor.prototype.getClickedActor = function() { + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var actor = $gameParty.battleMembers().reverse()[i]; + if (!actor) continue; + if (this.isClickedActor(actor)) { + if (this._selectDead && !actor.isDead()) continue; + if (this._inputLock && actor.index() !== this.index()) continue; + return actor.index(); + } + } + return -1; +}; + +Window_BattleActor.prototype.isClickedActor = function(actor) { + if (!actor) return false; + if (!actor.isSpriteVisible()) return false; + if (!actor.isAppeared()) return false; + if ($gameTemp._disableMouseOverSelect) return false; + var x = TouchInput.x; + var y = TouchInput.y; + var rect = new Rectangle(); + rect.width = actor.spriteWidth(); + rect.height = actor.spriteHeight(); + rect.x = actor.spritePosX() - rect.width / 2; + rect.y = actor.spritePosY() - rect.height; + return (x >= rect.x && y >= rect.y && x < rect.x + rect.width && + y < rect.y + rect.height); +}; + +Window_BattleActor.prototype.getMouseOverActor = function() { + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var actor = $gameParty.battleMembers().reverse()[i]; + if (!actor) continue; + if (this.isMouseOverActor(actor)) { + if (this._selectDead && !actor.isDead()) continue; + if (this._inputLock && actor.index() !== this.index()) continue; + return actor.index(); + } + } + return -1; +}; + +Window_BattleActor.prototype.isMouseOverActor = function(actor) { + if (!actor) return false; + if (!actor.isSpriteVisible()) return false; + if (!actor.isAppeared()) return false; + if ($gameTemp._disableMouseOverSelect) return false; + var x = TouchInput._mouseOverX; + var y = TouchInput._mouseOverY; + var rect = new Rectangle(); + rect.width = actor.spriteWidth(); + rect.height = actor.spriteHeight(); + rect.x = actor.spritePosX() - rect.width / 2; + rect.y = actor.spritePosY() - rect.height; + return (x >= rect.x && y >= rect.y && x < rect.x + rect.width && + y < rect.y + rect.height); +}; + +//============================================================================= +// Window_BattleEnemy +//============================================================================= + +Yanfly.DisableWebGLMask = false; + +Yanfly.BEC.Window_BattleEnemy_initialize = + Window_BattleEnemy.prototype.initialize; +Window_BattleEnemy.prototype.initialize = function(x, y) { + if (Yanfly.Param.BECEnemySelect) { + x -= Graphics.boxWidth * 200; + y -= Graphics.boxHeight * 200; + }; + Yanfly.BEC.Window_BattleEnemy_initialize.call(this, x, y); +}; + +Yanfly.BEC.WindowLayer_webglMaskWindow = + WindowLayer.prototype._webglMaskWindow; +WindowLayer.prototype._webglMaskWindow = function(renderSession, win) { + if (win._ignoreMask) return; + Yanfly.BEC.WindowLayer_webglMaskWindow.call(this, renderSession, win); +}; + +Yanfly.BEC.Window_BattleEnemy_maxCols = + Window_BattleEnemy.prototype.maxCols; +Window_BattleEnemy.prototype.maxCols = function() { + if (Yanfly.Param.BECEnemySelect) return this._enemies.length; + return Yanfly.BEC.Window_BattleEnemy_maxCols.call(this); +}; + +Window_BattleEnemy.prototype.allowedTargets = function() { + var targets = []; + targets = targets.concat($gameTroop.aliveMembers()); + return targets; +}; + +Window_BattleEnemy.prototype.refresh = function() { + this._enemies = this.allowedTargets(); + this.sortTargets(); + Window_Selectable.prototype.refresh.call(this); +}; + +Window_BattleEnemy.prototype.sortTargets = function() { + this._enemies.sort(function(a, b) { + if (a.spritePosX() === b.spritePosX()) { + return a.spritePosY() - b.spritePosY(); + } + return a.spritePosX() - b.spritePosX(); + }); +}; + +Window_BattleEnemy.prototype.autoSelect = function() { + if (Yanfly.Param.BECEnemyAutoSel === 0 || + Yanfly.Param.BECEnemyAutoSel === '0') { + var selectIndex = 0; + } else { + var selectIndex = this.furthestRight(); + } + this.select(selectIndex); +}; + +Window_BattleEnemy.prototype.furthestRight = function() { + return this.maxItems() - 1; +}; + +Window_BattleEnemy.prototype.updateHelp = function() { + if (!this._helpWindow) return; + this._helpWindow.setBattler(this.enemy()); +}; + +Yanfly.BEC.Window_BattleEnemy_processTouch = + Window_BattleEnemy.prototype.processTouch; +Window_BattleEnemy.prototype.processTouch = function() { + if (Yanfly.Param.BECEnemySelect && this.isOpenAndActive()) { + if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) { + if (this.getClickedEnemy() >= 0) { + var index = this.getClickedEnemy(); + if (this.index() === index) { + return this.processOk(); + } else { + SoundManager.playCursor(); + return this.select(index); + } + } + } + if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) { + if (this.getClickedEnemy() >= 0) { + var index = this.getClickedEnemy(); + if (this.index() !== index) { + SoundManager.playCursor(); + return this.select(index); + } + } + } + if (Yanfly.Param.BECSelectMouseOver) { + var index = this.getMouseOverEnemy(); + if (index >= 0 && this.index() !== index) { + SoundManager.playCursor(); + return this.select(index); + } + } + }; + Yanfly.BEC.Window_BattleEnemy_processTouch.call(this); +}; + +Window_BattleEnemy.prototype.getClickedEnemy = function() { + for (var i = 0; i < this._enemies.length; ++i) { + var enemy = this._enemies[i]; + if (!enemy) continue; + if (this.isClickedEnemy(enemy)) { + if (this._selectDead && !enemy.isDead()) continue; + var index = this._enemies.indexOf(enemy) + if (this._inputLock && index !== this.index()) continue; + return index; + } + } + return -1; +}; + +Window_BattleEnemy.prototype.isClickedEnemy = function(enemy) { + if (!enemy) return false; + if (!enemy.isSpriteVisible()) return false; + if ($gameTemp._disableMouseOverSelect) return false; + var x = TouchInput.x; + var y = TouchInput.y; + var rect = new Rectangle(); + rect.width = enemy.spriteWidth(); + rect.height = enemy.spriteHeight(); + rect.x = enemy.spritePosX() - rect.width / 2; + rect.y = enemy.spritePosY() - rect.height; + return (x >= rect.x && y >= rect.y && x < rect.x + rect.width && + y < rect.y + rect.height); +}; + +Window_BattleEnemy.prototype.getMouseOverEnemy = function() { + for (var i = 0; i < this._enemies.length; ++i) { + var enemy = this._enemies[i]; + if (!enemy) continue; + if (this.isMouseOverEnemy(enemy)) { + if (this._selectDead && !enemy.isDead()) continue; + var index = this._enemies.indexOf(enemy) + if (this._inputLock && index !== this.index()) continue; + return index; + } + } + return -1; +}; + +Window_BattleEnemy.prototype.isMouseOverEnemy = function(enemy) { + if (!enemy) return false; + if (!enemy.isSpriteVisible()) return false; + if ($gameTemp._disableMouseOverSelect) return false; + var x = TouchInput._mouseOverX; + var y = TouchInput._mouseOverY; + var rect = new Rectangle(); + rect.width = enemy.spriteWidth(); + rect.height = enemy.spriteHeight(); + rect.x = enemy.spritePosX() - rect.width / 2; + rect.y = enemy.spritePosY() - rect.height; + return (x >= rect.x && y >= rect.y && x < rect.x + rect.width && + y < rect.y + rect.height); +}; + +//============================================================================= +// Window_EnemyVisualSelect +//============================================================================= + +function Window_EnemyVisualSelect() { + this.initialize.apply(this, arguments); +} + +Window_EnemyVisualSelect.prototype = Object.create(Window_Base.prototype); +Window_EnemyVisualSelect.prototype.constructor = Window_EnemyVisualSelect; + +Window_EnemyVisualSelect.prototype.initialize = function() { + Window_Base.prototype.initialize.call(this, 0, 0, 1, 1); + this._battler = null; + this._battlerName = ''; + this._requestRefresh = false; + this._showSelectCursor = Yanfly.Param.BECShowSelectBox; + this._showEnemyName = Yanfly.Param.BECShowEnemyName; + this.contentsOpacity = 0; + this.opacity = 0; +}; + +Window_EnemyVisualSelect.prototype.setBattler = function(battler) { + if (this._battler === battler) return; + this._battler = battler; + this._battlerName = battler.name(); +}; + +Window_EnemyVisualSelect.prototype.update = function() { + Window_Base.prototype.update.call(this); + if (!this._battler) return; + this.updateWindowAspects(); +}; + +Window_EnemyVisualSelect.prototype.updateWindowAspects = function() { + this.updateBattlerName(); + this.updateWindowSize(); + this.updateWindowPosition(); + this.updateOpacity(); + this.updateRefresh(); + this.updateCursor(); +}; + +Window_EnemyVisualSelect.prototype.updateBattlerName = function() { + if (this._battlerName !== this._battler.name()) { + this._battlerName = this._battler.name(); + this._requestRefresh = true; + this._nameTextWidth = undefined; + } +}; + +Window_EnemyVisualSelect.prototype.updateWindowSize = function() { + var spriteWidth = this._battler.spriteWidth(); + this.contents.fontSize = Yanfly.Param.BECEnemyFontSize; + if (this._nameTextWidth === undefined) { + this._nameTextWidth = this.textWidth(this._battler.name()); + } + var textWidth = this._nameTextWidth; + textWidth += this.textPadding() * 2; + var width = Math.max(spriteWidth, textWidth) + this.standardPadding() * 2; + width = Math.ceil(width); + var height = this._battler.spriteHeight() + this.standardPadding() * 2; + height = Math.ceil(height); + height = Math.max(height, this.lineHeight() + this.standardPadding() * 2); + if (width === this.width && height === this.height) return; + this.width = width; + this.height = height; + this.createContents(); + this._requestRefresh = true; + this.makeWindowBoundaries(); +}; + +Window_EnemyVisualSelect.prototype.makeWindowBoundaries = function() { + if (!this._requestRefresh) return; + this._minX = -1 * this.standardPadding(); + this._maxX = Graphics.boxWidth - this.width + this.standardPadding(); + this._minY = -1 * this.standardPadding(); + this._maxY = Graphics.boxHeight - this.height + this.standardPadding(); + this._maxY -= SceneManager._scene._statusWindow.height; +}; + +Window_EnemyVisualSelect.prototype.updateWindowPosition = function() { + if (!this._battler) return; + this.x = -1 * this.width / 2; + this.y = -1 * this.height + this.standardPadding(); + this.x += this._battler.spritePosX(); + this.y += this._battler.spritePosY(); + this.x = this.x.clamp(this._minX, this._maxX); + this.y = this.y.clamp(this._minY, this._maxY); +}; + +Window_EnemyVisualSelect.prototype.updateOpacity = function() { + if (this.isShowWindow()) { + this.contentsOpacity += 32; + } else { + this.contentsOpacity -= 32; + } +}; + +Window_EnemyVisualSelect.prototype.isShowWindow = function() { + var scene = SceneManager._scene; + if (!scene._enemyWindow) return false; + var enemyWindow = scene._enemyWindow; + if (!enemyWindow.active) return false; + if (!this._battler.isAppeared()) return false; + if (this._battler.isDead()) { + return enemyWindow._selectDead; + } + return enemyWindow._enemies.contains(this._battler); +}; + +Window_EnemyVisualSelect.prototype.updateCursor = function() { + if (this.isShowCursor()) { + var wy = this.contents.height - this.lineHeight(); + this.setCursorRect(0, wy, this.contents.width, this.lineHeight()); + } else { + this.setCursorRect(0, 0, 0, 0); + } +}; + +Window_EnemyVisualSelect.prototype.isShowCursor = function() { + if (!this._showSelectCursor) return false; + var scene = SceneManager._scene; + if (!scene._enemyWindow) return false; + var enemyWindow = scene._enemyWindow; + if (!enemyWindow.active) return false; + if (!this._battler.isAppeared()) return false; + return this._battler.isSelected(); +}; + +Window_EnemyVisualSelect.prototype.updateRefresh = function() { + if (this._requestRefresh) this.refresh(); +}; + +Window_EnemyVisualSelect.prototype.refresh = function() { + this.contents.clear(); + if (!this._battler) return; + if (!this._showEnemyName) return; + if (this._battler.isHidden()) return; + this._requestRefresh = false; + this.contents.fontSize = Yanfly.Param.BECEnemyFontSize; + var text = this._battler.name(); + var wy = this.contents.height - this.lineHeight(); + this.drawText(text, 0, wy, this.contents.width, 'center'); +}; + +//============================================================================= +// Window_PartyCommand +//============================================================================= + +Window_PartyCommand.prototype.itemTextAlign = function() { + return Yanfly.Param.BECCommandAlign; +}; + +Window_PartyCommand.prototype.numVisibleRows = function() { + return Yanfly.Param.BECCommandRows; +}; + +//============================================================================= +// Window_ActorCommand +//============================================================================= + +Window_ActorCommand.prototype.itemTextAlign = function() { + return Yanfly.Param.BECCommandAlign; +}; + +Window_ActorCommand.prototype.numVisibleRows = function() { + return Yanfly.Param.BECCommandRows; +}; + +//============================================================================= +// Window_BattleStatus +//============================================================================= + +Window_BattleStatus.prototype.numVisibleRows = function() { + return Yanfly.Param.BECCommandRows; +}; + +Window_BattleStatus.prototype.updateStatusRequests = function() { + if (BattleManager._victoryPhase) return; + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var actor = $gameParty.battleMembers()[i]; + if (!actor) continue; + if (actor.isStatusRefreshRequested()) this.processStatusRefresh(i); + } +}; + +Window_BattleStatus.prototype.processStatusRefresh = function(index) { + var actor = $gameParty.battleMembers()[index]; + if (!actor) return; + var rect = this.itemRect(index); + this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); + this.drawItem(index); + actor.completetStatusRefreshRequest(); +}; + +Window_BattleStatus.prototype.update = function() { + Window_Selectable.prototype.update.call(this); +}; + +if (!Yanfly.Param.BECCurMax) { + +Window_BattleStatus.prototype.drawCurrentAndMax = function(current, max, x, y, + width, color1, color2) { + var labelWidth = this.textWidth('HP'); + var valueWidth = this.textWidth(Yanfly.Util.toGroup(max)); + var slashWidth = this.textWidth('/'); + var x1 = x + width - valueWidth; + this.changeTextColor(color1); + this.drawText(Yanfly.Util.toGroup(current), x1, y, valueWidth, 'right'); +}; + +}; // Yanfly.Param.BECCurMax + +//============================================================================= +// Window_BattleLog +//============================================================================= + +Yanfly.BEC.Window_BattleLog_isFastForward = + Window_BattleLog.prototype.isFastForward; +Window_BattleLog.prototype.isFastForward = function() { + if (Yanfly.Param.BECOptSpeed) return true; + return Yanfly.BEC.Window_BattleLog_isFastForward.call(this); +}; + +Window_BattleLog.prototype.updateWaitCount = function() { + if (this._waitCount > 0) { + this._waitCount -= 1; + if (this._waitCount < 0) { + this._waitCount = 0; + } + return true; + } + return false; +}; + +Window_BattleLog.prototype.animationBaseDelay = function() { + return Yanfly.Param.BECAniBaseDel; +}; + +Window_BattleLog.prototype.animationNextDelay = function() { + return Yanfly.Param.BECAniNextDel; +}; + +Window_BattleLog.prototype.updateWaitMode = function() { + var waiting = false; + switch (this._waitMode) { + case 'effect': + waiting = this._spriteset.isEffecting(); + break; + case 'movement': + waiting = this._spriteset.isAnyoneMoving(); + break; + case 'animation': + waiting = this._spriteset.isAnimationPlaying(); + break; + case 'popups': + waiting = this._spriteset.isPopupPlaying(); + break; + } + if (!waiting) { + this._waitMode = ''; + } + return waiting; +}; + +Window_BattleLog.prototype.startAction = function(subject, action, targets) { +}; + +Window_BattleLog.prototype.endAction = function(subject) { +}; + +Window_BattleLog.prototype.waitForAnimation = function() { + this.setWaitMode('animation'); +}; + +Window_BattleLog.prototype.waitForEffect = function() { + this.setWaitMode('effect'); +}; + +Window_BattleLog.prototype.waitForPopups = function() { + this.setWaitMode('popups'); +}; + +Yanfly.BEC.Window_BattleLog_displayAction = + Window_BattleLog.prototype.displayAction; +Window_BattleLog.prototype.displayAction = function(subject, item) { + if (Yanfly.Param.BECFullActText) { + Yanfly.BEC.Window_BattleLog_displayAction.call(this, subject, item); + } else { + this._actionIcon = this.displayIcon(item); + var text = this.displayText(item); + this.push('addText', '' + text); + if (item.message2) { + this.push('addText', '
' + item.message2.format(text)); + } + } +}; + +Window_BattleLog.prototype.displayIcon = function(item) { + if (!item) return 0; + return item.battleDisplayIcon; +}; + +Window_BattleLog.prototype.displayText = function(item) { + if (!item) return ''; + return item.battleDisplayText; +}; + +Yanfly.BEC.Window_BattleLog_displayActionResults = + Window_BattleLog.prototype.displayActionResults; +Window_BattleLog.prototype.displayActionResults = function(subject, target) { + if (Yanfly.Param.BECOptSpeed) { + if (target.result().used) { + this.displayCritical(target); + this.displayDamage(target); + this.displayAffectedStatus(target); + this.displayFailure(target); + } + } else { + Yanfly.BEC.Window_BattleLog_displayActionResults.call(this, subject, + target); + } + if (target.isDead()) target.performCollapse(); +}; + +Yanfly.BEC.Window_BattleLog_drawLineText = + Window_BattleLog.prototype.drawLineText; +Window_BattleLog.prototype.drawLineText = function(index) { + if (this._lines[index].match('
')) { + this.drawCenterLine(index); + } else if (this._lines[index].match('')) { + this.drawSimpleActionLine(index); + } else { + Yanfly.BEC.Window_BattleLog_drawLineText.call(this, index); + } +}; + +Window_BattleLog.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height + this.lineHeight()); +}; + +Window_BattleLog.prototype.drawCenterLine = function(index) { + var text = this._lines[index].replace('
', ''); + var rect = this.itemRectForText(index); + this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); + var tw = this.textWidthEx(text); + var wx = rect.x + (rect.width - tw) / 2; + this.resetFontSettings(); + this.drawTextEx(text, wx, rect.y); +}; + +Window_BattleLog.prototype.drawSimpleActionLine = function(index) { + var text = this._lines[index].replace('', ''); + var rect = this.itemRectForText(index); + this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); + if (this._actionIcon) { + var tw = this.textWidth(text); + var ix = (rect.width - tw) / 2 - 4; + this.drawIcon(this._actionIcon, ix, rect.y + 2); + } + this.drawText(text, rect.x, rect.y, Graphics.boxWidth, 'center'); +}; + +Window_BattleLog.prototype.displayCounter = function(target) { + if (Yanfly.Param.BECShowCntText) { + this.addText(TextManager.counterAttack.format(target.name())); + } + target.performCounter(); + this.showAttackAnimation(target, [BattleManager._subject]); + this.waitForAnimation(); +}; + +Window_BattleLog.prototype.displayReflection = function(target) { + if (Yanfly.Param.BECShowRflText) { + this.addText(TextManager.magicReflection.format(target.name())); + } + target.performReflection(); + var animationId = BattleManager._action.item().animationId; + this.showNormalAnimation([BattleManager._subject], animationId); + this.waitForAnimation(); +}; + +Window_BattleLog.prototype.displaySubstitute = function(substitute, target) { + if (Yanfly.Param.BECShowSubText) { + var substName = substitute.name(); + this.addText(TextManager.substitute.format(substName, target.name())); + } + substitute.performSubstitute(target); +}; + +Yanfly.BEC.Window_BattleLog_displayFailure = + Window_BattleLog.prototype.displayFailure; +Window_BattleLog.prototype.displayFailure = function(target) { + if (!Yanfly.Param.BECShowFailText) return; + Yanfly.BEC.Window_BattleLog_displayFailure.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayCritical = + Window_BattleLog.prototype.displayCritical; +Window_BattleLog.prototype.displayCritical = function(target) { + if (!Yanfly.Param.BECShowCritText) return; + Yanfly.BEC.Window_BattleLog_displayCritical.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayMiss = + Window_BattleLog.prototype.displayMiss; +Window_BattleLog.prototype.displayMiss = function(target) { + if (!Yanfly.Param.BECShowMissText) return; + Yanfly.BEC.Window_BattleLog_displayMiss.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayEvasion = + Window_BattleLog.prototype.displayEvasion; +Window_BattleLog.prototype.displayEvasion = function(target) { + if (!Yanfly.Param.BECShowEvaText) return; + Yanfly.BEC.Window_BattleLog_displayEvasion.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayHpDamage = + Window_BattleLog.prototype.displayHpDamage; +Window_BattleLog.prototype.displayHpDamage = function(target) { + if (!Yanfly.Param.BECShowHpText) return; + Yanfly.BEC.Window_BattleLog_displayHpDamage.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayMpDamage = + Window_BattleLog.prototype.displayMpDamage; +Window_BattleLog.prototype.displayMpDamage = function(target) { + if (!Yanfly.Param.BECShowMpText) return; + Yanfly.BEC.Window_BattleLog_displayMpDamage.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayTpDamage = + Window_BattleLog.prototype.displayTpDamage; +Window_BattleLog.prototype.displayTpDamage = function(target) { + if (!Yanfly.Param.BECShowTpText) return; + Yanfly.BEC.Window_BattleLog_displayTpDamage.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayCurrentState = + Window_BattleLog.prototype.displayCurrentState; +Window_BattleLog.prototype.displayCurrentState = function(subject) { + if (!Yanfly.Param.BECShowStateText) return; + Yanfly.BEC.Window_BattleLog_displayCurrentState.call(this, subject); +}; + +Yanfly.BEC.Window_BattleLog_displayAddedStates = + Window_BattleLog.prototype.displayAddedStates; +Window_BattleLog.prototype.displayAddedStates = function(target) { + if (!Yanfly.Param.BECShowStateText) return; + Yanfly.BEC.Window_BattleLog_displayAddedStates.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayRemovedStates = + Window_BattleLog.prototype.displayRemovedStates; +Window_BattleLog.prototype.displayRemovedStates = function(target) { + if (!Yanfly.Param.BECShowStateText) return; + Yanfly.BEC.Window_BattleLog_displayRemovedStates.call(this, target); +}; + +Yanfly.BEC.Window_BattleLog_displayChangedBuffs = + Window_BattleLog.prototype.displayChangedBuffs; +Window_BattleLog.prototype.displayChangedBuffs = function(target) { + if (!Yanfly.Param.BECShowBuffText) return; + Yanfly.BEC.Window_BattleLog_displayChangedBuffs.call(this, target); +}; + +Window_BattleLog.prototype.popupDamage = function(target) { +}; + +Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation = + Window_BattleLog.prototype.showEnemyAttackAnimation; +Window_BattleLog.prototype.showEnemyAttackAnimation = +function(subject, targets) { + if ($gameSystem.isSideView()) { + this.showNormalAnimation(targets, subject.attackAnimationId(), false); + } else { + this.showNormalAnimation(targets, subject.attackAnimationId(), false); + Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation.call(this, subject, + targets); + } +}; + +Window_BattleLog.prototype.showActorAtkAniMirror = function(subject, targets) { + if (subject.isActor()) { + this.showNormalAnimation(targets, subject.attackAnimationId1(), true); + this.showNormalAnimation(targets, subject.attackAnimationId2(), false); + } else { + this.showNormalAnimation(targets, subject.attackAnimationId1(), true) + } +}; + +//============================================================================= +// New Function +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +Yanfly.Util.getRange = function(n, m) { + var result = []; + for (var i = n; i <= m; ++i) result.push(i); + return result; +}; + +Yanfly.Util.onlyUnique = function(value, index, self) { + return self.indexOf(value) === index; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_BuffsStatesCore.js b/js/plugins/YEP_BuffsStatesCore.js new file mode 100644 index 0000000..2c0eccd --- /dev/null +++ b/js/plugins/YEP_BuffsStatesCore.js @@ -0,0 +1,2202 @@ +//============================================================================= +// Yanfly Engine Plugins - Buffs & States Core +// YEP_BuffsStatesCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_BuffsStatesCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.BSC = Yanfly.BSC || {}; +Yanfly.BSC.version = 1.16; + +//============================================================================= + /*: + * @plugindesc v1.16 Alter the basic mechanics behind buffs and states + * that aren't adjustable within the RPG Maker editor. + * @author Yanfly Engine Plugins + * + * @param ---Turn Indicator--- + * @default + * + * @param Show Turns + * @parent ---Turn Indicator--- + * @type boolean + * @on Show + * @off Hide + * @desc Show turns remaining for buffs and states? + * NO - false YES - true + * @default true + * + * @param Font Size + * @parent ---Turn Indicator--- + * @type number + * @min 1 + * @desc The default font size used for turn count. + * Default: 28 + * @default 16 + * + * @param Turn Alignment + * @parent ---Turn Indicator--- + * @type combo + * @option left + * @option center + * @option right + * @desc How do you want to align the turns? + * left center right + * @default right + * + * @param Turn Buffer X + * @parent ---Turn Indicator--- + * @desc Buffer the x position of the turn by this much. + * @default -3 + * + * @param Turn Buffer Y + * @parent ---Turn Indicator--- + * @desc Buffer the y position of the turn by this much. + * @default -6 + * + * @param State Color + * @parent ---Turn Indicator--- + * @type number + * @min 0 + * @max 31 + * @desc The default text color used for state turns. + * @default 0 + * + * @param Buff Color + * @parent ---Turn Indicator--- + * @type number + * @min 0 + * @max 31 + * @desc The default text color used for buffs. + * @default 24 + * + * @param Debuff Color + * @parent ---Turn Indicator--- + * @type number + * @min 0 + * @max 31 + * @desc The default text color used for debuffs. + * @default 2 + * + * @param ---Enemy Icons--- + * @default + * + * @param Show Enemy Icons + * @parent ---Enemy Icons--- + * @type boolean + * @on Show + * @off Hide + * @desc Do you wish to show enemy state icons? + * NO - false YES - true + * @default true + * + * @param Enemy Buff Turn + * @parent ---Enemy Icons--- + * @type boolean + * @on Show + * @off Hide + * @desc Do you wish to show enemy buff turns remaining? + * NO - false YES - true + * @default true + * + * @param Enemy State Turn + * @parent ---Enemy Icons--- + * @type boolean + * @on Show + * @off Hide + * @desc Do you wish to show enemy state turns remaining? + * NO - false YES - true + * @default true + * + * @param Enemy State Counter + * @parent ---Enemy Icons--- + * @type boolean + * @on Show + * @off Hide + * @desc Do you wish to show enemy state counters? + * NO - false YES - true + * @default true + * + * @param ---Buff Settings--- + * @default + * + * @param Default Limit + * @parent ---Buff Settings--- + * @type number + * @min 1 + * @desc The default number of times you can stack buff/debuff. + * Default: 2 + * @default 4 + * + * @param Maximum Limit + * @parent ---Buff Settings--- + * @type number + * @min 1 + * @desc The maximum number of times you can stack buff/debuff. + * @default 8 + * + * @param Buff Formula + * @parent ---Buff Settings--- + * @desc The formula used for buff rate calculation. + * Default: this._buffs[paramId] * 0.25 + 1.0 + * @default this._buffs[paramId] * 0.25 + 1.0 + * + * @param Show Buff Rate + * @parent ---Buff Settings--- + * @type boolean + * @on Show + * @off Hide + * @desc Shows the buff/debuff rate for buffs and debuffs. + * YES - true NO - false + * @default false + * + * @param ---State Settings--- + * @default + * + * @param Reapply Rules + * @parent ---State Settings--- + * @type select + * @option Ignore + * @value 0 + * @option Reset + * @value 1 + * @option Add + * @value 2 + * @desc The rules when reapplying an already existing state: + * 0 - Ignore 1 - Reset 2 - Add + * @default 1 + * + * @param Show Enemy Turns + * @parent ---State Settings--- + * @type boolean + * @on Show + * @off Hide + * @desc If using Battle Engine Core, show turns in help window? + * NO - false YES - true + * @default true + * + * @param ---Counter Settings--- + * @default + * + * @param Counter Font Size + * @parent ---Counter Settings--- + * @type number + * @min 1 + * @desc The default font size used for state counters. + * Default: 28 + * @default 16 + * + * @param Counter Alignment + * @parent ---Counter Settings--- + * @type combo + * @option left + * @option center + * @option right + * @desc How do you want to align the counter? + * left center right + * @default center + * + * @param Counter Buffer X + * @parent ---Counter Settings--- + * @desc Buffer the x position of the counter by this much. + * @default 0 + * + * @param Counter Buffer Y + * @parent ---Counter Settings--- + * @desc Buffer the y position of the counter by this much. + * @default 8 + * + * @param Counter Color + * @parent ---Counter Settings--- + * @type number + * @min 0 + * @max 31 + * @desc The default text color used for state counters. + * @default 0 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * If you are using YEP_BattleEngineCore.js, please this plugin under + * YEP_BattleEngineCore in the plugin list for the best effect. + * + * Alter the basic mechanics behind buffs and states that aren't adjustable + * within the RPG Maker editor. Such mechanics include altering the maximum + * number of times buffs can stack, changing the turns remaining on buffs and + * states, and the rules involved when reapplying states. + * + * A turn indicator has been added to show the amount of turns remaining on + * buffs, debuffs, and states. Buffs and debuffs will operate off the plugin + * parameter settings while states can operate on individual settings if you + * choose for them to have unique settings. + * + * Furthermore, a lot of Lunatic Mode options are added with this plugin to + * allow those with JavaScript proficiency maximum control with states and any + * unique effects that follow. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * The following are various notetags you can use to modify states and buffs. + * + * --- Buff Related --- + * + * Actor, Class, Enemy, Weapon, Armor, and State notetags: + * + * + * + * + * Replace 'stat' with 'maxhp', 'maxmp', 'atk', 'def', 'mat', 'mdf', 'agi', + * or 'luk' without the quotes. This notetag adjusts the maximum number of + * times the stat can be buffed or debuffed to the Maximum Limit cap in the + * plugin parameters. + * + * Skill and Item Notetags: + * + * + * + * + * Modifies already applied buff/debuff turns on target by x value. If this + * brings a buff/debuff to 0 or below, the buff/debuff is removed. + * + * --- State Related --- + * + * State Notetags: + * + * + * Show/hide the turn count remaining for the state. This will override the + * default setting. + * + * + * Sets the font size used for this specific state to be x. This will + * override the default setting. + * + * + * + * + * This sets the text alignment for the turn count indicator. This will + * override the default setting. + * + * + * + * + * + * Allows you to adjust the x/y position manually for the turn count for this + * particular state. This will override the default settings. + * + * + * This will set the turn count display color to text color x. This will + * override the default setting. + * + * + * + * + * Changes the rules when this state is reapplied on a battler. When ignored, + * the turn count remains unchanged. When reset, the turn count is set back + * to the default amount with variance. When added, the turn count is added + * upon with variance. + * + * Skill and Item Notetags: + * + * + * + * + * Modifies already applied state x turns on target by y value. If this + * brings the state to 0 or below turns, the state is removed. If you are + * using named states and have multiple states with the same name, priority + * will be given to the state with the highest ID. + * + * Enemy Notetags: + * + * + * Affected by the Battle Engine Core. When selecting enemies, the state + * turns will show up in the help window. You can use this to have certain + * enemies show the state turns or hide them. + * + * ============================================================================ + * Lunatic Mode - Custom Turn Modifiers + * ============================================================================ + * + * For those with an understanding of JavaScript, you can use these notetags to + * give conditional turn modifiers when altering a target's buff/state turn + * count. Follow the instructions below: + * + * Skill and Item Notetags: + * + * + * turn = 10; + * turn += user.agi; + * + * Replace 'stat' with 'maxhp', 'maxmp', 'atk', 'def', 'mat', 'mdf', 'agi', + * or 'luk' without the quotes. Whatever the 'turn' variable returns is what + * the turn count will be set to for the stat buff. + * + * + * turn = 10; + * turn += user.agi; + * + * Replace 'stat' with 'maxhp', 'maxmp', 'atk', 'def', 'mat', 'mdf', 'agi', + * or 'luk' without the quotes. Whatever the 'turn' variable returns is what + * the turn count will be set to for the stat debuff. + * + * + * turn = 10; + * turn += user.agi; + * + * This alters the turn count for state x. Whatever the 'turn' variable + * returns is what the turn count will be set for state x. + * + * + * turn = 10; + * turn += user.agi; + * + * This alters the turn count for state 'name'. Whatever the 'turn' variable + * returns is what the turn count will be set for state 'name'. If you have + * multiple states in your database with the same name, priority will be + * given to the state with the highest ID. + * + * ============================================================================ + * Lunatic Mode - Custom Timing Effects + * ============================================================================ + * + * For those with an understanding of JavaScript, you can use these notetags to + * cause code to run at certain times. + * + * Quick Reference: + * - Apply: When a state is added. + * - Remove: When a state is removed. + * - Leave: When a state expires by reaching 0 turns. + * - Turn Start: Whenever the battler's turn starts. + * - Action Start: Whenever the battler performs a new action. + * - Action End: Whenever the battler finishes an action. + * - Regenerate: Whenever the battler would regenerate HP/MP/TP. + * - Turn End: Whenever the battler's turn ends. + * - Battle: Whenever a battle is started. + * - Victory: Whenever a battle is won. *Note1 + * - Escape: Whenever a battle is escaped. *Note1 + * - Defeat: Whenever a battle is lost. *Note1 + * + * *Note1: If the state is set to expire on battle end, the expiration will + * occur before the custom effects would take place, meaning the effects will + * not occur at all unless the expiration is set to off. + * + * State Notetags: + * + * --- Timing Effects --- + * + * These effects specifically occur at certain intervals or timings. + * + * + * code + * code + * + * The code in between these notetags will run when the state is added onto + * a battler. The code will process after the state is actually applied. + * + * + * code + * code + * + * The code in between these notetags will run when the state is removed from + * a battler either manually or due to turn decay. The code will process + * after the state is actually removed but before . + * + * + * code + * code + * + * The code in between these notetags will run when the state is removed from + * a battler due to turn decay. The code will process after the state is + * actually removed and after . + * + * + * code + * code + * + * This requires YEP_BattleEngineCore. This effect will run at the start of + * each of the battler's turns. The code will process after all the other + * turn start effects have taken course. + * + * + * code + * code + * + * This effect will run at the start of each of the battler's actions. The + * code will process before the skill/item cost takes place. + * + * + * code + * code + * + * This effect will run at the end of each of the battler's actions. The + * code will process before the action end steps takes place. + * + * + * code + * code + * + * This effect will run whenever the battler would regenerate HP, MP, or TP. + * The code will process after all the other regenerate effects have ran. + * + * + * code + * code + * + * This effect will run at the end of each of the battler's turns. The code + * will process after all the other turn end effects have taken course. + * + * + * code + * code + * + * This effect will occur at the start of battle if the battler has the state + * already applied (usually through a passive state). + * + * + * code + * code + * + * This effect will occur at the end of battle if the party is victorious. + * This will only apply to the player's party. If this state can expire at + * the end of battle, this effect will not occur as state expiration will + * occur before this effect will happen. + * + * + * code + * code + * + * This effect will occur at the end of battle if the party has escaped. + * This will only apply to the player's party. If this state can expire at + * the end of battle, this effect will not occur as state expiration will + * occur before this effect will happen. + * + * + * code + * code + * + * This effect will occur at the end of battle if the party is defeated. + * This will only apply to the player's party. If this state can expire at + * the end of battle, this effect will not occur as state expiration will + * occur before this effect will happen. + * + * ============================================================================ + * Lunatic Mode - Custom Action Effects + * ============================================================================ + * + * For those with an understanding of JavaScript, you can use these notetags to + * cause code to run during actions. + * + * Quick Reference: + * Action Starts + * - Attacker: Initiate + * - Defender: Select + * Action Connects as a Success Hit, skip if Missed or Evaded + * - Attacker: Confirm + * - Defender: React + * Damage is Applied to the Defender + * - Defender: Respond + * - Attacker: Establish + * These occur regardless if the action is successfully hit. + * - Defender: Deselect + * - Attacker: Conclude + * + * State Notetags: + * + * --- On Action Effects --- + * + * These effects specifically occur when the battler is a target of an action. + * + * + * code + * code + * + * This effect will run when the battler selects a target. This will occur + * before hit/miss/evade confirmation and damage execution. This effect will + * run before everything else has taken course. + * + * + * code + * code + * + * This effect will run when the battler is selected as a target. This will + * occur before hit/miss/evade confirmation and damage execution. This effect + * will run after before everything else has ran. + * + * + * code + * code + * + * This effect will run when the battler connects a hit and before damage + * execution occurs. This effect will run after and + * and before everything else. + * + * + * value -= 100; + * value -= user.def; + * + * This effect will run when the battler is selected as a target. This will + * occur only if the action connects and will occur before damage execution. + * This effect will run before damage calculation occurs and will return the + * 'value' variable as a damage modifier. After , this + * effect will run. + * + * + * code + * code + * + * This effect will run when the battler is selected as a target. This will + * occur only if the action connects and will occur after damage execution. + * This effect will run after damage calculation occurs. The 'value' variable + * is equal to the damage dealt to the battler. This is the first effect to + * run after damage execution has taken place. + * + * + * code + * code + * + * This effect will run when the battler connects a hit and after damage + * execution occurs. This effect will run after has + * occurred and before everything else. + * + * + * code + * code + * + * This effect will run when the battler is selected as a target. This will + * occur after hit/miss/evade confirmation and damage execution. This effect + * will run after everything else has taken course. + * + * + * code + * code + * + * This is the final effect to be run after the battler selects a target and + * will occur after hit/miss/evade confirmation and damage execution. + * + * ============================================================================ + * Lunatic Mode - State Counters + * ============================================================================ + * + * State Counters are newly added features to suplement states. They are used + * purely in custom manners, which means they do not serve any function by + * themselves. State Counters can be used to note a number of stacks, a stored + * percentage, display a message, etc. All of it is purely updated based on + * JavaScript functions. + * + * --- + * + * There are a couple of notetags you can use for states: + * + * + * This adjusts the font size of the counter. + * + * + * + * + * This changes the alignment of the counter text. + * + * + * + * This adjusts the X buffer range for the counter text. + * + * + * + * This adjusts the Y buffer range for the counter text. + * + * + * This changes the font color of the text to the text color x. + * + * --- + * + * The following are JavaScript functions you may use to adjust counters: + * + * battler.clearStateCounters(); + * - This will clear all the counter values for all states. + * + * battler.setStateCounter(stateId, value); + * - This will set the counter value for the particular state to 'value'. + * + * battler.addStateCounter(stateId, value); + * - This will add to the counter value for the state. The counter must be + * a number in order for this to work. + * + * battler.clampStateCounter(stateId, min, max); + * - This will set a minimum and maximum value for the counter value of the + * particular state. The counter must be a number in order for this to work. + * + * battler.removeStateCounter(stateId) + * - This will clear the counter value for the state. + * + * battler.getStateCounter(stateId) + * - This will return the current state counter value. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.16: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.15: + * - Updated for RPG Maker MV version 1.6.1. + * + * Version 1.14: + * - Updated for RPG Maker MV version 1.5.0. + * - Fixed documentation error. + * + * Version 1.13: + * - Custom Turn End effects will no longer occur outside of battle. + * + * Version 1.12a: + * - Lunatic Mode fail safes added. + * - Optimization update. + * + * Version 1.11: + * - Fixed a bug involving Lunatic state effects not occuring in the right + * order when a state is removed. + * + * Version 1.10b: + * - Added new plugin parameter: Show Buff Rate. This will display the current + * buff or debuff rate on the buff icon. + * - Optimization Update. + * - Documentation fix for battler.clampStateCounter(stateId, min, max). + * + * Version 1.09b: + * - Added new plugin parameters: Show Enemy Icons, Enemy Buff Turn, Enemy + * State Turn, and Enemy State Counter to optionally display the enemy state + * icons, states, buffs, their turns, and their counters. + * - Added 'Lunatic Mode - State Counters'. Read more on it in the help file! + * - Added anti-crash method for newly added effect in case non-YEP plugins + * have non-battlers attached to battler sprites. + * - Fixed a bug that prevented screen flashes when walking around on the map + * when an actor is poisoned. + * + * Version 1.08: + * - Fixed an issue that caused adding states midway through Lunatic Mode to + * shift the order of states around causing some effects to be skipped. + * + * Version 1.07: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.06: + * - Added new notetags for , , + * , and for Lunatic Mode. + * + * Version 1.05a: + * - Fixed a bug with the 'Show Turns' parameter not working properly. + * - Fixed a bug with math issues for timed states. + * + * Version 1.04: + * - Changed timing of when Add/Remove/Leave Lunatic Effects occur to add more + * flexibility in custom effects. + * - Added a fail safe for when there are no targets to modify. + * - Fixed a bug with reapply ignore states. + * + * Version 1.03a: + * - Fixed a bug that would cause NaN to show up in state turns. + * + * Version 1.02: + * - Synched up with tick-based battle systems. + * + * Version 1.01: + * - Fixed a bug that didn't reset the font settings with the battle status. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_BuffsStatesCore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.BSCShowTurns = eval(String(Yanfly.Parameters['Show Turns'])); +Yanfly.Param.BSCFontSize = String(Yanfly.Parameters['Font Size']); +Yanfly.Param.BSCTurnAlign = String(Yanfly.Parameters['Turn Alignment']); +Yanfly.Param.BSCTurnBufferX = Number(Yanfly.Parameters['Turn Buffer X']); +Yanfly.Param.BSCTurnBufferY = Number(Yanfly.Parameters['Turn Buffer Y']); +Yanfly.Param.BSCTurnColor = Number(Yanfly.Parameters['State Color']); +Yanfly.Param.BSCBuffColor = Number(Yanfly.Parameters['Buff Color']); +Yanfly.Param.BSCDebuffColor = Number(Yanfly.Parameters['Debuff Color']); + +Yanfly.Param.BSCShowEnemyIcon = String(Yanfly.Parameters['Show Enemy Icons']); +Yanfly.Param.BSCShowEnemyIcon = eval(Yanfly.Param.BSCShowEnemyIcon); +Yanfly.Param.BSCEnemyBTurn = String(Yanfly.Parameters['Enemy Buff Turn']); +Yanfly.Param.BSCEnemyBTurn = eval(Yanfly.Param.BSCEnemyBTurn); +Yanfly.Param.BSCEnemyTurn = String(Yanfly.Parameters['Enemy State Turn']); +Yanfly.Param.BSCEnemyTurn = eval(Yanfly.Param.BSCEnemyTurn); +Yanfly.Param.BSCEnemyCounter = String(Yanfly.Parameters['Enemy State Counter']); +Yanfly.Param.BSCEnemyCounter = eval(Yanfly.Param.BSCEnemyCounter); + +Yanfly.Param.BSCDefaultLimit = Number(Yanfly.Parameters['Default Limit']); +Yanfly.Param.BSCMaximumLimit = Number(Yanfly.Parameters['Maximum Limit']); +Yanfly.Param.BSCBuffFormula = String(Yanfly.Parameters['Buff Formula']); +Yanfly.Param.BSCShowBuffRate = String(Yanfly.Parameters['Show Buff Rate']); +Yanfly.Param.BSCShowBuffRate = eval(Yanfly.Param.BSCShowBuffRate); + +Yanfly.Param.BSCReapplyRules = Number(Yanfly.Parameters['Reapply Rules']); +Yanfly.Param.BSCShowEnemyTurns = String(Yanfly.Parameters['Show Enemy Turns']); +Yanfly.Param.BSCShowEnemyTurns = eval(Yanfly.Param.BSCShowEnemyTurns); + +Yanfly.Param.BSCCounterSize = Number(Yanfly.Parameters['Counter Font Size']); +Yanfly.Param.BSCCounterAlign = String(Yanfly.Parameters['Counter Alignment']); +Yanfly.Param.BSCCounterBufferX = Number(Yanfly.Parameters['Counter Buffer X']); +Yanfly.Param.BSCCounterBufferY = Number(Yanfly.Parameters['Counter Buffer Y']); +Yanfly.Param.BSCCounterColor = Number(Yanfly.Parameters['Counter Color']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.BSC.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.BSC.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_BuffsStatesCore) { + this.processBSCNotetagsT($dataStates); + this.processBSCNotetags1($dataStates); + this.processBSCNotetags2($dataActors); + this.processBSCNotetags2($dataClasses); + this.processBSCNotetags2($dataEnemies); + this.processBSCNotetags2($dataWeapons); + this.processBSCNotetags2($dataArmors); + this.processBSCNotetags2($dataStates); + this.processBSCNotetags3($dataSkills); + this.processBSCNotetags3($dataItems); + this.processBSCNotetags4($dataEnemies); + Yanfly._loaded_YEP_BuffsStatesCore = true; + } + return true; +}; + +DataManager.processBSCNotetagsT = function(group) { + if (Yanfly.StateIdRef) return; + Yanfly.StateIdRef = {}; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + if (obj.name.length <= 0) continue; + Yanfly.StateIdRef[obj.name.toUpperCase()] = n; + } +}; + +DataManager.processBSCNotetags1 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.showTurns = Yanfly.Param.BSCShowTurns; + obj.turnAlign = Yanfly.Param.BSCTurnAlign; + obj.turnFontSize = Yanfly.Param.BSCFontSize; + obj.turnBufferX = Yanfly.Param.BSCTurnBufferX; + obj.turnBufferY = Yanfly.Param.BSCTurnBufferY; + obj.turnColor = Yanfly.Param.BSCTurnColor; + obj.reapplyRules = Yanfly.Param.BSCReapplyRules; + this.initStateEval(obj); + this.initStateCounter(obj); + var evalMode = 'none'; + var evalType = 'none'; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SHOW TURNS)>/i)) { + obj.showTurns = true; + } else if (line.match(/<(?:HIDE TURNS)>/i)) { + obj.showTurns = false; + } else if (line.match(/<(?:TURN ALIGNMENT|turn align):[ ](.*)>/i)) { + obj.turnAlign = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:TURN FONT SIZE):[ ](\d+)>/i)) { + obj.turnFontSize = parseInt(RegExp.$1); + } else if (line.match(/<(?:TURN BUFFER X):[ ]([\+\-]\d+)>/i)) { + obj.turnBufferX = parseInt(RegExp.$1); + } else if (line.match(/<(?:TURN BUFFER Y):[ ]([\+\-]\d+)>/i)) { + obj.turnBufferY = parseInt(RegExp.$1); + } else if (line.match(/<(?:TURN COLOR):[ ](\d+)>/i)) { + obj.turnColor = parseInt(RegExp.$1); + } else if (line.match(/<(?:REAPPLY IGNORE TURNS)>/i)) { + obj.reapplyRules = 0; + } else if (line.match(/<(?:REAPPLY RESET TURNS)>/i)) { + obj.reapplyRules = 1; + } else if (line.match(/<(?:REAPPLY ADD TURNS)>/i)) { + obj.reapplyRules = 2; + } else if (line.match(//i)) { + var name = String(RegExp.$1).toUpperCase(); + evalMode = 'custom state effect'; + if (['APPLY', 'ADD'].contains(name)) { + evalType = 'addState'; + } else if (['REMOVE', 'ERASE'].contains(name)) { + evalType = 'removeState'; + } else if (['LEAVE', 'DECAY'].contains(name)) { + evalType = 'leaveState'; + } else if (['TURN START', 'BEGIN'].contains(name)) { + evalType = 'turnStartState'; + } else if (['TURN END', 'CLOSE'].contains(name)) { + evalType = 'turnEndState'; + } else if (['REGENERATE', 'REGEN', 'WHILE'].contains(name)) { + evalType = 'regenerateState'; + } else if (['SELECT', 'ONTARGET'].contains(name)) { + evalType = 'selectState'; + } else if (['DESELECT', 'OFFTARGET'].contains(name)) { + evalType = 'deselectState'; + } else if (['REACT', 'REACTION'].contains(name)) { + evalType = 'reactState'; + } else if (['RESPOND', 'RESPONSE'].contains(name)) { + evalType = 'respondState'; + } else if (['INITIATE', 'ONAPPLY'].contains(name)) { + evalType = 'initiateState'; + } else if (['CONFIRM', 'PREDAMAGE', 'PRE-DAMAGE'].contains(name)) { + evalType = 'confirmState'; + } else if (['ESTABLISH', 'POSTDAMAGE', 'POST-DAMAGE'].contains(name)) { + evalType = 'establishState'; + } else if (['CONCLUDE', 'OFFAPPLY'].contains(name)) { + evalType = 'concludeState'; + } else if (['ACTION START', 'START'].contains(name)) { + evalType = 'actionStartState'; + } else if (['ACTION END', 'FINISH'].contains(name)) { + evalType = 'actionEndState'; + } else if (['BATTLE', 'BATTLE START'].contains(name)) { + evalType = 'battle'; + } else if (['VICTORY', 'BATTLE VICTORY'].contains(name)) { + evalType = 'victory'; + } else if (['DEFEAT', 'BATTLE DEFEAT'].contains(name)) { + evalType = 'defeat'; + } else if (['ESCAPE', 'BATTLE ESCAPE'].contains(name)) { + evalType = 'escape'; + } + } else if (line.match(/<\/CUSTOM[ ](.*)[ ]EFFECT>/i)) { + evalMode = 'none'; + evalType = 'none'; + } else if (evalMode === 'custom state effect') { + obj.customEffectEval[evalType] = obj.customEffectEval[evalType] + + line + '\n'; + } else if (line.match(//i)) { + obj.stateCounterSettings['size'] = parseInt(RegExp.$1); + } else if (line.match(//i)) { + obj.stateCounterSettings['align'] = String(RegExp.$1).toLowerCase(); + } else if (line.match(//i)) { + obj.stateCounterSettings['bufferX'] = parseInt(RegExp.$1); + } else if (line.match(//i)) { + obj.stateCounterSettings['bufferY'] = parseInt(RegExp.$1); + } else if (line.match(//i)) { + obj.stateCounterSettings['color'] = parseInt(RegExp.$1); + } + } + } +}; + +DataManager.initStateEval = function(obj) { + obj.customEffectEval = {}; + obj.customEffectEval['addState'] = ''; + obj.customEffectEval['removeState'] = ''; + obj.customEffectEval['leaveState'] = ''; + obj.customEffectEval['turnStartState'] = ''; + obj.customEffectEval['turnEndState'] = ''; + obj.customEffectEval['regenerateState'] = ''; + obj.customEffectEval['selectState'] = ''; + obj.customEffectEval['deselectState'] = ''; + obj.customEffectEval['reactState'] = ''; + obj.customEffectEval['respondState'] = ''; + obj.customEffectEval['initiateState'] = ''; + obj.customEffectEval['concludeState'] = ''; + obj.customEffectEval['confirmState'] = ''; + obj.customEffectEval['establishState'] = ''; + obj.customEffectEval['actionStartState'] = ''; + obj.customEffectEval['actionEndState'] = ''; + obj.customEffectEval['battle'] = ''; + obj.customEffectEval['victory'] = ''; + obj.customEffectEval['defeat'] = ''; + obj.customEffectEval['escape'] = ''; +}; + +DataManager.initStateCounter = function(obj) { + obj.stateCounterSettings = {}; + obj.stateCounterSettings['size'] = Yanfly.Param.BSCCounterSize || 16; + obj.stateCounterSettings['align'] = Yanfly.Param.BSCCounterAlign; + if (obj.stateCounterSettings['align'] === 'undefined') { + obj.stateCounterSettings['align'] = 'center'; + } + obj.stateCounterSettings['bufferX'] = Yanfly.Param.BSCCounterBufferX || 0; + obj.stateCounterSettings['bufferY'] = Yanfly.Param.BSCCounterBufferY || 8; + obj.stateCounterSettings['color'] = Yanfly.Param.BSCCounterColor || 0; +}; + +DataManager.processBSCNotetags2 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.maxBuff = [0, 0, 0, 0, 0, 0, 0, 0]; + obj.maxDebuff = [0, 0, 0, 0, 0, 0, 0, 0]; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:MAX)[ ](.*)[ ](?:BUFF):[ ]([\+\-]\d+)>/i)) { + var paramId = 8; + var stat = String(RegExp.$1).toUpperCase(); + var limit = parseInt(RegExp.$2); + if (['MAXHP', 'MAX HP', 'MHP', 'HP'].contains(stat)) { + paramId = 0; + } else if (['MAXMP', 'MAX MP', 'MMP', 'MP'].contains(stat)) { + paramId = 1; + } else if (['ATK', 'STR'].contains(stat)) { + paramId = 2; + } else if (['DEF'].contains(stat)) { + paramId = 3; + } else if (['MAT', 'INT'].contains(stat)) { + paramId = 4; + } else if (['MDF', 'RES'].contains(stat)) { + paramId = 5; + } else if (['AGI', 'SPD'].contains(stat)) { + paramId = 6; + } else if (['LUK'].contains(stat)) { + paramId = 7; + } + obj.maxBuff[paramId] = limit; + } else if (line.match(/<(?:MAX)[ ](.*)[ ](?:DEBUFF):[ ]([\+\-]\d+)>/i)) { + var paramId = 8; + var stat = String(RegExp.$1).toUpperCase(); + var limit = parseInt(RegExp.$2); + if (['MAXHP', 'MAX HP', 'MHP', 'HP'].contains(stat)) { + paramId = 0; + } else if (['MAXMP', 'MAX MP', 'MMP', 'MP'].contains(stat)) { + paramId = 1; + } else if (['ATK', 'STR'].contains(stat)) { + paramId = 2; + } else if (['DEF'].contains(stat)) { + paramId = 3; + } else if (['MAT', 'INT'].contains(stat)) { + paramId = 4; + } else if (['MDF', 'RES'].contains(stat)) { + paramId = 5; + } else if (['AGI', 'SPD'].contains(stat)) { + paramId = 6; + } else if (['LUK'].contains(stat)) { + paramId = 7; + } + obj.maxDebuff[paramId] = limit; + } + } + } +}; + +DataManager.processBSCNotetags3 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.modifyTurnBuff = [0, 0, 0, 0, 0, 0, 0, 0]; + obj.modifyTurnDebuff = [0, 0, 0, 0, 0, 0, 0, 0]; + obj.modifyTurnBuffEval = ['', '', '', '', '', '', '', '']; + obj.modifyTurnDebuffEval = ['', '', '', '', '', '', '', '']; + obj.modifyTurnState = {}; + obj.modifyTurnStateEval = {}; + var evalMode = 'none'; + var evalLine = ''; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(.*)[ ](?:BUFF TURNS):[ ]([\+\-]\d+)>/i)) { + var paramId = 8; + var stat = String(RegExp.$1).toUpperCase(); + var value = parseInt(RegExp.$2); + if (['MAXHP', 'MAX HP', 'MHP', 'HP'].contains(stat)) { + paramId = 0; + } else if (['MAXMP', 'MAX MP', 'MMP', 'MP'].contains(stat)) { + paramId = 1; + } else if (['ATK', 'STR'].contains(stat)) { + paramId = 2; + } else if (['DEF'].contains(stat)) { + paramId = 3; + } else if (['MAT', 'INT'].contains(stat)) { + paramId = 4; + } else if (['MDF', 'RES'].contains(stat)) { + paramId = 5; + } else if (['AGI', 'SPD'].contains(stat)) { + paramId = 6; + } else if (['LUK'].contains(stat)) { + paramId = 7; + } + obj.modifyTurnBuff[paramId] = value; + } else if (line.match(/<(.*)[ ](?:DEBUFF TURNS):[ ]([\+\-]\d+)>/i)) { + var paramId = 8; + var stat = String(RegExp.$1).toUpperCase(); + var value = parseInt(RegExp.$2); + if (['MAXHP', 'MAX HP', 'MHP', 'HP'].contains(stat)) { + paramId = 0; + } else if (['MAXMP', 'MAX MP', 'MMP', 'MP'].contains(stat)) { + paramId = 1; + } else if (['ATK', 'STR'].contains(stat)) { + paramId = 2; + } else if (['DEF'].contains(stat)) { + paramId = 3; + } else if (['MAT', 'INT'].contains(stat)) { + paramId = 4; + } else if (['MDF', 'RES'].contains(stat)) { + paramId = 5; + } else if (['AGI', 'SPD'].contains(stat)) { + paramId = 6; + } else if (['LUK'].contains(stat)) { + paramId = 7; + } + obj.modifyTurnDebuff[paramId] = value; + } else if (line.match(/<(?:CUSTOM)[ ](.*)[ ](?:BUFF TURNS)>/i)) { + evalMode = 'custom buff'; + evalLine = ''; + } else if (line.match(/<\/(?:CUSTOM)[ ](.*)[ ](?:BUFF TURNS)>/i)) { + var paramId = 8; + var stat = String(RegExp.$1).toUpperCase(); + if (['MAXHP', 'MAX HP', 'MHP', 'HP'].contains(stat)) { + paramId = 0; + } else if (['MAXMP', 'MAX MP', 'MMP', 'MP'].contains(stat)) { + paramId = 1; + } else if (['ATK', 'STR'].contains(stat)) { + paramId = 2; + } else if (['DEF'].contains(stat)) { + paramId = 3; + } else if (['MAT', 'INT'].contains(stat)) { + paramId = 4; + } else if (['MDF', 'RES'].contains(stat)) { + paramId = 5; + } else if (['AGI', 'SPD'].contains(stat)) { + paramId = 6; + } else if (['LUK'].contains(stat)) { + paramId = 7; + } + obj.modifyTurnBuffEval[paramId] = evalLine; + evalMode = 'none'; + evalLine = ''; + } else if (evalMode === 'custom buff') { + evalLine = evalLine + line + '\n'; + } else if (line.match(//i)) { + obj.modifyTurnState[parseInt(RegExp.$1)] = parseInt(RegExp.$2); + } else if (line.match(//i)) { + var name = String(RegExp.$1).toUpperCase(); + var value = parseInt(RegExp.$2); + var id = Yanfly.StateIdRef[name]; + obj.modifyTurnState[id] = value; + } else if (line.match(/<(?:CUSTOM STATE)[ ](.*)[ ](?:TURNS)>/i)) { + evalMode = 'custom state'; + evalLine = ''; + } else if (line.match(/<\/(?:CUSTOM STATE)[ ](.*)[ ](?:TURNS)>/i)) { + var text = String(RegExp.$1); + if (text.match(/(\d+)/i)) { + var id = parseInt(RegExp.$1); + } else { + var id = Yanfly.StateIdRef[text.toUpperCase()]; + } + obj.modifyTurnStateEval[id] = evalLine; + evalMode = 'none'; + evalLine = ''; + } else if (evalMode === 'custom state') { + evalLine = evalLine + line + '\n'; + } + } + } +}; + +DataManager.processBSCNotetags4 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.showStateTurns = Yanfly.Param.BSCShowEnemyTurns; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SHOW STATE TURNS)>/i)) { + obj.showStateTurns = true; + } else if (line.match(/<(?:HIDE STATE TURNS)>/i)) { + obj.showStateTurns = false; + } + } + } +}; + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.BSC.BattleManager_startAction = BattleManager.startAction; +BattleManager.startAction = function() { + if (this._subject) this._subject.onActionStartStateEffects(); + Yanfly.BSC.BattleManager_startAction.call(this); +}; + +Yanfly.BSC.BattleManager_endAction = BattleManager.endAction; +BattleManager.endAction = function() { + if (this._subject) this._subject.onActionEndStateEffects(); + Yanfly.BSC.BattleManager_endAction.call(this); +}; + +Yanfly.BSC.BattleManager_endBattle = BattleManager.endBattle; +BattleManager.endBattle = function(result) { + if (result === 0) { + $gameParty.processStateEval('victory'); + } else if (result === 1) { + $gameParty.processStateEval('escape'); + } else if (result === 2) { + $gameParty.processStateEval('defeat'); + } + Yanfly.BSC.BattleManager_endBattle.call(this, result); +}; + +//============================================================================= +// Game_BattlerBase +//============================================================================= + +Yanfly.BSC.Game_BattlerBase_initMembers = + Game_BattlerBase.prototype.initMembers; +Game_BattlerBase.prototype.initMembers = function() { + Yanfly.BSC.Game_BattlerBase_initMembers.call(this); + this.initStateCounter(); +}; + +Yanfly.BSC.Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh; +Game_BattlerBase.prototype.refresh = function() { + this._cacheParamBuffRate = {}; + Yanfly.BSC.Game_BattlerBase_refresh.call(this); +}; + +Game_BattlerBase.prototype.stateOrigin = function(stateId) { + if (this._stateOrigin === undefined) this._stateOrigin = {}; + if (!this._stateOrigin[stateId]) return this; + var arr = this._stateOrigin[stateId]; + if (arr[0] === 0) return $gameActors.actor(arr[1]); + if (arr[0] === 1) return $gameTroop.members()[arr[1]]; + return this; +}; + +Game_BattlerBase.prototype.setStateOrigin = function(stateId, battler) { + if (this._stateOrigin === undefined) this._stateOrigin = {}; + if (!$gameParty.inBattle()) return; + if (!battler) { + var battler = BattleManager._subject; + if (!battler) return; + } + if (battler.isActor()) { + var arr = [0, battler._actorId]; + } else { + var arr = [1, battler.index()]; + } + this._stateOrigin[stateId] = arr; +}; + +Game_BattlerBase.prototype.clearStateOrigin = function(stateId) { + if (this._stateOrigin === undefined) this._stateOrigin = {}; + this._stateOrigin[stateId] = undefined; +}; + +Game_BattlerBase.prototype.clearEnemyStateOrigins = function() { + var length = $dataStates.length; + for (var i = 0; i < length; ++i) { + if (this._stateOrigin === undefined) this._stateOrigin = {}; + if (this._stateOrigin[i] === undefined) continue; + var data = this._stateOrigin[i]; + if (data[0] === 1) this.clearStateOrigin(i); + } +}; + +Game_BattlerBase.prototype.stateTurns = function(stateId) { + return this._stateTurns[stateId]; +}; + +Game_BattlerBase.prototype.setStateTurns = function(stateId, turns) { + if (Imported.YEP_BattleEngineCore && !Yanfly.Param.BECTimeStates) { + turns = Math.floor(turns); + } + this._stateTurns[stateId] = turns; +}; + +Game_BattlerBase.prototype.buffTurns = function(paramId) { + return this._buffTurns[paramId]; +}; + +Game_BattlerBase.prototype.setBuffTurns = function(paramId, turns) { + if (Imported.YEP_BattleEngineCore && !Yanfly.Param.BECTimeBuffs) { + turns = Math.floor(turns); + } + this._buffTurns[paramId] = turns; +}; + +Game_BattlerBase.prototype.paramBuffRate = function(paramId) { + if (this._cacheParamBuffRate === undefined) this._cacheParamBuffRate = {}; + if (this._cacheParamBuffRate[paramId] !== undefined) { + return this._cacheParamBuffRate[paramId]; + } + var code = Yanfly.Param.BSCBuffFormula; + try { + var rate = eval(code); + } catch (e) { + var rate = 1; + Yanfly.Util.displayError(e, code, 'PARAM BUFF RATE FORMULA ERROR'); + } + this._cacheParamBuffRate[paramId] = rate; + return this._cacheParamBuffRate[paramId]; +}; + +Game_BattlerBase.prototype.isMaxBuffAffected = function(paramId) { + var limit = Math.max(1, this.maxBuffLimit(paramId)); + var max = Yanfly.Param.BSCMaximumLimit; + return this._buffs[paramId] === Math.min(limit, max); +}; + +Game_BattlerBase.prototype.maxBuffLimit = function(paramId) { + var value = Yanfly.Param.BSCDefaultLimit; + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + if (state.maxBuff) value += state.maxBuff[paramId]; + } + return value; +}; + +Game_BattlerBase.prototype.isMaxDebuffAffected = function(paramId) { + var limit = Math.min(-1, this.maxDebuffLimit(paramId)); + var max = Yanfly.Param.BSCMaximumLimit * -1; + return this._buffs[paramId] === Math.max(limit, max); +}; + +Game_BattlerBase.prototype.maxDebuffLimit = function(paramId) { + var value = -1 * Yanfly.Param.BSCDefaultLimit; + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + if (state.maxDebuff) value -= state.maxDebuff[paramId]; + } + return value; +}; + +Game_BattlerBase.prototype.buffIconIndex = function(buffLevel, paramId) { + if (buffLevel > 0) { + var level = Math.min(buffLevel - 1, 1); + return Game_BattlerBase.ICON_BUFF_START + (level) * 8 + paramId; + } else if (buffLevel < 0) { + var level = Math.min(-buffLevel - 1, 1); + return Game_BattlerBase.ICON_DEBUFF_START + (level) * 8 + paramId; + } else { + return 0; + } +}; + +Yanfly.BSC.Game_BattlerBase_resetStateCounts = + Game_BattlerBase.prototype.resetStateCounts; +Game_BattlerBase.prototype.resetStateCounts = function(stateId) { + var state = $dataStates[stateId]; + if (state.reapplyRules === 1) { + Yanfly.BSC.Game_BattlerBase_resetStateCounts.call(this, stateId); + } else if (state.reapplyRules === 2) { + this._stateTurns[stateId] = this._stateTurns[stateId] || 0; + var variance = 1 + Math.max(state.maxTurns - state.minTurns, 0); + this._stateTurns[stateId] += state.minTurns + Math.randomInt(variance); + } else if (state.reapplyRules === 0 && state.minTurns) { + if (this._stateTurns[stateId] === undefined) { + Yanfly.BSC.Game_BattlerBase_resetStateCounts.call(this, stateId); + } + } +}; + + +Game_BattlerBase.prototype.initStateCounter = function() { + this._stateCounter = {}; +}; + +Game_BattlerBase.prototype.clearStateCounters = function() { + this._stateCounter = {}; +}; + +Game_BattlerBase.prototype.setStateCounter = function(stateId, value) { + if (this._stateCounter === undefined) this.initStateCounter(); + this._stateCounter[stateId] = value; + this.refresh(); +}; + +Game_BattlerBase.prototype.addStateCounter = function(stateId, value) { + if (this._stateCounter === undefined) this.initStateCounter(); + this.setStateCounter(stateId, value + (this.getStateCounter(stateId) || 0)); +}; + +Game_BattlerBase.prototype.clampStateCounter = function(stateId, min, max) { + var value = this.getStateCounter(stateId).clamp(min, max); + this.setStateCounter(stateId, value); +}; + +Game_BattlerBase.prototype.removeStateCounter = function(stateId) { + if (this._stateCounter === undefined) this.initStateCounter(); + this._stateCounter[stateId] = undefined; +}; + +Game_BattlerBase.prototype.getStateCounter = function(stateId) { + if (this._stateCounter === undefined) this.initStateCounter(); + return this._stateCounter[stateId]; +}; + +Game_BattlerBase.prototype.statesAndBuffs = function() { + var group = this.states(); + var length = group.length; + var array = []; + for (var i = 0; i < length; ++i) { + var state = group[i]; + if (state && state.iconIndex > 0) array.push(state); + } + for (var i = 0; i < 8; ++i) { + if (this._buffs[i]) array.push(i); + } + return array; +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.hasState = function(stateId) { + return this.states().contains($dataStates[stateId]); +}; + +Game_Battler.prototype.customEffectEval = function(stateId, type) { + var state = $dataStates[stateId]; + if (!state) return; + if (state.customEffectEval[type] === '') return; + var a = this; + var user = this; + var target = this; + var origin = this.stateOrigin(stateId); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = state.customEffectEval[type]; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, + 'CUSTOM STATE ' + stateId + ' CODE ERROR'); + } +}; + +Yanfly.BSC.Game_Battler_addState = Game_Battler.prototype.addState; +Game_Battler.prototype.addState = function(stateId) { + var addable = this.isStateAddable(stateId); + Yanfly.BSC.Game_Battler_addState.call(this, stateId); + if (addable) { + this.setStateOrigin(stateId); + this.addStateEffects(stateId); + } +}; + +Game_Battler.prototype.addStateEffects = function(stateId) { + this.customEffectEval(stateId, 'addState'); +}; + +Yanfly.BSC.Game_Battler_removeState = Game_Battler.prototype.removeState; +Game_Battler.prototype.removeState = function(stateId) { + var affected = this.isStateAffected(stateId); + Yanfly.BSC.Game_Battler_removeState.call(this, stateId); + this.removeStateCounter(stateId); + if (affected) { + this.removeStateEffects(stateId); + this.clearStateOrigin(stateId); + } +}; + +Game_Battler.prototype.removeStateEffects = function(stateId) { + this.customEffectEval(stateId, 'removeState'); + if ($gameTemp._customLeaveEffectEval) this.leaveStateEffects(stateId); +}; + +Yanfly.BSC.Game_Battler_removeStatesAuto = + Game_Battler.prototype.removeStatesAuto; +Game_Battler.prototype.removeStatesAuto = function(timing) { + $gameTemp._customLeaveEffectEval = true; + Yanfly.BSC.Game_Battler_removeStatesAuto.call(this, timing); + $gameTemp._customLeaveEffectEval = undefined; +}; + +Game_Battler.prototype.leaveStateEffects = function(stateId) { + this.customEffectEval(stateId, 'leaveState'); +}; + +Game_Battler.prototype.onTurnStartStateEffects = function() { + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (state) this.turnStartStateEffects(state.id); + } +}; + +Game_Battler.prototype.turnStartStateEffects = function(stateId) { + this.customEffectEval(stateId, 'turnStartState'); +}; + +Game_Battler.prototype.onTurnEndStateEffects = function() { + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (state) this.turnEndStateEffects(state.id); + } +}; + +Game_Battler.prototype.turnEndStateEffects = function(stateId) { + this.customEffectEval(stateId, 'turnEndState'); +}; + +Yanfly.BSC.Game_Battler_onTurnEnd = Game_Battler.prototype.onTurnEnd; +Game_Battler.prototype.onTurnEnd = function() { + Yanfly.BSC.Game_Battler_onTurnEnd.call(this); + if (this.meetTurnEndStateEffectsConditions()) this.onTurnEndStateEffects(); +}; + +Game_Battler.prototype.meetTurnEndStateEffectsConditions = function() { + if (!$gameParty.inBattle()) return false; + if (Imported.YEP_BattleEngineCore) { + if (BattleManager.isTurnBased()) { + return true; + } else if (BattleManager.isTickBased() && !BattleManager.isTurnEnd()) { + return true; + } else { + return false; + } + } + return true; +}; + +Game_Battler.prototype.onRegenerateStateEffects = function() { + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (state) this.regenerateStateEffects(state.id); + } +}; + +Game_Battler.prototype.regenerateStateEffects = function(stateId) { + if ($gameParty.inBattle()) this.clearResult(); + var lifeState = this.isAlive(); + this.customEffectEval(stateId, 'regenerateState'); + if ($gameParty.inBattle() && this.isDead() && lifeState === true) { + this.performCollapse(); + } + if (!Imported.YEP_BattleEngineCore) return; + if ($gameParty.inBattle()) this.startDamagePopup(); +}; + +Yanfly.BSC.Game_Battler_regenerateAll = Game_Battler.prototype.regenerateAll; +Game_Battler.prototype.regenerateAll = function() { + if ($gameParty.inBattle()) this.onRegenerateStateEffects(); + Yanfly.BSC.Game_Battler_regenerateAll.call(this); +}; + +if (Imported.YEP_BattleEngineCore) { + +Yanfly.BSC.Game_BattlerBase_updateStateTicks = + Game_BattlerBase.prototype.updateStateTicks; +Game_BattlerBase.prototype.updateStateTicks = function() { + $gameTemp._customLeaveEffectEval = true; + Yanfly.BSC.Game_BattlerBase_updateStateTicks.call(this); + $gameTemp._customLeaveEffectEval = undefined; +}; + +Yanfly.BSC.Game_BattlerBase_updateStateTurnTiming = + Game_BattlerBase.prototype.updateStateTurnTiming; +Game_BattlerBase.prototype.updateStateTurnTiming = function(timing) { + $gameTemp._customLeaveEffectEval = true; + Yanfly.BSC.Game_BattlerBase_updateStateTurnTiming.call(this, timing); + $gameTemp._customLeaveEffectEval = undefined; +}; + +Yanfly.BSC.Game_Battler_onTurnStart = + Game_Battler.prototype.onTurnStart; +Game_Battler.prototype.onTurnStart = function() { + Yanfly.BSC.Game_Battler_onTurnStart.call(this); + if (this.meetTurnStartStateEffectsConditions()) { + this.onTurnStartStateEffects(); + } +}; + +Game_Battler.prototype.meetTurnStartStateEffectsConditions = function() { + return true; +}; + +}; // Imported.YEP_BattleEngineCore + +Game_Battler.prototype.onActionStartStateEffects = function() { + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (state) this.actionStartStateEffects(state.id); + } +}; + +Game_Battler.prototype.actionStartStateEffects = function(stateId) { + this.customEffectEval(stateId, 'actionStartState'); +}; + +Game_Battler.prototype.onActionEndStateEffects = function() { + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (state) this.actionEndStateEffects(state.id); + } +}; + +Game_Battler.prototype.actionEndStateEffects = function(stateId) { + this.customEffectEval(stateId, 'actionEndState'); +}; + +Yanfly.BSC.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd; +Game_Battler.prototype.onBattleEnd = function() { + Yanfly.BSC.Game_Battler_onBattleEnd.call(this); + this.clearEnemyStateOrigins(); +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.maxBuffLimit = function(paramId) { + var value = Game_Battler.prototype.maxBuffLimit.call(this, paramId); + value += this.actor().maxBuff[paramId]; + value += this.currentClass().maxBuff[paramId]; + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.maxBuff) value += equip.maxBuff[paramId]; + } + return value; +}; + +Game_Actor.prototype.maxDebuffLimit = function(paramId) { + var value = Game_Battler.prototype.maxDebuffLimit.call(this, paramId); + value -= this.actor().maxDebuff[paramId]; + value -= this.currentClass().maxDebuff[paramId]; + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.maxDebuff) value -= equip.maxDebuff[paramId]; + } + return value; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.maxBuffLimit = function(paramId) { + var value = Game_Battler.prototype.maxBuffLimit.call(this, paramId); + value += this.enemy().maxBuff[paramId]; + return value; +}; + +Game_Enemy.prototype.maxDebuffLimit = function(paramId) { + var value = Game_Battler.prototype.maxDebuffLimit.call(this, paramId); + value -= this.enemy().maxDebuff[paramId]; + return value; +}; + +//============================================================================= +// Game_Unit +//============================================================================= + +Game_Unit.prototype.processStateEval = function(type) { + var length1 = this.allMembers().length; + for (var i = 0; i < length1; ++i) { + var member = this.allMembers()[i]; + if (!member) return; + member.refresh(); + var states = member.states(); + var length2 = states.length; + for (var j = 0; j < length2; ++j) { + var state = states[j]; + if (state) member.customEffectEval(state.id, type); + } + } +}; + +Yanfly.BSC.Game_Unit_onBattleStart = Game_Unit.prototype.onBattleStart; +Game_Unit.prototype.onBattleStart = function() { + Yanfly.BSC.Game_Unit_onBattleStart.call(this); + this.processStateEval('battle'); +}; + +//============================================================================= +// Game_Troop +//============================================================================= + +Game_Troop.prototype.allMembers = function() { + return this.members(); +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.BSC.Game_Action_applyItemUserEffect = + Game_Action.prototype.applyItemUserEffect; +Game_Action.prototype.applyItemUserEffect = function(target) { + Yanfly.BSC.Game_Action_applyItemUserEffect.call(this, target); + if (!target) return; + this.applyModifyBuffTurns(target); + this.applyModifyDebuffTurns(target); + this.applyModifyStateTurns(target); +}; + +Game_Action.prototype.applyModifyBuffTurns = function(target) { + if (!this.item()) return; + var affected = false; + for (var i = 0; i < 8; ++i) { + if (!target.isBuffAffected(i)) continue; + var turn = this.item().modifyTurnBuff[i] + target.buffTurns(i); + turn = this.applyBuffTurnsEval(turn, i, target); + target.setBuffTurns(i, turn); + if (target.buffTurns(i) <= 0) target.eraseBuff(i); + affected = true; + } + if (affected) target.refresh(); +}; + +Game_Action.prototype.applyBuffTurnsEval = function(turn, paramId, target) { + if (this.item().modifyTurnBuffEval[paramId] === '') return turn; + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = this.item().modifyTurnBuffEval[paramId]; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CUSTOM BUFF TURN SET ERROR'); + } + return turn; +}; + +Game_Action.prototype.applyModifyDebuffTurns = function(target) { + if (!this.item()) return; + var affected = false; + for (var i = 0; i < 8; ++i) { + if (!target.isDebuffAffected(i)) continue; + var turn = this.item().modifyTurnDebuff[i] + target.buffTurns(i); + turn = this.applyDebuffTurnsEval(turn, i, target); + target.setBuffTurns(i, turn); + if (target.buffTurns(i) <= 0) target.eraseBuff(i); + affected = true; + } + if (affected) target.refresh(); +}; + +Game_Action.prototype.applyDebuffTurnsEval = function(turn, paramId, target) { + if (this.item().modifyTurnBuffEval[paramId] === '') return turn; + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = this.item().modifyTurnBuffEval[paramId]; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CUSTOM DEBUFF TURN SET ERROR'); + } + return turn; +}; + +Game_Action.prototype.applyModifyStateTurns = function(target) { + if (!this.item()) return; + var affected = false; + var states = target.states() + var length = states.length; + var removed = []; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (state.autoRemovalTiming <= 0) continue; + if (!target.isStateAffected(state.id)) continue; + var turn = target.stateTurns(state.id); + if (this.item().modifyTurnState[state.id]) { + turn += this.item().modifyTurnState[state.id]; + } + turn = this.applyStateTurnsEval(turn, state.id, target); + target.setStateTurns(state.id, turn); + if (target.stateTurns(state.id) <= 0) removed.push(state.id); + } + for (var i = 0; i < removed.length; ++i) { + target.removeState(removed[i]); + affected = true; + } + if (affected) target.refresh(); +}; + +Game_Action.prototype.applyStateTurnsEval = function(turn, stateId, target) { + if (this.item().modifyTurnStateEval[stateId] === undefined) return turn; + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var origin = target.stateOrigin(stateId); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = this.item().modifyTurnStateEval[stateId]; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CUSTOM STATE TURN SET ERROR'); + } + return turn; +}; + +Yanfly.BSC.Game_Action_apply = Game_Action.prototype.apply; +Game_Action.prototype.apply = function(target) { + this.onApplyStateEffects(target); + this.onSelectStateEffects(target); + Yanfly.BSC.Game_Action_apply.call(this, target); + this.onDeselectStateEffects(target); + this.offApplyStateEffects(target); +}; + +Game_Action.prototype.customEffectEval = +function(target, stateId, type, side, value) { + var state = $dataStates[stateId]; + if (!state) return value; + if (state.customEffectEval[type] === '') return value; + var attacker = this.subject(); + var defender = target; + var a = this.subject(); + var b = target; + var user = this.subject(); + var origin = side.stateOrigin(stateId); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = state.customEffectEval[type]; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, + 'CUSTOM STATE ' + stateId + ' CODE ERROR'); + } + return value; +}; + +Game_Action.prototype.onApplyStateEffects = function(target) { + var states = this.subject().states(); + var length = this.subject().states().length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + this.initiateStateEffects(target, state.id) + } +}; + +Game_Action.prototype.initiateStateEffects = function(target, stateId) { + this.customEffectEval(target, stateId, 'initiateState', this.subject()); +}; + +Game_Action.prototype.onSelectStateEffects = function(target) { + var states = target.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + this.selectStateEffects(target, state.id) + } +}; + +Game_Action.prototype.selectStateEffects = function(target, stateId) { + this.customEffectEval(target, stateId, 'selectState', target); +}; + +Game_Action.prototype.onDeselectStateEffects = function(target) { + var states = target.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + this.deselectStateEffects(target, state.id) + } +}; + +Game_Action.prototype.deselectStateEffects = function(target, stateId) { + this.customEffectEval(target, stateId, 'deselectState', target); +}; + +Game_Action.prototype.offApplyStateEffects = function(target) { + var states = this.subject().states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + this.concludeStateEffects(target, state.id) + } +}; + +Game_Action.prototype.concludeStateEffects = function(target, stateId) { + this.customEffectEval(target, stateId, 'concludeState', this.subject()); +}; + +Yanfly.BSC.Game_Action_executeDamage = Game_Action.prototype.executeDamage; +Game_Action.prototype.executeDamage = function(target, value) { + value = this.onPreDamageStateEffects(target, value); + value = this.onReactStateEffects(target, value); + Yanfly.BSC.Game_Action_executeDamage.call(this, target, value); + value = this.onRespondStateEffects(target, value); + value = this.onPostDamageStateEffects(target, value); +}; + +Game_Action.prototype.onPreDamageStateEffects = function(target, value) { + var states = this.subject().states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + value = this.confirmStateEffects(target, state.id, value); + } + return value; +}; + +Game_Action.prototype.confirmStateEffects = function(target, stateId, value) { + return this.customEffectEval(target, stateId, 'confirmState', + this.subject(), value); +}; + +Game_Action.prototype.onReactStateEffects = function(target, value) { + var states = target.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + value = this.reactStateEffects(target, state.id, value); + } + return value; +}; + +Game_Action.prototype.reactStateEffects = function(target, stateId, value) { + return this.customEffectEval(target, stateId, 'reactState', target, value); +}; + +Game_Action.prototype.onRespondStateEffects = function(target, value) { + var states = target.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + value = this.respondStateEffects(target, state.id, value); + } + return value; +}; + +Game_Action.prototype.respondStateEffects = function(target, stateId, value) { + return this.customEffectEval(target, stateId, 'respondState', + target, value); +}; + +Game_Action.prototype.onPostDamageStateEffects = function(target, value) { + var states = this.subject().states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + value = this.establishStateEffects(target, state.id, value); + } + return value; +}; + +Game_Action.prototype.establishStateEffects = function(target, stateId, value) { + return this.customEffectEval(target, stateId, 'establishState', + this.subject(), value); +}; + +//============================================================================= +// Sprite_StateIcon +//============================================================================= + +if (!Yanfly.Param.BSCShowEnemyIcon) { + +Sprite_StateIcon.prototype.updateFrame = function() { +}; + +} else { + +Yanfly.BSC.Sprite_StateIcon_initMembers = + Sprite_StateIcon.prototype.initMembers; +Sprite_StateIcon.prototype.initMembers = function() { + Yanfly.BSC.Sprite_StateIcon_initMembers.call(this); + this._turnCounterSprite = new Sprite(); + this.addChild(this._turnCounterSprite); + this._turnCounterSprite.anchor.x = 0.5; + this._turnCounterSprite.anchor.y = 0.5; + var w = Window_Base._iconWidth; + var h = Window_Base._iconHeight; + this._turnCounterSprite.bitmap = new Bitmap(w, h); +}; + +Yanfly.BSC.Sprite_StateIcon_updateFrame = + Sprite_StateIcon.prototype.updateFrame; +Sprite_StateIcon.prototype.updateFrame = function() { + Yanfly.BSC.Sprite_StateIcon_updateFrame.call(this); + if (this._turnCounterSprite) this.updateTurnAndCounter(); +}; + +Sprite_StateIcon.prototype.updateTurnAndCounter = function() { + this._turnCounterSprite.bitmap.clear(); + if (!this._battler) return; + var group = this._battler.statesAndBuffs(); + if (group.length <= 0) return; + var state = group[this._animationIndex]; + if (typeof state === 'number') { + if (Yanfly.Param.BSCEnemyBTurn) { + this.drawBuffTurns(state); + if (Yanfly.Param.BSCShowBuffRate) { + this.drawBuffRate(state) + } + } + } else { + if (Yanfly.Param.BSCEnemyTurn) this.drawStateTurns(state); + if (Yanfly.Param.BSCEnemyCounter) this.drawStateCounter(state); + } +}; + +Sprite_StateIcon.prototype.textColor = function(n) { + return SceneManager._scene._statusWindow.textColor(n); +}; + +Sprite_StateIcon.prototype.drawStateTurns = function(state) { + if (!state) return; + if (!state.showTurns) return; + if (state.autoRemovalTiming <= 0) return; + var turns = this._battler.stateTurns(state.id); + if (turns !== 0 && !turns) return; + var turns = Yanfly.Util.toGroup(Math.ceil(turns)); + var wx = state.turnBufferX; + var wy = state.turnBufferY - 2; + var ww = Window_Base._iconWidth; + var wh = Window_Base.prototype.lineHeight.call(this); + var contents = this._turnCounterSprite.bitmap; + contents.fontSize = state.turnFontSize; + contents.textColor = this.textColor(state.turnColor); + contents.drawText(turns, wx, wy, ww, wh, state.turnAlign); +}; + +Sprite_StateIcon.prototype.drawStateCounter = function(state) { + var value = this._battler.getStateCounter(state.id); + if (value === undefined) return; + var settings = state.stateCounterSettings; + value = Yanfly.Util.toGroup(value); + var wx = settings.bufferX; + var wy = settings.bufferY - 2; + var ww = Window_Base._iconWidth; + var wh = Window_Base.prototype.lineHeight.call(this); + var contents = this._turnCounterSprite.bitmap; + contents.fontSize = settings.size; + contents.textColor = this.textColor(settings.color); + contents.drawText(value, wx, wy, ww, wh, settings.align); +}; + +Sprite_StateIcon.prototype.drawBuffTurns = function(paramId) { + if (!Yanfly.Param.BSCShowTurns) return; + var turns = this._battler.buffTurns(paramId); + turns = Yanfly.Util.toGroup(Math.ceil(turns)); + var wx = Yanfly.Param.BSCTurnBufferX; + var wy = Yanfly.Param.BSCTurnBufferY - 2; + var ww = Window_Base._iconWidth; + var wh = Window_Base.prototype.lineHeight.call(this); + var contents = this._turnCounterSprite.bitmap; + contents.fontSize = Yanfly.Param.BSCFontSize; + if (this._battler.isBuffAffected(paramId)) { + contents.textColor = this.textColor(Yanfly.Param.BSCBuffColor); + } else { + contents.textColor = this.textColor(Yanfly.Param.BSCDebuffColor); + } + contents.drawText(turns, wx, wy, ww, wh, Yanfly.Param.BSCTurnAlign); +}; + +Sprite_StateIcon.prototype.drawBuffRate = function(paramId) { + if (!Yanfly.Param.BSCShowTurns) return; + var value = this._battler.paramBuffRate(paramId); + var text = Math.floor(value * 100) + '%'; + var wx = Yanfly.Param.BSCCounterBufferX || 0; + var wy = (Yanfly.Param.BSCCounterBufferY || 8) - 2; + var ww = Window_Base._iconWidth; + var wh = Window_Base.prototype.lineHeight.call(this); + var contents = this._turnCounterSprite.bitmap; + contents.fontSize = Yanfly.Param.BSCFontSize * 0.75; + contents.textColor = this.textColor(0); + contents.drawText(text, wx, wy, ww, wh, 'center'); +}; + +}; // Yanfly.Param.BSCShowEnemyIcon + +//============================================================================= +// Window_Base +//============================================================================= + +Yanfly.BSC.Window_Base_drawActorIcons = Window_Base.prototype.drawActorIcons; +Window_Base.prototype.drawActorIcons = function(actor, wx, wy, ww) { + ww = ww || 144; + Yanfly.BSC.Window_Base_drawActorIcons.call(this, actor, wx, wy, ww); + this.drawActorIconsTurns(actor, wx, wy, ww); +}; + +Window_Base.prototype.drawActorIconsTurns = function(actor, wx, wy, ww) { + var iw = Window_Base._iconWidth; + var icons = actor.allIcons().slice(0, Math.floor(ww / iw)); + var max = icons.length; + var shownMax = Math.floor(ww / iw); + for (var i = 0; i < actor.states().length; ++i) { + if (shownMax <= 0) break; + var state = actor.states()[i]; + if (state.iconIndex <= 0) continue; + if (state.autoRemovalTiming > 0) { + this.drawStateTurns(actor, state, wx, wy); + } + this.drawStateCounter(actor, state, wx, wy); + wx += iw; + --shownMax; + } + for (var i = 0; i < 8; ++i) { + if (shownMax <= 0) break; + if (actor._buffs[i] === 0) continue; + this.drawBuffTurns(actor, i, wx, wy); + if (Yanfly.Param.BSCShowBuffRate) { + this.drawBuffRate(actor, i, wx, wy); + } + wx += iw; + --shownMax; + } + this.resetFontSettings(); + this.resetTextColor(); +}; + +Window_Base.prototype.drawStateTurns = function(actor, state, wx, wy) { + if (!state.showTurns) return; + var turns = actor.stateTurns(state.id); + if (turns !== 0 && !turns) return; + var turns = Yanfly.Util.toGroup(Math.ceil(turns)); + wx += state.turnBufferX; + wy += state.turnBufferY; + this.changePaintOpacity(true); + this.changeTextColor(this.textColor(state.turnColor)); + this.contents.fontSize = state.turnFontSize; + this.drawText(turns, wx, wy, Window_Base._iconWidth, state.turnAlign); + this.resetFontSettings(); + this.resetTextColor(); +}; + +Window_Base.prototype.drawStateCounter = function(actor, state, wx, wy) { + var value = actor.getStateCounter(state.id); + if (value === undefined) return; + var settings = state.stateCounterSettings; + value = Yanfly.Util.toGroup(value); + wx += settings.bufferX; + wy += settings.bufferY; + this.changePaintOpacity(true); + this.changeTextColor(this.textColor(settings.color)); + this.contents.fontSize = settings.size; + this.drawText(value, wx, wy, Window_Base._iconWidth, settings.align); + this.resetFontSettings(); + this.resetTextColor(); +}; + +Window_Base.prototype.drawBuffTurns = function(actor, paramId, wx, wy) { + if (!Yanfly.Param.BSCShowTurns) return; + var turns = Yanfly.Util.toGroup(Math.ceil(actor.buffTurns(paramId))); + wx += Yanfly.Param.BSCTurnBufferX; + wy += Yanfly.Param.BSCTurnBufferY; + this.changePaintOpacity(true); + this.contents.fontSize = Yanfly.Param.BSCFontSize; + if (actor.isBuffAffected(paramId)) { + this.changeTextColor(this.textColor(Yanfly.Param.BSCBuffColor)); + } else { + this.changeTextColor(this.textColor(Yanfly.Param.BSCDebuffColor)); + } + var align = Yanfly.Param.BSCTurnAlign; + this.drawText(turns, wx, wy, Window_Base._iconWidth, align); + this.resetFontSettings(); + this.resetTextColor(); +}; + +Window_Base.prototype.drawBuffRate = function(actor, paramId, wx, wy) { + var value = actor.paramBuffRate(paramId); + if (value === undefined) return; + value = Math.floor(value * 100) + '%'; + this.contents.fontSize = (Yanfly.Param.BSCCounterSize || 16) * 0.75; + wx += Yanfly.Param.BSCCounterBufferX || 0; + wy += Yanfly.Param.BSCCounterBufferY || 8; + this.changePaintOpacity(true); + this.drawText(value, wx, wy, Window_Base._iconWidth, 'center'); + this.resetFontSettings(); + this.resetTextColor(); +}; + +//============================================================================= +// Window_Help +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +Yanfly.BSC.Window_Help_drawBattler = Window_Help.prototype.drawBattler; +Window_Help.prototype.drawBattler = function(battler) { + this.resetFontSettings(); + var length = battler.allIcons().length; + if (length <= 0) { + Yanfly.BSC.Window_Help_drawBattler.call(this, battler); + } else { + this.drawBattlerWithIcons(battler); + } +}; + +Window_Help.prototype.drawBattlerWithIcons = function(battler) { + var icons = battler.allIcons(); + var text = battler.name(); + var wx = 0; + var wy = 0; + this.drawText(text, wx, wy, this.contents.width, 'center'); + wy += this.lineHeight(); + var ww = icons.length * Window_Base._iconWidth; + ww = Math.min(ww, this.contents.width); + wx = (this.contents.width - ww) / 2; + this.drawActorIcons(battler, wx, wy, ww); +}; + +}; // Imported.YEP_BattleEngineCore + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_CoreEngine.js b/js/plugins/YEP_CoreEngine.js new file mode 100644 index 0000000..56c32da --- /dev/null +++ b/js/plugins/YEP_CoreEngine.js @@ -0,0 +1,2822 @@ +//============================================================================= +// Yanfly Engine Plugins - Core Engine +// YEP_CoreEngine.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_CoreEngine = true; + +var Yanfly = Yanfly || {}; +Yanfly.Core = Yanfly.Core || {}; +Yanfly.Core.version = 1.32; + +//============================================================================= +/*: + * @plugindesc v1.32 Needed for the majority of Yanfly Engine Scripts. Also + * contains bug fixes found inherently in RPG Maker. + * @author Yanfly Engine Plugins + * + * @param ---Screen--- + * @default + * + * @param Screen Width + * @parent ---Screen--- + * @type number + * @min 0 + * @desc Adjusts the width of the screen. + * Default: 816 + * @default 816 + * + * @param Screen Height + * @parent ---Screen--- + * @type number + * @min 0 + * @desc Adjusts the height of the screen. + * Default: 624 + * @default 624 + * + * @param Scale Battlebacks + * @parent ---Screen--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish to scale battlebacks to resolution? + * NO - false YES - true + * @default true + * + * @param Scale Title + * @parent ---Screen--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish to scale the title screen to resolution? + * NO - false YES - true + * @default true + * + * @param Scale Game Over + * @parent ---Screen--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish to scale the game over screen to resolution? + * NO - false YES - true + * @default true + * + * @param Open Console + * @parent ---Screen--- + * @type boolean + * @on Open + * @off Don't Open + * @desc For testing and debug purposes, this opens up the console. + * Don't Open - false Open - true + * @default false + * + * @param Reposition Battlers + * @parent ---Screen--- + * @type boolean + * @on YES + * @off NO + * @desc Allow the plugin to reposition battlers to resolution? + * NO - false YES - true + * @default true + * + * @param GameFont Load Timer + * @parent ---Screen--- + * @type number + * @min 0 + * @desc This allows you to set the timer for loading the GameFont. + * Set to 0 for unlimited time. Default: 20000 + * @default 0 + * + * @param Update Real Scale + * @parent ---Screen--- + * @type boolean + * @on YES + * @off NO + * @desc For now, best left alone, but it will allow real scaling for + * screen stretching. NO - false YES - true + * @default false + * + * @param Collection Clear + * @parent ---Screen--- + * @type boolean + * @on YES + * @off NO + * @desc Clears stored objects within major scenes upon switching + * scenes to free up memory. NO - false YES - true + * @default true + * + * @param ---Gold--- + * @desc + * + * @param Gold Max + * @parent ---Gold--- + * @type number + * @min 1 + * @desc The maximum amount of gold the player can have. + * Default: 99999999 + * @default 99999999 + * + * @param Gold Font Size + * @parent ---Gold--- + * @type number + * @min 1 + * @desc The font size used to display gold. + * Default: 28 + * @default 20 + * + * @param Gold Icon + * @parent ---Gold--- + * @type number + * @min 0 + * @desc This will be the icon used to represent gold in the gold + * window. If left at 0, no icon will be displayed. + * @default 313 + * + * @param Gold Overlap + * @parent ---Gold--- + * @desc This will be what's displayed when the gold number + * exceeds the allocated area's content size. + * @default A lotta + * + * @param ---Items--- + * @desc + * + * @param Default Max + * @parent ---Items--- + * @type number + * @min 1 + * @desc This is the maximum number of items a player can hold. + * Default: 99 + * @default 99 + * + * @param Quantity Text Size + * @parent ---Items--- + * @type number + * @min 1 + * @desc This is the text's font size used for the item quantity. + * Default: 28 + * @default 20 + * + * @param ---Parameters--- + * @default + * + * @param Max Level + * @parent ---Parameters--- + * @type number + * @min 1 + * @desc Adjusts the maximum level limit for actors. + * Default: 99 + * @default 99 + * + * @param Actor MaxHP + * @parent ---Parameters--- + * @type number + * @min 1 + * @desc Adjusts the maximum HP limit for actors. + * Default: 9999 + * @default 9999 + * + * @param Actor MaxMP + * @parent ---Parameters--- + * @type number + * @min 0 + * @desc Adjusts the maximum MP limit for actors. + * Default: 9999 + * @default 9999 + * + * @param Actor Parameter + * @parent ---Parameters--- + * @type number + * @min 1 + * @desc Adjusts the maximum parameter limit for actors. + * Default: 999 + * @default 999 + * + * @param Enemy MaxHP + * @parent ---Parameters--- + * @type number + * @min 1 + * @desc Adjusts the maximum HP limit for enemies. + * Default: 999999 + * @default 999999 + * + * @param Enemy MaxMP + * @parent ---Parameters--- + * @type number + * @min 0 + * @desc Adjusts the maximum MP limit for enemies. + * Default: 9999 + * @default 9999 + * + * @param Enemy Parameter + * @parent ---Parameters--- + * @type number + * @min 1 + * @desc Adjusts the maximum parameter limit for enemies. + * Default: 999 + * @default 999 + * + * @param ---Battle--- + * @desc + * + * @param Animation Rate + * @parent ---Battle--- + * @type number + * @min 1 + * @desc Adjusts the rate of battle animations. Lower for faster. + * Default: 4 + * @default 4 + * + * @param Flash Target + * @parent ---Battle--- + * @type boolean + * @on YES + * @off NO + * @desc If an enemy is targeted, it flashes or it can whiten. + * OFF - false ON - true + * @default false + * + * @param Show Events Transition + * @parent ---Battle--- + * @type boolean + * @on Show + * @off Hide + * @desc Show events during the battle transition? + * SHOW - true HIDE - false Default: false + * @default true + * + * @param Show Events Snapshot + * @parent ---Battle--- + * @type boolean + * @on Show + * @off Hide + * @desc Show events for the battle background snapshot? + * SHOW - true HIDE - false Default: false + * @default true + * + * @param ---Map Optimization--- + * @desc + * + * @param Refresh Update HP + * @parent ---Map Optimization--- + * @type boolean + * @on Show + * @off Hide + * @desc Do a full actor refresh when updating HP on map? + * YES - true NO - false Default: true + * @default true + * + * @param Refresh Update MP + * @parent ---Map Optimization--- + * @type boolean + * @on Show + * @off Hide + * @desc Do a full actor refresh when updating MP on map? + * YES - true NO - false Default: true + * @default true + * + * @param Refresh Update TP + * @parent ---Map Optimization--- + * @type boolean + * @on Show + * @off Hide + * @desc Do a full actor refresh when updating TP on map? + * YES - true NO - false Default: true + * @default false + * + * @param ---Font--- + * @desc + * + * @param Chinese Font + * @parent ---Font--- + * @desc Default font(s) used for a Chinese RPG. + * Default: SimHei, Heiti TC, sans-serif + * @default SimHei, Heiti TC, sans-serif + * + * @param Korean Font + * @parent ---Font--- + * @desc Default font(s) used for a Korean RPG. + * Default: Dotum, AppleGothic, sans-serif + * @default Dotum, AppleGothic, sans-serif + * + * @param Default Font + * @parent ---Font--- + * @desc Default font(s) used for everything else. + * Default: GameFont + * @default GameFont, Verdana, Arial, Courier New + * + * @param Font Size + * @parent ---Font--- + * @type number + * @min 1 + * @desc Default font size used for windows. + * Default: 28 + * @default 28 + * + * @param Text Align + * @parent ---Font--- + * @type combo + * @option left + * @option center + * @option right + * @desc How to align the text for command windows. + * left center right + * @default left + * + * @param ---Windows--- + * @default + * + * @param Digit Grouping + * @parent ---Windows--- + * @type boolean + * @on YES + * @off NO + * @desc Groups together digits with a comma. + * false - OFF true - ON + * @default true + * + * @param Line Height + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts universal line height used in Windows. + * Default: 36 + * @default 36 + * + * @param Icon Width + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the width of your icons. + * Default: 32 + * @default 32 + * + * @param Icon Height + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the height of your icons. + * Default: 32 + * @default 32 + * + * @param Face Width + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the width of actors' faces. + * Default: 144 + * @default 144 + * + * @param Face Height + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the height of actors' faces. + * Default: 144 + * @default 144 + * + * @param Window Padding + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the padding for all standard windows. + * Default: 18 + * @default 18 + * + * @param Text Padding + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the padding for text inside of windows. + * Default: 6 + * @default 6 + * + * @param Window Opacity + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Adjusts the background opacity for windows. + * Default: 192 + * @default 192 + * + * @param Gauge Outline + * @parent ---Windows--- + * @type boolean + * @on YES + * @off NO + * @desc Enable outlines for gauges. + * false - OFF true - ON + * @default true + * + * @param Gauge Height + * @parent ---Windows--- + * @type number + * @min 0 + * @desc Sets the height for gauges. + * Default: 6 + * @default 18 + * + * @param Menu TP Bar + * @parent ---Windows--- + * @type boolean + * @on YES + * @off NO + * @desc Draws a TP bar in the menu status for actors. + * false - OFF true - ON + * @default true + * + * @param ---Window Colors--- + * @default + * + * @param Color: Normal + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 0 + * @default 0 + * + * @param Color: System + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 16 + * @default 16 + * + * @param Color: Crisis + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 17 + * @default 17 + * + * @param Color: Death + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 18 + * @default 18 + * + * @param Color: Gauge Back + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 19 + * @default 19 + * + * @param Color: HP Gauge 1 + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 20 + * @default 20 + * + * @param Color: HP Gauge 2 + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 21 + * @default 21 + * + * @param Color: MP Gauge 1 + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 22 + * @default 22 + * + * @param Color: MP Gauge 2 + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 23 + * @default 23 + * + * @param Color: MP Cost + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 23 + * @default 23 + * + * @param Color: Power Up + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 24 + * @default 24 + * + * @param Color: Power Down + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 25 + * @default 25 + * + * @param Color: TP Gauge 1 + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 28 + * @default 28 + * + * @param Color: TP Gauge 2 + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 29 + * @default 29 + * + * @param Color: TP Cost Color + * @parent ---Window Colors--- + * @type number + * @min 0 + * @max 31 + * @desc Changes the text color for Windows. + * Default: 29 + * @default 29 + * + * @help + * ============================================================================ + * Introduction and Instructions + * ============================================================================ + * + * Yanfly Engine Plugins - Core Engine is made for RPG Maker MV. This plugin + * functions primarily to fix bugs and to allow the user more control over RPG + * Maker MV's various features, such as the screen resolution, font, window + * colors, and more. + * + * Just place this on top of all the other Yanfly Engine Plugins. + * Adjust any parameters as you see fit. + * + * ============================================================================ + * Bug Fixes + * ============================================================================ + * + * This plugin fixes a few bugs found present within RPG Maker MV. Of them are + * the following: + * + * Animation Overlay + * When a skill/item that targets multiple enemies at once using a fullscreen + * animation, it will overlay multiple times causing the image to look + * distorted by a series of overlayed effects. The plugin fixes this issue by + * having only one animation played over the group instead of every one. + * + * Audio Volume Stacking + * Sometimes when multiple sound effects are played in the same frame with + * the exact settings (usually due to animaitons), the volume stacks upon + * each other, causing them to not play the intended volume for the effect. + * This plugin fixes this issue by preventing sound effects of the same exact + * settings from playing during the same frame, allowing only the first to + * go through without stacking the volume higher. + * + * Event Movement Speed + * The movement speed of events are slightly slower than what they should be + * due a small error in the source code. The plugin fixes this issue and they + * move at the properly speed. + * + * Event Movement Queue + * If an event were to move through an event command, changing a condition + * that would set the event to change to a different page would cause that + * event's move route to halt in its tracks. The plugin fixes this issue and + * the event's move route will finish. + * + * Event Colliding + * Events cannot move over other events with a Below Player setting. This + * makes it difficult for certain types of puzzles or events to exist. This + * plugin fixes this issue by making the collision check only apply to events + * of "Same as Characters" priority. Any event that's above or below the + * characters will no longer collide with other events. + * + * Screen Tearing + * When moving slowly, the tiles on the screen tear. While it's not + * noticeable on all systems, slower computers will definitely show it. The + * plugin will fix this issue and synch the tiles to keep up to pace with + * the screen's camera movement properly. + * + * Sprite Distortion + * Because of JavaScript's strange mathematical behavior, sometimes values + * with decimal places cause spritesheets to end up looking distorted. The + * plugin will get rid of the decimal places and have sprite sheets take out + * frames properly by using integer values only. + * + * ============================================================================ + * Gold + * ============================================================================ + * + * You can use the plugin commands to add or remove gold more than the + * editor's 9,999,999 limit. You can also place notetags into items, weapons, + * and armors to over the 999,999 cost limit. + * + * Plugin Command: + * GainGold 1234567890 # Party gains 1234567890 gold. + * LoseGold 9876543210 # Party loses 9876543210 gold. + * + * Item, Weapon, Armor Notetags + * + * Changes the price of the item to x. This notetag allows you to bypass the + * editor's 999,999 gold cost limit. + * + * Enemy Notetag + * + * Changes the gold drop value of enemies to x. This notetag allows you to + * bypass the editor's 9,999,999 gold drop limit. + * + * ============================================================================ + * Items + * ============================================================================ + * + * Change the parameters to reflect the maximum number of items a player can + * hold per item. If you wish to make individual items have different max + * values, use the following notetag: + * + * Item, Weapon, Armor Notetag: + * + * This changes the maximum amount of the item to x. + * + * ============================================================================ + * Stats + * ============================================================================ + * + * Even with the parameter limits raised, the editor is still confined to RPG + * Maker MV's default limits. To break past them, use the following notetags + * to allow further control over the individual aspects for the parameters. + * + * Actor Notetag + * + * Changes the actor's initial level to x. This allows you to bypass the + * editor's level 99 limit. + * + * + * Changes the actor's max level to x. This allows you to bypass the editor's + * level 99 limit. + * + * Class Skill Learn Notetag + * + * When placed inside a class's "Skills to Learn" notetag, this will cause + * the class to learn the skill at level x. + * + * Weapon and Armor Notetags + * + * + * Allows the piece of weapon or armor to gain or lose x amount of stat. + * Replace "stat" with "hp", "mp", "atk", "def", "mat", "mdf", "agi", or + * "luk" to alter that specific stat. This allows the piece of equipment + * to go past the editor's default limitation so long as the maximum value + * allows for it. + * + * Enemy Notetags + * + * This changes the enemy's stat to x amount. Replace "stat" with "hp", + * "mp", "atk", "def", "mat", "mdf", "agi", or "luk" to alter that + * specific stat. This allows the piece of equipment to go past the + * editor's default limitation. + * + * + * This changes the enemy's exp given out to x amount. This allows the + * enemy give out more exp than the editor's default 9,999,999 limit. + * + * ============================================================================ + * Script Call Fail Safe + * ============================================================================ + * + * Irregular code in damage formulas, script calls, conditional branches, and + * variable events will no longer crash the game. Instead, they will force open + * the console window to display the error only during test play. + * + * If the player is not in test play, the game will continue as normal without + * the error being shown. If the game is being played in a browser, opening up + * the console window will still display the error. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.32: + * - Reversed the disable for the screen jitter fix from version 1.24. Somehow + * it came back and I don't know when, but now it needs to go. + * + * Version 1.31: + * - Added Fallen Angel Olivia's full error message display to the Core Engine + * (with her permission of course). + * - Bug fixed regarding blend modes and bush depth making sprites not blend + * properly in-game. + * - Tab key no longer requires you to press it twice before triggering Tab-key + * related inputs. + * + * Version 1.30: + * - Bug fixed for audio Sound Effect stacking. + * - Optimization update. + * + * Version 1.29: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.28: + * - Upon pressing F5 to reload your game, this will close the DevTools Debug + * Console if it is opened before reloading. This is because reloading with it + * closed ends up reloading the game faster. + * - New plugin parameters added: Refresh Update HP, MP, and TP + * - Option to choose to do a full actor refresh upon changing HP, MP, or TP + * - This is to reduce overall map lagging. + * + * Version 1.27: + * - Updated for RPG Maker MV version 1.6.0: + * - Fixing script call checks made with switches and self switches under + * conditional branches due to how ES6 handles === differently. + * + * Version 1.26: + * - Updated for RPG Maker MV version 1.6.0: + * - Removal of the destructive code in Scene_Item.update function. + * - Open Console parameter now occurs after the map's been loaded or after + * the battle has started. This is because after the 1.6.0 changes, loading + * the console before anything else will lock up other aspects of RPG Maker + * from loading properly. + * + * Version 1.25: + * - Updated for RPG Maker MV version 1.5.0. + * - Updated Scale Title and Scale GameOver to work with 1.5.0. + * + * Version 1.24: + * - Screen jittering prevention is now prevented for RPG Maker MV 1.3.4 and + * above since Pixi4 handles that now. + * + * Version 1.23: + * - For RPG Maker MV version 1.3.2 and above, the 'Scale Battlebacks' plugin + * parameter will now recreate the battleback sprites in a different format. + * This is because battleback scaling with Tiling Sprites is just too volatile. + * Battleback sprites are now just regular sprites instead of tiling sprites. + * This may or may not cause plugin incompatibilities with other plugins that + * alter battlebacks. + * - For RPG Maker MV version 1.3.4, Game_Actor.meetsUsableItemConditions is + * now updated to return a check back to the original Game_BattlerBase version + * to maintain compatibility with other plugins. + * + * Version 1.22: + * - Added 'Show Events Transition' plugin parameter. Enabling this will make + * events on the map no longer hide themselves while entering battle during the + * transition. + * - Added 'Show Events Snapshot' plugin parameter. Enabling this will keep + * events shown as a part of the battle snapshot when entering battle. + * - Irregular code in damage formulas, script calls, conditional branches, and + * variable events will no longer crash the game. Instead, it will force open + * the console window to display the error only during Test Play. + * + * Version 1.21: + * - Fixed a bug with scaling battlebacks not working properly for Front View. + * - Optimization update to keep garbage collection across all scenes. + * + * Version 1.20: + * - Altered increasing resolution function. + * - Added 'Update Real Scale' plugin parameter. This is best left alone for + * now and to be used if a later update meshes with rendered scaling. + * - Added memory clear functionality for versions under 1.3.2 to free up more + * memory upon leaving the map scene. + * - Added 'Collection Clear' plugin parameter. This option, if left on, will + * clear the attached children to Scene_Map and Scene_Battle upon switching to + * a different scene. This will potentially free up memory from various objects + * added to those scenes from other plugins (depending on how they're added) + * and serve as a means of reducing memory bloat. + * + * Version 1.19: + * - Updated for RPG Maker MV version 1.3.2. + * - Fixed 'LearnSkill' function for actors to not be bypassed if a piece of + * equipment has temporarily added a skill. + * + * Version 1.18: + * - Fixed a bug with scaling battlebacks not working properly for Front View. + * + * Version 1.17: + * - Updated for RPG Maker MV version 1.3.0. + * + * Version 1.16: + * - Fixed a bug with RPG Maker MV's inherent 'drawTextEx' function. By default + * it calculates the text height and then resets the font settings before + * drawing the text, which makes the text height inconsistent if it were to + * match the calculated height settings. + * + * Version 1.15: + * - Window's are now set to have only widths and heights of whole numbers. No + * longer is it possible for them to have decimal values. This is to reduce any + * and all clipping issues caused by non-whole numbers. + * + * Version 1.14: + * - Optimization update for RPG Maker MV itself by replacing more memory + * intensive loops in commonly used functions with more efficient loops. + * + * Version 1.13: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.12: + * - Fixed a bug with a notetag: . Now, the notetag works + * with both and + * + * Version 1.11: + * - Made fixes to the MV Source Code where FaceWidth was using a hard-coded + * 144 value regardless of what was changed for the Face Width parameter. + * - Fixed a notetag that wasn't working with the enemy EXP values. + * - Updated battler repositioning to no longer clash when entering-exiting the + * scene with Row Formation. + * + * Version 1.10: + * - Removed an MV bugfix that was applied through MV's newes tupdate. + * + * Version 1.09: + * - Changed minimum display width for status drawing to accomodate Party + * Formation defaults. + * + * Version 1.08: + * - Fixed a bug within the MV Source with changing classes and maintaining + * levels, even though the feature to maintain the levels has been removed. + * + * Version 1.07: + * - Fixed an issue with the gauges drawing outlines thicker than normal at odd + * intervals when windows are scaled irregularly. + * + * Version 1.06: + * - Removed event frequency bug fix since it's now included in the source. + * + * Version 1.05: + * - Added 'Scale Game Over' parameter to plugin settings. + * + * Version 1.04: + * - Reworked math for calculating scaled battleback locations. + * - Fixed a bug where if the party failed to escape from battle, states that + * would be removed by battle still get removed. *Fixed by Emjenoeg* + * + * Version 1.03: + * - Fixed a strange bug that made scaled battlebacks shift after one battle. + * + * Version 1.02: + * - Fixed a bug that made screen fading on mobile devices work incorrectly. + * - Added 'Scale Battlebacks' and 'Scale Title' parameters. + * + * Version 1.01: + * - Fixed a bug that where if button sprites had different anchors, they would + * not be properly clickable. *Fixed by Zalerinian* + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_CoreEngine'); +Yanfly.Param = Yanfly.Param || {}; +Yanfly.Icon = Yanfly.Icon || {}; + +Yanfly.Param.ScreenWidth = Number(Yanfly.Parameters['Screen Width'] || 816); +Yanfly.Param.ScreenHeight = Number(Yanfly.Parameters['Screen Height'] || 624); +Yanfly.Param.ScaleBattleback = String(Yanfly.Parameters['Scale Battlebacks']); +Yanfly.Param.ScaleBattleback = eval(Yanfly.Param.ScaleBattleback); +Yanfly.Param.ScaleTitle = eval(String(Yanfly.Parameters['Scale Title'])); +Yanfly.Param.ScaleGameOver = eval(String(Yanfly.Parameters['Scale Game Over'])); +Yanfly.Param.OpenConsole = String(Yanfly.Parameters['Open Console']); +Yanfly.Param.OpenConsole = eval(Yanfly.Param.OpenConsole); +Yanfly.Param.ReposBattlers = String(Yanfly.Parameters['Reposition Battlers']); +Yanfly.Param.ReposBattlers = eval(Yanfly.Param.ReposBattlers); +Yanfly.Param.GameFontTimer = Number(Yanfly.Parameters['GameFont Load Timer']); +Yanfly.Param.UpdateRealScale = String(Yanfly.Parameters['Update Real Scale']); +Yanfly.Param.UpdateRealScale = eval(Yanfly.Param.UpdateRealScale); +Yanfly.Param.CollectionClear = String(Yanfly.Parameters['Collection Clear']); +Yanfly.Param.CollectionClear = eval(Yanfly.Param.CollectionClear); + +Yanfly.Param.MaxGold = String(Yanfly.Parameters['Gold Max']); +Yanfly.Param.GoldFontSize = Number(Yanfly.Parameters['Gold Font Size']); +Yanfly.Icon.Gold = Number(Yanfly.Parameters['Gold Icon']); +Yanfly.Param.GoldOverlap = String(Yanfly.Parameters['Gold Overlap']); + +Yanfly.Param.MaxItem = Number(Yanfly.Parameters['Default Max']); +Yanfly.Param.ItemQuantitySize = Number(Yanfly.Parameters['Quantity Text Size']); + +Yanfly.Param.MaxLevel = Number(Yanfly.Parameters['Max Level']); +Yanfly.Param.EnemyMaxHp = Number(Yanfly.Parameters['Enemy MaxHP']); +Yanfly.Param.EnemyMaxMp = Number(Yanfly.Parameters['Enemy MaxMP']); +Yanfly.Param.EnemyParam = Number(Yanfly.Parameters['Enemy Parameter']); +Yanfly.Param.ActorMaxHp = Number(Yanfly.Parameters['Actor MaxHP']); +Yanfly.Param.ActorMaxMp = Number(Yanfly.Parameters['Actor MaxMP']); +Yanfly.Param.ActorParam = Number(Yanfly.Parameters['Actor Parameter']); + +Yanfly.Param.AnimationRate = Number(Yanfly.Parameters['Animation Rate']); +Yanfly.Param.FlashTarget = eval(String(Yanfly.Parameters['Flash Target'])); +Yanfly.Param.ShowEvTrans = String(Yanfly.Parameters['Show Events Transition']); +Yanfly.Param.ShowEvTrans = eval(Yanfly.Param.ShowEvTrans); +Yanfly.Param.ShowEvSnap = String(Yanfly.Parameters['Show Events Snapshot']); +Yanfly.Param.ShowEvSnap = eval(Yanfly.Param.ShowEvSnap); + +Yanfly.Param.RefreshUpdateHp = String(Yanfly.Parameters['Refresh Update HP']); +Yanfly.Param.RefreshUpdateHp = eval(Yanfly.Param.RefreshUpdateHp); +Yanfly.Param.RefreshUpdateMp = String(Yanfly.Parameters['Refresh Update MP']); +Yanfly.Param.RefreshUpdateMp = eval(Yanfly.Param.RefreshUpdateMp); +Yanfly.Param.RefreshUpdateTp = String(Yanfly.Parameters['Refresh Update TP']); +Yanfly.Param.RefreshUpdateTp = eval(Yanfly.Param.RefreshUpdateTp); + +Yanfly.Param.ChineseFont = String(Yanfly.Parameters['Chinese Font']); +Yanfly.Param.KoreanFont = String(Yanfly.Parameters['Korean Font']); +Yanfly.Param.DefaultFont = String(Yanfly.Parameters['Default Font']); +Yanfly.Param.FontSize = Number(Yanfly.Parameters['Font Size']); +Yanfly.Param.TextAlign = String(Yanfly.Parameters['Text Align']); + +Yanfly.Param.DigitGroup = eval(String(Yanfly.Parameters['Digit Grouping'])); +Yanfly.Param.LineHeight = Number(Yanfly.Parameters['Line Height']); +Yanfly.Param.IconWidth = Number(Yanfly.Parameters['Icon Width'] || 32);; +Yanfly.Param.IconHeight = Number(Yanfly.Parameters['Icon Height'] || 32);; +Yanfly.Param.FaceWidth = Number(Yanfly.Parameters['Face Width'] || 144); +Yanfly.Param.FaceHeight = Number(Yanfly.Parameters['Face Height'] || 144); +Yanfly.Param.WindowPadding = Number(Yanfly.Parameters['Window Padding']); +Yanfly.Param.TextPadding = Number(Yanfly.Parameters['Text Padding']); +Yanfly.Param.WindowOpacity = Number(Yanfly.Parameters['Window Opacity']); +Yanfly.Param.GaugeOutline = eval(String(Yanfly.Parameters['Gauge Outline'])); +Yanfly.Param.GaugeHeight = Number(Yanfly.Parameters['Gauge Height']); +Yanfly.Param.MenuTpGauge = eval(String(Yanfly.Parameters['Menu TP Bar'])); + +Yanfly.Param.ColorNormal = Number(Yanfly.Parameters['Color: Normal']); +Yanfly.Param.ColorSystem = Number(Yanfly.Parameters['Color: System']); +Yanfly.Param.ColorCrisis = Number(Yanfly.Parameters['Color: Crisis']); +Yanfly.Param.ColorDeath = Number(Yanfly.Parameters['Color: Death']); +Yanfly.Param.ColorGaugeBack = Number(Yanfly.Parameters['Color: Gauge Back']); +Yanfly.Param.ColorHpGauge1 = Number(Yanfly.Parameters['Color: HP Gauge 1']); +Yanfly.Param.ColorHpGauge2 = Number(Yanfly.Parameters['Color: HP Gauge 2']); +Yanfly.Param.ColorMpGauge1 = Number(Yanfly.Parameters['Color: MP Gauge 1']); +Yanfly.Param.ColorMpGauge2 = Number(Yanfly.Parameters['Color: MP Gauge 2']); +Yanfly.Param.ColorMpCost = Number(Yanfly.Parameters['Color: MP Cost']); +Yanfly.Param.ColorPowerUp = Number(Yanfly.Parameters['Color: Power Up']); +Yanfly.Param.ColorPowerDown = Number(Yanfly.Parameters['Color: Power Down']); +Yanfly.Param.ColorTpGauge1 = Number(Yanfly.Parameters['Color: TP Gauge 1']); +Yanfly.Param.ColorTpGauge2 = Number(Yanfly.Parameters['Color: TP Gauge 2']); +Yanfly.Param.ColorTpCost = Number(Yanfly.Parameters['Color: TP Cost Color']); + +//============================================================================= +// Bitmap +//============================================================================= + +Yanfly.Core.Bitmap_initialize = Bitmap.prototype.initialize; +Bitmap.prototype.initialize = function(width, height) { + Yanfly.Core.Bitmap_initialize.call(this, width, height); + this.fontFace = Yanfly.Param.DefaultFont; +}; + +Yanfly.Core.Bitmap_blt = Bitmap.prototype.blt; +Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) { + sx = Math.floor(sx); + sy = Math.floor(sy); + sw = Math.floor(sw); + sh = Math.floor(sh); + dx = Math.floor(dx); + dy = Math.floor(dy); + dw = Math.floor(dw); + dh = Math.floor(dh); + Yanfly.Core.Bitmap_blt.call(this, source, sx, sy, sw, sh, dx, dy, dw, dh); +}; + +Yanfly.Core.Bitmap_fillRect = Bitmap.prototype.fillRect; +Bitmap.prototype.fillRect = function(x, y, w, h, c) { + x = Math.floor(x); + y = Math.floor(y); + w = Math.floor(w); + h = Math.floor(h); + Yanfly.Core.Bitmap_fillRect.call(this, x, y, w, h, c); +}; + +Yanfly.Core.Bitmap_gradientFillRect = Bitmap.prototype.gradientFillRect; +Bitmap.prototype.gradientFillRect = function(x, y, w, h, c1, c2, ve) { + Yanfly.Core.Bitmap_gradientFillRect.call(this, x, y, w, h, c1, c2, ve); +}; + +Yanfly.Core.Bitmap_drawCircle = Bitmap.prototype.drawCircle; +Bitmap.prototype.drawCircle = function(x, y, r, c) { + x = Math.floor(x); + y = Math.floor(y); + Yanfly.Core.Bitmap_drawCircle.call(this, x, y, r, c); +}; + +Yanfly.Core.Bitmap_drawText = Bitmap.prototype.drawText; +Bitmap.prototype.drawText = function(text, x, y, mW, l, align) { + x = Math.floor(x); + y = Math.floor(y); + if (mW < 0) mW = 0; + mW = Math.floor(mW); + l = Math.floor(l); + Yanfly.Core.Bitmap_drawText.call(this, text, x, y, mW, l, align); +}; + +//============================================================================= +// Graphics +//============================================================================= + +if (Yanfly.Param.UpdateRealScale) { + +Graphics._updateRealScale = function() { + if (this._stretchEnabled) { + var h = window.innerWidth / this._width; + var v = window.innerHeight / this._height; + this._realScale = Math.min(h, v); + if (this._realScale >= 3) this._realScale = 3; + else if (this._realScale >= 2) this._realScale = 2; + else if (this._realScale >= 1.5) this._realScale = 1.5; + else if (this._realScale >= 1) this._realScale = 1; + else this._realScale = 0.5; + } else { + this._realScale = this._scale; + } +}; + +}; // Yanfly.Param.UpdateRealScale + +Graphics.printFullError = function(name, message, stack) { + stack = this.processErrorStackMessage(stack); + if (this._errorPrinter) { + this._errorPrinter.innerHTML = + this._makeFullErrorHtml(name, message, stack); + } + this._applyCanvasFilter(); + this._clearUpperCanvas(); +}; + +Graphics._makeFullErrorHtml = function(name, message, stack) { + var text = ''; + for (var i = 2; i < stack.length; ++i) { + text += '' + stack[i] + '
'; + } + return ('' + stack[0] + '
' + + '' + stack[1] + '
' + text); +}; + +Graphics.processErrorStackMessage = function(stack) { + var data = stack.split(/(?:\r\n|\r|\n)/); + data.unshift('Game has encountered a bug. Please report it.
'); + for (var i = 1; i < data.length; ++i) { + data[i] = data[i].replace(/[\(](.*[\/])/, '('); + } + data.push('
Press F5 to restart the game.' + + '
'); + return data; +}; + +Yanfly.Core.Graphics_updateErrorPrinter = Graphics._updateErrorPrinter; +Graphics._updateErrorPrinter = function() { + Yanfly.Core.Graphics_updateErrorPrinter.call(this); + this._errorPrinter.height = this._height * 0.5; + this._errorPrinter.style.textAlign = 'left'; + this._centerElement(this._errorPrinter); +}; + +SceneManager.catchException = function(e) { + if (e instanceof Error) { + Graphics.printFullError(e.name, e.message, e.stack); + console.error(e.stack); + } else { + Graphics.printError('UnknownError', e); + } + AudioManager.stopAll(); + this.stop(); +}; + +//============================================================================= +// Input +//============================================================================= + +Yanfly.Core.Input_shouldPreventDefault = Input._shouldPreventDefault; +Input._shouldPreventDefault = function(keyCode) { + if (keyCode === 9) return true; + return Yanfly.Core.Input_shouldPreventDefault.call(this, keyCode); +}; + +//============================================================================= +// Sprite +//============================================================================= + +Yanfly.Core.Sprite_updateTransform = Sprite.prototype.updateTransform; +Sprite.prototype.updateTransform = function() { + Yanfly.Core.Sprite_updateTransform.call(this); + this.worldTransform.tx = Math.floor(this.worldTransform.tx); + this.worldTransform.ty = Math.floor(this.worldTransform.ty); +}; + +//============================================================================= +// ScreenSprite +//============================================================================= + +Yanfly.Core.ScreenSprite_initialize = ScreenSprite.prototype.initialize; +ScreenSprite.prototype.initialize = function() { + Yanfly.Core.ScreenSprite_initialize.call(this); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.0') return; + this.scale.x = Graphics.boxWidth * 10; + this.scale.y = Graphics.boxHeight * 10; + this.anchor.x = 0.5; + this.anchor.y = 0.5; + this.x = 0; + this.y = 0; +}; + +//============================================================================= +// Window +//============================================================================= + +Yanfly.Core.Window_refreshAllParts = Window.prototype._refreshAllParts; +Window.prototype._refreshAllParts = function() { + this._roundWhUp(); + Yanfly.Core.Window_refreshAllParts.call(this); +}; + +Window.prototype._roundWhUp = function() { + this._width = Math.ceil(this._width); + this._height = Math.ceil(this._height); +}; + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.Core.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.Core.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_CoreEngine) { + this.processCORENotetags1($dataItems); + this.processCORENotetags1($dataWeapons); + this.processCORENotetags1($dataArmors); + this.processCORENotetags2($dataEnemies); + this.processCORENotetags3($dataActors); + this.processCORENotetags4($dataClasses); + Yanfly._loaded_YEP_CoreEngine = true; + } + return true; +}; + +DataManager.processCORENotetags1 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.maxItem = Yanfly.Param.MaxItem; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:PRICE):[ ](\d+)>/i)) { + obj.price = parseInt(RegExp.$1); + } else if (line.match(/<(?:MAX ITEM):[ ](\d+)>/i)) { + obj.maxItem = Math.max(1, parseInt(RegExp.$1)); + } else if (line.match(/<(.*):[ ]([\+\-]\d+)>/i)) { + var stat = String(RegExp.$1).toUpperCase(); + var value = parseInt(RegExp.$2); + switch (stat) { + case 'HP': + case 'MAXHP': + case 'MAX HP': + obj.params[0] = value; + break; + case 'MP': + case 'MAXMP': + case 'MAX MP': + case 'SP': + case 'MAXSP': + case 'MAX SP': + obj.params[1] = value; + break; + case 'ATK': + case 'STR': + obj.params[2] = value; + break; + case 'DEF': + obj.params[3] = value; + break; + case 'MAT': + case 'INT' || 'SPI': + obj.params[4] = value; + break; + case 'MDF': + case 'RES': + obj.params[5] = value; + break; + case 'AGI': + case 'SPD': + obj.params[6] = value; + break; + case 'LUK': + obj.params[7] = value; + break; + case 'EXP': + case 'XP': + obj.exp = value; + break; + } + } + } + } +}; + +DataManager.processCORENotetags2 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:GOLD):[ ](\d+)>/i)) { + obj.gold = parseInt(RegExp.$1); + } else if (line.match(/<(.*):[ ](\d+)>/i)) { + var stat = String(RegExp.$1).toUpperCase(); + var value = parseInt(RegExp.$2); + switch (stat) { + case 'HP': + case 'MAXHP': + case 'MAX HP': + obj.params[0] = value; + break; + case 'MP': + case 'MAXMP': + case 'MAX MP': + case 'SP': + case 'MAXSP': + case 'MAX SP': + obj.params[1] = value; + break; + case 'ATK': + case 'STR': + obj.params[2] = value; + break; + case 'DEF': + obj.params[3] = value; + break; + case 'MAT': + case 'INT': + case 'SPI': + obj.params[4] = value; + break; + case 'MDF': + case 'RES': + obj.params[5] = value; + break; + case 'AGI': + case 'SPD': + obj.params[6] = value; + break; + case 'LUK': + obj.params[7] = value; + break; + case 'EXP': + case 'XP': + obj.exp = value; + break; + } + } + } + } +}; + +DataManager.processCORENotetags3 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.maxLevel = Yanfly.Param.MaxLevel; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:MAX LEVEL):[ ](\d+)>/i)) { + obj.maxLevel = parseInt(RegExp.$1); + if (obj.maxLevel < 1) obj.maxLevel = 1; + } else if (line.match(/<(?:INITIAL LEVEL):[ ](\d+)>/i)) { + obj.initialLevel = parseInt(RegExp.$1); + if (obj.initialLevel < 1) obj.initialLevel = 1; + } + } + } +}; + +DataManager.processCORENotetags4 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.learnings.forEach(function(learning) { + if (learning.note.match(/<(?:LEARN LEVEL|LEARN AT LEVEL):[ ](\d+)>/i)) { + learning.level = parseInt(RegExp.$1); + if (learning.level < 1) obj.maxLevel = 1; + } + }, this); + } +}; + +//============================================================================= +// AudioManager Stacking Volume Bug Fix +//============================================================================= + +Yanfly.Core.AudioManager_playSe = AudioManager.playSe; +AudioManager.playSe = function(se) { + this._frameSe = this._frameSe || []; + if (this.uniqueCheckSe(se)) { + Yanfly.Core.AudioManager_playSe.call(this, se); + this._frameSe.push(se); + } +}; + +AudioManager.uniqueCheckSe = function(se1) { + if (this._frameSe.contains(se1)) return false; + return true; +}; + +AudioManager.clearUniqueCheckSe = function() { + this._frameSe = []; +}; + +Yanfly.Core.SceneManager_updateInputData = SceneManager.updateInputData; +SceneManager.updateInputData = function() { + Yanfly.Core.SceneManager_updateInputData.call(this); + AudioManager.clearUniqueCheckSe(); +}; + +//============================================================================= +// SceneManager +//============================================================================= + +SceneManager._screenWidth = Yanfly.Param.ScreenWidth; +SceneManager._screenHeight = Yanfly.Param.ScreenHeight; +SceneManager._boxWidth = Yanfly.Param.ScreenWidth; +SceneManager._boxHeight = Yanfly.Param.ScreenHeight + +Yanfly.Core.SceneManager_run = SceneManager.run; +SceneManager.run = function(sceneClass) { + Yanfly.Core.SceneManager_run.call(this, sceneClass); + Yanfly.updateResolution(); + if (!Utils.isNwjs()) return; + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Yanfly.Param.OpenConsole) Yanfly.openConsole(); +}; + +Yanfly.updateResolution = function() { + var resizeWidth = Yanfly.Param.ScreenWidth - window.innerWidth; + var resizeHeight = Yanfly.Param.ScreenHeight - window.innerHeight; + if (!Imported.ScreenResolution) { + window.moveBy(-1 * resizeWidth / 2, -1 * resizeHeight / 2); + window.resizeBy(resizeWidth, resizeHeight); + } +}; + +Yanfly.openConsole = function() { + Yanfly._openedConsole = true; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + var _debugWindow = require('nw.gui').Window.get().showDevTools(); + if (_debugWindow) _debugWindow.moveTo(0, 0); + window.focus(); + } +}; + +Yanfly.Core.SceneManager_onKeyDown = SceneManager.onKeyDown; +SceneManager.onKeyDown = function(event) { + if (!event.ctrlKey && !event.altKey && event.keyCode === 116) { + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + var win = require('nw.gui').Window.get(); + win.closeDevTools(); + } + } + Yanfly.Core.SceneManager_onKeyDown.call(this, event); +}; + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") { + +Yanfly.openConsole = function() { + Yanfly._openedConsole = true; + if (!Yanfly.Param.OpenConsole) return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + var win = require('nw.gui').Window.get(); + win.showDevTools(); + setTimeout(this.focusWindow.bind(this, win), 500); + } +}; + +Yanfly.focusWindow = function(win) { + win.focus(); +}; + +Yanfly.Core.Scene_Map_update = Scene_Map.prototype.update; +Scene_Map.prototype.update = function() { + Yanfly.Core.Scene_Map_update.call(this); + if (!Yanfly._openedConsole) Yanfly.openConsole(); +}; + +Yanfly.Core.Scene_Battle_update = Scene_Battle.prototype.update; +Scene_Battle.prototype.update = function() { + Yanfly.Core.Scene_Battle_update.call(this); + if (!Yanfly._openedConsole) Yanfly.openConsole(); +}; + +}; // 1.6.0 + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.Core.BattleManager_displayStartMessages = + BattleManager.displayStartMessages; +BattleManager.displayStartMessages = function() { + Yanfly.Core.BattleManager_displayStartMessages.call(this); + $gameTroop.members().forEach(function(enemy) { + enemy.recoverAll(); + }); +}; + +BattleManager.processEscape = function() { + $gameParty.performEscape(); + SoundManager.playEscape(); + var success = this._preemptive ? true : (Math.random() < this._escapeRatio); + if (success) { + $gameParty.removeBattleStates(); + this.displayEscapeSuccessMessage(); + this._escaped = true; + this.processAbort(); + } else { + this.displayEscapeFailureMessage(); + this._escapeRatio += 0.1; + $gameParty.clearActions(); + this.startTurn(); + } + return success; +}; + +//============================================================================= +// Game_BattlerBase +//============================================================================= + +Game_BattlerBase.prototype.paramMax = function(paramId) { + if (paramId === 0) { + return Yanfly.Param.EnemyMaxHp; + } else if (paramId === 1) { + return Yanfly.Param.EnemyMaxMp; + } else { + return Yanfly.Param.EnemyParam; + } +}; + +Yanfly.Core.Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh; + +Game_BattlerBase.prototype.mapRegenUpdateCheck = function(type) { + if ($gameParty.inBattle()) return true; + if (type === 'hp') { + return Yanfly.Param.RefreshUpdateHp; + } else if (type === 'mp') { + return Yanfly.Param.RefreshUpdateMp; + } else if (type === 'tp') { + return Yanfly.Param.RefreshUpdateTp; + } +}; + +Game_BattlerBase.prototype.setHp = function(hp) { + if (this._hp === hp) return; + this._hp = hp; + if (this.mapRegenUpdateCheck('hp')) { + this.refresh(); + } else { + Yanfly.Core.Game_BattlerBase_refresh.call(this); + } +}; + +Game_BattlerBase.prototype.setMp = function(mp) { + if (this._mp === mp) return; + this._mp = mp; + if (this.mapRegenUpdateCheck('mp')) { + this.refresh(); + } else { + Yanfly.Core.Game_BattlerBase_refresh.call(this); + } +}; + +Game_BattlerBase.prototype.setTp = function(tp) { + if (this._tp === tp) return; + this._tp = tp; + if (this.mapRegenUpdateCheck('tp')) { + this.refresh(); + } else { + Yanfly.Core.Game_BattlerBase_refresh.call(this); + } +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.onTurnEnd = function() { + this.clearResult(); + this.regenerateAll(); + this.updateStateTurns(); + this.updateBuffTurns(); + this.removeStatesAuto(2); +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Yanfly.Core.Game_Actor_isMaxLevel = Game_Actor.prototype.isMaxLevel; +Game_Actor.prototype.isMaxLevel = function() { + if (this.maxLevel() === 0) return false; + return Yanfly.Core.Game_Actor_isMaxLevel.call(this); +}; + +Game_Actor.prototype.paramMax = function(paramId) { + if (paramId === 0) { + return Yanfly.Param.ActorMaxHp; + } else if (paramId === 1) { + return Yanfly.Param.ActorMaxMp; + } else { + return Yanfly.Param.ActorParam; + } +}; + +Yanfly.Core.Game_Actor_paramBase = Game_Actor.prototype.paramBase; +Game_Actor.prototype.paramBase = function(paramId) { + if (this.level > 99) { + var i = this.currentClass().params[paramId][99]; + var j = this.currentClass().params[paramId][98]; + i += (i - j) * (this.level - 99); + return i; + } + return Yanfly.Core.Game_Actor_paramBase.call(this, paramId); +}; + +Game_Actor.prototype.changeClass = function(classId, keepExp) { + if (keepExp) { + this._exp[classId] = this._exp[this._classId]; + } + this._classId = classId; + this.changeExp(this._exp[this._classId] || 0, false); + this.refresh(); +}; + +Game_Actor.prototype.learnSkill = function(skillId) { + if (!this._skills.contains(skillId)) { + this._skills.push(skillId); + this._skills.sort(function(a, b) { + return a - b; + }); + } +}; + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.4') { + +Game_Actor.prototype.meetsUsableItemConditions = function(item) { + if($gameParty.inBattle() && !BattleManager.canEscape() && + this.testEscape(item)){ + return false; + } + return Game_BattlerBase.prototype.meetsUsableItemConditions.call(this, item); +}; + +}; // Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.4' + +//============================================================================= +// Game_Party +//============================================================================= + +Game_Party.prototype.maxGold = function() { + return eval(Yanfly.Param.MaxGold); +}; + +Game_Party.prototype.maxItems = function(item) { + if (!item) return 1; + return item.maxItem; +}; + +Game_Party.prototype.onPlayerWalk = function() { + var group = this.members(); + var length = group.length; + for (var i = 0; i < length; ++i) { + var actor = group[i]; + if (actor) actor.onPlayerWalk(); + } +}; + +//============================================================================= +// Game_Map +//============================================================================= + +Yanfly.isPreventScreenJittering = function() { + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.5.0') return true; + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.4') return false; + return true; +}; + +if (Yanfly.isPreventScreenJittering()) { + +Game_Map.prototype.displayX = function() { + return parseFloat(Math.floor(this._displayX * + this.tileWidth())) / this.tileWidth(); +}; + +Game_Map.prototype.displayY = function() { + return parseFloat(Math.floor(this._displayY * + this.tileHeight())) / this.tileHeight(); +}; + +}; // Yanfly.isPreventScreenJittering + +Game_Map.prototype.adjustX = function(x) { + if (this.isLoopHorizontal() && x < this.displayX() - + (this.width() - this.screenTileX()) / 2) { + return x - this.displayX() + $dataMap.width; + } else { + return x - this.displayX(); + } +}; + +Game_Map.prototype.adjustY = function(y) { + if (this.isLoopVertical() && y < this.displayY() - + (this.height() - this.screenTileY()) / 2) { + return y - this.displayY() + $dataMap.height; + } else { + return y - this.displayY(); + } +}; + +Game_Map.prototype.updateEvents = function() { + var group = this.events(); + var length = group.length; + for (var i = 0; i < length; ++i) { + var ev = group[i]; + if (ev) ev.update(); + } + var group = this._commonEvents; + var length = group.length; + for (var i = 0; i < length; ++i) { + var ev = group[i]; + if (ev) ev.update(); + } +}; + +Game_Map.prototype.updateVehicles = function() { + var group = this._vehicles; + var length = group.length; + for (var i = 0; i < length; ++i) { + var vehicle = group[i]; + if (vehicle) vehicle.update(); + } +}; + +//============================================================================= +// Game_Character +//============================================================================= + +Game_Character.prototype.queueMoveRoute = function(moveRoute) { + this._originalMoveRoute = moveRoute; + this._originalMoveRouteIndex = 0; +}; + +Yanfly.Core.Game_Event_setMoveRoute = + Game_Event.prototype.setMoveRoute; +Game_Character.prototype.setMoveRoute = function(moveRoute) { + if (!this._moveRouteForcing) { + Yanfly.Core.Game_Event_setMoveRoute.call(this, moveRoute); + } else { + this.queueMoveRoute(moveRoute); + } +}; + +Yanfly.Core.Game_Character_processMoveCommand = + Game_Character.prototype.processMoveCommand; +Game_Character.prototype.processMoveCommand = function(command) { + var gc = Game_Character; + var params = command.parameters; + switch (command.code) { + case gc.ROUTE_SCRIPT: + try { + eval(params[0]); + } catch (e) { + Yanfly.Util.displayError(e, params[0], 'MOVE ROUTE SCRIPT ERROR'); + } + return; + break; + } + return Yanfly.Core.Game_Character_processMoveCommand.call(this, command); +}; + +//============================================================================= +// Game_Event +//============================================================================= + +Game_Event.prototype.isCollidedWithEvents = function(x, y) { + var events = $gameMap.eventsXyNt(x, y).filter(function(ev) { + return ev.isNormalPriority(); + }); + if (events.length <= 0) return false; + return this.isNormalPriority(); +}; + +//============================================================================= +// Game_Screen +//============================================================================= + +Game_Screen.prototype.updatePictures = function() { + var group = this._pictures; + var length = group.length; + for (var i = 0; i < length; ++i) { + var picture = group[i]; + if (picture) picture.update(); + } +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.Core.Game_Action_testItemEffect = Game_Action.prototype.testItemEffect; +Game_Action.prototype.testItemEffect = function(target, effect) { + switch (effect.code) { + case Game_Action.EFFECT_LEARN_SKILL: + return target.isActor() && !target._skills.contains(effect.dataId); + default: + return Yanfly.Core.Game_Action_testItemEffect.call(this, target, effect); + } +}; + +Game_Action.prototype.evalDamageFormula = function(target) { + var item = this.item(); + var a = this.subject(); + var b = target; + var v = $gameVariables._data; + var sign = ([3, 4].contains(item.damage.type) ? -1 : 1); + try { + var value = Math.max(eval(item.damage.formula), 0) * sign; + if (isNaN(value)) value = 0; + return value; + } catch (e) { + Yanfly.Util.displayError(e, item.damage.formula, 'DAMAGE FORMULA ERROR'); + return 0; + } +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +// Conditional Branch +Yanfly.Core.Game_Interpreter_command111 = + Game_Interpreter.prototype.command111; +Game_Interpreter.prototype.command111 = function() { + var result = false; + switch (this._params[0]) { + case 0: // Switch + if (this._params[2] === 0) { + result = $gameSwitches.value(this._params[1]); + } else { + result = !$gameSwitches.value(this._params[1]); + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) this.skipBranch(); + return true + break; + case 2: // Self Switch + if (this._eventId > 0) { + var key = [this._mapId, this._eventId, this._params[1]]; + if (this._params[2] === 0) { + result = $gameSelfSwitches.value(key); + } else { + result = !$gameSelfSwitches.value(key); + } + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) this.skipBranch(); + return true + break; + case 12: // Script + var code = this._params[1]; + try { + result = !!eval(code); + } catch (e) { + result = false; + Yanfly.Util.displayError(e, code, 'CONDITIONAL BRANCH SCRIPT ERROR'); + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) this.skipBranch(); + return true + break; + } + return Yanfly.Core.Game_Interpreter_command111.call(this); +}; + +// Control Variables +Yanfly.Core.Game_Interpreter_command122 = + Game_Interpreter.prototype.command122; +Game_Interpreter.prototype.command122 = function() { + switch (this._params[3]) { + case 4: // Script + var value = 0; + var code = this._params[4]; + try { + value = eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CONTROL VARIABLE SCRIPT ERROR'); + } + for (var i = this._params[0]; i <= this._params[1]; i++) { + this.operateVariable(i, this._params[2], value); + } + return true; + break; + } + return Yanfly.Core.Game_Interpreter_command122.call(this); +}; + +// Script +Game_Interpreter.prototype.command355 = function() { + var script = this.currentCommand().parameters[0] + '\n'; + while (this.nextEventCode() === 655) { + this._index++; + script += this.currentCommand().parameters[0] + '\n'; + } + try { + eval(script); + } catch (e) { + Yanfly.Util.displayError(e, script, 'SCRIPT CALL ERROR'); + } + return true; +}; + +Yanfly.Core.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.Core.Game_Interpreter_pluginCommand.call(this, command, args); + if (command === 'GainGold') { + $gameParty.gainGold(parseInt(args[0])); + } + if (command === 'LoseGold') { + $gameParty.loseGold(parseInt(args[0])); + } +}; + +//============================================================================= +// Scene_Base +//============================================================================= + +Scene_Base.prototype.clearChildren = function() { + while (this.children.length > 0) { + this.removeChild(this.children[0]); + } +}; + +if (Yanfly.Param.CollectionClear) { + +Yanfly.Core.Scene_Base_terminate = Scene_Base.prototype.terminate; +Scene_Base.prototype.terminate = function() { + Yanfly.Core.Scene_Base_terminate.call(this); + if (this._bypassFirstClear) return; + this.clearChildren(); +}; + +Yanfly.Core.Scene_Title_terminate = Scene_Title.prototype.terminate; +Scene_Title.prototype.terminate = function() { + this._bypassFirstClear = true; + Yanfly.Core.Scene_Title_terminate.call(this); + this.clearChildren(); +}; + +Yanfly.Core.Scene_Map_terminate = Scene_Map.prototype.terminate; +Scene_Map.prototype.terminate = function() { + this._bypassFirstClear = true; + Yanfly.Core.Scene_Map_terminate.call(this); + this.clearChildren(); +}; + +Yanfly.Core.Scene_Battle_terminate = Scene_Battle.prototype.terminate; +Scene_Battle.prototype.terminate = function() { + this._bypassFirstClear = true; + Yanfly.Core.Scene_Battle_terminate.call(this); + this.clearChildren(); +}; + +Yanfly.Core.Scene_Options_terminate = Scene_Options.prototype.terminate; +Scene_Options.prototype.terminate = function() { + this._bypassFirstClear = true; + Yanfly.Core.Scene_Options_terminate.call(this); + this.clearChildren(); +}; + +Yanfly.Core.Scene_Load_terminate = Scene_Load.prototype.terminate; +Scene_Load.prototype.terminate = function() { + this._bypassFirstClear = true; + Yanfly.Core.Scene_Load_terminate.call(this); + this.clearChildren(); +}; + +Yanfly.Core.Scene_Gameover_terminate = Scene_Gameover.prototype.terminate; +Scene_Gameover.prototype.terminate = function() { + this._bypassFirstClear = true; + Yanfly.Core.Scene_Gameover_terminate.call(this); + this.clearChildren(); +}; + +}; // Yanfly.Param.CollectionClear + +//============================================================================= +// Scene_Boot +//============================================================================= + +Scene_Boot.prototype.isGameFontLoaded = function() { + if (Graphics.isFontLoaded('GameFont')) { + return true; + } else if (Yanfly.Param.GameFontTimer <= 0) { + return false; + } else { + var elapsed = Date.now() - this._startDate; + if (elapsed >= Yanfly.Param.GameFontTimer) { + throw new Error('Failed to load GameFont'); + } else { + return false; + } + } +}; + +//============================================================================= +// Scene_Item +//============================================================================= + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") { + +Scene_Item.prototype.update = function() { + Scene_ItemBase.prototype.update.call(this); +}; + +}; // Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0" + +//============================================================================= +// Scene_Title +//============================================================================= + +Yanfly.Core.Scene_Title_start = Scene_Title.prototype.start; +Scene_Title.prototype.start = function() { + Yanfly.Core.Scene_Title_start.call(this); + if (Yanfly.Param.ScaleTitle) this.rescaleTitle(); +}; + +Scene_Title.prototype.rescaleTitle = function() { + this.rescaleTitleSprite(this._backSprite1); + this.rescaleTitleSprite(this._backSprite2); +}; + +Scene_Title.prototype.rescaleTitleSprite = function(sprite) { + if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) { + return setTimeout(this.rescaleTitleSprite.bind(this, sprite), 5); + } + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + var ratioX = width / sprite.bitmap.width; + var ratioY = height / sprite.bitmap.height; + if (ratioX > 1.0) sprite.scale.x = ratioX; + if (ratioY > 1.0) sprite.scale.y = ratioY; + this.centerSprite(sprite); +}; + +//============================================================================= +// Scene_Map +//============================================================================= + +if (Yanfly.Param.ShowEvTrans) { + +Scene_Map.prototype.startEncounterEffect = function() { + this._encounterEffectDuration = this.encounterEffectSpeed(); +}; + +}; // Yanfly.Param.ShowEvTrans + +Yanfly.Core.Scene_Map_snapForBattleBackground = + Scene_Map.prototype.snapForBattleBackground; +Scene_Map.prototype.snapForBattleBackground = function() { + if (!Yanfly.Param.ShowEvSnap) this._spriteset.hideCharacters(); + Yanfly.Core.Scene_Map_snapForBattleBackground.call(this); + if (Yanfly.Param.ShowEvTrans) this._spriteset.showCharacters(); +}; + +//============================================================================= +// Scene_Gameover +//============================================================================= + +Yanfly.Core.Scene_Gameover_start = Scene_Gameover.prototype.start; +Scene_Gameover.prototype.start = function() { + Yanfly.Core.Scene_Gameover_start.call(this); + if (Yanfly.Param.ScaleGameOver) this.rescaleBackground(); +}; + +Scene_Gameover.prototype.rescaleBackground = function() { + this.rescaleImageSprite(this._backSprite); +}; + +Scene_Gameover.prototype.rescaleImageSprite = function(sprite) { + if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) { + return setTimeout(this.rescaleImageSprite.bind(this, sprite), 5); + } + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + var ratioX = width / sprite.bitmap.width; + var ratioY = height / sprite.bitmap.height; + if (ratioX > 1.0) sprite.scale.x = ratioX; + if (ratioY > 1.0) sprite.scale.y = ratioY; + this.centerSprite(sprite); +}; + +Scene_Gameover.prototype.centerSprite = function(sprite) { + sprite.x = Graphics.width / 2; + sprite.y = Graphics.height / 2; + sprite.anchor.x = 0.5; + sprite.anchor.y = 0.5; +}; + +//============================================================================= +// Sprite_Animation +//============================================================================= + +Sprite_Animation.prototype.setupRate = function() { + this._rate = Yanfly.Param.AnimationRate; +}; + +//============================================================================= +// Sprite_Battler +//============================================================================= + +if (!Yanfly.Param.FlashTarget) { + +Yanfly.Core.Sprite_Battler_updateSelectionEffect = + Sprite_Battler.prototype.updateSelectionEffect; +Sprite_Battler.prototype.updateSelectionEffect = function() { + if (this._battler.isActor()) { + Yanfly.Core.Sprite_Battler_updateSelectionEffect.call(this); + } else { + if (this._battler.isSelected()) this.startEffect('whiten'); + } +}; + +}; // Yanfly.Param.FlashTarget + +//============================================================================= +// Sprite_Actor +//============================================================================= + +if (Yanfly.Param.ReposBattlers) { + Yanfly.Core.Sprite_Actor_setActorHome = Sprite_Actor.prototype.setActorHome; + Sprite_Actor.prototype.setActorHome = function(index) { + Yanfly.Core.Sprite_Actor_setActorHome.call(this, index); + this._homeX += Graphics.boxWidth - 816; + this._homeY += Graphics.boxHeight - 624; + }; +}; + +Sprite_Actor.prototype.retreat = function() { + this.startMove(1200, 0, 120); +}; + +//============================================================================= +// Sprite_Enemy +//============================================================================= + +if (Yanfly.Param.ReposBattlers) { + +Yanfly.Core.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler; +Sprite_Enemy.prototype.setBattler = function(battler) { + Yanfly.Core.Sprite_Enemy_setBattler.call(this, battler); + if (!this._enemy._alteredScreenY) { + this._homeY += Math.floor((Graphics.boxHeight - 624) / 2); + this._enemy._screenY = this._homeY; + this._enemy._alteredScreenY = true; + } + if ($gameSystem.isSideView()) return; + if (!this._enemy._alteredScreenX) { + this._homeX += (Graphics.boxWidth - 816) / 2; + this._enemy._screenX = this._homeX; + this._enemy._alteredScreenX = true; + } +}; + +}; // Yanfly.Param.ReposBattlers + +//============================================================================= +// Sprite_StateIcon +//============================================================================= + +Sprite_StateIcon._iconWidth = Yanfly.Param.IconWidth; +Sprite_StateIcon._iconHeight = Yanfly.Param.IconHeight; + +//============================================================================= +// Sprite_Button +//============================================================================= + +Sprite_Button.prototype.isButtonTouched = function() { + var x = this.canvasToLocalX(TouchInput.x) + (this.anchor.x * this.width); + var y = this.canvasToLocalY(TouchInput.y) + (this.anchor.y * this.height); + return x >= 0 && y >= 0 && x < this.width && y < this.height; +}; + +//============================================================================= +// Sprite_Battleback +//============================================================================= + +function Sprite_Battleback() { + this.initialize.apply(this, arguments); +} + +Sprite_Battleback.prototype = Object.create(Sprite.prototype); +Sprite_Battleback.prototype.constructor = Sprite_Battleback; + +Sprite_Battleback.prototype.initialize = function(bitmapName, type) { + Sprite.prototype.initialize.call(this); + this._bitmapName = bitmapName; + this._battlebackType = type; + this.createBitmap(); +}; + +Sprite_Battleback.prototype.createBitmap = function() { + if (this._bitmapName === '') { + this.bitmap = new Bitmap(Graphics.boxWidth, Graphics.boxHeight); + } else { + if (this._battlebackType === 1) { + this.bitmap = ImageManager.loadBattleback1(this._bitmapName); + } else { + this.bitmap = ImageManager.loadBattleback2(this._bitmapName); + } + this.scaleSprite(); + } +}; + +Sprite_Battleback.prototype.scaleSprite = function() { + if (this.bitmap.width <= 0) return setTimeout(this.scaleSprite.bind(this), 5); + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + if (this.bitmap.width < width) { + this.scale.x = width / this.bitmap.width; + } + if (this.bitmap.height < height) { + this.scale.y = height / this.bitmap.height; + } + this.anchor.x = 0.5; + this.x = Graphics.boxWidth / 2; + if ($gameSystem.isSideView()) { + this.anchor.y = 1; + this.y = Graphics.boxHeight; + } else { + this.anchor.y = 0.5; + this.y = Graphics.boxHeight / 2; + } +}; + +//============================================================================= +// Sprite_Character +//============================================================================= + +Yanfly.Core.Sprite_Character_updateHalfBodySprites = + Sprite_Character.prototype.updateHalfBodySprites; +Sprite_Character.prototype.updateHalfBodySprites = function() { + Yanfly.Core.Sprite_Character_updateHalfBodySprites.call(this); + if (this._bushDepth > 0) { + this._upperBody.blendMode = this.blendMode; + this._lowerBody.blendMode = this.blendMode; + } +}; + +//============================================================================= +// Spriteset_Map +//============================================================================= + +Spriteset_Map.prototype.hideCharacters = function() { + for (var i = 0; i < this._characterSprites.length; i++) { + var sprite = this._characterSprites[i]; + if (!sprite.isTile()) sprite.hide(); + } +}; + +Spriteset_Map.prototype.showCharacters = function() { + for (var i = 0; i < this._characterSprites.length; i++) { + var sprite = this._characterSprites[i]; + if (!sprite.isTile()) sprite.show(); + } +}; + +//============================================================================= +// Spriteset_Battle +//============================================================================= + +if (Yanfly.Param.ScaleBattleback) { + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.2') { + +// Rewriting the battlebacks +Spriteset_Battle.prototype.createBattleback = function() { + this._back1Sprite = new Sprite_Battleback(this.battleback1Name(), 1); + this._back2Sprite = new Sprite_Battleback(this.battleback2Name(), 2); + this._battleField.addChild(this._back1Sprite); + this._battleField.addChild(this._back2Sprite); +}; + +// No more updateBattleback +Spriteset_Battle.prototype.updateBattleback = function() { +}; + +} else { // Version 1.3.0 and below + +Yanfly.Core.Spriteset_Battle_locateBattleback = + Spriteset_Battle.prototype.locateBattleback; +Spriteset_Battle.prototype.locateBattleback = function() { + var sprite1 = this._back1Sprite; + var sprite2 = this._back2Sprite; + if (sprite1.bitmap.width <= 0) return; + if (sprite2.bitmap.width <= 0) return; + if (this._rescaledBattlebackSprite) return; + this._rescaledBattlebackSprite = true; + Yanfly.Core.Spriteset_Battle_locateBattleback.call(this); + var height = this._battleField.height; + sprite1.origin.y = sprite1.x + sprite1.bitmap.height - height; + sprite2.origin.y = sprite1.y + sprite2.bitmap.height - height; + this.rescaleBattlebacks(); +}; + +Spriteset_Battle.prototype.rescaleBattlebacks = function() { + this.rescaleBattlebackSprite(this._back1Sprite); + this.rescaleBattlebackSprite(this._back2Sprite); +}; + +Spriteset_Battle.prototype.rescaleBattlebackSprite = function(sprite) { + if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) return; + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + var ratioX = width / sprite.bitmap.width; + var ratioY = height / sprite.bitmap.height; + if (ratioX > 1.0) { + sprite.scale.x = ratioX; + sprite.anchor.x = 0.5; + sprite.x = width / 2; + } + if (ratioY > 1.0) { + sprite.scale.y = ratioY; + sprite.origin.y = 0; + sprite.y = 0; + } +}; + +} // Version 1.3.0 and below + +} // Yanfly.Param.ScaleBattleback + +//============================================================================= +// Window_Base +//============================================================================= + +Window_Base._iconWidth = Yanfly.Param.IconWidth; +Window_Base._iconHeight = Yanfly.Param.IconHeight; +Window_Base._faceWidth = Yanfly.Param.FaceWidth; +Window_Base._faceHeight = Yanfly.Param.FaceHeight; + +Window_Base.prototype.lineHeight = function() { + return Yanfly.Param.LineHeight; +}; + +Window_Base.prototype.drawTextEx = function(text, x, y) { + if (text) { + this.resetFontSettings(); + var textState = { index: 0, x: x, y: y, left: x }; + textState.text = this.convertEscapeCharacters(text); + textState.height = this.calcTextHeight(textState, false); + while (textState.index < textState.text.length) { + this.processCharacter(textState); + } + return textState.x - x; + } else { + return 0; + } +}; + +Window_Base.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height + this.lineHeight()); +}; + +Window_Base.prototype.standardFontFace = function() { + if ($gameSystem.isChinese()) { + return Yanfly.Param.ChineseFont; + } else if ($gameSystem.isKorean()) { + return Yanfly.Param.KoreanFont; + } else { + return Yanfly.Param.DefaultFont; + } +}; + +Window_Base.prototype.standardFontSize = function() { + return Yanfly.Param.FontSize; +}; + +Window_Base.prototype.standardPadding = function() { + return Yanfly.Param.WindowPadding; +}; + +Window_Base.prototype.textPadding = function() { + return Yanfly.Param.TextPadding; +}; + +Window_Base.prototype.standardBackOpacity = function() { + return Yanfly.Param.WindowOpacity; +}; + +Window_Base.prototype.normalColor = function() { + return this.textColor(Yanfly.Param.ColorNormal); +}; +Window_Base.prototype.systemColor = function() { + return this.textColor(Yanfly.Param.ColorSystem); +}; + +Window_Base.prototype.crisisColor = function() { + return this.textColor(Yanfly.Param.ColorCrisis); +}; + +Window_Base.prototype.deathColor = function() { + return this.textColor(Yanfly.Param.ColorDeath); +}; + +Window_Base.prototype.gaugeBackColor = function() { + return this.textColor(Yanfly.Param.ColorGaugeBack); +}; + +Window_Base.prototype.hpGaugeColor1 = function() { + return this.textColor(Yanfly.Param.ColorHpGauge1); +}; + +Window_Base.prototype.hpGaugeColor2 = function() { + return this.textColor(Yanfly.Param.ColorHpGauge2); +}; + +Window_Base.prototype.mpGaugeColor1 = function() { + return this.textColor(Yanfly.Param.ColorMpGauge1); +}; + +Window_Base.prototype.mpGaugeColor2 = function() { + return this.textColor(Yanfly.Param.ColorMpGauge2); +}; + +Window_Base.prototype.mpCostColor = function() { + return this.textColor(Yanfly.Param.ColorMpCost); +}; + +Window_Base.prototype.powerUpColor = function() { + return this.textColor(Yanfly.Param.ColorPowerUp); +}; + +Window_Base.prototype.powerDownColor = function() { + return this.textColor(Yanfly.Param.ColorPowerDown); +}; + +Window_Base.prototype.tpGaugeColor1 = function() { + return this.textColor(Yanfly.Param.ColorTpGauge1); +}; + +Window_Base.prototype.tpGaugeColor2 = function() { + return this.textColor(Yanfly.Param.ColorTpGauge2); +}; + +Window_Base.prototype.tpCostColor = function() { + return this.textColor(Yanfly.Param.ColorTpCost); +}; + +Window_Base.prototype.drawGauge = function(dx, dy, dw, rate, color1, color2) { + var color3 = this.gaugeBackColor(); + var fillW = Math.floor(dw * rate).clamp(0, dw); + var gaugeH = this.gaugeHeight(); + var gaugeY = dy + this.lineHeight() - gaugeH - 2; + if (Yanfly.Param.GaugeOutline) { + color3.paintOpacity = this.translucentOpacity(); + this.contents.fillRect(dx, gaugeY - 1, dw, gaugeH, color3); + fillW = Math.max(fillW - 2, 0); + gaugeH -= 2; + dx += 1; + } else { + var fillW = Math.floor(dw * rate); + var gaugeY = dy + this.lineHeight() - gaugeH - 2; + this.contents.fillRect(dx, gaugeY, dw, gaugeH, color3); + } + this.contents.gradientFillRect(dx, gaugeY, fillW, gaugeH, color1, color2); +}; + +Window_Base.prototype.gaugeHeight = function() { + return Yanfly.Param.GaugeHeight; +}; + +Window_Base.prototype.drawActorLevel = function(actor, x, y) { + this.changeTextColor(this.systemColor()); + var dw1 = this.textWidth(TextManager.levelA); + this.drawText(TextManager.levelA, x, y, dw1); + this.resetTextColor(); + var level = Yanfly.Util.toGroup(actor.level); + var dw2 = this.textWidth(Yanfly.Util.toGroup(actor.maxLevel())); + this.drawText(level, x + dw1, y, dw2, 'right'); +}; + +Window_Base.prototype.drawCurrentAndMax = function(current, max, x, y, + width, color1, color2) { + var labelWidth = this.textWidth('HP'); + var valueWidth = this.textWidth(Yanfly.Util.toGroup(max)); + var slashWidth = this.textWidth('/'); + var x1 = x + width - valueWidth; + var x2 = x1 - slashWidth; + var x3 = x2 - valueWidth; + if (x3 >= x + labelWidth) { + this.changeTextColor(color1); + this.drawText(Yanfly.Util.toGroup(current), x3, y, valueWidth, + 'right'); + this.changeTextColor(color2); + this.drawText('/', x2, y, slashWidth, 'right'); + this.drawText(Yanfly.Util.toGroup(max), x1, y, valueWidth, 'right'); + } else { + this.changeTextColor(color1); + this.drawText(Yanfly.Util.toGroup(current), x1, y, valueWidth, + 'right'); + } +}; + +Window_Base.prototype.drawActorTp = function(actor, x, y, width) { + width = width || 96; + var color1 = this.tpGaugeColor1(); + var color2 = this.tpGaugeColor2(); + this.drawGauge(x, y, width, actor.tpRate(), color1, color2); + this.changeTextColor(this.systemColor()); + this.drawText(TextManager.tpA, x, y, 44); + this.changeTextColor(this.tpColor(actor)); + this.drawText(Yanfly.Util.toGroup(actor.tp), x + width - 64, y, 64, + 'right'); +}; + +Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) { + var lineHeight = this.lineHeight(); + var xpad = Window_Base._faceWidth + (2 * Yanfly.Param.TextPadding); + var x2 = x + xpad; + var width2 = Math.max(180, width - xpad - this.textPadding()); + this.drawActorName(actor, x, y); + this.drawActorLevel(actor, x, y + lineHeight * 1); + this.drawActorIcons(actor, x, y + lineHeight * 2); + this.drawActorClass(actor, x2, y, width2); + this.drawActorHp(actor, x2, y + lineHeight * 1, width2); + this.drawActorMp(actor, x2, y + lineHeight * 2, width2); + if (Yanfly.Param.MenuTpGauge) { + this.drawActorTp(actor, x2, y + lineHeight * 3, width2); + } +}; + +Window_Base.prototype.drawCurrencyValue = function(value, unit, wx, wy, ww) { + this.resetTextColor(); + this.contents.fontSize = Yanfly.Param.GoldFontSize; + if (this.usingGoldIcon(unit)) { + var cx = Window_Base._iconWidth; + } else { + var cx = this.textWidth(unit); + } + var text = Yanfly.Util.toGroup(value); + if (this.textWidth(text) > ww - cx) { + text = Yanfly.Param.GoldOverlap; + } + this.drawText(text, wx, wy, ww - cx - 4, 'right'); + if (this.usingGoldIcon(unit)) { + this.drawIcon(Yanfly.Icon.Gold, wx + ww - Window_Base._iconWidth, wy + 2); + } else { + this.changeTextColor(this.systemColor()); + this.drawText(unit, wx, wy, ww, 'right'); + } + this.resetFontSettings(); +}; + +Window_Base.prototype.usingGoldIcon = function(unit) { + if (unit !== TextManager.currencyUnit) return false; + return Yanfly.Icon.Gold > 0; +}; + +//============================================================================= +// Window_Command +//============================================================================= + +Window_Command.prototype.itemTextAlign = function() { + return Yanfly.Param.TextAlign; +}; + +//============================================================================= +// Window_MenuStatus +//============================================================================= + +Window_MenuStatus.prototype.drawItemImage = function(index) { + var actor = $gameParty.members()[index]; + var rect = this.itemRect(index); + this.changePaintOpacity(actor.isBattleMember()); + var fw = Window_Base._faceWidth; + this.drawActorFace(actor, rect.x + 1, rect.y + 1, fw, rect.height - 2); + this.changePaintOpacity(true); +}; + +Window_MenuStatus.prototype.drawItemStatus = function(index) { + var actor = $gameParty.members()[index]; + var rect = this.itemRect(index); + var xpad = Yanfly.Param.WindowPadding + Window_Base._faceWidth; + var x = rect.x + xpad; + if (!Yanfly.Param.MenuTpGauge) { + var y = Math.floor(rect.y + rect.height / 2 - this.lineHeight() * 1.5); + } else { + var y = Math.floor(rect.y); + } + var width = rect.width - x - this.textPadding(); + this.drawActorSimpleStatus(actor, x, y, width); +}; + +//============================================================================= +// Window_ItemList +//============================================================================= + +Window_ItemList.prototype.numberWidth = function() { + return this.textWidth('\u00d70,000'); +}; + +Window_ItemList.prototype.drawItemNumber = function(item, x, y, width) { + if (!this.needsNumber()) return; + var numItems = Yanfly.Util.toGroup($gameParty.numItems(item)); + this.contents.fontSize = Yanfly.Param.ItemQuantitySize; + this.drawText('\u00d7' + numItems, x, y, width, 'right'); + this.resetFontSettings(); +}; + +//============================================================================= +// Window_SkillStatus +//============================================================================= + +Window_SkillStatus.prototype.refresh = function() { + this.contents.clear(); + if (this._actor) { + var w = this.width - this.padding * 2; + var h = this.height - this.padding * 2; + if (!Yanfly.Param.MenuTpGauge) { + var y = h / 2 - this.lineHeight() * 1.5; + } else { + var y = 0; + } + var xpad = Yanfly.Param.WindowPadding + Window_Base._faceWidth; + var width = w - xpad - this.textPadding(); + this.drawActorFace(this._actor, 0, 0, Window_Base._faceWidth, h); + this.drawActorSimpleStatus(this._actor, xpad, y, width); + } +}; + +Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) { + if (this._actor.skillTpCost(skill) > 0) { + this.changeTextColor(this.tpCostColor()); + var skillcost = Yanfly.Util.toGroup(this._actor.skillTpCost(skill)); + this.drawText(skillcost, x, y, width, 'right'); + } else if (this._actor.skillMpCost(skill) > 0) { + this.changeTextColor(this.mpCostColor()); + var skillcost = Yanfly.Util.toGroup(this._actor.skillMpCost(skill)); + this.drawText(skillcost, x, y, width, 'right'); + } +}; + +//============================================================================= +// Window_EquipStatus +//============================================================================= + +Window_EquipStatus.prototype.drawCurrentParam = function(x, y, paramId) { + this.resetTextColor(); + var actorparam = Yanfly.Util.toGroup(this._actor.param(paramId)); + this.drawText(actorparam, x, y, 48, 'right'); +}; + +Window_EquipStatus.prototype.drawNewParam = function(x, y, paramId) { + var newValue = this._tempActor.param(paramId); + var diffvalue = newValue - this._actor.param(paramId); + var actorparam = Yanfly.Util.toGroup(newValue); + this.changeTextColor(this.paramchangeTextColor(diffvalue)); + this.drawText(actorparam, x, y, 48, 'right'); +}; + +//============================================================================= +// Window_SkillType +//============================================================================= + +Window_SkillType.prototype.makeCommandList = function() { + if (this._actor) { + var skillTypes = this._actor.addedSkillTypes(); + skillTypes.sort(function(a, b){return a-b}); + skillTypes.forEach(function(stypeId) { + var name = $dataSystem.skillTypes[stypeId]; + this.addCommand(name, 'skill', true, stypeId); + }, this); + } +}; + +//============================================================================= +// Window_ActorCommand +//============================================================================= + +Window_ActorCommand.prototype.addSkillCommands = function() { + var skillTypes = this._actor.addedSkillTypes(); + skillTypes.sort(function(a, b){return a-b}); + skillTypes.forEach(function(stypeId) { + var name = $dataSystem.skillTypes[stypeId]; + this.addCommand(name, 'skill', true, stypeId); + }, this); +}; + +//============================================================================= +// Window_Status +//============================================================================= + +Window_Status.prototype.drawParameters = function(x, y) { + var lineHeight = this.lineHeight(); + for (var i = 0; i < 6; i++) { + var paramId = i + 2; + var y2 = y + lineHeight * i; + this.changeTextColor(this.systemColor()); + this.drawText(TextManager.param(paramId), x, y2, 160); + this.resetTextColor(); + var actorParam = Yanfly.Util.toGroup(this._actor.param(paramId)); + var dw = this.textWidth(Yanfly.Util.toGroup(this._actor.paramMax(i + 2))); + this.drawText(actorParam, x + 160, y2, dw, 'right'); + } +}; + +Window_Status.prototype.drawExpInfo = function(x, y) { + var lineHeight = this.lineHeight(); + var expTotal = TextManager.expTotal.format(TextManager.exp); + var expNext = TextManager.expNext.format(TextManager.level); + var value1 = this._actor.currentExp(); + var value2 = this._actor.nextRequiredExp(); + if (this._actor.isMaxLevel()) { + value1 = '-------'; + value2 = '-------'; + } else { + value1 = Yanfly.Util.toGroup(value1); + value2 = Yanfly.Util.toGroup(value2); + } + this.changeTextColor(this.systemColor()); + this.drawText(expTotal, x, y + lineHeight * 0, 270); + this.drawText(expNext, x, y + lineHeight * 2, 270); + this.resetTextColor(); + this.drawText(value1, x, y + lineHeight * 1, 270, 'right'); + this.drawText(value2, x, y + lineHeight * 3, 270, 'right'); +}; + +//============================================================================= +// Window_ShopBuy +//============================================================================= + +Window_ShopBuy.prototype.drawItem = function(index) { + var item = this._data[index]; + var rect = this.itemRect(index); + rect.width -= this.textPadding(); + this.changePaintOpacity(this.isEnabled(item)); + this.drawItemName(item, rect.x, rect.y, rect.width); + this.contents.fontSize = Yanfly.Param.GoldFontSize; + var itemPrice = Yanfly.Util.toGroup(this.price(item)); + this.drawText(itemPrice, rect.x, rect.y, rect.width, 'right'); + this.changePaintOpacity(true); + this.resetFontSettings(); +}; + +//============================================================================= +// Window_ShopNumber +//============================================================================= + +Window_ShopNumber.prototype.drawNumber = function() { + var x = this.cursorX(); + var y = this.itemY(); + var width = this.cursorWidth() - this.textPadding(); + this.resetTextColor(); + var itemNumber = Yanfly.Util.toGroup(this._number); + this.drawText(itemNumber, x, y, width, 'right'); +}; + +//============================================================================= +// Window_NameEdit +//============================================================================= + +Window_NameEdit.prototype.faceWidth = function() { + return Window_Base._faceWidth; +}; + +//============================================================================= +// Window_BattleStatus +//============================================================================= + +Window_BattleStatus.prototype.gaugeAreaWidth = function() { + return this.width / 2 + this.standardPadding(); +}; + +Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) { + var minIconArea = Window_Base._iconWidth * 2; + var nameLength = this.textWidth('0') * 16 + 6; + var iconWidth = Math.max(rect.width - nameLength, minIconArea); + var nameWidth = rect.width - iconWidth; + this.drawActorName(actor, rect.x + 0, rect.y, nameWidth); + this.drawActorIcons(actor, rect.x + nameWidth, rect.y, iconWidth); +}; + +Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) { + var totalArea = this.gaugeAreaWidth() - 30; + var hpW = Math.floor(parseInt(totalArea * 108 / 300)); + var otW = Math.floor(parseInt(totalArea * 96 / 300)); + this.drawActorHp(actor, rect.x + 0, rect.y, hpW); + this.drawActorMp(actor, rect.x + hpW + 15, rect.y, otW); + this.drawActorTp(actor, rect.x + hpW + otW + 30, rect.y, otW); +}; + +Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) { + var totalArea = this.gaugeAreaWidth() - 15; + var hpW = Math.floor(parseInt(totalArea * 201 / 315)); + var otW = Math.floor(parseInt(totalArea * 114 / 315)); + this.drawActorHp(actor, rect.x + 0, rect.y, hpW); + this.drawActorMp(actor, rect.x + hpW + 15, rect.y, otW); +}; + +//============================================================================= +// Window_BattleLog +//============================================================================= + +Window_BattleLog.prototype.showNormalAnimation = function(targets, +animationId, mirror) { + var animation = $dataAnimations[animationId]; + if (animation) { + if (animation.position === 3) { + targets.forEach(function(target) { + target.startAnimation(animationId, mirror, 0); + }); + } else { + var delay = this.animationBaseDelay(); + var nextDelay = this.animationNextDelay(); + targets.forEach(function(target) { + target.startAnimation(animationId, mirror, delay); + delay += nextDelay; + }); + } + } +}; + +//============================================================================= +// New Function +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.5.0') { + +Yanfly.Util.toGroup = function(inVal) { + if (typeof inVal === 'string') return inVal; + if (!Yanfly.Param.DigitGroup) return inVal; + return inVal.toLocaleString('en'); + return inVal.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) { + return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,"); + }); +}; + +} else { + +Yanfly.Util.toGroup = function(inVal) { + if (typeof inVal !== 'string') { inVal = String(inVal); } + if (!Yanfly.Param.DigitGroup) return inVal; + return inVal.toLocaleString('en'); + return inVal.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) { + return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,"); + }); +}; + +} // Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.5.0' + + + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_ElementCore.js b/js/plugins/YEP_ElementCore.js new file mode 100644 index 0000000..9410c9c --- /dev/null +++ b/js/plugins/YEP_ElementCore.js @@ -0,0 +1,817 @@ +//============================================================================= +// Yanfly Engine Plugins - Element Core +// YEP_ElementCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_ElementCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.Ele = Yanfly.Ele || {}; +Yanfly.Ele.version = 1.03; + +//============================================================================= + /*: + * @plugindesc v1.02 Manage the way elements work in this game from + * absorbing elements, reflecting elements, and more! + * @author Yanfly Engine Plugins + * + * @param Multi-Element Rulings + * @type select + * @option Lowest + * @value 0 + * @option Add + * @value 1 + * @option Multiply + * @value 2 + * @option Highest + * @value 3 + * @option Average + * @value 4 + * @desc If a skill/item has multiple elements, then use these rules: + * 0 - Lowest; 1 - Add; 2 - Multiply; 3 - Highest; 4 - Average + * @default 2 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * Elemental control in RPG Maker MV is pretty lacking. The calculation of how + * multiple elements are handled aren't very clear nor are they too intuitive + * when it comes to certain aspects. This plugin also gives way to skills and + * items having more than one element, battlers being able to absorb, reflect, + * amplify elemental damage, and more! + * + * * Note: If you are using the Battle Engine Core, place this plugin under the + * Battle Engine Core in the plugin list for additional features. + * + * * Note: If you are using the Damage Core, place this plugin underneath the + * Damage Core plugin in the list for maximum compatibility. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * Use these notetags if you wish to modify various aspects of elements for + * your database objects. + * + * Skill and Item Notetags + * + * + * - Allows this skill/item to ignore elemental reflect properties. This will + * not bypass reflect properties as a whole, however. + * + * + * + * + * + * - This adds elements x (or name) to the skill/item in addition to the + * skill/item's current element. Skills and items with multiple elements will + * follow the Multi-Element Rule when calculating damage rate. Insert more of + * this notetag to insert more elements. + * + * + * + * + * + * + * - This allows you to set the rule for this skill/item if it has multiple + * elements. Either the lowest rate, the additive sum of all rates, the + * multiplicative product of all rates, or the highest rate will be used. If + * average is used, it will be the average of all element rates. + * + * Actor, Class, Enemy, Weapon, Armor, and State Notetags: + * + * + * + * + * + * - Causes element x to be absorbed and heals the battler. When an element + * is absorbed, the rate goes down by 200% instead of being just an inverse. + * This is so that battlers that are originally resistant to the element will + * absorb more of the element while battlers that are originally vulnerable + * to the element will absorb less of the element. The minimum amount + * absorbed is 0.01%. + * + * + * + * + * + * - Increases or decreases the rate to reflect element x by y%. If a skill + * or item has multiple elements, the reflect rate is added for each element + * used by the skill/item. + * + * + * + * + * + * - If the user performs a skill or item that utilizes element x (or name), + * increase or decrease its damage by y%. If a skill or item has multiple + * elements, the rate is increased additively for each element and adjusted + * multiplicatively with base rate. This bottoms out at 0%. + * + * + * + * + * + * - If the user performs a skill or item that utilizes element x (or name), + * increase or decrease its damage by y%. If a skill or item has multiple + * elements, the rate is increased additively for each element and adjusted + * additively for base rate. + * + * + * - This will cause the battler to not have elemental attacks when using + * skills and items. However, this will not bypass the 'Force Element' action + * sequence effect. + * + * + * + * - This forces the battler's elemental rate for x (or named) to be y%. This + * will work in a priority setting of states (highest priority to lowest), + * equips (first to last), then class, then actor/enemy if more than one + * notetag is used for the same element. If y is negative, the element is + * absorbed. + * + * ============================================================================ + * Yanfly Engine Plugins - Battle Engine Extension - Action Sequence Commands + * ============================================================================ + * + * If you have YEP_BattleEngineCore.js installed with this plugin located + * underneath it in the Plugin Manager, you can make use of these extra + * damage related action sequences. + * + *============================================================================= + * ADD ELEMENT: X + * ADD ELEMENT: X, X, X + * ADD ELEMENT: NAME + * ADD ELEMENT: NAME, NAME, NAME + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will add more elements to the currently existing elements. This will + * not include forced elements. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: add element: 4 + * add element: 5, 6, 7 + * add element: fire + * add element: ice, wind, water + *============================================================================= + * + *============================================================================= + * CLEAR ELEMENT + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will clear any ___ Element action sequence settings and revert element + * calculation back to normal. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: clear element + *============================================================================= + * + *============================================================================= + * FORCE ELEMENT: X + * FORCE ELEMENT: X, X, X + * FORCE ELEMENT: NAME + * FORCE ELEMENT: NAME, NAME, NAME + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will override elemental settings for elemental damage rate calculations + * except for customized calculations that aim at specific elements. This will + * ignore all other elements. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: force element: 4 + * force element: 5, 6, 7 + * force element: fire + * force element: ice, wind, water + *============================================================================= + * + *============================================================================= + * NULL ELEMENT + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will force the elements to null. Calculated elemental damage will + * always return neutral rate. Using this will clear the Force Element action + * sequence effect. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: null element + *============================================================================= + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.03: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.02: + * - Added , notetags. These + * notetags different from the Amplify counterparts in a way where the Amplify + * notetags will shift the element rate additively. These will alter the rate + * multiplicatively. + * + * Version 1.01: + * - Optimized element rate calculation where if no elements are present, then + * damage rate will default to 100%. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_ElementCore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.EleMultiRule = Number(Yanfly.Parameters['Multi-Element Rulings']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.Ele.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.Ele.DataManager_isDatabaseLoaded.call(this)) return false; + + if (!Yanfly._loaded_YEP_ElementCore) { + this.processElementNotetagsSys($dataSystem); + this.processElementNotetags1($dataSkills); + this.processElementNotetags1($dataItems); + this.processElementNotetags2($dataActors); + this.processElementNotetags2($dataClasses); + this.processElementNotetags2($dataEnemies); + this.processElementNotetags2($dataWeapons); + this.processElementNotetags2($dataArmors); + this.processElementNotetags2($dataStates); + Yanfly._loaded_YEP_ElementCore = true; + } + + return true; +}; + +DataManager.processElementNotetagsSys = function(group) { + Yanfly.ElementIdRef = {}; + for (var i = 1; i < group.elements.length; ++i) { + var name = group.elements[i].toUpperCase(); + name = name.replace(/\\I\[(\d+)\]/gi, ''); + Yanfly.ElementIdRef[name] = i; + } +}; + +DataManager.processElementNotetags1 = function(group) { + var noteA1 = //i; + var noteA2 = //i; + var noteA3 = //i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.elementMultiRule = Yanfly.Param.EleMultiRule; + obj.multipleElements = []; + obj.bypassElementReflect = false; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(//i)) { + obj.elementMultiRule = 0; + } else if (line.match(//i)) { + obj.elementMultiRule = 1; + } else if (line.match(//i)) { + obj.elementMultiRule = 2; + } else if (line.match(//i)) { + obj.elementMultiRule = 3; + } else if (line.match(//i)) { + obj.elementMultiRule = 4; + } else if (line.match(//i)) { + obj.elementMultiRule = String(RegExp.$1); + } else if (line.match(noteA1)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + obj.multipleElements = obj.multipleElements.concat(array); + } else if (line.match(noteA2)) { + var range = Yanfly.Util.getRange(parseInt(RegExp.$1), + parseInt(RegExp.$2)); + obj.multipleElements = obj.multipleElements.concat(range); + } else if (line.match(noteA3)) { + var text = String(RegExp.$1); + var array = text.split(','); + var length = array.length; + for (var j = 0; j < length; ++j) { + var name = array[j].toUpperCase().trim(); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.multipleElements.push(id); + } + } + } else if (line.match(/<(?:BYPASS ELEMENT REFLECT)>/i)) { + obj.bypassElementReflect = true; + } + } + } +}; + +DataManager.processElementNotetags2 = function(group) { + var noteA1 = /<(?:ELEMENT ABSORB):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i; + var noteB1 = /<(?:ELEMENT REFLECT)[ ](\d+):[ ]([\+\-]\d+)([%%])>/i; + var noteB2 = /<(?:ELEMENT REFLECT)[ ](.*):[ ]([\+\-]\d+)([%%])>/i; + var noteC1 = /<(?:ELEMENT AMPLIFY)[ ](\d+):[ ]([\+\-]\d+)([%%])>/i; + var noteC2 = /<(?:ELEMENT AMPLIFY)[ ](.*):[ ]([\+\-]\d+)([%%])>/i; + var noteC3 = /<(?:ELEMENT MAGNIFY)[ ](\d+):[ ]([\+\-]\d+)([%%])>/i; + var noteC4 = /<(?:ELEMENT MAGNIFY)[ ](.*):[ ]([\+\-]\d+)([%%])>/i; + var noteD1 = //i; + var noteD2 = //i; + var noteD3 = //i; + var noteD4 = //i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.elementAbsorb = []; + obj.elementReflect = {}; + obj.elementAmplify = {}; + obj.elementMagnify = {}; + obj.elementNull = false; + obj.elementForcedRate = {}; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + obj.elementAbsorb = obj.elementAbsorb.concat(array); + } else if (line.match(noteA1)) { + var range = Yanfly.Util.getRange(parseInt(RegExp.$1), + parseInt(RegExp.$2)); + obj.elementAbsorb = obj.elementAbsorb.concat(range); + } else if (line.match(/<(?:ELEMENT ABSORB):[ ](.*)>/i)) { + var text = String(RegExp.$1); + var array = text.split(','); + var length = array.length; + for (var j = 0; j < length; ++j) { + var name = array[j].toUpperCase().trim(); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.elementAbsorb.push(id); + } + } + } else if (line.match(noteB1)) { + var elementId = parseInt(RegExp.$1); + var rate = parseFloat(RegExp.$2 * 0.01); + obj.elementReflect[elementId] = rate; + } else if (line.match(noteB2)) { + var name = String(RegExp.$1).toUpperCase().trim(); + var rate = parseFloat(RegExp.$2 * 0.01); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.elementReflect[id] = rate; + } + } else if (line.match(noteC1)) { + var elementId = parseInt(RegExp.$1); + var rate = parseFloat(RegExp.$2 * 0.01); + obj.elementAmplify[elementId] = rate; + } else if (line.match(noteC2)) { + var name = String(RegExp.$1).toUpperCase().trim(); + var rate = parseFloat(RegExp.$2 * 0.01); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.elementAmplify[id] = rate; + } + } else if (line.match(noteC3)) { + var elementId = parseInt(RegExp.$1); + var rate = parseFloat(RegExp.$2 * 0.01); + obj.elementMagnify[elementId] = rate; + } else if (line.match(noteC4)) { + var name = String(RegExp.$1).toUpperCase().trim(); + var rate = parseFloat(RegExp.$2 * 0.01); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.elementMagnify[id] = rate; + } + } else if (line.match(/<(?:ELEMENT NULL)>/i)) { + obj.elementNull = true; + } else if (line.match(noteD1)) { + var elementId = parseInt(RegExp.$1); + var rate = parseFloat(RegExp.$2 * 0.01); + obj.elementForcedRate[elementId] = rate; + } else if (line.match(noteD2)) { + var elementId = parseInt(RegExp.$1); + var rate = parseFloat(RegExp.$2 * 0.01); + obj.elementForcedRate[elementId] = rate * -1; + } else if (line.match(noteD3)) { + var name = String(RegExp.$1).toUpperCase().trim(); + var rate = parseFloat(RegExp.$2 * 0.01); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.elementForcedRate[id] = rate; + } + } else if (line.match(noteD4)) { + var name = String(RegExp.$1).toUpperCase().trim(); + var rate = parseFloat(RegExp.$2 * 0.01); + if (Yanfly.ElementIdRef[name]) { + var id = Yanfly.ElementIdRef[name]; + obj.elementForcedRate[id] = rate * -1; + } + } + } + } +}; + +//============================================================================= +// BattleManager +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +Yanfly.Ele.BattleManager_processActionSequence = + BattleManager.processActionSequence; +BattleManager.processActionSequence = function(actionName, actionArgs) { + // ADD ELEMENT: X + if (actionName === 'ADD ELEMENT') { + return this.actionAddElement(actionArgs); + } + // CLEAR ELEMENT + if (actionName === 'CLEAR ELEMENT') { + return this.actionClearElement(); + } + // FORCE ELEMENT: X + if (actionName === 'FORCE ELEMENT') { + return this.actionForceElement(actionArgs); + } + // FORCE ELEMENT + if (actionName === 'NULL ELEMENT') { + return this.actionNullElement(); + } + return Yanfly.Ele.BattleManager_processActionSequence.call(this, + actionName, actionArgs); +}; + +BattleManager.actionAddElement = function(actionArgs) { + if (!actionArgs) return; + var array = []; + var length = actionArgs.length; + for (var i = 0; i < length; ++i) { + var ele = actionArgs[i].toUpperCase().trim(); + if (ele.match(/(\d+)/i)) { + array.push(parseInt(RegExp.$1)); + } else if (Yanfly.ElementIdRef[ele]) { + array.push(Yanfly.ElementIdRef[ele]); + } + } + $gameTemp._addedElements = array; + return true; +}; + +BattleManager.actionClearElement = function() { + $gameTemp._addedElements = undefined; + $gameTemp._forcedElements = undefined; + return true; +}; + +BattleManager.actionForceElement = function(actionArgs) { + if (!actionArgs) return; + var array = []; + var length = actionArgs.length; + for (var i = 0; i < length; ++i) { + var ele = actionArgs[i].toUpperCase().trim(); + if (ele.match(/(\d+)/i)) { + array.push(parseInt(RegExp.$1)); + } else if (Yanfly.ElementIdRef[ele]) { + array.push(Yanfly.ElementIdRef[ele]); + } + } + $gameTemp._forcedElements = array; + return true; +}; + +BattleManager.actionNullElement = function() { + $gameTemp._forcedElements = []; + return true; +}; + +}; // Imported.YEP_BattleEngineCore + +//============================================================================= +// Game_BattlerBase +//============================================================================= + +Yanfly.Ele.Game_BtlrBase_elementRate = + Game_BattlerBase.prototype.elementRate; +Game_BattlerBase.prototype.elementRate = function(elementId) { + var rate = this.forcedElementRate(elementId); + if (rate !== undefined) return rate; + var result = Yanfly.Ele.Game_BtlrBase_elementRate.call(this, elementId); + if (this.isAbsorbElement(elementId) && result > 0) { + result = Math.min(result - 2.0, -0.01); + } + return result; +}; + +Game_BattlerBase.prototype.getObjElementReflectRate = function(obj, elementId) { + if (!obj) return 0; + if (!obj.elementReflect) return 0; + return obj.elementReflect[elementId] || 0; +}; + +Game_BattlerBase.prototype.getObjElementAmplifyRate = function(obj, elementId) { + if (!obj) return 0; + if (!obj.elementAmplify) return 0; + return obj.elementAmplify[elementId] || 0; +}; + +Game_BattlerBase.prototype.getObjElementMagnifyRate = function(obj, elementId) { + if (!obj) return 0; + if (!obj.elementMagnify) return 0; + return obj.elementMagnify[elementId] || 0; +}; + +Game_BattlerBase.prototype.getObjElementForcedRate = function(obj, elementId) { + if (!obj) return undefined; + if (!obj.elementForcedRate) return undefined; + return obj.elementForcedRate[elementId] || undefined; +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.isAbsorbElement = function(elementId) { + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (!state.elementAbsorb) continue; + if (state.elementAbsorb.contains(elementId)) return true; + } + return false; +}; + +Game_Battler.prototype.elementReflectRate = function(elementId) { + var rate = 0; + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var obj = this.states()[i]; + rate += this.getObjElementReflectRate(obj, elementId); + } + return rate; +}; + +Game_Battler.prototype.elementAmplifyRate = function(elementId) { + var rate = 0; + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var obj = this.states()[i]; + rate += this.getObjElementAmplifyRate(obj, elementId); + } + return rate; +}; + +Game_Battler.prototype.elementMagnifyRate = function(elementId) { + var rate = 1; + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var obj = this.states()[i]; + rate += this.getObjElementMagnifyRate(obj, elementId); + } + return rate; +}; + +Game_Battler.prototype.isNullElement = function() { + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var state = this.states()[i]; + if (state && state.elementNull) return true; + } + return false; +}; + +Game_Battler.prototype.forcedElementRate = function(elementId) { + var length = this.states().length; + for (var i = 0; i < length; ++i) { + var state = this.states()[i]; + var rate = this.getObjElementForcedRate(state, elementId); + if (rate !== undefined) return rate; + } + return undefined; +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.isAbsorbElement = function(elementId) { + if (this.actor().elementAbsorb.contains(elementId)) return true; + if (this.currentClass().elementAbsorb.contains(elementId)) return true; + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (!equip.elementAbsorb) continue; + if (equip.elementAbsorb.contains(elementId)) return true; + } + return Game_Battler.prototype.isAbsorbElement.call(this, elementId); +}; + +Game_Actor.prototype.elementReflectRate = function(elementId) { + var rate = Game_Battler.prototype.elementReflectRate.call(this, elementId); + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var obj = this.equips()[i]; + rate += this.getObjElementReflectRate(obj, elementId); + } + rate += this.getObjElementReflectRate(this.actor(), elementId); + rate += this.getObjElementReflectRate(this.currentClass(), elementId); + return rate; +}; + +Game_Actor.prototype.elementAmplifyRate = function(elementId) { + var rate = Game_Battler.prototype.elementAmplifyRate.call(this, elementId); + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var obj = this.equips()[i]; + rate += this.getObjElementAmplifyRate(obj, elementId); + } + rate += this.getObjElementAmplifyRate(this.actor(), elementId); + rate += this.getObjElementAmplifyRate(this.currentClass(), elementId); + return rate; +}; + +Game_Actor.prototype.elementMagnifyRate = function(elementId) { + var rate = Game_Battler.prototype.elementMagnifyRate.call(this, elementId); + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var obj = this.equips()[i]; + rate += this.getObjElementMagnifyRate(obj, elementId); + } + rate += this.getObjElementMagnifyRate(this.actor(), elementId); + rate += this.getObjElementMagnifyRate(this.currentClass(), elementId); + return rate; +}; + +Game_Actor.prototype.isNullElement = function() { + if (this.actor().elementNull) return true; + if (this.currentClass().elementNull) return true; + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.elementNull) return true; + } + return Game_Battler.prototype.isNullElement.call(this); +}; + +Game_Actor.prototype.forcedElementRate = function(elementId) { + var rate = Game_Battler.prototype.forcedElementRate.call(this, elementId); + if (rate !== undefined) return rate; + var length = this.equips().length; + for (var i = 0; i < length; ++i) { + var equip = this.equips()[i]; + rate = this.getObjElementForcedRate(equip, elementId); + if (rate !== undefined) return rate; + } + rate = this.getObjElementForcedRate(this.currentClass(), elementId); + if (rate !== undefined) return rate; + rate = this.getObjElementForcedRate(this.actor(), elementId); + if (rate !== undefined) return rate; + return undefined; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.isAbsorbElement = function(elementId) { + if (this.enemy().elementAbsorb.contains(elementId)) return true; + return Game_Battler.prototype.isAbsorbElement.call(this, elementId); +}; + +Game_Enemy.prototype.elementReflectRate = function(elementId) { + var rate = Game_Battler.prototype.elementReflectRate.call(this, elementId); + rate += this.getObjElementReflectRate(this.enemy(), elementId); + return rate; +}; + +Game_Enemy.prototype.elementAmplifyRate = function(elementId) { + var rate = Game_Battler.prototype.elementAmplifyRate.call(this, elementId); + rate += this.getObjElementAmplifyRate(this.enemy(), elementId); + return rate; +}; + +Game_Enemy.prototype.elementMagnifyRate = function(elementId) { + var rate = Game_Battler.prototype.elementMagnifyRate.call(this, elementId); + rate += this.getObjElementMagnifyRate(this.enemy(), elementId); + return rate; +}; + +Game_Enemy.prototype.isNullElement = function() { + if (this.enemy().elementNull) return true; + return Game_Battler.prototype.isNullElement.call(this); +}; + +Game_Enemy.prototype.forcedElementRate = function(elementId) { + var rate = Game_Battler.prototype.forcedElementRate.call(this, elementId); + if (rate !== undefined) return rate; + rate = this.getObjElementForcedRate(this.enemy(), elementId); + if (rate !== undefined) return rate; + return undefined; +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Game_Action.prototype.getItemElements = function() { + if ($gameTemp._forcedElements !== undefined) { + return $gameTemp._forcedElements.filter(Yanfly.Util.onlyUnique); + } + if (this.subject().isNullElement()) return []; + var elements = []; + if (this.item().damage.elementId < 0) { + Yanfly.Util.extend(elements, this.subject().attackElements()); + } else if (this.item().damage.elementId > 0) { + elements.push(this.item().damage.elementId); + } + Yanfly.Util.extend(elements, this.item().multipleElements); + if ($gameTemp._addedElements !== undefined) { + Yanfly.Util.extend(elements, $gameTemp._addedElements); + } + return elements.filter(Yanfly.Util.onlyUnique); +}; + +Game_Action.prototype.calcElementRate = function(target) { + if (!this.item()) return 1; + var finalRate; + var elements = this.getItemElements(); + if (elements.length < 1) return 1.00; + var rule = this.item().elementMultiRule; + var average = 0; + while (elements.length > 0) { + var elementId = elements.shift(); + var eleRate = target.elementRate(elementId); + eleRate *= Math.max(0, this.subject().elementMagnifyRate(elementId)); + var absorbed = eleRate < 0; + + eleRate += this.subject().elementAmplifyRate(elementId); + if (rule === 0) { // Lowest Rate + finalRate = finalRate || eleRate; + finalRate = Math.min(finalRate, eleRate); + } else if (rule === 1) { // Additive + finalRate = finalRate || 1.00; + eleRate -= 1.00; + finalRate += eleRate; + } else if (rule === 2) { // Multiplicative + finalRate = finalRate || 1.00; + finalRate *= Math.abs(eleRate); + if (eleRate < 0) finalRate = Math.abs(finalRate) * -1; + } else if (rule === 3) { // Highest + finalRate = finalRate || eleRate; + finalRate = Math.max(finalRate, eleRate); + } else if (rule === 4) { // Average + finalRate = finalRate || 0; + finalRate += eleRate; + average += 1; + } else { + finalRate = this.calcElementRateRule(target, elementId, finalRate, + eleRate, rule); + } + } + if (rule === 4) finalRate /= Math.max(1, average); + if (finalRate === undefined) finalRate = 1.00; + return finalRate; +}; + +Game_Action.prototype.calcElementRateRule = function(target, elementId, +finalRate, eleRate, rule) { + return finalRate; +}; + +Yanfly.Ele.Game_Action_itemMrf = Game_Action.prototype.itemMrf; +Game_Action.prototype.itemMrf = function(target) { + var rate = Yanfly.Ele.Game_Action_itemMrf.call(this, target); + if (this.item().bypassElementReflect) return rate; + var elements = this.getItemElements(); + while (elements.length > 0) { + var elementId = elements.shift(); + rate += target.elementReflectRate(elementId); + } + return rate; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.getRange = function(n, m) { + var result = []; + for (var i = n; i <= m; ++i) result.push(i); + return result; +}; + +Yanfly.Util.extend = function (mainArray, otherArray) { + otherArray.forEach(function(i) { + mainArray.push(i) + }, this); +} + +Yanfly.Util.onlyUnique = function(value, index, self) { + return self.indexOf(value) === index; +}; + +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_EquipCore.js b/js/plugins/YEP_EquipCore.js new file mode 100644 index 0000000..8f789f1 --- /dev/null +++ b/js/plugins/YEP_EquipCore.js @@ -0,0 +1,1158 @@ +//============================================================================= +// Yanfly Engine Plugins - Equip Core +// YEP_EquipCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_EquipCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.Equip = Yanfly.Equip || {}; +Yanfly.Equip.version = 1.18; + +//============================================================================= + /*: + * @plugindesc v1.18 Allows for the equipment system to be more flexible to + * allow for unique equipment slots per class. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Text Align + * @parent ---General--- + * @type combo + * @option left + * @option center + * @option right + * @desc How to align the text for the command window. + * left center right + * @default center + * + * @param Finish Command + * @parent ---General--- + * @desc The command text used for exiting the equip scene. + * Leave empty to not include this command. + * @default Finish + * + * @param Remove Text + * @parent ---General--- + * @desc The text used to display the "Remove" command in the equip + * item list. + * @default Remove + * + * @param Remove Icon + * @parent ---General--- + * @type number + * @min 0 + * @desc The icon used to display next to the "Remove" command in + * the equip item list. + * @default 16 + * + * @param Empty Text + * @parent ---General--- + * @desc The text used to display an "Empty" piece of equipment. + * @default + * + * @param Empty Icon + * @parent ---General--- + * @type number + * @min 0 + * @desc The icon used to display next to the "Empty" piece of + * equipment in the equipment list. + * @default 16 + * + * @param ---Rules--- + * @default + * + * @param Non-Removable Types + * @parent ---Rules--- + * @type number + * @min 1 + * @max 100 + * @desc These types must always have an item equipped and cannot + * be empty. Separate the type ID's by a space. + * @default 1 + * + * @param Non-Optimized Types + * @parent ---Rules--- + * @type number + * @min 1 + * @max 100 + * @desc These types will be ignored when the actor optimizes + * equips. Separate the type ID's by a space. + * @default 5 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin alters various aspects regarding equipment handling. The changes + * are as listed: + * + * 1. Scene_Equip + * Scene_Equip has been modified to look differently. This is primarily done to + * make the main menu scenes look uniform and keep everything familiar for + * players. Furthermore, the command window has been adjusted to be better fit + * for extension plugins in the future that may add commands to the command + * window and/or the scene. + * + * 2. Equipment Type Handling + * Characters will no longer have one universal equipment slot setting. Now, + * different classes can use different setups by simply adding a few notetags + * to the class notebox. Furthermore, equipment types in the past with matching + * names would be treated as separate types. Now, equipment types with matching + * names will be treated as the same type. + * + * 3. Equipment Rulings + * Now, certain equipment types can or cannot be removed. For example, this + * plugin can set it so that the Weapon slot must always have something + * equipped and that the player cannot manually leave it empty (the game, on + * the other hand, can achieve this through events). In addition to that, + * optimizing equipment can be restricted for certain equipment types, which + * are better off being decided manually (such as accessories). + * + * 4. Parameter Control + * Equipment parameters can now to be adjusted through notetags to have a large + * value or customized value (through code). This allows for equipment to no + * longer be static items, but instead, equipment can now be dynamic and may + * change over the course of the game. + * + * Note: Item Core Users + * For users using the Item Core plugin and the new Item Scene layout option, + * the Item Info Window is now added to the Equip Scene. Pressing Left/Right + * will toggle the stat comparison window with the info window. Pressing Tab on + * the keyboard will also switch them as well as clicking on those windows. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * You can use the following notetags to change a class's equipment setup. + * + * Class Notetags: + * Example: + * + * Changes this class's equipment slots to x. Using repeating numbers makes + * it so that equipment type is duplicated and that the class can equip + * multiple equipment of that type. To find the Equipment Type ID, go to your + * database's Types tab and look for the ID type. + * + * If you don't like the above method for setting equipment slots, you can + * use the following notetags instead: + * + * Example: + * string Weapon + * string Armor + * string Accessory + * string Accessory + * + * Replace 'string' with the Equipment type's name entry. This is case + * sensitive so if the string does not match a name entry perfectly, the slot + * will not be granted to the class. Multiple copies of a name entry would + * mean the class can equip multiple equipment of that type. Everything works + * the same as the previous notetag. + * + * Weapon and Armor Notetags: + * + * + * Allows the piece of weapon or armor to gain or lose x amount of stat. + * Replace "stat" with "hp", "mp", "atk", "def", "mat", "mdf", "agi", or + * "luk" to alter that specific stat. This allows the piece of equipment + * to go past the editor's default limitation so long as the maximum value + * allows for it. Changes made here alter the base parameters. + * + * ============================================================================ + * Lunatic Mode - Custom Parameters + * ============================================================================ + * + * Example: + * code atk = $gameVariables.value(1); + * code mat = atk / 2; + * code all = $gameParty.members().length; + * code + * + * Allows for parameters to have custom rates adjusted by code. The following + * parameters are defined: 'maxhp', 'maxmp', 'atk', 'def', 'mat', 'mdf', + * 'agi', 'luk', and 'all'. The 'all' parameter will affect all parameters. + * Changes made here do not alter the base parameters, but instead, are added + * onto the base parameters. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.18: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.17: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.16: + * - Lunatic Mode fail safes added. + * + * Version 1.15: + * - Optimization update. + * + * Version 1.14: + * - Added an actor refresh upon listing the various equip slots to ensure that + * all slots are updated in case any cache'd instances may have been missed. + * + * Version 1.13: + * - Fixed a bug that caused a crash for those who weren't using the Item Core + * in addition to this plugin. + * + * Version 1.12: + * - Added optional functionality. Leaving 'Finish Command' empty will remove + * it from being added to the command list. + * + * Version 1.11: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.10: + * - Fixed a bug that did not clear changes made to an actor's stats after + * having unequipped them and then switching actors. + * + * Version 1.09: + * - For users using the Item Core plugin and the new Item Scene layout option, + * the Item Info Window is now added to the Equip Scene. Pressing Left/Right + * will toggle the stat comparison window with the info window. Pressing Tab on + * the keyboard will also switch them as well as clicking on those windows. + * + * Version 1.08: + * - Fixed a bug where changing an actor's equips would revive them if dead. + * + * Version 1.07: + * - Fixed a bug with 'Optimize' and 'Remove All' not refreshing windows. + * + * Version 1.06: + * - Fixed a bug with 'Change Equipment' event where it would only change the + * slot of the marked equipment rather than the slot type. + * + * Version 1.05: + * - Fixed an issue where unequipping items can kill actors. + * + * Version 1.04a: + * - Fixed a bug and rewrote the initializing equipment process. + * + * Version 1.03: + * - Fixed an bug that resulted in null object errors. + * + * Version 1.02: + * - Fixed an issue that did not keep HP and MP rates the same when using the + * optimize and clear commands. + * + * Version 1.01: + * - Fixed a bug that did not update the stats properly when compared. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_EquipCore'); +Yanfly.Param = Yanfly.Param || {}; +Yanfly.Icon = Yanfly.Icon || {}; + +Yanfly.Param.EquipTextAlign = String(Yanfly.Parameters['Text Align']); +Yanfly.Param.EquipFinishCmd = String(Yanfly.Parameters['Finish Command']); +Yanfly.Param.EquipRemoveText = String(Yanfly.Parameters['Remove Text']); +Yanfly.Icon.RemoveEquip = Number(Yanfly.Parameters['Remove Icon']); +Yanfly.Param.EquipEmptyText = String(Yanfly.Parameters['Empty Text']); +Yanfly.Icon.EmptyEquip = Number(Yanfly.Parameters['Empty Icon']); +Yanfly.Data = String(Yanfly.Parameters['Non-Removable Types']); +Yanfly.Data = Yanfly.Data.split(' '); +Yanfly.Param.EquipNonRemove = []; +for (Yanfly.i = 0; Yanfly.i < Yanfly.Data.length; ++Yanfly.i) { + Yanfly.Param.EquipNonRemove.push(parseInt(Yanfly.Data[Yanfly.i])); +}; +Yanfly.Data = String(Yanfly.Parameters['Non-Optimized Types']); +Yanfly.Data = Yanfly.Data.split(' '); +Yanfly.Param.EquipNonOptimized = []; +for (Yanfly.i = 0; Yanfly.i < Yanfly.Data.length; ++Yanfly.i) { + Yanfly.Param.EquipNonOptimized.push(parseInt(Yanfly.Data[Yanfly.i])); +}; + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.Equip.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.Equip.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_EquipCore) { + DataManager.processEquipNotetags1($dataClasses); + DataManager.processEquipNotetags2($dataWeapons); + DataManager.processEquipNotetags2($dataArmors); + Yanfly._loaded_YEP_EquipCore = true; + } + return true; +}; + +DataManager.processEquipNotetags1 = function(group) { + var note1 = /<(?:EQUIP SLOT|equip slots):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note2 = /<(?:EQUIP SLOT|equip slots)>/i; + var note3 = /<\/(?:EQUIP SLOT|equip slots)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.equipSlots = []; + var equipSlots = false; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + obj.equipSlots = obj.equipSlots.concat(array); + } else if (line.match(note2)) { + equipSlots = true; + } else if (line.match(note3)) { + equipSlots = false; + } else if (equipSlots && line.match(/[ ]*(.*)/i)) { + var name = String(RegExp.$1); + var slotId = $dataSystem.equipTypes.indexOf(name); + if (slotId >= 0) obj.equipSlots.push(slotId); + } + } + if (obj.equipSlots.length <= 0) this.setDefaultEquipSlots(obj); + } +}; + +DataManager.setDefaultEquipSlots = function(obj) { + for (var i = 1; i < $dataSystem.equipTypes.length; ++i) { + var name = $dataSystem.equipTypes[i]; + var slotId = $dataSystem.equipTypes.indexOf(name); + if (slotId >= 0) obj.equipSlots.push(slotId); + } +}; + +DataManager.processEquipNotetags2 = function(group) { + var note1 = /<(?:PARAMETER EVAL|custom parameter|custom parameters)>/i; + var note2 = /<\/(?:PARAMETER EVAL|custom parameter|custom parameters)>/i; + var note3 = /<(.*):[ ]([\+\-]\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.parameterEval = ''; + var parameterEval = false; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + parameterEval = true; + } else if (line.match(note2)) { + parameterEval = false; + } else if (parameterEval) { + obj.parameterEval = obj.parameterEval + line + '\n'; + } else if (line.match(note3)) { + var stat = String(RegExp.$1).toUpperCase(); + var value = parseInt(RegExp.$2); + switch (stat) { + case 'HP': + case 'MAXHP': + case 'MAX HP': + obj.params[0] = value; + break; + case 'MP': + case 'MAXMP': + case 'MAX MP': + case 'SP': + case 'MAXSP': + case 'MAX SP': + obj.params[1] = value; + break; + case 'ATK': + case 'STR': + obj.params[2] = value; + break; + case 'DEF': + obj.params[3] = value; + break; + case 'MAT': + case 'INT' || 'SPI': + obj.params[4] = value; + break; + case 'MDF': + case 'RES': + obj.params[5] = value; + break; + case 'AGI': + case 'SPD': + obj.params[6] = value; + break; + case 'LUK': + obj.params[7] = value; + break; + } + } + } + } +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.initEquips = function(equips) { + var equips = this.convertInitEquips(equips); + this.equipInitEquips(equips); + this.releaseUnequippableItems(true); + this.recoverAll(); + this.refresh(); +}; + +Game_Actor.prototype.convertInitEquips = function(equips) { + var items = []; + for (var i = 0; i < equips.length; ++i) { + var equipId = equips[i]; + if (equipId <= 0) continue; + var equipType = $dataSystem.equipTypes[i + 1]; + if (equipType === $dataSystem.equipTypes[1] || + (i === 1 && this.isDualWield())) { + var equip = $dataWeapons[equipId]; + } else { + var equip = $dataArmors[equipId]; + } + items.push(equip); + } + return items; +}; + +Game_Actor.prototype.equipInitEquips = function(equips) { + var slots = this.equipSlots(); + var maxSlots = slots.length; + this._equips = []; + for (var i = 0; i < maxSlots; ++i) { + this._equips[i] = new Game_Item(); + } + for (var i = 0; i < maxSlots; ++i) { + var slotType = slots[i]; + var equip = this.grabInitEquips(equips, slotType); + if (this.canEquip(equip)) this._equips[i].setObject(equip); + } +}; + +Game_Actor.prototype.grabInitEquips = function(equips, slotType) { + var item = null; + for (var i = 0; i < equips.length; ++i) { + var equip = equips[i]; + if (!equip) continue; + if (slotType === 1 && DataManager.isWeapon(equip)) { + item = equip; + break; + } else if (equip.etypeId === slotType) { + item = equip; + break; + } + } + if (item) equips[i] = null; + return item; +}; + +Game_Actor.prototype.equipSlots = function() { + var slots = this.currentClass().equipSlots.slice(); + if (slots.length >= 2 && this.isDualWield()) slots[1] = 1; + return slots; +}; + +Yanfly.Equip.Game_Actor_equips = Game_Actor.prototype.equips; +Game_Actor.prototype.equips = function() { + for (var i = 0; i < this.currentClass().equipSlots.length; ++i) { + if (this._equips[i] === undefined || this._equips[i] === null) { + this._equips[i] = new Game_Item(); + } + } + return Yanfly.Equip.Game_Actor_equips.call(this); +}; + +Yanfly.Equip.Game_Actor_changeEquip = Game_Actor.prototype.changeEquip; +Game_Actor.prototype.changeEquip = function(slotId, item) { + if (!this._equips[slotId]) this._equips[slotId] = new Game_Item(); + Yanfly.Equip.Game_Actor_changeEquip.call(this, slotId, item); +}; + +Yanfly.Equip.Game_Actor_forceChangeEquip = + Game_Actor.prototype.forceChangeEquip; +Game_Actor.prototype.forceChangeEquip = function(slotId, item) { + if (!this._equips[slotId]) { + this._equips[slotId] = new Game_Item(); + this._equips[slotId].setEquip(this.equipSlots()[slotId] === 1, 0); + } + Yanfly.Equip.Game_Actor_forceChangeEquip.call(this, slotId, item); +}; + +Yanfly.Equip.Game_Actor_isEquipChangeOk = Game_Actor.prototype.isEquipChangeOk; +Game_Actor.prototype.isEquipChangeOk = function(slotId) { + if ($gameTemp._clearEquipments) { + var typeId = this.equipSlots()[slotId]; + if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false; + } + if ($gameTemp._optimizeEquipments) { + var typeId = this.equipSlots()[slotId]; + if (Yanfly.Param.EquipNonOptimized.contains(typeId)) return false; + } + return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this, slotId); +}; + +Yanfly.Equip.Game_Actor_paramPlus = Game_Actor.prototype.paramPlus; +Game_Actor.prototype.paramPlus = function(paramId) { + value = Yanfly.Equip.Game_Actor_paramPlus.call(this, paramId); + var equips = this.equips(); + for (var i = 0; i < equips.length; i++) { + var item = equips[i]; + if (!item) continue; + value += this.customParamPlus(item, paramId); + value += this.evalParamPlus(item, paramId); + } + return value; +}; + +Game_Actor.prototype.customParamPlus = function(item, paramId) { + return 0; +}; + +Game_Actor.prototype.evalParamPlus = function(item, paramId) { + if (!item) return 0; + if (!item.parameterEval || item.parameterEval === '') return 0; + var value = 0; + var hp = 0; + var maxhp = 0; + var mhp = 0; + var mp = 0; + var maxmp = 0; + var mmp = 0; + var sp = 0; + var maxsp = 0; + var msp = 0; + var atk = 0; + var str = 0; + var def = 0; + var mat = 0; + var int = 0; + var spi = 0; + var mdf = 0; + var res = 0; + var agi = 0; + var spd = 0; + var luk = 0; + var all = 0; + var a = this; + var user = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.parameterEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CUSTOM PARAMETER FORMULA ERROR'); + } + switch (paramId) { + case 0: + value += hp + maxhp + mhp; + break; + case 1: + value += mp + maxmp + mmp + sp + maxsp + msp; + break; + case 2: + value += atk + str; + break; + case 3: + value += def; + break; + case 4: + value += mat + int + spi; + break; + case 5: + value += mdf + res; + break; + case 6: + value += agi + spd; + break; + case 7: + value += luk; + break; + } + return value + all; +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +// Change Equipment +Game_Interpreter.prototype.command319 = function() { + var actor = $gameActors.actor(this._params[0]); + if (!actor) return true; + var index = actor.equipSlots().indexOf(this._params[1]) + 1; + actor.changeEquipById(index, this._params[2]); + return true; +}; + +//============================================================================= +// Window_EquipCommand +//============================================================================= + +Window_EquipCommand.prototype.windowWidth = function() { + return 240; +}; + +Window_EquipCommand.prototype.maxCols = function() { + return 1; +}; + +Window_EquipCommand.prototype.windowHeight = function() { + return this.fittingHeight(this.numVisibleRows()); +}; + +Window_EquipCommand.prototype.numVisibleRows = function() { + return 4; +}; + +Window_EquipCommand.prototype.itemTextAlign = function() { + return Yanfly.Param.EquipTextAlign; +}; + +Yanfly.Equip.Window_EquipCommand_makeCommandList = + Window_EquipCommand.prototype.makeCommandList; +Window_EquipCommand.prototype.makeCommandList = function() { + Yanfly.Equip.Window_EquipCommand_makeCommandList.call(this); + this.addCustomCommand(); + this.addFinishCommand(); +}; + +Window_EquipCommand.prototype.addCustomCommand = function() { +}; + +Window_EquipCommand.prototype.addFinishCommand = function() { + if (Yanfly.Param.EquipFinishCmd === '') return; + this.addCommand(Yanfly.Param.EquipFinishCmd, 'cancel'); +}; + +//============================================================================= +// Window_EquipSlot +//============================================================================= + +Yanfly.Equip.Window_EquipSlot_setActor = Window_EquipSlot.prototype.setActor; +Window_EquipSlot.prototype.setActor = function(actor) { + this.setSlotNameWidth(actor); + Yanfly.Equip.Window_EquipSlot_setActor.call(this, actor); +}; + +Window_EquipSlot.prototype.refresh = function() { + if (this._actor) this._actor.refresh(); + Window_Selectable.prototype.refresh.call(this); +}; + +Window_EquipSlot.prototype.isEnabled = function(index) { + if (this._actor) { + return Yanfly.Equip.Game_Actor_isEquipChangeOk.call(this._actor, index); + } else { + return false; + } +}; + +Window_EquipSlot.prototype.drawItem = function(index) { + if (!this._actor) return; + var rect = this.itemRectForText(index); + this.changeTextColor(this.systemColor()); + this.changePaintOpacity(this.isEnabled(index)); + var ww1 = this._nameWidth; + this.drawText(this.slotName(index), rect.x, rect.y, ww1); + var ww2 = rect.width - ww1; + var item = this._actor.equips()[index]; + if (item) { + this.drawItemName(item, rect.x + ww1, rect.y, ww2); + } else { + this.drawEmptySlot(rect.x + ww1, rect.y, ww2); + } + this.changePaintOpacity(true); +}; + +Window_EquipSlot.prototype.setSlotNameWidth = function(actor) { + if (!actor) return; + this._nameWidth = 0; + for (var i = 0; i < actor.equipSlots().length; ++i) { + var text = $dataSystem.equipTypes[actor.equipSlots()[i]] + ' '; + this._nameWidth = Math.max(this._nameWidth, this.textWidth(text)); + } +}; + +Window_EquipSlot.prototype.drawEmptySlot = function(wx, wy, ww) { + this.changePaintOpacity(false); + var ibw = Window_Base._iconWidth + 4; + this.resetTextColor(); + this.drawIcon(Yanfly.Icon.EmptyEquip, wx + 2, wy + 2); + var text = Yanfly.Param.EquipEmptyText; + this.drawText(text, wx + ibw, wy, ww - ibw); +}; + +Window_EquipSlot.prototype.setInfoWindow = function(infoWindow) { + this._infoWindow = infoWindow; + this.update(); +}; + +Yanfly.Equip.Window_ItemList_updateHelp = Window_EquipSlot.prototype.updateHelp; +Window_EquipSlot.prototype.updateHelp = function() { + Yanfly.Equip.Window_ItemList_updateHelp.call(this); + if (SceneManager._scene instanceof Scene_Equip && this._infoWindow) { + this._infoWindow.setItem(this.item()); + } +}; + +//============================================================================= +// Window_EquipItem +//============================================================================= + +Window_EquipItem.prototype.maxCols = function() { + return 1; +}; + +Yanfly.Equip.Window_EquipItem_setSlotId = Window_EquipItem.prototype.setSlotId; +Window_EquipItem.prototype.setSlotId = function(slotId) { + // do nothing +}; + +Yanfly.Equip.Window_EquipItem_includes = Window_EquipItem.prototype.includes; +Window_EquipItem.prototype.includes = function(item) { + if (item === null && this._actor && this._data.length > 0) { + var typeId = this._actor.equipSlots()[this._slotId]; + if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false; + } + return Yanfly.Equip.Window_EquipItem_includes.call(this, item); +}; + +Yanfly.Equip.Window_EquipItem_isEnabled = + Window_EquipItem.prototype.isEnabled; +Window_EquipItem.prototype.isEnabled = function(item) { + if (item === null && this._actor) { + var typeId = this._actor.equipSlots()[this._slotId]; + if (Yanfly.Param.EquipNonRemove.contains(typeId)) return false; + } + return Yanfly.Equip.Window_EquipItem_isEnabled.call(this, item); +}; + +Yanfly.Equip.Window_EquipItem_drawItem = Window_EquipItem.prototype.drawItem; +Window_EquipItem.prototype.drawItem = function(index) { + var item = this._data[index]; + if (item === null) { + this.drawRemoveEquip(index); + } else { + Yanfly.Equip.Window_EquipItem_drawItem.call(this, index); + } +}; + +Window_EquipItem.prototype.drawRemoveEquip = function(index) { + if (!this.isEnabled(null)) return; + var rect = this.itemRect(index); + rect.width -= this.textPadding(); + this.changePaintOpacity(true); + var ibw = Window_Base._iconWidth + 4; + this.resetTextColor(); + this.drawIcon(Yanfly.Icon.RemoveEquip, rect.x + 2, rect.y + 2); + var text = Yanfly.Param.EquipRemoveText; + this.drawText(text, rect.x + ibw, rect.y, rect.width - ibw); +}; + +Window_EquipItem.prototype.setInfoWindow = function(infoWindow) { + this._infoWindow = infoWindow; + this.update(); +}; + +Yanfly.Equip.Window_ItemList_updateHelp = Window_EquipItem.prototype.updateHelp; +Window_EquipItem.prototype.updateHelp = function() { + Yanfly.Equip.Window_ItemList_updateHelp.call(this); + if (SceneManager._scene instanceof Scene_Equip && this._infoWindow) { + this._infoWindow.setItem(this.item()); + } +}; + +//============================================================================= +// Window_StatCompare +//============================================================================= + +function Window_StatCompare() { + this.initialize.apply(this, arguments); +} + +Window_StatCompare.prototype = Object.create(Window_Base.prototype); +Window_StatCompare.prototype.constructor = Window_StatCompare; + +Window_StatCompare.prototype.initialize = function(wx, wy, ww, wh) { + Window_Base.prototype.initialize.call(this, wx, wy, ww, wh); + this._actor = null; + this._tempActor = null; + this.refresh(); +}; + +Window_StatCompare.prototype.createWidths = function() { + this._paramNameWidth = 0; + this._paramValueWidth = 0; + this._arrowWidth = this.textWidth('\u2192' + ' '); + var buffer = this.textWidth(' '); + for (var i = 0; i < 8; ++i) { + var value1 = this.textWidth(TextManager.param(i)); + var value2 = this.textWidth(Yanfly.Util.toGroup(this._actor.paramMax(i))); + this._paramNameWidth = Math.max(value1, this._paramNameWidth); + this._paramValueWidth = Math.max(value2, this._paramValueWidth); + } + this._bonusValueWidth = this._paramValueWidth; + this._bonusValueWidth += this.textWidth('(+)') + buffer; + this._paramNameWidth += buffer; + this._paramValueWidth; + if (this._paramNameWidth + this._paramValueWidth * 2 + this._arrowWidth + + this._bonusValueWidth > this.contents.width) this._bonusValueWidth = 0; +}; + +Window_StatCompare.prototype.setActor = function(actor) { + if (this._actor === actor) return; + this._actor = actor; + this.createWidths(); + this.refresh(); +}; + +Window_StatCompare.prototype.refresh = function() { + this.contents.clear(); + if (!this._actor) return; + for (var i = 0; i < 8; ++i) { + this.drawItem(0, this.lineHeight() * i, i); + } +}; + +Window_StatCompare.prototype.setTempActor = function(tempActor) { + if (this._tempActor === tempActor) return; + this._tempActor = tempActor; + this.refresh(); +}; + +Window_StatCompare.prototype.drawItem = function(x, y, paramId) { + this.drawDarkRect(x, y, this.contents.width, this.lineHeight()); + this.drawParamName(y, paramId); + this.drawCurrentParam(y, paramId); + this.drawRightArrow(y); + if (!this._tempActor) return; + this.drawNewParam(y, paramId); + this.drawParamDifference(y, paramId); +}; + +Window_StatCompare.prototype.drawDarkRect = function(dx, dy, dw, dh) { + var color = this.gaugeBackColor(); + this.changePaintOpacity(false); + this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color); + this.changePaintOpacity(true); +}; + +Window_StatCompare.prototype.drawParamName = function(y, paramId) { + var x = this.textPadding(); + this.changeTextColor(this.systemColor()); + this.drawText(TextManager.param(paramId), x, y, this._paramNameWidth); +}; + +Window_StatCompare.prototype.drawCurrentParam = function(y, paramId) { + var x = this.contents.width - this.textPadding(); + x -= this._paramValueWidth * 2 + this._arrowWidth + this._bonusValueWidth; + this.resetTextColor(); + var actorparam = Yanfly.Util.toGroup(this._actor.param(paramId)); + this.drawText(actorparam, x, y, this._paramValueWidth, 'right'); +}; + +Window_StatCompare.prototype.drawRightArrow = function(y) { + var x = this.contents.width - this.textPadding(); + x -= this._paramValueWidth + this._arrowWidth + this._bonusValueWidth; + var dw = this.textWidth('\u2192' + ' '); + this.changeTextColor(this.systemColor()); + this.drawText('\u2192', x, y, dw, 'center'); +}; + +Window_StatCompare.prototype.drawNewParam = function(y, paramId) { + var x = this.contents.width - this.textPadding(); + x -= this._paramValueWidth + this._bonusValueWidth; + var newValue = this._tempActor.param(paramId); + var diffvalue = newValue - this._actor.param(paramId); + var actorparam = Yanfly.Util.toGroup(newValue); + this.changeTextColor(this.paramchangeTextColor(diffvalue)); + this.drawText(actorparam, x, y, this._paramValueWidth, 'right'); +}; + +Window_StatCompare.prototype.drawParamDifference = function(y, paramId) { + var x = this.contents.width - this.textPadding(); + x -= this._bonusValueWidth; + var newValue = this._tempActor.param(paramId); + var diffvalue = newValue - this._actor.param(paramId); + if (diffvalue === 0) return; + var actorparam = Yanfly.Util.toGroup(newValue); + this.changeTextColor(this.paramchangeTextColor(diffvalue)); + var text = Yanfly.Util.toGroup(diffvalue); + if (diffvalue > 0) { + text = ' (+' + text + ')'; + } else { + text = ' (' + text + ')'; + } + this.drawText(text, x, y, this._bonusValueWidth, 'left'); +}; + +//============================================================================= +// Scene_Equip +//============================================================================= + +Scene_Equip.prototype.create = function() { + Scene_MenuBase.prototype.create.call(this); + this.createHelpWindow(); + this.createCommandWindow(); + this.createStatusWindow(); + this.createSlotWindow(); + this.createItemWindow(); + this.createCompareWindow(); + this._lowerRightVisibility = true; + this.updateLowerRightWindows(); + this.refreshActor(); +}; + +Scene_Equip.prototype.createCommandWindow = function() { + var wy = this._helpWindow.height; + this._commandWindow = new Window_EquipCommand(0, wy, 240); + this._commandWindow.setHelpWindow(this._helpWindow); + this._commandWindow.setHandler('equip', this.commandEquip.bind(this)); + this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this)); + this._commandWindow.setHandler('clear', this.commandClear.bind(this)); + this._commandWindow.setHandler('cancel', this.popScene.bind(this)); + this._commandWindow.setHandler('pagedown', this.nextActor.bind(this)); + this._commandWindow.setHandler('pageup', this.previousActor.bind(this)); + this.addWindow(this._commandWindow); +}; + +Scene_Equip.prototype.createStatusWindow = function() { + var wx = this._commandWindow.width; + var wy = this._helpWindow.height; + var ww = Graphics.boxWidth - wx; + var wh = this._commandWindow.height; + this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh); + this.addWindow(this._statusWindow); +}; + +Scene_Equip.prototype.createSlotWindow = function() { + var wy = this._commandWindow.y + this._commandWindow.height; + var ww = Graphics.boxWidth / 2; + var wh = Graphics.boxHeight - wy; + this._slotWindow = new Window_EquipSlot(0, wy, ww, wh); + this._slotWindow.setHelpWindow(this._helpWindow); + this._slotWindow.setHandler('ok', this.onSlotOk.bind(this)); + this._slotWindow.setHandler('cancel', this.onSlotCancel.bind(this)); + this.addWindow(this._slotWindow); +}; + +Scene_Equip.prototype.createItemWindow = function() { + var wy = this._slotWindow.y; + var ww = Graphics.boxWidth / 2; + var wh = Graphics.boxHeight - wy; + this._itemWindow = new Window_EquipItem(0, wy, ww, wh); + this._itemWindow.setHelpWindow(this._helpWindow); + this._itemWindow.setHandler('ok', this.onItemOk.bind(this)); + this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this)); + this._slotWindow.setItemWindow(this._itemWindow); + this.addWindow(this._itemWindow); + this._itemWindow.hide(); +}; + +Scene_Equip.prototype.createCompareWindow = function() { + this._lowerRightWindows = []; + var wx = this._itemWindow.width; + var wy = this._itemWindow.y; + var ww = Graphics.boxWidth - wx; + var wh = Graphics.boxHeight - wy; + this._compareWindow = new Window_StatCompare(wx, wy, ww, wh); + this._slotWindow.setStatusWindow(this._compareWindow); + this._itemWindow.setStatusWindow(this._compareWindow); + this.addWindow(this._compareWindow); + this._lowerRightWindows.push(this._compareWindow); + if (Imported.YEP_ItemCore && eval(Yanfly.Param.ItemSceneItem)) { + this.createItemInfoWindow(); + } +}; + +Scene_Equip.prototype.createItemInfoWindow = function() { + var wx = this._itemWindow.width; + var wy = this._itemWindow.y; + var ww = Graphics.boxWidth - wx; + var wh = this._itemWindow.height; + this._infoWindow = new Window_ItemInfo(wx, wy, ww, wh); + this._slotWindow.setInfoWindow(this._infoWindow); + this._itemWindow.setInfoWindow(this._infoWindow); + this.addWindow(this._infoWindow); + this._lowerRightWindows.push(this._infoWindow); +}; + +Yanfly.Equip.Scene_Equip_refreshActor = Scene_Equip.prototype.refreshActor; +Scene_Equip.prototype.refreshActor = function() { + Yanfly.Equip.Scene_Equip_refreshActor.call(this); + this._compareWindow.setActor(this.actor()); +}; + +Yanfly.Equip.Scene_Equip_commandOptimize = + Scene_Equip.prototype.commandOptimize; +Scene_Equip.prototype.commandOptimize = function() { + $gameTemp._optimizeEquipments = true; + var hpRate = this.actor().hp / Math.max(1, this.actor().mhp); + var mpRate = this.actor().mp / Math.max(1, this.actor().mmp); + Yanfly.Equip.Scene_Equip_commandOptimize.call(this); + $gameTemp._optimizeEquipments = false; + var max = this.actor().isDead() ? 0 : 1; + var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate)); + this.actor().setHp(hpAmount); + this.actor().setMp(parseInt(this.actor().mmp * mpRate)); + this._compareWindow.refresh(); + this._statusWindow.refresh(); + this.refreshActor(); +}; + +Yanfly.Equip.Scene_Equip_commandClear = Scene_Equip.prototype.commandClear; +Scene_Equip.prototype.commandClear = function() { + $gameTemp._clearEquipments = true; + var hpRate = this.actor().hp / Math.max(1, this.actor().mhp); + var mpRate = this.actor().mp / Math.max(1, this.actor().mmp); + Yanfly.Equip.Scene_Equip_commandClear.call(this); + $gameTemp._clearEquipments = false; + var max = this.actor().isDead() ? 0 : 1; + var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate)); + this.actor().setHp(hpAmount); + this.actor().setMp(parseInt(this.actor().mmp * mpRate)); + this._compareWindow.refresh(); + this._statusWindow.refresh(); + this.refreshActor(); +}; + +Yanfly.Equip.Scene_Equip_onSlotOk = Scene_Equip.prototype.onSlotOk; +Scene_Equip.prototype.onSlotOk = function() { + this._itemWindow._slotId = -1; + var slotId = this._slotWindow.index(); + Yanfly.Equip.Window_EquipItem_setSlotId.call(this._itemWindow, slotId); + Yanfly.Equip.Scene_Equip_onSlotOk.call(this); + this._itemWindow.show(); +}; + +Yanfly.Equip.Scene_Equip_onSlotCancel = Scene_Equip.prototype.onSlotCancel; +Scene_Equip.prototype.onSlotCancel = function() { + Yanfly.Equip.Scene_Equip_onSlotCancel.call(this); + if (this._infoWindow) this._infoWindow.setItem(null); + this._compareWindow.setTempActor(null); +}; + +Yanfly.Equip.Scene_Equip_onItemOk = Scene_Equip.prototype.onItemOk; +Scene_Equip.prototype.onItemOk = function() { + var hpRate = this.actor().hp / Math.max(1, this.actor().mhp); + var mpRate = this.actor().mp / Math.max(1, this.actor().mmp); + Yanfly.Equip.Scene_Equip_onItemOk.call(this); + var max = this.actor().isDead() ? 0 : 1; + var hpAmount = Math.max(max, parseInt(this.actor().mhp * hpRate)); + this.actor().setHp(hpAmount); + this.actor().setMp(parseInt(this.actor().mmp * mpRate)); + this._itemWindow.hide(); + this._statusWindow.refresh(); +}; + +Yanfly.Equip.Scene_Equip_onItemCancel = Scene_Equip.prototype.onItemCancel; +Scene_Equip.prototype.onItemCancel = function() { + Yanfly.Equip.Scene_Equip_onItemCancel.call(this); + this._compareWindow.setTempActor(null); + this._itemWindow.hide(); +}; + +Scene_Equip.prototype.update = function() { + Scene_MenuBase.prototype.update.call(this); + if (this.isActive()) this.updateLowerRightWindowTriggers(); +}; + +Scene_Equip.prototype.updateLowerRightWindowTriggers = function() { + if (!this._lowerRightVisibility) return; + if (Input.isRepeated('right')) { + this.shiftLowerRightWindows(); + } else if (Input.isRepeated('left')) { + this.unshiftLowerRightWindows(); + } else if (Input.isRepeated('tab')) { + this.shiftLowerRightWindows(); + } else if (this.isLowerWindowTouched()) { + this.shiftLowerRightWindows(); + } +}; + +Scene_Equip.prototype.isLowerWindowTouched = function() { + if (!TouchInput.isTriggered()) return false; + var x = TouchInput.x; + var y = TouchInput.y; + var rect = new Rectangle(); + rect.x = this._compareWindow.x; + rect.y = this._compareWindow.y; + rect.width = this._compareWindow.x + this._compareWindow.width; + rect.height = this._compareWindow.y + this._compareWindow.height; + return (x >= rect.x && y >= rect.y && x < rect.width && y < rect.height); +}; + +Scene_Equip.prototype.updateLowerRightWindows = function() { + var length = this._lowerRightWindows.length; + for (var i = 0; i < length; ++i) { + var win = this._lowerRightWindows[i]; + win.visible = false; + } + this._lowerRightWindows[0].visible = this._lowerRightVisibility; +}; + +Scene_Equip.prototype.shiftLowerRightWindows = function() { + var win = this._lowerRightWindows.shift(); + this._lowerRightWindows.push(win); + this.updateLowerRightWindows(); + this.playLowerRightWindowSound(); +}; + +Scene_Equip.prototype.unshiftLowerRightWindows = function() { + var win = this._lowerRightWindows.pop(); + this._lowerRightWindows.unshift(win); + this.updateLowerRightWindows(); + this.playLowerRightWindowSound(); +}; + +Scene_Equip.prototype.playLowerRightWindowSound = function() { + if (this._lowerRightWindows.length <= 1) return; + SoundManager.playCursor(); +}; + +Yanfly.Equip.Scene_Equip_onActorChange = Scene_Equip.prototype.onActorChange; +Scene_Equip.prototype.onActorChange = function() { + Yanfly.Equip.Scene_Equip_onActorChange.call(this); + this._compareWindow.setTempActor(null); + if (this._infoWindow) this._infoWindow.setItem(null); +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_EventChasePlayer.js b/js/plugins/YEP_EventChasePlayer.js new file mode 100644 index 0000000..fa78375 --- /dev/null +++ b/js/plugins/YEP_EventChasePlayer.js @@ -0,0 +1,435 @@ +//============================================================================= +// Yanfly Engine Plugins - Event Chase Player +// YEP_EventChasePlayer.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_EventChasePlayer = true; + +var Yanfly = Yanfly || {}; +Yanfly.ECP = Yanfly.ECP || {}; +Yanfly.ECP.version = 1.07; + +//============================================================================= + /*: + * @plugindesc v1.07 When a player is in the proximity of a certain event, + * the event will start chasing or fleeing from the player. + * @author Yanfly Engine Plugins + * + * @param Sight Lock + * @type number + * @min 0 + * @desc This is the number of frames for how long an event chases + * the player if 'this._seePlayer = true' is used. + * @default 300 + * + * @param See Player + * @type boolean + * @on YES + * @off NO + * @desc Does the event have to be able to see the player by default? + * NO - false YES - true + * @default true + * + * @param Alert Timer + * @type number + * @min 0 + * @desc This is the number of frames that must occur before the + * alert balloon will show up on the same event. + * @default 120 + * + * @param Alert Balloon + * @type number + * @min 0 + * @desc This is the default balloon used when the player is seen. + * Refer to balloon ID's. + * @default 1 + * + * @param Alert Sound + * @type file + * @dir audio/se/ + * @require 1 + * @desc This is the default sound played when the player is seen. + * @default Attack1 + * + * @param Alert Common Event + * @type common_event + * @desc The default common event played when the player is seen. + * Use 0 if you do not wish to use a Common Event. + * @default 0 + * + * @param Return After + * @type boolean + * @on YES + * @off NO + * @desc After chasing/fleeing from a player, the event returns + * to its original spot. NO - false YES - true + * @default true + * + * @param Return Wait + * @type number + * @min 0 + * @desc The frames to wait after finishing a chase/flee. + * @default 180 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin allows you to make events that will chase the player or flee + * from the player when the player enters within range of the event or when the + * event sees the player. + * + * ============================================================================ + * How to Use + * ============================================================================ + * + * Insert these lines into the script call window within the Movement Route + * event to give an event the chase or flee flag. + * + * Note: This doesn’t work with players. + * + * Script Call lines + * this._chaseRange = x Event will chase player if reaching x range. + * this._fleeRange = x Event will flee from player if reaching x range. + * this._chaseSpeed = x Event's movement speed when chasing. + * this._fleeSpeed = x Event's movement speed when fleeing. + * this._sightLock = x Event will flee/chase player for x frames. + * this._seePlayer = true Requires the event to be able to see player. + * this._seePlayer = false Doesn't require event to be able to see player. + * this._alertBalloon = x This balloon will play when player is seen. + * this._alertSound = x This sound will play when player is seen. + * this._alertSoundVol = x The volume used by the alert sound. + * this._alertSoundPitch = x The pitch used by the alert sound. + * this._alertSoundPan = x The pan used by the alert sound. + * this._alertCommonEvent = x This event will play when player is seen. + * this._returnAfter = true Returns the event back to its original spot. + * this._returnAfter = false Event stays where it is when finished chasing. + * this._returnWait = x How long event waits after finishing chase/flee. + * + * It is best to play this inside of a custom move route for the event at a + * high frequency rate. Keep in mind these effects only occur after the setting + * is made and ran, which means upon loading a map, if the event with a low + * frequency hasn't loaded up 'this._chaseRange = x' in its movement queue yet, + * the event will not chase the player just yet. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.07: + * - Added a background mechanic to stagger an event if they're chasing the + * player and get caught behind an object. This will prevent the event from + * continuously chasing the player and dropping the FPS rate. + * + * Version 1.06: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.05: + * - Optimization update. + * + * Version 1.04: + * - Fixed a bug with this._seePlayer causing them to see stealthed players. + * + * Version 1.03: + * - Improved pathfinding for chasing events. They will get stuck less by walls + * and/or events that may be blocking the event. + * - Added random factor for fleeing events. Fleeing events won't simply just + * run away 180 degrees away from the player. They will sometimes move in a + * random direction. + * + * Version 1.02: + * - Added 'Return After' parameter where events will return to their original + * spot after chasing/fleeing from a player. + * - Added 'Return Wait' parameter to determine how long an event will wait in + * place before returning after a finished chase/flee. + * - Added 'this._returnAfter' and 'this._returnWait' to the list of available + * movement route script calls. + * + * Version 1.01: + * - Added 'this._alertSoundPitch' 'this._alertSoundVol' 'this._alertSoundPan' + * to the settings you can alter to adjust the alert sound. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_EventChasePlayer'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.ECPSightLock = Number(Yanfly.Parameters['Sight Lock']); +Yanfly.Param.ECPSeePlayer = String(Yanfly.Parameters['See Player']); +Yanfly.Param.ECPSeePlayer = eval(Yanfly.Param.ECPSeePlayer); +Yanfly.Param.ECPAlertTimer = Number(Yanfly.Parameters['Alert Timer']); +Yanfly.Param.ECPAlertBalloon = Number(Yanfly.Parameters['Alert Balloon']); +Yanfly.Param.ECPAlertSound = String(Yanfly.Parameters['Alert Sound']); +Yanfly.Param.ECPAlertEvent = Number(Yanfly.Parameters['Alert Common Event']); +Yanfly.Param.ECPReturn = eval(String(Yanfly.Parameters['Return After'])); +Yanfly.Param.ECPReturnWait = Number(Yanfly.Parameters['Return Wait']); + +//============================================================================= +// Main Code +//============================================================================= + +Yanfly.ECP.Game_Event_setupPage = Game_Event.prototype.setupPage; +Game_Event.prototype.setupPage = function() { + Yanfly.ECP.Game_Event_setupPage.call(this); + this.clearChaseSettings(); +}; + +Game_Event.prototype.clearChaseSettings = function() { + this._alertBalloon = Yanfly.Param.ECPAlertBalloon; + this._alertCommonEvent = Yanfly.Param.ECPAlertEvent; + this._alertLock = 0; + this._alertPlayer = false; + this._alertSound = Yanfly.Param.ECPAlertSound; + this._alertSoundVol = 100; + this._alertSoundPitch = 100; + this._alertSoundPan = 0; + this._alertTimer = 0; + this._chasePlayer = false; + this._chaseRange = 0; + this._chaseSpeed = this._moveSpeed; + this._defaultSpeed = this._moveSpeed; + this._fleePlayer = false; + this._fleeRange = 0; + this._fleeSpeed = this._moveSpeed; + this._seePlayer = Yanfly.Param.ECPSeePlayer; + this._sightLock = Yanfly.Param.ECPSightLock; + this._returnAfter = Yanfly.Param.ECPReturn; + this._returnWait = Yanfly.Param.ECPReturnWait; + this._returnPhase = false; + this._returnFrames = 0; + this._staggerCount = 0; + this._startLocationX = this.x; + this._startLocationY = this.y; + this._startLocationDir = this._direction; +}; + +Yanfly.ECP.Game_Event_updateSelfMovement = + Game_Event.prototype.updateSelfMovement; +Game_Event.prototype.updateSelfMovement = function() { + if (Imported.YEP_StopAllMove && $gameSystem.isEventMoveStopped()) return; + this.updateChaseDistance(); + this.updateFleeDistance(); + this.updateChaseMovement(); +}; + +Yanfly.ECP.Game_Event_update = Game_Event.prototype.update; +Game_Event.prototype.update = function() { + Yanfly.ECP.Game_Event_update.call(this); + this.updateAlert(); + this.updateReturnPhase(); +}; + +Game_Event.prototype.canSeePlayer = function() { + if (!this._seePlayer) return false; + var sx = this.deltaXFrom($gamePlayer.x); + var sy = this.deltaYFrom($gamePlayer.y); + if (Math.abs(sx) > Math.abs(sy)) { + var direction = (sx > 0) ? 4 : 6; + } else { + var direction = (sy > 0) ? 8 : 2; + } + if (direction === this.direction()) { + this._alertLock = this._sightLock; + return true; + } + return false; +}; + +Game_Event.prototype.updateChaseDistance = function() { + if (this._erased) return; + if (this._chaseRange <= 0) return; + var dis = Math.abs(this.deltaXFrom($gamePlayer.x)); + dis += Math.abs(this.deltaYFrom($gamePlayer.y)); + if (this.chaseConditions(dis)) { + this.startEventChase(); + } else if (this._chasePlayer) { + this.endEventChase(); + } +}; + +Game_Event.prototype.chaseConditions = function(dis) { + if (dis <= this._chaseRange && this.nonSeePlayer()) { + this._alertLock = this._sightLock; + return true; + } + if (this._alertLock > 0) return true; + if (dis <= this._chaseRange && this.canSeePlayer()) return true; + return false; +}; + +Game_Event.prototype.nonSeePlayer = function() { + if (Imported.YEP_X_EventChaseStealth) { + if (this.meetStealthModeConditions()) { + this.stealthClearChaseSettings(); + this._stopCount = 0; + return false; + } + } + return !this._seePlayer; +}; + +Game_Event.prototype.startEventChase = function() { + this._chasePlayer = true; + this.setMoveSpeed(this._chaseSpeed); +}; + +Game_Event.prototype.endEventChase = function() { + this._chasePlayer = false; + this.setMoveSpeed(this._defaultSpeed); + if (this._alertTimer <= 0) this._alertPlayer = false; + this.startReturnPhase(); +}; + +Game_Event.prototype.updateFleeDistance = function() { + if (this._erased) return; + if (this._fleeRange <= 0) return; + var dis = Math.abs(this.deltaXFrom($gamePlayer.x)); + dis += Math.abs(this.deltaYFrom($gamePlayer.y)); + if (this.fleeConditions(dis)) { + this.startEventFlee(); + } else if (this._fleePlayer) { + this.endEventFlee(); + } +}; + +Game_Event.prototype.fleeConditions = function(dis) { + if (this._alertLock > 0) return true; + if (dis <= this._fleeRange && this.canSeePlayer()) return true; + if (dis <= this._fleeRange && !this._seePlayer) { + this._alertLock = this._sightLock; + return true; + } + return false; +}; + +Game_Event.prototype.startEventFlee = function() { + this._fleePlayer = true; + this.setMoveSpeed(this._fleeSpeed); +}; + +Game_Event.prototype.endEventFlee = function() { + this._fleePlayer = false; + this.setMoveSpeed(this._defaultSpeed); + if (this._alertTimer <= 0) this._alertPlayer = false; + this.startReturnPhase(); +}; + +Game_Event.prototype.updateChaseMovement = function() { + if (this._staggerCount > 0) { + return this._staggerCount--; + } + if (this._stopCount > 0 && this._chasePlayer) { + var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y); + if (direction > 0) { + var x = this._x; + var y = this._y; + this.moveStraight(direction); + if (x === this._x && y === this._y) this._staggerCount = 20; + } + } else if (this._stopCount > 0 && this._fleePlayer) { + this.updateFleeMovement(); + } else if (this._returnPhase) { + this.updateMoveReturnAfter(); + } else { + Yanfly.ECP.Game_Event_updateSelfMovement.call(this); + } +}; + +Game_Event.prototype.updateFleeMovement = function() { + switch (Math.randomInt(6)) { + case 0: case 1: case 2: case 3: case 4: + this.moveAwayFromPlayer(); + break; + case 5: + this.moveRandom(); + break; + } +}; + +Game_Event.prototype.updateAlert = function() { + if (this._erased) return; + this._alertLock--; + if (this.alertConditions()) this.activateAlert(); + if (this._alertPlayer) this._alertTimer--; +}; + +Game_Event.prototype.alertConditions = function() { + return (this._chasePlayer || this._fleePlayer) && !this._alertPlayer; +}; + +Game_Event.prototype.activateAlert = function() { + if (this._alertBalloon >= 0) this.requestBalloon(this._alertBalloon); + this._alertPlayer = true; + this._alertTimer = Yanfly.Param.ECPAlertTimer; + this.playAlertSound(); + this.playAlertCommonEvent(); +}; + +Game_Event.prototype.playAlertSound = function() { + if (this._alertSound === '') return; + var sound = { + name: this._alertSound, + volume: this._alertSoundVol, + pitch: this._alertSoundPitch, + pan: this._alertSoundPan + }; + AudioManager.playSe(sound); +}; + +Game_Event.prototype.playAlertCommonEvent = function() { + if (this._alertCommonEvent <= 0) return; + $gameTemp.reserveCommonEvent(this._alertCommonEvent); +}; + +Game_Event.prototype.startReturnPhase = function() { + if (!this._returnAfter) return; + this._returnPhase = true; + this._returnFrames = this._returnWait; +}; + +Game_Event.prototype.updateReturnPhase = function() { + if (this._returnPhase) this._returnFrames--; +}; + +Game_Event.prototype.updateMoveReturnAfter = function() { + if (this._returnFrames > 0) return; + var sx = this.deltaXFrom(this._startLocationX); + var sy = this.deltaYFrom(this._startLocationY); + if (Math.abs(sx) > Math.abs(sy)) { + if (Math.randomInt(6) <= 4) { + this.moveStraight(sx > 0 ? 4 : 6); + if (!this.isMovementSucceeded() && sy !== 0) { + this.moveStraight(sy > 0 ? 8 : 2); + } + } else { + this.moveRandom(); + } + } else if (sy !== 0) { + if (Math.randomInt(6) <= 4) { + this.moveStraight(sy > 0 ? 8 : 2); + if (!this.isMovementSucceeded() && sx !== 0) { + this.moveStraight(sx > 0 ? 4 : 6); + } + } else { + this.moveRandom(); + } + } + if (sx === 0 && sy === 0) { + this._returnPhase = false; + this._returnFrames = 0; + this._direction = this._startLocationDir; + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_FpsSynchOption.js b/js/plugins/YEP_FpsSynchOption.js new file mode 100644 index 0000000..39bf5c7 --- /dev/null +++ b/js/plugins/YEP_FpsSynchOption.js @@ -0,0 +1,247 @@ +//============================================================================= +// Yanfly Engine Plugins - FPS Synch Option +// YEP_FpsSynchOption.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_SynchFpsOption = true; + +var Yanfly = Yanfly || {}; +Yanfly.FpsSynch = Yanfly.FpsSynch || {}; +Yanfly.FpsSynch.version = 1.03; + +//============================================================================= + /*: + * @plugindesc v1.03 Adds a new command to Options menu for synching + * the FPS of moniters with higher FPS rates. + * @author Yanfly Engine Plugins + * + * @param Command Name + * @desc Command name used inside of the Options menu. + * @default Synch Monitor FPS + * + * @param Default Setting + * @type boolean + * @on ON + * @off OFF + * @desc The default setting of the Synch Monitor FPS. + * OFF - false (Recommended) ON - true + * @default false + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin is to be used with RPG Maker MV version 1.1.0 and upward. + * + * RPG Maker MV is constructed in a way where each update to its engine is done + * once per frame update. While this is normally fine, as many players view the + * game through 60 fps, some players experience the game differently as their + * hardware may run at higher than 60 fps. + * + * When RPG Maker MV version 1.1.0 is implemented, it implemented Galenmereth's + * fluid timestep, which forces the game to always play as if it is 60 fps. In + * practice, this is great for everybody because players that experience more + * 60 fps will be able to play the game as if it was 60 fps. + * + * However, there comes a problem when a player's hardware isn't strong enough + * to support RPG Maker MV natively at 60 fps (such as the case with older + * computers, or weaker mobile devices) or if the player is using video + * recording software that goes below 60 fps. The game will appear laggy and + * jumping without good response rates from input commands or possibly even + * make the player miss out on certain visual frame updates. + * + * This plugin places a setting in the Options menu to enable or disable the + * fluid timestep addition and utilize the former RPG Maker MV engine updating + * function. This way, players will have the option of using fluid timesteps or + * opting to not use it instead of forcing it on everybody who may not be able + * to handle it. + * + * ============================================================================ + * Options Core Settings - Adding the New Options + * ============================================================================ + * + * If you are using YEP_OptionsCore.js, you can add a new Option using this + * plugin. Here's the following code/parameter settings you can use with it. + * + * --------- + * Settings: + * --------- + * + * Name: + * \i[302]Synch Monitor FPS + * + * Help Description: + * Turn this ON if your monitor runs above 60 FPS + * to synchronize the game to run at 60 FPS. + * + * Symbol: + * synchFps + * + * Show/Hide: + * show = Imported.YEP_SynchFpsOption; + * + * Enable: + * enabled = true; + * + * Ext: + * ext = 0; + * + * ---------- + * Functions: + * ---------- + * + * Make Option Code: + * this.addCommand(name, symbol, enabled, ext); + * + * Draw Option Code: + * var rect = this.itemRectForText(index); + * var statusWidth = this.statusWidth(); + * var titleWidth = rect.width - statusWidth; + * this.resetTextColor(); + * this.changePaintOpacity(this.isCommandEnabled(index)); + * this.drawOptionsName(index); + * this.drawOptionsOnOff(index); + * + * Process OK Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, !value); + * + * Cursor Right Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, true); + * + * Cursor Left Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, false); + * + * Default Config Code: + * // Empty. Provided by this plugin. + * + * Save Config Code: + * // Empty. Provided by this plugin. + * + * Load Config Code: + * // Empty. Provided by this plugin. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.03: + * - Compatibility update with YEP_OptionsCore.js. + * + * Version 1.02: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.01: + * - The plugin is now prevented if the project's core files are under version + * RPG Maker MV 1.1.0. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.1.0') { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_FpsSynchOption'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.FpsSynchCmd = String(Yanfly.Parameters['Command Name']); +Yanfly.Param.FpsSDefault = eval(String(Yanfly.Parameters['Default Setting'])); + +//============================================================================= +// MainCode +//============================================================================= + +ConfigManager.synchFps = Yanfly.Param.FpsSDefault; + +Yanfly.FpsSynch.ConfigManager_makeData = ConfigManager.makeData; +ConfigManager.makeData = function() { + var config = Yanfly.FpsSynch.ConfigManager_makeData.call(this); + config.synchFps = this.synchFps; + return config; +}; + +Yanfly.FpsSynch.ConfigManager_applyData = ConfigManager.applyData; +ConfigManager.applyData = function(config) { + Yanfly.FpsSynch.ConfigManager_applyData.call(this, config); + this.synchFps = this.readConfigFpsSynch(config, 'synchFps'); +}; + +ConfigManager.readConfigFpsSynch = function(config, name) { + var value = config[name]; + if (value !== undefined) { + return value; + } else { + return Yanfly.Param.FpsSDefault; + } +}; + +//============================================================================= +// SceneManager +//============================================================================= + +SceneManager.updateMainFluidTimestep = SceneManager.updateMain; + +SceneManager.updateMain = function() { + if (ConfigManager.synchFps) { + this.updateMainFluidTimestep(); + } else { + this.updateMainNoFpsSynch(); + } +}; + +SceneManager.updateMainNoFpsSynch = function() { + this.updateInputData(); + this.changeScene(); + this.updateScene(); + this.renderScene(); + this.requestUpdate(); +}; + +//============================================================================= +// Window_Options +//============================================================================= + +Yanfly.FpsSynch.Window_Options_addGeneralOptions = + Window_Options.prototype.addGeneralOptions; +Window_Options.prototype.addGeneralOptions = function() { + Yanfly.FpsSynch.Window_Options_addGeneralOptions.call(this); + if (!Imported.YEP_OptionsCore) { + this.addCommand(Yanfly.Param.FpsSynchCmd, 'synchFps'); + } +}; + +//============================================================================= +// Version Compatibility Update +//============================================================================= +} else { + +var text = ''; +text += 'You are getting this error because you are trying to run FPS Synch '; +text += 'Options while your project files are lower than version 1.1.0. \n\n'; +text += 'Please visit this thread for instructions on how to update your '; +text += 'project files to 1.1.0 or higher: \n\n'; +text += 'http://forums.rpgmakerweb.com/index.php?/topic/'; +text += '71400-rpg-maker-mv-v134-update/'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.1.0') + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_ItemCore.js b/js/plugins/YEP_ItemCore.js new file mode 100644 index 0000000..3252351 --- /dev/null +++ b/js/plugins/YEP_ItemCore.js @@ -0,0 +1,2223 @@ +//============================================================================= +// Yanfly Engine Plugins - Item Core +// YEP_ItemCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_ItemCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.Item = Yanfly.Item || {}; +Yanfly.Item.version = 1.30; + +//============================================================================= + /*: + * @plugindesc v1.30 Changes the way Items are handled for your game + * and the Item Scene, too. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Max Items + * @parent ---General--- + * @type number + * @min 0 + * @desc Maximum number of items. If this is set to 0, then there + * will be no independent items. + * @default 0 + * + * @param Max Weapons + * @parent ---General--- + * @type number + * @min 0 + * @desc Maximum number of weapons. If this is set to 0, then there + * will be no independent weapons. + * @default 100 + * + * @param Max Armors + * @parent ---General--- + * @type number + * @min 0 + * @desc Maximum number of armors. If this is set to 0, then there + * will be no independent armors. + * @default 100 + * + * @param Starting ID + * @parent ---General--- + * @type number + * @min 1 + * @desc This will be the starting ID number for independent items + * so that they don't interfere with default items. + * @default 3000 + * + * @param Random Variance + * @parent ---General--- + * @type number + * @desc Randomize the stats found for non shop items by this value + * either positive or negative. Set as 0 for no random. + * @default 0 + * + * @param Negative Variance + * @parent ---General--- + * @type boolean + * @on Allow + * @off Disallow + * @desc If using random variance, allow random variance equipment + * stats to go under 0? NO - false YES - true + * @default false + * + * @param Name Format + * @parent ---General--- + * @desc How item names will be ordered and structured. + * %1 - Prefix, %2 - Base Name, %3 - Suffix, %4 Boost + * @default %1%2%3%4 + * + * @param Name Spacing + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Place a space between name prefixes and suffixes? + * NO - false YES - true + * @default true + * + * @param Boost Format + * @parent ---General--- + * @desc This is the text format for a boosted independent item. + * %1 - Boost Amount + * @default (+%1) + * + * @param ---Item Scene--- + * @default + * + * @param Updated Scene Item + * @parent ---Item Scene--- + * @type boolean + * @on Updated (Recommended) + * @off Normal + * @desc Enabling this will change Scene Item's visual appearance. + * NO - false YES - true (recommended) + * @default true + * + * @param List Equipped Items + * @parent ---Item Scene--- + * @type boolean + * @on YES + * @off NO + * @desc Show equipped independent items in the item lists? + * NO - false YES - true + * @default true + * + * @param Show Icon + * @parent ---Item Scene--- + * @type boolean + * @on YES + * @off NO + * @desc Show the icon in the status window? + * NO - false YES - true + * @default true + * + * @param Icon Size + * @parent ---Item Scene--- + * @type number + * @min 0 + * @desc This will be the width and height of the icon to be drawn. + * This is normally 4x the default Icon Width and Icon Height. + * @default 128 + * + * @param Font Size + * @parent ---Item Scene--- + * @type number + * @min 1 + * @desc This changes the font size for description items. + * Default: 28 + * @default 20 + * + * @param Command Alignment + * @parent ---Item Scene--- + * @type combo + * @option left + * @option center + * @option right + * @desc This is the text alignment for the command windows. + * left center right + * @default center + * + * @param Recovery Format + * @parent ---Item Scene--- + * @desc This is the text format for HP/MP Recovery. + * @default %1 Heal + * + * @param Add State + * @parent ---Item Scene--- + * @desc This is the text for adding states. + * @default +State + * + * @param Add Buff + * @parent ---Item Scene--- + * @desc This is the text for adding buffs. + * @default +Buff + * + * @param Remove State + * @parent ---Item Scene--- + * @desc This is the text for remove states. + * @default -State + * + * @param Remove Buff + * @parent ---Item Scene--- + * @desc This is the text for remove buffs. + * @default -Buff + * + * @param Maximum Icons + * @parent ---Item Scene--- + * @type number + * @min 0 + * @desc Maximum number of icons drawn for states and buffs. + * @default 4 + * + * @param Use Command + * @parent ---Item Scene--- + * @desc Command text for using the selected item. + * %1 - Item Icon and Name + * @default Use %1 + * + * @param Carry Format + * @parent ---Item Scene--- + * @desc This is the visual text format for independent item ID. + * %1 - Item Index %2 - Maximum + * @default %1/%2 + * + * @param --Independent Items-- + * @default + * + * @param Midgame Note Parsing + * @parent ---Independent Items--- + * @type boolean + * @on YES + * @off NO (Recommended) + * @desc Allow midgame note parsing or do it at beginning? + * NO - false YES - true Recommended: false + * @default false + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin makes a couple of main changes to your game and the way items + * are handled to allow a base core for future plugins. + * + * 1. Independent Items + * If you choose to have maximum limit on your items, weapons, and/or armors, + * those items will become independent and have their own individual stats and + * whatnot. Independent items are capable of being upgraded, altered, modified, + * etc. and retain those changed properties independent of other items of the + * same type. Items without a maximum limit (aka 0), will continue working as + * they normally did in RPG Maker MV. + * + * 2. New Scene_Item + * The item scene has been revamped to look a little bit different. With the + * new layout, the item list is no longer two columns, but one. Added are a few + * more windows, such as the item status window (which displays basic item + * information), an item information window (which shows information applied to + * the item via upgrades, etc.), and an item action window, which appears when + * you select an item and it will ask you if you wish to Use the item or any + * action added via plugins (such as upgrading the item). If you wish to not + * use this revamp, you can disable it from the parameters. + * + * 3. Random Variance + * Newly acquired items that aren't from shop can be given randomized stats to + * a small degree for items that are independent. Items can be above the stock + * value or below the stock value by the variance value. If you wish for an + * item to not have a variance value, you can use a notetag to set the variance + * value to 0. If you wish for all of your items to not have a variance value, + * you can set the parameter to 0. + * + * Note: During battle test, independent items are disabled. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * If you are using independent items, items that aren't gained through the + * shop can have a random variance applied to its stats. + * + * Item, Weapon, Armor Notetag + * + * If this item is acquired through non-shop means, it will have random + * stats offset by x amount in either a positive or negative value. + * + * + * Sets an item that is independent by default to become a nonindependent + * item, allowing it to stack and making it unable to be affected by + * independent item modifiers. + * + * + * This sets the item, weapon, or armor's priority name to its database + * entry so that name schemes cannot affect the item. + * + * + * This sets the text color of this item, weapon, or armor to use text color + * x from the window skin. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * If you wish to be able to add items to your player's inventory without the + * random variance being applied to it, you can use the following plugin + * commands to adjust the settings for that. + * + * Plugin Command: + * EnableVarianceStock - Causes all items acquired from this point forward + * to have its variance give stock (nonrandom) values. + * DisableVarianceStock - Causes all items acquired from this point forward + * to have its variance give random values. + * + * A small note is that if you enabled the variance stock values, if the player + * restarts the game by either going through the title screen or just turning + * off the program and starting it back up, the random variance will be in + * effect again. This plugin command is meant to exist as a short term disable. + * + * ============================================================================ + * Eventing Changes + * ============================================================================ + * + * A few changes have been made to eventing in order to adjust for independent + * items. They are as follows: + * + * Event Page Conditions and Conditional Branches: + * Checking to see if an item exists in the party's inventory will differ if + * the item can be independent. Instead, the condition can be fulfilled if + * there is an item, even when upgraded, that has the selected item as the base + * item. This means your Long Sword (+1) will fulfill the condition of having + * the target Long Sword item in the event editor. + * + * Actor Has X Equip: + * Just like the previous condition, this condition will be fulfilled if the + * actor has a weapon whose base item matches the event editor's target item. + * The Long Sword (+1) will fulfill the condition of needing the actor to have + * a Long Sword item equipped. + * + * Change Equipment: + * If the target equipment is independent, the game will first check to see + * if the actor has an item equipped with the matching base item. If not, the + * game will then check to see if the party has a matching base item in the + * inventory first and use that. If not, then the game will create a new stock + * version of the item and equip that to the actor. + * + * ============================================================================ + * Item Name System + * ============================================================================ + * + * For independent items, they have a unique name handling system. Independent + * items consist of four parts: + * + * Prefix Base Name Suffix Boost Count + * + * The prefix, base name, suffix, and boost count are adjusted by plugins. + * Depending on the effects applied, they can be altered or changed. Using the + * name system, an item with a prefix of 'Fiery', base name of 'Sword', suffix + * being 'of Might', and a boost count of 5 will end up looking like: + * + * Fiery Sword of Might (+5) + * + * This item would appear that way only if its various name parts have been + * altered some way or another. However, there is a fifth name convention, and + * that is the priority name. If an item has a priority name, it will completely + * overwrite the current name scheme with just the priority name itself. So even + * if the item's name is 'Fiery Sword of Might (+5)', if the item's priority + * name is 'Legendary Blade', then 'Legendary Blade' will take priority. + * + * ============================================================================ + * Lunatic Mode - On Independent Item Creation + * ============================================================================ + * + * For those with JavaScript experience, you can use the following Lunatic Mode + * to run JavaScript code upon the creation of the item. This only applies to + * newly made independent items. + * + * Item, Weapon, Armor + * + * + * item.price = baseItem.price; + * item.price += Math.floor(Random() * 100); + * + * The 'item' variable refers to the independent item being made. 'baseItem' + * refers to the item's base item. Any alterations made to the 'item' will be + * applied to the independent item. + * + * ============================================================================ + * Lunatic Mode - Custom Info Window Display + * ============================================================================ + * + * If you want to display unique and custom stuff into your info window on the + * side, you can use the following notetags: + * + * + * text + * text + * + * Type in extra information you wish to type in for the item info window + * here, whether it is lore or other information. Text codes can be used. + * Information here is is displayed towards the top of the info window. + * + * + * text + * text + * + * Type in extra information you wish to type in for the item info window + * here, whether it is lore or other information. Text codes can be used. + * Information here is is displayed towards the bottom of the info window. + * + * + * var variableId = 1; + * var value = 500; + * $gameVariables.setValue(variableId, value); + * + * If you know JavaScript, you can use these notetags to run some code before + * displaying any new info. This way, if you plan on using text codes that + * display variable values, you can run a bit of code before displaying them + * to synch up what's shown in the item info window. + * + * ============================================================================ + * Independent Items and Midgame Note Parsing + * ============================================================================ + * + * The "Midgame Note Parsing" option in the plugin parameters is made for any + * plugins that may only parse notetags midgame as opposed to at the loading of + * the game. This is an option that you should enable AT YOUR OWN RISK. + * + * Why is it at your own risk? Because enabling this option means independent + * items will keep their notedata, thus, increasing the file sizes of your save + * files several times bigger, and it can cause lag midgame, too. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.30: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.29: + * - Updated for RPG Maker MV version 1.6.0: + * Removal of the destructive code in Scene_Item.update function. + * + * Version 1.28: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.27: + * - Compatibility update for future plugins. + * + * Version 1.26: + * - Lunatic Mode fail safes added. + * + * Version 1.25: + * - Optimization Update + * + * Version 1.24a: + * - Fixed a typo within the code. Please update Item Core, Item Disassemble, + * Attachable Augments, and More Currencies if you are using those plugins. + * - Random variance is now disabled from fresh plugin installation by default. + * + * Version 1.23: + * - Fixed an issue custom info text when using different font sizes. + * + * Version 1.22: + * - Fixed a removal bug that caused weapon and armor ID's to clash. + * + * Version 1.21: + * - Fixed an error with sorting algorithm when items have the same base ID. + * + * Version 1.20: + * - Added Lunatic Mode notetag. Read the help file for more + * information about it. + * + * Version 1.19: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.18a: + * - Added 'Midgame Note Parsing' plugin parameter. + * - Fixed a visual error with MP recovery displaying a 0 instead of ---. + * + * Version 1.17: + * - Added notetag for items, weapons, and armors. + * + * Version 1.16: + * - Fixed a bug that made mid-game actor initialization not display items + * correctly in the item menu. + * + * Version 1.15: + * - Fixed a bug with independent items getting values that crash the game. + * + * Version 1.14: + * - Fixed an unintended function of the game not granting a piece of equipment + * through events. + * + * Version 1.13: + * - Fixed a bug that didn't unequip items properly. + * + * Version 1.12: + * - Added 'Negative Variance' parameter. + * + * Version 1.11: + * - Fixed a bug that caused random variance to not calculate correctly. + * - Fixed a bug that didn't return the correct conditional branch results. + * - Fixed the display in the shop window to show number of independent items + * owned by the player rather than just 0. + * + * Version 1.10: + * - Added Lunatic Mode - Custom Info Window Display. + * + * Version 1.09: + * - Fixed a bug with evented item removal that didn't remove equipped items if + * the 'Include Equipment' checkbox was checked. + * + * Version 1.08: + * - Fixed a bug with the Control Variable event that would not gather the + * right amount of independent items. + * + * Version 1.07: + * - Fixed a bug with the Change Equipment event where armors wouldn't equip. + * + * Version 1.06: + * - Fixed a bug and rewrote the initializing equipment process. + * + * Version 1.05: + * - Compatibility update with ItemBook. + * + * Version 1.04: + * - Added 'List Equipped Items' parameter to allow for equipment restricted + * actors to be able to alt their equipment. + * + * Version 1.03: + * - Fixed a bug where using events to remove independent items weren't working + * properly and instead added more items. + * - Fixed a bug where a Random Variance of 0 still gave random stats. + * + * Version 1.02: + * - Fixed a bug where initializing equipment slots didn't work properly and/or + * added incorrect equips from the wrong actors into the inventory. + * + * Version 1.01: + * - Fixed bug where if you are using no independent pieces of equipment, + * actors would fail to start with initial equipment. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_ItemCore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.ItemMaxItems = Number(Yanfly.Parameters['Max Items']); +Yanfly.Param.ItemMaxWeapons = Number(Yanfly.Parameters['Max Weapons']); +Yanfly.Param.ItemMaxArmors = Number(Yanfly.Parameters['Max Armors']); +Yanfly.Param.ItemStartingId = Number(Yanfly.Parameters['Starting ID']); +Yanfly.Param.ItemRandomVariance = Number(Yanfly.Parameters['Random Variance']); +Yanfly.Param.ItemNegVar = eval(String(Yanfly.Parameters['Negative Variance'])); +Yanfly.Param.ItemNameFmt = String(Yanfly.Parameters['Name Format']); +Yanfly.Param.ItemNameSpacing = String(Yanfly.Parameters['Name Spacing']); +Yanfly.Param.ItemBoostFmt = String(Yanfly.Parameters['Boost Format']); + +Yanfly.Param.ItemSceneItem = String(Yanfly.Parameters['Updated Scene Item']); +Yanfly.Param.ItemSceneItem = eval(Yanfly.Param.ItemSceneItem); +Yanfly.Param.ItemShEquipped = String(Yanfly.Parameters['List Equipped Items']); +Yanfly.Param.ItemShEquipped = eval(Yanfly.Param.ItemShEquipped); +Yanfly.Param.ItemShowIcon = String(Yanfly.Parameters['Show Icon']); +Yanfly.Param.ItemShowIcon = eval(Yanfly.Param.ItemShowIcon); +Yanfly.Param.ItemIconSize = Number(Yanfly.Parameters['Icon Size']); +Yanfly.Param.ItemFontSize = Number(Yanfly.Parameters['Font Size']); +Yanfly.Param.ItemCmdAlign = String(Yanfly.Parameters['Command Alignment']); +Yanfly.Param.ItemRecoverFmt = String(Yanfly.Parameters['Recovery Format']); +Yanfly.Param.ItemAddState = String(Yanfly.Parameters['Add State']); +Yanfly.Param.ItemAddBuff = String(Yanfly.Parameters['Add Buff']); +Yanfly.Param.ItemRemoveState = String(Yanfly.Parameters['Remove State']); +Yanfly.Param.ItemRemoveBuff = String(Yanfly.Parameters['Remove Buff']); +Yanfly.Param.ItemMaxIcons = Number(Yanfly.Parameters['Maximum Icons']); +Yanfly.Param.ItemUseCmd = String(Yanfly.Parameters['Use Command']); +Yanfly.Param.ItemCarryFmt = String(Yanfly.Parameters['Carry Format']); + +Yanfly.Param.ItemNoteParse = String(Yanfly.Parameters['Midgame Note Parsing']); +Yanfly.Param.ItemNoteParse = eval(Yanfly.Param.ItemNoteParse); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.Item.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.Item.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_ItemCore) { + this.setDatabaseLengths(); + this.processItemCoreNotetags($dataItems); + this.processItemCoreNotetags($dataWeapons); + this.processItemCoreNotetags($dataArmors); + Yanfly._loaded_YEP_ItemCore = true; + } + return true; +}; + +DataManager.processItemCoreNotetags = function(group) { + var note1 = /<(?:RANDOM VARIANCE):[ ](\d+)>/i; + var note2 = /<(?:NONINDEPENDENT ITEM|not independent item)>/i; + var note3 = /<(?:PRIORITY NAME)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.randomVariance = Yanfly.Param.ItemRandomVariance; + obj.textColor = 0; + if (Imported.YEP_CoreEngine) obj.textColor = Yanfly.Param.ColorNormal; + obj.nonIndependent = false; + obj.setPriorityName = false; + obj.infoEval = ''; + obj.infoTextTop = ''; + obj.infoTextBottom = ''; + obj.onCreationEval = ''; + var evalMode = 'none'; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + obj.randomVariance = parseInt(RegExp.$1); + } else if (line.match(note2)) { + obj.nonIndependent = true; + } else if (line.match(note3)) { + obj.setPriorityName = true; + } else if (line.match(/<(?:INFO EVAL)>/i)) { + evalMode = 'info eval'; + } else if (line.match(/<\/(?:INFO EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:INFO TEXT TOP)>/i)) { + evalMode = 'info text top'; + } else if (line.match(/<\/(?:INFO TEXT TOP)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:INFO TEXT BOTTOM)>/i)) { + evalMode = 'info text bottom'; + } else if (line.match(/<\/(?:INFO TEXT BOTTOM)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'info eval') { + obj.infoEval = obj.infoEval + line + '\n'; + } else if (evalMode === 'info text top') { + if (obj.infoTextTop !== '') obj.infoTextTop += '\n'; + obj.infoTextTop = obj.infoTextTop + line; + } else if (evalMode === 'info text bottom') { + if (obj.infoTextBottom !== '') obj.infoTextBottom += '\n'; + obj.infoTextBottom = obj.infoTextBottom + line; + } else if (line.match(/<(?:TEXT COLOR):[ ](\d+)>/i)) { + obj.textColor = parseInt(RegExp.$1); + } else if (line.match(/<(?:ON CREATE EVAL|ON CREATION EVAL)>/i)) { + evalMode = 'on create eval'; + } else if (line.match(/<\/(?:ON CREATE EVAL|ON CREATION EVAL)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'on create eval') { + obj.onCreationEval = obj.onCreationEval + line + '\n'; + } + } + } +}; + +DataManager.setDatabaseLengths = function() { + this._baseItemsLength = $dataItems.length + this._baseWeaponsLength = $dataWeapons.length + this._baseArmorsLength = $dataArmors.length +}; + +Yanfly.Item.DataManager_createGameObjects = + DataManager.createGameObjects; +DataManager.createGameObjects = function() { + Yanfly.Item.DataManager_createGameObjects.call(this); + this.createIndependentObjects(); +}; + +DataManager.createIndependentObjects = function() { + DataManager.createIndependentGroups(); + this.loadIndependentItems(); +}; + +DataManager.loadIndependentItems = function() { + if (Yanfly.Param.ItemMaxItems > 0) { + var difItems = $dataItems.length - DataManager._baseItemsLength; + $dataItems.splice(DataManager._baseItemsLength, difItems); + this.setIndependentLength($dataItems); + $dataItems = $dataItems.concat(this._independentItems); + } + if (Yanfly.Param.ItemMaxWeapons > 0) { + var difWeapons = $dataWeapons.length - DataManager._baseWeaponsLength; + $dataWeapons.splice(DataManager._baseWeaponsLength, difWeapons); + this.setIndependentLength($dataWeapons); + $dataWeapons = $dataWeapons.concat(this._independentWeapons); + } + if (Yanfly.Param.ItemMaxArmors > 0) { + var difArmors = $dataArmors.length - DataManager._baseArmorsLength; + $dataArmors.splice(DataManager._baseArmorsLength, difArmors); + this.setIndependentLength($dataArmors); + $dataArmors = $dataArmors.concat(this._independentArmors); + } +}; + +DataManager.setIndependentLength = function(group) { + for (;;) { + if (group.length > Yanfly.Param.ItemStartingId) break; + group.push(null); + } +}; + +DataManager.saveGameWithoutRescue = function(savefileId) { + var json = JsonEx.stringify(this.makeSaveContents()); + StorageManager.save(savefileId, json); + this._lastAccessedId = savefileId; + var globalInfo = this.loadGlobalInfo() || []; + globalInfo[savefileId] = this.makeSavefileInfo(); + this.saveGlobalInfo(globalInfo); + return true; +}; + +Yanfly.Item.DataManager_makeSaveContents = DataManager.makeSaveContents; +DataManager.makeSaveContents = function() { + var contents = Yanfly.Item.DataManager_makeSaveContents.call(this); + contents.items = this._independentItems; + contents.weapons = this._independentWeapons; + contents.armors = this._independentArmors; + return contents; +}; + +Yanfly.Item.DataManager_extractSaveContents = + DataManager.extractSaveContents; +DataManager.extractSaveContents = function(contents) { + Yanfly.Item.DataManager_extractSaveContents.call(this, contents); + this._independentItems = contents.items || []; + this._independentWeapons = contents.weapons || []; + this._independentArmors = contents.armors || []; + this.loadIndependentItems(); +}; + +DataManager.createIndependentGroups = function() { + this._independentItems = []; + this._independentWeapons = []; + this._independentArmors = []; +}; + +DataManager.isIndependent = function(item) { + if (!item) return false; + if (DataManager.isBattleTest()) return false; + if (item.nonIndependent) return false; + if (DataManager.isItem(item)) return Yanfly.Param.ItemMaxItems > 0; + if (DataManager.isWeapon(item)) return Yanfly.Param.ItemMaxWeapons > 0; + if (DataManager.isArmor(item)) return Yanfly.Param.ItemMaxArmors > 0; + return false; +}; + +DataManager.registerNewItem = function(item) { + if (!this.isNewItemValid(item)) return item; + var newItem = JsonEx.makeDeepCopy(item); + this.addNewIndependentItem(item, newItem); + return newItem; +}; + +DataManager.isNewItemValid = function(item) { + if (!item) return false; + if (item.baseItemId) return false; + return item.id === this.getDatabase(item).indexOf(item); +}; + +DataManager.addNewIndependentItem = function(baseItem, newItem) { + newItem.id = this.getDatabase(baseItem).length; + ItemManager.setNewIndependentItem(baseItem, newItem); + ItemManager.customizeNewIndependentItem(baseItem, newItem); + ItemManager.onCreationEval(baseItem, newItem); + this.getDatabase(baseItem).push(newItem); + this.getContainer(baseItem).push(newItem); +}; + +DataManager.removeIndependentItem = function(item) { + if (!item) return; + if (this.independentItemIsUsed(item)) return; + var container = this.getContainer(item); + var database = this.getDatabase(item); + var index = container.indexOf(item); + container[index] = null; + var index = database.indexOf(item); + database[index] = null; +}; + +DataManager.independentItemIsUsed = function(item) { + if ($gameParty.numItems(item) > 0) return false; + for (var i = 0; i < $dataActors.length; ++i) { + var actor = $gameActors.actor(i); + if (!actor) continue; + if (actor.equips().contains(item)) return true; + } + return false; +}; + +DataManager.getDatabase = function(item) { + if (!item) return []; + if (DataManager.isItem(item)) return $dataItems; + if (DataManager.isWeapon(item)) return $dataWeapons; + if (DataManager.isArmor(item)) return $dataArmors; + return []; +}; + +DataManager.getContainer = function(item) { + if (!item) return []; + if (DataManager.isItem(item)) return this._independentItems; + if (DataManager.isWeapon(item)) return this._independentWeapons; + if (DataManager.isArmor(item)) return this._independentArmors; + return []; +}; + +DataManager.getBaseItem = function(item) { + if (!this.isIndependent(item)) return item; + if (!item.baseItemId) return item; + var baseItemId = item.baseItemId; + var baseItem = this.getDatabase(item)[baseItemId]; + return baseItem; +}; + +//============================================================================= +// ItemManager +//============================================================================= + +function ItemManager() { + throw new Error('This is a static class'); +}; + +ItemManager.setNewIndependentItem = function(baseItem, newItem) { + newItem.baseItemId = baseItem.id; + newItem.baseItemName = baseItem.name; + newItem.baseItemPrice = baseItem.price; + newItem.baseItemIconIndex = baseItem.iconIndex; + newItem.namePrefix = ''; + newItem.nameSuffix = ''; + if (baseItem.setPriorityName) { + newItem.priorityName = baseItem.name; + } else { + newItem.priorityName = ''; + } + newItem.boostCount = 0; + if (!Yanfly.Param.ItemNoteParse) newItem.note = ''; +}; + +ItemManager.customizeNewIndependentItem = function(baseItem, newItem) { + this.randomizeInitialItem(baseItem, newItem); + this.updateItemName(newItem); +}; + +ItemManager.randomizeInitialItem = function(baseItem, newItem) { + if ($gameTemp.varianceStock()) return; + if (DataManager.isItem(baseItem)) { + this.randomizeInitialEffects(baseItem, newItem); + } else { + this.randomizeInitialStats(baseItem, newItem); + } +}; + +ItemManager.randomizeInitialEffects = function(baseItem, newItem) { + if (baseItem.randomVariance <= 0) return; + var randomValue = baseItem.randomVariance * 2 + 1; + var offset = baseItem.randomVariance; + newItem.effects.forEach(function(effect) { + if (effect.code === Game_Action.EFFECT_RECOVER_HP) { + if (effect.value1 !== 0) { + var boost = Math.floor(Math.random() * randomValue - offset); + effect.value1 += boost * 0.01; + effect.value1 = parseFloat(effect.value1.toFixed(2)); + effect.value1 = effect.value1.clamp(0, 1); + } + if (effect.value2 !== 0) { + effect.value2 += Math.floor(Math.random() * randomValue - offset); + } + } + if (effect.code === Game_Action.EFFECT_RECOVER_MP) { + if (effect.value1 !== 0) { + var boost = Math.floor(Math.random() * randomValue - offset); + effect.value1 += boost * 0.01; + effect.value1 = parseFloat(effect.value1.toFixed(2)); + effect.value1 = effect.value1.clamp(0, 1); + } + if (effect.value2 !== 0) { + effect.value2 += Math.floor(Math.random() * randomValue - offset); + } + } + }, this); +}; + +ItemManager.randomizeInitialStats = function(baseItem, newItem) { + if (baseItem.randomVariance <= 0) return; + var randomValue = baseItem.randomVariance * 2 + 1; + var offset = baseItem.randomVariance; + for (var i = 0; i < 8; ++i) { + if (newItem.params[i] === 0) continue; + newItem.params[i] += Math.floor(Math.random() * randomValue - offset); + if (!Yanfly.Param.ItemNegVar && baseItem.params[i] >= 0) { + newItem.params[i] = Math.max(newItem.params[i], 0); + } + } +}; + +ItemManager.setBaseName = function(item, value) { + item.baseItemName = value; +}; + +ItemManager.setNamePrefix = function(item, value) { + item.namePrefix = value; + if (eval(Yanfly.Param.ItemNameSpacing) && item.namePrefix.length > 0) { + item.namePrefix = item.namePrefix + ' '; + } +}; + +ItemManager.setNameSuffix = function(item, value) { + item.nameSuffix = value; + if (eval(Yanfly.Param.ItemNameSpacing) && item.nameSuffix.length > 0) { + item.nameSuffix = ' ' + item.nameSuffix; + } +}; + +ItemManager.setPriorityName = function(item, value) { + item.priorityName = value; +}; + +ItemManager.updateItemName = function(item) { + if (item.priorityName && item.priorityName.length > 0) { + item.name = item.priorityName; + return; + } + var prefix = item.namePrefix || ''; + var baseName = item.baseItemName || ''; + var suffix = item.nameSuffix || ''; + var boostCount = item.boostCount || 0; + var fmt = Yanfly.Param.ItemBoostFmt; + var boostText = fmt.format(Yanfly.Util.toGroup(boostCount)) + if (boostText === fmt.format(0)) { + boostText = ''; + } else if (eval(Yanfly.Param.ItemNameSpacing)) { + boostText = ' ' + boostText; + } + fmt = Yanfly.Param.ItemNameFmt; + item.name = fmt.format(prefix, baseName, suffix, boostText); +}; + +ItemManager.increaseItemBoostCount = function(item, value) { + value = value || 1; + if (!item.boostCount) item.boostCount = 0; + item.boostCount += value; + this.updateItemName(item); +}; + +ItemManager.onCreationEval = function(baseItem, newItem) { + var item = newItem; + if (item.onCreationEval === '') return; + var weapon = item; + var armor = item; + var baseWeapon = baseItem; + var baseArmor = baseItem; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.onCreationEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'ITEM CREATION CUSTOM CODE ERROR'); + } + item.onCreationEval = ''; +}; + +//============================================================================= +// Game_Temp +//============================================================================= + +Game_Temp.prototype.enableVarianceStock = function() { + this._independentStock = true; +}; + +Game_Temp.prototype.disableVarianceStock = function() { + this._independentStock = false; +}; + +Game_Temp.prototype.varianceStock = function() { + return this._independentStock; +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Yanfly.Item.Game_Actor_setup = Game_Actor.prototype.setup; +Game_Actor.prototype.setup = function(actorId) { + Yanfly.Item.Game_Actor_setup.call(this, actorId); + if ($gameTemp._initializeStartingMemberEquipment) return; + this.initIndependentEquips($dataActors[actorId].equips); +}; + +Game_Actor.prototype.initIndependentEquips = function(equips) { + var equips = this.convertInitEquips(equips); + this.equipInitIndependentEquips(equips); + this.releaseUnequippableItems(true); + this.recoverAll(); + this.refresh(); +}; + +Game_Actor.prototype.convertInitEquips = function(equips) { + var items = []; + for (var i = 0; i < equips.length; ++i) { + var equipId = equips[i]; + if (equipId <= 0) continue; + var equipType = $dataSystem.equipTypes[i + 1]; + if (equipType === $dataSystem.equipTypes[1] || + (i === 1 && this.isDualWield())) { + var equip = $dataWeapons[equipId]; + } else { + var equip = $dataArmors[equipId]; + } + items.push(equip); + } + return items; +}; + +Game_Actor.prototype.equipInitIndependentEquips = function(equips) { + var slots = this.equipSlots(); + var maxSlots = slots.length; + this._equips = []; + for (var i = 0; i < maxSlots; ++i) { + this._equips[i] = new Game_Item(); + } + for (var i = 0; i < maxSlots; ++i) { + var slotType = slots[i]; + var equip = this.grabInitEquips(equips, slotType); + if (DataManager.isIndependent(equip) && this.canEquip(equip)) { + var array = $gameParty.gainIndependentItem(equip, 1) + if (array instanceof Array) { + newItem = array[0]; + this.changeEquip(i, newItem); + } + } else if (this.canEquip(equip)) { + this._equips[i].setObject(equip); + } + } +}; + +Game_Actor.prototype.grabInitEquips = function(equips, slotType) { + var item = null; + for (var i = 0; i < equips.length; ++i) { + var equip = equips[i]; + if (!equip) continue; + if (slotType === 1 && DataManager.isWeapon(equip)) { + item = equip; + break; + } else if (equip.etypeId === slotType) { + item = equip; + break; + } + } + if (item) equips[i] = null; + return item; +}; + +Yanfly.Item.Game_Actor_hasWeapon = Game_Actor.prototype.hasWeapon; +Game_Actor.prototype.hasWeapon = function(weapon) { + if (this.hasBaseItem(weapon)) return true; + return Yanfly.Item.Game_Actor_hasWeapon.call(this, weapon); +}; + +Yanfly.Item.Game_Actor_hasArmor = Game_Actor.prototype.hasArmor; +Game_Actor.prototype.hasArmor = function(armor) { + if (this.hasBaseItem(armor)) return true; + return Yanfly.Item.Game_Actor_hasArmor.call(this, armor); +}; + +Game_Actor.prototype.hasBaseItem = function(baseItem) { + if (!DataManager.isIndependent(baseItem)) return false; + var type = (DataManager.isWeapon(baseItem)) ? 'weapon' : 'armor'; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (!equip.baseItemId) continue; + if (DataManager.isWeapon(equip) && type === 'weapon') { + if (equip.baseItemId === baseItem.id) return true; + } else if (DataManager.isArmor(equip) && type === 'armor') { + if (equip.baseItemId === baseItem.id) return true; + } + } + return false; +}; + +Yanfly.Item.Game_Actor_changeEquipById = Game_Actor.prototype.changeEquipById; +Game_Actor.prototype.changeEquipById = function(etypeId, itemId) { + if (itemId > 0) { + var slotId = etypeId - 1; + if (this.equipSlots()[slotId] === 1) { + var baseItem = $dataWeapons[itemId]; + } else { + var baseItem = $dataArmors[itemId]; + } + if (!$gameParty.hasItem(baseItem)) { + $gameParty.gainItem(baseItem, 1); + } + if (DataManager.isIndependent(baseItem)) { + if (this.hasBaseItem(baseItem)) return; + var item = $gameParty.getMatchingBaseItem(baseItem, false); + if (item === null) { + $gameTemp.enableVarianceStock(); + $gameParty.gainItem(baseItem, 1); + $gameTemp.disableVarianceStock(); + item = $gameParty.getMatchingBaseItem(baseItem, false); + } + this.changeEquip(slotId, item); + return; + } + } + Yanfly.Item.Game_Actor_changeEquipById.call(this, etypeId, itemId) +}; + +Game_Actor.prototype.unequipItem = function(item) { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip !== item) continue; + this.changeEquip(i, null); + } +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Yanfly.Item.Game_Party_setupStartingMembers = + Game_Party.prototype.setupStartingMembers; +Game_Party.prototype.setupStartingMembers = function() { + Yanfly.Item.Game_Party_setupStartingMembers.call(this); + $gameTemp.enableVarianceStock(); + this.initActorEquips(); + $gameTemp.disableVarianceStock(); +}; + +Game_Party.prototype.initActorEquips = function() { + $gameTemp._initializeStartingMemberEquipment = true; + for (var i = 0; i < $dataActors.length; ++i) { + var actor = $gameActors.actor(i); + if (actor) { + var baseActor = $dataActors[i]; + actor.initIndependentEquips(baseActor.equips); + } + } + $gameTemp._initializeStartingMemberEquipment = undefined; +}; + +Yanfly.Item.Game_Party_gainItem = Game_Party.prototype.gainItem; +Game_Party.prototype.gainItem = function(item, amount, includeEquip) { + if (DataManager.isIndependent(item)) { + this.gainIndependentItem(item, amount, includeEquip); + } else { + Yanfly.Item.Game_Party_gainItem.call(this, item, amount, includeEquip); + } +}; + +Game_Party.prototype.gainIndependentItem = function(item, amount, includeEquip) { + var arr = []; + if (amount > 0) { + for (var i = 0; i < amount; ++i) { + var newItem = DataManager.registerNewItem(item); + this.registerNewItem(item, newItem); + arr.push(newItem); + } + } else if (amount < 0) { + amount = Math.abs(amount); + for (var i = 0; i < amount; ++i) { + if (item.baseItemId) { + this.removeIndependentItem(item, includeEquip); + } else if (DataManager.isIndependent(item)) { + var target = $gameParty.getMatchingBaseItem(item, includeEquip); + if (target !== null) this.removeIndependentItem(target, includeEquip); + } else { + this.removeBaseItem(item, includeEquip); + } + } + } + return arr; +}; + +Game_Party.prototype.getIndependentItemTypeMax = function(item) { + if (!item) return 0; + if (DataManager.isItem(item)) return Yanfly.Param.ItemMaxItems; + if (DataManager.isWeapon(item)) return Yanfly.Param.ItemMaxWeapons; + if (DataManager.isArmor(item)) return Yanfly.Param.ItemMaxArmors; +}; + +Game_Party.prototype.getIndependentItemTypeCur = function(item) { + if (!item) return 0; + if (DataManager.isItem(item)) return this.items().length; + if (DataManager.isWeapon(item)) return this.weapons().length; + if (DataManager.isArmor(item)) return this.armors().length; +}; + +Game_Party.prototype.registerNewItem = function(baseItem, newItem) { + var container = this.itemContainer(baseItem); + if (container) { + var lastNumber = this.numItems(newItem); + container[newItem.id] = 1; + } +}; + +Game_Party.prototype.removeIndependentItem = function(item, includeEquip) { + if (includeEquip && this.checkItemIsEquipped(item)) { + for (var i = 1; i < $gameActors._data.length; ++i) { + var actor = $gameActors.actor(i); + if (!actor) continue; + if (!actor.equips().contains(item)) continue; + actor.unequipItem(item); + } + } + var container = this.itemContainer(item); + container[item.id] = 0; + if (container[item.id] <= 0) delete container[item.id]; + +}; + +Game_Party.prototype.removeBaseItem = function(item, includeEquip) { + var container = this.itemContainer(item); + container[item.id]--; + if (container[item.id] <= 0) delete container[item.id]; + if (includeEquip) this.discardMembersEquip(item, -1); +}; + +Game_Party.prototype.getMatchingBaseItem = function(baseItem, equipped) { + if (!baseItem) return null; + if (DataManager.isItem(baseItem)) var group = this.items(); + if (DataManager.isWeapon(baseItem)) var group = this.weapons(); + if (DataManager.isArmor(baseItem)) var group = this.armors(); + if (equipped) { + for (var a = 0; a < this.members().length; ++a) { + var actor = this.members()[a]; + if (!actor) continue; + if (DataManager.isWeapon(baseItem)) { + group = group.concat(actor.weapons()); + } else if (DataManager.isArmor(baseItem)) { + group = group.concat(actor.armors()); + } + } + } + var baseItemId = baseItem.id; + for (var i = 0; i < group.length; ++i) { + var item = group[i]; + if (!item) continue; + if (!item.baseItemId) continue; + if (item.baseItemId !== baseItemId) continue; + return item; + } + return null; +}; + +Game_Party.prototype.checkItemIsEquipped = function(item) { + for (var i = 1; i < $gameActors._data.length; ++i) { + var actor = $gameActors.actor(i); + if (!actor) continue; + if (actor.equips().contains(item)) return true; + } + return false; +}; + +Yanfly.Item.Game_Party_items = Game_Party.prototype.items; +Game_Party.prototype.items = function() { + var results = Yanfly.Item.Game_Party_items.call(this); + results.sort(this.independentItemSort); + return results; +}; + +Yanfly.Item.Game_Party_weapons = Game_Party.prototype.weapons; +Game_Party.prototype.weapons = function() { + var results = Yanfly.Item.Game_Party_weapons.call(this); + results.sort(this.independentItemSort); + return results; +}; + +Yanfly.Item.Game_Party_armors = Game_Party.prototype.armors; +Game_Party.prototype.armors = function() { + var results = Yanfly.Item.Game_Party_armors.call(this); + results.sort(this.independentItemSort); + return results; +}; + +Game_Party.prototype.independentItemSort = function(a, b) { + var aa = (a.baseItemId) ? a.baseItemId : a.id; + var bb = (b.baseItemId) ? b.baseItemId : b.id; + if (aa < bb) return -1; + if (aa >= bb) return 1; + return 0; +}; + +Yanfly.Item.Game_Party_maxItems = Game_Party.prototype.maxItems; +Game_Party.prototype.maxItems = function(item) { + if (DataManager.isIndependent(item)) return 1; + return Yanfly.Item.Game_Party_maxItems.call(this, item); +}; + +Yanfly.Item.Game_Party_hasItem = Game_Party.prototype.hasItem; +Game_Party.prototype.hasItem = function(item, includeEquip) { + if (DataManager.isIndependent(item)) { + if (this.numIndependentItems(item) > 0) return true; + } + return Yanfly.Item.Game_Party_hasItem.call(this, item, includeEquip); +}; + +Yanfly.Item.Game_Party_isAnyMemberEquipped = + Game_Party.prototype.isAnyMemberEquipped; +Game_Party.prototype.isAnyMemberEquipped = function(item) { + if (DataManager.isIndependent(item)) { + for (var i = 0; i < this.members().length; ++i) { + var actor = this.members()[i]; + if (!actor) continue; + if (actor.hasBaseItem(item)) return true; + } + } + return Yanfly.Item.Game_Party_isAnyMemberEquipped.call(this, item); +}; + +Game_Party.prototype.numIndependentItems = function(baseItem) { + var value = 0; + if (!DataManager.isIndependent(baseItem)) return this.numItems(baseItem); + var id = baseItem.id; + if (DataManager.isItem(baseItem)) var group = this.items(); + if (DataManager.isWeapon(baseItem)) var group = this.weapons(); + if (DataManager.isArmor(baseItem)) var group = this.armors(); + for (var i = 0; i < group.length; ++i) { + var item = group[i]; + if (!item) continue; + if (item.baseItemId && item.baseItemId === id) value += 1; + } + return value; +}; + +Game_Party.prototype.clearAllMatchingBaseItems = function(baseItem, equipped) { + if (!Imported.YEP_ItemCore) return; + for (;;) { + var item = this.getMatchingBaseItem(baseItem, equipped); + if (item) { + this.removeIndependentItem(item, equipped); + DataManager.removeIndependentItem(item); + } else { + break; + } + } +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.Item.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.Item.Game_Interpreter_pluginCommand.call(this, command, args) + if (command === 'EnableVarianceStock') $gameTemp.enableVarianceStock(); + if (command === 'DisableVarianceStock') $gameTemp.disableVarianceStock(); +}; + +Yanfly.Item.Game_Interpreter_gDO = Game_Interpreter.prototype.gameDataOperand; +Game_Interpreter.prototype.gameDataOperand = function(type, param1, param2) { + switch (type) { + case 0: + return $gameParty.numIndependentItems($dataItems[param1]); + break; + case 1: + return $gameParty.numIndependentItems($dataWeapons[param1]); + break; + case 2: + return $gameParty.numIndependentItems($dataArmors[param1]); + break; + default: + return Yanfly.Item.Game_Interpreter_gDO.call(this, type, param1, param2); + break; + } +}; + +//============================================================================= +// Window_Base +//============================================================================= + +Yanfly.Item.Window_Base_drawItemName = Window_Base.prototype.drawItemName; +Window_Base.prototype.drawItemName = function(item, wx, wy, ww) { + ww = ww || 312; + this.setItemTextColor(item); + Yanfly.Item.Window_Base_drawItemName.call(this, item, wx, wy, ww); + this._resetTextColor = undefined; + this.resetTextColor(); +}; + +Window_Base.prototype.setItemTextColor = function(item) { + if (!item) return; + if (item.textColor === undefined) return; + this._resetTextColor = item.textColor; +}; + +Yanfly.Item.Window_Base_normalColor = Window_Base.prototype.normalColor; +Window_Base.prototype.normalColor = function() { + if (this._resetTextColor !== undefined) { + return this.textColor(this._resetTextColor); + } + return Yanfly.Item.Window_Base_normalColor.call(this); +}; + +//============================================================================= +// Window_ItemList +//============================================================================= + +Yanfly.Item.Window_ItemList_makeItemList = + Window_ItemList.prototype.makeItemList; +Window_ItemList.prototype.makeItemList = function() { + Yanfly.Item.Window_ItemList_makeItemList.call(this); + if (SceneManager._scene instanceof Scene_Item) this.listEquippedItems(); +}; + +Window_ItemList.prototype.listEquippedItems = function() { + if (!Yanfly.Param.ItemShEquipped) return; + var results = []; + for (var a = 0; a < $gameParty.members().length; ++a) { + var actor = $gameParty.members()[a]; + if (!actor) continue; + for (var i = 0; i < actor.equips().length; ++i) { + var equip = actor.equips()[i]; + if (!equip) continue; + if (!equip.baseItemId) continue; + if (this.includes(equip)) results.push(equip); + } + } + this._data = results.concat(this._data); +}; + +Yanfly.Item.Window_ItemList_drawItemNumber = + Window_ItemList.prototype.drawItemNumber; +Window_ItemList.prototype.drawItemNumber = function(item, dx, dy, dw) { + if (DataManager.isIndependent(item)) { + this.drawItemCarryNumber(item, dx, dy, dw); + return; + } + Yanfly.Item.Window_ItemList_drawItemNumber.call(this, item, dx, dy, dw); +}; + +Window_ItemList.prototype.drawItemCarryNumber = function(item, dx, dy, dw) { + if (DataManager.isItem(item)) { + var index = $gameParty.items().indexOf(item); + } else if (DataManager.isWeapon(item)) { + var index = $gameParty.weapons().indexOf(item); + } else if (DataManager.isArmor(item)) { + var index = $gameParty.armors().indexOf(item); + } + if (index < 0) return this.drawEquippedActor(item, dx, dy, dw); + index += 1; + var max = $gameParty.getIndependentItemTypeMax(item); + var fmt = Yanfly.Param.ItemCarryFmt; + var text = fmt.format(Yanfly.Util.toGroup(index), Yanfly.Util.toGroup(max)); + if (Yanfly.Param.ItemQuantitySize) { + this.contents.fontSize = Yanfly.Param.ItemQuantitySize; + } + if (index > max) { + this.changeTextColor(this.powerDownColor()); + } else if (index === max) { + this.changeTextColor(this.crisisColor()); + } else { + this.changeTextColor(this.normalColor()); + } + this.drawText(text, dx, dy, dw, 'right'); + this.resetFontSettings(); +}; + +Window_ItemList.prototype.drawEquippedActor = function(item, dx, dy, dw) { + var carrier = null; + for (var a = 0; a < $gameParty.members().length; ++a) { + var actor = $gameParty.members()[a]; + if (!actor) continue; + if (actor.equips().contains(item)) carrier = actor; + }; + if (Yanfly.Param.ItemQuantitySize) { + this.contents.fontSize = Yanfly.Param.ItemQuantitySize; + } + var text = carrier.name(); + this.drawText(text, dx, dy, dw, 'right'); + this.resetFontSettings(); +}; + +//============================================================================= +// Window_EquipItem +//============================================================================= + +Yanfly.Item.Window_EquipItem_includes = Window_EquipItem.prototype.includes; +Window_EquipItem.prototype.includes = function(item) { + if (this._actor && item !== null) { + if (!item) return false; + } + return Yanfly.Item.Window_EquipItem_includes.call(this, item); +}; + +//============================================================================= +// Window_ShopBuy +//============================================================================= + +Yanfly.Item.Window_ShopBuy_isEnabled = Window_ShopBuy.prototype.isEnabled; +Window_ShopBuy.prototype.isEnabled = function(item) { + if (DataManager.isIndependent(item)) { + var typeMax = $gameParty.getIndependentItemTypeMax(item); + var typeCur = $gameParty.getIndependentItemTypeCur(item); + if (typeCur >= typeMax) return false; + } + return Yanfly.Item.Window_ShopBuy_isEnabled.call(this, item); +}; + +//============================================================================= +// Window_ShopStatus +//============================================================================= + +Yanfly.Item.Window_ShopStatus_drawPossession = + Window_ShopStatus.prototype.drawPossession; +Window_ShopStatus.prototype.drawPossession = function(x, y) { + if (DataManager.isIndependent(this._item)) { + return this.drawIndependentPossession(x, y); + } + Yanfly.Item.Window_ShopStatus_drawPossession.call(this, x, y); +}; + +Window_ShopStatus.prototype.drawIndependentPossession = function(x, y) { + var width = this.contents.width - this.textPadding() - x; + var baseItem = DataManager.getBaseItem(this._item); + var value = $gameParty.numIndependentItems(baseItem); + value = Yanfly.Util.toGroup(value); + var possessionWidth = this.textWidth(value); + this.changeTextColor(this.systemColor()); + this.drawText(TextManager.possession, x, y, width - possessionWidth); + this.resetTextColor(); + this.drawText(value, x, y, width, 'right'); +}; + +//============================================================================= +// Scene_Equip +//============================================================================= + +Yanfly.Item.Scene_Equip_refreshActor = Scene_Equip.prototype.refreshActor; +Scene_Equip.prototype.refreshActor = function() { + this.actor().releaseUnequippableItems(); + Yanfly.Item.Scene_Equip_refreshActor.call(this); +}; + +//============================================================================= +// Scene_Shop +//============================================================================= + +Yanfly.Item.Scene_Shop_doBuy = Scene_Shop.prototype.doBuy; +Scene_Shop.prototype.doBuy = function(number) { + $gameTemp.enableVarianceStock(); + Yanfly.Item.Scene_Shop_doBuy.call(this, number); + $gameTemp.disableVarianceStock(); +}; + +Yanfly.Item.Scene_Shop_doSell = Scene_Shop.prototype.doSell; +Scene_Shop.prototype.doSell = function(number) { + Yanfly.Item.Scene_Shop_doSell.call(this, number); + if (!DataManager.isIndependent(this._item)) return; + DataManager.removeIndependentItem(this._item); +}; + +//============================================================================= +// Scene_Item 1.6.0 Code Suppress +//============================================================================= + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") { + +Scene_Item.prototype.update = function() { + Scene_ItemBase.prototype.update.call(this); +}; + +}; // Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0" + +//============================================================================= +// Scene_Item Update +//============================================================================= + +if (Yanfly.Param.ItemSceneItem) { + +//============================================================================= +// Window_ItemCategory +//============================================================================= + +Yanfly.Item.Window_ItemCategory_windowWidth = + Window_ItemCategory.prototype.windowWidth; +Window_ItemCategory.prototype.windowWidth = function() { + if (SceneManager._scene instanceof Scene_Item) return 240; + return Yanfly.Item.Window_ItemCategory_windowWidth.call(this); +}; + +Yanfly.Item.Window_ItemCategory_numVisibleRows = + Window_ItemCategory.prototype.numVisibleRows; +Window_ItemCategory.prototype.numVisibleRows = function() { + if (SceneManager._scene instanceof Scene_Item) return 4; + return Yanfly.Item.Window_ItemCategory_numVisibleRows.call(this); +}; + +Yanfly.Item.Window_ItemCategory_maxCols = Window_ItemCategory.prototype.maxCols; +Window_ItemCategory.prototype.maxCols = function() { + if (SceneManager._scene instanceof Scene_Item) return 1; + return Yanfly.Item.Window_ItemCategory_maxCols.call(this); +}; + +Yanfly.Item.Window_ItemCategory_itemTextAlign = + Window_ItemCategory.prototype.itemTextAlign; +Window_ItemCategory.prototype.itemTextAlign = function() { + if (SceneManager._scene instanceof Scene_Item) { + return Yanfly.Param.ItemCmdAlign; + } + return Yanfly.Item.Window_ItemCategory_itemTextAlign.call(this); +}; + +//============================================================================= +// Window_ItemList +//============================================================================= + +Yanfly.Item.Window_ItemList_initialize = Window_ItemList.prototype.initialize; +Window_ItemList.prototype.initialize = function(x, y, width, height) { + if (SceneManager._scene instanceof Scene_Item) { + width = Graphics.boxWidth / 2; + } + Yanfly.Item.Window_ItemList_initialize.call(this, x, y, width, height); +}; + +Yanfly.Item.Window_ItemList_maxCols = Window_ItemList.prototype.maxCols; +Window_ItemList.prototype.maxCols = function() { + if (SceneManager._scene instanceof Scene_Item) return 1; + return Yanfly.Item.Window_ItemList_maxCols.call(this); +}; + +Yanfly.Item.Window_ItemList_isEnabled = Window_ItemList.prototype.isEnabled; +Window_ItemList.prototype.isEnabled = function(item) { + if (!item) return false; + if (SceneManager._scene instanceof Scene_Item) return true; + return Yanfly.Item.Window_ItemList_isEnabled.call(this, item); +}; + +Window_ItemList.prototype.setStatusWindow = function(statusWindow) { + this._statusWindow = statusWindow; + this.update(); +}; + +Window_ItemList.prototype.setInfoWindow = function(infoWindow) { + this._infoWindow = infoWindow; + this.update(); +}; + +Yanfly.Item.Window_ItemList_updateHelp = Window_ItemList.prototype.updateHelp; +Window_ItemList.prototype.updateHelp = function() { + Yanfly.Item.Window_ItemList_updateHelp.call(this); + if (SceneManager._scene instanceof Scene_Item && this._statusWindow) { + this._statusWindow.setItem(this.item()); + } + if (SceneManager._scene instanceof Scene_Item && this._infoWindow) { + this._infoWindow.setItem(this.item()); + } +}; + +//============================================================================= +// Window_ItemStatus +//============================================================================= + +function Window_ItemStatus() { + this.initialize.apply(this, arguments); +} + +Window_ItemStatus.prototype = Object.create(Window_Base.prototype); +Window_ItemStatus.prototype.constructor = Window_ItemStatus; + +Window_ItemStatus.prototype.initialize = function(x, y, width, height) { + Window_Base.prototype.initialize.call(this, x, y, width, height); + this._item = null; + this.deactivate(); + this.refresh(); +}; + +Window_ItemStatus.prototype.setItem = function(item) { + if (this._item === item) return; + this._item = item; + this.refresh(); +}; + +Window_ItemStatus.prototype.refresh = function() { + this.contents.clear(); + this.drawDarkRectEntries(); + if (!this._item) return; + this.contents.fontSize = Yanfly.Param.ItemFontSize; + this.drawItemEntry(); +}; + +Window_ItemStatus.prototype.drawDarkRectEntries = function() { + var rect = new Rectangle(); + if (Yanfly.Param.ItemShowIcon) { + rect.width = Window_Base._faceWidth; + rect.height = Window_Base._faceHeight; + this.drawDarkRect(rect.x, rect.y, rect.width, rect.height); + rect.width = (this.contents.width - Window_Base._faceWidth) / 2; + } else { + rect.width = this.contents.width / 2; + } + rect.height = this.lineHeight(); + for (var i = 0; i < 8; ++i) { + rect = this.getRectPosition(rect, i); + this.drawDarkRect(rect.x, rect.y, rect.width, rect.height); + } +}; + +Window_ItemStatus.prototype.drawDarkRect = function(dx, dy, dw, dh) { + var color = this.gaugeBackColor(); + this.changePaintOpacity(false); + this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color); + this.changePaintOpacity(true); +}; + +Window_ItemStatus.prototype.getRectPosition = function(rect, i) { + if (i % 2 === 0) { + if (Yanfly.Param.ItemShowIcon) { + rect.x = Window_Base._faceWidth; + } else { + rect.x = 0; + } + rect.y = i / 2 * this.lineHeight(); + } else { + if (Yanfly.Param.ItemShowIcon) { + rect.x = Window_Base._faceWidth + rect.width; + } else { + rect.x = rect.width; + } + } + return rect; +}; + +Window_ItemStatus.prototype.drawItemEntry = function() { + var item = this._item; + if (Yanfly.Param.ItemShowIcon) this.drawItemIcon(item); + if (DataManager.isItem(item)) this.drawItemInfo(item); + if (DataManager.isWeapon(item)) this.drawEquipInfo(item); + if (DataManager.isArmor(item)) this.drawEquipInfo(item); +}; + +Window_ItemStatus.prototype.drawItemIcon = function() { + this.drawLargeIcon(); +}; + +Window_ItemStatus.prototype.drawLargeIcon = function() { + var iconIndex = this._item.iconIndex; + var bitmap = ImageManager.loadSystem('IconSet'); + var pw = Window_Base._iconWidth; + var ph = Window_Base._iconHeight; + var sx = iconIndex % 16 * pw; + var sy = Math.floor(iconIndex / 16) * ph; + var dw = Yanfly.Param.ItemIconSize; + var dh = Yanfly.Param.ItemIconSize; + var dx = (Window_Base._faceWidth - dw) / 2; + var dy = (Window_Base._faceHeight - dh) / 2; + this.contents._context.imageSmoothingEnabled = false; + this.contents.blt(bitmap, sx, sy, pw, ph, dx, dy, dw, dh); + this.contents._context.imageSmoothingEnabled = true; +}; + +Window_ItemStatus.prototype.drawEquipInfo = function(item) { + var rect = new Rectangle(); + if (eval(Yanfly.Param.ItemShowIcon)) { + rect.width = (this.contents.width - Window_Base._faceWidth) / 2; + } else { + rect.width = this.contents.width / 2; + } + for (var i = 0; i < 8; ++i) { + rect = this.getRectPosition(rect, i); + var dx = rect.x + this.textPadding(); + var dw = rect.width - this.textPadding() * 2; + this.changeTextColor(this.systemColor()); + this.drawText(TextManager.param(i), dx, rect.y, dw); + this.changeTextColor(this.paramchangeTextColor(item.params[i])); + var text = Yanfly.Util.toGroup(item.params[i]); + if (item.params[i] >= 0) text = '+' + text; + if (text === '+0') this.changePaintOpacity(false); + this.drawText(text, dx, rect.y, dw, 'right'); + this.changePaintOpacity(true); + } +}; + +Window_ItemStatus.prototype.drawItemInfo = function(item) { + var rect = new Rectangle(); + if (eval(Yanfly.Param.ItemShowIcon)) { + rect.width = (this.contents.width - Window_Base._faceWidth) / 2; + } else { + rect.width = this.contents.width / 2; + } + for (var i = 0; i < 8; ++i) { + rect = this.getRectPosition(rect, i); + var dx = rect.x + this.textPadding(); + var dw = rect.width - this.textPadding() * 2; + this.changeTextColor(this.systemColor()); + var text = this.getItemInfoCategory(i); + this.drawText(text, dx, rect.y, dw); + this.drawItemData(i, dx, rect.y, dw); + } +}; + +Window_ItemStatus.prototype.getItemInfoCategory = function(i) { + var fmt = Yanfly.Param.ItemRecoverFmt; + if (i === 0) return fmt.format(TextManager.param(0)); + if (i === 1) return fmt.format(TextManager.hp); + if (i === 2) return fmt.format(TextManager.param(1)); + if (i === 3) return fmt.format(TextManager.mp); + if (i === 4) return Yanfly.Param.ItemAddState; + if (i === 5) return Yanfly.Param.ItemRemoveState; + if (i === 6) return Yanfly.Param.ItemAddBuff; + if (i === 7) return Yanfly.Param.ItemRemoveBuff; + return ''; +}; + +Window_ItemStatus.prototype.drawItemData = function(i, dx, dy, dw) { + if (!this._item) return; + var effect; + var value = '---'; + var pre = ''; + var text = ''; + var icons = []; + if (i === 0) { + effect = this.getEffect(Game_Action.EFFECT_RECOVER_HP); + value = (effect) ? effect.value1 : '---'; + if (value === 0) value = '---'; + if (value !== '---' && value !== 0) value *= 100; + } + if (i === 1) { + effect = this.getEffect(Game_Action.EFFECT_RECOVER_HP); + value = (effect) ? effect.value2 : '---'; + if (value === 0) value = '---'; + } + if (i === 2) { + effect = this.getEffect(Game_Action.EFFECT_RECOVER_MP); + value = (effect) ? effect.value1 : '---'; + if (value === 0) value = '---'; + if (value !== '---' && value !== 0) value *= 100; + } + if (i === 3) { + effect = this.getEffect(Game_Action.EFFECT_RECOVER_MP); + value = (effect) ? effect.value2 : '---'; + if (value === 0) value = '---'; + } + if (i >= 4) { + icons = this.getItemIcons(i, icons); + } + this.changeTextColor(this.normalColor()); + if (value === '---') { + this.changePaintOpacity(false); + } else if (i < 4) { + if (value > 0) pre = '+'; + value = Yanfly.Util.toGroup(parseInt(value)); + if ([0, 2].contains(i)) text = '%'; + } + if (icons.length > 0) { + this.changePaintOpacity(true); + dx = dx + dw - icons.length * Window_Base._iconWidth; + dx += this.textPadding() - 2; + for (var j = 0; j < icons.length; ++j) { + var icon = icons[j]; + this.drawIcon(icon, dx, dy + 2); + dx += Window_Base._iconWidth; + } + } else { + text = pre + value + text; + this.drawText(text, dx, dy, dw, 'right'); + this.changePaintOpacity(true); + } +}; + +Window_ItemStatus.prototype.getEffect = function(code) { + var targetEffect; + this._item.effects.forEach(function(effect) { + if (effect.code === code) targetEffect = effect; + }, this); + return targetEffect; +}; + +Window_ItemStatus.prototype.getItemIcons = function(i, array) { + this._item.effects.forEach(function(effect) { + if (i === 4 && effect.code === Game_Action.EFFECT_ADD_STATE) { + var state = $dataStates[effect.dataId]; + if (state && state.iconIndex !== 0) array.push(state.iconIndex); + } + if (i === 5 && effect.code === Game_Action.EFFECT_REMOVE_STATE) { + var state = $dataStates[effect.dataId]; + if (state && state.iconIndex !== 0) array.push(state.iconIndex); + } + if (i === 6 && effect.code === Game_Action.EFFECT_ADD_BUFF) { + var icon = Game_BattlerBase.ICON_BUFF_START + effect.dataId; + array.push(icon); + } + if (i === 6 && effect.code === Game_Action.EFFECT_ADD_DEBUFF) { + var icon = Game_BattlerBase.ICON_DEBUFF_START + effect.dataId; + array.push(icon); + } + if (i === 7 && effect.code === Game_Action.EFFECT_REMOVE_BUFF) { + var icon = Game_BattlerBase.ICON_BUFF_START + effect.dataId; + array.push(icon); + } + if (i === 7 && effect.code === Game_Action.EFFECT_REMOVE_DEBUFF) { + var icon = Game_BattlerBase.ICON_DEBUFF_START + effect.dataId; + array.push(icon); + } + }, this); + array = array.slice(0, Yanfly.Param.ItemMaxIcons); + return array; +}; + +//============================================================================= +// Window_ItemInfo +//============================================================================= + +function Window_ItemInfo() { + this.initialize.apply(this, arguments); +} + +Window_ItemInfo.prototype = Object.create(Window_Base.prototype); +Window_ItemInfo.prototype.constructor = Window_ItemInfo; + +Window_ItemInfo.prototype.initialize = function(x, y, width, height) { + Window_Base.prototype.initialize.call(this, x, y, width, height); + this._item = null; + this.deactivate(); + this.refresh(); +}; + +Window_ItemInfo.prototype.setItem = function(item) { + if (this._item === item) return; + this._item = item; + this.refresh(); +}; + +Window_ItemInfo.prototype.refresh = function() { + this.contents.clear(); + var dy = 0; + if (!this._item) return dy; + this.preInfoEval(); + dy = this.drawPreItemInfo(dy); + dy = this.drawItemInfo(dy); + dy = this.drawItemInfoA(dy); + dy = this.drawItemInfoB(dy); + dy = this.drawItemInfoC(dy); + dy = this.drawItemInfoD(dy); + dy = this.drawItemInfoE(dy); + return this.drawItemInfoF(dy); +}; + +Window_ItemInfo.prototype.preInfoEval = function() { + var item = this._item; + if (item.infoEval === undefined) { + item.infoEval = DataManager.getBaseItem(item).infoEval; + } + if (item.infoEval === '') return; + var weapon = this._item; + var armor = this._item; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.infoEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'ITEM WINDOW PRE INFO EVAL ERROR'); + } +}; + +Window_ItemInfo.prototype.drawPreItemInfo = function(dy) { + return dy; +}; + +Window_ItemInfo.prototype.drawItemInfo = function(dy) { + var dx = this.textPadding(); + var dw = this.contents.width - this.textPadding() * 2; + this.resetFontSettings(); + this.drawItemName(this._item, dx, dy, dw); + return dy + this.lineHeight(); +}; + +Window_ItemInfo.prototype.drawItemInfoA = function(dy) { + dy = this.drawInfoTextTop(dy); + return dy; +}; + +Window_ItemInfo.prototype.drawItemInfoB = function(dy) { + return dy; +}; + +Window_ItemInfo.prototype.drawItemInfoC = function(dy) { + return dy; +}; + +Window_ItemInfo.prototype.drawItemInfoD = function(dy) { + return dy; +}; + +Window_ItemInfo.prototype.drawItemInfoE = function(dy) { + return dy; +}; + +Window_ItemInfo.prototype.drawItemInfoF = function(dy) { + dy = this.drawInfoTextBottom(dy); + return dy; +}; + +Window_ItemInfo.prototype.drawDarkRect = function(dx, dy, dw, dh) { + var color = this.gaugeBackColor(); + this.changePaintOpacity(false); + this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color); + this.changePaintOpacity(true); +}; + +Window_ItemInfo.prototype.drawInfoTextTop = function(dy) { + var item = this._item; + if (item.infoTextTop === undefined) { + item.infoTextTop = DataManager.getBaseItem(item).infoTextTop; + } + if (item.infoTextTop === '') return dy; + var info = item.infoTextTop.split(/[\r\n]+/); + for (var i = 0; i < info.length; ++i) { + var line = info[i]; + this.resetFontSettings(); + this.drawTextEx(line, this.textPadding(), dy); + dy += this.contents.fontSize + 8; + } + return dy; +}; + +Window_ItemInfo.prototype.drawInfoTextBottom = function(dy) { + var item = this._item; + if (item.infoTextBottom === undefined) { + item.infoTextBottom = DataManager.getBaseItem(item).infoTextBottom; + } + if (item.infoTextBottom === '') return dy; + var info = item.infoTextBottom.split(/[\r\n]+/); + for (var i = 0; i < info.length; ++i) { + var line = info[i]; + this.resetFontSettings(); + this.drawTextEx(line, this.textPadding(), dy); + dy += this.contents.fontSize + 8; + } + return dy; +}; + +//============================================================================= +// Window_ItemActionCommand +//============================================================================= + +function Window_ItemActionCommand() { + this.initialize.apply(this, arguments); +} + +Window_ItemActionCommand.prototype = Object.create(Window_Command.prototype); +Window_ItemActionCommand.prototype.constructor = Window_ItemActionCommand; + +Window_ItemActionCommand.prototype.initialize = function(x, y) { + this._windowHeight = Graphics.boxHeight - y; + Window_Command.prototype.initialize.call(this, x, y); + this._item = null; + this.hide(); + this.deactivate(); +}; + +Window_ItemActionCommand.prototype.windowWidth = function() { + return Graphics.boxWidth / 2; +}; + +Window_ItemActionCommand.prototype.update = function() { + Window_Command.prototype.update.call(this); +}; + +Window_ItemActionCommand.prototype.setItem = function(item) { + this._item = item; + this.refresh(); + this.show(); + this.activate(); + this.select(0); +}; + +Window_ItemActionCommand.prototype.windowHeight = function() { + return this._windowHeight; +}; + +Window_ItemActionCommand.prototype.makeCommandList = function() { + if (!this._item) return; + this.addUseCommand(); + this.addCustomCommandsA(); + this.addCustomCommandsB(); + this.addCustomCommandsC(); + this.addCustomCommandsD(); + this.addCustomCommandsE(); + this.addCustomCommandsF(); + this.addCancelCommand(); +}; + +Window_ItemActionCommand.prototype.addUseCommand = function() { + var enabled = this.isEnabled(this._item); + var fmt = Yanfly.Param.ItemUseCmd; + text = '\\i[' + this._item.iconIndex + ']'; + if (this._item.textColor !== undefined) { + text += '\\c[' + this._item.textColor + ']'; + } + text += this._item.name; + text = fmt.format(text); + this.addCommand(text, 'use', enabled); +}; + +Window_ItemActionCommand.prototype.isEnabled = function(item) { + if (!item) return false; + return $gameParty.canUse(item); +}; + +Window_ItemActionCommand.prototype.addCustomCommandsA = function() { +}; + +Window_ItemActionCommand.prototype.addCustomCommandsB = function() { +}; + +Window_ItemActionCommand.prototype.addCustomCommandsC = function() { +}; + +Window_ItemActionCommand.prototype.addCustomCommandsD = function() { +}; + +Window_ItemActionCommand.prototype.addCustomCommandsE = function() { +}; + +Window_ItemActionCommand.prototype.addCustomCommandsF = function() { +}; + +Window_ItemActionCommand.prototype.addCancelCommand = function() { + this.addCommand(TextManager.cancel, 'cancel'); +}; + +Window_ItemActionCommand.prototype.drawItem = function(index) { + var rect = this.itemRectForText(index); + var align = this.itemTextAlign(); + this.resetTextColor(); + this.changePaintOpacity(this.isCommandEnabled(index)); + this.drawTextEx(this.commandName(index), rect.x, rect.y); +}; + +//============================================================================= +// Scene_Item +//============================================================================= + +Yanfly.Item.Scene_Item_createItemWindow = Scene_Item.prototype.createItemWindow; +Scene_Item.prototype.createItemWindow = function() { + Yanfly.Item.Scene_Item_createItemWindow.call(this); + this.createStatusWindow(); + this.createInfoWindow(); + this.createActionWindow(); + this._categoryWindow.setHandler('cancel', this.exitScene.bind(this)); +}; + +Scene_Item.prototype.createStatusWindow = function() { + var wx = this._categoryWindow.width; + var wy = this._helpWindow.height; + var ww = Graphics.boxWidth - wx; + var wh = this._categoryWindow.height; + this._statusWindow = new Window_ItemStatus(wx, wy, ww, wh); + this._itemWindow.setStatusWindow(this._statusWindow); + this.addWindow(this._statusWindow); +}; + +Scene_Item.prototype.createInfoWindow = function() { + var wx = this._itemWindow.width; + var wy = this._itemWindow.y; + var ww = Graphics.boxWidth - wx; + var wh = this._itemWindow.height; + this._infoWindow = new Window_ItemInfo(wx, wy, ww, wh); + this._itemWindow.setInfoWindow(this._infoWindow); + this.addWindow(this._infoWindow); +}; + +Scene_Item.prototype.createActionWindow = function() { + var wy = this._itemWindow.y; + this._itemActionWindow = new Window_ItemActionCommand(0, wy); + this._itemActionWindow.setHandler('use', this.onActionUse.bind(this)); + this._itemActionWindow.setHandler('cancel', this.onActionCancel.bind(this)); + this.addWindow(this._itemActionWindow); +}; + +Scene_Item.prototype.isCursorLeft = function() { + return true; +}; + +Scene_Item.prototype.onItemOk = function() { + var item = this.item(); + this._itemActionWindow.setItem(item); +}; + +Yanfly.Item.Scene_Item_onItemCancel = Scene_Item.prototype.onItemCancel; +Scene_Item.prototype.onItemCancel = function() { + Yanfly.Item.Scene_Item_onItemCancel.call(this); + this._statusWindow.setItem(null); + this._infoWindow.setItem(null); +}; + +Scene_Item.prototype.onActionUse = function() { + this._itemActionWindow.hide(); + this._itemActionWindow.deactivate(); + $gameParty.setLastItem(this.item()); + this.determineItem(); +}; + +Scene_Item.prototype.onActionCancel = function() { + this._itemActionWindow.hide(); + this._itemActionWindow.deactivate(); + this._itemWindow.activate(); +}; + +Yanfly.Item.Scene_Item_applyItem = Scene_Item.prototype.applyItem; +Scene_Item.prototype.applyItem = function() { + Yanfly.Item.Scene_Item_applyItem.call(this); + if (DataManager.isIndependent(this.item())) this.onActorCancel(); +}; + +Scene_Item.prototype.exitScene = function() { + var length = $gameParty.members().length; + for (var i = 0; i < length; ++i) { + var member = $gameParty.members()[i]; + if (member) member.refresh(); + } + this.popScene(); +}; + +//============================================================================= +// Scene_Item Update +//============================================================================= + +}; // End Scene_Item + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_KeyboardConfig.js b/js/plugins/YEP_KeyboardConfig.js new file mode 100644 index 0000000..c1f8aa2 --- /dev/null +++ b/js/plugins/YEP_KeyboardConfig.js @@ -0,0 +1,1190 @@ +//============================================================================= +// Yanfly Engine Plugins - Keyboard Configuration +// YEP_KeyboardConfig.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_KeyboardConfig = true; + +var Yanfly = Yanfly || {}; +Yanfly.KeyConfig = Yanfly.KeyConfig || {}; +Yanfly.KeyConfig.version = 1.04; + +//============================================================================= + /*: + * @plugindesc v1.04 Allows players to adjust their button configuration + * for keyboards. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Command Name + * @parent ---General--- + * @desc This is the option name that appears in the main menu. + * @default Keyboard Config + * + * @param Button Events + * @parent ---General--- + * @desc Requires YEP_ButtonCommonEvents. This is a list of common + * events you can bind to key presses. Separate with a space. + * @default 1 2 3 + * + * @param Button Events List + * @parent ---General--- + * @type number[] + * @desc Requires YEP_ButtonCommonEvents. This is a list of common + * events you can bind to key presses. MV 1.5.0+ + * @default [] + * + * @param ---Help Text--- + * @default + * + * @param Key Help + * @parent ---Help Text--- + * @desc This is the help message that will display for keys. + * @default Change the configuration of this key? + * + * @param Default Layout + * @parent ---Help Text--- + * @desc This is the text for switching to the default layout. + * @default Default Keyboard Layout + * + * @param Default Help + * @parent ---Help Text--- + * @desc This is the help message that will display for keys. + * @default Reverts your keyboard setting to the default setup. + * + * @param WASD Layout + * @parent ---Help Text--- + * @desc This is the text for switching to the WASD layout. + * @default WASD Movement Layout + * + * @param WASD Help + * @parent ---Help Text--- + * @desc This is the help message that will display for WASD. + * @default Changes your keyboard to WASD movement. + * + * @param Finish Config + * @parent ---Help Text--- + * @desc This is the text for finishing with keyboard configuration. + * @default Finish Configuration + * + * @param Finish Help + * @parent ---Help Text--- + * @desc This is the help message that will display for Finish. + * @default Are you done configuring your keyboard? + * + * @param Assigned Color + * @parent ---Help Text--- + * @type number + * @min 0 + * @max 31 + * @desc This is the background color of a key that's assigned. + * @default 21 + * + * @param Action Color + * @parent ---Help Text--- + * @type number + * @min 0 + * @max 31 + * @desc This is the text color of an assigned action. + * @default 4 + * + * @param Clear Text + * @parent ---Help Text--- + * @desc This is the Clear action will appear for the config text. + * @default Clear + * + * @param ---Key Names--- + * @default + * + * @param OK Key + * @parent ---Key Names--- + * @desc This is the OK action will appear on a key. + * @default OK + * + * @param OK Text + * @parent ---Key Names--- + * @desc This is the OK action will appear for the config text. + * @default OK / Talk + * + * @param Escape Key + * @parent ---Key Names--- + * @desc This is the Escape action will appear on a key. + * @default X + * + * @param Escape Text + * @parent ---Key Names--- + * @desc This is the Escape action will appear for the config text. + * @default Cancel / Menu + * + * @param Cancel Key + * @parent ---Key Names--- + * @desc This is the Cancel action will appear on a key. + * @default Cancel + * + * @param Cancel Text + * @parent ---Key Names--- + * @desc This is the Cancel action will appear for the config text. + * @default Cancel + * + * @param Menu Key + * @parent ---Key Names--- + * @desc This is the Menu action will appear on a key. + * @default Menu + * + * @param Menu Text + * @parent ---Key Names--- + * @desc This is the Menu action will appear for the config text. + * @default Menu + * + * @param Shift Key + * @parent ---Key Names--- + * @desc This is the Shift action will appear on a key. + * @default Dash + * + * @param Shift Text + * @parent ---Key Names--- + * @desc This is the Shift action will appear for the config text. + * @default Dash + * + * @param PageUp Key + * @parent ---Key Names--- + * @desc This is the PageUp action will appear on a key. + * @default PgUp + * + * @param PageUp Text + * @parent ---Key Names--- + * @desc This is the PageUp action will appear for the config text. + * @default Page Up + * + * @param PageDown Key + * @parent ---Key Names--- + * @desc This is the PageUp action will appear on a key. + * @default PgDn + * + * @param PageDown Text + * @parent ---Key Names--- + * @desc This is the PageUp action will appear for the config text. + * @default Page Down + * + * @param Left Key + * @parent ---Key Names--- + * @desc This is the Left action will appear on a key. + * @default ◄ + * + * @param Left Text + * @parent ---Key Names--- + * @desc This is the Left action will appear for the config text. + * @default Move ◄ Left + * + * @param Up Key + * @parent ---Key Names--- + * @desc This is the Up action will appear on a key. + * @default ▲ + * + * @param Up Text + * @parent ---Key Names--- + * @desc This is the Up action will appear for the config text. + * @default Move ▲ Up + * + * @param Right Key + * @parent ---Key Names--- + * @desc This is the Right action will appear on a key. + * @default ► + * + * @param Right Text + * @parent ---Key Names--- + * @desc This is the Right action will appear for the config text. + * @default Move ► Right + * + * @param Down Key + * @parent ---Key Names--- + * @desc This is the Down action will appear on a key. + * @default ▼ + * + * @param Down Text + * @parent ---Key Names--- + * @desc This is the Down action will appear for the config text. + * @default Move ▼ Down + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin allows players to change their keyboard configuration from the + * in-game Options menu provided that they're using a computer to play the + * game and not from a mobile device. The "Keyboard Config" option will send + * the player to a different screen where they can assign actions to each of + * the allowed keys on the keyboard. + * + * Certain measures are made to prevent the player from locking himself or + * herself in the configuration screen. These measures are that the Enter keys + * and arrow keys cannot be changed. Almost every other key is capable of being + * changed to something of the player's liking. + * + * Note: If you are using Button Common Events, place this plugin beneath + * Button Common Events in the plugin parameter list. + * + * ============================================================================ + * Button Common Event - Comment Tags + * ============================================================================ + * + * If you're using Button Common Events, you can make certain Common Events + * able to be bound to the keyboard using Comment Tags. To make a Comment Tag, + * use a Comment Event inside of your Common Event, and insert the following to + * achieve the desired effect: + * + * Comment Tag: + * + * + * This is the text displayed on the keyboard if this common event is bound + * to a keyboard key. If this text isn't used, then the text displayed will + * be the common event's name. + * + * + * This is the text displayed when selecting a key to bind for the keyboard + * key. This is the text displayed in the selection list. If this text isn't + * used, then the text displayed will be the common event's name. + * + * + * This makes the common event required to be bound on the keyboard before + * the player can exit the configuration menu. In order for this to work + * properly, there needs to be a Button Common Event bound for this common + * event as well. + * + * ============================================================================ + * Options Core Settings - Adding the New Options + * ============================================================================ + * + * If you are using YEP_OptionsCore.js, you can add a new Option using this + * plugin. Here's the following code/parameter settings you can use with it. + * + * --------- + * Settings: + * --------- + * + * Name: + * \i[83]Keyboard Config + * + * Help Description: + * Configure the game's keyboard settings. + * + * Symbol: + * keyConfig + * + * Show/Hide: + * if (Imported.YEP_KeyboardConfig) { + * show = !Utils.isMobileDevice(); + * } else { + * show = false; + * } + * + * Enable: + * enabled = true; + * + * Ext: + * ext = 0; + * + * ---------- + * Functions: + * ---------- + * + * Make Option Code: + * this.addCommand(name, symbol, enabled, ext); + * + * Draw Option Code: + * var rect = this.itemRectForText(index); + * var statusWidth = this.statusWidth(); + * var titleWidth = rect.width - statusWidth; + * this.resetTextColor(); + * this.changePaintOpacity(this.isCommandEnabled(index)); + * this.drawOptionsName(index); + * + * Process OK Code: + * this.playOkSound(); + * SceneManager.push(Scene_KeyConfig); + * + * Cursor Right Code: + * // Empty. Provided by this plugin. + * + * Cursor Left Code: + * // Empty. Provided by this plugin. + * + * Default Config Code: + * // Empty. Provided by this plugin. + * + * Save Config Code: + * // Empty. Provided by this plugin. + * + * Load Config Code: + * // Empty. Provided by this plugin. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.04: + * - Compatibility update with YEP_OptionsCore.js. + * + * Version 1.03: + * - Bug fixed that prevented the plugin from working if specific other plugins + * weren't present. + * + * Version 1.02: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.01: + * - Compatibility update with Button Common Events. + * - Added , , and + * comment tags. These tags work together with Button Common Events. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_KeyboardConfig'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.KeyConfigName = String(Yanfly.Parameters['Command Name']); +Yanfly.SetupParameters = function() { + if (Imported.YEP_ButtonCommonEvents) { + Yanfly.Param.KeyConfigEv = String(Yanfly.Parameters['Button Events']); + Yanfly.Param.KeyConfigEv = Yanfly.Param.KeyConfigEv.split(' '); + for (var i = 0; i < Yanfly.Param.KeyConfigEv.length; ++i) { + Yanfly.Param.KeyConfigEv[i] = + parseInt(Yanfly.Param.KeyConfigEv[i]); + }; + Yanfly.Param.KeyConfigKeys = {}; + for (var key in Yanfly.Param.BCEList) { + value = Yanfly.Param.BCEList[key]; + Yanfly.Param.KeyConfigKeys[value] = key; + } + var array = JSON.parse(Yanfly.Parameters['Button Events List'] || '[]'); + for (var j = 0; j < array.length; ++j) { + if (Yanfly.Param.KeyConfigEv.contains(array[j])) continue; + Yanfly.Param.KeyConfigEv.push(parseInt(array[j])); + } + } else { + Yanfly.Param.KeyConfigEv = []; + }; +}; +Yanfly.SetupParameters(); + +Yanfly.Param.KeyConfigKeyHelp = String(Yanfly.Parameters['Key Help']); +Yanfly.Param.KeyConfigDefaultTx = String(Yanfly.Parameters['Default Layout']); +Yanfly.Param.KeyConfigDefaultHelp = String(Yanfly.Parameters['Default Help']); +Yanfly.Param.KeyConfigWasdTx = String(Yanfly.Parameters['WASD Layout']); +Yanfly.Param.KeyConfigWasdHelp = String(Yanfly.Parameters['WASD Help']); +Yanfly.Param.KeyConfigFinishTx = String(Yanfly.Parameters['Finish Config']); +Yanfly.Param.KeyConfigFinishHelp = String(Yanfly.Parameters['Finish Help']); +Yanfly.Param.KeyConfigAssignColor = Number(Yanfly.Parameters['Assigned Color']); +Yanfly.Param.KeyConfigActionColor = Number(Yanfly.Parameters['Action Color']); +Yanfly.Param.KeyConfigClearTx = String(Yanfly.Parameters['Clear Text']); + +Yanfly.Param.KeyConfigOkKey = String(Yanfly.Parameters['OK Key']); +Yanfly.Param.KeyConfigOkTx = String(Yanfly.Parameters['OK Text']); +Yanfly.Param.KeyConfigEscKey = String(Yanfly.Parameters['Escape Key']); +Yanfly.Param.KeyConfigEscTx = String(Yanfly.Parameters['Escape Text']); +Yanfly.Param.KeyConfigCancelKey = String(Yanfly.Parameters['Cancel Key']); +Yanfly.Param.KeyConfigCancelTx = String(Yanfly.Parameters['Cancel Text']); +Yanfly.Param.KeyConfigMenuKey = String(Yanfly.Parameters['Menu Key']); +Yanfly.Param.KeyConfigMenuTx = String(Yanfly.Parameters['Menu Text']); +Yanfly.Param.KeyConfigShiftKey = String(Yanfly.Parameters['Shift Key']); +Yanfly.Param.KeyConfigShiftTx = String(Yanfly.Parameters['Shift Text']); +Yanfly.Param.KeyConfigPageUpKey = String(Yanfly.Parameters['PageUp Key']); +Yanfly.Param.KeyConfigPageUpTx = String(Yanfly.Parameters['PageUp Text']); +Yanfly.Param.KeyConfigPageDnKey = String(Yanfly.Parameters['PageDown Key']); +Yanfly.Param.KeyConfigPageDnTx = String(Yanfly.Parameters['PageDown Text']); +Yanfly.Param.KeyConfigLeftKey = String(Yanfly.Parameters['Left Key']); +Yanfly.Param.KeyConfigLeftTx = String(Yanfly.Parameters['Left Text']); +Yanfly.Param.KeyConfigUpKey = String(Yanfly.Parameters['Up Key']); +Yanfly.Param.KeyConfigUpTx = String(Yanfly.Parameters['Up Text']); +Yanfly.Param.KeyConfigRightKey = String(Yanfly.Parameters['Right Key']); +Yanfly.Param.KeyConfigRightTx = String(Yanfly.Parameters['Right Text']); +Yanfly.Param.KeyConfigDownKey = String(Yanfly.Parameters['Down Key']); +Yanfly.Param.KeyConfigDownTx = String(Yanfly.Parameters['Down Text']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.KeyConfig.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.KeyConfig.DataManager_isDatabaseLoaded.call(this)) return false; + this.processKeyConfigCommentTags($dataCommonEvents); + return true; +}; + +DataManager.processKeyConfigCommentTags = function(group) { + Yanfly.KeyConfig.RequiredCommonEvents = []; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var list = obj.list; + var length = list.length; + var comment = ''; + for (var i = 0; i < length; ++i) { + var ev = list[i]; + if ([108, 408].contains(ev.code)) comment += ev.parameters[0] + '\n'; + } + this.extraKeyConfigCommentTags(obj, comment); + } +}; + +DataManager.extraKeyConfigCommentTags = function(obj, comment) { + obj.configKey = obj.name; + obj.configText = obj.name; + obj.configRequired = false; + if (comment === '') return; + if (!Imported.YEP_ButtonCommonEvents) return; + var notedata = comment.split(/[\r\n]+/); + for (var i = 0; i < notedata.length; ++i) { + var line = notedata[i]; + if (line.match(/<(?:CONFIG KEY):[ ](.*)>/i)) { + obj.configKey = String(RegExp.$1); + } else if (line.match(/<(?:CONFIG TEXT):[ ](.*)>/i)) { + obj.configText = String(RegExp.$1); + } else if (line.match(/<(?:CONFIG REQUIRED)>/i)) { + obj.configRequired = true; + Yanfly.KeyConfig.RequiredCommonEvents.push(obj.id); + } + } +}; + +//============================================================================= +// Input +//============================================================================= + +if (Imported.YEP_ButtonCommonEvents) { + +Input._revertButton = function(button) { +}; + +Input._switchButton = function(button) { +}; + +}; // Imported.YEP_ButtonCommonEvents + +//============================================================================= +// ConfigManager +//============================================================================= + +ConfigManager.keyMapper = JSON.parse(JSON.stringify(Input.keyMapper)); +ConfigManager.defaultMap = JSON.parse(JSON.stringify(Input.keyMapper)); +ConfigManager.wasdMap = { + 9: 'tab', 13: 'ok', 16: 'shift', 17: 'control', 18: 'control', 27: 'escape', + 32: 'ok', 33: 'pageup', 34: 'pagedown', 37: 'left', 38: 'up', 39: 'right', + 40: 'down', 87: 'up', 65: 'left', 83: 'down', 68: 'right', 74: 'ok', + 75: 'escape', 77: 'menu', 219: 'pageup', 221: 'pagedown', 45: 'escape', + 46: 'ok', 35: 'escape', 36: 'menu', 96: 'escape', 98: 'down', 100: 'left', + 102: 'right', 104: 'up', 120: 'debug' +}; + +if (Imported.YEP_ButtonCommonEvents) { +if (Yanfly.Param.BCEList['tilde'] !== 0) ConfigManager.wasdMap[192] = 'tilde'; +if (Yanfly.Param.BCEList['1'] !== 0) ConfigManager.wasdMap[49] = '1'; +if (Yanfly.Param.BCEList['2'] !== 0) ConfigManager.wasdMap[50] = '2'; +if (Yanfly.Param.BCEList['3'] !== 0) ConfigManager.wasdMap[51] = '3'; +if (Yanfly.Param.BCEList['4'] !== 0) ConfigManager.wasdMap[52] = '4'; +if (Yanfly.Param.BCEList['5'] !== 0) ConfigManager.wasdMap[53] = '5'; +if (Yanfly.Param.BCEList['6'] !== 0) ConfigManager.wasdMap[54] = '6'; +if (Yanfly.Param.BCEList['7'] !== 0) ConfigManager.wasdMap[55] = '7'; +if (Yanfly.Param.BCEList['8'] !== 0) ConfigManager.wasdMap[56] = '8'; +if (Yanfly.Param.BCEList['9'] !== 0) ConfigManager.wasdMap[57] = '9'; +if (Yanfly.Param.BCEList['0'] !== 0) ConfigManager.wasdMap[48] = '0'; +if (Yanfly.Param.BCEList['minus'] !== 0) ConfigManager.wasdMap[189] = 'minus'; +if (Yanfly.Param.BCEList['equal'] !== 0) ConfigManager.wasdMap[187] = 'equal'; + +if (Yanfly.Param.BCEList['q'] !== 0) ConfigManager.wasdMap[81] = 'q'; +if (Yanfly.Param.BCEList['w'] !== 0) ConfigManager.wasdMap[87] = 'w'; +if (Yanfly.Param.BCEList['e'] !== 0) ConfigManager.wasdMap[69] = 'e'; +if (Yanfly.Param.BCEList['r'] !== 0) ConfigManager.wasdMap[82] = 'r'; +if (Yanfly.Param.BCEList['t'] !== 0) ConfigManager.wasdMap[84] = 't'; +if (Yanfly.Param.BCEList['y'] !== 0) ConfigManager.wasdMap[89] = 'y'; +if (Yanfly.Param.BCEList['u'] !== 0) ConfigManager.wasdMap[85] = 'u'; +if (Yanfly.Param.BCEList['i'] !== 0) ConfigManager.wasdMap[73] = 'i'; +if (Yanfly.Param.BCEList['o'] !== 0) ConfigManager.wasdMap[79] = 'o'; +if (Yanfly.Param.BCEList['p'] !== 0) ConfigManager.wasdMap[80] = 'p'; +if (Yanfly.Param.BCEList['foreBrack'] !== 0) ConfigManager.wasdMap[219] = + 'foreBrack'; +if (Yanfly.Param.BCEList['backBrack'] !== 0) ConfigManager.wasdMap[221] = + 'backBrack'; +if (Yanfly.Param.BCEList['backSlash'] !== 0) ConfigManager.wasdMap[220] = + 'backSlash'; + +if (Yanfly.Param.BCEList['a'] !== 0) ConfigManager.wasdMap[65] = 'a'; +if (Yanfly.Param.BCEList['s'] !== 0) ConfigManager.wasdMap[83] = 's'; +if (Yanfly.Param.BCEList['d'] !== 0) ConfigManager.wasdMap[68] = 'd'; +if (Yanfly.Param.BCEList['f'] !== 0) ConfigManager.wasdMap[70] = 'f'; +if (Yanfly.Param.BCEList['g'] !== 0) ConfigManager.wasdMap[71] = 'g'; +if (Yanfly.Param.BCEList['h'] !== 0) ConfigManager.wasdMap[72] = 'h'; +if (Yanfly.Param.BCEList['j'] !== 0) ConfigManager.wasdMap[74] = 'j'; +if (Yanfly.Param.BCEList['k'] !== 0) ConfigManager.wasdMap[75] = 'k'; +if (Yanfly.Param.BCEList['l'] !== 0) ConfigManager.wasdMap[76] = 'l'; +if (Yanfly.Param.BCEList['semicolon'] !== 0) ConfigManager.wasdMap[186] = + 'semicolon'; +if (Yanfly.Param.BCEList['quote'] !== 0) ConfigManager.wasdMap[222] = 'quote'; +if (Yanfly.Param.BCEList['enter'] !== 0) ConfigManager.wasdMap[13] = 'enter'; + +if (Yanfly.Param.BCEList['keyShift'] !== 0) ConfigManager.wasdMap[16] = + 'keyShift'; +if (Yanfly.Param.BCEList['z'] !== 0) ConfigManager.wasdMap[90] = 'z'; +if (Yanfly.Param.BCEList['x'] !== 0) ConfigManager.wasdMap[88] = 'x'; +if (Yanfly.Param.BCEList['c'] !== 0) ConfigManager.wasdMap[67] = 'c'; +if (Yanfly.Param.BCEList['v'] !== 0) ConfigManager.wasdMap[86] = 'v'; +if (Yanfly.Param.BCEList['b'] !== 0) ConfigManager.wasdMap[66] = 'b'; +if (Yanfly.Param.BCEList['n'] !== 0) ConfigManager.wasdMap[78] = 'n'; +if (Yanfly.Param.BCEList['m'] !== 0) ConfigManager.wasdMap[77] = 'm'; +if (Yanfly.Param.BCEList['comma'] !== 0) ConfigManager.wasdMap[188] = 'comma'; +if (Yanfly.Param.BCEList['period'] !== 0) ConfigManager.wasdMap[190] = 'period'; +if (Yanfly.Param.BCEList['foreSlash'] !== 0) ConfigManager.wasdMap[191] = + 'foreSlash'; + +if (Yanfly.Param.BCEList['space'] !== 0) ConfigManager.wasdMap[32] = 'space'; +if (Yanfly.Param.BCEList['dirLeft'] !== 0) ConfigManager.wasdMap[37] = + 'dirLeft'; +if (Yanfly.Param.BCEList['dirUp'] !== 0) ConfigManager.wasdMap[38] = 'dirUp'; +if (Yanfly.Param.BCEList['dirRight'] !== 0) ConfigManager.wasdMap[39] = + 'dirRight'; +if (Yanfly.Param.BCEList['dirDown'] !== 0) ConfigManager.wasdMap[40] = + 'dirDown'; +if (Yanfly.Param.BCEList['ins'] !== 0) ConfigManager.wasdMap[45] = 'ins'; +if (Yanfly.Param.BCEList['del'] !== 0) ConfigManager.wasdMap[46] = 'del'; +if (Yanfly.Param.BCEList['home'] !== 0) ConfigManager.wasdMap[36] = 'home'; +if (Yanfly.Param.BCEList['end'] !== 0) ConfigManager.wasdMap[35] = 'end'; +if (Yanfly.Param.BCEList['pageUp'] !== 0) ConfigManager.wasdMap[33] = 'pageUp'; +if (Yanfly.Param.BCEList['pageDown'] !== 0) ConfigManager.wasdMap[34] = + 'pageDown'; + +if (Yanfly.Param.BCEList['num0'] !== 0) ConfigManager.wasdMap[96] = 'num0'; +if (Yanfly.Param.BCEList['num1'] !== 0) ConfigManager.wasdMap[97] = 'num1'; +if (Yanfly.Param.BCEList['num2'] !== 0) ConfigManager.wasdMap[98] = 'num2'; +if (Yanfly.Param.BCEList['num3'] !== 0) ConfigManager.wasdMap[99] = 'num3'; +if (Yanfly.Param.BCEList['num4'] !== 0) ConfigManager.wasdMap[100] = 'num4'; +if (Yanfly.Param.BCEList['num5'] !== 0) ConfigManager.wasdMap[101] = 'num5'; +if (Yanfly.Param.BCEList['num6'] !== 0) ConfigManager.wasdMap[102] = 'num6'; +if (Yanfly.Param.BCEList['num7'] !== 0) ConfigManager.wasdMap[103] = 'num7'; +if (Yanfly.Param.BCEList['num8'] !== 0) ConfigManager.wasdMap[104] = 'num8'; +if (Yanfly.Param.BCEList['num9'] !== 0) ConfigManager.wasdMap[105] = 'num9'; +if (Yanfly.Param.BCEList['numPeriod'] !== 0) ConfigManager.wasdMap[110] = + 'numPeriod'; +if (Yanfly.Param.BCEList['numPlus'] !== 0) ConfigManager.wasdMap[107] = + 'numPlus'; +if (Yanfly.Param.BCEList['numMinus'] !== 0) ConfigManager.wasdMap[109] = + 'numMinus'; +if (Yanfly.Param.BCEList['numTimes'] !== 0) ConfigManager.wasdMap[106] = + 'numTimes'; +if (Yanfly.Param.BCEList['numDivide'] !== 0) ConfigManager.wasdMap[111] = + 'numDivide'; +}; + +Yanfly.KeyConfig.ConfigManager_makeData = ConfigManager.makeData; +ConfigManager.makeData = function() { + var config = Yanfly.KeyConfig.ConfigManager_makeData.call(this); + config.keyMapper = this.keyMapper; + return config; +}; + +Yanfly.KeyConfig.ConfigManager_applyData = ConfigManager.applyData; +ConfigManager.applyData = function(config) { + Yanfly.KeyConfig.ConfigManager_applyData.call(this, config); + this.keyMapper = this.readKeyConfig(config, 'keyMapper'); + this.applyKeyConfig(); +}; + +ConfigManager.applyKeyConfig = function() { + Input.keyMapper = this.keyMapper; + Input.update(); + Input.clear(); +}; + +ConfigManager.readKeyConfig = function(config, name) { + var value = config[name]; + if (value !== undefined) { + return value; + } else { + return JSON.parse(JSON.stringify(ConfigManager.defaultMap)); + } +}; + +//============================================================================= +// Window_Options +//============================================================================= + +Yanfly.KeyConfig.Window_Options_addGeneralOptions = + Window_Options.prototype.addGeneralOptions; +Window_Options.prototype.addGeneralOptions = function() { + Yanfly.KeyConfig.Window_Options_addGeneralOptions.call(this); + if (!Imported.YEP_OptionsCore) this.addKeyConfigCommand(); +}; + +Window_Options.prototype.addKeyConfigCommand = function() { + if (Utils.isMobileDevice()) return; + this.addCommand(Yanfly.Param.KeyConfigName, 'keyConfig', true); +}; + +if (!Imported.YEP_OptionsCore) { + +Yanfly.KeyConfig.Window_Options_drawItem = + Window_Options.prototype.drawItem; +Window_Options.prototype.drawItem = function(index) { + if (this.commandSymbol(index) === 'keyConfig') { + var rect = this.itemRectForText(index); + var text = this.commandName(index); + this.resetTextColor(); + this.changePaintOpacity(this.isCommandEnabled(index)); + this.drawText(text, rect.x, rect.y, rect.width, 'left'); + } else { + Yanfly.KeyConfig.Window_Options_drawItem.call(this, index); + } +}; + +Yanfly.KeyConfig.Window_Options_processOk = + Window_Options.prototype.processOk; +Window_Options.prototype.processOk = function() { + if (this.commandSymbol(this.index()) === 'keyConfig') { + Window_Command.prototype.processOk.call(this); + } else { + Yanfly.KeyConfig.Window_Options_processOk.call(this); + } +}; + +}; // Imported.YEP_OptionsCore + + +//============================================================================= +// Window_KeyConfig +//============================================================================= + +function Window_KeyConfig() { + this.initialize.apply(this, arguments); +}; + +Window_KeyConfig._keyLayout = [ + '~', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', ' ', 'Ins', + 'Home', 'PgUp', ' ', '#pD/', '*', '#pD-', ' ', 'Q', 'W', 'E', 'R', 'T', 'Y', + 'U', 'I', 'O', 'P', '[', ']', '\\', 'Del', 'End', 'PgDn', '#pD7', '#pD8', + '#pD9', '+', ' ', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', "'", + 'Enter', 'Enter', ' ', ' ', ' ', '#pD4', '#pD5', '#pD6', '+', 'Shift', + 'Shift', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 'Shift', 'Shift', + ' ', '↑', ' ', '#pD1', '#pD2', '#pD3', 'En', ' ', ' ', ' ', 'Space', 'Space', + 'Space', 'Space', 'Space', 'Space', 'Space', ' ', ' ', ' ', ' ', '←', '↓', + '→', '#pD0', '#pD0', '#pD.', 'En' +]; + +Window_KeyConfig._refId = { + '~': 192, '0': 48, '1': 49, '2': 50, '3': 51, '4': 52, + '5': 53, '6': 54, '7': 55, '8': 56, '9': 57, '-': 189, + '=': 187, 'Ins': 45, 'Home': 36, 'PgUp': 33, '#pD/': 111, '*': 106, + '#pD-': 109, 'Q': 81, 'W': 87, 'E': 69, 'R': 82, 'T': 84, + 'Y': 89, 'U': 85, 'I': 73, 'O': 79, 'P': 80, '[': 219, + ']': 221, '\\': 220, 'Del': 46, 'End': 35, 'PgDn': 34, '#pD7': 103, + '#pD8': 104, '#pD9': 105, '+': 107, 'A': 65, 'S': 83, 'D': 68, + 'F': 70, 'G': 71, 'H': 72, 'J': 74, 'K': 75, 'L': 76, + ';': 186, "'": 222, 'Enter': 13, '#pD4': 100, '#pD5': 101, '#pD6': 102, + 'Shift': 16, 'Z': 90, 'X': 88, 'C': 67, 'V': 86, 'B': 66, + 'N': 78, 'M': 77, ',': 188, '.': 190, '/': 191, 'Shift': 16, + '↑': 38, '#pD1': 97, '#pD2': 98, '#pD3': 99, 'En': 13, 'Space': 32, + '←': 37, '↓': 40, '→': 39, '#pD0': 96, '#pD.': 110 +}; + +Window_KeyConfig.prototype = Object.create(Window_Command.prototype); +Window_KeyConfig.prototype.constructor = Window_KeyConfig; + +Window_KeyConfig.prototype.initialize = function(helpWindow) { + var wy = helpWindow.height; + Window_Command.prototype.initialize.call(this, 0, wy); + this.setHelpWindow(helpWindow); + this.height = Graphics.boxHeight - wy; + this.refresh(); + this.activate(); + this.select(0); +}; + +Window_KeyConfig.prototype.windowWidth = function() { + return Graphics.boxWidth; +}; + +Window_KeyConfig.prototype.maxCols = function() { + return 21; +}; + +Window_KeyConfig.prototype.spacing = function() { + return 1; +}; + +Window_KeyConfig.prototype.itemHeight = function() { + return this.lineHeight() * 2; +}; + +Window_KeyConfig.prototype.itemTextAlign = function() { + return 'center'; +}; + +Window_KeyConfig.prototype.makeCommandList = function(index) { + for (var i = 0; i < Window_KeyConfig._keyLayout.length; ++i) { + var keyName = Window_KeyConfig._keyLayout[i]; + var enabled = this.isKeyEnabled(keyName); + this.addCommand(keyName, 'key', enabled); + } + this.addCommand(Yanfly.Param.KeyConfigDefaultTx, 'default', true); + for (var i = 0; i < 6; ++i) this.addCommand(' ', 'default', true); + this.addCommand(Yanfly.Param.KeyConfigWasdTx, 'wasd', true); + for (var i = 0; i < 6; ++i) this.addCommand(' ', 'wasd', true); + this.addCommand(Yanfly.Param.KeyConfigFinishTx, 'cancel', true); + for (var i = 0; i < 6; ++i) this.addCommand(' ', 'cancel', true); +}; + +Window_KeyConfig.prototype.isKeyEnabled = function(keyName) { + return !([' ', 'Enter', 'En', '↑', '←', '↓', '→'].contains(keyName)); +}; + +Window_KeyConfig.prototype.itemRect = function(index) { + var rect = Window_Selectable.prototype.itemRect.call(this, index); + var maxCols = this.maxCols(); + if ([41, 62].contains(index)) { + rect.y = Math.floor(41 / maxCols) * rect.height - this._scrollY; + rect.height = this.itemHeight() * 2; + } else if ([54, 55].contains(index)) { + rect.x = 54 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing(); + } else if ([63, 64].contains(index)) { + rect.x = 63 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing(); + } else if ([75, 76].contains(index)) { + rect.x = 75 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing(); + } else if ([83, 104].contains(index)) { + rect.y = Math.floor(83 / maxCols) * rect.height - this._scrollY; + rect.height = this.itemHeight() * 2; + } else if ([87, 88, 89, 90, 91, 92, 93].contains(index)) { + rect.x = 87 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing(); + } else if ([101, 102].contains(index)) { + rect.x = 101 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 2 - this.spacing(); + } else if ([105, 106, 107, 108, 109, 110, 111].contains(index)) { + rect.x = 105 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing(); + } else if ([112, 113, 114, 115, 116, 117, 118].contains(index)) { + rect.x = 112 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing(); + } else if ([119, 120, 121, 122, 123, 124, 125].contains(index)) { + rect.x = 119 % maxCols * (rect.width + this.spacing()) - this._scrollX; + rect.width = (this.itemWidth() + this.spacing()) * 7 - this.spacing(); + } + rect.y += Math.max(0, (this.contents.height - this.lineHeight() * 12) / 2); + return rect; +}; + +Window_KeyConfig.prototype.leaveEmpty = function(index) { + return [55, 56, 57, 58, 62, 64, 76, 77, 79, 84, 85, 86, 88, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 102, 104, 106, 107, 108, 109, 110, 111, 113, 114, + 115, 116, 117, 118, 120, 121, 122, 123, 124, 125].contains(index); +}; + +Window_KeyConfig.prototype.drawItem = function(index) { + if (this.leaveEmpty(index)) return; + this.drawItemRect(index); + this.drawItemKey(index); + this.drawItemAction(index); +}; + +Window_KeyConfig.prototype.drawItemRect = function(index) { + var rect = this.itemRect(index); + var color = this.getRectColor(index); + this.drawRect(rect.x+1, rect.y+1, rect.width-2, rect.height-2, color); +}; + +Window_KeyConfig.prototype.getRectColor = function(index) { + if (index > 104) return this.gaugeBackColor(); + var key = Window_KeyConfig._refId[this.commandName(index)]; + var action = Input.keyMapper[key]; + if (action !== undefined) { + return this.textColor(Yanfly.Param.KeyConfigAssignColor); + } else { + return this.gaugeBackColor(); + } +}; + +Window_KeyConfig.prototype.drawRect = function(dx, dy, dw, dh, color) { + this.changePaintOpacity(false); + this.contents.fillRect(dx, dy, dw, dh, color); + this.changePaintOpacity(true); +}; + +Window_KeyConfig.prototype.drawItemKey = function(index) { + this.resetFontSettings(); + this.contents.fontSize -= 8; + this.resetTextColor(); + this.changePaintOpacity(true); + var rect = this.itemRectForText(index); + var align = this.itemTextAlign(); + this.drawText(this.visualName(index), rect.x, rect.y, rect.width, align); +}; + +Window_KeyConfig.prototype.visualName = function(index) { + var text = this._list[index].name; + text = text.replace(/#pD/gi, '' ); + return text; +}; + +Window_KeyConfig.prototype.drawItemAction = function(index) { + var key = Window_KeyConfig._refId[this.commandName(index)]; + var action = Input.keyMapper[key]; + if (action === undefined) return; + this.resetFontSettings(); + this.contents.fontSize -= 8; + var color = this.textColor(Yanfly.Param.KeyConfigActionColor); + this.changeTextColor(color); + this.changePaintOpacity(true); + var rect = this.itemRectForText(index); + rect.y += this.lineHeight(); + var align = this.itemTextAlign(); + this.drawText(this.actionKey(action), rect.x, rect.y, rect.width, align); +}; + +Window_KeyConfig.prototype.actionKey = function(action) { + switch(action) { + case 'ok': + return Yanfly.Param.KeyConfigOkKey; + break; + case 'escape': + return Yanfly.Param.KeyConfigEscKey; + break; + case 'cancel': + return Yanfly.Param.KeyConfigCancelKey; + break; + case 'menu': + return Yanfly.Param.KeyConfigMenuKey; + break; + case 'shift': + return Yanfly.Param.KeyConfigShiftKey; + break; + case 'pageup': + return Yanfly.Param.KeyConfigPageUpKey; + break; + case 'pagedown': + return Yanfly.Param.KeyConfigPageDnKey; + break; + case 'left': + return Yanfly.Param.KeyConfigLeftKey; + break; + case 'up': + return Yanfly.Param.KeyConfigUpKey; + break; + case 'right': + return Yanfly.Param.KeyConfigRightKey; + break; + case 'down': + return Yanfly.Param.KeyConfigDownKey; + break; + default: + if (Imported.YEP_ButtonCommonEvents) { + if (Yanfly.Param.BCEList[action]) { + var id = Yanfly.Param.BCEList[action]; + var ev = $dataCommonEvents[id]; + return ev.configKey; + } + } + return ''; + break; + } +}; + +Window_KeyConfig.prototype.cursorDown = function(wrap) { + var index = this.index(); + if (index >= 105) { + this.select(index - 104); + } else if ([41, 62].contains(index)) { + this.select(83); + } else if ([83, 104].contains(index)) { + this.select(125); + } else { + Window_Command.prototype.cursorDown.call(this, wrap); + } +}; + +Window_KeyConfig.prototype.cursorUp = function(wrap) { + var index = this.index(); + if (index === 0) { + this.select(125); + } else if (index <= 20) { + this.select(index + 104); + } else if ([41, 62].contains(index)) { + this.select(20); + } else if ([83, 104].contains(index)) { + this.select(41); + } else { + Window_Command.prototype.cursorUp.call(this, wrap); + } +}; + +Window_KeyConfig.prototype.cursorRight = function(wrap) { + var index = this.index(); + if ([54, 55].contains(index)) { + this.select(56); + } else if ([63, 64].contains(index)) { + this.select(65); + } else if ([75, 76].contains(index)) { + this.select(77); + } else if ([87, 88, 89, 90, 91, 92, 93].contains(index)) { + this.select(94); + } else if ([101, 102].contains(index)) { + this.select(103); + } else if ([105, 106, 107, 108, 109, 110, 111].contains(index)) { + this.select(112); + } else if ([112, 113, 114, 115, 116, 117, 118].contains(index)) { + this.select(119); + } else if ([119, 120, 121, 122, 123, 124, 125].contains(index)) { + this.select(0); + } else { + Window_Command.prototype.cursorRight.call(this, wrap); + } +}; + +Window_KeyConfig.prototype.cursorLeft = function(wrap) { + var index = this.index(); + if (index === 0) { + this.select(125); + } else if ([54, 55].contains(index)) { + this.select(53); + } else if ([63, 64].contains(index)) { + this.select(62); + } else if ([75, 76].contains(index)) { + this.select(74); + } else if ([87, 88, 89, 90, 91, 92, 93].contains(index)) { + this.select(86); + } else if ([101, 102].contains(index)) { + this.select(100); + } else if ([105, 106, 107, 108, 109, 110, 111].contains(index)) { + this.select(104); + } else if ([112, 113, 114, 115, 116, 117, 118].contains(index)) { + this.select(111); + } else if ([119, 120, 121, 122, 123, 124, 125].contains(index)) { + this.select(118); + } else { + Window_Command.prototype.cursorLeft.call(this, wrap); + } +}; + +Window_KeyConfig.prototype.updateHelp = function() { + if (!this._helpWindow) return; + switch (this.currentSymbol()) { + case 'key': + this._helpWindow.setText(Yanfly.Param.KeyConfigKeyHelp); + break; + case 'default': + this._helpWindow.setText(Yanfly.Param.KeyConfigDefaultHelp); + break; + case 'wasd': + this._helpWindow.setText(Yanfly.Param.KeyConfigWasdHelp); + break; + case 'cancel': + this._helpWindow.setText(Yanfly.Param.KeyConfigFinishHelp); + break; + default: + this._helpWindow.clear(); + break; + } +}; + +//============================================================================= +// Window_KeyAction +//============================================================================= + +function Window_KeyAction() { + this.initialize.apply(this, arguments); +}; + +Window_KeyAction.prototype = Object.create(Window_Command.prototype); +Window_KeyAction.prototype.constructor = Window_KeyAction; + +Window_KeyAction.prototype.initialize = function() { + Window_Command.prototype.initialize.call(this, 0, 0); + this.x = (Graphics.boxWidth - this.width) / 2; + this.y = (Graphics.boxHeight - this.height) / 2; + this.openness = 0; + this.deactivate(); +}; + +Window_KeyAction.prototype.windowWidth = function() { + return Graphics.boxWidth / 2; +}; + +Window_KeyAction.prototype.windowHeight = function() { + var value = this.fittingHeight(this.numVisibleRows()) + return Math.min(value, Graphics.boxHeight); +}; + +Window_KeyAction.prototype.makeCommandList = function() { + this.addCommand(Yanfly.Param.KeyConfigClearTx, 'ok', true, 'clear'); + this.addCommand(Yanfly.Param.KeyConfigOkTx, 'ok', true, 'ok'); + this.addCommand(Yanfly.Param.KeyConfigEscTx, 'ok', true, 'escape'); + this.addCommand(Yanfly.Param.KeyConfigCancelTx, 'ok', true, 'cancel'); + this.addCommand(Yanfly.Param.KeyConfigMenuTx, 'ok', true, 'menu'); + this.addCommand(Yanfly.Param.KeyConfigShiftTx, 'ok', true, 'shift'); + this.addCommand(Yanfly.Param.KeyConfigPageUpTx, 'ok', true, 'pageup'); + this.addCommand(Yanfly.Param.KeyConfigPageDnTx, 'ok', true, 'pagedown'); + this.addCommand(Yanfly.Param.KeyConfigLeftTx, 'ok', true, 'left'); + this.addCommand(Yanfly.Param.KeyConfigUpTx, 'ok', true, 'up'); + this.addCommand(Yanfly.Param.KeyConfigRightTx, 'ok', true, 'right'); + this.addCommand(Yanfly.Param.KeyConfigDownTx, 'ok', true, 'down'); + if (Imported.YEP_ButtonCommonEvents) this.addButtonCommonEvents(); +}; + +Window_KeyAction.prototype.addButtonCommonEvents = function() { + var length = Yanfly.Param.KeyConfigEv.length; + for (var i = 0 ; i < length; ++i) { + var eventId = Yanfly.Param.KeyConfigEv[i]; + if (Yanfly.Param.KeyConfigKeys[eventId]) { + var ev = $dataCommonEvents[eventId]; + var key = Yanfly.Param.KeyConfigKeys[eventId]; + var text = ev.configText; + this.addCommand(text, 'ok', true, key); + } + } +}; + +//============================================================================= +// Scene_Options +//============================================================================= + +Yanfly.KeyConfig.Scene_Options_createOptionsWindow = + Scene_Options.prototype.createOptionsWindow; +Scene_Options.prototype.createOptionsWindow = function() { + Yanfly.KeyConfig.Scene_Options_createOptionsWindow.call(this); + this._optionsWindow.setHandler('keyConfig', this.commandKeyConfig.bind(this)); +}; + +Scene_Options.prototype.commandKeyConfig = function() { + SceneManager.push(Scene_KeyConfig); +}; + +//============================================================================= +// Scene_KeyConfig +//============================================================================= + +function Scene_KeyConfig() { + this.initialize.apply(this, arguments); +} + +Scene_KeyConfig.prototype = Object.create(Scene_MenuBase.prototype); +Scene_KeyConfig.prototype.constructor = Scene_KeyConfig; + +Scene_KeyConfig.prototype.initialize = function() { + Scene_MenuBase.prototype.initialize.call(this); +}; + +Scene_KeyConfig.prototype.create = function() { + Scene_MenuBase.prototype.create.call(this); + this.createHelpWindow(); + this.createKeyConfigWindow(); + this.createKeyActionWindow(); +}; + +Scene_KeyConfig.prototype.terminate = function() { + Scene_MenuBase.prototype.terminate.call(this); + ConfigManager.save(); +}; + +Scene_KeyConfig.prototype.refreshWindows = function() { + this._configWindow.refresh(); + this._configWindow.activate(); + ConfigManager.save(); +}; + +Scene_KeyConfig.prototype.createKeyConfigWindow = function() { + this._configWindow = new Window_KeyConfig(this._helpWindow); + this._configWindow.setHandler('default', this.commandDefault.bind(this)); + this._configWindow.setHandler('wasd', this.commandWasd.bind(this)); + this._configWindow.setHandler('cancel', this.commandExit.bind(this)); + this._configWindow.setHandler('key', this.commandKey.bind(this)); + this.addWindow(this._configWindow); +}; + +Scene_KeyConfig.prototype.createKeyActionWindow = function() { + this._actionWindow = new Window_KeyAction(); + this._actionWindow.setHandler('ok', this.onActionOk.bind(this)); + this._actionWindow.setHandler('cancel', this.onActionCancel.bind(this)); + this.addWindow(this._actionWindow); +}; + +Scene_KeyConfig.prototype.commandDefault = function() { + ConfigManager.keyMapper = + JSON.parse(JSON.stringify(ConfigManager.defaultMap)); + ConfigManager.applyKeyConfig(); + this.refreshWindows(); +}; + +Scene_KeyConfig.prototype.commandWasd = function() { + ConfigManager.keyMapper = JSON.parse(JSON.stringify(ConfigManager.wasdMap)); + ConfigManager.applyKeyConfig(); + this.refreshWindows(); +}; + +Scene_KeyConfig.prototype.commandKey = function() { + this._actionWindow.select(0); + this._actionWindow.open(); + this._actionWindow.activate(); +}; + +Scene_KeyConfig.prototype.onActionCancel = function() { + this._actionWindow.close(); + this._actionWindow.deactivate(); + this._configWindow.activate(); +}; + +Scene_KeyConfig.prototype.onActionOk = function() { + var action = this._actionWindow.currentExt(); + var name = this._configWindow.commandName(this._configWindow.index()); + var key = Window_KeyConfig._refId[name]; + if (action === 'clear') { + ConfigManager.keyMapper[key] = undefined; + } else { + ConfigManager.keyMapper[key] = action; + } + SoundManager.playEquip(); + ConfigManager.applyKeyConfig(); + this.onActionCancel(); + this.refreshWindows(); +}; + +Scene_KeyConfig.prototype.commandExit = function() { + if (!this.canExit()) { + SoundManager.playBuzzer(); + this._configWindow.activate(); + return; + } + this.popScene(); +}; + +Scene_KeyConfig.prototype.canExit = function() { + if (!Imported.YEP_ButtonCommonEvents) return true; + for (var i = 0; i < Yanfly.KeyConfig.RequiredCommonEvents.length; ++i) { + var commonEventId = Yanfly.KeyConfig.RequiredCommonEvents[i]; + if (!this.isCommonEventBound(commonEventId)) return false; + } + return true; +}; + +Scene_KeyConfig.prototype.isCommonEventBound = function(id) { + var length = Window_KeyConfig._keyLayout.length; + for (var i = 0; i < length; ++i) { + var key = Window_KeyConfig._refId[this._configWindow.commandName(i)]; + var action = Input.keyMapper[key]; + if (Yanfly.Param.BCEList[action] === id) return true; + } + return false; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_LevelUpGrowthEffects.js b/js/plugins/YEP_LevelUpGrowthEffects.js new file mode 100644 index 0000000..bf053e8 --- /dev/null +++ b/js/plugins/YEP_LevelUpGrowthEffects.js @@ -0,0 +1,294 @@ +//============================================================================= +// Yanfly Engine Plugins - Level Up Growth Effects +// YEP_LevelUpGrowthEffects.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_LevelUpGrowthEffects = true; + +var Yanfly = Yanfly || {}; +Yanfly.LvGrEf = Yanfly.LvGrEf || {}; +Yanfly.LvGrEf.version = 1.01; + +//============================================================================= + /*: + * @plugindesc v1.01 Equip an item that upon leveling up will raise stats? + * This plugin will let you do just that! + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin lets you create items that allow actor growth upon leveling up + * due to the actor, the equipment worn, class, learned skills, or any states + * applied to the actor upon leveling up. Growth options include increasing + * basic parameters, learning new skills, turning switches on/off, full + * recovery, and for those experienced with JavaScript, any kind of custom + * effect that can be done using code. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * Insert the following notetags into the respective database object noteboxes + * to acquire their Level Up Growth Effects. + * + * Actor, Class, Skill, Weapon, Armor, State Notetags: + * + * + * + * Upon leveling up, this will raise/reduce a particular 'stat' by x value. + * - Replace 'stat' with 'MaxHP', 'MaxMP', 'ATK', 'DEF', 'MAT', 'MDF', 'AGI', + * or 'LUK' to alter that specific stat. + * - Replace 'x' with a numeric value indicating how much growth to apply. + * + * + * Upon leveling up, this will teach the actor skill x. + * - Replace 'x' with the ID of the skill you wish to teach the actor. + * + * + * + * + * + * + * + * Upon leveling up, this will cause switch(es) x to turn on or off. + * - Replace 'x' with the ID of the switch(es) to turn on/off. + * - If using 'x to y', set 'x' to the starting ID and 'y' to the ending ID. + * - Insert multiples of this notetag to affect multiple switches. + * + * + * Upon leveling up, this will cause the Recover All effect to trigger for + * the actor. + * + * =========================================================================== + * Lunatic Mode + * =========================================================================== + * + * For those with JavaScript experience, you can make custom effects occur upon + * leveling up as well using these notetags: + * + * Actor, Class, Skill, Weapon, Armor, State Notetags: + * + * + * code + * code + * + * - Replace 'code' with the code you wish to run inside the notetags. + * + * --- Example --- + * + * + * var heal = actor.mdf; + * actor.gainHp(heal); + * + * - Upon leveling up, this will make the actor heal HP equal to the actor's + * current MDF parameter. + * + * --- Example --- + * + * + * if (actor.level >= 50) { + * var keepExp = true; + * actor.changeClass(5, keepExp); + * } + * + * - If actor's level has exceeded level 50, then the actor will class change + * into class ID 5. + * + * --- Example --- + * + * + * if (actor.level >= 25) { + * // Change sprite + * var characterName = 'Actor1'; + * var characterIndex = 0; + * actor.setCharacterImage(characterName, characterIndex); + * // Change Face + * var faceName = 'Actor1'; + * var faceIndex = 0; + * actor.setFaceImage(faceName, faceIndex); + * // Change SV Battler + * var battlerName = 'Actor1_1'; + * actor.setBattlerImage(battlerName); + * // Refresh Actor + * actor.refresh(); + * } + * + * - If actor's level has exceeded level 25, then the actor's map sprite, + * face graphic, and sideview battler will change into something else. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.01: + * - Bugfix made by Arisu's Dollhouse. + * - Fixed the Level Up Switch On/Off notetags. + * + * Version 1.00: + * - Finished Plugin! + * + * ============================================================================ + * End of Helpfile + * ============================================================================ + * + */ +//============================================================================= + +//============================================================================= +// Game_Actor +//============================================================================= + +Yanfly.LvGrEf.Game_Actor_changeClass = Game_Actor.prototype.changeClass; +Game_Actor.prototype.changeClass = function(classId, keepExp) { + this._preventLevelUpGrowth = true; + Yanfly.LvGrEf.Game_Actor_changeClass.call(this, classId, keepExp); + this._preventLevelUpGrowth = false; +}; + +Yanfly.LvGrEf.Game_Actor_levelUp = Game_Actor.prototype.levelUp; +Game_Actor.prototype.levelUp = function() { + Yanfly.LvGrEf.Game_Actor_levelUp.call(this); + if (this._preventLevelUpGrowth) return; + this.performLevelUpGrowth(); +}; + +Game_Actor.prototype.performLevelUpGrowth = function() { + var objects = [this.actor(), this.currentClass()]; + var equips = this.equips(); + var length = equips.length; + for (var i = 0; i < length; ++i) { + var equip = equips[i]; + if (!equip) continue; + objects.push(equip); + } + var states = this.states(); + var length = states.length; + for (var i = 0; i < length; ++i) { + var state = states[i]; + if (!state) continue; + objects.push(state); + } + var skills = this.skills(); + var length = skills.length; + for (var i = 0; i < length; ++i) { + var skill = skills[i]; + if (!skill) continue; + objects.push(skill); + } + var length = objects.length; + for (var i = 0; i < length; ++i) { + var object = objects[i]; + if (!object) continue; + this.performLevelUpGrowthFromObject(object); + } +}; + +Game_Actor.prototype.performLevelUpGrowthFromObject = function(object) { + var notedata = object.note.split(/[\r\n]+/); + var code = ''; + var evalMode = 'none'; + for (var i = 0; i < notedata.length; ++i) { + var line = notedata[i]; + // Level Up Stat Growth + if (line.match(//i)) { + var param = String(RegExp.$1).toUpperCase().trim(); + var value = Number(RegExp.$2); + if (['MAXHP','HP','MHP'].contains(param)) { + var paramId = 0; + } else if (['MAXMP','MP','MMP'].contains(param)) { + var paramId = 1; + } else if (['ATTACK','ATK'].contains(param)) { + var paramId = 2; + } else if (['DEFENSE','DEF'].contains(param)) { + var paramId = 3; + } else if (['MAGIC ATTACK','MAT','INT'].contains(param)) { + var paramId = 4; + } else if (['MAGIC DEFENSE','MDF','RES'].contains(param)) { + var paramId = 5; + } else if (['AGILITY','AGI','SPD'].contains(param)) { + var paramId = 6; + } else if (['LUCK','LUK'].contains(param)) { + var paramId = 7; + } else { + continue; + } + this.addParam(paramId, value); + + // Learn Skill + } else if (line.match(//i)) { + var skillId = Number(RegExp.$1); + this.learnSkill(skillId); + + // Switch On + } else if (line.match(//i)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + for (var a = 0; a < array.length; ++a) { + $gameSwitches.setValue(Number(array[a]), true); + } + } else if (line.match(//i)) { + var array = Yanfly.Util.getRange(Number(RegExp.$1), Number(RegExp.$2)); + for (var a = 0; a < array.length; ++a) { + $gameSwitches.setValue(Number(array[a]), true); + } + + // Switch Off + } else if (line.match(//i)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + for (var a = 0; a < array.length; ++a) { + $gameSwitches.setValue(Number(array[a]), false); + } + } else if (line.match(//i)) { + var array = Yanfly.Util.getRange(Number(RegExp.$1), Number(RegExp.$2)); + for (var a = 0; a < array.length; ++a) { + $gameSwitches.setValue(Number(array[a]), false); + } + + // Recover All + } else if (line.match(//i)) { + this.recoverAll(); + + // Custom Effect + } else if (line.match(//i)) { + evalMode = 'Custom Level Up Effect'; + } else if (line.match(/<\/Custom Level Up Effect>/i)) { + evalMode = 'none'; + } else if (evalMode === 'Custom Level Up Effect') { + code += line + '\n'; + + } + } + + // If custom effect + if (code !== '') { + var item = object; + var actor = this; + var user = this; + var subject = this; + var target = this; + var a = this; + var b = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + eval(code); + } +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.getRange = function(n, m) { + var result = []; + for (var i = n; i <= m; ++i) result.push(i); + return result; +}; + +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_MainMenuManager.js b/js/plugins/YEP_MainMenuManager.js new file mode 100644 index 0000000..8e85481 --- /dev/null +++ b/js/plugins/YEP_MainMenuManager.js @@ -0,0 +1,4783 @@ +//============================================================================= +// Yanfly Engine Plugins - Main Menu Manager +// YEP_MainMenuManager.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_MainMenuManager = true; + +var Yanfly = Yanfly || {}; +Yanfly.MMM = Yanfly.MMM || {}; +Yanfly.MMM.version = 1.03 + +//============================================================================= + /*: + * @plugindesc v1.03 This plugin allows you to manage the various aspects + * of your main menu. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Hide Actor Window + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish to hide the main actor window? + * NO - false YES - true + * @default false + * + * @param Hide Gold Window + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish to hide the gold window? + * NO - false YES - true + * @default false + * + * @param Blurry Background + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish to have a blurry background? + * NO - false YES - true Default: true + * @default true + * + * @param ---Command--- + * @default + * + * @param Command Alignment + * @parent ---Command--- + * @type combo + * @option left + * @option center + * @option right + * @desc This is the text alignment for the Command Window. + * left center right + * @default left + * + * @param Command Position + * @parent ---Command--- + * @type combo + * @option left + * @option right + * @desc Determine the command window's position. + * left right + * @default left + * + * @param Command Columns + * @parent ---Command--- + * @desc Amount of columns to be displayed by the command window. + * This is a formula. Default: 1 + * @default 1 + * + * @param Command Rows + * @parent ---Command--- + * @desc The number of visible rows for the command window. + * This is a formula. + * @default Math.min(10, Math.ceil(this.maxItems() / this.maxCols())) + * + * @param Command Width + * @parent ---Command--- + * @desc This is the command window width in pixels. + * This is a formula. Default: 240 + * @default 240 + * + * @param ---Menu Items--- + * @default + * + * @param ---Menu 1--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 1 Name + * @parent ---Menu 1--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 1 Symbol + * @parent ---Menu 1--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 1 Show + * @parent ---Menu 1--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 1 Enabled + * @parent ---Menu 1--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 1 Ext + * @parent ---Menu 1--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 1 Main Bind + * @parent ---Menu 1--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 1 Actor Bind + * @parent ---Menu 1--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 2--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 2 Name + * @parent ---Menu 2--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 2 Symbol + * @parent ---Menu 2--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 2 Show + * @parent ---Menu 2--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 2 Enabled + * @parent ---Menu 2--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 2 Ext + * @parent ---Menu 2--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 2 Main Bind + * @parent ---Menu 2--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 2 Actor Bind + * @parent ---Menu 2--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 3--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 3 Name + * @parent ---Menu 3--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 3 Symbol + * @parent ---Menu 3--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 3 Show + * @parent ---Menu 3--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 3 Enabled + * @parent ---Menu 3--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 3 Ext + * @parent ---Menu 3--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 3 Main Bind + * @parent ---Menu 3--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 3 Actor Bind + * @parent ---Menu 3--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 4--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 4 Name + * @parent ---Menu 4--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 4 Symbol + * @parent ---Menu 4--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 4 Show + * @parent ---Menu 4--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 4 Enabled + * @parent ---Menu 4--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 4 Ext + * @parent ---Menu 4--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 4 Main Bind + * @parent ---Menu 4--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 4 Actor Bind + * @parent ---Menu 4--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 5--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 5 Name + * @parent ---Menu 5--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 5 Symbol + * @parent ---Menu 5--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 5 Show + * @parent ---Menu 5--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 5 Enabled + * @parent ---Menu 5--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 5 Ext + * @parent ---Menu 5--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 5 Main Bind + * @parent ---Menu 5--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 5 Actor Bind + * @parent ---Menu 5--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 6--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 6 Name + * @parent ---Menu 6--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 6 Symbol + * @parent ---Menu 6--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 6 Show + * @parent ---Menu 6--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 6 Enabled + * @parent ---Menu 6--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 6 Ext + * @parent ---Menu 6--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 6 Main Bind + * @parent ---Menu 6--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 6 Actor Bind + * @parent ---Menu 6--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 7--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 7 Name + * @parent ---Menu 7--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 7 Symbol + * @parent ---Menu 7--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 7 Show + * @parent ---Menu 7--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 7 Enabled + * @parent ---Menu 7--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 7 Ext + * @parent ---Menu 7--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 7 Main Bind + * @parent ---Menu 7--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 7 Actor Bind + * @parent ---Menu 7--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 8--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 8 Name + * @parent ---Menu 8--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 8 Symbol + * @parent ---Menu 8--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 8 Show + * @parent ---Menu 8--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 8 Enabled + * @parent ---Menu 8--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 8 Ext + * @parent ---Menu 8--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 8 Main Bind + * @parent ---Menu 8--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 8 Actor Bind + * @parent ---Menu 8--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 9--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 9 Name + * @parent ---Menu 9--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 9 Symbol + * @parent ---Menu 9--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 9 Show + * @parent ---Menu 9--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 9 Enabled + * @parent ---Menu 9--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 9 Ext + * @parent ---Menu 9--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 9 Main Bind + * @parent ---Menu 9--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 9 Actor Bind + * @parent ---Menu 9--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 10--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 10 Name + * @parent ---Menu 10--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.item + * + * @param Menu 10 Symbol + * @parent ---Menu 10--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default item + * + * @param Menu 10 Show + * @parent ---Menu 10--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('item') + * + * @param Menu 10 Enabled + * @parent ---Menu 10--- + * @desc Is this menu command enabled? This is an eval. + * @default this.areMainCommandsEnabled() + * + * @param Menu 10 Ext + * @parent ---Menu 10--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 10 Main Bind + * @parent ---Menu 10--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandItem.bind(this) + * + * @param Menu 10 Actor Bind + * @parent ---Menu 10--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 11--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 11 Name + * @parent ---Menu 11--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 11 Symbol + * @parent ---Menu 11--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 11 Show + * @parent ---Menu 11--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 11 Enabled + * @parent ---Menu 11--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 11 Ext + * @parent ---Menu 11--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 11 Main Bind + * @parent ---Menu 11--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 11 Actor Bind + * @parent ---Menu 11--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 12--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 12 Name + * @parent ---Menu 12--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 12 Symbol + * @parent ---Menu 12--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 12 Show + * @parent ---Menu 12--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 12 Enabled + * @parent ---Menu 12--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 12 Ext + * @parent ---Menu 12--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 12 Main Bind + * @parent ---Menu 12--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 12 Actor Bind + * @parent ---Menu 12--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 13--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 13 Name + * @parent ---Menu 13--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 13 Symbol + * @parent ---Menu 13--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 13 Show + * @parent ---Menu 13--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 13 Enabled + * @parent ---Menu 13--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 13 Ext + * @parent ---Menu 13--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 13 Main Bind + * @parent ---Menu 13--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 13 Actor Bind + * @parent ---Menu 13--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 14--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 14 Name + * @parent ---Menu 14--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 14 Symbol + * @parent ---Menu 14--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 14 Show + * @parent ---Menu 14--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 14 Enabled + * @parent ---Menu 14--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 14 Ext + * @parent ---Menu 14--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 14 Main Bind + * @parent ---Menu 14--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 14 Actor Bind + * @parent ---Menu 14--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 15--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 15 Name + * @parent ---Menu 15--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.skill + * + * @param Menu 15 Symbol + * @parent ---Menu 15--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default skill + * + * @param Menu 15 Show + * @parent ---Menu 15--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('skill') + * + * @param Menu 15 Enabled + * @parent ---Menu 15--- + * @desc Is this menu command enabled? This is an eval. + * @default this.areMainCommandsEnabled() + * + * @param Menu 15 Ext + * @parent ---Menu 15--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 15 Main Bind + * @parent ---Menu 15--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandPersonal.bind(this) + * + * @param Menu 15 Actor Bind + * @parent ---Menu 15--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default SceneManager.push(Scene_Skill) + * + * @param ---Menu 16--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 16 Name + * @parent ---Menu 16--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 16 Symbol + * @parent ---Menu 16--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 16 Show + * @parent ---Menu 16--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 16 Enabled + * @parent ---Menu 16--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 16 Ext + * @parent ---Menu 16--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 16 Main Bind + * @parent ---Menu 16--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 16 Actor Bind + * @parent ---Menu 16--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 17--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 17 Name + * @parent ---Menu 17--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 17 Symbol + * @parent ---Menu 17--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 17 Show + * @parent ---Menu 17--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 17 Enabled + * @parent ---Menu 17--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 17 Ext + * @parent ---Menu 17--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 17 Main Bind + * @parent ---Menu 17--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 17 Actor Bind + * @parent ---Menu 17--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 18--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 18 Name + * @parent ---Menu 18--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 18 Symbol + * @parent ---Menu 18--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 18 Show + * @parent ---Menu 18--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 18 Enabled + * @parent ---Menu 18--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 18 Ext + * @parent ---Menu 18--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 18 Main Bind + * @parent ---Menu 18--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 18 Actor Bind + * @parent ---Menu 18--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 19--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 19 Name + * @parent ---Menu 19--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 19 Symbol + * @parent ---Menu 19--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 19 Show + * @parent ---Menu 19--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 19 Enabled + * @parent ---Menu 19--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 19 Ext + * @parent ---Menu 19--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 19 Main Bind + * @parent ---Menu 19--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 19 Actor Bind + * @parent ---Menu 19--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 20--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 20 Name + * @parent ---Menu 20--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.equip + * + * @param Menu 20 Symbol + * @parent ---Menu 20--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default equip + * + * @param Menu 20 Show + * @parent ---Menu 20--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('equip') + * + * @param Menu 20 Enabled + * @parent ---Menu 20--- + * @desc Is this menu command enabled? This is an eval. + * @default this.areMainCommandsEnabled() + * + * @param Menu 20 Ext + * @parent ---Menu 20--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 20 Main Bind + * @parent ---Menu 20--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandPersonal.bind(this) + * + * @param Menu 20 Actor Bind + * @parent ---Menu 20--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default SceneManager.push(Scene_Equip) + * + * @param ---Menu 21--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 21 Name + * @parent ---Menu 21--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 21 Symbol + * @parent ---Menu 21--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 21 Show + * @parent ---Menu 21--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 21 Enabled + * @parent ---Menu 21--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 21 Ext + * @parent ---Menu 21--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 21 Main Bind + * @parent ---Menu 21--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 21 Actor Bind + * @parent ---Menu 21--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 22--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 22 Name + * @parent ---Menu 22--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 22 Symbol + * @parent ---Menu 22--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 22 Show + * @parent ---Menu 22--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 22 Enabled + * @parent ---Menu 22--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 22 Ext + * @parent ---Menu 22--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 22 Main Bind + * @parent ---Menu 22--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 22 Actor Bind + * @parent ---Menu 22--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 23--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 23 Name + * @parent ---Menu 23--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 23 Symbol + * @parent ---Menu 23--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 23 Show + * @parent ---Menu 23--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 23 Enabled + * @parent ---Menu 23--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 23 Ext + * @parent ---Menu 23--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 23 Main Bind + * @parent ---Menu 23--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 23 Actor Bind + * @parent ---Menu 23--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 24--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 24 Name + * @parent ---Menu 24--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 24 Symbol + * @parent ---Menu 24--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 24 Show + * @parent ---Menu 24--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 24 Enabled + * @parent ---Menu 24--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 24 Ext + * @parent ---Menu 24--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 24 Main Bind + * @parent ---Menu 24--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 24 Actor Bind + * @parent ---Menu 24--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 25--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 25 Name + * @parent ---Menu 25--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default Yanfly.Param.CCCCmdName + * + * @param Menu 25 Symbol + * @parent ---Menu 25--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default class + * + * @param Menu 25 Show + * @parent ---Menu 25--- + * @desc This is the eval condition for this menu command to appear. + * @default Imported.YEP_ClassChangeCore && $gameSystem.isShowClass() + * + * @param Menu 25 Enabled + * @parent ---Menu 25--- + * @desc Is this menu command enabled? This is an eval. + * @default $gameSystem.isEnableClass() && this.areMainCommandsEnabled() + * + * @param Menu 25 Ext + * @parent ---Menu 25--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 25 Main Bind + * @parent ---Menu 25--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandPersonal.bind(this) + * + * @param Menu 25 Actor Bind + * @parent ---Menu 25--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default SceneManager.push(Scene_Class) + * + * @param ---Menu 26--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 26 Name + * @parent ---Menu 26--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 26 Symbol + * @parent ---Menu 26--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 26 Show + * @parent ---Menu 26--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 26 Enabled + * @parent ---Menu 26--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 26 Ext + * @parent ---Menu 26--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 26 Main Bind + * @parent ---Menu 26--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 26 Actor Bind + * @parent ---Menu 26--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 27--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 27 Name + * @parent ---Menu 27--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 27 Symbol + * @parent ---Menu 27--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 27 Show + * @parent ---Menu 27--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 27 Enabled + * @parent ---Menu 27--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 27 Ext + * @parent ---Menu 27--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 27 Main Bind + * @parent ---Menu 27--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 27 Actor Bind + * @parent ---Menu 27--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 28--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 28 Name + * @parent ---Menu 28--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 28 Symbol + * @parent ---Menu 28--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 28 Show + * @parent ---Menu 28--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 28 Enabled + * @parent ---Menu 28--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 28 Ext + * @parent ---Menu 28--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 28 Main Bind + * @parent ---Menu 28--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 28 Actor Bind + * @parent ---Menu 28--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 29--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 29 Name + * @parent ---Menu 29--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 29 Symbol + * @parent ---Menu 29--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 29 Show + * @parent ---Menu 29--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 29 Enabled + * @parent ---Menu 29--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 29 Ext + * @parent ---Menu 29--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 29 Main Bind + * @parent ---Menu 29--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 29 Actor Bind + * @parent ---Menu 29--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 30--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 30 Name + * @parent ---Menu 30--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 30 Symbol + * @parent ---Menu 30--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 30 Show + * @parent ---Menu 30--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 30 Enabled + * @parent ---Menu 30--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 30 Ext + * @parent ---Menu 30--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 30 Main Bind + * @parent ---Menu 30--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 30 Actor Bind + * @parent ---Menu 30--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 31--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 31 Name + * @parent ---Menu 31--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 31 Symbol + * @parent ---Menu 31--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 31 Show + * @parent ---Menu 31--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 31 Enabled + * @parent ---Menu 31--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 31 Ext + * @parent ---Menu 31--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 31 Main Bind + * @parent ---Menu 31--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 31 Actor Bind + * @parent ---Menu 31--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 32--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 32 Name + * @parent ---Menu 32--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 32 Symbol + * @parent ---Menu 32--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 32 Show + * @parent ---Menu 32--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 32 Enabled + * @parent ---Menu 32--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 32 Ext + * @parent ---Menu 32--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 32 Main Bind + * @parent ---Menu 32--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 32 Actor Bind + * @parent ---Menu 32--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 33--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 33 Name + * @parent ---Menu 33--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 33 Symbol + * @parent ---Menu 33--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 33 Show + * @parent ---Menu 33--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 33 Enabled + * @parent ---Menu 33--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 33 Ext + * @parent ---Menu 33--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 33 Main Bind + * @parent ---Menu 33--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 33 Actor Bind + * @parent ---Menu 33--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 34--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 34 Name + * @parent ---Menu 34--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 34 Symbol + * @parent ---Menu 34--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 34 Show + * @parent ---Menu 34--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 34 Enabled + * @parent ---Menu 34--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 34 Ext + * @parent ---Menu 34--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 34 Main Bind + * @parent ---Menu 34--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 34 Actor Bind + * @parent ---Menu 34--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 35--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 35 Name + * @parent ---Menu 35--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 35 Symbol + * @parent ---Menu 35--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 35 Show + * @parent ---Menu 35--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 35 Enabled + * @parent ---Menu 35--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 35 Ext + * @parent ---Menu 35--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 35 Main Bind + * @parent ---Menu 35--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 35 Actor Bind + * @parent ---Menu 35--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 36--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 36 Name + * @parent ---Menu 36--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 36 Symbol + * @parent ---Menu 36--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 36 Show + * @parent ---Menu 36--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 36 Enabled + * @parent ---Menu 36--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 36 Ext + * @parent ---Menu 36--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 36 Main Bind + * @parent ---Menu 36--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 36 Actor Bind + * @parent ---Menu 36--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 37--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 37 Name + * @parent ---Menu 37--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 37 Symbol + * @parent ---Menu 37--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 37 Show + * @parent ---Menu 37--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 37 Enabled + * @parent ---Menu 37--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 37 Ext + * @parent ---Menu 37--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 37 Main Bind + * @parent ---Menu 37--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 37 Actor Bind + * @parent ---Menu 37--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 38--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 38 Name + * @parent ---Menu 38--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 38 Symbol + * @parent ---Menu 38--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 38 Show + * @parent ---Menu 38--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 38 Enabled + * @parent ---Menu 38--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 38 Ext + * @parent ---Menu 38--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 38 Main Bind + * @parent ---Menu 38--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 38 Actor Bind + * @parent ---Menu 38--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 39--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 39 Name + * @parent ---Menu 39--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 39 Symbol + * @parent ---Menu 39--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 39 Show + * @parent ---Menu 39--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 39 Enabled + * @parent ---Menu 39--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 39 Ext + * @parent ---Menu 39--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 39 Main Bind + * @parent ---Menu 39--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 39 Actor Bind + * @parent ---Menu 39--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 40--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 40 Name + * @parent ---Menu 40--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 40 Symbol + * @parent ---Menu 40--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 40 Show + * @parent ---Menu 40--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 40 Enabled + * @parent ---Menu 40--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 40 Ext + * @parent ---Menu 40--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 40 Main Bind + * @parent ---Menu 40--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 40 Actor Bind + * @parent ---Menu 40--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 41--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 41 Name + * @parent ---Menu 41--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 41 Symbol + * @parent ---Menu 41--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 41 Show + * @parent ---Menu 41--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 41 Enabled + * @parent ---Menu 41--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 41 Ext + * @parent ---Menu 41--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 41 Main Bind + * @parent ---Menu 41--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 41 Actor Bind + * @parent ---Menu 41--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 42--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 42 Name + * @parent ---Menu 42--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 42 Symbol + * @parent ---Menu 42--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 42 Show + * @parent ---Menu 42--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 42 Enabled + * @parent ---Menu 42--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 42 Ext + * @parent ---Menu 42--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 42 Main Bind + * @parent ---Menu 42--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 42 Actor Bind + * @parent ---Menu 42--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 43--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 43 Name + * @parent ---Menu 43--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 43 Symbol + * @parent ---Menu 43--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 43 Show + * @parent ---Menu 43--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 43 Enabled + * @parent ---Menu 43--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 43 Ext + * @parent ---Menu 43--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 43 Main Bind + * @parent ---Menu 43--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 43 Actor Bind + * @parent ---Menu 43--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 44--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 44 Name + * @parent ---Menu 44--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 44 Symbol + * @parent ---Menu 44--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 44 Show + * @parent ---Menu 44--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 44 Enabled + * @parent ---Menu 44--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 44 Ext + * @parent ---Menu 44--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 44 Main Bind + * @parent ---Menu 44--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 44 Actor Bind + * @parent ---Menu 44--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 45--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 45 Name + * @parent ---Menu 45--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 45 Symbol + * @parent ---Menu 45--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 45 Show + * @parent ---Menu 45--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 45 Enabled + * @parent ---Menu 45--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 45 Ext + * @parent ---Menu 45--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 45 Main Bind + * @parent ---Menu 45--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 45 Actor Bind + * @parent ---Menu 45--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 46--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 46 Name + * @parent ---Menu 46--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 46 Symbol + * @parent ---Menu 46--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 46 Show + * @parent ---Menu 46--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 46 Enabled + * @parent ---Menu 46--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 46 Ext + * @parent ---Menu 46--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 46 Main Bind + * @parent ---Menu 46--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 46 Actor Bind + * @parent ---Menu 46--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 47--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 47 Name + * @parent ---Menu 47--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 47 Symbol + * @parent ---Menu 47--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 47 Show + * @parent ---Menu 47--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 47 Enabled + * @parent ---Menu 47--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 47 Ext + * @parent ---Menu 47--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 47 Main Bind + * @parent ---Menu 47--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 47 Actor Bind + * @parent ---Menu 47--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 48--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 48 Name + * @parent ---Menu 48--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 48 Symbol + * @parent ---Menu 48--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 48 Show + * @parent ---Menu 48--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 48 Enabled + * @parent ---Menu 48--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 48 Ext + * @parent ---Menu 48--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 48 Main Bind + * @parent ---Menu 48--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 48 Actor Bind + * @parent ---Menu 48--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 49--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 49 Name + * @parent ---Menu 49--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 49 Symbol + * @parent ---Menu 49--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 49 Show + * @parent ---Menu 49--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 49 Enabled + * @parent ---Menu 49--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 49 Ext + * @parent ---Menu 49--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 49 Main Bind + * @parent ---Menu 49--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 49 Actor Bind + * @parent ---Menu 49--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 50--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 50 Name + * @parent ---Menu 50--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.status + * + * @param Menu 50 Symbol + * @parent ---Menu 50--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default status + * + * @param Menu 50 Show + * @parent ---Menu 50--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('status') + * + * @param Menu 50 Enabled + * @parent ---Menu 50--- + * @desc Is this menu command enabled? This is an eval. + * @default this.areMainCommandsEnabled() + * + * @param Menu 50 Ext + * @parent ---Menu 50--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 50 Main Bind + * @parent ---Menu 50--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandPersonal.bind(this) + * + * @param Menu 50 Actor Bind + * @parent ---Menu 50--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default SceneManager.push(Scene_Status) + * + * @param ---Menu 51--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 51 Name + * @parent ---Menu 51--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 51 Symbol + * @parent ---Menu 51--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 51 Show + * @parent ---Menu 51--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 51 Enabled + * @parent ---Menu 51--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 51 Ext + * @parent ---Menu 51--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 51 Main Bind + * @parent ---Menu 51--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 51 Actor Bind + * @parent ---Menu 51--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 52--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 52 Name + * @parent ---Menu 52--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 52 Symbol + * @parent ---Menu 52--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 52 Show + * @parent ---Menu 52--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 52 Enabled + * @parent ---Menu 52--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 52 Ext + * @parent ---Menu 52--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 52 Main Bind + * @parent ---Menu 52--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 52 Actor Bind + * @parent ---Menu 52--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 53--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 53 Name + * @parent ---Menu 53--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 53 Symbol + * @parent ---Menu 53--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 53 Show + * @parent ---Menu 53--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 53 Enabled + * @parent ---Menu 53--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 53 Ext + * @parent ---Menu 53--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 53 Main Bind + * @parent ---Menu 53--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 53 Actor Bind + * @parent ---Menu 53--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 54--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 54 Name + * @parent ---Menu 54--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 54 Symbol + * @parent ---Menu 54--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 54 Show + * @parent ---Menu 54--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 54 Enabled + * @parent ---Menu 54--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 54 Ext + * @parent ---Menu 54--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 54 Main Bind + * @parent ---Menu 54--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 54 Actor Bind + * @parent ---Menu 54--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 55--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 55 Name + * @parent ---Menu 55--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.formation + * + * @param Menu 55 Symbol + * @parent ---Menu 55--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default formation + * + * @param Menu 55 Show + * @parent ---Menu 55--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('formation') + * + * @param Menu 55 Enabled + * @parent ---Menu 55--- + * @desc Is this menu command enabled? This is an eval. + * @default this.isFormationEnabled() + * + * @param Menu 55 Ext + * @parent ---Menu 55--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 55 Main Bind + * @parent ---Menu 55--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandFormation.bind(this) + * + * @param Menu 55 Actor Bind + * @parent ---Menu 55--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 56--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 56 Name + * @parent ---Menu 56--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 56 Symbol + * @parent ---Menu 56--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 56 Show + * @parent ---Menu 56--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 56 Enabled + * @parent ---Menu 56--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 56 Ext + * @parent ---Menu 56--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 56 Main Bind + * @parent ---Menu 56--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 56 Actor Bind + * @parent ---Menu 56--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 57--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 57 Name + * @parent ---Menu 57--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 57 Symbol + * @parent ---Menu 57--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 57 Show + * @parent ---Menu 57--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 57 Enabled + * @parent ---Menu 57--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 57 Ext + * @parent ---Menu 57--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 57 Main Bind + * @parent ---Menu 57--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 57 Actor Bind + * @parent ---Menu 57--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 58--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 58 Name + * @parent ---Menu 58--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 58 Symbol + * @parent ---Menu 58--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 58 Show + * @parent ---Menu 58--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 58 Enabled + * @parent ---Menu 58--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 58 Ext + * @parent ---Menu 58--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 58 Main Bind + * @parent ---Menu 58--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 58 Actor Bind + * @parent ---Menu 58--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 59--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 59 Name + * @parent ---Menu 59--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 59 Symbol + * @parent ---Menu 59--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 59 Show + * @parent ---Menu 59--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 59 Enabled + * @parent ---Menu 59--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 59 Ext + * @parent ---Menu 59--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 59 Main Bind + * @parent ---Menu 59--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 59 Actor Bind + * @parent ---Menu 59--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 60--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 60 Name + * @parent ---Menu 60--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 60 Symbol + * @parent ---Menu 60--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 60 Show + * @parent ---Menu 60--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 60 Enabled + * @parent ---Menu 60--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 60 Ext + * @parent ---Menu 60--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 60 Main Bind + * @parent ---Menu 60--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 60 Actor Bind + * @parent ---Menu 60--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 61--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 61 Name + * @parent ---Menu 61--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 61 Symbol + * @parent ---Menu 61--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 61 Show + * @parent ---Menu 61--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 61 Enabled + * @parent ---Menu 61--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 61 Ext + * @parent ---Menu 61--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 61 Main Bind + * @parent ---Menu 61--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 61 Actor Bind + * @parent ---Menu 61--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 62--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 62 Name + * @parent ---Menu 62--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 62 Symbol + * @parent ---Menu 62--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 62 Show + * @parent ---Menu 62--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 62 Enabled + * @parent ---Menu 62--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 62 Ext + * @parent ---Menu 62--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 62 Main Bind + * @parent ---Menu 62--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 62 Actor Bind + * @parent ---Menu 62--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 63--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 63 Name + * @parent ---Menu 63--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 63 Symbol + * @parent ---Menu 63--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 63 Show + * @parent ---Menu 63--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 63 Enabled + * @parent ---Menu 63--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 63 Ext + * @parent ---Menu 63--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 63 Main Bind + * @parent ---Menu 63--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 63 Actor Bind + * @parent ---Menu 63--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 64--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 64 Name + * @parent ---Menu 64--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 64 Symbol + * @parent ---Menu 64--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 64 Show + * @parent ---Menu 64--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 64 Enabled + * @parent ---Menu 64--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 64 Ext + * @parent ---Menu 64--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 64 Main Bind + * @parent ---Menu 64--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 64 Actor Bind + * @parent ---Menu 64--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 65--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 65 Name + * @parent ---Menu 65--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 65 Symbol + * @parent ---Menu 65--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 65 Show + * @parent ---Menu 65--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 65 Enabled + * @parent ---Menu 65--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 65 Ext + * @parent ---Menu 65--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 65 Main Bind + * @parent ---Menu 65--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 65 Actor Bind + * @parent ---Menu 65--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 66--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 66 Name + * @parent ---Menu 66--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 66 Symbol + * @parent ---Menu 66--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 66 Show + * @parent ---Menu 66--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 66 Enabled + * @parent ---Menu 66--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 66 Ext + * @parent ---Menu 66--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 66 Main Bind + * @parent ---Menu 66--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 66 Actor Bind + * @parent ---Menu 66--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 67--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 67 Name + * @parent ---Menu 67--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 67 Symbol + * @parent ---Menu 67--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 67 Show + * @parent ---Menu 67--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 67 Enabled + * @parent ---Menu 67--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 67 Ext + * @parent ---Menu 67--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 67 Main Bind + * @parent ---Menu 67--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 67 Actor Bind + * @parent ---Menu 67--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 68--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 68 Name + * @parent ---Menu 68--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 68 Symbol + * @parent ---Menu 68--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 68 Show + * @parent ---Menu 68--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 68 Enabled + * @parent ---Menu 68--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 68 Ext + * @parent ---Menu 68--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 68 Main Bind + * @parent ---Menu 68--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 68 Actor Bind + * @parent ---Menu 68--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 69--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 69 Name + * @parent ---Menu 69--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 69 Symbol + * @parent ---Menu 69--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 69 Show + * @parent ---Menu 69--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 69 Enabled + * @parent ---Menu 69--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 69 Ext + * @parent ---Menu 69--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 69 Main Bind + * @parent ---Menu 69--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 69 Actor Bind + * @parent ---Menu 69--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 70--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 70 Name + * @parent ---Menu 70--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 70 Symbol + * @parent ---Menu 70--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 70 Show + * @parent ---Menu 70--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 70 Enabled + * @parent ---Menu 70--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 70 Ext + * @parent ---Menu 70--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 70 Main Bind + * @parent ---Menu 70--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 70 Actor Bind + * @parent ---Menu 70--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 71--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 71 Name + * @parent ---Menu 71--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 71 Symbol + * @parent ---Menu 71--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 71 Show + * @parent ---Menu 71--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 71 Enabled + * @parent ---Menu 71--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 71 Ext + * @parent ---Menu 71--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 71 Main Bind + * @parent ---Menu 71--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 71 Actor Bind + * @parent ---Menu 71--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 72--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 72 Name + * @parent ---Menu 72--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 72 Symbol + * @parent ---Menu 72--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 72 Show + * @parent ---Menu 72--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 72 Enabled + * @parent ---Menu 72--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 72 Ext + * @parent ---Menu 72--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 72 Main Bind + * @parent ---Menu 72--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 72 Actor Bind + * @parent ---Menu 72--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 73--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 73 Name + * @parent ---Menu 73--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 73 Symbol + * @parent ---Menu 73--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 73 Show + * @parent ---Menu 73--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 73 Enabled + * @parent ---Menu 73--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 73 Ext + * @parent ---Menu 73--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 73 Main Bind + * @parent ---Menu 73--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 73 Actor Bind + * @parent ---Menu 73--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 74--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 74 Name + * @parent ---Menu 74--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 74 Symbol + * @parent ---Menu 74--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 74 Show + * @parent ---Menu 74--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 74 Enabled + * @parent ---Menu 74--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 74 Ext + * @parent ---Menu 74--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 74 Main Bind + * @parent ---Menu 74--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 74 Actor Bind + * @parent ---Menu 74--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 75--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 75 Name + * @parent ---Menu 75--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 75 Symbol + * @parent ---Menu 75--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 75 Show + * @parent ---Menu 75--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 75 Enabled + * @parent ---Menu 75--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 75 Ext + * @parent ---Menu 75--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 75 Main Bind + * @parent ---Menu 75--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 75 Actor Bind + * @parent ---Menu 75--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 76--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 76 Name + * @parent ---Menu 76--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 76 Symbol + * @parent ---Menu 76--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 76 Show + * @parent ---Menu 76--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 76 Enabled + * @parent ---Menu 76--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 76 Ext + * @parent ---Menu 76--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 76 Main Bind + * @parent ---Menu 76--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 76 Actor Bind + * @parent ---Menu 76--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 77--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 77 Name + * @parent ---Menu 77--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 77 Symbol + * @parent ---Menu 77--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 77 Show + * @parent ---Menu 77--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 77 Enabled + * @parent ---Menu 77--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 77 Ext + * @parent ---Menu 77--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 77 Main Bind + * @parent ---Menu 77--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 77 Actor Bind + * @parent ---Menu 77--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 78--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 78 Name + * @parent ---Menu 78--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 78 Symbol + * @parent ---Menu 78--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 78 Show + * @parent ---Menu 78--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 78 Enabled + * @parent ---Menu 78--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 78 Ext + * @parent ---Menu 78--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 78 Main Bind + * @parent ---Menu 78--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 78 Actor Bind + * @parent ---Menu 78--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 79--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 79 Name + * @parent ---Menu 79--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 79 Symbol + * @parent ---Menu 79--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 79 Show + * @parent ---Menu 79--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 79 Enabled + * @parent ---Menu 79--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 79 Ext + * @parent ---Menu 79--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 79 Main Bind + * @parent ---Menu 79--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 79 Actor Bind + * @parent ---Menu 79--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 80--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 80 Name + * @parent ---Menu 80--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 80 Symbol + * @parent ---Menu 80--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 80 Show + * @parent ---Menu 80--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 80 Enabled + * @parent ---Menu 80--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 80 Ext + * @parent ---Menu 80--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 80 Main Bind + * @parent ---Menu 80--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 80 Actor Bind + * @parent ---Menu 80--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 81--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 81 Name + * @parent ---Menu 81--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default 'Common Event 1' + * + * @param Menu 81 Symbol + * @parent ---Menu 81--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default common event + * + * @param Menu 81 Show + * @parent ---Menu 81--- + * @desc This is the eval condition for this menu command to appear. + * @default false + * + * @param Menu 81 Enabled + * @parent ---Menu 81--- + * @desc Is this menu command enabled? This is an eval. + * @default true + * + * @param Menu 81 Ext + * @parent ---Menu 81--- + * @desc This is the menu command's extension. This is an eval. + * @default 1 + * + * @param Menu 81 Main Bind + * @parent ---Menu 81--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.callCommonEvent.bind(this) + * + * @param Menu 81 Actor Bind + * @parent ---Menu 81--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 82--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 82 Name + * @parent ---Menu 82--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default 'Common Event 2' + * + * @param Menu 82 Symbol + * @parent ---Menu 82--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default common event + * + * @param Menu 82 Show + * @parent ---Menu 82--- + * @desc This is the eval condition for this menu command to appear. + * @default false + * + * @param Menu 82 Enabled + * @parent ---Menu 82--- + * @desc Is this menu command enabled? This is an eval. + * @default true + * + * @param Menu 82 Ext + * @parent ---Menu 82--- + * @desc This is the menu command's extension. This is an eval. + * @default 2 + * + * @param Menu 82 Main Bind + * @parent ---Menu 82--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.callCommonEvent.bind(this) + * + * @param Menu 82 Actor Bind + * @parent ---Menu 82--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 83--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 83 Name + * @parent ---Menu 83--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default 'Common Event 3' + * + * @param Menu 83 Symbol + * @parent ---Menu 83--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default common event + * + * @param Menu 83 Show + * @parent ---Menu 83--- + * @desc This is the eval condition for this menu command to appear. + * @default false + * + * @param Menu 83 Enabled + * @parent ---Menu 83--- + * @desc Is this menu command enabled? This is an eval. + * @default true + * + * @param Menu 83 Ext + * @parent ---Menu 83--- + * @desc This is the menu command's extension. This is an eval. + * @default 3 + * + * @param Menu 83 Main Bind + * @parent ---Menu 83--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.callCommonEvent.bind(this) + * + * @param Menu 83 Actor Bind + * @parent ---Menu 83--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 84--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 84 Name + * @parent ---Menu 84--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 84 Symbol + * @parent ---Menu 84--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 84 Show + * @parent ---Menu 84--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 84 Enabled + * @parent ---Menu 84--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 84 Ext + * @parent ---Menu 84--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 84 Main Bind + * @parent ---Menu 84--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 84 Actor Bind + * @parent ---Menu 84--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 85--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 85 Name + * @parent ---Menu 85--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 85 Symbol + * @parent ---Menu 85--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 85 Show + * @parent ---Menu 85--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 85 Enabled + * @parent ---Menu 85--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 85 Ext + * @parent ---Menu 85--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 85 Main Bind + * @parent ---Menu 85--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 85 Actor Bind + * @parent ---Menu 85--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 86--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 86 Name + * @parent ---Menu 86--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 86 Symbol + * @parent ---Menu 86--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 86 Show + * @parent ---Menu 86--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 86 Enabled + * @parent ---Menu 86--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 86 Ext + * @parent ---Menu 86--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 86 Main Bind + * @parent ---Menu 86--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 86 Actor Bind + * @parent ---Menu 86--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 87--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 87 Name + * @parent ---Menu 87--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 87 Symbol + * @parent ---Menu 87--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 87 Show + * @parent ---Menu 87--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 87 Enabled + * @parent ---Menu 87--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 87 Ext + * @parent ---Menu 87--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 87 Main Bind + * @parent ---Menu 87--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 87 Actor Bind + * @parent ---Menu 87--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 88--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 88 Name + * @parent ---Menu 88--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 88 Symbol + * @parent ---Menu 88--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 88 Show + * @parent ---Menu 88--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 88 Enabled + * @parent ---Menu 88--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 88 Ext + * @parent ---Menu 88--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 88 Main Bind + * @parent ---Menu 88--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 88 Actor Bind + * @parent ---Menu 88--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 89--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 89 Name + * @parent ---Menu 89--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 89 Symbol + * @parent ---Menu 89--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 89 Show + * @parent ---Menu 89--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 89 Enabled + * @parent ---Menu 89--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 89 Ext + * @parent ---Menu 89--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 89 Main Bind + * @parent ---Menu 89--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 89 Actor Bind + * @parent ---Menu 89--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 90--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 90 Name + * @parent ---Menu 90--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.options + * + * @param Menu 90 Symbol + * @parent ---Menu 90--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default options + * + * @param Menu 90 Show + * @parent ---Menu 90--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('options') + * + * @param Menu 90 Enabled + * @parent ---Menu 90--- + * @desc Is this menu command enabled? This is an eval. + * @default this.isOptionsEnabled() + * + * @param Menu 90 Ext + * @parent ---Menu 90--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 90 Main Bind + * @parent ---Menu 90--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandOptions.bind(this) + * + * @param Menu 90 Actor Bind + * @parent ---Menu 90--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 91--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 91 Name + * @parent ---Menu 91--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 91 Symbol + * @parent ---Menu 91--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 91 Show + * @parent ---Menu 91--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 91 Enabled + * @parent ---Menu 91--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 91 Ext + * @parent ---Menu 91--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 91 Main Bind + * @parent ---Menu 91--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 91 Actor Bind + * @parent ---Menu 91--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 92--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 92 Name + * @parent ---Menu 92--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 92 Symbol + * @parent ---Menu 92--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 92 Show + * @parent ---Menu 92--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 92 Enabled + * @parent ---Menu 92--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 92 Ext + * @parent ---Menu 92--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 92 Main Bind + * @parent ---Menu 92--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 92 Actor Bind + * @parent ---Menu 92--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 93--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 93 Name + * @parent ---Menu 93--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 93 Symbol + * @parent ---Menu 93--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 93 Show + * @parent ---Menu 93--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 93 Enabled + * @parent ---Menu 93--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 93 Ext + * @parent ---Menu 93--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 93 Main Bind + * @parent ---Menu 93--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 93 Actor Bind + * @parent ---Menu 93--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 94--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 94 Name + * @parent ---Menu 94--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 94 Symbol + * @parent ---Menu 94--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 94 Show + * @parent ---Menu 94--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 94 Enabled + * @parent ---Menu 94--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 94 Ext + * @parent ---Menu 94--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 94 Main Bind + * @parent ---Menu 94--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 94 Actor Bind + * @parent ---Menu 94--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 95--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 95 Name + * @parent ---Menu 95--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.save + * + * @param Menu 95 Symbol + * @parent ---Menu 95--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default save + * + * @param Menu 95 Show + * @parent ---Menu 95--- + * @desc This is the eval condition for this menu command to appear. + * @default this.needsCommand('save') + * + * @param Menu 95 Enabled + * @parent ---Menu 95--- + * @desc Is this menu command enabled? This is an eval. + * @default this.isSaveEnabled() + * + * @param Menu 95 Ext + * @parent ---Menu 95--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 95 Main Bind + * @parent ---Menu 95--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandSave.bind(this) + * + * @param Menu 95 Actor Bind + * @parent ---Menu 95--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 96--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 96 Name + * @parent ---Menu 96--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 96 Symbol + * @parent ---Menu 96--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 96 Show + * @parent ---Menu 96--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 96 Enabled + * @parent ---Menu 96--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 96 Ext + * @parent ---Menu 96--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 96 Main Bind + * @parent ---Menu 96--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 96 Actor Bind + * @parent ---Menu 96--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 97--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 97 Name + * @parent ---Menu 97--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 97 Symbol + * @parent ---Menu 97--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 97 Show + * @parent ---Menu 97--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 97 Enabled + * @parent ---Menu 97--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 97 Ext + * @parent ---Menu 97--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 97 Main Bind + * @parent ---Menu 97--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 97 Actor Bind + * @parent ---Menu 97--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 98--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 98 Name + * @parent ---Menu 98--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default + * + * @param Menu 98 Symbol + * @parent ---Menu 98--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default + * + * @param Menu 98 Show + * @parent ---Menu 98--- + * @desc This is the eval condition for this menu command to appear. + * @default + * + * @param Menu 98 Enabled + * @parent ---Menu 98--- + * @desc Is this menu command enabled? This is an eval. + * @default + * + * @param Menu 98 Ext + * @parent ---Menu 98--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 98 Main Bind + * @parent ---Menu 98--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default + * + * @param Menu 98 Actor Bind + * @parent ---Menu 98--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 99--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 99 Name + * @parent ---Menu 99--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default 'Debug' + * + * @param Menu 99 Symbol + * @parent ---Menu 99--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default debug + * + * @param Menu 99 Show + * @parent ---Menu 99--- + * @desc This is the eval condition for this menu command to appear. + * @default $gameTemp.isPlaytest() + * + * @param Menu 99 Enabled + * @parent ---Menu 99--- + * @desc Is this menu command enabled? This is an eval. + * @default true + * + * @param Menu 99 Ext + * @parent ---Menu 99--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 99 Main Bind + * @parent ---Menu 99--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandDebug.bind(this) + * + * @param Menu 99 Actor Bind + * @parent ---Menu 99--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @param ---Menu 100--- + * @parent ---Menu Items--- + * @default + * + * @param Menu 100 Name + * @parent ---Menu 100--- + * @desc This is the name for the menu command. This is an eval. To + * make it a string, use 'quotes' around the name. + * @default TextManager.gameEnd + * + * @param Menu 100 Symbol + * @parent ---Menu 100--- + * @desc This is the symbol for the menu command. This needs to be + * unique per menu command. + * @default gameEnd + * + * @param Menu 100 Show + * @parent ---Menu 100--- + * @desc This is the eval condition for this menu command to appear. + * @default true + * + * @param Menu 100 Enabled + * @parent ---Menu 100--- + * @desc Is this menu command enabled? This is an eval. + * @default this.isGameEndEnabled() + * + * @param Menu 100 Ext + * @parent ---Menu 100--- + * @desc This is the menu command's extension. This is an eval. + * @default + * + * @param Menu 100 Main Bind + * @parent ---Menu 100--- + * @desc This is the function activated by this menu command. + * This is an eval. + * @default this.commandGameEnd.bind(this) + * + * @param Menu 100 Actor Bind + * @parent ---Menu 100--- + * @desc If the menu command leads to selecting an actor, this is + * the function activated after selecting an actor. + * @default + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * For those who wish to alter the various aspects of the main menu commands + * without needing to touch the source code can use this plugin to do so. + * Although this plugin mostly ports the menu creation process to the Plugin + * Manager parameters, it allows for a cleaner way to handle the menu command + * management process. + * + * ============================================================================ + * How to Use This Plugin + * ============================================================================ + * + * Each section in the parameters is divided up into various parts. Each of + * these parts play a role in how the menu command functions. Here's what each + * part does: + * + * Name + * - This is how the command will appear visually in the main menu. This is an + * eval, which means, it's code driven. If you want the command to appear just + * as it is, use 'quotes' around it. + * + * Symbol + * - This is the identifier for the command. Each command should have a unique + * symbol, so much as to not cause conflicts with each command. However, shared + * symbols are perfectly fine as long as you're fine with them performing the + * same function when selected. + * + * Show + * - This is an eval condition for whether or not the command shows up in the + * main menu. If you wish for this to always show up, simply use 'true' without + * the quotes. + * + * Enabled + * - This is an eval condition for whether or not the command is enabled. The + * difference between showing a command and enabling a command is that a + * command can show, but it can't be selected because it isn't enabled. If you + * wish for this command to always be enabled, use 'true' without the quotes. + * + * Ext + * - Stands for extension. This serves as a secondary symbol for the command + * and it can be used for pretty much anything. It has no direct impact on the + * command unless the command's objective is related to the extension value. + * The majority of commands do not need to make use of the Ext value. + * + * Main Bind + * - This is an eval function that is to be ran when this command is selected + * straight from the main menu. The function that is to be bound to this + * command needs to be accessible from Scene_Menu is some way or another. For + * commands that are meant to select an actor first, use + * 'this.commandItem.bind(this)' without the quotes. + * + * Actor Bind + * - This is an eval function that is to be ran when an actor is selected after + * choosing this command, usually to push a scene. This function isn't needed + * for any menu commands that don't require selecting an actor. + * + * ============================================================================ + * Examples + * ============================================================================ + * + * The following are some examples to help you add/alter/change the way + * commands appear for your main menu. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Name: TextManager.item + * Symbol: item + * Show: this.needsCommand('item') + * Enabled: this.areMainCommandsEnabled() + * Ext: + * Main Bind: this.commandItem.bind(this) + * Actor Bind: + * + * The item command is made using the above example. 'TextManager.item' is how + * the command name will appear. It draws the name information from the + * database Text Manager entry for 'Item' and uses whatever you put into the + * database in here. The symbol 'item' is used to make the item command's + * unique identifier. In order for the command to show, it will run a + * 'needsCommand' function to check if it will appear. This 'needsCommand' + * function is related to your database on whether or not you want the item to + * appear there. In order for this command to be enabled, it will check for + * whether or not the main commands are enabled, which is related to whether or + * not there are actors in the current party. And finally, the line of code + * 'this.commandItem.bind(this)' is the command that will run once the item + * entry is selected. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Name: TextManager.skill + * Symbol: skill + * Show: this.needsCommand('skill') + * Enabled: this.areMainCommandsEnabled() + * Ext: + * Main Bind: this.commandPersonal.bind(this) + * Actor Bind: SceneManager.push(Scene_Skill) + * + * The skill command is made using the above example. 'TextManager.skill' is + * how the command name will appear. It draws the name information from the + * database Text Manager entry for 'Skill' and uses whatever you put into the + * database in here. The symbol 'skill' is used to make the skill command's + * unique identifier. In order for the command to show, it will run a line code + * 'needsCommand' function to check if it will appear. This 'needsCommand' + * function is related to your database on whether or not you want the skill + * option to appear there. In order for this command to be enabled, it will + * check for whether or not the main commands are enabled, which is related to + * whether or not there are actors in the current party. This time, the main + * bind command is to send the player to the actor selection process using + * 'this.commandPersonal.bind(this)' instead. Once the player selects an actor, + * 'SceneManager.push(Scene_Skill)' is then ran to send the player to + * Scene_Skill to manage the actor's skills. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Name: 'Common Event 1' + * Symbol: common event + * Show: false + * Enabled: true + * Ext: 1 + * Main Bind: this.callCommonEvent.bind(this) + * Actor Bind: + * + * This is a customized command that is included by default with the plugin. + * This command's name is 'Common Event 1', but it can be changed to whatever + * you want by simply changing what's in between the 'quotes' in the parameter + * settings. The symbol is the identifier for all common events. However, by + * default, this common event item does not show in the main menu. If you want + * it to appear, set the Show option to 'true' without the quotes and it will + * appear. Because the Enabled option is 'true', the command can always be + * selected by the player. The Ext actually has a role with this command. The + * Ext determines which common event is to be played. In this example, the Ext + * value is 1, which means common event 1 will be ran when this command is + * selected. Should the Ext value equal to 25, it will be common event 25 that + * will run once this command is selected. The reason is because the Main Bind + * for this command option is 'this.callCommonEvent.bind(this)', which is a + * function included in this plugin to allow for common events to be ran. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.03: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.02: + * - The gold window will now match the command window's width. + * + * Version 1.01: + * - Added 'Hide Actor Window', 'Hide Gold Window', 'Blurry Background' + * parameters for the plugin settings. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_MainMenuManager'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.MMMCmdAlign = String(Yanfly.Parameters['Command Alignment']); +Yanfly.Param.MMMCmdPosition = String(Yanfly.Parameters['Command Position']); +Yanfly.Param.MMMCmdCols = String(Yanfly.Parameters['Command Columns']); +Yanfly.Param.MMMCmdRows = String(Yanfly.Parameters['Command Rows']); +Yanfly.Param.MMMCmdWidth = String(Yanfly.Parameters['Command Width']); +Yanfly.Param.MMMHideActorWin = String(Yanfly.Parameters['Hide Actor Window']); +Yanfly.Param.MMMHideGoldWin = String(Yanfly.Parameters['Hide Gold Window']); +Yanfly.Param.MMMBlurryBG = String(Yanfly.Parameters['Blurry Background']); +Yanfly.MMM.Name = {}; +Yanfly.MMM.Symbol = {}; +Yanfly.MMM.Show = {}; +Yanfly.MMM.Enabled = {}; +Yanfly.MMM.Ext = {}; +Yanfly.MMM.MainBind = {}; +Yanfly.MMM.ActorBind = {}; +for (Yanfly.i = 1; Yanfly.i <= 100; ++Yanfly.i) { + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Name'])"; + Yanfly.MMM.Name[Yanfly.i] = eval(Yanfly.line); + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Symbol'])"; + Yanfly.MMM.Symbol[Yanfly.i] = eval(Yanfly.line); + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Show'])"; + Yanfly.MMM.Show[Yanfly.i] = eval(Yanfly.line); + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Enabled'])"; + Yanfly.MMM.Enabled[Yanfly.i] = eval(Yanfly.line); + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Ext'])"; + Yanfly.MMM.Ext[Yanfly.i] = eval(Yanfly.line); + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Main Bind'])"; + Yanfly.MMM.MainBind[Yanfly.i] = eval(Yanfly.line); + Yanfly.line = "String(Yanfly.Parameters['Menu " + Yanfly.i + " Actor Bind'])"; + Yanfly.MMM.ActorBind[Yanfly.i] = eval(Yanfly.line); +}; + +//============================================================================= +// SceneManager +//============================================================================= + +Yanfly.MMM.SceneManager_snapForBackground = SceneManager.snapForBackground; +SceneManager.snapForBackground = function() { + if (eval(Yanfly.Param.MMMBlurryBG)) { + Yanfly.MMM.SceneManager_snapForBackground.call(this); + } else { + this._backgroundBitmap = this.snap(); + } +}; + +//============================================================================= +// Window_MenuCommand +//============================================================================= + +Window_MenuCommand.prototype.makeCommandList = function() { + for (var i = 1; i <= 100; ++i) { + this.createCommand(i); + } +}; + +Window_MenuCommand.prototype.addMainCommands = function() { +}; + +Window_MenuCommand.prototype.addFormationCommand = function() { +}; + +Window_MenuCommand.prototype.addOriginalCommands = function() { +}; + +Window_MenuCommand.prototype.addOptionsCommand = function() { +}; + +Window_MenuCommand.prototype.addSaveCommand = function() { +}; + +Window_MenuCommand.prototype.addGameEndCommand = function() { +}; + +Window_MenuCommand.prototype.createCommand = function(i) { + var show = Yanfly.MMM.Show[i]; + if (show === '') return; + if (!eval(show)) return; + var name = Yanfly.MMM.Name[i]; + if (name === '') return; + name = eval(name); + var symbol = Yanfly.MMM.Symbol[i]; + if (symbol === '') return; + var enabled = eval(Yanfly.MMM.Enabled[i]); + if (enabled === '') enabled = true; + var ext = eval(Yanfly.MMM.Ext[i]); + this.addCommand(name, symbol, enabled, ext); + this.addSymbolBridge(symbol); +}; + +Window_MenuCommand.prototype.addSymbolBridge = function(symbol) { + if (symbol === 'item') this.addMainCommands(); + if (symbol === 'formation') this.addFormationCommand(); + if (symbol === 'formation') this.addOriginalCommands(); + if (symbol === 'options') this.addOptionsCommand(); + if (symbol === 'save') this.addSaveCommand(); + if (symbol === 'gameEnd') this.addGameEndCommand(); +}; + +Window_MenuCommand.prototype.itemTextAlign = function() { + return Yanfly.Param.MMMCmdAlign; +}; + +Window_MenuCommand.prototype.windowWidth = function() { + return eval(Yanfly.Param.MMMCmdWidth); +}; + +Window_MenuCommand.prototype.maxCols = function() { + return eval(Yanfly.Param.MMMCmdCols); +}; + +Window_MenuCommand.prototype.numVisibleRows = function() { + return eval(Yanfly.Param.MMMCmdRows); +}; + +//============================================================================= +// Window_MenuStatus +//============================================================================= + +Yanfly.MMM.Window_MenuStatus_initialize = + Window_MenuStatus.prototype.initialize; +Window_MenuStatus.prototype.initialize = function(wx, wy) { + this._initX = wx; + Yanfly.MMM.Window_MenuStatus_initialize.call(this, wx, wy); +}; + +Window_MenuStatus.prototype.windowWidth = function() { + return Graphics.boxWidth - this._initX; +}; + +//============================================================================= +// Scene_Menu +//============================================================================= + +Yanfly.MMM.Scene_Menu_create = Scene_Menu.prototype.create; +Scene_Menu.prototype.create = function() { + Yanfly.MMM.Scene_Menu_create.call(this); + this.repositionWindows(); +}; + +Scene_Menu.prototype.createCommandWindow = function() { + this._commandWindow = new Window_MenuCommand(0, 0); + this.createCommandWindowBinds(); + this._commandWindow.setHandler('cancel', this.popScene.bind(this)); + this.addWindow(this._commandWindow); +}; + +Yanfly.MMM.Scene_Menu_createGoldWindow = + Scene_Menu.prototype.createGoldWindow; +Scene_Menu.prototype.createGoldWindow = function() { + Yanfly.MMM.Scene_Menu_createGoldWindow.call(this); + if (eval(Yanfly.Param.MMMHideGoldWin)) this._goldWindow.hide(); +}; + +Yanfly.MMM.Scene_Menu_createStatusWindow = + Scene_Menu.prototype.createStatusWindow; +Scene_Menu.prototype.createStatusWindow = function() { + Yanfly.MMM.Scene_Menu_createStatusWindow.call(this); + if (eval(Yanfly.Param.MMMHideActorWin)) this._statusWindow.hide(); +}; + +Scene_Menu.prototype.createCommandWindowBinds = function() { + this._actorBinds = {}; + for (var i = 1; i <= 100; ++i) { + var symbol = Yanfly.MMM.Symbol[i]; + if (symbol === '') continue; + var bind = Yanfly.MMM.MainBind[i]; + if (bind === '') continue; + eval("this._commandWindow.setHandler('" + symbol + "', " + bind + ")"); + var actorBind = Yanfly.MMM.ActorBind[i]; + if (actorBind === '') continue; + this._actorBinds[symbol] = actorBind; + } +}; + +Scene_Menu.prototype.resizeGoldWindow = function() { + this._goldWindow.width = this._commandWindow.width; + this._goldWindow.createContents(); + this._goldWindow.refresh(); +}; + +Scene_Menu.prototype.repositionWindows = function() { + this.resizeGoldWindow(); + if (Yanfly.Param.MMMCmdPosition === 'right') { + this._commandWindow.x = Graphics.boxWidth - this._commandWindow.width; + this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width; + this._statusWindow.x = 0; + } else if (Yanfly.Param.MMMCmdPosition === 'left') { + this._commandWindow.x = 0; + this._goldWindow.x = 0; + this._statusWindow.x = this._commandWindow.width; + } +}; + +Yanfly.MMM.Scene_Menu_commandPersonal = Scene_Menu.prototype.commandPersonal; +Scene_Menu.prototype.commandPersonal = function() { + Yanfly.MMM.Scene_Menu_commandPersonal.call(this); + this._statusWindow.show(); +}; + +Scene_Menu.prototype.onPersonalOk = function() { + var symbol = this._commandWindow.currentSymbol(); + var actorBind = this._actorBinds[symbol]; + if (!actorBind) return; + eval(actorBind); +}; + +Yanfly.MMM.Scene_Menu_onPersonalCancel = Scene_Menu.prototype.onPersonalCancel; +Scene_Menu.prototype.onPersonalCancel = function() { + Yanfly.MMM.Scene_Menu_onPersonalCancel.call(this); + if (eval(Yanfly.Param.MMMHideActorWin)) this._statusWindow.hide(); +}; + +Scene_Menu.prototype.callCommonEvent = function() { + var ext = this._commandWindow.currentExt(); + $gameTemp.reserveCommonEvent(parseInt(ext)); + this.popScene(); +}; + +Scene_Menu.prototype.commandDebug = function() { + SceneManager.push(Scene_Debug); +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_MessageCore.js b/js/plugins/YEP_MessageCore.js new file mode 100644 index 0000000..f3e3f13 --- /dev/null +++ b/js/plugins/YEP_MessageCore.js @@ -0,0 +1,1425 @@ +//============================================================================= +// Yanfly Engine Plugins - Message Core +// YEP_MessageCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_MessageCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.Message = Yanfly.Message || {}; +Yanfly.Message.version = 1.19; + +//============================================================================= + /*: + * @plugindesc v1.19 Adds more features to the Message Window to customized + * the way your messages appear and functions. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Default Rows + * @parent ---General--- + * @type number + * @min 0 + * @desc This is default amount of rows the message box will have. + * Default: 4 + * @default 4 + * + * @param Default Width + * @parent ---General--- + * @desc This is default width for the message box in pixels. + * Default: Graphics.boxWidth + * @default Graphics.boxWidth + * + * @param Face Indent + * @parent ---General--- + * @desc If using a face graphic, this is how much text indents by. + * Default: Window_Base._faceWidth + 24 + * @default Window_Base._faceWidth + 24 + * + * @param Fast Forward Key + * @parent ---General--- + * @type combo + * @option tab + * @option shift + * @option control + * @option pageup + * @option pagedown + * @desc This is the key used for fast forwarding. + * @default pagedown + * + * @param Enable Fast Forward + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Enable fast forward button for your messages by default? + * NO - false YES - true + * @default true + * + * @param Word Wrapping + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Use this to enable or disable word wrapping by default. + * OFF - false ON - true + * @default false + * + * @param Description Wrap + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Enable or disable word wrapping for descriptions. + * OFF - false ON - true + * @default false + * + * @param Word Wrap Space + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Insert a space with manual line breaks? + * NO - false YES - true + * @default false + * + * @param Tight Wrap + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc If true and using a face for the message, the message will + * wrap tighter. NO - false YES - true + * @default false + * + * @param ---Font--- + * @default + * + * @param Font Name + * @parent ---Font--- + * @desc This is the default font used for the Message Window. + * Default: GameFont + * @default GameFont + * + * @param Font Name CH + * @parent ---Font--- + * @desc This is the default font used for the Message Window for Chinese. + * Default: SimHei, Heiti TC, sans-serif + * @default SimHei, Heiti TC, sans-serif + * + * @param Font Name KR + * @parent ---Font--- + * @desc This is the default font used for the Message Window for Korean. + * Default: Dotum, AppleGothic, sans-serif + * @default Dotum, AppleGothic, sans-serif + * + * @param Font Size + * @parent ---Font--- + * @type number + * @min 1 + * @desc This is the default font size used for the Message Window. + * Default: 28 + * @default 28 + * + * @param Font Size Change + * @parent ---Font--- + * @type number + * @min 1 + * @desc Whenever \{ and \} are used, they adjust by this value. + * Default: 12 + * @default 12 + * + * @param Font Changed Max + * @parent ---Font--- + * @type number + * @min 1 + * @desc This is the maximum size achieved by \{. + * Default: 96 + * @default 96 + * + * @param Font Changed Min + * @parent ---Font--- + * @type number + * @min 1 + * @desc This is the minimum size achieved by \{. + * Default: 12 + * @default 12 + * + * @param Font Outline + * @parent ---Font--- + * @type number + * @min 0 + * @desc This is the default font outline width for messages. + * Default: 4 + * @default 4 + * + * @param Maintain Font + * @parent ---Font--- + * @type boolean + * @on YES + * @off NO + * @desc When changing the font name or size, maintain for following + * messages. NO - false YES - true + * @default false + * + * @param ---Name Box--- + * @default + * + * @param Name Box Buffer X + * @parent ---Name Box--- + * @type number + * @desc This is the buffer for the x location of the Name Box. + * @default -28 + * + * @param Name Box Buffer Y + * @parent ---Name Box--- + * @type number + * @desc This is the buffer for the y location of the Name Box. + * @default 0 + * + * @param Name Box Padding + * @parent ---Name Box--- + * @desc This is the value for the padding of the Name Box. + * @default this.standardPadding() * 4 + * + * @param Name Box Color + * @parent ---Name Box--- + * @type number + * @min 0 + * @max 31 + * @desc This is the text color used for the Name Box. + * @default 0 + * + * @param Name Box Clear + * @parent ---Name Box--- + * @type boolean + * @on YES + * @off NO + * @desc Do you wish for the Name Box window to be clear? + * NO - false YES - true + * @default false + * + * @param Name Box Added Text + * @parent ---Name Box--- + * @desc This text is always added whenever the name box is used. + * This can be used to automatically set up colors. + * @default \c[6] + * + * @param Name Box Auto Close + * @parent ---Name Box--- + * @type boolean + * @on YES + * @off NO + * @desc Close the message window each time the namebox displays a + * different name? YES - true NO - false + * @default false + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * While RPG Maker MV Ace certainly improved the message system a whole lot, it + * wouldn't hurt to add in a few more features, such as name windows, + * converting textcodes to write out the icons and/or names of items, weapons, + * armours, and* more in quicker fashion. This script also gives the developer + * the ability to adjust the size of the message window during the game, give + * it a separate font, and to give the player a text fast-forward feature. + * + * ============================================================================ + * Word Wrapping + * ============================================================================ + * + * Word wrapping is now possible through the message system. You can enable and + * disable Word wrap using Plugin Commands. While using word wrap, if the word + * is to extend past the message window's area, it will automatically go to the + * following line. That said, word wrap will disable the editor's line breaks + * and will require you to use the ones provided by the plugin: + * + *
or is text code to apply a line break. Use this before or + * after a part in which you wish to start a new line. + * + * Keep in mind word wrapping is mostly for message windows. However, in other + * places that you'd like to see word wrapping, such as item descriptions, + * insert at the beginning of the text to enable it. + * + * ============================================================================ + * Text Codes + * ============================================================================ + * + * By using certain text codes in your messages, you can have the game replace + * them with the following: + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Text Code Function + * \V[n] Replaced by the value of the nth variable. + * \N[n] Replaced by the name of the nth actor. + * \P[n] Replaced by the name of the nth party member. + * \G Replaced by the currency unit. + * \C[n] Draw the subsequent text in the nth color. + * \I[n] Draw the nth icon. + * \{ Increases the text size by one step. + * \} Decreases the text size by one step. + * \\ Replaced with the backslash character. + * \$ Opens the gold window. + * \. Waits 1/4th seconds. + * \| Waits 1 second. + * \! Waits for button input. + * \> Display remaining text on same line all at once. + * \< Cancel the effect that displays text all at once. + * \^ Do not wait for input after displaying text. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Wait: Effect: + * \w[x] - Waits x frames (60 frames = 1 second). Message window only. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * NameWindow: Effect: + * \n - Creates a name box with x string. Left side. *Note + * \nc - Creates a name box with x string. Centered. *Note + * \nr - Creates a name box with x string. Right side. *Note + * + * *Note: Works for message window only. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Line Break Effect: + *
- If using word wrap mode, this will cause a line break. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Position: Effect: + * \px[x] - Sets x position of text to x. + * \py[x] - Sets y position of text to y. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Outline: Effect: + * \oc[x] - Sets outline colour to x. + * \ow[x] - Sets outline width to x. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Font: Effect: + * \fr - Resets all font changes. + * \fs[x] - Changes font size to x. + * \fn - Changes font name to x. + * \fb - Toggles font boldness. + * \fi - Toggles font italic. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Actor: Effect: + * \af[x] - Shows face of actor x. *Note + * \ac[x] - Writes out actor's class name. + * \an[x] - Writes out actor's nickname. + * + * *Note: Works for message window only. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Party: Effect: + * \pf[x] - Shows face of party member x. *Note + * \pc[x] - Writes out party member x's class name. + * \pn[x] - Writes out party member x's nickname. + * + * *Note: Works for message window only. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Names: Effect: + * \nc[x] - Writes out class x's name. + * \ni[x] - Writes out item x's name. + * \nw[x] - Writes out weapon x's name. + * \na[x] - Writes out armour x's name. + * \ns[x] - Writes out skill x's name. + * \nt[x] - Writes out state x's name. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * Icon Names: Effect: + * \ii[x] - Writes out item x's name including icon. + * \iw[x] - Writes out weapon x's name including icon. + * \ia[x] - Writes out armour x's name including icon. + * \is[x] - Writes out skill x's name including icon. + * \it[x] - Writes out state x's name including icon. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * + * And those are the text codes added with this script. Keep in mind that some + * of these text codes only work for the Message Window. Otherwise, they'll + * work for help descriptions, actor biographies, and others. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * The following are some plugin commands you can use through the Event Editor + * to change various aspects about the Message system. + * + * Plugin Comand + * MessageRows 6 + * - Changes the Message Rows displayed to 6. If you are using continuous + * Show Text events, this will continue displaying the following lines's + * texts until it hits the row limit. Anything after that is cut off until + * the next message starts to avoid accidental overlap. + * + * MessageWidth 400 + * - Changes the Message Window Width to 400 pixels. This will cut off any + * words that are shown too far to the right so adjust accordingly! + * + * EnableWordWrap + * - Enables wordwrapping. If a word extends past the window size, it will + * automatically move onto the next line. Keep in mind, you will need to use + * \br to perform line breaks. + * + * DisableWordWrap + * - This disables wordwrapping. Line breaks will be automatic at points + * where a new line is started in the editor. + * + * EnableFastForward + * - Enables Fast Forward key from working with messages. + * + * DisableFastForward + * - Disables Fast Forward key from working with messages. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.19: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.18: + * - Added new plugin parameters: 'Font Name CH' and 'Font Name KR'. + * + * Version 1.17: + * - Compatibility update with Message Macros for 'Name Box Auto Close' option. + * + * Version 1.16: + * - Added 'Tight Wrap' plugin parameter as a word wrap option to make the + * word wrap tighter when using faces. + * + * Version 1.15: + * - Added a failsafe where if the name box window would be off the screen, it + * will automatically reposition itself to under the main message window. + * + * Version 1.14: + * - Added 'Name Box Close' plugin parameter. If this is enabled, the message + * window will check for the Name Window speaker each time a follow up message + * occurs. If the name in the currently Name Window matches the name in the + * following Name Window, the message window will remain open. If it doesn't, + * the Name Window will close and reopen to indicate a new speaker. + * + * Version 1.13: + * - Added 'Maintain Font' plugin parameter under the Font category. This will + * allow you to use text codes \fn and \fs[x] to permanently change the font + * of your messages until you use it again. \fr will reset them to the plugin's + * default parameter settings. + * + * Version 1.12: + * - 'Word Wrap Space' parameter no longer leaves a space at the beginning of + * each message. + * + * Version 1.11: + * - Added 'Font Outline' parameter for the plugin parameters. This adjusts the + * font outline width used by default for only message fonts. + * + * Version 1.10: + * - Updated the Message Row system for Extended Message Pack 1's Autosizing + * feature to work with extended heights. + * + * Version 1.09: + * - Replaced 'Fast Forward' parameter with the 'Fast Forward Key' parameter + * and 'Enable Fast Forward' parameter. Two new Plugin Commands are added. They + * are 'EnableFastForward' and 'DisableFastForward' for control over when fast + * forwarding is allowed as to not cause timed cutscenes to desynch. + * + * Version 1.08: + * - Fixed a bug regarding Input Number positioning when the Message Window's + * position was middle. + * + * Version 1.07: + * - Added 'Word Wrap Space' for word wrap users. This parameter will leave a + * space behind for those who want a space left behind. + * + * Version 1.06: + * - Fixed a bug that would cause masking problems with mobile devices. + * + * Version 1.05: + * - Fixed a bug that would cause the namebox window to appear distorted. + * + * Version 1.04: + * - Fixed a bug that captured too many text codes with the namebox window. + * - Timed Name Window's closing speed with main window's closing speed. + * + * Verison 1.03: + * - Fixed a bug with textcodes that messed up wordwrapping. + * - Fixed a bug with font reset, italic, and bold textcodes. + * + * Version 1.02: + * - Namebox Window's overlap feature that's in every MV window is now disabled + * to allow for overlapping with main message window. + * - Updated window positioning for Branch Choices, Number Input, and Item + * Selection windows. + * + * Version 1.01: + * - Added 'Description Wrap' into the parameters to allow for all item + * descriptions to be automatically processed with word wrapping. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_MessageCore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.MSGDefaultRows = String(Yanfly.Parameters['Default Rows']); +Yanfly.Param.MSGDefaultWidth = String(Yanfly.Parameters['Default Width']); +Yanfly.Param.MSGFaceIndent = String(Yanfly.Parameters['Face Indent']); +Yanfly.Param.MSGFastForwardKey = String(Yanfly.Parameters['Fast Forward Key']); +Yanfly.Param.MSGFFOn = eval(String(Yanfly.Parameters['Enable Fast Forward'])); +Yanfly.Param.MSGWordWrap = String(Yanfly.Parameters['Word Wrapping']); +Yanfly.Param.MSGWordWrap = eval(Yanfly.Param.MSGWordWrap); +Yanfly.Param.MSGDescWrap = String(Yanfly.Parameters['Description Wrap']); +Yanfly.Param.MSGWrapSpace = eval(String(Yanfly.Parameters['Word Wrap Space'])); +Yanfly.Param.MSGTightWrap = eval(String(Yanfly.Parameters['Tight Wrap'])); + +Yanfly.Param.MSGFontName = String(Yanfly.Parameters['Font Name']); +Yanfly.Param.MSGCNFontName = String(Yanfly.Parameters['Font Name CH']); +Yanfly.Param.MSGKRFontName = String(Yanfly.Parameters['Font Name KR']); +Yanfly.Param.MSGFontSize = Number(Yanfly.Parameters['Font Size']); +Yanfly.Param.MSGFontSizeChange = String(Yanfly.Parameters['Font Size Change']); +Yanfly.Param.MSGFontChangeMax = String(Yanfly.Parameters['Font Changed Max']); +Yanfly.Param.MSGFontChangeMin = String(Yanfly.Parameters['Font Changed Min']); +Yanfly.Param.MSGFontOutline = Number(Yanfly.Parameters['Font Outline']); +Yanfly.Param.MSGFontMaintain = eval(String(Yanfly.Parameters['Maintain Font'])); + +Yanfly.Param.MSGNameBoxBufferX = String(Yanfly.Parameters['Name Box Buffer X']); +Yanfly.Param.MSGNameBoxBufferY = String(Yanfly.Parameters['Name Box Buffer Y']); +Yanfly.Param.MSGNameBoxPadding = String(Yanfly.Parameters['Name Box Padding']); +Yanfly.Param.MSGNameBoxColor = Number(Yanfly.Parameters['Name Box Color']); +Yanfly.Param.MSGNameBoxClear = String(Yanfly.Parameters['Name Box Clear']); +Yanfly.Param.MSGNameBoxText = String(Yanfly.Parameters['Name Box Added Text']); +Yanfly.Param.MSGNameBoxClose = String(Yanfly.Parameters['Name Box Auto Close']); +Yanfly.Param.MSGNameBoxClose = eval(Yanfly.Param.MSGNameBoxClose); + +//============================================================================= +// Bitmap +//============================================================================= + +Yanfly.Message.Bitmap_initialize = Bitmap.prototype.initialize; +Bitmap.prototype.initialize = function(width, height) { + Yanfly.Message.Bitmap_initialize.call(this, width, height); + this.fontBold = false; +}; + +Yanfly.Message.Bitmap_makeFontNameText = Bitmap.prototype._makeFontNameText; +Bitmap.prototype._makeFontNameText = function() { + if (this.fontBold) return 'Bold ' + this.fontSize + 'px ' + this.fontFace; + return Yanfly.Message.Bitmap_makeFontNameText.call(this); +}; + +//============================================================================= +// Game_System +//============================================================================= + +Yanfly.Message.Game_System_initialize = Game_System.prototype.initialize; +Game_System.prototype.initialize = function() { + Yanfly.Message.Game_System_initialize.call(this); + this.initMessageSystem(); + this.initMessageFontSettings(); +}; + +Game_System.prototype.initMessageSystem = function() { + this._wordWrap = Yanfly.Param.MSGWordWrap; + this._fastForward = Yanfly.Param.MSGFFOn; +}; + +Game_System.prototype.initMessageFontSettings = function() { + if ($dataSystem.locale.match(/^zh/)) { + this._msgFontName = Yanfly.Param.MSGCNFontName; + } else if ($dataSystem.locale.match(/^ko/)) { + this._msgFontName = Yanfly.Param.MSGKRFontName; + } else { + this._msgFontName = Yanfly.Param.MSGFontName; + } + this._msgFontSize = Yanfly.Param.MSGFontSize; + this._msgFontOutline = Yanfly.Param.MSGFontOutline; +}; + +Game_System.prototype.messageRows = function() { + var rows = eval(this._messageRows) || eval(Yanfly.Param.MSGDefaultRows); + return Math.max(1, Number(rows)); +}; + +Game_System.prototype.messageWidth = function() { + return eval(this._messageWidth) || eval(Yanfly.Param.MSGDefaultWidth); +}; + +Game_System.prototype.wordWrap = function() { + if (this._wordWrap === undefined) this.initMessageSystem(); + return this._wordWrap; +}; + +Game_System.prototype.setWordWrap = function(state) { + if (this._wordWrap === undefined) this.initMessageSystem(); + this._wordWrap = state; +}; + +Game_System.prototype.isFastFowardEnabled = function() { + if (this._fastForward === undefined) this.initMessageSystem(); + return this._fastForward; +}; + +Game_System.prototype.setFastFoward = function(state) { + if (this._fastForward === undefined) this.initMessageSystem(); + this._fastForward = state; +}; + +Game_System.prototype.getMessageFontName = function() { + if (this._msgFontName === undefined) this.initMessageFontSettings(); + return this._msgFontName; +}; + +Game_System.prototype.setMessageFontName = function(value) { + if (this._msgFontName === undefined) this.initMessageFontSettings(); + this._msgFontName = value; +}; + +Game_System.prototype.getMessageFontSize = function() { + if (this._msgFontSize === undefined) this.initMessageFontSettings(); + return this._msgFontSize; +}; + +Game_System.prototype.setMessageFontSize = function(value) { + if (this._msgFontSize === undefined) this.initMessageFontSettings(); + this._msgFontSize = value; +}; + +Game_System.prototype.getMessageFontOutline = function() { + if (this._msgFontOutline === undefined) this.initMessageFontSettings(); + return this._msgFontOutline; +}; + +Game_System.prototype.setMessageFontOutline = function(value) { + if (this._msgFontOutline === undefined) this.initMessageFontSettings(); + this._msgFontOutline = value; +}; + +//============================================================================= +// Game_Message +//============================================================================= + +Game_Message.prototype.addText = function(text) { + if ($gameSystem.wordWrap()) text = '' + text; + this.add(text); +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.Message.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.Message.Game_Interpreter_pluginCommand.call(this, command, args); + if (command === 'MessageRows') $gameSystem._messageRows = args[0]; + if (command === 'MessageWidth') $gameSystem._messageWidth = args[0]; + if (command === 'EnableWordWrap') $gameSystem.setWordWrap(true); + if (command === 'DisableWordWrap') $gameSystem.setWordWrap(false); + if (command === 'EnableFastForward') $gameSystem.setFastFoward(true); + if (command === 'DisableFastForward') $gameSystem.setFastFoward(false); +}; + +Game_Interpreter.prototype.command101 = function() { + if (!$gameMessage.isBusy()) { + $gameMessage.setFaceImage(this._params[0], this._params[1]); + $gameMessage.setBackground(this._params[2]); + $gameMessage.setPositionType(this._params[3]); + while (this.isContinueMessageString()) { + this._index++; + if (this._list[this._index].code === 401) { + $gameMessage.addText(this.currentCommand().parameters[0]); + } + if ($gameMessage._texts.length >= $gameSystem.messageRows()) break; + } + switch (this.nextEventCode()) { + case 102: + this._index++; + this.setupChoices(this.currentCommand().parameters); + break; + case 103: + this._index++; + this.setupNumInput(this.currentCommand().parameters); + break; + case 104: + this._index++; + this.setupItemChoice(this.currentCommand().parameters); + break; + } + this._index++; + this.setWaitMode('message'); + } + return false; +}; + +Game_Interpreter.prototype.isContinueMessageString = function() { + if (this.nextEventCode() === 101 && $gameSystem.messageRows() > 4) { + return true; + } else { + return this.nextEventCode() === 401; + } +}; + +//============================================================================= +// Window_Base +//============================================================================= + +Yanfly.Message.Window_Base_resetFontSettings = + Window_Base.prototype.resetFontSettings; +Window_Base.prototype.resetFontSettings = function() { + Yanfly.Message.Window_Base_resetFontSettings.call(this); + this.contents.fontBold = false; + this.contents.fontItalic = false; + this.contents.outlineColor = 'rgba(0, 0, 0, 0.5)'; + this.contents.outlineWidth = $gameSystem.getMessageFontOutline(); +}; + +Window_Base.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height + this.lineHeight()); +}; + +Yanfly.Message.Window_Base_convertEscapeCharacters = + Window_Base.prototype.convertEscapeCharacters; +Window_Base.prototype.convertEscapeCharacters = function(text) { + text = this.setWordWrap(text); + text = Yanfly.Message.Window_Base_convertEscapeCharacters.call(this, text); + text = this.convertExtraEscapeCharacters(text); + return text; +}; + +Window_Base.prototype.setWordWrap = function(text) { + this._wordWrap = false; + if (text.match(/<(?:WordWrap)>/i)) { + this._wordWrap = true; + text = text.replace(/<(?:WordWrap)>/gi, ''); + } + if (this._wordWrap) { + var replace = Yanfly.Param.MSGWrapSpace ? ' ' : ''; + text = text.replace(/[\n\r]+/g, replace); + } + if (this._wordWrap) { + text = text.replace(/<(?:BR|line break)>/gi, '\n'); + } else { + text = text.replace(/<(?:BR|line break)>/gi, ''); + } + return text; +}; + +Window_Base.prototype.convertExtraEscapeCharacters = function(text) { + // Font Codes + text = text.replace(/\x1bFR/gi, '\x1bMSGCORE[0]'); + text = text.replace(/\x1bFB/gi, '\x1bMSGCORE[1]'); + text = text.replace(/\x1bFI/gi, '\x1bMSGCORE[2]'); + // \AC[n] + text = text.replace(/\x1bAC\[(\d+)\]/gi, function() { + return this.actorClassName(parseInt(arguments[1])); + }.bind(this)); + // \AN[n] + text = text.replace(/\x1bAN\[(\d+)\]/gi, function() { + return this.actorNickname(parseInt(arguments[1])); + }.bind(this)); + // \PC[n] + text = text.replace(/\x1bPC\[(\d+)\]/gi, function() { + return this.partyClassName(parseInt(arguments[1])); + }.bind(this)); + // \PN[n] + text = text.replace(/\x1bPN\[(\d+)\]/gi, function() { + return this.partyNickname(parseInt(arguments[1])); + }.bind(this)); + // \NC[n] + text = text.replace(/\x1bNC\[(\d+)\]/gi, function() { + return $dataClasses[parseInt(arguments[1])].name; + }.bind(this)); + // \NI[n] + text = text.replace(/\x1bNI\[(\d+)\]/gi, function() { + return $dataItems[parseInt(arguments[1])].name; + }.bind(this)); + // \NW[n] + text = text.replace(/\x1bNW\[(\d+)\]/gi, function() { + return $dataWeapons[parseInt(arguments[1])].name; + }.bind(this)); + // \NA[n] + text = text.replace(/\x1bNA\[(\d+)\]/gi, function() { + return $dataArmors[parseInt(arguments[1])].name; + }.bind(this)); + // \NE[n] + text = text.replace(/\x1bNE\[(\d+)\]/gi, function() { + return $dataEnemies[parseInt(arguments[1])].name; + }.bind(this)); + // \NS[n] + text = text.replace(/\x1bNS\[(\d+)\]/gi, function() { + return $dataSkills[parseInt(arguments[1])].name; + }.bind(this)); + // \NT[n] + text = text.replace(/\x1bNT\[(\d+)\]/gi, function() { + return $dataStates[parseInt(arguments[1])].name; + }.bind(this)); + // \II[n] + text = text.replace(/\x1bII\[(\d+)\]/gi, function() { + return this.escapeIconItem(arguments[1], $dataItems); + }.bind(this)); + // \IW[n] + text = text.replace(/\x1bIW\[(\d+)\]/gi, function() { + return this.escapeIconItem(arguments[1], $dataWeapons); + }.bind(this)); + // \IA[n] + text = text.replace(/\x1bIA\[(\d+)\]/gi, function() { + return this.escapeIconItem(arguments[1], $dataArmors); + }.bind(this)); + // \IS[n] + text = text.replace(/\x1bIS\[(\d+)\]/gi, function() { + return this.escapeIconItem(arguments[1], $dataSkills); + }.bind(this)); + // \IT[n] + text = text.replace(/\x1bIT\[(\d+)\]/gi, function() { + return this.escapeIconItem(arguments[1], $dataStates); + }.bind(this)); + // Finish + return text; +}; + +Window_Base.prototype.actorClassName = function(n) { + var actor = n >= 1 ? $gameActors.actor(n) : null; + return actor ? actor.currentClass().name : ''; +}; + +Window_Base.prototype.actorNickname = function(n) { + var actor = n >= 1 ? $gameActors.actor(n) : null; + return actor ? actor.nickname() : ''; +}; + +Window_Base.prototype.partyClassName = function(n) { + var actor = n >= 1 ? $gameParty.members()[n - 1] : null; + return actor ? actor.currentClass().name : ''; +}; + +Window_Base.prototype.partyNickname = function(n) { + var actor = n >= 1 ? $gameParty.members()[n - 1] : null; + return actor ? actor.nickname() : ''; +}; + +Window_Base.prototype.escapeIconItem = function(n, database) { + return '\x1bI[' + database[n].iconIndex + ']' + database[n].name; +}; + +Window_Base.prototype.obtainEscapeString = function(textState) { + var arr = /^\<(.*?)\>/.exec(textState.text.slice(textState.index)); + if (arr) { + textState.index += arr[0].length; + return String(arr[0].slice(1, arr[0].length - 1)); + } else { + return ''; + } +}; + +Yanfly.Message.Window_Base_processEscapeCharacter = + Window_Base.prototype.processEscapeCharacter; +Window_Base.prototype.processEscapeCharacter = function(code, textState) { + switch (code) { + case 'MSGCORE': + var id = this.obtainEscapeParam(textState); + if (id === 0) { + $gameSystem.initMessageFontSettings(); + this.resetFontSettings(); + } + if (id === 1) this.contents.fontBold = !this.contents.fontBold; + if (id === 2) this.contents.fontItalic = !this.contents.fontItalic; + break; + case 'FS': + var size = this.obtainEscapeParam(textState); + this.contents.fontSize = size; + if (Yanfly.Param.MSGFontMaintain) $gameSystem.setMessageFontSize(size); + break; + case 'FN': + var name = this.obtainEscapeString(textState); + this.contents.fontFace = name; + if (Yanfly.Param.MSGFontMaintain) $gameSystem.setMessageFontName(name); + break; + case 'OC': + var id = this.obtainEscapeParam(textState); + this.contents.outlineColor = this.textColor(id); + break; + case 'OW': + this.contents.outlineWidth = this.obtainEscapeParam(textState); + break; + case 'PX': + textState.x = this.obtainEscapeParam(textState); + break; + case 'PY': + textState.y = this.obtainEscapeParam(textState); + break; + default: + Yanfly.Message.Window_Base_processEscapeCharacter.call(this, + code, textState); + break; + } +}; + +Window_Base.prototype.makeFontBigger = function() { + var size = this.contents.fontSize + eval(Yanfly.Param.MSGFontSizeChange); + this.contents.fontSize = Math.min(size, Yanfly.Param.MSGFontChangeMax); +}; + +Window_Base.prototype.makeFontSmaller = function() { + var size = this.contents.fontSize - eval(Yanfly.Param.MSGFontSizeChange); + this.contents.fontSize = Math.max(size, Yanfly.Param.MSGFontChangeMin); +}; + +Yanfly.Message.Window_Base_processNormalCharacter = + Window_Base.prototype.processNormalCharacter; +Window_Base.prototype.processNormalCharacter = function(textState) { + if (this.checkWordWrap(textState)) return this.processNewLine(textState); + Yanfly.Message.Window_Base_processNormalCharacter.call(this, textState); +}; + +Window_Base.prototype.checkWordWrap = function(textState) { + if (!textState) return false; + if (!this._wordWrap) return false; + if (textState.text[textState.index] === ' ') { + var nextSpace = textState.text.indexOf(' ', textState.index + 1); + var nextBreak = textState.text.indexOf('\n', textState.index + 1); + if (nextSpace < 0) nextSpace = textState.text.length + 1; + if (nextBreak > 0) nextSpace = Math.min(nextSpace, nextBreak); + var word = textState.text.substring(textState.index, nextSpace); + var size = this.textWidthExCheck(word); + } + return (size + textState.x > this.wordwrapWidth()); +}; + +Window_Base.prototype.wordwrapWidth = function(){ + return this.contents.width; +}; + +Window_Base.prototype.saveCurrentWindowSettings = function(){ + this._saveFontFace = this.contents.fontFace; + this._saveFontSize = this.contents.fontSize; + this._savetextColor = this.contents.textColor; + this._saveFontBold = this.contents.fontBold; + this._saveFontItalic = this.contents.fontItalic; + this._saveOutlineColor = this.contents.outlineColor; + this._saveOutlineWidth = this.contents.outlineWidth; +}; + +Window_Base.prototype.restoreCurrentWindowSettings = function(){ + this.contents.fontFace = this._saveFontFace; + this.contents.fontSize = this._saveFontSize; + this.contents.textColor = this._savetextColor; + this.contents.fontBold = this._saveFontBold; + this.contents.fontItalic = this._saveFontItalic; + this.contents.outlineColor = this._saveOutlineColor; + this.contents.outlineWidth = this._saveOutlineWidth; +}; + +Window_Base.prototype.clearCurrentWindowSettings = function(){ + this._saveFontFace = undefined; + this._saveFontSize = undefined; + this._savetextColor = undefined; + this._saveFontBold = undefined; + this._saveFontItalic = undefined; + this._saveOutlineColor = undefined; + this._saveOutlineWidth = undefined; +}; + +Window_Base.prototype.textWidthExCheck = function(text) { + var setting = this._wordWrap; + this._wordWrap = false; + this.saveCurrentWindowSettings(); + this._checkWordWrapMode = true; + var value = this.drawTextEx(text, 0, this.contents.height); + this._checkWordWrapMode = false; + this.restoreCurrentWindowSettings(); + this.clearCurrentWindowSettings(); + this._wordWrap = setting; + return value; +}; + +//============================================================================= +// Window_Help +//============================================================================= + +Yanfly.Message.Window_Help_setItem = Window_Help.prototype.setItem; +Window_Help.prototype.setItem = function(item) { + if (eval(Yanfly.Param.MSGDescWrap)) { + this.setText(item ? '' + item.description : ''); + } else { + Yanfly.Message.Window_Help_setItem.call(this, item); + } +}; + +//============================================================================= +// Window_ChoiceList +//============================================================================= + +Window_ChoiceList.prototype.standardFontFace = function() { + return $gameSystem.getMessageFontName(); +}; + +Window_ChoiceList.prototype.standardFontSize = function() { + return $gameSystem.getMessageFontSize(); +}; + +Yanfly.Message.Window_ChoiceList_updatePlacement = + Window_ChoiceList.prototype.updatePlacement; +Window_ChoiceList.prototype.updatePlacement = function() { + Yanfly.Message.Window_ChoiceList_updatePlacement.call(this); + var messagePosType = $gameMessage.positionType(); + if (messagePosType === 0) { + this.y = this._messageWindow.height; + } else if (messagePosType === 2) { + this.y = Graphics.boxHeight - this._messageWindow.height - this.height; + } +}; + +//============================================================================= +// Window_NumberInput +//============================================================================= + +Yanfly.Message.Window_NumberInput_updatePlacement = + Window_NumberInput.prototype.updatePlacement; +Window_NumberInput.prototype.updatePlacement = function() { + Yanfly.Message.Window_NumberInput_updatePlacement.call(this); + var messageY = this._messageWindow.y; + var messagePosType = $gameMessage.positionType(); + if (messagePosType === 0) { + this.y = this._messageWindow.height; + } else if (messagePosType === 1) { + if (messageY >= Graphics.boxHeight / 2) { + this.y = messageY - this.height; + } else { + this.y = messageY + this._messageWindow.height; + } + } else if (messagePosType === 2) { + this.y = Graphics.boxHeight - this._messageWindow.height - this.height; + } +}; + +//============================================================================= +// Window_EventItem +//============================================================================= + +Yanfly.Message.Window_EventItem_updatePlacement = + Window_EventItem.prototype.updatePlacement; +Window_EventItem.prototype.updatePlacement = function() { + Yanfly.Message.Window_EventItem_updatePlacement.call(this); + var messagePosType = $gameMessage.positionType(); + if (messagePosType === 0) { + this.y = Graphics.boxHeight - this.height; + } else if (messagePosType === 2) { + this.y = 0; + } +}; + +//============================================================================= +// Window_ScrollText +//============================================================================= + +Window_ScrollText.prototype.standardFontFace = function() { + return $gameSystem.getMessageFontName(); +}; + +Window_ScrollText.prototype.standardFontSize = function() { + return $gameSystem.getMessageFontSize(); +}; + +//============================================================================= +// Window_NameBox +//============================================================================= + +Yanfly.DisableWebGLMask = false; + +function Window_NameBox() { + this.initialize.apply(this, arguments); +} + +Window_NameBox.prototype = Object.create(Window_Base.prototype); +Window_NameBox.prototype.constructor = Window_NameBox; + +Window_NameBox.prototype.initialize = function(parentWindow) { + this._parentWindow = parentWindow; + Window_Base.prototype.initialize.call(this, 0, 0, 240, this.windowHeight()); + this._text = ''; + this._lastNameText = ''; + this._openness = 0; + this._closeCounter = 0; + this.deactivate(); + if (eval(Yanfly.Param.MSGNameBoxClear)) { + this.backOpacity = 0; + this.opacity = 0; + } + this.hide(); +}; + +Window_NameBox.prototype.windowWidth = function() { + this.resetFontSettings(); + var dw = this.textWidthEx(this._text); + dw += this.padding * 2; + var width = dw + eval(Yanfly.Param.MSGNameBoxPadding) + return Math.ceil(width); +}; + +Window_NameBox.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +Window_NameBox.prototype.calcNormalCharacter = function(textState) { + return this.textWidth(textState.text[textState.index++]); +}; + +Window_NameBox.prototype.windowHeight = function() { + return this.fittingHeight(1); +}; + +Window_NameBox.prototype.standardFontFace = function() { + return $gameSystem.getMessageFontName(); +}; + +Window_NameBox.prototype.standardFontSize = function() { + return $gameSystem.getMessageFontSize(); +}; + +Window_NameBox.prototype.update = function() { + Window_Base.prototype.update.call(this); + if (this.active) return; + if (this.isClosed()) return; + if (this.isClosing()) return; + if (this._closeCounter-- > 0) return; + if (this._parentWindow.isClosing()) { + this._openness = this._parentWindow.openness; + } + this.close(); +}; + +Window_NameBox.prototype.refresh = function(text, position) { + this.show(); + this._lastNameText = text; + this._text = Yanfly.Param.MSGNameBoxText + text; + this._position = position; + this.width = this.windowWidth(); + this.createContents(); + this.contents.clear(); + this.resetFontSettings(); + this.changeTextColor(this.textColor(Yanfly.Param.MSGNameBoxColor)); + var padding = eval(Yanfly.Param.MSGNameBoxPadding) / 2; + this.drawTextEx(this._text, padding, 0, this.contents.width); + this._parentWindow.adjustWindowSettings(); + this._parentWindow.updatePlacement(); + this.adjustPositionX(); + this.adjustPositionY(); + this.open(); + this.activate(); + this._closeCounter = 4; + return ''; +}; + +Window_NameBox.prototype.adjustPositionX = function() { + if (this._position === 1) { + this.x = this._parentWindow.x; + this.x += eval(Yanfly.Param.MSGNameBoxBufferX); + } else if (this._position === 2) { + this.x = this._parentWindow.x; + this.x += this._parentWindow.width * 3 / 10; + this.x -= this.width / 2; + } else if (this._position === 3) { + this.x = this._parentWindow.x; + this.x += this._parentWindow.width / 2; + this.x -= this.width / 2; + } else if (this._position === 4) { + this.x = this._parentWindow.x; + this.x += this._parentWindow.width * 7 / 10; + this.x -= this.width / 2; + } else { + this.x = this._parentWindow.x + this._parentWindow.width; + this.x -= this.width; + this.x -= eval(Yanfly.Param.MSGNameBoxBufferX); + } + this.x = this.x.clamp(0, Graphics.boxWidth - this.width); +}; + +Window_NameBox.prototype.adjustPositionY = function() { + if ($gameMessage.positionType() === 0) { + this.y = this._parentWindow.y + this._parentWindow.height; + this.y -= eval(Yanfly.Param.MSGNameBoxBufferY); + } else { + this.y = this._parentWindow.y; + this.y -= this.height; + this.y += eval(Yanfly.Param.MSGNameBoxBufferY); + } + if (this.y < 0) { + this.y = this._parentWindow.y + this._parentWindow.height; + this.y -= eval(Yanfly.Param.MSGNameBoxBufferY); + } +}; + +//============================================================================= +// Window_Message +//============================================================================= + +Yanfly.Message.Window_Message_createSubWindows = + Window_Message.prototype.createSubWindows; +Window_Message.prototype.createSubWindows = function() { + Yanfly.Message.Window_Message_createSubWindows.call(this); + this._nameWindow = new Window_NameBox(this); + Yanfly.nameWindow = this._nameWindow; + var scene = SceneManager._scene; + scene.addChild(this._nameWindow); +}; + +Window_Message.prototype.numVisibleRows = function() { + return $gameSystem.messageRows(); +}; + +Window_Message.prototype.windowWidth = function() { + return $gameSystem.messageWidth(); +}; + +Window_Message.prototype.wordwrapWidth = function(){ + if (Yanfly.Param.MSGTightWrap && $gameMessage.faceName() !== '') { + return this.contents.width - this.newLineX(); + } + return Window_Base.prototype.wordwrapWidth.call(this); +}; + +Window_Message.prototype.adjustWindowSettings = function() { + this.width = this.windowWidth(); + this.height = Math.min(this.windowHeight(), Graphics.boxHeight); + if (Math.abs(Graphics.boxHeight - this.height) < this.lineHeight()) { + this.height = Graphics.boxHeight; + } + this.createContents(); + this.x = (Graphics.boxWidth - this.width) / 2; +}; + +Yanfly.Message.Window_Message_startMessage = + Window_Message.prototype.startMessage; +Window_Message.prototype.startMessage = function() { + this._nameWindow.deactivate(); + Yanfly.Message.Window_Message_startMessage.call(this); +}; + +Yanfly.Message.Window_Message_terminateMessage = + Window_Message.prototype.terminateMessage; +Window_Message.prototype.terminateMessage = function() { + this._nameWindow.deactivate(); + Yanfly.Message.Window_Message_terminateMessage.call(this); +}; + +Yanfly.Message.Window_Message_newPage = + Window_Message.prototype.newPage; +Window_Message.prototype.newPage = function(textState) { + this.adjustWindowSettings(); + Yanfly.Message.Window_Message_newPage.call(this, textState); +}; + +Window_Message.prototype.standardFontFace = function() { + return $gameSystem.getMessageFontName(); +}; + +Window_Message.prototype.standardFontSize = function() { + return $gameSystem.getMessageFontSize(); +}; + +Window_Message.prototype.newLineX = function() { + if ($gameMessage.faceName() === '') { + return 0; + } else { + return eval(Yanfly.Param.MSGFaceIndent); + } +}; + +Window_Message.prototype.isFastForward = function() { + if (!$gameSystem.isFastFowardEnabled()) return false; + return Input.isPressed(Yanfly.Param.MSGFastForwardKey); +}; + +Yanfly.Message.Window_Message_updateInput = + Window_Message.prototype.updateInput; +Window_Message.prototype.updateInput = function() { + if (this.pause && this.isFastForward()) { + if (!this._textState) { + this.pause = false; + this.terminateMessage(); + } + } + return Yanfly.Message.Window_Message_updateInput.call(this); +}; + +Yanfly.Message.Window_Message_updateShowFast = + Window_Message.prototype.updateShowFast; +Window_Message.prototype.updateShowFast = function() { + if (this.isFastForward()) this._showFast = true; + Yanfly.Message.Window_Message_updateShowFast.call(this); +}; + +Yanfly.Message.Window_Message_updateWait = + Window_Message.prototype.updateWait; +Window_Message.prototype.updateWait = function() { + if (this.isFastForward()) return false; + return Yanfly.Message.Window_Message_updateWait.call(this); +}; + +Yanfly.Message.Window_Message_startWait = + Window_Message.prototype.startWait; +Window_Message.prototype.startWait = function(count) { + if (this._checkWordWrapMode) return; + Yanfly.Message.Window_Message_startWait.call(this, count); + if (this.isFastForward()) this._waitCount = 0; +}; + +Yanfly.Message.Window_Message_startPause = + Window_Message.prototype.startPause; +Window_Message.prototype.startPause = function() { + if (this._checkWordWrapMode) return; + Yanfly.Message.Window_Message_startPause.call(this); +}; + +Window_Message.prototype.convertEscapeCharacters = function(text) { + text = Window_Base.prototype.convertEscapeCharacters.call(this, text); + text = this.convertNameBox(text); + text = this.convertMessageCharacters(text); + return text; +}; + +Window_Message.prototype.convertNameBox = function(text) { + text = text.replace(/\x1bN\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 1); + }, this); + text = text.replace(/\x1bN1\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 1); + }, this); + text = text.replace(/\x1bN2\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 2); + }, this); + text = text.replace(/\x1bN3\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 3); + }, this); + text = text.replace(/\x1bNC\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 3); + }, this); + text = text.replace(/\x1bN4\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 4); + }, this); + text = text.replace(/\x1bN5\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 5); + }, this); + text = text.replace(/\x1bNR\<(.*?)\>/gi, function() { + return Yanfly.nameWindow.refresh(arguments[1], 5); + }, this); + return text; +}; + +Window_Message.prototype.convertMessageCharacters = function(text) { + text = text.replace(/\x1bAF\[(\d+)\]/gi, function() { + var i = parseInt(arguments[1]); + return this.convertActorFace($gameActors.actor(i)); + }.bind(this)); + text = text.replace(/\x1bPF\[(\d+)\]/gi, function() { + var i = parseInt(arguments[1]); + return this.convertActorFace($gameParty.members()[i - 1]); + }.bind(this)); + return text; +}; + +Window_Message.prototype.convertActorFace = function(actor) { + $gameMessage.setFaceImage(actor.faceName(), actor.faceIndex()); + return ''; +}; + +Yanfly.Message.Window_Message_processEscapeCharacter = + Window_Message.prototype.processEscapeCharacter; +Window_Message.prototype.processEscapeCharacter = function(code, textState) { + switch (code) { + case '!': + if (!this.isFastForward()) this.startPause(); + break; + case 'W': + this.startWait(this.obtainEscapeParam(textState)); + default: + Yanfly.Message.Window_Message_processEscapeCharacter.call(this, + code, textState); + break; + } +}; + +if (Yanfly.Param.MSGNameBoxClose) { + +Yanfly.Message.Window_Message_doesContinue = + Window_Message.prototype.doesContinue; +Window_Message.prototype.doesContinue = function() { + var value = Yanfly.Message.Window_Message_doesContinue.call(this); + if (!value) return false; + if (this.hasDifferentNameBoxText()) { + return false; + } + return true; +}; + +Window_Message.prototype.hasDifferentNameBoxText = function() { + var texts = $gameMessage._texts; + var length = texts.length; + var open = this._nameWindow.isOpen(); + for (var i = 0; i < length; ++i) { + var text = texts[i]; + if (text.length <= 0) continue; + if (Yanfly.MsgMacro) { + text = this.convertMacroText(text); + text = text.replace(/\x1b/gi, '\\'); + } + if (text.match(/\\(?:N|N1|N2|N3|N4|N5|NC|NR)<(.*)>/i)) { + var name = String(RegExp.$1); + } else if (text.match(/\\(?:ND|ND1|ND2|ND3|ND4|ND5|NDC|NDR)<(.*)>/i)) { + var name = String(RegExp.$1); + } else if (text.match(/\\(?:NT|NT1|NT2|NT3|NT4|NT5|NTC|NTR)<(.*)>/i)) { + var name = String(RegExp.$1); + } + if (name) { + name = name.replace(/\\V\[(\d+)\]/gi, function() { + return $gameVariables.value(parseInt(arguments[1])); + }.bind(this)); + name = name.replace(/\\V\[(\d+)\]/gi, function() { + return $gameVariables.value(parseInt(arguments[1])); + }.bind(this)); + name = name.replace(/\\N\[(\d+)\]/gi, function() { + return this.actorName(parseInt(arguments[1])); + }.bind(this)); + name = name.replace(/\\P\[(\d+)\]/gi, function() { + return this.partyMemberName(parseInt(arguments[1])); + }.bind(this)); + name = name.replace(/\\/gi, '\x1b'); + } + if (name && !open) return true; + if (name && name !== this._nameWindow._lastNameText) { + return true; + } + } + if (open && !name) return true; + return false; +}; + +} // Yanfly.Param.MSGNameBoxClose + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_MoveRouteCore.js b/js/plugins/YEP_MoveRouteCore.js new file mode 100644 index 0000000..7cc5e42 --- /dev/null +++ b/js/plugins/YEP_MoveRouteCore.js @@ -0,0 +1,1084 @@ +//============================================================================= +// Yanfly Engine Plugins - Move Route Core +// YEP_MoveRouteCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_MoveRouteCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.MoveRoute = Yanfly.MoveRoute || {}; +Yanfly.MoveRoute.version = 1.04; + +//============================================================================= + /*: + * @plugindesc v1.04 Expand the number of movement options for the move + * route events using this plugin. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * RPG Maker MV gives us a lot of various commands to use for our Move Routes. + * However, it still imposes a lot of limitations on the system for what else + * could still be potentially useful for move route commands. This plugin will + * provide additional methods to construct move routes for your events and + * allow you to streamline the move route creation process. + * + * ============================================================================ + * Instructions - Simplified Movement Routes + * ============================================================================ + * + * If you want to make events move a certain way using the commands from this + * plugin, do the following: + * + * 1. Open the event you wish to move. + * 2. Make a Movement Route command or Automatic Custom Route. + * 3. Press "Script..." + * 4. Type in any of the desired following commands: + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * UP: x + * LEFT: x + * RIGHT: x + * DOWN: x + * UPPER LEFT: x + * UPPER RIGHT: x + * LOWER LEFT: x + * LOWER RIGHT: x + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the designated event move the noted direction x amount of + * times. This is no different than inserting a direction multiple times with + * editor, but this is meant to serve as a way to consolidate commands. + * Replace x with an integar value. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Up: 10 + * Left: 7 + * Down: 3 + * Right: 4 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * ANIMATION: x + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Play animation x on the designated event. + * Replace x with an integar value. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Animation: 10 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * BALLOON: x + * BALLOON: EXCLAMATION + * BALLOON: ! + * BALLOON: QUESTION + * BALLOON: ? + * BALLOON: MUSIC NOTE + * BALLOON: HEART + * BALLOON: ANGER + * BALLOON: SWEAT + * BALLOON: COBWEB + * BALLOON: SILENCE + * BALLOON: ... + * BALLOON: LIGHT BULB + * BALLOON: ZZZ + * BALLOON: USER 1 + * BALLOON: USER 2 + * BALLOON: USER 3 + * BALLOON: USER 4 + * BALLOON: USER 5 + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Plays balloon ID x on the designated event. + * Replace x with an integar value or replace it with one of the strings shown + * above to produce that specific balloon. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Balloon: 5 + * Balloon: Heart + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * ICON BALLOON: x + * ICON BALLOON: x to y + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Requires YEP_IconBalloons. + * This will make the designated event display an icon balloon using icon x + * or x to y if the latter is used. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Turn Away: 20, 30 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * JUMP FORWARD: x + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * The designated event will jump in the direction it is facing x tiles. + * Replace x an integar value. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Jump Forward: 5 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * JUMP TO: x, y + * JUMP TO: EVENT x + * JUMP TO: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * The designated event will jump to either the coordinates x, y, or event x on + * the map (if event x is present), or to the player's location. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Jump To: 20, 30 + * Jump To: Event 5 + * Jump To: Player + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * MOVE TO: x, y + * MOVE TO: EVENT x + * MOVE TO: PLAYER + * + * AVOID MOVE TO: x, y + * AVOID MOVE TO: EVENT x + * AVOID MOVE TO: PLAYER + * + * CRASH MOVE TO: x, y + * CRASH MOVE TO: EVENT x + * CRASH MOVE TO: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * The designated event will move to either the coordinates x, y, or event x on + * the map (if event x is present), or to the player's location. The designated + * event will determine what is the best route within 12 iterations to reach + * the marked location. The designated event will keep repeating this command + * until it has reached the coordinates. + * + * Replace x and y with integar values. + * + * 'Move To' and 'Avoid Move To' will make the designated event move around the + * player and the player's followers when calculating a path to move to. + * + * 'Crash Move To' will allow collision with the player and/or followers. + * + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Move To: 20, 30 + * Move To: Event 5 + * Move To: Player + * Avoid Move To: 30, 40 + * Crash Move To: 40, 50 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * PATTERN LOCK: x + * PATTERN UNLOCK + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * For some reason, RPG Maker MV does not allow you to set the currently used + * pattern (sprite frame) within the Move Route editor. This command will allow + * you to do so. If Pattern Lock is used, the sprite will remain locked in that + * pattern position until unlocked. + * Replace x an integar value. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Pattern Lock: 0 + * Pattern Lock: 2 + * Pattern Unlock + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * SELF SWITCH x: ON + * SELF SWITCH x: OFF + * SELF SWITCH x: TOGGLE + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will turn the self switch designed event (unless it's the player) to + * either On, Off, or Toggle it On/Off. + * Replace x with A, B, C, or D. + * Those using YEP_SelfSwVar.js can use numbers, too. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Self Switch A: On + * Self Switch B: Off + * Self Switch 123: Toggle + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * SELF VARIABLE x: y + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Requires YEP_SelfSwVar.js. This will set the self variable x for the + * designated event (unless it's the player) to y. + * Replace x with an integar value. + * Replace y with an integar value or code. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Self Variable A: On + * Self Variable B: Off + * Self Variable 123: Toggle + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * STEP AWAY FROM: x, y + * STEP AWAY FROM: EVENT x + * STEP AWAY FROM: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the designated event step one tile away from map coordinates + * x, y, or event x on the map (if event x is present), or from the player's + * current location. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Step Away: 20, 30 + * Step Away: Event 5 + * Step Away: Player + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * STEP TOWARD: x, y + * STEP TOWARD: EVENT x + * STEP TOWARD: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the designated event step one tile toward map coordinates + * x, y, or event x on the map (if event x is present), or to the player's + * current location. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Step Toward: 20, 30 + * Step Toward: Event 5 + * Step Toward: Player + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * TELEPORT: x, y + * TELEPORT: EVENT x + * TELEPORT: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will instantly teleport the designated event to coordinates x, y, or + * event x on the map (if event x is present), or to the player's current + * location on the map. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Teleport: 20, 30 + * Teleport: Event 5 + * Teleport: Player + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * TURN AWAY FROM: x, y + * TURN AWAY FROM: EVENT x + * TURN AWAY FROM: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the designated event turn away from map coordinates x, y, or + * event x on the map (if event x is present), or from the player's location. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Turn Away: 20, 30 + * Turn Away: Event 5 + * Turn Away: Player + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * TURN TOWARDS: x, y + * TURN TOWARDS: EVENT x + * TURN TOWARDS: PLAYER + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will make the designated event turn towards tile toward map coordinates + * x, y, or event x on the map (if event x is present), or to the player's + * current location. + * Replace x and y with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Turn Towards: 50, 60 + * Turn Towards: Event 5 + * Turn Towards: Player + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * And that's it for the specialized movement routes you can use. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * These are some notetags you can utilize for your events. + * + * Event Notetags: + * + * + * - Most events don't update unless they're close to the screen. But any + * event with this notetag will always be updating regardless of whether they + * are close to the screen or not. + * + * ============================================================================ + * Lunatic Mode - Script Calls + * ============================================================================ + * + * For those with JavaScript experience and would like to use the raw command + * functions without resorting to the simplified commands, you can use the + * following code inside of a Script: + * + * this.jumpForward(x) + * - Replace x with the amount of tiles you want the designated event to jump + * forward. x will be automatically rounded to the nearest integar value if + * it is a float value. + * + * this.jumpToPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to jump towards. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.jumpToEvent(x) + * - Replace x with the ID of the event you wish for the designated event to + * jump towards. x will be automatically rounded to the nearest integar value + * if it is a float value. If 0 is used, it will refer to the player. + * + * this.moveRepeat(direction, times) + * - This will make the designated event move in 'direction' a certain amount + * of 'times'. Replace 'direction' with the number value you wish the event + * to move in (refer to NumPad) and replace 'times' with the number of times + * to step in that direction. + * + * this.moveToPoint(x, y) + * - This will calculate the best possible movement route for the designated + * event to reach coordinates x, y within 12 iterations. The designated event + * will keep repeating this command until it has reached the coordinates. + * This will cause the designated event to go around the player and followers + * on the map without colliding into them. + * + * this.moveToPoint(x, y, true) + * - This will calculate the best possible movement route for the designated + * event to reach coordinates x, y within 12 iterations. The designated event + * will keep repeating this command until it has reached the coordinates. + * This will cause the designated event to crash into the player and/or any + * followers if they are in the path way. + * + * this.moveToEvent(x) + * - This will calculate the best possible movement route for the designated + * event to reach event x within 12 iterations. The designated event will + * keep repeating this command until it has reached the coordinates. If 0 is + * used, it will refer to the player. This will cause the designated event to + * go around the player and followers on the map without colliding into them. + * + * this.moveToEvent(x, true) + * - This will calculate the best possible movement route for the designated + * event to reach event x within 12 iterations. The designated event will + * keep repeating this command until it has reached the coordinates. If 0 is + * used, it will refer to the player. This will cause the designated event to + * crash into the player and/or any followers if they are in the path way. + * + * this.requestAnimation(x) + * - Replace x with the animation ID you want to play on the designated + * event. x will be automatically rounded to the nearest integar value if it + * is a float value. + * + * this.requestBalloon(x) + * - Replace x with the balloon ID you want to play on the designated event. + * x will be automatically rounded to the nearest integar value if it is a + * float value. + * + * this.stepAwayFromPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to step away from. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.stepAwayFromEvent(x) + * - Replace x with the ID of the event you wish for the designated event to + * step away from. x will be automatically rounded to the nearest integar + * value if it is a float value. If 0 is used, it will refer to the player. + * + * this.stepTowardPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to step towards. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.stepTowardPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to step towards. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.stepTowardEvent(x) + * - Replace x with the ID of the event you wish for the designated event to + * step towards. x will be automatically rounded to the nearest integar value + * if it is a float value. If 0 is used, it will refer to the player. + * + * this.teleportToPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to teleport to. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.teleportToEvent(x) + * - Replace x with the ID of the event you wish for the designated event to + * teleport to. x will be automatically rounded to the nearest integar value + * if it is a float value. If 0 is used, it will refer to the player. + * + * this.turnAwayFromPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to turn away from. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.turnAwayFromEvent(x) + * - Replace x with the ID of the event you wish for the designated event to + * turn away from. x will be automatically rounded to the nearest integar + * value if it is a float value. If 0 is used, it will refer to the player. + * + * this.turnTowardPoint(x, y) + * - Replace x and y with the coordinates you wish for the designated event + * to turn towards. x and y will be automatically rounded to the nearest + * integar value if it is a float value. + * + * this.turnTowardEvent(x) + * - Replace x with the ID of the event you wish for the designated event to + * turn towards. x will be automatically rounded to the nearest integar value + * if it is a float value. If 0 is used, it will refer to the player. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.04: + * - Fixed a bug that caused UP, LEFT, RIGHT, DOWN repeats to stack when used + * with a repeating movement pattern. + * + * Version 1.03: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.02: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.01: + * - Bug fixed for the repeated commands that caused the commands to add upon + * one another. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Game_Character +//============================================================================= + +Yanfly.MoveRoute.Game_Character_setMoveRoute = + Game_Character.prototype.setMoveRoute; +Game_Character.prototype.setMoveRoute = function(moveRoute) { + var route = JsonEx.makeDeepCopy(moveRoute); + Yanfly.MoveRoute.Game_Character_setMoveRoute.call(this, route); +}; + +Yanfly.MoveRoute.Game_Character_processMoveCommand = + Game_Character.prototype.processMoveCommand; +Game_Character.prototype.processMoveCommand = function(command) { + var gc = Game_Character; + switch (command.code) { + case gc.ROUTE_SCRIPT: + $gameTemp._moveCommand = command; + this.processMoveRouteScriptCall(command.parameters[0]); + break; + default: + Yanfly.MoveRoute.Game_Character_processMoveCommand.call(this, command); + break; + } +}; + +Game_Character.prototype.processMoveRouteScriptCall = function(line) { + // EVAL + if (line.match(/EVAL:[ ](.*)/i)) { + this.processMoveRouteEval(String(RegExp.$1)); + // ANIMATION + } else if (line.match(/(?:ANIMATION|REQUEST ANIMATION):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.requestAnimation(x); + // ICON BALLOON + } else if (line.match(/(?:ICON BALLOON|REQUEST ICON BALLOON):[ ](.*)/i)) { + var str = String(RegExp.$1); + this.processMoveRouteIconBalloon(str); + // BALLOON + } else if (line.match(/(?:BALLOON|REQUEST BALLOON):[ ](.*)/i)) { + var str = String(RegExp.$1); + this.processMoveRouteBalloon(str); + // JUMP FORWARD + } else if (line.match(/(?:JUMP FORWARD|JUMP FORWARDS):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.jumpForward(x); + // JUMP TO: POINT + } else if (line.match(/JUMP[ ](?:TO|TOWARD|TOWARDS):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + this.jumpToPoint(x, y); + // JUMP TO: EVENT + } else if (line.match(/JUMP[ ](?:TO|TOWARD|TOWARDS):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.jumpToEvent(x); + // JUMP TO: PLAYER + } else if (line.match(/JUMP[ ](?:TO|TOWARD|TOWARDS):[ ]PLAYER/i)) { + this.jumpToEvent(0); + // MOVE TO: POINT + } else if (line.match(/MOVE[ ](?:TO|TOWARD|TOWARDS):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + var collision = this.checkCollisionKeywords(line); + this.moveToPoint(x, y, collision); + // MOVE TO: EVENT + } else if (line.match(/MOVE[ ](?:TO|TOWARD|TOWARDS):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var collision = this.checkCollisionKeywords(line); + this.moveToEvent(x, collision); + // MOVE TO: PLAYER + } else if (line.match(/MOVE[ ](?:TO|TOWARD|TOWARDS):[ ]PLAYER/i)) { + this.moveToEvent(0); + // PATTERN LOCK + } else if (line.match(/(?:PATTERN LOCK):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.patternLock(x); + // PATTERN UNLOCK + } else if (line.match(/(?:PATTERN UNLOCK)/i)) { + this.patternUnlock(); + // SELF SWITCH: ON + } else if (line.match(/(?:SELF SWITCH)[ ](.*):[ ]ON/i)) { + var str = String(RegExp.$1); + this.processMoveRouteSelfSwitch(str, 'on'); + // SELF SWITCH: OFF + } else if (line.match(/(?:SELF SWITCH)[ ](.*):[ ]OFF/i)) { + var str = String(RegExp.$1); + this.processMoveRouteSelfSwitch(str, 'off'); + // SELF SWITCH: TOGGLE + } else if (line.match(/(?:SELF SWITCH)[ ](.*):[ ]TOGGLE/i)) { + var str = String(RegExp.$1); + this.processMoveRouteSelfSwitch(str, 'toggle'); + // SELF VARIABLE + } else if (line.match(/(?:SELF VARIABLE)[ ](.*):[ ](.*)/i)) { + var str = String(RegExp.$1); + var code = String(RegExp.$2); + this.processMoveRouteSelfVariable(str, code); + // STEP AWAY FROM: POINT + } else if (line.match(/(?:STEP AWAY|STEP AWAY FROM):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + this.stepAwayFromPoint(x, y); + // STEP AWAY FROM: EVENT + } else if (line.match(/(?:STEP AWAY|STEP AWAY FROM):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.stepAwayFromEvent(x); + // STEP AWAY FROM: PLAYER + } else if (line.match(/(?:STEP AWAY|STEP AWAY FROM):[ ]PLAYER/i)) { + this.stepAwayFromEvent(0); + // STEP TOWARD: POINT + } else if (line.match(/(?:STEP TOWARD|STEP TOWARDS):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + this.stepTowardPoint(x, y); + // STEP TOWARD: EVENT + } else if (line.match(/(?:STEP TOWARD|STEP TOWARDS):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.stepTowardEvent(x); + // STEP TOWARD: PLAYER + } else if (line.match(/(?:STEP TOWARD|STEP TOWARDS):[ ]PLAYER/i)) { + this.stepTowardEvent(0); + // TELEPORT: POINT + } else if (line.match(/(?:TELEPORT|TELEPORT TO):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + this.teleportToPoint(x, y); + // TELEPORT: EVENT + } else if (line.match(/(?:TELEPORT):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.teleportToEvent(x); + // TELEPORT: PLAYER + } else if (line.match(/(?:TELEPORT):[ ]PLAYER/i)) { + this.teleportToEvent(0); + // TURN AWAY FROM: POINT + } else if (line.match(/(?:TURN AWAY FROM|TURN AWAY):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + this.turnAwayFromPoint(x, y); + // TURN AWAY FROM: EVENT + } else if (line.match(/(?:TURN AWAY FROM|TURN AWAY):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.turnAwayFromEvent(x); + // TURN AWAY FROM: PLAYER + } else if (line.match(/(?:TURN AWAY FROM|TURN AWAY):[ ]PLAYER/i)) { + this.turnAwayFromEvent(0); + // TURN TOWARD: POINT + } else if (line.match(/(?:TURN TOWARD|TURN TOWARDS):[ ](\d+),[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + var y = parseInt(RegExp.$2); + this.turnTowardPoint(x, y); + // TURN TOWARD: EVENT + } else if (line.match(/(?:TURN TOWARD|TURN TOWARDS):[ ]EVENT[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.turnTowardEvent(x); + // TURN TOWARD: PLAYER + } else if (line.match(/(?:TURN TOWARD|TURN TOWARDS):[ ]PLAYER/i)) { + this.turnTowardEvent(0); + // MOVE DIRECTION + } else if (line.match(/(?:MOVE LOWER LEFT|LOWER LEFT):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(1, x); + } else if (line.match(/(?:MOVE LOWER RIGHT|LOWER RIGHT):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(3, x); + } else if (line.match(/(?:MOVE UPPER LEFT|UPPER LEFT):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(7, x); + } else if (line.match(/(?:MOVE UPPER RIGHT|UPPER RIGHT):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(9, x); + } else if (line.match(/(?:MOVE UP|UP):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(8, x); + } else if (line.match(/(?:MOVE DOWN|DOWN):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(2, x); + } else if (line.match(/(?:MOVE LEFT|LEFT):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(4, x); + } else if (line.match(/(?:MOVE RIGHT|RIGHT):[ ](\d+)/i)) { + var x = parseInt(RegExp.$1); + this.moveRepeat(6, x); + // ELSE/EVAL + } else { + this.processMoveRouteEval(line); + } +}; + +Game_Character.prototype.checkCollisionKeywords = function(line) { + if (line.match(/(?:CRASH|COLLIDE|COLLISION|ENCOUNTER|TOUCH)/i)) { + return true; + } else if (line.match(/(?:AVOID|EVADE|DODGE)/i)) { + return false; + } else { + return false; + } +}; + +Game_Character.prototype.processMoveRouteEval = function(code) { + var a = this; + var b = this; + var player = $gamePlayer; + var s = $gameSwitches._data; + var v = $gameVariables._data; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'MOVE ROUTE SCRIPT ERROR'); + } +}; + +Game_Character.prototype.processMoveRouteIconBalloon = function(str) { + if (!Yanfly.IBalloon) return; + if (str.match(/(\d+)[ ]TO[ ](\d+)/i)) { + var iconIndex1 = parseInt(RegExp.$1); + var iconIndex2 = parseInt(RegExp.$2); + } else if (str.match(/(\d+)/i)) { + var iconIndex1 = parseInt(RegExp.$1); + var iconIndex2 = iconIndex1; + } else { + return; + } + this.setIconBalloon(iconIndex1, iconIndex2); +}; + +Game_Character.prototype.processMoveRouteBalloon = function(str) { + var id = 0; + if (str.match(/(?:EXCLAMATION|\!)/i)) { + id = 1; + } else if (str.match(/(?:QUESTION|\?)/i)) { + id = 2; + } else if (str.match(/(?:MUSIC NOTE|MUSIC|NOTE)/i)) { + id = 3; + } else if (str.match(/(?:HEART|LOVE)/i)) { + id = 4; + } else if (str.match(/(?:ANGER)/i)) { + id = 5; + } else if (str.match(/(?:SWEAT)/i)) { + id = 6; + } else if (str.match(/(?:COBWEB)/i)) { + id = 7; + } else if (str.match(/(?:SILENCE|\.\.\.)/i)) { + id = 8; + } else if (str.match(/(?:LIGHT BULB|LIGHT|BULB)/i)) { + id = 9; + } else if (str.match(/(?:ZZZ|ZZ|Z)/i)) { + id = 10; + } else if (str.match(/(?:USER|USER-DEFINED|USER DEFINED)[ ](\d+)/i)) { + id = 10 + parseInt(RegExp.$1); + } + this.requestBalloon(id); +}; + +Game_Character.prototype.processMoveRouteSelfSwitch = function(str, setting) { + if (this === $gamePlayer) return; + if (Imported.YEP_SelfSwVar && str.match(/(\d+)/i)) { + var keyName = 'SELF SWITCH ' + parseInt(RegExp.$1); + } else { + var keyName = str.toUpperCase(); + } + var key = [$gameMap.mapId(), this.eventId(), keyName]; + if (setting.toUpperCase() === 'ON') { + $gameSelfSwitches.setValue(key, true); + } else if (setting.toUpperCase() === 'OFF') { + $gameSelfSwitches.setValue(key, false); + } else if (setting.toUpperCase() === 'TOGGLE') { + $gameSelfSwitches.setValue(key, !$gameSelfSwitches.value(key)); + } +}; + +Game_Character.prototype.processMoveRouteSelfVariable = function(str, code) { + if (!Imported.YEP_SelfSwVar) return; + if (this === $gamePlayer) return; + if (str.match(/(\d+)/i)) { + var keyName = 'SELF VARIABLE ' + parseInt(RegExp.$1); + } else { + var keyName = str.toUpperCase(); + } + var key = [$gameMap.mapId(), this.eventId(), keyName]; + try { + var value = eval(code); + } catch (e) { + var value = 0; + Yanfly.Util.displayError(e, code, 'MOVE ROUTE SELF VARIABLE SCRIPT ERROR'); + } + $gameSelfSwitches.setValue(key, value); +}; + +// Simplified Functions + +Game_Character.prototype.jumpForward = function(distance) { + distance = Math.round(distance); + var direction = this.direction(); + var dx = 0; + var dy = 0; + switch (direction) { + case 1: + dx = -distance; + dy = distance; + break; + case 2: + dy = distance; + break; + case 3: + dx = distance; + dy = distance; + break; + case 4: + dx = -distance; + break; + case 6: + dx = distance; + break; + case 7: + dx = -distance; + dy = -distance; + break; + case 8: + dy = -distance; + break; + case 9: + dx = distance; + dy = -distance; + break; + } + this.jump(dx, dy); +}; + +Game_Character.prototype.jumpToPoint = function(x, y) { + x = Math.round(x); + y = Math.round(y); + dx = (this.x - x) * -1; + dy = (this.y - y) * -1; + this.jump(dx, dy); +}; + +Game_Character.prototype.jumpToEvent = function(eventId) { + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.jumpToPoint(x, y); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.jumpToPoint(x, y); + } +}; + +Game_Character.prototype.moveRepeat = function(direction, times) { + times = times || 0; + times = Math.round(times); + var command = { + code: 1, + indent: null, + parameters: [] + } + var gc = Game_Character; + switch (direction) { + case 1: + command.code = gc.ROUTE_MOVE_LOWER_L; + break; + case 2: + command.code = gc.ROUTE_MOVE_DOWN; + break; + case 3: + command.code = gc.ROUTE_MOVE_LOWER_R; + break; + case 4: + command.code = gc.ROUTE_MOVE_LEFT; + break; + case 5: + return; + break; + case 6: + command.code = gc.ROUTE_MOVE_RIGHT; + break; + case 7: + command.code = gc.ROUTE_MOVE_UPPER_L; + break; + case 8: + command.code = gc.ROUTE_MOVE_UP; + break; + case 9: + command.code = gc.ROUTE_MOVE_UPPER_R; + break; + } + var index = this._moveRoute.list.indexOf($gameTemp._moveCommand); + this._moveRoute = JsonEx.makeDeepCopy(this._moveRoute); + this._moveRoute.list[index].parameters[0] = ''; + while (times--) { + this._moveRoute.list.splice(this._moveRouteIndex + 1, 0, command); + } +}; + +Game_CharacterBase.prototype.moveToPoint = function(x, y, collision) { + collision = collision || false; + x = Math.round(x); + y = Math.round(y); + if (collision) $gameTemp._moveAllowPlayerCollision = true; + var direction = this.findDirectionTo(x, y); + if (collision) $gameTemp._moveAllowPlayerCollision = false; + if (direction > 0) this.moveStraight(direction); + if (this.x !== x || this.y !== y) this._moveRouteIndex -= 1; + this.setMovementSuccess(true); +}; + +Game_CharacterBase.prototype.moveTowardPoint = function(x, y, collision) { + this.moveToPoint(x, y, collision); +}; + +Game_Character.prototype.moveToEvent = function(eventId, collision) { + collision = collision || false; + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.moveToPoint(x, y, collision); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.moveToPoint(x, y, collision); + } +}; + +Game_Character.prototype.patternLock = function(index) { + index = Math.round(index); + this._patternMoveRouteLocked = true; + this.setPattern(index); +}; + +Game_Character.prototype.patternUnlock = function() { + this._patternMoveRouteLocked = false; +}; + +Game_Character.prototype.stepAwayFromPoint = function(x, y) { + var sx = this.deltaXFrom(Math.round(x)); + var sy = this.deltaYFrom(Math.round(y)); + if (Math.abs(sx) > Math.abs(sy)) { + this.moveStraight(sx > 0 ? 6 : 4); + if (!this.isMovementSucceeded() && sy !== 0) { + this.moveStraight(sy > 0 ? 2 : 8); + } + } else if (sy !== 0) { + this.moveStraight(sy > 0 ? 2 : 8); + if (!this.isMovementSucceeded() && sx !== 0) { + this.moveStraight(sx > 0 ? 6 : 4); + } + } +}; + +Game_Character.prototype.stepAwayFromEvent = function(eventId) { + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.stepAwayFromPoint(x, y); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.stepAwayFromPoint(x, y); + } +}; + +Game_Character.prototype.stepTowardPoint = function(x, y) { + var sx = this.deltaXFrom(Math.round(x)); + var sy = this.deltaYFrom(Math.round(y)); + if (Math.abs(sx) > Math.abs(sy)) { + this.moveStraight(sx > 0 ? 4 : 6); + if (!this.isMovementSucceeded() && sy !== 0) { + this.moveStraight(sy > 0 ? 8 : 2); + } + } else if (sy !== 0) { + this.moveStraight(sy > 0 ? 8 : 2); + if (!this.isMovementSucceeded() && sx !== 0) { + this.moveStraight(sx > 0 ? 4 : 6); + } + } +}; + +Game_Character.prototype.stepTowardEvent = function(eventId) { + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.stepTowardPoint(x, y); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.stepTowardPoint(x, y); + } +}; + +Game_Character.prototype.teleportToPoint = function(x, y) { + x = Math.round(x); + y = Math.round(y); + this.locate(x, y); +}; + +Game_Character.prototype.teleportToEvent = function(eventId) { + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.teleportToPoint(x, y); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.teleportToPoint(x, y); + } +}; + +Game_Character.prototype.turnAwayFromPoint = function(x, y) { + x = Math.round(x); + y = Math.round(y); + var sx = this.deltaXFrom(x); + var sy = this.deltaYFrom(y); + if (Math.abs(sx) > Math.abs(sy)) { + this.setDirection(sx > 0 ? 6 : 4); + } else if (sy !== 0) { + this.setDirection(sy > 0 ? 2 : 8); + } +}; + +Game_Character.prototype.turnAwayFromEvent = function(eventId) { + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.turnAwayFromPoint(x, y); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.turnAwayFromPoint(x, y); + } +}; + +Game_Character.prototype.turnTowardPoint = function(x, y) { + x = Math.round(x); + y = Math.round(y); + var sx = this.deltaXFrom(x); + var sy = this.deltaYFrom(y); + if (Math.abs(sx) > Math.abs(sy)) { + this.setDirection(sx > 0 ? 4 : 6); + } else if (sy !== 0) { + this.setDirection(sy > 0 ? 8 : 2); + } +}; + +Game_Character.prototype.turnTowardEvent = function(eventId) { + if (eventId === 0) { + var x = $gamePlayer.x; + var y = $gamePlayer.y; + this.turnTowardPoint(x, y); + } else { + var ev = $gameMap.event(eventId); + if (!ev) return; + var x = ev.x; + var y = ev.y; + this.turnTowardPoint(x, y); + } +}; + +//============================================================================= +// Game_CharacterBase +//============================================================================= + +Yanfly.MoveRoute.Game_CharacterBase_isNearTheScreen = + Game_CharacterBase.prototype.isNearTheScreen; +Game_CharacterBase.prototype.isNearTheScreen = function() { + if (this._isAlwaysUpdateMovement) return true; + return Yanfly.MoveRoute.Game_CharacterBase_isNearTheScreen.call(this); +}; + +Yanfly.MoveRoute.Game_CharacterBase_updatePattern = + Game_CharacterBase.prototype.updatePattern; +Game_CharacterBase.prototype.updatePattern = function() { + if (this._patternMoveRouteLocked) return; + Yanfly.MoveRoute.Game_CharacterBase_updatePattern.call(this); +}; + +Yanfly.MoveRoute.Game_CharacterBase_requestAnimation = + Game_CharacterBase.prototype.requestAnimation; +Game_CharacterBase.prototype.requestAnimation = function(animationId) { + animationId = Math.round(animationId); + Yanfly.MoveRoute.Game_CharacterBase_requestAnimation.call(this, animationId); +}; + +//============================================================================= +// Game_Event +//============================================================================= + +Yanfly.MoveRoute.Game_Event_updateSelfMovement = + Game_Event.prototype.updateSelfMovement; +Game_Event.prototype.updateSelfMovement = function() { + if (this._isAlwaysUpdateMovement === undefined) this.checkUpdateSelfMove(); + Yanfly.MoveRoute.Game_Event_updateSelfMovement.call(this); +}; + +Game_Event.prototype.checkUpdateSelfMove = function() { + var note = this.event().note; + this._isAlwaysUpdateMovement = note.match(//i); +}; + +Yanfly.MoveRoute.Game_Event_isPlayerCollided = + Game_Event.prototype.isCollidedWithPlayerCharacters; +Game_Event.prototype.isCollidedWithPlayerCharacters = function(x, y) { + if ($gameTemp._moveAllowPlayerCollision) return false; + return Yanfly.MoveRoute.Game_Event_isPlayerCollided.call(this, x, y); +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_PatchNotes.js b/js/plugins/YEP_PatchNotes.js new file mode 100644 index 0000000..4043776 --- /dev/null +++ b/js/plugins/YEP_PatchNotes.js @@ -0,0 +1,298 @@ +//============================================================================= +// Yanfly Engine Plugins - Patch Notes +// YEP_PatchNotes.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_PatchNotes = true; + +var Yanfly = Yanfly || {}; +Yanfly.PatchNotes = Yanfly.PatchNotes || {}; +Yanfly.PatchNotes.version = 1.00; + +//============================================================================= + /*: + * @plugindesc v1.00 Add the ability to read Patch Notes from inside your game. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Patch Notes File + * @parent ---General--- + * @desc Filename used for the Patch Notes. Place this inside your + * project's main folder. + * @default patchnotes.txt + * + * @param ---Title--- + * @default + * + * @param PatchTitleCommand + * @text Command Name + * @parent ---Title--- + * @desc This is the text used for the menu command. + * @default Patch Notes + * + * @param Add Title Screen + * @parent ---Title--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 'Patch Notes' command to the title screen? + * NO - false YES - true + * @default true + * + * @param ---Menu--- + * @default + * + * @param PatchMenuCommand + * @text Command Name + * @parent ---Menu--- + * @desc This is the text used for the menu command. + * @default Patch Notes + * + * @param Auto Add Menu + * @parent ---Menu--- + * @type boolean + * @on YES + * @off NO + * @desc Automatically add the 'Patch Notes' command to the main menu? + * NO - false YES - true + * @default true + * + * @param Show Command + * @parent ---Menu--- + * @type boolean + * @on Show + * @off Hide + * @desc Show the Patch command in the main menu by default? + * NO - false YES - true + * @default true + * + * @param Auto Place Command + * @parent ---Menu--- + * @type boolean + * @on YES + * @off NO + * @desc Allow this plugin to decide the menu placement position? + * NO - false YES - true + * @default true + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin grants your players the ability to access Patch Notes from the + * game itself. Being able to tell your players what you've changed from inside + * the game can make all the difference in the player experience. This plugin + * lets players access Patch Notes from the title screen, the main menu, or + * from a Plugin Command ran inside the game. + * + * ============================================================================ + * Intructions + * ============================================================================ + * + * Place your Patch Notes file (could be either a HTML or TXT file) inside the + * base directory of your game project. By default, this filename is set to + * 'patchnotes.txt' in the Plugin Parameters, so change that if you intend to + * use a different filename or file type. + * + * ============================================================================ + * Main Menu Manager - Positioning the Patch Command + * ============================================================================ + * + * For those using the Main Menu Manager and would like to position the Patch + * Notes command in a place you'd like, use the following format: + * + * Name: Yanfly.Param.PatchCmd + * Symbol: PatchNotes + * Show: $gameSystem.isShowPatchNotesCommand() + * Enabled: true + * Ext: + * Main Bind: this.commandPatchNotes.bind(this) + * Actor Bind: + * + * Insert the above setup within a Main Menu Manager slot. Provided you copy + * the exact settings to where you need it, it will appear there while using + * all of the naming, enabling, disabling, hiding, and showing effects done by + * the plugin parameters. + * + * Remember to turn off 'Auto Add Menu' from the plugin parameters. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * You can use the following plugin commands to adjust how accessing the Patch + * file is done for your game. + * + * Plugin Commands + * + * OpenPatchNotes + * - This will open up the Patch file or URL for your game. + * + * ShowMenuPatchNotesCommand + * - Will make the 'PatchNotes' command show up in the main menu. + * + * HideMenuPatchNotesCommand + * - Will make the 'PatchNotes' command hidden in the main menu. + */ +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_PatchNotes'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.PatchNotesFilename = String(Yanfly.Parameters['Patch Notes File']); + +Yanfly.Param.PatchTitleCmd = String(Yanfly.Parameters['PatchTitleCommand']); +Yanfly.Param.PatchAddTitle = eval(String(Yanfly.Parameters['Add Title Screen'])); + +Yanfly.Param.PatchCmd = String(Yanfly.Parameters['PatchMenuCommand']); +Yanfly.Param.PatchAutoAdd = eval(String(Yanfly.Parameters['Auto Add Menu'])); +Yanfly.Param.PatchShow = eval(String(Yanfly.Parameters['Show Command'])); +Yanfly.Param.PatchAutoPlace = String(Yanfly.Parameters['Auto Place Command']); +Yanfly.Param.PatchAutoPlace = eval(Yanfly.Param.PatchAutoPlace); + +//============================================================================= +// Game_System +//============================================================================= + +Yanfly.PatchNotes.Game_System_initialize = Game_System.prototype.initialize; +Game_System.prototype.initialize = function() { + Yanfly.PatchNotes.Game_System_initialize.call(this); + this.initPatchNotes(); +}; + +Game_System.prototype.initPatchNotes = function() { + this._PatchNotesCommandShow = Yanfly.Param.PatchShow; +}; + +Game_System.prototype.isShowPatchNotesCommand = function() { + if (this._PatchNotesCommandShow === undefined) this.initPatchNotes(); + return this._PatchNotesCommandShow; +}; + +Game_System.prototype.setShowPatchNotesCommand = function(value) { + if (this._PatchNotesCommandShow === undefined) this.initPatchNotes(); + this._PatchNotesCommandShow = value; +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.PatchNotes.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.PatchNotes.Game_Interpreter_pluginCommand.call(this, command, args); + if (command === 'OpenPatchNotes') { + Yanfly.AccessPatchNotes(); + } else if (command === 'ShowMenuPatchNotesCommand') { + $gameSystem.setShowPatchNotesCommand(true); + } else if (command === 'HideMenuPatcNoteshCommand') { + $gameSystem.setShowPatchNotesCommand(false); + } +}; + +//============================================================================= +// Window_MenuCommand +//============================================================================= + +Yanfly.PatchNotes.Window_MenuCommand_addOriginalCommands = + Window_MenuCommand.prototype.addOriginalCommands; +Window_MenuCommand.prototype.addOriginalCommands = function() { + Yanfly.PatchNotes.Window_MenuCommand_addOriginalCommands.call(this); + if (Yanfly.Param.PatchAutoAdd) this.addPatchCommand(); +}; + +Window_MenuCommand.prototype.addPatchCommand = function() { + if (!Yanfly.Param.PatchAutoPlace) return; + if (!$gameSystem.isShowPatchNotesCommand()) return; + if (this.findSymbol('PatchNotes') > -1) return; + var text = Yanfly.Param.PatchCmd; + this.addCommand(text, 'PatchNotes', true); +}; + +//============================================================================= +// Window_TitleCommand +//============================================================================= + +Yanfly.PatchNotes.Window_TitleCommand_makeCommandList = + Window_TitleCommand.prototype.makeCommandList; +Window_TitleCommand.prototype.makeCommandList = function() { + Yanfly.PatchNotes.Window_TitleCommand_makeCommandList.call(this); + this.addPatchNotesCommand(); +}; + +Window_TitleCommand.prototype.addPatchNotesCommand = function() { + if (!Yanfly.Param.PatchAddTitle) return; + this.addCommand(Yanfly.Param.PatchTitleCmd, 'PatchNotes'); +}; + +//============================================================================= +// Scene_Menu +//============================================================================= + +Yanfly.PatchNotes.Scene_Menu_createCommandWindow = + Scene_Menu.prototype.createCommandWindow; +Scene_Menu.prototype.createCommandWindow = function() { + Yanfly.PatchNotes.Scene_Menu_createCommandWindow.call(this); + this._commandWindow.setHandler('PatchNotes', + this.commandPatchNotes.bind(this)); +}; + +Scene_Menu.prototype.commandPatchNotes = function() { + Yanfly.AccessPatchNotes(); + this._commandWindow.activate(); +}; + +//============================================================================= +// Scene_Title +//============================================================================= + +Yanfly.PatchNotes.Scene_Title_createCommandWindow = + Scene_Title.prototype.createCommandWindow; +Scene_Title.prototype.createCommandWindow = function() { + Yanfly.PatchNotes.Scene_Title_createCommandWindow.call(this); + this._commandWindow.setHandler('PatchNotes', this.commandPatchNotes.bind(this)); +}; + +Scene_Title.prototype.commandPatchNotes = function() { + Yanfly.AccessPatchNotes(); + this._commandWindow.activate(); +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.AccessPatchNotes = function() { + if ($gameTemp.isPlaytest()) console.log('Opening Patch Notes File...'); + TouchInput.clear(); + Input.clear(); + var url = this.getPatchFileUrl(); + var win = window.open(url); + if (win) { + win.focus(); + } else if (Imported.YEP_ExternalLinks) { + SceneManager.openPopupBlockerMessage(); + } +}; + +Yanfly.getPatchFileUrl = function() { + var url = Yanfly.Param.PatchNotesFilename; + if (url.match(/http/i)) { + return url; + } else { + var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, + '/' + Yanfly.Param.PatchNotesFilename); + if (path.match(/^\/([A-Z]\:)/)) path = path.slice(1); + path = decodeURI(path); + return path; + } +}; + +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_PictureSpritesheets.js b/js/plugins/YEP_PictureSpritesheets.js new file mode 100644 index 0000000..b150a51 --- /dev/null +++ b/js/plugins/YEP_PictureSpritesheets.js @@ -0,0 +1,224 @@ +//============================================================================= +// Yanfly Engine Plugins - Picture Spritesheets +// YEP_PictureSpritesheets.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_PictureSpritesheets = true; + +var Yanfly = Yanfly || {}; +Yanfly.PicSS = Yanfly.PicSS || {}; +Yanfly.PicSS.version = 1.00; + +//============================================================================= + /*: + * @plugindesc v1.00 Another function from RPG Maker 2003 is back. You can now + * use spritesheets in your pictures folder and change them to specific frames. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * In RPG Maker 2003, pictures had the ability to load spritesheets and display + * certain frames from them at the issue of a command. Ever since then, later + * iterations of RPG Maker lacked the feature. This plugin will bring back that + * old feature and give you access to use spritesheets as pictures once more + * with complete frame control. + * + * ============================================================================ + * Instructions + * ============================================================================ + * + * When putting a spritesheet into your project's /img/pictures/ folder, you + * have to name them a certain way. + * + * filename[HxV] + * + * Replace H in the filename with the number of horizontal cells it has. + * Replace V in the filename with the number of vertical cells it has. + * + * --- For example --- + * + * "Actor1_1(9x6)" will have 9 horizontal cells and 6 vertical cells. + * + * As long as the picture's filename is formatted in such a way, it will be + * displayed in-game as a spritesheet. + * + * --- Frames --- + * + * Individual frames can be displayed using Plugin Commands or Script Calls + * (look in the later help sections to figure out how). To identify which frame + * ID a particular spritesheet cell is, start with 0 in the upper left. The + * frame ID increases as you go left to right, then it loops back around at the + * start of a new row. For example: + * + * 0 1 2 3 4 5 6 7 8 + * 9 10 11 12 13 14 15 16 17 + * 18 19 20 21 22 23 24 25 26 + * 27 28 29 30 31 32 33 34 35 + * 36 37 38 39 40 41 42 43 44 + * 45 46 47 48 49 50 51 52 53 + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * Using the Plugin Command event, you can set a specific picture to change to + * a different cell by using the Plugin Command below: + * + * Plugin Commands: + * + * Picture x Frame y + * - Replace 'x' with the ID of the picture you wish to change the frame of. + * - Replace 'y' with the frame ID to change the picture to. + * + * ============================================================================ + * Script Calls + * ============================================================================ + * + * For those who wish to use JavaScript code instead of Plugin Commands, you + * can use the Script Call event command to do so: + * + * var pictureId = 5; + * var frame = 10; + * $gameScreen.picture(pictureId).setSpritesheetFrame(frame); + * + * The above code will adjust the designated picture to change to desired frame + * setting you would like. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.00: + * - Finished Plugin! + * + * ============================================================================ + * End of Helpfile + * ============================================================================ + * + */ +//============================================================================= + +//============================================================================= +// Game_Picture +//============================================================================= + +Yanfly.PicSS.Game_Picture_initialize = Game_Picture.prototype.initialize; +Game_Picture.prototype.initialize = function() { + Yanfly.PicSS.Game_Picture_initialize.call(this); + this.initSpritesheetFrame(); +}; + +Game_Picture.prototype.initSpritesheetFrame = function() { + this._spritesheetFrame = 0; +}; + +Game_Picture.prototype.getSpritesheetFrame = function() { + if (this._spritesheetFrame === undefined) this.initSpritesheetFrame(); + return this._spritesheetFrame; +}; + +Game_Picture.prototype.setSpritesheetFrame = function(value) { + if (this._spritesheetFrame === undefined) this.initSpritesheetFrame(); + this._spritesheetFrame = value; +}; + +Yanfly.PicSS.Game_Picture_show = Game_Picture.prototype.show; +Game_Picture.prototype.show = function(name, origin, x, y, scaleX, scaleY, opacity, blendMode) { + Yanfly.PicSS.Game_Picture_show.call(this, name, origin, x, y, scaleX, scaleY, opacity, blendMode); + this.initSpritesheetFrame(); +}; + +Yanfly.PicSS.Game_Picture_erase = Game_Picture.prototype.erase; +Game_Picture.prototype.erase = function() { + Yanfly.PicSS.Game_Picture_erase.call(this); + this.initSpritesheetFrame(); +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.PicSS.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.PicSS.Game_Interpreter_pluginCommand.call(this, command, args); + var line = this._params[0]; + if (line.match(/Picture (\d+) Frame (\d+)/i)) { + var pictureId = Number(RegExp.$1); + var frame = Number(RegExp.$2); + $gameScreen.picture(pictureId).setSpritesheetFrame(frame); + } +}; + +//============================================================================= +// Sprite_Picture +//============================================================================= + +Yanfly.PicSS.Sprite_Picture_initialize = Sprite_Picture.prototype.initialize; +Sprite_Picture.prototype.initialize = function(pictureId) { + Yanfly.PicSS.Sprite_Picture_initialize.call(this, pictureId); + this.initPictureSpritesheetSettings(); +}; + +Sprite_Picture.prototype.initPictureSpritesheetSettings = function() { + this._spritesheetHorzCells = 1; + this._spritesheetVertCells = 1; + this._lastSpritesheetFrame = -1; +}; + +Yanfly.PicSS.Sprite_Picture_loadBitmap = Sprite_Picture.prototype.loadBitmap; +Sprite_Picture.prototype.loadBitmap = function() { + Yanfly.PicSS.Sprite_Picture_loadBitmap.call(this); + this.initPictureSpritesheetSettings(); + this.setupPictureSpritesheetSettings(); + if (this.isSpritesheet()) { + this.bitmap.addLoadListener(this.updateSpritesheetFrame.bind(this)); + } else { + this.bitmap.addLoadListener(this.resetSpritesheetFrame.bind(this)); + } +}; + +Sprite_Picture.prototype.setupPictureSpritesheetSettings = function() { + var name = this.picture().name(); + if (name && name.match(/\((\d+)x(\d+)\)/i)) { + this._spritesheetHorzCells = Number(RegExp.$1); + this._spritesheetVertCells = Number(RegExp.$2); + } +}; + +Sprite_Picture.prototype.isSpritesheet = function() { + return this._spritesheetHorzCells > 1 || this._spritesheetVertCells > 1; +}; + +Sprite_Picture.prototype.spritesheetFrame = function() { + return this.picture().getSpritesheetFrame(); +}; + +Sprite_Picture.prototype.updateSpritesheetFrame = function() { + if (this._lastSpritesheetFrame === this.spritesheetFrame()) return; + if (this.bitmap.width <= 0) return; + this._lastSpritesheetFrame = this.spritesheetFrame(); + var pw = this.bitmap.width / this._spritesheetHorzCells; + var ph = this.bitmap.height / this._spritesheetVertCells; + var sx = this.spritesheetFrame() % this._spritesheetHorzCells * pw; + var sy = Math.floor(this.spritesheetFrame() / this._spritesheetHorzCells) * ph; + this.setFrame(sx, sy, pw, ph); +}; + +Sprite_Picture.prototype.resetSpritesheetFrame = function() { + this.setFrame(0, 0, this.bitmap.width, this.bitmap.height); +}; + +Yanfly.PicSS.Sprite_Picture_update = Sprite_Picture.prototype.update; +Sprite_Picture.prototype.update = function() { + Yanfly.PicSS.Sprite_Picture_update.call(this); + if (this.isSpritesheet()) this.updateSpritesheetFrame(); +}; + +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_QuestJournal.js b/js/plugins/YEP_QuestJournal.js new file mode 100644 index 0000000..08d9e49 --- /dev/null +++ b/js/plugins/YEP_QuestJournal.js @@ -0,0 +1,5017 @@ +//============================================================================= +// Yanfly Engine Plugins - Quest Journal System +// YEP_QuestJournal.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_QuestJournal = true; + +var Yanfly = Yanfly || {}; +Yanfly.Quest = Yanfly.Quest || {}; +Yanfly.Quest.version = 1.02; + +//============================================================================= + /*: + * @plugindesc v1.02 Insert a quest journal system into your game! + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * WARNING: This plugin is to be used with RPG Maker MV 1.5.0 or above! This is + * because the MV 1.5.0 editor allows for this plugin to be made in an orderly + * and efficient manner. Please make sure your RPG Maker MV software is up to + * date before using this plugin. + * + * --- + * + * A quest journal is a very important tool provided by game developers for the + * players. It lists various quests, missions, and objectives that the player + * can pursue in order to progress further into the game. This can be helpful + * in reminding the player what needs to be done in the event the player can + * forget what things there are to do in a vast and large RPG world. + * + * This plugin places a quest journal system into your RPG Maker MV game. You + * can set up how the quest journal appears, move its windows around and/or + * reshape them to fit your game. There are 100 quest slots provided by this + * plugin (more can be obtained through extension plugins) and each one of them + * requires your attention in constructing individually. + * + * You can adjust the quest's title, display a difficulty level, remind the + * player who the quest is from, where that quest is from, various dynamic + * descriptions explaining the quest, a list of objectives to make, a list of + * rewards that will be given to the player once the quest is complete, and any + * subtext footnotes you may wish to insert into each quest. + * + * --- + * + * Keep in mind that while this plugin does enable a quest journal system into + * your game, this plugin will NOT automate it. If you have a quest enabled, it + * is still up to you to add the quest properly into the journal, set its many + * objectives, when the other objectives appear, what the rewards are, and then + * giving out the rewards yourself manually. The purpose of this plugin is to + * simply serve as a visual record for your player to see what quests have been + * handed down to him or her. + * + * ============================================================================ + * Instructions - Setting Up the Quest Category Window + * ============================================================================ + * + * The plugin parameter 'Quest Category Window' can actually be left as is by + * default, but should you wish to customize it, here's what there is to know. + * + * --- + * + * Category Order + * - This is the order in which the following categories appear in the menu: + * available, completed, failed, all, cancel. Moving these around will let you + * adjust how the menu is structured. If you do move them around, by default, + * the first item will be selected at the start. + * Default: ["available","completed","failed","all"] + * + * Available Text + * - How the entry for the 'available' category appears. You can use text codes + * here to give the appearance of icons and/or color. The %1 is a format option + * that will allow you to display how many available quests there are. + * Default: \i[192]Available (%1) + * + * Completed Text + * - How the entry for the 'completed' category appears. You can use text codes + * here to give the appearance of icons and/or color. The %1 is a format option + * that will allow you to display how many completed quests there are. + * Default: \i[191]Completed (%1) + * + * Failed Text + * - How the entry for the 'failed' category appears. You can use text codes + * here to give the appearance of icons and/or color. The %1 is a format option + * that will allow you to display how many failed quests there are. + * Default: \i[194]Failed (%1) + * + * All Text + * - How the entry for the 'all' category appears. You can use text codes + * here to give the appearance of icons and/or color. The %1 is a format option + * that will allow you to display how many quests there are in total. + * Default: \i[189]All Quests (%1) + * + * Cancel Text + * - How the entry for the 'cancel' option appears. You can use text codes + * here to give the appearance of icons and/or color. There is no format option + * to be used with this text. + * Default: \i[161]Close + * + * --- + * + * Window Settings + * - If you wish to customize the category window, you can adjust the various + * settings here to adjust its properties. However, keep in mind that unless + * you are familiar with JavaScript, you can make errors here that can make the + * windows not work in your game. + * + * Default: + * + * X: 0 + * Y: 0 + * Width: Graphics.boxWidth / 3 + * Height: this.fittingHeight(this.numVisibleRows()) + * Rows: 4 + * Columns: 1 + * Line Height: 36 + * Font Face: GameFont + * Font Size: 28 + * Standard Padding: 18 + * Text Padding: 6 + * Text Alignment: left + * Standard Opacity: 255 + * Back Opacity: 192 + * Window Skin: Window + * + * ============================================================================ + * Instructions - Setting Up the Quest List Window + * ============================================================================ + * + * The plugin parameter 'Quest List Window' can be modified to show the various + * quest types. By default, the plugin will have the following quest types: + * Main Quests, Side Quests, Character Quests, and Tutorial Quests. Here's what + * there is to know about the Quest List Window. + * + * --- + * + * Show Types + * - If this is enabled, it will allow for the Quest List Window to display the + * various quest types. If this is disabled, then those quest types will not + * appear and all quests will be displayed without their quest type as their + * individual header. + * Default: true + * + * Type Order + * - This is the order for the quest list types and it also enables which types + * will be available in the quest journal to display. You can use text codes + * here to add icons and/or colors to the quest types. When you are typing out + * the quest type names for the individual quest types to fall under, you can + * omit the \i[x] and \c[x] codes, but everything else must be in tact. + * Default: ["\\c[6]Main Quests","\\c[4]Side Quests","\\c[3]Character Quests", + * "\\c[5]Tutorial Quests"] + * + * List Open Symbol + * - The symbol used to display to show a quest type is opened (showing all of + * the quests listed under it) and not closed (not showing any of the quests + * listed under it). + * Default: - + * + * List Closed Symbol + * - The symbol used to display to show a quest type is closed (not showing any + * of the quests listed under it) and not opened (showing all of the quests + * listed under it). + * Default: + + * + * Type Text Format + * - The text formating type display the quest types in the Quest List Window. + * %1 will refer to the Open/Closed Symbol. %2 will be the quest type's name. + * %3 will reveal the number of quests that are listed under this quest type. + * Default: %1%2 (%3) + * + * Quest Indent + * - This is how much to indent the regular quests if quest types are shown. + * This is to help players distinguish quest types from regular quests, though + * it isn't necessary if you plan on using icons for your quests and none for + * your quest types. + * Default: 0 + * + * Show Empty + * - If enabled, this will show quest types that are empty and have no quests + * under them. Otherwise, if it is disabled, quest types that have no quests + * will not appear in the quest list and can help reduce clutter. + * Default: false + * + * Read Quest + * - This is how the text appears for the 'Read Quest' command. This command + * will only appear in the List Window if an extension plugin prompting the + * extra actions list to appear. + * Default: \i[121]Read Quest + * + * Cancel + * - This is how the text appears for the 'Cancel' command. This command will + * only appear in the List Window if an extension plugin prompting the extra + * actions list to appear. + * Default: \i[16]Cancel + * + * --- + * + * Window Settings + * - If you wish to customize the category window, you can adjust the various + * settings here to adjust its properties. However, keep in mind that unless + * you are familiar with JavaScript, you can make errors here that can make the + * windows not work in your game. + * + * Default: + * + * X: 0 + * Y: Graphics.boxHeight - height + * Width: Graphics.boxWidth / 3 + * Height: Graphics.boxHeight - this.fittingHeight(4) + * Line Height: 36 + * Font Face: GameFont + * Font Size: 28 + * Standard Padding: 18 + * Text Padding: 6 + * Standard Opacity: 255 + * Back Opacity: 192 + * Type Alignment: left + * Quest Alignment: left + * Window Skin: Window + * + * ============================================================================ + * Instructions - Setting Up the Quest Title Window + * ============================================================================ + * + * The plugin parameter 'Quest Title Window' can also be left alone by default, + * but should you wish to alter it to fit your game's settings, here's what you + * need to know. + * + * --- + * + * No Quest Title + * - When there's no quest selected in the quest list window, this text will + * appear in the quest title window. Otherwise, the selected quest's name will + * appear above the data window. Text codes may be used here. + * Default: \c[4]Quest Journal + * + * --- + * + * Window Settings + * - If you wish to customize the category window, you can adjust the various + * settings here to adjust its properties. However, keep in mind that unless + * you are familiar with JavaScript, you can make errors here that can make the + * windows not work in your game. + * + * X: Graphics.boxWidth - width + * Y: 0 + * Width: Graphics.boxWidth * 2 / 3 + * Height: this.fittingHeight(1) + * Line Height: 36 + * Font Face: GameFont + * Font Size: 28 + * Standard Padding: 18 + * Text Padding: 6 + * Text Alignment: center + * Standard Opacity: 255 + * Back Opacity: 192 + * Window Skin: Window + * + * ============================================================================ + * Instructions - Setting Up the Quest Data Window + * ============================================================================ + * + * The plugin parameter 'Quest Data Window' can be modified to show the various + * information contained inside of a quest. This data is used by the player to + * understand just what is required of the player to do in order to fulfill and + * complete the quest. This window's settings can be left as is, but should you + * wish to alter it to fit your game, read below: + * + * --- + * + * No Data Text + * - This is the text to be displayed in the data window when there is no quest + * currently selected by the quest list window. You can use text codes here to + * make the text appear more vivid to your players. + * + * Default: + * Welcome to the \c[4]Quest Journal\c[0]. + * + * Here, you can review over the various + * quests given to you by people from all + * over the world. + * + * Word Wrap Version (Requires YEP_MessageCore.js): + * Welcome to the \c[4]Quest Journal\c[0]. + *
+ *
Here, you can review over the various + * quests given to you by people from all + * over the world. + * + * Quest Data Format + * - This format is how the data in the quest data window is shown to your + * players. You can use various text codes to make your quest data window more + * vivid to your players. %1 will reference the title without any icons or + * color text codes. %2 will reference the quest's difficulty level. %3 will be + * who the quest is from. %4 will display where the quest is from. %5 will show + * the quest's current description, which can change midway through the quest. + * %6 will show the various objectives the player needs to achieve. %7 will + * show any rewards the player can earn. And if there are any, %8 will show the + * subtext for the quest. + * + * Default: + * \{%1\} + * \c[4]Level:\c[0] %2 + * \c[4]From:\c[0] %3 + * \c[4]Location:\c[0] %4 + * + * \c[4]Description:\c[0] + * %5 + * + * \c[4]Objectives:\c[0] + * %6 + * + * \c[4]Rewards:\c[0] + * %7 + * + * %8 + * + * Word Wrap Version (Requires YEP_MessageCore.js): + * \{%1\} + *
\c[4]Level:\c[0] %2 + *
\c[4]From:\c[0] %3 + *
\c[4]Location:\c[0] %4 + *
+ *
\c[4]Description:\c[0] + *
%5 + *
+ *
\c[4]Objectives:\c[0] + *
%6 + *
+ *
\c[4]Rewards:\c[0] + *
%7 + *
+ *
%8 + * + * Uncleared Objective + * - This is the text format that appears for each objective that is neither + * completed nor failed. %1 will be replaced with the objective's text. + * Default: \i[160]%1 + * + * Completed Objective + * - If an objective is completed, this text format will be used instead. + * %1 will be replaced with the objective's text. + * Default: \i[165]%1 + * + * Failed Objective + * - If an objective is failed, this text format will be used instead. + * %1 will be replaced with the objective's text. + * Default: \i[162]%1 + * + * Unclaimed Reward + * - This is the text format that appears for each reward item that is neither + * claimed nor denied. %1 will be replaced with the reward's text. + * Default: \i[160]%1 + * + * Claimed Reward + * - If a reward has been claimed, this text format will be used instead. + * %1 will be replaced with the reward's text. + * Default: \i[163]%1 + * + * Denied Reward + * - If a reward has been denied, this text format will be used instead. + * %1 will be replaced with the reward's text. + * Default: \i[161]%1 + * + * Load Delay + * - This is the amount of frames the data window will wait before loading a + * quest's data onto the window itself. This is to prevent overburdening the + * game engine by loading every single quest that the cursor passes through, + * and instead, waits until the cursor has settled on a particular quest entry + * for x amount of frames before loading it. + * Default: 30 + * + * --- + * + * Window Settings + * - If you wish to customize the category window, you can adjust the various + * settings here to adjust its properties. However, keep in mind that unless + * you are familiar with JavaScript, you can make errors here that can make the + * windows not work in your game. + * + * X: Graphics.boxWidth - width + * Y: Graphics.boxHeight - height + * Width: Graphics.boxWidth * 2 / 3 + * Height: Graphics.boxHeight - this.fittingHeight(1) + * Line Height: 36 + * Font Face: GameFont + * Font Size: 28 + * Standard Padding: 18 + * Text Padding: 6 + * Standard Opacity: 255 + * Back Opacity: 192 + * Window Skin: Window + * Scroll Speed: 4 + * + * ============================================================================ + * Instructions - Setting Up New Quests + * ============================================================================ + * + * By default, there aren't any quests made for you. You must set each one up + * manually. Go into the plugin parameters for YEP_QuestJournal.js and look for + * the ---Quest List--- section. Each of those entries starts off empty. + * However, if you decide to modify it, you'll be greeted with a template that + * explains how to set up your quests. Here is what each parameter does: + * + * --- + * + * Title + * - This is the title of your quest. It will show up in three places: the + * quest list, the quest title window, and if you format it to show in the data + * window, it will appear there as well. You can use text codes to change the + * color of the quest or to give the quest icons. + * + * Type + * - This is the quest type. If you decide to show quest types from the list + * window, this will be where this quest will be listed under. The template has + * a drop down window for a few of the popular quest types, but you can enter + * in your own quest type. Keep in mind that this is case sensitive and will + * require you to type out the quest type correctly. You can, however, omit any + * \i[x] or \c[x] text codes. + * + * Difficulty + * - No mechanical purpose. It's just there to label a certain difficulty level + * for the quest. You can insert any kind of text you wish here and it will be + * displayed in the quest data window if you decide to keep it in there. + * + * From + * - No mechanical purpose. This can be used to state which character in your + * game issued this quest so the player can have a reference point in knowing + * who to return to when it becomes time to deliver the quest results. + * + * Location + * - No mechanical purpose. This can be used to state where the quest has + * originated from, and can reduce the amount of effort the player needs to in + * order to figure out where the quest came from. + * + * Description + * - No mechanical purpose. This is often used to describe the contents of the + * quest to the player and provide a set of general instructions as to what the + * player has to actually do. You can provide multiple descriptions. However, + * only the first description will be visible by default. If you do provide + * multiple descriptions, you can change the entry using the plugin command: + * 'Quest x Change Description Entry To y' to alter the description entry to + * display something else midway through a quest. + * + * Objectives List + * - No mechanical purpose to the game but does have mechanical aspects. The + * objectives list is commonly used to display a specific set of instructions + * the player needs to do in order to complete the quest. Multiple sets of + * objectives can be displayed to indicate multiple objectives that need to be + * fulfilled by the player. + * + * Visible Objectives + * - This is a list of the set of objectives that will be visible by default + * when the quest is added to the game's quest journal. Each number entry in + * there refers to the objective ID (their order position) found in the + * 'Objectives List' plugin parameter. + * + * Rewards List + * - No mechanical purpose to the game but does have mechanical aspects. The + * rewards list is to show what the player has to gain as a result of finishing + * the quest. Multiple sets of rewards can be displayed to indicate the player + * will receive more than just one type of reward. + * + * Visible Rewards + * - This is a list of the set of rewards that will be visible by default when + * the quest is added to the game's quest journal. Each number entry in there + * refers to the reward ID (their order position) found in the 'Rewards List' + * plugin parameter. + * + * Subtext + * - No mechanical purpose. This is usually used as a footer to provide the + * player a message that doesn't fit elsewhere in the data window. You can use + * this however you like or don't use it at all. Multiple sets of subtexts can + * be used here in case you wish to update the subtext midway through a quest. + * + * ============================================================================ + * Main Menu Manager - Positioning the Quest Journal Command + * ============================================================================ + * + * For those using the Main Menu Manager and would like to position the Quest + * command in a place you'd like, use the following format: + * + * Name: Yanfly.Param.QuestCmdName + * Symbol: quest + * Show: $gameSystem.isShowQuest() + * Enabled: $gameSystem.isEnableQuest() + * Ext: + * Main Bind: this.commandQuest.bind(this) + * Actor Bind: + * + * Insert the above setup within a Main Menu Manager slot. Provided you copy + * the exact settings to where you need it, it will appear there while using + * all of the naming, enabling, disabling, hiding, and showing effects done by + * the plugin parameters. + * + * Remember to turn off 'Auto Place Command' from the plugin parameters. + * + * ============================================================================ + * Script Calls + * ============================================================================ + * + * For this plugin, you can use various script calls for certain events to make + * checks on a quest's progress. Here are the different event types and the + * various script calls you can use with them: + * + * + * --- Control Variables Event's Script Calls --- + * + * + * $gameSystem.totalQuestsAvailable() + * - Sets the variable's value to the number of available quests. + * + * $gameSystem.totalQuestsCompleted() + * - Sets the variable's value to the number of completed quests. + * + * $gameSystem.totalQuestsFailed() + * - Sets the variable's value to the number of failed quests. + * + * $gameSystem.totalQuestsKnown() + * - Sets the variable's value to the total number of quests known. + * + * $gameSystem.totalQuestsInGame() + * - Sets the variable's value to the total number of quests in the game. + * + * $gameSystem.totalQuestTypes(category, type) + * - Replace 'category' with either 'available', 'completed', 'failed', or + * 'all' to designate the category. Replace 'type' with the quest type + * (ie. 'Main Quests', 'Side Quests', 'Character Quests', etc). Include the + * quotes around the category and type + * Example: $gameSystem.totalQuestTypes('all', 'Main Quests') + * + * $gameSystem.getQuestDescriptionIndex(questId) + * - Replace 'questId' with the ID of the quest you're looking for. This will + * set the variable to show which description is being used currently. + * Example: $gameSystem.getQuestDescriptionIndex(50) + * + * $gameSystem.totalVisibleQuestObjectives(questId) + * - Replace 'questId' with the ID of the quest you're looking for. This will + * set the variable to show how many quest objectives are visible currently for + * the selected quest. + * Example: $gameSystem.totalVisibleQuestObjectives(50) + * + * $gameSystem.totalQuestObjectives(questId) + * - Replace 'questId' with the ID of the quest you're looking for. This will + * set the variable to show how many quest objectives are total for the + * selected quest's settings. + * Example: $gameSystem.totalQuestObjectives(50) + * + * $gameSystem.totalVisibleQuestRewards(questId) + * - Replace 'questId' with the ID of the quest you're looking for. This will + * set the variable to show how many quest rewards are visible currently for + * the selected quest. + * Example: $gameSystem.totalVisibleQuestRewards(50) + * + * $gameSystem.totalQuestRewards(questId) + * - Replace 'questId' with the ID of the quest you're looking for. This will + * set the variable to show how many quest rewards are total for the selected + * quest's settings. + * Example: $gameSystem.totalQuestRewards(50) + * + * $gameSystem.getQuestSubtextIndex(questId) + * - Replace 'questId' with the ID of the quest you're looking for. This will + * set the variable to show which subtext is being used currently. + * Example: $gameSystem.getQuestSubtextIndex(50) + * + * + * --- Conditional Branch Event's Script Calls --- + * + * + * $gameSystem.isQuestObjectiveCompleted(questId, objectiveId) + * - Replace 'questId' with the ID of the quest you're looking for. Replace + * 'objectiveId' with the ID of the objective you're intending to check. This + * will make a check in the conditional branch's script call to see if an + * objective's status is completed (true) or not (false). + * Example: $gameSystem.isQuestObjectiveCompleted(50, 1) + * + * $gameSystem.isQuestObjectiveFailed(questId, objectiveId) + * - Replace 'questId' with the ID of the quest you're looking for. Replace + * 'objectiveId' with the ID of the objective you're intending to check. This + * will make a check in the conditional branch's script call to see if an + * objective's status is failed (true) or not (false). + * Example: $gameSystem.isQuestObjectiveFailed(50, 1) + * + * $gameSystem.isQuestObjectiveUncleared(questId, objectiveId) + * - Replace 'questId' with the ID of the quest you're looking for. Replace + * 'objectiveId' with the ID of the objective you're intending to check. This + * will make a check in the conditional branch's script call to see if an + * objective's status is neither completed nor failed (true) or either (false). + * Example: $gameSystem.isQuestObjectiveUncleared(50, 1) + * + * $gameSystem.isQuestRewardClaimed(questId, rewardId) + * - Replace 'questId' with the ID of the quest you're looking for. Replace + * 'rewardId' with the ID of the reward you're intending to check. This will + * make a check in the conditional branch's script call to see if a reward's + * status is claimed (true) or not (false). + * Example: $gameSystem.isQuestRewardClaimed(50, 1) + * + * $gameSystem.isQuestRewardDenied(questId, rewardId) + * - Replace 'questId' with the ID of the quest you're looking for. Replace + * 'rewardId' with the ID of the reward you're intending to check. This will + * make a check in the conditional branch's script call to see if a reward's + * status is denied (true) or not (false). + * Example: $gameSystem.isQuestRewardDenied(50, 1) + * + * $gameSystem.isQuestRewardUnclaimed(questId, rewardId) + * - Replace 'questId' with the ID of the quest you're looking for. Replace + * 'rewardId' with the ID of the reward you're intending to check. This will + * make a check in the conditional branch's script call to see if a reward's + * status is neither claimed nor denied (true) or either (false). + * Example: $gameSystem.isQuestRewardUnclaimed(50, 1) + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * There are various plugin commands you can use to control the quest journal + * system in your game. + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * Plugin Commands: + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * Quest Journal Open + * - Opens the quest journal system menu with no quest selected. + * + * Quest Journal Open To x + * - Replace 'x' with the quest ID you wish to open the quest journal system + * to. If the quest isn't known to the player at the time this plugin command + * takes place, then the quest will be added to the player's quest journal. + * + * --- + * + * Quest Journal Show + * Quest Journal Hide + * - Show or hide the Quest Journal option from the main menu. + * + * Quest Journal Enable + * Quest Journal Disable + * - Enable or disable the Quest Journal option in the main menu. + * + * --- + * + * Quest Add x + * - Replace 'x' with an integer. Adds quest ID 'x' to the quest journal as + * an available quest. This will make it viewable from the in-game quest + * journal system menu. + * + * Quest Add x to y + * - Replace 'x' and 'y' with integer values determining the quest ID range + * you wish to add in mass amounts to the quest journal. + * + * Quest Add x, x, x + * - Replace 'x' values with integer values representing the quest ID's you + * wish to add to the quest journal. + * + * --- + * + * Quest Remove x + * - Replace 'x' with an integer. This will remove quest ID 'x' from the + * quest journal. + * + * Quest Remove x to y + * - Replace 'x' and 'y' with integer values determining the quest ID range + * you wish to remove in mass amounts from the quest journal. + * + * Quest Remove x, x, x + * - Replace 'x' values with integer values representing the quest ID's you + * wish to remove from the quest journal. + * + * --- + * + * Quest Set Completed x + * Quest Set Failed x + * Quest Set Available x + * - Replace 'x' with the quest ID you wish to change the quest status to + * 'completed', 'failed', or 'available'. + * + * Quest Set Completed x to y + * Quest Set Failed x to y + * Quest Set Available x to y + * - Replace 'x' and 'y' with integer values determining the quest ID range + * you wish to set as completed, failed, or available. + * + * Quest Set Completed x, x, x + * Quest Set Failed x, x, x + * Quest Set Available x, x, x + * - Replace 'x' values with integer values representing the quest ID's you + * wish to set as completed, failed, or available. + * + * --- + * + * Quest x Change Description Entry To y + * - Replace 'x' with the Quest ID you want to modify the description of. + * Replace 'y' with the description entry ID you wish to change the quest to. + * This will make the description, when viewed in-game in the quest journal, + * to display the description entry ID 'y' found in the plugin parameters for + * quest 'x'. This is used for times you wish to update the description text + * midway through a quest. + * + * --- + * + * Quest x Show Objective y + * Quest x Hide Objective y + * - Replace 'x' with the Quest ID you wish to alter the objective of. + * Replace 'y' with the objective ID you wish to make visible/hidden. Quests + * can show multiple objectives at once. + * + * Quest x Show Objective y to z + * Quest x Hide Objective y to z + * - Replace 'x' with the Quest ID you wish to alter the objective of. + * Replace 'y' and 'z' with the objective ID range you wish to make + * visible/hidden. Quests can show multiple objectives at once. + * + * Quest x Show Objective y, y, y + * Quest x Hide Objective y, y, y + * - Replace 'x' with the Quest ID you wish to alter the objective of. + * Replace 'y' values with integer values representing the objective ID's you + * wish to make visible/hidden. Quests can show multiple objectives at once. + * + * Quest X Show All Objectives + * Quest X Hide All Objectives + * - Replace 'x' with the Quest ID you wish to alter the objectives of. + * This will show/hide all of the quest's objectives. + * + * Quest x Complete Objective y + * Quest x Fail Objective y + * Quest x Normalize Objective y + * - Replace 'x' with the Quest ID you wish to alter the objective of. + * Replace 'y' with the objective ID you wish to change the status of. + * Using 'Complete' will mark the objective as completed. Using 'Fail' will + * mark the objective as failed. Using 'Normalize' will set the objective's + * status to neither completed or failed. + * + * Quest x Complete Objective y to z + * Quest x Fail Objective y to z + * Quest x Normalize Objective y to z + * - Replace 'x' with the Quest ID you wish to alter the objective of. + * Replace 'y' and 'z' with the objective ID range you wish to change the + * status of. Using 'Complete' will mark the objective as completed. Using + * 'Fail' will mark the objective as failed. Using 'Normalize' will set the + * objective's status to neither completed or failed. + * + * Quest x Complete Objective y, y, y + * Quest x Fail Objective y, y, y + * Quest x Normalize Objective y, y, y + * - Replace 'x' with the Quest ID you wish to alter the objective of. + * Replace 'y' values with integer values representing the objective ID's you + * wish to change the status of. Using 'Complete' will mark the objective as + * completed. Using 'Fail' will mark the objective as failed. Using + * 'Normalize' will set the objective's status to neither completed or + * failed. + * + * Quest x Complete All Objectives + * Quest x Fail All Objectives + * Quest x Normalize All Objectives + * - Replace 'x' with the Quest ID you wish to alter the objectives of. + * This will complete/fail/normalize all of the quest's objectives. + * + * --- + * + * Quest x Show Reward y + * Quest x Hide Reward y + * - Replace 'x' with the Quest ID you wish to alter the reward of. Replace + * 'y' with the reward ID you wish to make visible/hidden. Quests can show + * multiple reward at once. + * + * Quest x Show Reward y to z + * Quest x Hide Reward y to z + * - Replace 'x' with the Quest ID you wish to alter the reward of. Replace + * 'y' and 'z' with the reward ID range you wish to make visible/hidden. + * Quests can show multiple reward at once. + * + * Quest x Show Reward y, y, y + * Quest x Hide Reward y, y, y + * - Replace 'x' with the Quest ID you wish to alter the reward of. Replace + * 'y' values with integer values representing the reward ID's you wish to + * make visible/hidden. Quests can show multiple reward at once. + * + * Quest x Show All Rewards + * Quest x Hide All Rewards + * - Replace 'x' with the Quest ID you wish to alter the rewards of. This + * will show/hide all of the quest's rewards. + * + * Quest x Claim Reward y + * Quest x Deny Reward y + * Quest x Normalize Reward y + * - Replace 'x' with the Quest ID you wish to alter the reward of. Replace + * 'y' with the reward ID you wish to change the status of. Using 'Claim' + * will mark the reward as claimed. Using 'Deny' will mark the reward as + * denied. Using 'Normalize' will set the reward's status to neither claimed + * or denied. + * + * Quest x Claim Reward y to z + * Quest x Deny Reward y to z + * Quest x Normalize Reward y to z + * - Replace 'x' with the Quest ID you wish to alter the reward of. Replace + * 'y' and 'z' with the reward ID range you wish to change the status of. + * Using 'Claim' will mark the reward as claimed. Using 'Deny' will mark the + * reward as denied. Using 'Normalize' will set the reward's status to + * neither claimed or denied. + * + * Quest x Claim Reward y, y, y + * Quest x Deny Reward y, y, y + * Quest x Normalize Reward y, y, y + * - Replace 'x' with the Quest ID you wish to alter the reward of. Replace + * 'y' values with integer values representing the reward ID you wish to + * change the status of. Using 'Claim' will mark the reward as claimed. Using + * 'Deny' will mark the reward as denied. Using 'Normalize' will set the + * reward's status to neither claimed or denied. + * + * Quest x Claim All Rewards + * Quest x Deny All Rewards + * Quest x Normalize All Rewards + * - Replace 'x' with the Quest ID you wish to alter the rewards of. This + * will claim/deny/normalize all of the quest's rewards. + * + * --- + * + * Quest x Change Subtext Entry To y + * - Replace 'x' with the Quest ID you want to modify the subtext of. Replace + * 'y' with the subtext entry ID you wish to change the quest to. This will + * make the subtext, when viewed in-game in the quest journal, to display the + * subtext entry ID 'y' found in the plugin parameters for quest 'x'. This is + * used for times you wish to update the subtext text midway through a quest. + * + * --- + * + * ============================================================================ + * Instructions - Lunatic Mode + * ============================================================================ + * + * The plugin parameter 'Lunatic Mode' is made for users who are familiar with + * JavaScript. These parameters allow you to add additional lines of code to + * their respective functions whenever the respective quest journal function + * occurs in-game. The timing for them will occur after the function occurred + * and only if it was successful in delivering a change. + * + * --- + * + * Before Create Windows + * After Create Windows + * Close Quest Menu + * + * --- + * + * Quest Add + * Quest Remove + * Quest Complete + * Quest Fail + * Quest Available + * + * --- + * + * Change Description + * + * --- + * + * Show Objective + * Hide Objective + * Complete Objective + * Fail Objective + * Normalize Objective + * + * --- + * + * Show Reward + * Hide Reward + * Claim Reward + * Deny Reward + * Normalize Reward + * + * --- + * + * Change Subtext + * + * --- + * + * There are a few rules to note. The code for each of those plugin functions + * will only run if it meets these rules: + * + * 1. The code will run for each quest or quest property changed. This means + * that if you used a plugin command that alters a group of quests or + * quest properties at once, the code will run multiple times individually + * for each quest or quest property. + * + * 2. The code will only run if there has been successful changes to a quest + * or quest property. For example, if a quest is already set to 'Failed', + * running the plugin command to fail that quest again will not trigger + * the Lunatic Mode code to run again. + * + * 3. When a quest is first added, any default properties added to the quest + * will not trigger the Lunatic Mode to run. For example, if the quest + * being added has objectives 1 and 2 already visible from the start, then + * the Lunatic Mode code will not run for 1 and 2. + * + * Make sure you understand these rules so that you know what governs whether + * or not the custom code runs. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.02: + * - Fixed a bug that caused a game freeze when using the Quest Journal Open + * plugin command. + * + * Version 1.01: + * - Fixed some bugs regarding certain plugin commands not working properly. + * + * Version 1.00: + * - Finished Plugin! + * + * ============================================================================ + * End of Help + * ============================================================================ + * + * @param ---Main Menu--- + * @default + * + * @param Quest Command + * @parent ---Main Menu--- + * @desc This is the text used for the main menu command + * @default Quest + * + * @param Show Command + * @parent ---Main Menu--- + * @type boolean + * @on Show + * @off Hide + * @desc Show the Quest command in the main menu by default? + * NO - false YES - true + * @default true + * + * @param Enable Command + * @parent ---Main Menu--- + * @type boolean + * @on Enable + * @off Disable + * @desc Enable the Synthesis command in the main menu by default? + * NO - false YES - true + * @default true + * + * @param Auto Place Command + * @parent ---Main Menu--- + * @type boolean + * @on YES + * @off NO + * @desc Allow this plugin to decide the menu placement position? + * NO - false YES - true + * @default true + * + * @param ---Quest Menu--- + * @default + * + * @param Quest Category Window + * @parent ---Quest Menu--- + * @type struct + * @desc Adjust the properties for the quest category window here. + * @default {"---Categories---":"","Category Order":"[\"available\",\"completed\",\"failed\",\"all\"]","Available Text":"\\i[192]Available (%1)","Completed Text":"\\i[191]Completed (%1)","Failed Text":"\\i[194]Failed (%1)","All Text":"\\i[189]All Quests (%1)","Cancel Text":"\\i[161]Close","---Window Settings---":"","X":"0","Y":"0","Width":"Graphics.boxWidth / 3","Height":"this.fittingHeight(this.numVisibleRows())","Rows":"4","Columns":"1","Line Height":"36","Font Face":"GameFont","Font Size":"28","Standard Padding":"18","Text Padding":"6","Text Alignment":"left","Standard Opacity":"255","Back Opacity":"192","Window Skin":"Window"} + * + * @param Quest List Window + * @parent ---Quest Menu--- + * @type struct + * @desc Adjust the properties for the quest list window here. + * @default {"---Types---":"","Show Types":"true","Type Order":"[\"\\\\c[6]Main Quests\",\"\\\\c[4]Side Quests\",\"\\\\c[3]Character Quests\",\"\\\\c[5]Tutorial Quests\"]","List Open Symbol":"-","List Closed Symbol":"+","Type Text Format":"%1%2 (%3)","Quest Indent":"0","Show Empty":"false","Read Quest":"\\i[121]Read Quest","Cancel":"\\i[16]Cancel","---Window Settings---":"","X":"0","Y":"Graphics.boxHeight - height","Width":"Graphics.boxWidth / 3","Height":"Graphics.boxHeight - this.fittingHeight(4)","Line Height":"36","Font Face":"GameFont","Font Size":"28","Standard Padding":"18","Text Padding":"6","Standard Opacity":"255","Back Opacity":"192","Type Alignment":"left","Quest Alignment":"left","Window Skin":"Window"} + * + * @param Quest Title Window + * @parent ---Quest Menu--- + * @type struct + * @desc Adjust the properties for the quest title window here. + * @default {"---Window Settings---":"","No Quest Title":"\\c[4]Quest Journal","X":"Graphics.boxWidth - width","Y":"0","Width":"Graphics.boxWidth * 2 / 3","Height":"this.fittingHeight(1)","Line Height":"36","Font Face":"GameFont","Font Size":"28","Standard Padding":"18","Text Padding":"6","Text Alignment":"center","Standard Opacity":"255","Back Opacity":"192","Window Skin":"Window"} + * + * @param Quest Data Window + * @parent ---Quest Menu--- + * @type struct + * @desc Adjust the properties for the quest data window here. + * @default {"---Data Settings---":"","No Data Text":"\"Welcome to the \\\\c[4]Quest Journal\\\\c[0].\\n\\nHere, you can review over the various\\nquests given to you by people from all\\nover the world.\"","Quest Data Format":"\"\\\\{%1\\\\}\\n
\\\\c[4]Level:\\\\c[0] %2\\n
\\\\c[4]From:\\\\c[0] %3\\n
\\\\c[4]Location:\\\\c[0] %4\\n
\\n
\\\\c[4]Description:\\\\c[0]\\n
%5\\n
\\n
\\\\c[4]Objectives:\\\\c[0]\\n
%6\\n
\\n
\\\\c[4]Rewards:\\\\c[0]\\n
%7\\n
\\n
%8\"","Uncleared Objective":"\\i[160]%1","Completed Objective":"\\i[165]%1","Failed Objective":"\\i[162]%1","Unclaimed Reward":"\\i[160]%1","Claimed Reward":"\\i[163]%1","Denied Reward":"\\i[161]%1","Load Delay":"30","---Window Settings---":"","X":"Graphics.boxWidth - width","Y":"Graphics.boxHeight - height","Width":"Graphics.boxWidth * 2 / 3","Height":"Graphics.boxHeight - this.fittingHeight(1)","Line Height":"36","Font Face":"GameFont","Font Size":"28","Standard Padding":"18","Text Padding":"6","Standard Opacity":"255","Back Opacity":"192","Window Skin":"Window","Scroll Speed":"4"} + * + * @param Lunatic Mode + * @parent ---Quest Menu--- + * @type struct + * @desc Add custom code to each of the plugin's major functions. + * @default {"---Quest Menu---":"","Before Create Windows":"\"// Variables\\n// background - background image used for the menu\\n// windowLayer - sprite layer that contains all windows\\n//\\n// background.bitmap = ImageManager.loadTitle1(\\\"Book\\\");\\n// this.fitScreen(background);\"","After Create Windows":"\"// Variables\\n// background - background image used for the menu\\n// windowLayer - sprite layer that contains all windows\"","Close Quest Menu":"\"// Variables\\n// background - background image used for the menu\\n// windowLayer - sprite layer that contains all windows\"","---Quest Status---":"","Quest Add":"\"// Variables:\\n// questId - ID of the quest being added\\n//\\n// console.log('Quest ' + questId + ' successfully added!')\"","Quest Remove":"\"// Variables:\\n// questId - ID of the quest being removed\\n//\\n// console.log('Quest ' + questId + ' successfully removed!')\"","Quest Complete":"\"// Variables:\\n// questId - ID of the quest set to completed\\n//\\n// console.log('Quest ' + questId + ' status changed to Completed!')\"","Quest Fail":"\"// Variables:\\n// questId - ID of the quest set to failed\\n//\\n// console.log('Quest ' + questId + ' status changed to Failed!')\"","Quest Available":"\"// Variables:\\n// questId - ID of the quest set to available\\n//\\n// console.log('Quest ' + questId + ' status changed to Available!')\"","---Description---":"","Change Description":"\"// Variables:\\n// questId - ID of the quest whose description is changed\\n// index - Description index being changed to\\n//\\n// console.log('Quest ' + questId + ' description index changed to ' + index)\"","---Objectives---":"","Show Objective":"\"// Variables:\\n// questId - ID of the quest whose objectives are altered\\n// objectiveId - ID of the objective being shown\\n//\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to shown!')\"","Hide Objective":"\"// Variables:\\n// questId - ID of the quest whose objectives are altered\\n// objectiveId - ID of the objective being hidden\\n//\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to hidden!')\"","Complete Objective":"\"// Variables:\\n// questId - ID of the quest whose objectives are altered\\n// objectiveId - ID of the objective being completed\\n//\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to completed!')\"","Fail Objective":"\"// Variables:\\n// questId - ID of the quest whose objectives are altered\\n// objectiveId - ID of the objective having failed\\n//\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to failed!')\"","Normalize Objective":"\"// Variables:\\n// questId - ID of the quest whose objectives are altered\\n// objectiveId - ID of the objective normalized\\n//\\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to normal!')\"","---Rewards---":"","Show Reward":"\"// Variables:\\n// questId - ID of the quest whose rewards are altered\\n// rewardId - ID of the reward being shown\\n//\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' becomes shown!')\"","Hide Reward":"\"// Variables:\\n// questId - ID of the quest whose rewards are altered\\n// rewardId - ID of the reward being hidden\\n//\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' becomes hidden!')\"","Claim Reward":"\"// Variables:\\n// questId - ID of the quest whose rewards are altered\\n// rewardId - ID of the reward becoming claimed\\n//\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is now claimed!')\"","Deny Reward":"\"// Variables:\\n// questId - ID of the quest whose rewards are altered\\n// rewardId - ID of the reward becoming denied\\n//\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is now denied!')\"","Normalize Reward":"\"// Variables:\\n// questId - ID of the quest whose rewards are altered\\n// rewardId - ID of the reward normalized\\n//\\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is normalized!')\"","---Subtext---":"","Change Subtext":"\"// Variables:\\n// questId - ID of the quest whose subtext is changed\\n// index - Subtext index being changed to\\n//\\n// console.log('Quest ' + questId + ' subtext index changed to ' + index)\""} + * + * @param ---Quest List--- + * @default + * + * @param Quest 1 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 2 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 3 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 4 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 5 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 6 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 7 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 8 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 9 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 10 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 11 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 12 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 13 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 14 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 15 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 16 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 17 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 18 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 19 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 20 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 21 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 22 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 23 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 24 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 25 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 26 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 27 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 28 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 29 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 30 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 31 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 32 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 33 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 34 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 35 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 36 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 37 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 38 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 39 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 40 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 41 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 42 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 43 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 44 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 45 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 46 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 47 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 48 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 49 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 50 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 51 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 52 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 53 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 54 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 55 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 56 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 57 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 58 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 59 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 60 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 61 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 62 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 63 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 64 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 65 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 66 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 67 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 68 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 69 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 70 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 71 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 72 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 73 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 74 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 75 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 76 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 77 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 78 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 79 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 80 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 81 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 82 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 83 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 84 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 85 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 86 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 87 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 88 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 89 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 90 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 91 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 92 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 93 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 94 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 95 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 96 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 97 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 98 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 99 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + * + * @param Quest 100 + * @parent ---Quest List--- + * @type struct + * @desc Modify the data used by this quest entry. + * Refer to Help for more information about each setting. + * @default + */ +//============================================================================= +/* Plugin Parameter Structure Settings + *============================================================================= + */ +/* ---------------------------------------------------------------------------- + * CategoryWindow Parameter Structure + * --------------------------------------------------------------------------- + */ +/*~struct~CategoryWindow: + * @param ---Categories--- + * @default + * + * @param Category Order + * @parent ---Categories--- + * @type string[] + * @desc Order list for the quest type categories. + * Options: available, completed, failed, all, cancel + * @default ["available","completed","failed","all"] + * + * @param Available Text + * @parent ---Categories--- + * @desc The text used for available quests. + * Text codes allowed. %1 - Quest Number + * @default \i[192]Available (%1) + * + * @param Completed Text + * @parent ---Categories--- + * @desc The text used for completed quests. + * Text codes allowed. %1 - Quest Number + * @default \i[191]Completed (%1) + * + * @param Failed Text + * @parent ---Categories--- + * @desc The text used for failed quests. + * Text codes allowed. %1 - Quest Number + * @default \i[194]Failed (%1) + * + * @param All Text + * @parent ---Categories--- + * @desc The text used for all quests. + * Text codes allowed. %1 - Quest Number + * @default \i[189]All Quests (%1) + * + * @param Cancel Text + * @parent ---Categories--- + * @desc The text used for the Close option. + * Text codes allowed. + * @default \i[161]Close + * + * @param ---Window Settings--- + * @default + * + * @param X + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxWidth - width + * @desc Formula for the window's X position. + * @default 0 + * + * @param Y + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxHeight - height + * @desc Formula for the window's Y position. + * @default 0 + * + * @param Width + * @parent ---Window Settings--- + * @type combo + * @option Graphics.boxWidth + * @option Graphics.boxWidth / 2 + * @option Graphics.boxWidth / 3 + * @option Graphics.boxWidth * 2 / 3 + * @option Graphics.boxWidth / 4 + * @option Graphics.boxWidth * 3 / 4 + * @option Graphics.boxWidth / 5 + * @option Graphics.boxWidth * 4 / 5 + * @desc Formula for the window width. + * @default Graphics.boxWidth / 3 + * + * @param Height + * @parent ---Window Settings--- + * @type combo + * @option this.fittingHeight(1) + * @option this.fittingHeight(2) + * @option this.fittingHeight(3) + * @option this.fittingHeight(4) + * @option this.fittingHeight(5) + * @option this.fittingHeight(this.numVisibleRows()) + * @desc Formula for the window height. + * @default this.fittingHeight(this.numVisibleRows()) + * + * @param Rows + * @parent ---Window Settings--- + * @type combo + * @option 1 + * @option 2 + * @option 3 + * @option 4 + * @desc Formula for the number of window rows. + * @default 4 + * + * @param Columns + * @parent ---Window Settings--- + * @type combo + * @option 1 + * @option 2 + * @option 3 + * @option 4 + * @desc Formula for the number of window columns. + * @default 1 + * + * @param Line Height + * @parent ---Window Settings--- + * @type number + * @min 1 + * @desc The height used for each line entry. + * @default 36 + * + * @param Font Face + * @parent ---Window Settings--- + * @type combo + * @option GameFont + * @option Arial + * @option Courier New + * @option SimHei + * @option Heiti TC + * @option Dotum + * @option AppleGothic + * @desc The font face used for your game. + * @default GameFont + * + * @param Font Size + * @parent ---Window Settings--- + * @type combo + * @option 20 + * @option 28 + * @option Window_Base.prototype.standardFontSize.call(this); + * @desc Formula for the standard font size. + * @default 28 + * + * @param Standard Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 10 + * @option 18 + * @option 24 + * @desc Formula for the window's padding. + * @default 18 + * + * @param Text Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 6 + * @option 12 + * @desc Formula for the padding used before displaying text. + * @default 6 + * + * @param Text Alignment + * @parent ---Window Settings--- + * @type combo + * @option left + * @option center + * @option right + * @desc Choose what type of alignment to use for the window's text. + * left center right + * @default left + * + * @param Standard Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the standard opacity used by the window. + * @default 255 + * + * @param Back Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the opacity used by the window. + * @default 192 + * + * @param Window Skin + * @parent ---Window Settings--- + * @type file + * @dir img/system/ + * @desc Window skin used. + * @default Window + * + */ +/* ---------------------------------------------------------------------------- + * ListWindow Parameter Structure + * --------------------------------------------------------------------------- + */ +/*~struct~ListWindow: + * @param ---Types--- + * @default + * + * @param Show Types + * @parent ---Types--- + * @type boolean + * @on Show + * @off Hide + * @desc Show quest types in the quest list? + * @default true + * + * @param Type Order + * @parent ---Types--- + * @type string[] + * @desc Order list for the quest list types. + * Name these however you want. Text codes are allowed. + * @default ["\\c[6]Main Quests","\\c[4]Side Quests","\\c[3]Character Quests","\\c[5]Tutorial Quests"] + * + * @param List Open Symbol + * @parent ---Types--- + * @desc Text indicator to show if a type is opened. + * Opened types will show all quests within that quest type. + * @default - + * + * @param List Closed Symbol + * @parent ---Types--- + * @desc Text indicator to show if a type is closed. + * Closed types will not show all quests within that quest type. + * @default + + * + * @param Type Text Format + * @parent ---Types--- + * @desc Format used to display quest types. Text codes allowed. + * %1 - Open/Closed %2 - Type Name %3 - Quest Number + * @default %1%2 (%3) + * + * @param Quest Indent + * @parent ---Types--- + * @number + * @number 0 + * @desc How many pixels much to indent quests by. + * @default 0 + * + * @param Show Empty + * @parent ---Types--- + * @type boolean + * @on Show + * @off Hide + * @desc Show quest types that are empty? If not, types + * without any quests will be hidden from the list. + * @default false + * + * @param Read Quest + * @parent ---Types--- + * @desc Vocabulary used for the 'Read Quest' option. + * You can use text codes. + * @default \\i[121]Read Quest + * + * @param Cancel + * @parent ---Types--- + * @desc Vocabulary used for the 'Cancel' option. + * @default \\i[16]Cancel + * + * @param ---Window Settings--- + * @default + * + * @param X + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxWidth - width + * @desc Formula for the window's X position. + * @default 0 + * + * @param Y + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxHeight - height + * @desc Formula for the window's Y position. + * @default Graphics.boxHeight - height + * + * @param Width + * @parent ---Window Settings--- + * @type combo + * @option Graphics.boxWidth + * @option Graphics.boxWidth / 2 + * @option Graphics.boxWidth / 3 + * @option Graphics.boxWidth * 2 / 3 + * @option Graphics.boxWidth / 4 + * @option Graphics.boxWidth * 3 / 4 + * @option Graphics.boxWidth / 5 + * @option Graphics.boxWidth * 4 / 5 + * @desc Formula for the window width. + * @default Graphics.boxWidth / 3 + * + * @param Height + * @parent ---Window Settings--- + * @type combo + * @option Graphics.boxHeight - this.fittingHeight(1) + * @option Graphics.boxHeight - this.fittingHeight(2) + * @option Graphics.boxHeight - this.fittingHeight(3) + * @option Graphics.boxHeight - this.fittingHeight(4) + * @option Graphics.boxHeight - this.fittingHeight(5) + * @desc Formula for the window height. + * @default Graphics.boxHeight - this.fittingHeight(4) + * + * @param Line Height + * @parent ---Window Settings--- + * @type number + * @min 1 + * @desc The height used for each line entry. + * @default 36 + * + * @param Font Face + * @parent ---Window Settings--- + * @type combo + * @option GameFont + * @option Arial + * @option Courier New + * @option SimHei + * @option Heiti TC + * @option Dotum + * @option AppleGothic + * @desc The font face used for your game. + * @default GameFont + * + * @param Font Size + * @parent ---Window Settings--- + * @type combo + * @option 20 + * @option 28 + * @option Window_Base.prototype.standardFontSize.call(this); + * @desc Formula for the standard font size. + * @default 28 + * + * @param Standard Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 10 + * @option 18 + * @option 24 + * @desc Formula for the window's padding. + * @default 18 + * + * @param Text Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 6 + * @option 12 + * @desc Formula for the padding used before displaying text. + * @default 6 + * + * @param Standard Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the standard opacity used by the window. + * @default 255 + * + * @param Back Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the opacity used by the window. + * @default 192 + * + * @param Type Alignment + * @parent ---Window Settings--- + * @type combo + * @option left + * @option center + * @option right + * @desc Choose what type of alignment to use for the quest types. + * left center right + * @default left + * + * @param Quest Alignment + * @parent ---Window Settings--- + * @type combo + * @option left + * @option center + * @option right + * @desc Choose what type of alignment to use for the quests themselves. + * left center right + * @default left + * + * @param Window Skin + * @parent ---Window Settings--- + * @type file + * @dir img/system/ + * @desc Window skin used. + * @default Window + * + */ +/* ---------------------------------------------------------------------------- + * TitleWindow Parameter Structure + * --------------------------------------------------------------------------- + */ +/*~struct~TitleWindow: + * @param ---Window Settings--- + * @default + * + * @param No Quest Title + * @parent ---Window Settings--- + * @desc Display this when there's no quest selected. + * Text codes allowed. + * @default \\c[4]Quest Journal + * + * @param X + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxWidth - width + * @desc Formula for the window's X position. + * @default Graphics.boxWidth - width + * + * @param Y + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxHeight - height + * @desc Formula for the window's Y position. + * @default 0 + * + * @param Width + * @parent ---Window Settings--- + * @type combo + * @option Graphics.boxWidth + * @option Graphics.boxWidth / 2 + * @option Graphics.boxWidth / 3 + * @option Graphics.boxWidth * 2 / 3 + * @option Graphics.boxWidth / 4 + * @option Graphics.boxWidth * 3 / 4 + * @option Graphics.boxWidth / 5 + * @option Graphics.boxWidth * 4 / 5 + * @desc Formula for the window width. + * @default Graphics.boxWidth * 2 / 3 + * + * @param Height + * @parent ---Window Settings--- + * @type combo + * @option this.fittingHeight(1) + * @option this.fittingHeight(2) + * @option this.fittingHeight(3) + * @option this.fittingHeight(4) + * @option this.fittingHeight(5) + * @desc Formula for the window height. + * @default this.fittingHeight(1) + * + * @param Line Height + * @parent ---Window Settings--- + * @type number + * @min 1 + * @desc The height used for each line entry. + * @default 36 + * + * @param Font Face + * @parent ---Window Settings--- + * @type combo + * @option GameFont + * @option Arial + * @option Courier New + * @option SimHei + * @option Heiti TC + * @option Dotum + * @option AppleGothic + * @desc The font face used for your game. + * @default GameFont + * + * @param Font Size + * @parent ---Window Settings--- + * @type combo + * @option 20 + * @option 28 + * @option Window_Base.prototype.standardFontSize.call(this); + * @desc Formula for the standard font size. + * @default 28 + * + * @param Standard Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 10 + * @option 18 + * @option 24 + * @desc Formula for the window's padding. + * @default 18 + * + * @param Text Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 6 + * @option 12 + * @desc Formula for the padding used before displaying text. + * @default 6 + * + * @param Text Alignment + * @parent ---Window Settings--- + * @type combo + * @option left + * @option center + * @option right + * @desc Choose what type of alignment to use for the window's text. + * left center right + * @default center + * + * @param Standard Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the standard opacity used by the window. + * @default 255 + * + * @param Back Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the opacity used by the window. + * @default 192 + * + * @param Window Skin + * @parent ---Window Settings--- + * @type file + * @dir img/system/ + * @desc Window skin used. + * @default Window + * + */ +/* ---------------------------------------------------------------------------- + * DataWindow Parameter Structure + * --------------------------------------------------------------------------- + */ +/*~struct~DataWindow: + * @param ---Data Settings--- + * @default + * + * @param No Data Text + * @parent ---Data Settings--- + * @type note + * @desc Text to display when no quest data is available. + * @default "Welcome to the \\c[4]Quest Journal\\c[0].\n\nHere, you can review over the various\nquests given to you by people from all\nover the world." + * + * @param Quest Data Format + * @parent ---Data Settings--- + * @type note + * @desc %1 - Title, %2 - Difficulty, %3 - From, %4 - Location + * %5 - Desc, %6 - Objectives, %7 - Rewards, %8 - Subtext + * @default "\\{%1\\}\n\\c[4]Level:\\c[0] %2\n\\c[4]From:\\c[0] %3\n\\c[4]Location:\\c[0] %4\n\n\\c[4]Description:\\c[0]\n%5\n\n\\c[4]Objectives:\\c[0]\n%6\n\n\\c[4]Rewards:\\c[0]\n%7\n\n%8" + * + * @param Uncleared Objective + * @parent ---Data Settings--- + * @desc Text format for uncleared quest objectives. + * %1 - Objective Text + * @default \i[160]%1 + * + * @param Completed Objective + * @parent ---Data Settings--- + * @desc Text format for completed quest objectives. + * %1 - Objective Text + * @default \i[165]%1 + * + * @param Failed Objective + * @parent ---Data Settings--- + * @desc Text format for failed quest objectives. + * %1 - Objective Text + * @default \i[162]%1 + * + * @param Unclaimed Reward + * @parent ---Data Settings--- + * @desc Text format for unclaimed quest rewards. + * %1 - Reward Text + * @default \i[160]%1 + * + * @param Claimed Reward + * @parent ---Data Settings--- + * @desc Text format for claimed quest rewards. + * %1 - Reward Text + * @default \i[163]%1 + * + * @param Denied Reward + * @parent ---Data Settings--- + * @desc Text format for denied quest rewards. + * %1 - Reward Text + * @default \i[161]%1 + * + * @param Load Delay + * @parent ---Data Settings--- + * @type number + * @desc Loading time delay for data in frames. + * This is to prevent overburdening the engine. + * @default 30 + * + * @param ---Window Settings--- + * @default + * + * @param X + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxWidth - width + * @desc Formula for the window's X position. + * @default Graphics.boxWidth - width + * + * @param Y + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option Graphics.boxHeight - height + * @desc Formula for the window's Y position. + * @default Graphics.boxHeight - height + * + * @param Width + * @parent ---Window Settings--- + * @type combo + * @option Graphics.boxWidth + * @option Graphics.boxWidth / 2 + * @option Graphics.boxWidth / 3 + * @option Graphics.boxWidth * 2 / 3 + * @option Graphics.boxWidth / 4 + * @option Graphics.boxWidth * 3 / 4 + * @option Graphics.boxWidth / 5 + * @option Graphics.boxWidth * 4 / 5 + * @desc Formula for the window width. + * @default Graphics.boxWidth * 2 / 3 + * + * @param Height + * @parent ---Window Settings--- + * @type combo + * @option Graphics.boxHeight - this.fittingHeight(1) + * @option Graphics.boxHeight - this.fittingHeight(2) + * @option Graphics.boxHeight - this.fittingHeight(3) + * @option Graphics.boxHeight - this.fittingHeight(4) + * @option Graphics.boxHeight - this.fittingHeight(5) + * @desc Formula for the window height. + * @default Graphics.boxHeight - this.fittingHeight(1) + * + * @param Line Height + * @parent ---Window Settings--- + * @type number + * @min 1 + * @desc The height used for each line entry. + * @default 36 + * + * @param Font Face + * @parent ---Window Settings--- + * @type combo + * @option GameFont + * @option Arial + * @option Courier New + * @option SimHei + * @option Heiti TC + * @option Dotum + * @option AppleGothic + * @desc The font face used for your game. + * @default GameFont + * + * @param Font Size + * @parent ---Window Settings--- + * @type combo + * @option 20 + * @option 28 + * @option Window_Base.prototype.standardFontSize.call(this); + * @desc Formula for the standard font size. + * @default 28 + * + * @param Standard Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 10 + * @option 18 + * @option 24 + * @desc Formula for the window's padding. + * @default 18 + * + * @param Text Padding + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 6 + * @option 12 + * @desc Formula for the padding used before displaying text. + * @default 6 + * + * @param Standard Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the standard opacity used by the window. + * @default 255 + * + * @param Back Opacity + * @parent ---Window Settings--- + * @type combo + * @option 0 + * @option 128 + * @option 192 + * @option 255 + * @desc Formula for the opacity used by the window. + * @default 192 + * + * @param Window Skin + * @parent ---Window Settings--- + * @type file + * @dir img/system/ + * @desc Window skin used. + * @default Window + * + * @param Scroll Speed + * @parent ---Window Settings--- + * @type number + * @min 1 + * @desc The speed at which the window scrolls when pressing up/down. + * @default 4 + * + */ +/* ---------------------------------------------------------------------------- + * LunaticMode Parameter Structure + * --------------------------------------------------------------------------- + */ +/*~struct~LunaticMode: + * @param ---Quest Menu--- + * @default + * + * @param Before Create Windows + * @parent ---Quest Menu--- + * @type note + * @desc This code will run before any of the quest menus + * are created for the scene. + * @default "// Variables\n// background - background image used for the menu\n// windowLayer - sprite layer that contains all windows\n//\n// background.bitmap = ImageManager.loadTitle1(\"Book\");\n// this.fitScreen(background);" + * + * @param After Create Windows + * @parent ---Quest Menu--- + * @type note + * @desc This code will run after all of the quest menus + * are created for the scene. + * @default "// Variables\n// background - background image used for the menu\n// windowLayer - sprite layer that contains all windows" + * + * @param Close Quest Menu + * @parent ---Quest Menu--- + * @type note + * @desc This code will run when the quest menu is closed. + * @default "// Variables\n// background - background image used for the menu\n// windowLayer - sprite layer that contains all windows" + * + * @param ---Quest Status--- + * @default + * + * @param Quest Add + * @parent ---Quest Status--- + * @type note + * @desc This code will run any time a quest is successfully + * added to the Quest Journal. + * @default "// Variables:\n// questId - ID of the quest being added\n//\n// console.log('Quest ' + questId + ' successfully added!')" + * + * @param Quest Remove + * @parent ---Quest Status--- + * @type note + * @desc This code will run any time a quest is successfully + * removed the Quest Journal. + * @default "// Variables:\n// questId - ID of the quest being removed\n//\n// console.log('Quest ' + questId + ' successfully removed!')" + * + * @param Quest Complete + * @parent ---Quest Status--- + * @type note + * @desc This code will run any time a quest's status is + * changed to completed. + * @default "// Variables:\n// questId - ID of the quest set to completed\n//\n// console.log('Quest ' + questId + ' status changed to Completed!')" + * + * @param Quest Fail + * @parent ---Quest Status--- + * @type note + * @desc This code will run any time a quest's status is + * changed to failed. + * @default "// Variables:\n// questId - ID of the quest set to failed\n//\n// console.log('Quest ' + questId + ' status changed to Failed!')" + * + * @param Quest Available + * @parent ---Quest Status--- + * @type note + * @desc This code will run any time a quest's status is + * changed to available. + * @default "// Variables:\n// questId - ID of the quest set to available\n//\n// console.log('Quest ' + questId + ' status changed to Available!')" + * + * @param ---Description--- + * @default + * + * @param Change Description + * @parent ---Description--- + * @type note + * @desc This code will run any time a quest's description + * has been changed to a particular index. + * @default "// Variables:\n// questId - ID of the quest whose description is changed\n// index - Description index being changed to\n//\n// console.log('Quest ' + questId + ' description index changed to ' + index)" + * + * @param ---Objectives--- + * @default + * + * @param Show Objective + * @parent ---Objectives--- + * @type note + * @desc This code will run any time a quest's objectives + * becomes shown. + * @default "// Variables:\n// questId - ID of the quest whose objectives are altered\n// objectiveId - ID of the objective being shown\n//\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to shown!')" + * + * @param Hide Objective + * @parent ---Objectives--- + * @type note + * @desc This code will run any time a quest's objectives + * becomes hidden. + * @default "// Variables:\n// questId - ID of the quest whose objectives are altered\n// objectiveId - ID of the objective being hidden\n//\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to hidden!')" + * + * @param Complete Objective + * @parent ---Objectives--- + * @type note + * @desc This code will run any time a quest's objectives + * becomes completed. + * @default "// Variables:\n// questId - ID of the quest whose objectives are altered\n// objectiveId - ID of the objective being completed\n//\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to completed!')" + * + * @param Fail Objective + * @parent ---Objectives--- + * @type note + * @desc This code will run any time a quest's objectives + * becomes failed. + * @default "// Variables:\n// questId - ID of the quest whose objectives are altered\n// objectiveId - ID of the objective having failed\n//\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to failed!')" + * + * @param Normalize Objective + * @parent ---Objectives--- + * @type note + * @desc This code will run any time a quest's objectives + * becomes normalized. + * @default "// Variables:\n// questId - ID of the quest whose objectives are altered\n// objectiveId - ID of the objective normalized\n//\n// console.log('Quest ' + questId + ' objective ' + objectiveId + ' changed to normal!')" + * + * @param ---Rewards--- + * @default + * + * @param Show Reward + * @parent ---Rewards--- + * @type note + * @desc This code will run any time a quest's rewards + * becomes shown. + * @default "// Variables:\n// questId - ID of the quest whose rewards are altered\n// rewardId - ID of the reward being shown\n//\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' becomes shown!')" + * + * @param Hide Reward + * @parent ---Rewards--- + * @type note + * @desc This code will run any time a quest's rewards + * becomes hidden. + * @default "// Variables:\n// questId - ID of the quest whose rewards are altered\n// rewardId - ID of the reward being hidden\n//\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' becomes hidden!')" + * + * @param Claim Reward + * @parent ---Rewards--- + * @type note + * @desc This code will run any time a quest's rewards + * is claimed. + * @default "// Variables:\n// questId - ID of the quest whose rewards are altered\n// rewardId - ID of the reward becoming claimed\n//\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is now claimed!')" + * + * @param Deny Reward + * @parent ---Rewards--- + * @type note + * @desc This code will run any time a quest's rewards + * is denied. + * @default "// Variables:\n// questId - ID of the quest whose rewards are altered\n// rewardId - ID of the reward becoming denied\n//\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is now denied!')" + * + * @param Normalize Reward + * @parent ---Rewards--- + * @type note + * @desc This code will run any time a quest's rewards + * is normalized. + * @default "// Variables:\n// questId - ID of the quest whose rewards are altered\n// rewardId - ID of the reward normalized\n//\n// console.log('Quest ' + questId + ' reward ' + rewardId + ' is normalized!')" + * + * @param ---Subtext--- + * @default + * + * @param Change Subtext + * @parent ---Subtext--- + * @type note + * @desc This code will run any time a quest's subtext + * has been changed to a particular index. + * @default "// Variables:\n// questId - ID of the quest whose subtext is changed\n// index - Subtext index being changed to\n//\n// console.log('Quest ' + questId + ' subtext index changed to ' + index)" + * + */ +/* ---------------------------------------------------------------------------- + * Quest Parameter Structure + * --------------------------------------------------------------------------- + */ +/*~struct~Quest: + * + * @param Title + * @desc Title of the quest. + * Text codes allowed. + * @default \i[87]Untitled Quest + * + * @param Type + * @parent Title + * @type combo + * @option Main Quests + * @option Side Quests + * @option Character Quests + * @option Tutorial Quests + * @desc What type of quest is this? + * @default Main Quests + * + * @param Difficulty + * @parent Title + * @desc Difficulty level for this quest. + * Text codes allowed. + * @default Easy Peasy + * + * @param From + * @parent Title + * @desc Insert the name of the NPC who issued this quest. + * Text codes allowed. + * @default NPC Name + * + * @param Location + * @parent Title + * @desc Insert the location of the NPC who issued this quest. + * Text codes allowed. + * @default Location Name + * + * @param Description + * @parent Title + * @type note[] + * @desc Type out the description used for this quest. + * Text codes allowed. + * @default ["\"This is the \\\\c[4]default\\\\c[0] quest description.\"","\"This is the \\\\c[4]default\\\\c[0] quest description.\\n\\nYou can insert multiple description entries in case you\\never want to update the quest description midway while the\\nquest is in progress.\""] + * + * @param Objectives List + * @type note[] + * @desc The objectives to be completed for this quest. + * Text codes allowed. + * @default ["\"\\\\c[4]First\\\\c[0] objective to be cleared.\"","\"\\\\c[4]Second\\\\c[0] objective, but it's hidden.\"","\"To make other objectives appear,\\nenable them through the \\\\c[4]'Visible\\nObjectives'\\\\c[0] plugin parameter or by\\nusing a plugin command to make\\nthem appear\""] + * + * @param Visible Objectives + * @parent Objectives List + * @type number[] + * @min 1 + * @desc The objectives that are visible from the start. + * @default ["1"] + * + * @param Rewards List + * @type note[] + * @desc The reward list for this quest. + * Text codes allowed. + * @default ["\"\\\\i[176]Potion x5\"","\"\\\\i[178]Ether x3\"","\"To make other rewards appear,\\nenable them through the \\\\c[4]'Visible\\nRewards'\\\\c[0] plugin parameter or by\\nusing a plugin command to make\\nthem appear\""] + * + * @param Visible Rewards + * @parent Rewards List + * @type number[] + * @min 1 + * @desc The rewards that are visible from the start. + * @default ["1"] + * + * @param Subtext + * @type note[] + * @desc Subtext to be displayed with the quest. + * @default ["\"\"","\"This is a subtext. It is used as\\nextra text that you may want to\\nplace on your quest journal that\\ndiffers from the description.\""] + */ +//============================================================================= + +if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.3.5") { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_QuestJournal'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.QuestCmdName = String(Yanfly.Parameters['Quest Command']); +Yanfly.Param.QuestCmdShow = eval(Yanfly.Parameters['Show Command']); +Yanfly.Param.QuestCmdEnable = eval(Yanfly.Parameters['Enable Command']); +Yanfly.Param.QuestCmdPlace = eval(Yanfly.Parameters['Auto Place Command']); + +Yanfly.Param.QuestCategoryWindow = + JSON.parse(Yanfly.Parameters['Quest Category Window']); +Yanfly.Param.QuestListWindow = + JSON.parse(Yanfly.Parameters['Quest List Window']); +Yanfly.Param.QuestTitleWindow = + JSON.parse(Yanfly.Parameters['Quest Title Window']); +Yanfly.Param.QuestDataWindow = + JSON.parse(Yanfly.Parameters['Quest Data Window']); +Yanfly.Quest.LunaticMode = + JSON.parse(Yanfly.Parameters['Lunatic Mode']); + +//============================================================================= +// TouchInput +//============================================================================= + +Yanfly.Quest.TouchInput_onMouseMove = TouchInput._onMouseMove; +TouchInput._onMouseMove = function(event) { + Yanfly.Quest.TouchInput_onMouseMove.call(this, event); + this._mouseOverX = Graphics.pageToCanvasX(event.pageX); + this._mouseOverY = Graphics.pageToCanvasY(event.pageY); +}; + +//============================================================================= +// DataManager +//============================================================================= + +var $dataQuests = [null]; +Yanfly.Quest.totalCount = 0; + +DataManager.questDatabaseAdd = function(id, data) { + if (!data) return $dataQuests.push(null); + data = this.questDataFailsafe(id, data); + var visibleObjectives = JSON.parse(data['Visible Objectives']); + for (var i = 0; i < visibleObjectives.length; ++i) { + visibleObjectives[i] = parseInt(visibleObjectives[i]); + }; + var visibleRewards = JSON.parse(data['Visible Rewards']); + for (var i = 0; i < visibleRewards.length; ++i) { + visibleRewards[i] = parseInt(visibleRewards[i]); + }; + var description = JSON.parse(data['Description']); + description.unshift(''); + var objectives = JSON.parse(data['Objectives List']); + objectives.unshift(''); + var rewards = JSON.parse(data['Rewards List']); + rewards.unshift(''); + var subtext = JSON.parse(data['Subtext']); + subtext.unshift(''); + var type = data['Type']; + type = type.replace(/\\I\[(\d+)\]/gi, '').trim(); + type = type.replace(/\\C\[(\d+)\]/gi, '').trim(); + var quest = { + name: data['Title'], + id: id, + type: type, + difficulty: data['Difficulty'], + from: data['From'], + location: data['Location'], + description: description, + objectives: objectives, + visibleObjectives: visibleObjectives, + rewards: rewards, + visibleRewards: visibleRewards, + subtext: subtext, + note: '' + }; + $dataQuests[id] = quest; + Yanfly.Quest.totalCount += 1; +}; + +DataManager.questDataFailsafe = function(id, data) { + if (!data['Title']) data['Title'] = "\\i[87]Unfinished Quest"; + if (!data['Type']) data['Type'] = "Main Quests"; + if (!data['Difficulty']) data['Difficulty'] = "Easy Peasy"; + if (!data['From']) data['From'] = "NPC Name"; + if (!data['Location']) data['Location'] = "Location Name"; + if (!data['Description']) data['Description'] = "[\"\\\"\\\"\"]"; + if (data['Description'] === '[]') data['Description'] = "[\"\\\"\\\"\"]"; + if (!data['Objectives List']) data['Objectives List'] = "[\"\\\"\\\"\"]"; + if (data['Objectives List'] === '[]') data['Objectives List'] = + "[\"\\\"\\\"\"]"; + if (!data['Visible Objectives']) data['Visible Objectives'] = "[\"1\"]"; + if (!data['Rewards List']) data['Rewards List'] = "[\"\\\"\\\"\"]"; + if (data['Rewards List'] === '[]') data['Rewards List'] = "[\"\\\"\\\"\"]"; + if (!data['Visible Rewards']) data['Visible Rewards'] = "[\"1\"]"; + if (!data['Subtext']) data['Subtext'] = "[\"\\\"\\\"\"]"; + if (data['Subtext'] === '[]') data['Subtext'] = "[\"\\\"\\\"\"]"; + return data; +}; + +DataManager.questDatabaseCreate = function() { + $dataQuests = [null]; + for (var i = 1; i <= 100; ++i) { + var questData = JSON.parse(Yanfly.Parameters['Quest ' + i] || 'null'); + if (!questData) continue; + this.questDatabaseAdd(i, questData); + }; +}; + +DataManager.questDatabaseCreate(); + +//============================================================================= +// Game_Temp +//============================================================================= + +Game_Temp.prototype.reservedQuestOpen = function(questId) { + this._questOpen = questId; +}; + +Game_Temp.prototype.getQuestOpen = function() { + return this._questOpen; +}; + +Game_Temp.prototype.clearQuestOpen = function() { + this._questOpen = undefined; +}; + +//============================================================================= +// Game_System +//============================================================================= + +Yanfly.Quest.Game_System_initialize = Game_System.prototype.initialize; +Game_System.prototype.initialize = function() { + Yanfly.Quest.Game_System_initialize.call(this); + this.initQuestSettings(); +}; + +Game_System.prototype.initQuestSettings = function() { + this._showQuest = this._showQuest || Yanfly.Param.QuestCmdShow; + this._enableQuest = this._enableQuest || Yanfly.Param.QuestCmdEnable; + this._questsKnown = this._questsKnown || []; + this._questsCompleted = this._questsCompleted || []; + this._questsFailed = this._questsFailed || []; + this._questsDescription = this._questsDescription || {}; + this._questsObjectives = this._questsObjectives || {}; + this._questsObjectivesCompleted = this._questsObjectivesCompleted || {}; + this._questsObjectivesFailed = this._questsObjectivesFailed || {}; + this._questsRewards = this._questsRewards || {}; + this._questsRewardsClaimed = this._questsRewardsClaimed || {}; + this._questsRewardsDenied = this._questsRewardsDenied || {}; + this._questsSubtext = this._questsSubtext || {}; +}; + +Game_System.prototype.isShowQuest = function() { + this.initQuestSettings(); + return this._showQuest; +}; + +Game_System.prototype.setShowQuest = function(value) { + this.initQuestSettings(); + this._showQuest = value; +}; + +Game_System.prototype.isEnableQuest = function() { + this.initQuestSettings(); + return this._enableQuest; +}; + +Game_System.prototype.setEnableQuest = function(value) { + this.initQuestSettings(); + this._enableQuest = value; +}; + +Game_System.prototype.getQuestsAvailable = function() { + this.initQuestSettings(); + var result = []; + var length = this._questsKnown.length; + for (var i = 0; i < length; ++i) { + var questId = this._questsKnown[i]; + if (this._questsCompleted.contains(questId)) continue; + if (this._questsFailed.contains(questId)) continue; + result.push(questId); + } + return result; +}; + +Game_System.prototype.getQuestsCompleted = function() { + this.initQuestSettings(); + var result = []; + var length = this._questsKnown.length; + for (var i = 0; i < length; ++i) { + var questId = this._questsKnown[i]; + if (this._questsCompleted.contains(questId)) result.push(questId); + } + return result; +}; + +Game_System.prototype.getQuestsFailed = function() { + this.initQuestSettings(); + var result = []; + var length = this._questsKnown.length; + for (var i = 0; i < length; ++i) { + var questId = this._questsKnown[i]; + if (this._questsFailed.contains(questId)) result.push(questId); + } + return result; +}; + +Game_System.prototype.getAllQuests = function() { + this.initQuestSettings(); + return this._questsKnown; +}; + +Game_System.prototype.getTypeQuests = function(category, type) { + this.initQuestSettings(); + category = category || 'all'; + type = type || ''; + var result = []; + if (category === 'available') { + var quests = this.getQuestsAvailable(); + } else if (category === 'completed') { + var quests = this.getQuestsCompleted(); + } else if (category === 'failed') { + var quests = this.getQuestsFailed(); + } else { + var quests = this.getAllQuests(); + } + var length = quests.length; + for (var i = 0; i < length; ++i) { + var questId = quests[i]; + var questData = $dataQuests[questId]; + if (!questData) continue; + if (questData.type === type) result.push(questId); + } + return result; +}; + +Game_System.prototype.getQuestDescriptionIndex = function(questId) { + this.initQuestSettings(); + return this._questsDescription[questId] || 0; +}; + +Game_System.prototype.getQuestObjectives = function(questId) { + this.initQuestSettings(); + return this._questsObjectives[questId] || ['1']; +}; + +Game_System.prototype.getQuestObjectiveStatus = function(questId, objId) { + this.initQuestSettings(); + this._questsObjectivesCompleted[questId] = + this._questsObjectivesCompleted[questId] || []; + this._questsObjectivesFailed[questId] = + this._questsObjectivesFailed[questId] || []; + if (this._questsObjectivesCompleted[questId].contains(objId)) { + return 'Completed Objective'; + } else if (this._questsObjectivesFailed[questId].contains(objId)) { + return 'Failed Objective'; + } else { + return 'Uncleared Objective'; + } +}; + +Game_System.prototype.getQuestRewards = function(questId) { + this.initQuestSettings(); + return this._questsRewards[questId] || ['1']; +}; + +Game_System.prototype.getQuestRewardStatus = function(questId, objId) { + this.initQuestSettings(); + if (this._questsRewardsClaimed[questId].contains(objId)) { + return 'Claimed Reward'; + } else if (this._questsRewardsDenied[questId].contains(objId)) { + return 'Denied Reward'; + } else { + return 'Unclaimed Reward'; + } +}; + +Game_System.prototype.getQuestSubtextIndex = function(questId) { + this.initQuestSettings(); + return this._questsSubtext[questId] || 0; +}; + +Game_System.prototype.questAdd = function(questId) { + this.initQuestSettings(); + if (this._questsKnown.contains(questId)) return; + var questData = $dataQuests[questId]; + if (!questData) return; + this._questsKnown.push(questId); + this._questsKnown.sort(function(a, b) { + return a - b; + }); + this._questsDescription[questId] = 1; + this._questsObjectives[questId] = []; + for (var i = 0; i < questData['visibleObjectives'].length; ++i) { + var value = questData['visibleObjectives'][i]; + this._questsObjectives[questId].push(value); + } + this._questsObjectivesCompleted[questId] = []; + this._questsObjectivesFailed[questId] = []; + this._questsRewards[questId] = []; + for (var i = 0; i < questData['visibleRewards'].length; ++i) { + var value = questData['visibleRewards'][i]; + this._questsRewards[questId].push(value); + } + this._questsRewardsClaimed[questId] = []; + this._questsRewardsDenied[questId] = []; + this._questsSubtext[questId] = 1; + this.questAddCustomEval(questId); +}; + +Yanfly.Quest.questAdd = + JSON.parse(Yanfly.Quest.LunaticMode['Quest Add']); +Game_System.prototype.questAddCustomEval = function(questId) { + eval(Yanfly.Quest.questAdd); +}; + +Game_System.prototype.questAddRange = function(range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var questId = range[i]; + this.questAdd(questId); + } +}; + +Game_System.prototype.questRemove = function(questId) { + this.initQuestSettings(); + if (!this._questsKnown.contains(questId)) return; + var index = this._questsKnown.indexOf(questId); + this._questsKnown.splice(index, 1); + this.questRemoveCustomEval(questId); +}; + +Yanfly.Quest.questRemove = + JSON.parse(Yanfly.Quest.LunaticMode['Quest Remove']); +Game_System.prototype.questRemoveCustomEval = function(questId) { + eval(Yanfly.Quest.questRemove); +}; + +Game_System.prototype.questRemoveRange = function(range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var questId = range[i]; + this.questRemove(questId); + } +}; + +Game_System.prototype.questSetCompleted = function(questId) { + this.initQuestSettings(); + var changed = false; + if (!this._questsKnown.contains(questId)) this.questAdd(questId); + if (!this._questsCompleted.contains(questId)) { + changed = true; + this._questsCompleted.push(questId); + this._questsCompleted.sort(function(a, b) { + return a - b; + }); + } + if (this._questsFailed.contains(questId)) { + var index = this._questsFailed.indexOf(questId); + this._questsFailed.splice(index, 1); + this._questsFailed.sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questSetCompletedEval(questId); +}; + +Yanfly.Quest.questSetCompleted = + JSON.parse(Yanfly.Quest.LunaticMode['Quest Complete']); +Game_System.prototype.questSetCompletedEval = function(questId) { + eval(Yanfly.Quest.questSetCompleted); +}; + +Game_System.prototype.questSetCompletedRange = function(range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var questId = range[i]; + this.questSetCompleted(questId); + } +}; + +Game_System.prototype.questSetFailed = function(questId) { + this.initQuestSettings(); + var changed = false; + if (!this._questsKnown.contains(questId)) this.questAdd(questId); + if (!this._questsFailed.contains(questId)) { + changed = true; + this._questsFailed.push(questId); + this._questsFailed.sort(function(a, b) { + return a - b; + }); + } + if (this._questsCompleted.contains(questId)) { + var index = this._questsCompleted.indexOf(questId); + this._questsCompleted.splice(index, 1); + this._questsCompleted.sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questSetFailedEval(questId); +}; + +Yanfly.Quest.questSetFailed = + JSON.parse(Yanfly.Quest.LunaticMode['Quest Fail']); +Game_System.prototype.questSetFailedEval = function(questId) { + eval(Yanfly.Quest.questSetFailed); +}; + +Game_System.prototype.questSetFailedRange = function(range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var questId = range[i]; + this.questSetFailed(questId); + } +}; + +Game_System.prototype.questSetAvailable = function(questId) { + this.initQuestSettings(); + var changed = false; + if (!this._questsKnown.contains(questId)) this.questAdd(questId); + if (this._questsCompleted.contains(questId)) { + changed = true; + var index = this._questsCompleted.indexOf(questId); + this._questsCompleted.splice(index, 1); + this._questsCompleted.sort(function(a, b) { + return a - b; + }); + } + if (this._questsFailed.contains(questId)) { + changed = true; + var index = this._questsFailed.indexOf(questId); + this._questsFailed.splice(index, 1); + this._questsFailed.sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questSetAvailableEval(questId); +}; + +Yanfly.Quest.questSetAvailable = + JSON.parse(Yanfly.Quest.LunaticMode['Quest Available']); +Game_System.prototype.questSetAvailableEval = function(questId) { + eval(Yanfly.Quest.questSetAvailable); +}; + +Game_System.prototype.questSetAvailableRange = function(range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var questId = range[i]; + this.questSetAvailable(questId); + } +}; + +Game_System.prototype.questChangeDescriptionIndex = function(questId, index) { + this.initQuestSettings(); + this._questsDescription[questId] = index; + this.questChangeDescIndexEval(questId, index); +}; + +Yanfly.Quest.questChangeDescriptionIndex = + JSON.parse(Yanfly.Quest.LunaticMode['Change Description']); +Game_System.prototype.questChangeDescIndexEval = function(questId, index) { + eval(Yanfly.Quest.questChangeDescriptionIndex); +}; + +Game_System.prototype.questObjectivesShow = function(questId, objectiveId) { + this.initQuestSettings(); + this._questsObjectives[questId] = this._questsObjectives[questId] || []; + if (this._questsObjectives[questId].contains(objectiveId)) return; + this._questsObjectives[questId].push(objectiveId); + this._questsObjectives[questId].sort(function(a, b) { + return a - b; + }); + this.questObjectivesShowEval(questId, objectiveId); +}; + +Yanfly.Quest.questObjectivesShow = + JSON.parse(Yanfly.Quest.LunaticMode['Show Objective']); +Game_System.prototype.questObjectivesShowEval = function(questId, obj) { + var objectiveId = obj; + eval(Yanfly.Quest.questObjectivesShow); +}; + +Game_System.prototype.questObjectivesShowRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var objId = parseInt(range[i]); + this.questObjectivesShow(questId, objId); + } +}; + +Game_System.prototype.questObjectivesShowAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.objectives.length; + for (var i = 1; i < length; ++i) { + this.questObjectivesShow(questId, i); + } +}; + +Game_System.prototype.questObjectivesHide = function(questId, objectiveId) { + this.initQuestSettings(); + this._questsObjectives[questId] = this._questsObjectives[questId] || []; + if (!this._questsObjectives[questId].contains(objectiveId)) return; + var index = this._questsObjectives[questId].indexOf(objectiveId); + this._questsObjectives[questId].splice(index, 1); + this._questsObjectives[questId].sort(function(a, b) { + return a - b; + }); + this.questObjectivesHideEval(questId, objectiveId); +}; + +Yanfly.Quest.questObjectivesHide = + JSON.parse(Yanfly.Quest.LunaticMode['Hide Objective']); +Game_System.prototype.questObjectivesHideEval = function(questId, obj) { + var objectiveId = obj; + eval(Yanfly.Quest.questObjectivesHide); +}; + +Game_System.prototype.questObjectivesHideRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var objId = parseInt(range[i]); + this.questObjectivesHide(questId, objId); + } +}; + +Game_System.prototype.questObjectivesHideAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.objectives.length; + for (var i = 1; i < length; ++i) { + this.questObjectivesHide(questId, i); + } +}; + +Game_System.prototype.questObjectivesNormal = function(questId, objectiveId) { + this.initQuestSettings(); + var changed = false; + this._questsObjectivesCompleted[questId] = + this._questsObjectivesCompleted[questId] || []; + if (this._questsObjectivesCompleted[questId].contains(objectiveId)) { + changed = true; + var index = this._questsObjectivesCompleted[questId].indexOf(objectiveId); + this._questsObjectivesCompleted[questId].splice(index, 1); + this._questsObjectivesCompleted[questId].sort(function(a, b) { + return a - b; + }); + } + if (this._questsObjectivesFailed[questId].contains(objectiveId)) { + changed = true; + var index = this._questsObjectivesFailed[questId].indexOf(objectiveId); + this._questsObjectivesFailed[questId].splice(index, 1); + this._questsObjectivesFailed[questId].sort(function(a, b) { + return a - b; + }); + } + this.questObjectivesNormalEval(questId, objectiveId); +}; + +Yanfly.Quest.questObjectivesNormal = + JSON.parse(Yanfly.Quest.LunaticMode['Normalize Objective']); +Game_System.prototype.questObjectivesNormalEval = function(questId, obj) { + var objectiveId = obj; + eval(Yanfly.Quest.questObjectivesNormal); +}; + +Game_System.prototype.questObjectivesNormalRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var objId = parseInt(range[i]); + this.questObjectivesNormal(questId, objId); + } +}; + +Game_System.prototype.questObjectivesNormalAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.objectives.length; + for (var i = 1; i < length; ++i) { + this.questObjectivesNormal(questId, i); + } +}; + +Game_System.prototype.questObjectivesComplete = function(questId, objectiveId) { + this.initQuestSettings(); + var changed = false; + this._questsObjectivesCompleted[questId] = + this._questsObjectivesCompleted[questId] || []; + if (!this._questsObjectivesCompleted[questId].contains(objectiveId)) { + changed = true; + this._questsObjectivesCompleted[questId].push(objectiveId); + this._questsObjectivesCompleted[questId].sort(function(a, b) { + return a - b; + }); + } + this._questsObjectivesFailed[questId] = + this._questsObjectivesFailed[questId] || []; + if (this._questsObjectivesFailed[questId].contains(objectiveId)) { + var index = this._questsObjectivesFailed[questId].indexOf(objectiveId); + this._questsObjectivesFailed[questId].splice(index, 1); + this._questsObjectivesFailed[questId].sort(function(a, b) { + return a - b; + }); + } + this.questObjectivesCompleteEval(questId, objectiveId); +}; + +Yanfly.Quest.questObjectivesComplete = + JSON.parse(Yanfly.Quest.LunaticMode['Complete Objective']); +Game_System.prototype.questObjectivesCompleteEval = function(questId, obj) { + var objectiveId = obj; + eval(Yanfly.Quest.questObjectivesComplete); +}; + +Game_System.prototype.questObjectivesCompleteRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var objId = parseInt(range[i]); + this.questObjectivesComplete(questId, objId); + } +}; + +Game_System.prototype.questObjectivesCompleteAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.objectives.length; + for (var i = 1; i < length; ++i) { + this.questObjectivesComplete(questId, i); + } +}; + +Game_System.prototype.questObjectivesFail = function(questId, objectiveId) { + this.initQuestSettings(); + var changed = false; + this._questsObjectivesFailed[questId] = + this._questsObjectivesFailed[questId] || []; + if (!this._questsObjectivesFailed[questId].contains(objectiveId)) { + changed = true; + this._questsObjectivesFailed[questId].push(objectiveId); + this._questsObjectivesFailed[questId].sort(function(a, b) { + return a - b; + }); + } + this._questsObjectivesCompleted[questId] = + this._questsObjectivesCompleted[questId] || []; + if (this._questsObjectivesCompleted[questId].contains(objectiveId)) { + var index = this._questsObjectivesCompleted[questId].indexOf(objectiveId); + this._questsObjectivesCompleted[questId].splice(index, 1); + this._questsObjectivesCompleted[questId].sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questObjectivesFailEval(questId, objectiveId); +}; + +Yanfly.Quest.questObjectivesFail = + JSON.parse(Yanfly.Quest.LunaticMode['Fail Objective']); +Game_System.prototype.questObjectivesFailEval = function(questId, obj) { + var objectiveId = obj; + eval(Yanfly.Quest.questObjectivesFail); +}; + +Game_System.prototype.questObjectivesFailRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var objId = parseInt(range[i]); + this.questObjectivesFail(questId, objId); + } +}; + +Game_System.prototype.questObjectivesFailAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.objectives.length; + for (var i = 1; i < length; ++i) { + this.questObjectivesFail(questId, i); + } +}; + +Game_System.prototype.questRewardsShow = function(questId, rewardId) { + this.initQuestSettings(); + this._questsRewards[questId] = this._questsRewards[questId] || []; + if (this._questsRewards[questId].contains(rewardId)) return; + this._questsRewards[questId].push(rewardId); + this._questsRewards[questId].sort(function(a, b) { + return a - b; + }); + this.questRewardsShowEval(questId, rewardId); +}; + +Yanfly.Quest.questRewardsShow = + JSON.parse(Yanfly.Quest.LunaticMode['Show Reward']); +Game_System.prototype.questRewardsShowEval = function(questId, rewardId) { + eval(Yanfly.Quest.questRewardsShow); +}; + +Game_System.prototype.questRewardsShowRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var rewardId = parseInt(range[i]); + this.questRewardsShow(questId, rewardId); + } +}; + +Game_System.prototype.questRewardsShowAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.rewards.length; + for (var i = 1; i < length; ++i) { + this.questRewardsShow(questId, i); + } +}; + +Game_System.prototype.questRewardsHide = function(questId, rewardId) { + this.initQuestSettings(); + this._questsRewards[questId] = this._questsRewards[questId] || []; + if (!this._questsRewards[questId].contains(rewardId)) return; + var index = this._questsRewards[questId].indexOf(rewardId); + this._questsRewards[questId].splice(index, 1); + this._questsRewards[questId].sort(function(a, b) { + return a - b; + }); + this.questRewardsHideEval(questId, rewardId); +}; + +Yanfly.Quest.questRewardsHide = + JSON.parse(Yanfly.Quest.LunaticMode['Hide Reward']); +Game_System.prototype.questRewardsHideEval = function(questId, rewardId) { + eval(Yanfly.Quest.questRewardsHide); +}; + +Game_System.prototype.questRewardsHideRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var rewardId = parseInt(range[i]); + this.questRewardsHide(questId, rewardId); + } +}; + +Game_System.prototype.questRewardsHideAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.rewards.length; + for (var i = 1; i < length; ++i) { + this.questRewardsHide(questId, i); + } +}; + +Game_System.prototype.questRewardsNormal = function(questId, rewardId) { + this.initQuestSettings(); + var changed = false; + this._questsRewardsClaimed[questId] = + this._questsRewardsClaimed[questId] || []; + if (this._questsRewardsClaimed[questId].contains(rewardId)) { + changed = true; + var index = this._questsRewardsClaimed[questId].indexOf(rewardId); + this._questsRewardsClaimed[questId].splice(index, 1); + this._questsRewardsClaimed[questId].sort(function(a, b) { + return a - b; + }); + } + this._questsRewardsDenied[questId] = + this._questsRewardsDenied[questId] || []; + if (this._questsRewardsDenied[questId].contains(rewardId)) { + changed = true; + var index = this._questsRewardsDenied[questId].indexOf(rewardId); + this._questsRewardsDenied[questId].splice(index, 1); + this._questsRewardsDenied[questId].sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questRewardsNormalEval(questId, rewardId); +}; + +Yanfly.Quest.questRewardsNormal = + JSON.parse(Yanfly.Quest.LunaticMode['Normalize Reward']); +Game_System.prototype.questRewardsNormalEval = function(questId, rewardId) { + eval(Yanfly.Quest.questRewardsNormal); +}; + +Game_System.prototype.questRewardsNormalRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var rewardId = parseInt(range[i]); + this.questRewardsNormal(questId, rewardId); + } +}; + +Game_System.prototype.questRewardsNormalAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.rewards.length; + for (var i = 1; i < length; ++i) { + this.questRewardsNormal(questId, i); + } +}; + +Game_System.prototype.questRewardsClaim = function(questId, rewardId) { + this.initQuestSettings(); + var changed = false; + this._questsRewardsClaimed[questId] = + this._questsRewardsClaimed[questId] || []; + if (!this._questsRewardsClaimed[questId].contains(rewardId)) { + changed = true; + this._questsRewardsClaimed[questId].push(rewardId); + this._questsRewardsClaimed[questId].sort(function(a, b) { + return a - b; + }); + } + this._questsRewardsDenied[questId] = + this._questsRewardsDenied[questId] || []; + if (this._questsRewardsDenied[questId].contains(rewardId)) { + var index = this._questsRewardsDenied[questId].indexOf(rewardId); + this._questsRewardsDenied[questId].splice(index, 1); + this._questsRewardsDenied[questId].sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questRewardsClaimEval(questId, rewardId); +}; + +Yanfly.Quest.questRewardsClaim = + JSON.parse(Yanfly.Quest.LunaticMode['Claim Reward']); +Game_System.prototype.questRewardsClaimEval = function(questId, rewardId) { + eval(Yanfly.Quest.questRewardsClaim); +}; + +Game_System.prototype.questRewardsClaimRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var rewardId = parseInt(range[i]); + this.questRewardsClaim(questId, rewardId); + } +}; + +Game_System.prototype.questRewardsClaimAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.rewards.length; + for (var i = 1; i < length; ++i) { + this.questRewardsClaim(questId, i); + } +}; + +Game_System.prototype.questRewardsDeny = function(questId, rewardId) { + this.initQuestSettings(); + var changed = false; + this._questsRewardsDenied[questId] = + this._questsRewardsDenied[questId] || []; + if (!this._questsRewardsDenied[questId].contains(rewardId)) { + changed = true; + this._questsRewardsDenied[questId].push(rewardId); + this._questsRewardsDenied[questId].sort(function(a, b) { + return a - b; + }); + } + this._questsRewardsClaimed[questId] = + this._questsRewardsClaimed[questId] || []; + if (this._questsRewardsClaimed[questId].contains(rewardId)) { + var index = this._questsRewardsClaimed[questId].indexOf(rewardId); + this._questsRewardsClaimed[questId].splice(index, 1); + this._questsRewardsClaimed[questId].sort(function(a, b) { + return a - b; + }); + } + if (changed) this.questRewardsDenyEval(questId, rewardId); +}; + +Yanfly.Quest.questRewardsDeny = + JSON.parse(Yanfly.Quest.LunaticMode['Deny Reward']); +Game_System.prototype.questRewardsDenyEval = function(questId, rewardId) { + eval(Yanfly.Quest.questRewardsDeny); +}; + +Game_System.prototype.questRewardsDenyRange = function(questId, range) { + var length = range.length; + for (var i = 0; i < length; ++i) { + var rewardId = parseInt(range[i]); + this.questRewardsDeny(questId, rewardId); + } +}; + +Game_System.prototype.questRewardsDenyAll = function(questId) { + this.initQuestSettings(); + var questData = $dataQuests[questId]; + if (!questData) return; + var length = questData.rewards.length; + for (var i = 1; i < length; ++i) { + this.questRewardsDeny(questId, i); + } +}; + +Game_System.prototype.questChangeSubtextIndex = function(questId, index) { + this.initQuestSettings(); + this._questsSubtext[questId] = index; + this.questChangeSubtextIndexEval(questId, index); +}; + +Yanfly.Quest.questChangeSubtextIndexEval = + JSON.parse(Yanfly.Quest.LunaticMode['Change Subtext']); +Game_System.prototype.questChangeSubtextIndexEval = function(questId, index) { + eval(Yanfly.Quest.questChangeSubtextIndexEval); +}; + +//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Game_System Script Calls +//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +Game_System.prototype.totalQuestsAvailable = function() { + return this.getQuestsAvailable().length; +}; + +Game_System.prototype.totalQuestsCompleted = function() { + return this.getQuestsCompleted().length; +}; + +Game_System.prototype.totalQuestsFailed = function() { + return this.getQuestsFailed().length; +}; + +Game_System.prototype.totalQuestsKnown = function() { + return this.getAllQuests().length; +}; + +Game_System.prototype.totalQuestsInGame = function() { + return Yanfly.Quest.totalCount; +}; + +Game_System.prototype.totalQuestTypes = function(category, type) { + return this.getTypeQuests(category, type).length; +}; + +Game_System.prototype.totalVisibleQuestObjectives = function(questId) { + return this.getQuestObjectives(questId).length; +}; + +Game_System.prototype.totalQuestObjectives = function(questId) { + var questData = $dataQuests[questId]; + if (!questData) return 0; + return questData.objectives.length; +}; + +Game_System.prototype.totalVisibleQuestRewards = function(questId) { + return this.getQuestRewards(questId).length; +}; + +Game_System.prototype.totalQuestRewards = function(questId) { + var questData = $dataQuests[questId]; + if (!questData) return 0; + return questData.rewards.length; +}; + +Game_System.prototype.isQuestObjectiveCompleted = function(questId, objId) { + if (this._questsObjectivesCompleted[questId]) { + return this._questsObjectivesCompleted[questId].contains(objId); + } else { + return false; + } +}; + +Game_System.prototype.isQuestObjectiveFailed = function(questId, objId) { + if (this._questsObjectivesFailed[questId]) { + return this._questsObjectivesFailed[questId].contains(objId); + } else { + return false; + } +}; + +Game_System.prototype.isQuestObjectiveUncleared = function(questId, objId) { + if (this._questsKnown.contains(questId)) { + return !this.isQuestObjectiveCompleted(questId, objId) && + !this.isQuestObjectiveFailed(questId, objId) + } else { + return false; + } +}; + +Game_System.prototype.isQuestRewardClaimed = function(questId, objId) { + if (this._questsRewardsClaimed[questId]) { + return this._questsRewardsClaimed[questId].contains(objId); + } else { + return false; + } +}; + +Game_System.prototype.isQuestRewardDenied = function(questId, objId) { + if (this._questsRewardsDenied[questId]) { + return this._questsRewardsDenied[questId].contains(objId); + } else { + return false; + } +}; + +Game_System.prototype.isQuestRewardUnclaimed = function(questId, objId) { + if (this._questsKnown.contains(questId)) { + return !this.isQuestRewardClaimed(questId, objId) && + !this.isQuestRewardDenied(questId, objId) + } else { + return false; + } +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.Quest.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.Quest.Game_Interpreter_pluginCommand.call(this, command, args); + if (command === 'OpenQuestJournal') { + SceneManager.push(Scene_Quest); + } else if (command === 'Quest') { + this.processQuestPluginCommands(this.argsToString(args)); + } +}; + +Game_Interpreter.prototype.argsToString = function(args) { + var str = ''; + var length = args.length; + for (var i = 0; i < length; ++i) { + str += args[i] + ' '; + } + return str.trim(); +}; + +Game_Interpreter.prototype.parseNumericRange = function(str) { + if (str.match(/(\d+)[ ](?:THROUGH|to)[ ](\d+)/i)) { + var range = Yanfly.Util.getRange(parseInt(RegExp.$1), + parseInt(RegExp.$2)); + } else { + var range = str.split(','); + var length = range.length; + for (var i = 0; i < length; ++i) { + range[i] = parseInt(range[i]); + } + } + return range; +}; + +Game_Interpreter.prototype.processQuestPluginCommands = function(line) { + if (line.match(/EVAL[ ](.*)/i)) { + eval(RegExp.$1); + + } else if (line.match(/JOURNAL OPEN TO[ ](\d+)/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questAdd(questId); + $gameTemp.reservedQuestOpen(questId); + SceneManager.push(Scene_Quest); + } else if (line.match(/JOURNAL OPEN/i)) { + SceneManager.push(Scene_Quest); + + } else if (line.match(/JOURNAL SHOW/i)) { + $gameSystem.setShowQuest(true); + } else if (line.match(/JOURNAL HIDE/i)) { + $gameSystem.setShowQuest(false); + } else if (line.match(/JOURNAL ENABLE/i)) { + $gameSystem.setEnableQuest(true); + } else if (line.match(/JOURNAL DISABLE/i)) { + $gameSystem.setEnableQuest(false); + + } else if (line.match(/SET COMPLETED[ ](.*)/i)) { + var range = this.parseNumericRange(String(RegExp.$1)); + $gameSystem.questSetCompletedRange(range); + } else if (line.match(/SET FAILED[ ](.*)/i)) { + var range = this.parseNumericRange(String(RegExp.$1)); + $gameSystem.questSetFailedRange(range); + } else if (line.match(/SET AVAILABLE[ ](.*)/i)) { + var range = this.parseNumericRange(String(RegExp.$1)); + $gameSystem.questSetAvailableRange(range); + + } else if (line.match(/(\d+)[ ]CHANGE DESCRIPTION ENTRY TO[ ](\d+)/i)) { + var questId = parseInt(RegExp.$1); + var value = parseInt(RegExp.$2); + $gameSystem.questChangeDescriptionIndex(questId, value); + + } else if (line.match(/(\d+)[ ]SHOW OBJECTIVE[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questObjectivesShowRange(questId, range); + } else if (line.match(/(\d+)[ ]SHOW ALL OBJECTIVE/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questObjectivesShowAll(questId); + } else if (line.match(/(\d+)[ ]HIDE OBJECTIVE[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questObjectivesHideRange(questId, range); + } else if (line.match(/(\d+)[ ]HIDE ALL OBJECTIVE/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questObjectivesHideAll(questId); + } else if (line.match(/(\d+)[ ]NORMALIZE OBJECTIVE[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questObjectivesNormalRange(questId, range); + } else if (line.match(/(\d+)[ ]NORMALIZE ALL OBJECTIVE/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questObjectivesNormalAll(questId); + } else if (line.match(/(\d+)[ ]COMPLETE OBJECTIVE[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questObjectivesCompleteRange(questId, range); + } else if (line.match(/(\d+)[ ]COMPLETE ALL OBJECTIVE/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questObjectivesCompleteAll(questId); + } else if (line.match(/(\d+)[ ]FAIL OBJECTIVE[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questObjectivesFailRange(questId, range); + } else if (line.match(/(\d+)[ ]FAIL ALL OBJECTIVE/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questObjectivesFailAll(questId); + + } else if (line.match(/(\d+)[ ]SHOW REWARD[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questRewardsShowRange(questId, range); + } else if (line.match(/(\d+)[ ]SHOW ALL REWARD/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questRewardsShowAll(questId); + } else if (line.match(/(\d+)[ ]HIDE REWARD[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questRewardsHideRange(questId, range); + } else if (line.match(/(\d+)[ ]HIDE ALL REWARD/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questRewardsHideAll(questId); + } else if (line.match(/(\d+)[ ]NORMALIZE REWARD[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questRewardsNormalRange(questId, range); + } else if (line.match(/(\d+)[ ]NORMALIZE ALL REWARD/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questRewardsNormalAll(questId); + } else if (line.match(/(\d+)[ ]CLAIM REWARD[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questRewardsClaimRange(questId, range); + } else if (line.match(/(\d+)[ ]CLAIM ALL REWARD/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questRewardsClaimAll(questId); + } else if (line.match(/(\d+)[ ]DENY REWARD[ ](.*)/i)) { + var questId = parseInt(RegExp.$1); + var range = this.parseNumericRange(String(RegExp.$2)); + $gameSystem.questRewardsDenyRange(questId, range); + } else if (line.match(/(\d+)[ ]DENY ALL REWARD/i)) { + var questId = parseInt(RegExp.$1); + $gameSystem.questRewardsDenyAll(questId); + + } else if (line.match(/(\d+)[ ]CHANGE SUBTEXT ENTRY TO[ ](\d+)/i)) { + var questId = parseInt(RegExp.$1); + var value = parseInt(RegExp.$2); + $gameSystem.questChangeSubtextIndex(questId, value); + + } else if (line.match(/ADD[ ](.*)/i)) { + var range = this.parseNumericRange(String(RegExp.$1)); + $gameSystem.questAddRange(range); + + } else if (line.match(/REMOVE[ ](.*)/i)) { + var range = this.parseNumericRange(String(RegExp.$1)); + $gameSystem.questRemoveRange(range); + + } +}; + +//============================================================================= +// Window_MenuCommand +//============================================================================= + +Yanfly.Quest.Window_MenuCommand_addOriginalCommands = + Window_MenuCommand.prototype.addOriginalCommands; +Window_MenuCommand.prototype.addOriginalCommands = function() { + Yanfly.Quest.Window_MenuCommand_addOriginalCommands.call(this); + this.addQuestCommand(); +}; + +Window_MenuCommand.prototype.addQuestCommand = function() { + if (!Yanfly.Param.QuestCmdPlace) return; + if (!$gameSystem.isShowQuest()) return; + if (this.findSymbol('quest') > -1) return; + var text = Yanfly.Param.QuestCmdName; + var enabled = $gameSystem.isEnableQuest(); + this.addCommand(text, 'quest', enabled); +}; + +//============================================================================= +// Window_QuestData +//============================================================================= + +function Window_QuestData() { + this.initialize.apply(this, arguments); +}; + +Window_QuestData.prototype = Object.create(Window_Selectable.prototype); +Window_QuestData.prototype.constructor = Window_QuestData; + +Window_QuestData.prototype.initialize = function() { + var width = this.windowWidth(); + var height = this.windowHeight(); + var x = Math.round(eval(this.settings('X'))); + var y = Math.round(eval(this.settings('Y'))); + this._allTextHeight = 0; + this._countdown = 0; + this._arrowBlinkTimer = 0; + Window_Selectable.prototype.initialize.call(this, x, y, width, height); + this.setQuestId(0); + this.opacity = Math.round(eval(this.settings('Standard Opacity'))); +}; + +Window_QuestData.prototype.settings = function(key) { + return Yanfly.Param.QuestDataWindow[key]; +}; + +Window_QuestData.prototype.windowWidth = function() { + if (this._windowWidth === undefined) { + this._windowWidth = Math.round(eval(this.settings('Width'))); + } + return this._windowWidth; +}; + +Window_QuestData.prototype.windowHeight = function() { + if (this._windowHeight === undefined) { + this._windowHeight = Math.round(eval(this.settings('Height'))); + } + return this._windowHeight; +}; + +Window_QuestData.prototype.lineHeight = function() { + if (this._windowLineHeight === undefined) { + this._windowLineHeight = parseInt(this.settings('Line Height')); + } + return this._windowLineHeight; +}; + +Window_QuestData.prototype.standardFontFace = function() { + if (this._windowFontFace === undefined) { + this._windowFontFace = this.settings('Font Face'); + } + return this._windowFontFace; +}; + +Window_QuestData.prototype.standardFontSize = function() { + if (this._windowFontSize === undefined) { + this._windowFontSize = Math.round(eval(this.settings('Font Size'))); + } + return this._windowFontSize; +}; + +Window_QuestData.prototype.standardPadding = function() { + if (this._windowStandardPadding === undefined) { + this._windowStandardPadding = + Math.round(eval(this.settings('Standard Padding'))); + } + return this._windowStandardPadding; +}; + +Window_QuestData.prototype.textPadding = function() { + if (this._windowTextPadding === undefined) { + this._windowTextPadding = Math.round(eval(this.settings('Text Padding'))); + } + return this._windowTextPadding; +}; + +Window_QuestData.prototype.standardBackOpacity = function() { + if (this._windowBackOpacity === undefined) { + this._windowBackOpacity = Math.round(eval(this.settings('Back Opacity'))); + } + return this._windowBackOpacity; +}; + +Window_QuestData.prototype.loadWindowskin = function() { + this.windowskin = ImageManager.loadSystem(this.settings('Window Skin')); +}; + +Window_QuestData.prototype.delayLoadFrames = function() { + if (this._delayLoad === undefined) { + this._delayLoad = Math.round(eval(this.settings('Load Delay'))); + } + return this._delayLoad; +}; + +Window_QuestData.prototype.setQuestId = function(id) { + if (this._questId !== id) { + this._questId = id; + this._countdown = 30; + this.refresh(); + } +}; + +Window_QuestData.prototype.refresh = function() { + if (this._countdown > 0) return; + this.contents.clear(); + this._lastOriginY = -200; + this.origin.y = 0; + this._allTextHeight = 0; + if (this._questId > 0) { + this.drawQuestData(); + } else { + this.drawEmpty(); + } +}; + +Window_QuestData._questNoDataFmt = + JSON.parse(Yanfly.Param.QuestDataWindow['No Data Text'] || ""); + +Window_QuestData.prototype.drawEmpty = function() { + var fmt = Window_QuestData._questNoDataFmt; + var wordwrap = fmt.match(/<(?:WordWrap)>/i); + var text = fmt.format(); + var textState = { index: 0 }; + textState.originalText = text; + textState.text = this.convertEscapeCharacters(text); + this.resetFontSettings(); + this._allTextHeight = this.calcTextHeight(textState, true); + this._allTextHeight *= (wordwrap) ? 10 : 1; + this.createContents(); + this.drawQuestTextEx(text, 0, 0); +}; + +Window_QuestData.prototype.drawQuestData = function() { + Window_QuestData._questDataFmt = + JSON.parse(Yanfly.Param.QuestDataWindow['Quest Data Format'] || ""); + var questData = $dataQuests[this._questId]; + if (!questData) return; + var fmt = Window_QuestData._questDataFmt; + var wordwrap = fmt.match(/<(?:WordWrap)>/i); + var title = questData.name; + title = title.replace(/\\I\[(\d+)\]/gi, '').trim(); + title = title.replace(/\\C\[(\d+)\]/gi, '').trim(); + var difficulty = questData.difficulty; + var from = questData.from; + var location = questData.location; + var description = this.getQuestDescription(); + var objectives = this.getQuestObjectives(wordwrap); + var rewards = this.getQuestRewards(wordwrap); + var subtext = this.getQuestSubtext(); + var text = fmt.format(title, difficulty, from, location, description, + objectives, rewards, subtext); + var textState = { index: 0 }; + textState.originalText = text; + textState.text = this.convertEscapeCharacters(text); + this.resetFontSettings(); + this._allTextHeight = this.calcTextHeight(textState, true); + this._allTextHeight *= (wordwrap) ? 10 : 1; + this.createContents(); + this.drawQuestTextEx(text, 0, 0); +}; + +Window_QuestData.prototype.drawQuestTextEx = function(text, x, y) { + if (text) { + var textState = { index: 0, x: x, y: y, left: x }; + textState.text = this.convertEscapeCharacters(text); + textState.height = this.calcTextHeight(textState, false); + this.resetFontSettings(); + while (textState.index < textState.text.length) { + this.processCharacter(textState); + } + this._allTextHeight = textState.y - y + this.lineHeight(); + return textState.x - x; + } else { + return 0; + } +}; + +Window_QuestData.prototype.getQuestDescription = function() { + var questData = $dataQuests[this._questId]; + var index = $gameSystem.getQuestDescriptionIndex(this._questId); + return JSON.parse(questData.description[index]); +}; + +Window_QuestData.prototype.getQuestObjectives = function(wordwrap) { + var questData = $dataQuests[this._questId]; + var lineData = questData.objectives; + var visibleObjectives = $gameSystem.getQuestObjectives(this._questId); + var length = visibleObjectives.length; + var text = ''; + for (var i = 0; i < length; ++i) { + if (i > 0) text += wordwrap ? '
' : '\n'; + var objectiveId = visibleObjectives[i]; + var key = $gameSystem.getQuestObjectiveStatus(this._questId, objectiveId); + var fmt = this.settings(key); + text += fmt.format(JSON.parse(lineData[objectiveId])); + } + return text; +}; + +Window_QuestData.prototype.getQuestRewards = function(wordwrap) { + var questData = $dataQuests[this._questId]; + var lineData = questData.rewards; + var visibleRewards = $gameSystem.getQuestRewards(this._questId); + var length = visibleRewards.length; + var text = ''; + for (var i = 0; i < length; ++i) { + if (i > 0) text += wordwrap ? '
' : '\n'; + var rewardId = visibleRewards[i]; + var key = $gameSystem.getQuestRewardStatus(this._questId, rewardId); + var fmt = this.settings(key); + text += fmt.format(JSON.parse(lineData[rewardId])); + } + return text; +}; + +Window_QuestData.prototype.getQuestSubtext = function() { + var questData = $dataQuests[this._questId]; + var index = $gameSystem.getQuestSubtextIndex(this._questId); + return JSON.parse(questData.subtext[index]); +}; + +Window_QuestData.prototype.select = function(index) { +}; + +Window_QuestData.prototype.contentsHeight = function() { + var standard = this.height - this.standardPadding() * 2; + return Math.max(standard, this._allTextHeight); +}; + +Window_QuestData.prototype.update = function() { + Window_Selectable.prototype.update.call(this); + this.updateCountdown(); + if (this.isOpenAndActive()) this.updateKeyScrolling(); +}; + +Window_QuestData.prototype.updateCountdown = function() { + if (this._countdown > 0) { + this._countdown -= 1; + if (this._countdown <= 0) this.refresh(); + } +}; + +Window_QuestData.prototype.scrollSpeed = function() { + if (this._scrollSpeed === undefined) { + this._scrollSpeed = Number(this.settings('Scroll Speed')); + } + return this._scrollSpeed; +}; + +Window_QuestData.prototype.scrollOriginDown = function(speed) { + var value = this.contentsHeight() - this.height + + this.standardPadding() * 2; + this.origin.y = Math.min(value, this.origin.y + speed); +}; + +Window_QuestData.prototype.scrollOriginUp = function(speed) { + this.origin.y = Math.max(0, this.origin.y - speed); +}; + +Window_QuestData.prototype.updateKeyScrolling = function() { + if (Input.isPressed('up')) { + this.scrollOriginUp(this.scrollSpeed()); + } else if (Input.isPressed('down')) { + this.scrollOriginDown(this.scrollSpeed()); + } else if (Input.isPressed('pageup')) { + this.scrollOriginUp(this.scrollSpeed() * 4); + } else if (Input.isPressed('pagedown')) { + this.scrollOriginDown(this.scrollSpeed() * 4); + } +}; + +Window_QuestData.prototype.updateArrows = function() { + if (this._lastOriginY === this.origin.y) return; + this.showArrows(); +}; + +Window_QuestData.prototype.showArrows = function() { + this._lastOriginY = this.origin.y; + this.upArrowVisible = this.origin.y !== 0; + this.downArrowVisible = this.origin.y !== this.contentsHeight() - + this.height + this.standardPadding() * 2; +}; + +Window_QuestData.prototype.hideArrows = function() { + this.upArrowVisible = false; + this.downArrowVisible = false; +}; + +Window_QuestData.prototype.isInsideFrame = function() { + var x = this.canvasToLocalX(TouchInput._mouseOverX); + var y = this.canvasToLocalY(TouchInput._mouseOverY); + return x >= 0 && y >= 0 && x < this.width && y < this.height; +}; + +Window_QuestData.prototype.processWheel = function() { + if (!this.isInsideFrame()) return; + var threshold = 20; + if (TouchInput.wheelY >= threshold) { + this.scrollOriginDown(this.scrollSpeed() * 4); + } + if (TouchInput.wheelY <= -threshold) { + this.scrollOriginUp(this.scrollSpeed() * 4); + } +}; + +//============================================================================= +// Window_QuestTitle +//============================================================================= + +function Window_QuestTitle() { + this.initialize.apply(this, arguments); +}; + +Window_QuestTitle.prototype = Object.create(Window_Base.prototype); +Window_QuestTitle.prototype.constructor = Window_QuestTitle; + +Window_QuestTitle.prototype.initialize = function() { + var width = this.windowWidth(); + var height = this.windowHeight(); + var x = Math.round(eval(this.settings('X'))); + var y = Math.round(eval(this.settings('Y'))); + Window_Base.prototype.initialize.call(this, x, y, width, height); + this.setText(this.settings('No Quest Title')); + this.opacity = Math.round(eval(this.settings('Standard Opacity'))); +}; + +Window_QuestTitle.prototype.settings = function(key) { + return Yanfly.Param.QuestTitleWindow[key]; +}; + +Window_QuestTitle.prototype.windowWidth = function() { + if (this._windowWidth === undefined) { + this._windowWidth = Math.round(eval(this.settings('Width'))); + } + return this._windowWidth; +}; + +Window_QuestTitle.prototype.windowHeight = function() { + if (this._windowHeight === undefined) { + this._windowHeight = Math.round(eval(this.settings('Height'))); + } + return this._windowHeight; +}; + +Window_QuestTitle.prototype.lineHeight = function() { + if (this._windowLineHeight === undefined) { + this._windowLineHeight = parseInt(this.settings('Line Height')); + } + return this._windowLineHeight; +}; + +Window_QuestTitle.prototype.standardFontFace = function() { + if (this._windowFontFace === undefined) { + this._windowFontFace = this.settings('Font Face'); + } + return this._windowFontFace; +}; + +Window_QuestTitle.prototype.standardFontSize = function() { + if (this._windowFontSize === undefined) { + this._windowFontSize = Math.round(eval(this.settings('Font Size'))); + } + return this._windowFontSize; +}; + +Window_QuestTitle.prototype.standardPadding = function() { + if (this._windowStandardPadding === undefined) { + this._windowStandardPadding = + Math.round(eval(this.settings('Standard Padding'))); + } + return this._windowStandardPadding; +}; + +Window_QuestTitle.prototype.textPadding = function() { + if (this._windowTextPadding === undefined) { + this._windowTextPadding = Math.round(eval(this.settings('Text Padding'))); + } + return this._windowTextPadding; +}; + +Window_QuestTitle.prototype.itemTextAlign = function() { + return this.settings('Text Alignment') +}; + +Window_QuestTitle.prototype.standardBackOpacity = function() { + if (this._windowBackOpacity === undefined) { + this._windowBackOpacity = Math.round(eval(this.settings('Back Opacity'))); + } + return this._windowBackOpacity; +}; + +Window_QuestTitle.prototype.loadWindowskin = function() { + this.windowskin = ImageManager.loadSystem(this.settings('Window Skin')); +}; + +Window_QuestTitle.prototype.setText = function(text) { + if (this._text !== text) { + this._text = text; + this.refresh(); + } +}; + +Window_QuestTitle.prototype.refresh = function() { + this.contents.clear(); + var align = this.settings('Text Alignment'); + var wx = 0; + var ww = this.contents.width; + if (align === 'left') { + wx = this.textPadding(); + } else if (align === 'center') { + wx += (ww - this.textWidthEx(this._text)) / 2; + } else { + wx += ww - this.textWidthEx(this._text) - this.textPadding(); + } + this.drawTextEx(this._text, wx, 0); +}; + +Window_QuestTitle.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +//============================================================================= +// Window_QuestCategories +//============================================================================= + +function Window_QuestCategories() { + this.initialize.apply(this, arguments); +}; + +Window_QuestCategories.prototype = Object.create(Window_Command.prototype); +Window_QuestCategories.prototype.constructor = Window_QuestCategories; + +Window_QuestCategories.prototype.initialize = function() { + var width = this.windowWidth(); + var height = this.windowHeight(); + var x = Math.round(eval(this.settings('X'))); + var y = Math.round(eval(this.settings('Y'))); + Window_Command.prototype.initialize.call(this, x, y); + this.opacity = Math.round(eval(this.settings('Standard Opacity'))); +}; + +Window_QuestCategories.prototype.settings = function(key) { + return Yanfly.Param.QuestCategoryWindow[key]; +}; + +Window_QuestCategories.prototype.windowWidth = function() { + if (this._windowWidth === undefined) { + this._windowWidth = Math.round(eval(this.settings('Width'))); + } + return this._windowWidth; +}; + +Window_QuestCategories.prototype.windowHeight = function() { + if (this._windowHeight === undefined) { + this._windowHeight = Math.round(eval(this.settings('Height'))); + } + return this._windowHeight; +}; + +Window_QuestCategories.prototype.numVisibleRows = function() { + if (this._windowRows === undefined) { + this._windowRows = Math.round(eval(this.settings('Rows'))); + } + return this._windowRows; +}; + +Window_QuestCategories.prototype.maxCols = function() { + if (this._windowColumns === undefined) { + this._windowColumns = Math.round(eval(this.settings('Columns'))); + } + return this._windowColumns; +}; + +Window_QuestCategories.prototype.lineHeight = function() { + if (this._windowLineHeight === undefined) { + this._windowLineHeight = parseInt(this.settings('Line Height')); + } + return this._windowLineHeight; +}; + +Window_QuestCategories.prototype.standardFontFace = function() { + if (this._windowFontFace === undefined) { + this._windowFontFace = this.settings('Font Face'); + } + return this._windowFontFace; +}; + +Window_QuestCategories.prototype.standardFontSize = function() { + if (this._windowFontSize === undefined) { + this._windowFontSize = Math.round(eval(this.settings('Font Size'))); + } + return this._windowFontSize; +}; + +Window_QuestCategories.prototype.standardPadding = function() { + if (this._windowStandardPadding === undefined) { + this._windowStandardPadding = + Math.round(eval(this.settings('Standard Padding'))); + } + return this._windowStandardPadding; +}; + +Window_QuestCategories.prototype.textPadding = function() { + if (this._windowTextPadding === undefined) { + this._windowTextPadding = Math.round(eval(this.settings('Text Padding'))); + } + return this._windowTextPadding; +}; + +Window_QuestCategories.prototype.itemTextAlign = function() { + return this.settings('Text Alignment') +}; + +Window_QuestCategories.prototype.standardBackOpacity = function() { + if (this._windowBackOpacity === undefined) { + this._windowBackOpacity = Math.round(eval(this.settings('Back Opacity'))); + } + return this._windowBackOpacity; +}; + +Window_QuestCategories.prototype.loadWindowskin = function() { + this.windowskin = ImageManager.loadSystem(this.settings('Window Skin')); +}; + +Window_QuestCategories.prototype.makeCommandList = function() { + var list = JSON.parse(this.settings('Category Order')); + var length = list.length; + for (var i = 0; i < length; ++i) { + var listItem = list[i]; + switch (listItem) { + case 'available': + var fmt = this.settings('Available Text'); + var number = $gameSystem.totalQuestsAvailable(); + break; + case 'completed': + var fmt = this.settings('Completed Text'); + var number = $gameSystem.totalQuestsCompleted(); + break; + case 'failed': + var fmt = this.settings('Failed Text'); + var number = $gameSystem.totalQuestsFailed(); + break; + case 'all': + var fmt = this.settings('All Text'); + var number = $gameSystem.totalQuestsKnown(); + break; + case 'cancel': + var text = this.settings('Cancel Text'); + this.addCommand(text, 'cancel'); + continue; + break; + } + number = Yanfly.Util.toGroup(number); + var text = fmt.format(number); + this.addCommand(text, 'category', true, listItem); + } +}; + +Window_QuestCategories.prototype.drawItem = function(index) { + var rect = this.itemRectForText(index); + var text = this.commandName(index); + var align = this.settings('Text Alignment'); + var wx = 0; + var ww = rect.width; + if (align === 'left') { + wx = rect.x; + } else if (align === 'center') { + wx += (ww - this.textWidthEx(text)) / 2; + } else { + wx += ww - this.textWidthEx(text) - this.textPadding(); + } + this.drawTextEx(text, wx, rect.y); +}; + +Window_QuestCategories.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +Window_QuestCategories.prototype.setListWindow = function(win) { + this._listWindow = win; +}; + +Window_QuestCategories.prototype.update = function() { + Window_Command.prototype.update.call(this); + if (this._listWindow) this._listWindow.setCategoryType(this.currentExt()); +}; + +Window_QuestCategories.prototype.isInsideFrame = function() { + var x = this.canvasToLocalX(TouchInput._mouseOverX); + var y = this.canvasToLocalY(TouchInput._mouseOverY); + return x >= 0 && y >= 0 && x < this.width && y < this.height; +}; + +Window_QuestCategories.prototype.processWheel = function() { + if (!this.isInsideFrame()) return; + var threshold = 20; + if (TouchInput.wheelY >= threshold) this.scrollDown(); + if (TouchInput.wheelY <= -threshold) this.scrollUp(); +}; + +//============================================================================= +// Window_QuestList +//============================================================================= + +function Window_QuestList() { + this.initialize.apply(this, arguments); +}; + +Window_QuestList.prototype = Object.create(Window_Command.prototype); +Window_QuestList.prototype.constructor = Window_QuestList; + +Window_QuestList.prototype.initialize = function(cw, dw, tw) { + this._currentCategory = + JSON.parse(Yanfly.Param.QuestCategoryWindow['Category Order'])[0]; + this._closedQuestTypes = []; + var width = this.windowWidth(); + var height = this.windowHeight(); + var x = Math.round(eval(this.settings('X'))); + var y = Math.round(eval(this.settings('Y'))); + this._dataWindow = dw; + this._titleWindow = tw; + this._mode = 'Quest'; + Window_Command.prototype.initialize.call(this, x, y); + cw.setListWindow(this); + this.opacity = Math.round(eval(this.settings('Standard Opacity'))); + this.deselect(); + this.deactivate(); +}; + +Window_QuestList.prototype.settings = function(key) { + return Yanfly.Param.QuestListWindow[key]; +}; + +Window_QuestList.prototype.windowWidth = function() { + if (this._windowWidth === undefined) { + this._windowWidth = Math.round(eval(this.settings('Width'))); + } + return this._windowWidth; +}; + +Window_QuestList.prototype.windowHeight = function() { + if (this._windowHeight === undefined) { + this._windowHeight = Math.round(eval(this.settings('Height'))); + } + return this._windowHeight; +}; + +Window_QuestList.prototype.maxCols = function() { + return 1; +}; + +Window_QuestList.prototype.lineHeight = function() { + if (this._windowLineHeight === undefined) { + this._windowLineHeight = parseInt(this.settings('Line Height')); + } + return this._windowLineHeight; +}; + +Window_QuestList.prototype.standardFontFace = function() { + if (this._windowFontFace === undefined) { + this._windowFontFace = this.settings('Font Face'); + } + return this._windowFontFace; +}; + +Window_QuestList.prototype.standardFontSize = function() { + if (this._windowFontSize === undefined) { + this._windowFontSize = Math.round(eval(this.settings('Font Size'))); + } + return this._windowFontSize; +}; + +Window_QuestList.prototype.standardPadding = function() { + if (this._windowStandardPadding === undefined) { + this._windowStandardPadding = + Math.round(eval(this.settings('Standard Padding'))); + } + return this._windowStandardPadding; +}; + +Window_QuestList.prototype.textPadding = function() { + if (this._windowTextPadding === undefined) { + this._windowTextPadding = Math.round(eval(this.settings('Text Padding'))); + } + return this._windowTextPadding; +}; + +Window_QuestList.prototype.standardBackOpacity = function() { + if (this._windowBackOpacity === undefined) { + this._windowBackOpacity = Math.round(eval(this.settings('Back Opacity'))); + } + return this._windowBackOpacity; +}; + +Window_QuestList.prototype.loadWindowskin = function() { + this.windowskin = ImageManager.loadSystem(this.settings('Window Skin')); +}; + +Window_QuestList.prototype.itemTextAlign = function() { + return this.settings('Quest Alignment') +}; + +Window_QuestList.prototype.drawItem = function(index) { + var rect = this.itemRectForText(index); + var text = this.commandName(index); + var symbol = this.commandSymbol(index); + this.changePaintOpacity(this.isCommandEnabled(index)); + if (symbol === 'type') { + var align = this.settings('Type Alignment'); + } else { + var align = this.settings('Quest Alignment'); + var indent = parseInt(this.settings('Quest Indent')); + rect.x += indent; + rect.width -= indent; + } + var wx = 0; + var ww = rect.width; + if (align === 'left') { + wx = rect.x; + } else if (align === 'center') { + wx += (ww - this.textWidthEx(text)) / 2; + } else { + wx += ww - this.textWidthEx(text) - this.textPadding(); + } + this.drawTextEx(text, wx, rect.y); +}; + +Window_QuestList.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +Window_QuestList.prototype.setCategoryType = function(category) { + if (this._currentCategory !== category) { + this._currentCategory = category; + this.refresh(); + this.resetScroll(); + this.deselect(); + this.update(); + } +}; + +Window_QuestList.prototype.showType = function() { + if (this._settingsShowType === undefined) { + this._settingsShowType = Math.round(eval(this.settings('Show Types'))); + } + return this._settingsShowType; +}; + +Window_QuestList.prototype.showEmptyTypes = function() { + if (this._showEmpty === undefined) { + this._showEmpty = eval(this.settings('Show Empty')); + } + return this._showEmpty; +}; + +Window_QuestList.prototype.setMode = function(mode) { + if (mode === 'Extra') { + this._prevTopRow = this.topRow(); + this._prevIndex = this.index(); + this._forcedExt = this.currentExt(); + this.setTopRow(0); + } else { + this._forcedExt = undefined; + } + this._mode = mode; + this.refresh(); + this.activate(); + if (mode === 'Extra') { + this.select(0); + } else { + this.select(this._prevIndex); + this.setTopRow(this._prevTopRow); + } +}; + +Window_QuestList.prototype.currentExt = function() { + return this._forcedExt || Window_Command.prototype.currentExt.call(this); +}; + +Window_QuestList.prototype.makeCommandList = function() { + if (this._mode === 'Quest') { + this.makeQuestList(); + } else { + this.makeExtraList(); + } +}; + +Window_QuestList.prototype.makeQuestList = function() { + if (this.showType()) { + var list = JSON.parse(this.settings('Type Order')); + var length = list.length; + for (var i = 0; i < length; ++i) { + var listItem = list[i]; + var fmt = this.settings('Type Text Format'); + var type = listItem.replace(/\\I\[(\d+)\]/gi, '').trim(); + var type = listItem.replace(/\\C\[(\d+)\]/gi, '').trim(); + if (this._closedQuestTypes.contains(type)) { + var closed = this.settings('List Closed Symbol'); + } else { + var closed = this.settings('List Open Symbol'); + } + var number = $gameSystem.getTypeQuests(this._currentCategory, + type).length; + if (!this.showEmptyTypes() && number <= 0) continue; + number = Yanfly.Util.toGroup(number); + var text = fmt.format(closed, listItem, number); + this.addCommand(text, 'type', true, type); + if (!this._closedQuestTypes.contains(type)) { + this.addQuestCommands(this._currentCategory, type); + } + } + } else { + this.addQuestCommands(this._currentCategory) + } +}; + +Window_QuestList.prototype.makeExtraList = function() { + this.addReadQuestCommand(); + this.makeExtraListA(); + this.makeExtraListB(); + this.makeExtraListC(); + this.makeExtraListD(); + this.makeExtraListE(); + this.makeExtraListF(); + this.addCancelCommand(); +}; + +Window_QuestList.prototype.addReadQuestCommand = function() { + var text = this.settings('Read Quest') || '\\i[121]Read Quest'; + this.addCommand(text, 'readQuest'); +}; + +Window_QuestList.prototype.addCancelCommand = function() { + var text = this.settings('Cancel') || '\\i[16]Cancel'; + this.addCommand(text, 'cancel'); +}; + +Window_QuestList.prototype.makeExtraListA = function() { +}; + +Window_QuestList.prototype.makeExtraListB = function() { +}; + +Window_QuestList.prototype.makeExtraListC = function() { +}; + +Window_QuestList.prototype.makeExtraListD = function() { +}; + +Window_QuestList.prototype.makeExtraListE = function() { +}; + +Window_QuestList.prototype.makeExtraListF = function() { +}; + +Window_QuestList.prototype.addQuestCommands = function(category, type) { + category = category || this._currentCategory; + type = type || ''; + var list = $gameSystem.getTypeQuests(category, type); + var length = list.length; + for (var i = 0; i < length; ++i) { + var questId = list[i]; + var questData = $dataQuests[questId]; + if (!questData) continue; + var text = questData.name; + this.addCommand(text, 'quest', true, questId); + } +}; + +Window_QuestList.prototype.update = function() { + Window_Command.prototype.update.call(this); + if (this._dataWindow) { + if (this.currentSymbol() === 'quest' || this._mode === 'Extra') { + this._dataWindow.setQuestId(this.currentExt()); + } else { + this._dataWindow.setQuestId(0); + } + } + if (this._titleWindow) { + if (this.currentSymbol() === 'quest' || this._mode === 'Extra') { + this._titleWindow.setText($dataQuests[this.currentExt()].name); + } else { + this._titleWindow.setText(this._titleWindow.settings('No Quest Title')); + } + } +}; + +Window_QuestList.prototype.typeToggle = function(type) { + if (this._closedQuestTypes.contains(type)) { + var index = this._closedQuestTypes.indexOf(type); + this._closedQuestTypes.splice(index, 1); + } else { + this._closedQuestTypes.push(type); + } + this.refresh(); +}; + +Window_QuestList.prototype.getVisibleRows = function() { + var value = this.height - (this.standardPadding() * 2); + value = Math.floor(value / this.lineHeight()); + return value; +}; + +Window_QuestList.prototype.isInsideFrame = function() { + var x = this.canvasToLocalX(TouchInput._mouseOverX); + var y = this.canvasToLocalY(TouchInput._mouseOverY); + return x >= 0 && y >= 0 && x < this.width && y < this.height; +}; + +Window_QuestList.prototype.processWheel = function() { + if (!this.isInsideFrame()) return; + var threshold = 20; + if (TouchInput.wheelY >= threshold) this.scrollDown(); + if (TouchInput.wheelY <= -threshold) this.scrollUp(); +}; + +//============================================================================= +// Scene_Menu +//============================================================================= + +Yanfly.Quest.Scene_Menu_createCommandWindow = + Scene_Menu.prototype.createCommandWindow; +Scene_Menu.prototype.createCommandWindow = function() { + Yanfly.Quest.Scene_Menu_createCommandWindow.call(this); + this._commandWindow.setHandler('quest', this.commandQuest.bind(this)); +}; + +Scene_Menu.prototype.commandQuest = function() { + SceneManager.push(Scene_Quest); +}; + +//============================================================================= +// Scene_Quest +//============================================================================= + +function Scene_Quest() { + this.initialize.apply(this, arguments); +}; + +Scene_Quest.prototype = Object.create(Scene_MenuBase.prototype); +Scene_Quest.prototype.constructor = Scene_Quest; + +Scene_Quest.prototype.initialize = function() { + Scene_MenuBase.prototype.initialize.call(this); +}; + +Scene_Quest.prototype.create = function() { + Scene_MenuBase.prototype.create.call(this); + this.runCustomCode(Yanfly.Quest.createBefore); + this.createDataWindow(); + this.createTitleWindow(); + this.createCategoryWindow(); + this.createListWindow(); + this.processQuestOpen(); + this.runCustomCode(Yanfly.Quest.createAfter); +}; + +Yanfly.Quest.createBefore = + JSON.parse(Yanfly.Quest.LunaticMode['Before Create Windows']); +Yanfly.Quest.createAfter = + JSON.parse(Yanfly.Quest.LunaticMode['After Create Windows']); +Yanfly.Quest.terminateMenu = + JSON.parse(Yanfly.Quest.LunaticMode['Close Quest Menu']); + +Scene_Quest.prototype.runCustomCode = function(code) { + var background = this._backgroundSprite; + var windowLayer = this._windowLayer; + eval(code); +}; + +Scene_Quest.prototype.createDataWindow = function() { + this._dataWindow = new Window_QuestData(); + this._dataWindow.setHandler('cancel', this.onDataCancel.bind(this)); + this.addWindow(this._dataWindow); +}; + +Scene_Quest.prototype.createTitleWindow = function() { + this._titleWindow = new Window_QuestTitle(); + this.addWindow(this._titleWindow); +}; + +Scene_Quest.prototype.createCategoryWindow = function() { + this._categoryWindow = new Window_QuestCategories(); + this._categoryWindow.setHandler('cancel', this.onCategoryCancel.bind(this)); + this._categoryWindow.setHandler('category', this.onCategoryOk.bind(this)); + this.addWindow(this._categoryWindow); +}; + +Scene_Quest.prototype.createListWindow = function() { + this._listWindow = new Window_QuestList(this._categoryWindow, + this._dataWindow, this._titleWindow); + this._listWindow.setHandler('cancel', this.onListCancel.bind(this)); + this._listWindow.setHandler('type', this.onListTypeToggle.bind(this)); + this._listWindow.setHandler('quest', this.onListQuest.bind(this)); + this._listWindow.setHandler('readQuest', this.dataWindowActivate.bind(this)); + this.addWindow(this._listWindow); +}; + +Scene_Quest.prototype.onCategoryCancel = function() { + this.runCustomCode(Yanfly.Quest.terminateMenu); + this.popScene(); +}; + +Scene_Quest.prototype.onCategoryOk = function() { + this._listWindow.activate(); + if (this._listWindow.index() < 0) this._listWindow.select(0); +}; + +Scene_Quest.prototype.isQuestExtraCommand = function() { + return false; +}; + +Scene_Quest.prototype.onListCancel = function() { + if (this._listWindow._mode === 'Extra') { + this._listWindow.setMode('Quest'); + } else { + this._categoryWindow.activate(); + } +}; + +Scene_Quest.prototype.onListTypeToggle = function() { + this._listWindow.activate(); + this._listWindow.typeToggle(this._listWindow.currentExt()); +}; + +Scene_Quest.prototype.onListQuest = function() { + if (this.isQuestExtraCommand()) { + this._listWindow.setMode('Extra'); + } else { + this.dataWindowActivate(); + } +}; + +Scene_Quest.prototype.dataWindowActivate = function() { + this._dataWindow.activate(); +}; + +Scene_Quest.prototype.onDataCancel = function() { + if (this._dataWindow._mode === 'Extra') { + this._listWindow.setMode('Quest'); + } else { + this._dataWindow.deactivate(); + this._listWindow.activate(); + } +}; + +Scene_Quest.prototype.processQuestOpen = function() { + var questId = $gameTemp.getQuestOpen(); + if (questId) { + var categoryOrder = this.getQuestOpenCategories(); + var length = categoryOrder.length; + for (var i = 0; i < length; ++i) { + var category = categoryOrder[i]; + var index = this._categoryWindow.findExt(category); + if (index >= 0) break; + } + this._categoryWindow.selectExt(index); + this.onCategoryOk(); + this._categoryWindow.deactivate(); + this._listWindow.selectExt(questId); + this.onListQuest(); + if (this._listWindow._mode === 'Quest') { + this._listWindow.deactivate(); + this._listWindow.setTopRow(this._listWindow.findExt(questId)); + var scrollTimes = Math.floor(this._listWindow.getVisibleRows() / 2); + while (scrollTimes--) { + this._listWindow.scrollUp(); + } + } else if (this._listWindow._mode === 'Extra') { + this.dataWindowActivate(); + this._listWindow.deactivate(); + } + this._listWindow.ensureCursorVisible(); + this._listWindow.updateCursor(); + } + $gameTemp.clearQuestOpen(); +}; + +Scene_Quest.prototype.getQuestOpenCategories = function() { + return ['available', 'completed', 'failed', 'all']; +}; + +// Custom Code + +Scene_Quest.prototype.centerSprite = function(sprite) { + sprite.x = Graphics.width / 2; + sprite.y = Graphics.height / 2; + sprite.anchor.x = 0.5; + sprite.anchor.y = 0.5; +}; + +Scene_Quest.prototype.fitScreen = function(sprite) { + if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) { + return setTimeout(this.fitScreen.bind(this, sprite), 5); + } + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + var ratioX = width / sprite.bitmap.width; + var ratioY = height / sprite.bitmap.height; + if (ratioX > 1.0) sprite.scale.x = ratioX; + if (ratioY > 1.0) sprite.scale.y = ratioY; + this.centerSprite(sprite); +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + +Yanfly.Util.toGroup = function(inVal) { + return inVal; +}; + +}; // Yanfly.Util.toGroup + +Yanfly.Util.getRange = function(n, m) { + var result = []; + for (var i = n; i <= m; ++i) result.push(i); + return result; +}; + +//============================================================================= +// End of Main Functions +//============================================================================= +} else { + +var text = ''; +text += 'You are getting this error because you are trying to run '; +text += 'YEP_QuestJournal while your project files are lower than version '; +text += '1.5.0.\n\nPlease visit this thread for instructions on how to update '; +text += 'your project files to 1.5.0 or higher: \n\n'; +text += 'https://forums.rpgmakerweb.com/index.php?threads/'; +text += 'rpg-maker-mv-1-5-0-update.79677/'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.5.0') +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_RegionEvents.js b/js/plugins/YEP_RegionEvents.js new file mode 100644 index 0000000..3fb5e0a --- /dev/null +++ b/js/plugins/YEP_RegionEvents.js @@ -0,0 +1,2015 @@ +//============================================================================= +// Yanfly Engine Plugins - Region Events +// YEP_RegionEvents.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_RegionEvents = true; + +var Yanfly = Yanfly || {}; +Yanfly.RCE = Yanfly.RCE || {}; +Yanfly.RCE.version = 1.03; + +//============================================================================= + /*: + * @plugindesc v1.03 Make it so that whenever players step on certain + * Region ID's, the game will play certain common events. + * @author Yanfly Engine Plugins + * + * @param ---Regions 1 to 20--- + * @default + * + * @param Region 1 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 2 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 3 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 4 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 5 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 6 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 7 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 8 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 9 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 10 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 11 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 12 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 13 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 14 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 15 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 16 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 17 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 18 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 19 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 20 + * @parent ---Regions 1 to 20--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 21 to 40--- + * @default + * + * @param Region 21 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 22 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 23 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 24 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 25 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 26 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 27 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 28 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 29 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 30 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 31 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 32 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 33 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 34 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 35 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 36 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 37 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 38 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 39 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 40 + * @parent ---Regions 21 to 40--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 41 to 60--- + * @default + * + * @param Region 41 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 42 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 43 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 44 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 45 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 46 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 47 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 48 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 49 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 50 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 51 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 52 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 53 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 54 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 55 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 56 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 57 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 58 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 59 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 60 + * @parent ---Regions 41 to 60--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 61 to 80--- + * @default + * + * @param Region 61 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 62 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 63 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 64 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 65 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 66 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 67 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 68 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 69 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 70 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 71 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 72 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 73 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 74 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 75 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 76 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 77 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 78 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 79 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 80 + * @parent ---Regions 61 to 80--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 81 to 100--- + * @default + * + * @param Region 81 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 82 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 83 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 84 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 85 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 86 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 87 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 88 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 89 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 90 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 91 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 92 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 93 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 94 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 95 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 96 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 97 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 98 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 99 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 100 + * @parent ---Regions 81 to 100--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 101 to 120--- + * @default + * + * @param Region 101 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 102 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 103 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 104 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 105 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 106 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 107 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 108 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 109 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc The common event to play for this region when stepped on. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 110 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 111 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 112 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 113 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 114 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 115 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 116 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 117 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 118 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 119 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 120 + * @parent ---Regions 101 to 120--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 121 to 140--- + * @default + * + * @param Region 121 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 122 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 123 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 124 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 125 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 126 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 127 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 128 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 129 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 130 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 131 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 132 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 133 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 134 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 135 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 136 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 137 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 138 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 139 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 140 + * @parent ---Regions 121 to 140--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 141 to 160--- + * @default + * + * @param Region 141 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 142 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 143 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 144 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 145 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 146 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 147 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 148 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 149 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 150 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 151 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 152 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 153 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 154 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 155 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 156 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 157 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 158 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 159 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 160 + * @parent ---Regions 141 to 160--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 161 to 180--- + * @default + * + * @param Region 161 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 162 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 163 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 164 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 165 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 166 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 167 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 168 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 169 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 170 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 171 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 172 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 173 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 174 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 175 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 176 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 177 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 178 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 179 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 180 + * @parent ---Regions 161 to 180--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param ---Regions 181 to 200--- + * @default + * + * @param Region 181 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 182 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 183 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 184 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 185 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 186 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 187 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 188 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 189 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 190 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 191 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 192 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 193 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 194 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 195 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 196 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 197 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 198 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 199 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that region not trigger a common event. + * @default 0 + * + * @param Region 200 + * @parent ---Regions 181 to 200--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param ---Regions 201 to 220--- + * @default + * + * @param Region 201 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 202 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 203 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 204 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 205 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 206 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 207 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 208 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 209 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 210 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 211 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 212 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 213 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 214 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 215 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 216 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 217 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 218 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 219 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 220 + * @parent ---Regions 201 to 220--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param ---Regions 221 to 240--- + * @default + * + * @param Region 221 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 222 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 223 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 224 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 225 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 226 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 227 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 228 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 229 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 230 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 231 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 232 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 233 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 234 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 235 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 236 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 237 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 238 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 239 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 240 + * @parent ---Regions 221 to 240--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param ---Regions 241 to 255--- + * @default + * + * @param Region 241 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 242 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 243 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 244 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 245 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 246 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 247 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 248 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 249 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 250 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 251 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 252 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 253 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 254 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @param Region 255 + * @parent ---Regions 241 to 255--- + * @type common_event + * @desc What common event to play for this Region when stepped upon. + * Use 0 to have that Region not trigger a common event. + * @default 0 + * + * @help + * ============================================================================ + * Introduction and Instructions + * ============================================================================ + * + * There are 255 Regions you can mark on your map. You can set it so that when + * players step on those specific Regions, a Common Event will play each time + * they step on it. To do so, bind a Common Event's ID to the Region number in + * this plugin's parameters. It will make it so that any tile with that very + * specific Region ID to trigger an on-Player Touch event using the Common + * Event ID that you have marked for it. + * + * Keep in mind that if any common event occurs during a touch input, it will + * clear the touch input as intended by the game engine. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * You can use this notetag inside of your maps. + * + * Map Notetags: + * + * If the player steps onto a tile marked by Region x, it will run the + * common event y. This will override the default settings marked in the + * editor specifically for that map. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.03: + * - Corrected an issue that would cause a region event to repeatedly trigger + * if the mouse button is held down on the player. + * + * Version 1.02: + * - Fixed a bug that prevented region events from trigger if the mouse button + * is held down longer than usual. + * + * Version 1.01a: + * - Fixed a bug with region event notetags that stopped working if it was used + * to teleport onto the same map. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_RegionEvents'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.RCE.RegionEvents = {}; +for (Yanfly.i = 1; Yanfly.i <= 255; ++Yanfly.i) { + Yanfly.line = "Number(Yanfly.Parameters['Region " + Yanfly.i + "'] || 0)"; + Yanfly.RCE.RegionEvents[Yanfly.i] = eval(Yanfly.line); +}; + +//============================================================================= +// DataManager +//============================================================================= + +DataManager.processRECNotetags = function() { + if (!$dataMap) return; + if (!$dataMap.note) return; + var notedata = $dataMap.note.split(/[\r\n]+/); + $dataMap.regionCommonEvents = {}; + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:REGION)[ ](\d+)[ ](?:EVENT):[ ](\d+)>/i)) { + $dataMap.regionCommonEvents[parseInt(RegExp.$1)] = parseInt(RegExp.$2); + } + } +}; + +//============================================================================= +// Game_Map +//============================================================================= + +Yanfly.RCE.Game_Map_setup = Game_Map.prototype.setup; +Game_Map.prototype.setup = function(mapId) { + if ($dataMap) DataManager.processRECNotetags(); + Yanfly.RCE.Game_Map_setup.call(this, mapId); +}; + +Game_Map.prototype.isRegionEvent = function(mx, my) { + return (this.isValid(mx, my) && this.regionEventTag(mx, my)); +}; + +Game_Map.prototype.getUniqueRegionCommonEvent = function(regionId) { + if ($dataMap.regionCommonEvents === undefined) { + DataManager.processRECNotetags(); + } + if ($dataMap.regionCommonEvents && $dataMap.regionCommonEvents[regionId]) { + return $dataMap.regionCommonEvents[regionId]; + } + return 0; +}; + +Game_Map.prototype.regionEventTag = function(mx, my) { + if (this.regionId(mx, my) <= 0) return false; + var regionId = this.regionId(mx, my); + if (this.getUniqueRegionCommonEvent(regionId) > 0) return true; + return Yanfly.RCE.RegionEvents[regionId] > 0; +}; + +Game_Map.prototype.moveAfterCommonEvent = function() { + var interpreter = $gameMap._interpreter; + if (!interpreter._list) return false; + if (interpreter.eventId() > 0) return false; + var list = interpreter._list; + if ($gameTemp.destinationX() === $gamePlayer.x && + $gameTemp.destinationY() === $gamePlayer.y) { + $gameTemp.clearDestination(); + } + for (var i = 0; i < list.length; ++i) { + var code = list[i].code; + if ([201, 205, 230, 232, 261, 301].contains(code)) return false; + } + return true; +}; + +//============================================================================= +// Game_Player +//============================================================================= + +Yanfly.RCE.Game_Player_checkEventTriggerHere = + Game_Player.prototype.checkEventTriggerHere; +Game_Player.prototype.checkEventTriggerHere = function(triggers) { + if (!this.canStartLocalEvents()) return; + if (!triggers.contains(0)) this.processRegionEvent(); + Yanfly.RCE.Game_Player_checkEventTriggerHere.call(this, triggers); +}; + +Game_Player.prototype.processRegionEvent = function() { + if (!$gameMap.isRegionEvent(this.x, this.y)) return; + if (Input.isTriggered('ok')) return; + var regionId = $gameMap.regionId(this.x, this.y) + if ($gameMap.getUniqueRegionCommonEvent(regionId) > 0) { + var commonEventId = $gameMap.getUniqueRegionCommonEvent(regionId); + } else { + var commonEventId = Yanfly.RCE.RegionEvents[regionId]; + } + $gameTemp.reserveCommonEvent(commonEventId); +}; + +Yanfly.RCE.Game_Player_canMove = Game_Player.prototype.canMove; +Game_Player.prototype.canMove = function() { + if ($gameMessage.isBusy()) { + return false; + } + if (this.isMoveRouteForcing() || this.areFollowersGathering()) { + return false; + } + if (this._vehicleGettingOn || this._vehicleGettingOff) { + return false; + } + if (this.isInVehicle() && !this.vehicle().canMove()) { + return false; + } + if ($gameMap.isEventRunning() && $gameMap.moveAfterCommonEvent()) { + return true; + } + return Yanfly.RCE.Game_Player_canMove.call(this); +}; + + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_RegionRestrictions.js b/js/plugins/YEP_RegionRestrictions.js new file mode 100644 index 0000000..f1511b2 --- /dev/null +++ b/js/plugins/YEP_RegionRestrictions.js @@ -0,0 +1,453 @@ +//============================================================================= +// Yanfly Engine Plugins - Region Restrictions +// YEP_RegionRestrictions.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_RegionRestrictions = true; + +var Yanfly = Yanfly || {}; +Yanfly.RR = Yanfly.RR || {}; +Yanfly.RR.version = 1.04 + +//============================================================================= + /*: + * @plugindesc v1.04 Use regions to block out Events and/or the player from + * being able to venture into those spots. + * @author Yanfly Engine Plugins + * + * @param Player Restrict + * @desc This region ID will restrict the player from entering. + * To use multiple regions, separate them by spaces. + * @default 0 + * + * @param Event Restrict + * @desc This region ID will restrict all events from entering. + * To use multiple regions, separate them by spaces. + * @default 0 + * + * @param All Restrict + * @desc This region ID will restrict players and events. + * To use multiple regions, separate them by spaces. + * @default 0 + * + * @param Player Allow + * @desc This region ID will always allow player passability. + * To use multiple regions, separate them by spaces. + * @default 0 + * + * @param Event Allow + * @desc This region ID will always allow events passability. + * To use multiple regions, separate them by spaces. + * @default 0 + * + * @param All Allow + * @desc This region ID will always allow both passability. + * To use multiple regions, separate them by spaces. + * @default 0 + * + * @help + * ============================================================================ + * Introduction and Instructions + * ============================================================================ + * + * Not everybody wants NPC's to travel all over the place. With this plugin, + * you can set NPC's to be unable to move pass tiles marked by a specified + * Region ID. Simply draw out the area you want to enclose NPC's in on and + * they'll be unable to move past it unless they have Through on. Likewise, + * there are regions that you can prevent the player from moving onto, too! + * + * A new change from the RPG Maker VX Ace version is that now there exist + * Regions that can allow players and events to always travel through. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * You can use this notetag inside of your maps. + * + * Map Notetags: + * + * + * + * + * Restricts region x for the player on this particular map. Use multiple x + * to mark more regions. From x to y, you can mark a multitude of regions. + * + * + * + * + * Restricts region x for all events on this particular map. Use multiple x + * to mark more regions. From x to y, you can mark a multitude of regions. + * + * + * + * + * Restricts region x for the player and all events on this particular map. + * Use multiple x to mark more regions. From x to y, you can mark a multitude + * of regions. + * + * + * + * + * Allows region x for the player on this particular map. Use multiple x + * to mark more regions. From x to y, you can mark a multitude of regions. + * + * + * + * + * Allows region x for all events on this particular map. Use multiple x + * to mark more regions. From x to y, you can mark a multitude of regions. + * + * + * + * + * Allows region x for the player and all events on this particular map. + * Use multiple x to mark more regions. From x to y, you can mark a multitude + * of regions. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.04: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.03: + * - Fixed an issue with vehicles being capable of landing the player in region + * restricted zones. + * + * Version 1.02: + * - Plugin parameters have been upgraded to now accept multiple region ID's. + * Insert a space in between them to add more than one region ID. + * + * Version 1.01: + * - Added new notetags to allow for more region restriction settings! + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.SetupParameters = function() { + var parameters = PluginManager.parameters('YEP_RegionRestrictions'); + Yanfly.Param.RRAllAllow = String(parameters['All Allow']); + Yanfly.Param.RRAllAllow = Yanfly.Param.RRAllAllow.split(' '); + for (var i = 0; i < Yanfly.Param.RRAllAllow.length; ++i) { + Yanfly.Param.RRAllAllow[i] = Number(Yanfly.Param.RRAllAllow[i]); + } + Yanfly.Param.RRAllRestrict = String(parameters['All Restrict']); + Yanfly.Param.RRAllRestrict = Yanfly.Param.RRAllRestrict.split(' '); + for (var i = 0; i < Yanfly.Param.RRAllRestrict.length; ++i) { + Yanfly.Param.RRAllRestrict[i] = Number(Yanfly.Param.RRAllRestrict[i]); + } + Yanfly.Param.RREventAllow = String(parameters['Event Allow']); + Yanfly.Param.RREventAllow = Yanfly.Param.RREventAllow.split(' '); + for (var i = 0; i < Yanfly.Param.RREventAllow.length; ++i) { + Yanfly.Param.RREventAllow[i] = Number(Yanfly.Param.RREventAllow[i]); + } + Yanfly.Param.RREventRestrict = String(parameters['Event Restrict']); + Yanfly.Param.RREventRestrict = Yanfly.Param.RREventRestrict.split(' '); + for (var i = 0; i < Yanfly.Param.RREventRestrict.length; ++i) { + Yanfly.Param.RREventRestrict[i] = Number(Yanfly.Param.RREventRestrict[i]); + } + Yanfly.Param.RRPlayerAllow = String(parameters['Player Allow']); + Yanfly.Param.RRPlayerAllow = Yanfly.Param.RRPlayerAllow.split(' '); + for (var i = 0; i < Yanfly.Param.RRPlayerAllow.length; ++i) { + Yanfly.Param.RRPlayerAllow[i] = Number(Yanfly.Param.RRPlayerAllow[i]); + } + Yanfly.Param.RRPlayerRestrict = String(parameters['Player Restrict']); + Yanfly.Param.RRPlayerRestrict = Yanfly.Param.RRPlayerRestrict.split(' '); + for (var i = 0; i < Yanfly.Param.RRPlayerRestrict.length; ++i) { + Yanfly.Param.RRPlayerRestrict[i] = Number(Yanfly.Param.RRPlayerRestrict[i]); + } +}; +Yanfly.SetupParameters(); + +//============================================================================= +// DataManager +//============================================================================= + +DataManager.processRRNotetags = function() { + if (!$dataMap) return; + $dataMap.restrictPlayerRegions = Yanfly.Param.RRAllRestrict.concat( + Yanfly.Param.RRPlayerRestrict); + $dataMap.restrictEventRegions = Yanfly.Param.RRAllRestrict.concat( + Yanfly.Param.RREventRestrict); + $dataMap.allowPlayerRegions = Yanfly.Param.RRAllAllow.concat( + Yanfly.Param.RRPlayerAllow); + $dataMap.allowEventRegions = Yanfly.Param.RRAllAllow.concat( + Yanfly.Param.RREventAllow); + if (!$dataMap.note) return; + + var note1a = /<(?:PLAYER RESTRICT REGION):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note1b = /<(?:PLAYER RESTRICT REGION):[ ](\d+)[ ](?:TO)[ ](\d+)>/i; + var note2a = /<(?:EVENT RESTRICT REGION):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note2b = /<(?:EVENT RESTRICT REGION):[ ](\d+)[ ](?:TO)[ ](\d+)>/i; + var note3a = /<(?:ALL RESTRICT REGION):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note3b = /<(?:ALL RESTRICT REGION):[ ](\d+)[ ](?:TO)[ ](\d+)>/i; + + var note4a = /<(?:PLAYER ALLOW REGION):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note4b = /<(?:PLAYER ALLOW REGION):[ ](\d+)[ ](?:TO)[ ](\d+)>/i; + var note5a = /<(?:EVENT ALLOW REGION):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note5b = /<(?:EVENT ALLOW REGION):[ ](\d+)[ ](?:TO)[ ](\d+)>/i; + var note6a = /<(?:ALL ALLOW REGION):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note6b = /<(?:ALL ALLOW REGION):[ ](\d+)[ ](?:TO)[ ](\d+)>/i; + + var notedata = $dataMap.note.split(/[\r\n]+/); + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1a)) { + array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + $dataMap.restrictPlayerRegions = + $dataMap.restrictPlayerRegions.concat(array); + } else if (line.match(note1b)) { + var mainArray = $dataMap.restrictPlayerRegions; + var range = Yanfly.Util.getRange(Number(RegExp.$1), + Number(RegExp.$2)); + $dataMap.restrictPlayerRegions = + $dataMap.restrictPlayerRegions.concat(range); + } else if (line.match(note2a)) { + array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + $dataMap.restrictEventRegions = + $dataMap.restrictEventRegions.concat(array); + } else if (line.match(note2b)) { + var range = Yanfly.Util.getRange(Number(RegExp.$1), + Number(RegExp.$2)); + $dataMap.restrictEventRegions = + $dataMap.restrictEventRegions.concat(range); + } else if (line.match(note3a)) { + array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + $dataMap.restrictPlayerRegions = + $dataMap.restrictPlayerRegions.concat(array); + $dataMap.restrictEventRegions = + $dataMap.restrictEventRegions.concat(array); + } else if (line.match(note3b)) { + var range = Yanfly.Util.getRange(Number(RegExp.$1), + Number(RegExp.$2)); + $dataMap.restrictPlayerRegions = + $dataMap.restrictPlayerRegions.concat(array); + $dataMap.restrictEventRegions = + $dataMap.restrictEventRegions.concat(array); + } else if (line.match(note4a)) { + array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + $dataMap.allowPlayerRegions = + $dataMap.allowPlayerRegions.concat(array); + } else if (line.match(note4b)) { + var range = Yanfly.Util.getRange(Number(RegExp.$1), + Number(RegExp.$2)); + $dataMap.allowPlayerRegions =$dataMap.allowPlayerRegions.concat(range); + } else if (line.match(note5a)) { + array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + $dataMap.allowEventRegions = $dataMap.allowEventRegions.concat(array); + } else if (line.match(note5b)) { + var range = Yanfly.Util.getRange(Number(RegExp.$1), + Number(RegExp.$2)); + $dataMap.allowEventRegions = $dataMap.allowEventRegions.concat(range); + } else if (line.match(note6a)) { + array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + $dataMap.allowPlayerRegions = $dataMap.allowPlayerRegions.concat(array); + $dataMap.allowEventRegions = $dataMap.allowEventRegions.concat(array); + } else if (line.match(note6b)) { + var range = Yanfly.Util.getRange(Number(RegExp.$1), + Number(RegExp.$2)); + $dataMap.allowPlayerRegions = $dataMap.allowPlayerRegions.concat(array); + $dataMap.allowEventRegions = $dataMap.allowEventRegions.concat(array); + } + } +}; + +//============================================================================= +// Game_Map +//============================================================================= + +Yanfly.RR.Game_Map_setup = Game_Map.prototype.setup; +Game_Map.prototype.setup = function(mapId) { + Yanfly.RR.Game_Map_setup.call(this, mapId); + if ($dataMap) DataManager.processRRNotetags(); +}; + +Game_Map.prototype.restrictEventRegions = function() { + if ($dataMap.restrictEventRegions === undefined) { + DataManager.processRRNotetags(); + } + return $dataMap.restrictEventRegions || []; +}; + +Game_Map.prototype.restrictPlayerRegions = function() { + if ($dataMap.restrictPlayerRegions === undefined) { + DataManager.processRRNotetags(); + } + return $dataMap.restrictPlayerRegions || []; +}; + +Game_Map.prototype.allowEventRegions = function() { + if ($dataMap.allowEventRegions === undefined) { + DataManager.processRRNotetags(); + } + return $dataMap.allowEventRegions || []; +}; + +Game_Map.prototype.allowPlayerRegions = function() { + if ($dataMap.allowPlayerRegions === undefined) { + DataManager.processRRNotetags(); + } + return $dataMap.allowPlayerRegions || []; +}; + +//============================================================================= +// Game_CharacterBase +//============================================================================= + +Yanfly.RR.Game_CharacterBase_isMapPassable = + Game_CharacterBase.prototype.isMapPassable; +Game_CharacterBase.prototype.isMapPassable = function(x, y, d) { + if (this.isEventRegionForbid(x, y, d)) return false; + if (this.isPlayerRegionForbid(x, y, d)) return false; + if (this.isEventRegionAllow(x, y, d)) return true; + if (this.isPlayerRegionAllow(x, y, d)) return true; + return Yanfly.RR.Game_CharacterBase_isMapPassable.call(this, x, y, d); +}; + +Game_CharacterBase.prototype.isEvent = function() { + return false; +}; + +Game_CharacterBase.prototype.isPlayer = function() { + return false; +}; + +Game_CharacterBase.prototype.processRRNotetags = function() { + DataManager.processRRNotetags(); +}; + +Game_CharacterBase.prototype.isEventRegionForbid = function(x, y, d) { + if (this.isPlayer()) return false; + if (this.isThrough()) return false; + var regionId = this.getRegionId(x, y, d); + if (regionId === 0) return false; + if ($gameMap.restrictEventRegions().contains(regionId)) return true; + return false; +}; + +Game_CharacterBase.prototype.isPlayerRegionForbid = function(x, y, d) { + if (this.isEvent()) return false; + if (this.isThrough()) return false; + var regionId = this.getRegionId(x, y, d); + if (regionId === 0) return false; + if ($gameMap.restrictPlayerRegions().contains(regionId)) return true; + return false; +}; + +Game_CharacterBase.prototype.isEventRegionAllow = function(x, y, d) { + if (this.isPlayer()) return false; + var regionId = this.getRegionId(x, y, d); + if (regionId === 0) return false; + if ($gameMap.allowEventRegions().contains(regionId)) return true; + return false; +}; + +Game_CharacterBase.prototype.isPlayerRegionAllow = function(x, y, d) { + if (this.isEvent()) return false; + var regionId = this.getRegionId(x, y, d); + if (regionId === 0) return false; + if ($gameMap.allowPlayerRegions().contains(regionId)) return true; + return false +}; + +Game_CharacterBase.prototype.getRegionId = function(x, y, d) { + switch (d) { + case 1: + return $gameMap.regionId(x - 1, y + 1); + break; + case 2: + return $gameMap.regionId(x + 0, y + 1); + break; + case 3: + return $gameMap.regionId(x + 1, y + 1); + break; + case 4: + return $gameMap.regionId(x - 1, y + 0); + break; + case 5: + return $gameMap.regionId(x + 0, y + 0); + break; + case 6: + return $gameMap.regionId(x + 1, y + 0); + break; + case 7: + return $gameMap.regionId(x - 1, y - 1); + break; + case 8: + return $gameMap.regionId(x + 0, y - 1); + break; + case 9: + return $gameMap.regionId(x + 1, y - 1); + break; + default: + return $gameMap.regionId(x, y); + break; + } +}; + +//============================================================================= +// Game_Event +//============================================================================= + +Game_Event.prototype.isEvent = function() { + return true; +}; + +//============================================================================= +// Game_Player +//============================================================================= + +Game_Player.prototype.isPlayer = function() { + return true; +}; + +//============================================================================= +// Game_Vehicle +//============================================================================= + +Yanfly.RR.Game_Vehicle_isLandOk = Game_Vehicle.prototype.isLandOk; +Game_Vehicle.prototype.isLandOk = function(x, y, d) { + var value = Yanfly.RR.Game_Vehicle_isLandOk.call(this, x, y, d); + if (!value) return false; + if (this.isAirship()) { + d = 5; + $gamePlayer._through = false; + } + if ($gamePlayer.isPlayerRegionForbid(x, y, d)) { + if (this.isAirship()) $gamePlayer._through = true; + return false; + } + if ($gamePlayer.isPlayerRegionAllow(x, y, d)) { + if (this.isAirship()) $gamePlayer._through = true; + return true; + } + return true; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.getRange = function(n, m) { + var result = []; + for (var i = n; i <= m; ++i) result.push(i); + return result; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_SaveCore.js b/js/plugins/YEP_SaveCore.js new file mode 100644 index 0000000..76af435 --- /dev/null +++ b/js/plugins/YEP_SaveCore.js @@ -0,0 +1,1485 @@ +//============================================================================= +// Yanfly Engine Plugins - Save Core +// YEP_SaveCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_SaveCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.Save = Yanfly.Save || {}; +Yanfly.Save.version = 1.06; + +//============================================================================= + /*: + * @plugindesc v1.06 Alter the save menu for a more aesthetic layout + * and take control over the file system's rules. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Max Files + * @parent ---General--- + * @type number + * @min 1 + * @desc The maximum number of files for your game. + * Default: 20 + * @default 24 + * + * @param Saved Icon + * @parent ---General--- + * @type number + * @min 0 + * @desc Icon ID used for a file slot with a save. + * @default 231 + * + * @param Empty Icon + * @parent ---General--- + * @type number + * @min 0 + * @desc Icon ID used for an empty file slot. + * @default 230 + * + * @param Return After Saving + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Return to the previous scene after saving? + * NO - false YES - true Default: true + * @default false + * + * @param Auto New Index + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc For new games, automatically decide the save slot? + * NO - false YES - true Default: true + * @default true + * + * @param ---Action Window--- + * @default + * + * @param Load Command + * @parent ---Action Window--- + * @desc Text for the load command in the action window. + * @default Load + * + * @param Save Command + * @parent ---Action Window--- + * @desc Text for the save command in the action window. + * @default Save + * + * @param Delete Command + * @parent ---Action Window--- + * @desc Text for the delete command in the action window. + * @default Delete + * + * @param ---Help Window--- + * @default + * + * @param Select Help + * @parent ---Help Window--- + * @desc Help text displayed when selecting a slot. + * @default Please select a file slot. + * + * @param Load Help + * @parent ---Help Window--- + * @desc Help text displayed when selecting load option. + * @default Loads the data from the saved game. + * + * @param Save Help + * @parent ---Help Window--- + * @desc Help text displayed when selecting save option. + * @default Saves the current progress in your game. + * + * @param Delete Help + * @parent ---Help Window--- + * @desc Help text displayed when selecting delete option. + * @default Deletes all data from this save file. + * + * @param ---Delete--- + * @default + * + * @param Delete Filename + * @parent ---Delete--- + * @type file + * @dir audio/se/ + * @require 1 + * @desc Used for the delete sound from the /audio/se/ folder. + * Do NOT include the file extension. + * @default Damage2 + * + * @param Delete Volume + * @parent ---Delete--- + * @desc Volume used for the delete sound. + * @default 100 + * + * @param Delete Pitch + * @parent ---Delete--- + * @desc Pitch used for the delete sound. + * @default 150 + * + * @param Delete Pan + * @parent ---Delete--- + * @desc Pan used for the delete sound. + * @default 0 + * + * @param ---Info Window--- + * @default + * + * @param Show Game Title + * @parent ---Info Window--- + * @type boolean + * @on Show + * @off Hide + * @desc Display the game title in the save file? + * NO - false YES - true + * @default true + * + * @param Invalid Game Text + * @parent ---Info Window--- + * @desc Text used when the save is for a different game. + * @default This save is for a different game. + * + * @param Empty Game Text + * @parent ---Info Window--- + * @desc Text used when the save is empty. + * @default Empty + * + * @param Map Display Name + * @parent ---Info Window--- + * @type boolean + * @on Show + * @off Hide + * @desc Use the display name for the saved map instead? + * NO - false YES - true + * @default true + * + * @param Party Display + * @parent ---Info Window--- + * @type select + * @option None + * @value 0 + * @option Characters + * @value 1 + * @option Faces + * @value 2 + * @option SV Actors + * @value 3 + * @desc The display type used for the party. + * 0 - None; 1 - Characters; 2 - Faces; 3 - SV Actors + * @default 2 + * + * @param Party Y Position + * @parent ---Info Window--- + * @desc This is the base Y position for the party display. + * Formulas can be used. + * @default this.lineHeight() + Window_Base._faceHeight + * + * @param Show Actor Names + * @parent ---Info Window--- + * @type boolean + * @on Show + * @off Hide + * @desc Display the names of the actors? + * NO - false YES - true + * @default true + * + * @param Name Font Size + * @parent ---Info Window--- + * @type number + * @min 1 + * @desc Font size used for names if names are displayed. + * Default: 28 + * @default 20 + * + * @param Show Actor Level + * @parent ---Info Window--- + * @type boolean + * @on Show + * @off Hide + * @desc Display the levels of the actors? + * NO - false YES - true + * @default true + * + * @param Level Font Size + * @parent ---Info Window--- + * @type number + * @min 1 + * @desc Font size used for levels if levels are displayed. + * Default: 28 + * @default 20 + * + * @param Level Format + * @parent ---Info Window--- + * @desc The text format used to display levels. + * %1 - Lv (Abbr) %2 - Lv (Full) %3 - Value + * @default \c[16]%1 \c[0]%3 + * + * @param Data Font Size + * @parent ---Info Window--- + * @type number + * @min 1 + * @desc Font size used for displaying data. + * Default: 28 + * @default 20 + * + * @param Data Column 1 + * @parent ---Info Window--- + * @desc The data to be displayed in data column 1. Refer to help + * file for data entries. Separate each entry with commas. + * @default empty, playtime, save count, gold count + * + * @param Data Column 2 + * @parent ---Info Window--- + * @desc The data to be displayed in data column 2. Refer to help + * file for data entries. Separate each entry with commas. + * @default location, variable 1, variable 2, variable 3 + * + * @param Data Column 3 + * @parent ---Info Window--- + * @desc The data to be displayed in data column 2. Refer to help + * file for data entries. Separate each entry with commas. + * @default empty, variable 4, variable 5, variable 6 + * + * @param Data Column 4 + * @parent ---Info Window--- + * @desc The data to be displayed in data column 2. Refer to help + * file for data entries. Separate each entry with commas. + * @default + * + * @param ---Vocabulary--- + * @default + * + * @param Map Location + * @parent ---Vocabulary--- + * @desc Text used to categorize 'Map Location'. + * Leave empty to not use this category and center the data. + * @default + * + * @param Playtime + * @parent ---Vocabulary--- + * @desc Text used to categorize 'Playtime'. + * Leave empty to not use this category and center the data. + * @default Playtime: + * + * @param Save Count + * @parent ---Vocabulary--- + * @desc Text used to categorize 'Save Count'. + * Leave empty to not use this category and center the data. + * @default Total Saves: + * + * @param Gold Count + * @parent ---Vocabulary--- + * @desc Text used to categorize 'Gold Count'. + * Leave empty to not use this category and center the data. + * @default %1: + * + * @param ---Technical--- + * @default + * + * @param Save Mode + * @parent ---Technical--- + * @type combo + * @option local + * @option web + * @option auto + * @desc How the save system should work for your game: + * local web auto + * @default auto + * + * @param Local Config + * @parent ---Technical--- + * @desc Filename for config when working with local saves. + * Default: config.rpgsave + * @default config.rpgsave + * + * @param Local Global + * @parent ---Technical--- + * @desc Filename for global when working with local saves. + * Default: global.rpgsave + * @default global.rpgsave + * + * @param Local Save + * @parent ---Technical--- + * @desc Filename for game saves when working with local saves. + * %1 - File Slot. Default: config.rpgsave + * @default file%1.rpgsave + * + * @param Web Config + * @parent ---Technical--- + * @desc Filename for config when working with web saves. + * %1 - Game Name. Default: RPG Config + * @default RPG %1 Config + * + * @param Web Global + * @parent ---Technical--- + * @desc Filename for global when working with web saves. + * %1 - Game Name. Default: RPG Global + * @default RPG %1 Global + * + * @param Web Save + * @parent ---Technical--- + * @desc Filename for game saves when working with web saves. + * %1 - Game Name. %2 - File Slot. Default: RPG File%1 + * @default RPG %1 File%2 + * + * @param ---Confirmation--- + * @default + * + * @param Load Confirmation + * @parent ---Confirmation--- + * @type boolean + * @on YES + * @off NO + * @desc Show the load confirmation window when loading a + * save file? NO - false YES - true + * @default true + * + * @param Load Text + * @parent ---Confirmation--- + * @desc Text displayed when loading a save file. + * @default Do you wish to load this save file? + * + * @param Save Confirmation + * @parent ---Confirmation--- + * @type boolean + * @on YES + * @off NO + * @desc Show the save confirmation window when overwriting a + * save file? NO - false YES - true + * @default true + * + * @param Save Text + * @parent ---Confirmation--- + * @desc Text displayed when overwriting a save file. + * @default Do you wish to overwrite this save file? + * + * @param Delete Confirmation + * @parent ---Confirmation--- + * @type boolean + * @on YES + * @off NO + * @desc Show the save confirmation window when deleting a + * save file? NO - false YES - true + * @default true + * + * @param Delete Text + * @parent ---Confirmation--- + * @desc Text displayed when deleting a save file. + * @default Do you wish to delete this save file? + * + * @param Confirm Yes + * @parent ---Confirmation--- + * @desc Text used for the 'Yes' confirm command + * @default Yes + * + * @param Confirm No + * @parent ---Confirmation--- + * @desc Text used for the 'No' confirm command + * @default No + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin provides a new save interface for the player. Along with a new + * interface, the player can also load and delete saves straight from the menu + * itself. This will in turn make the save command from the Main Menu always + * available, but the save option within the new save menu will be enabled + * depending on whether or not it is allowed or disallowed. From the interface, + * the player is given more information regarding the save file including the + * the location the player saved at, the amount of gold available, and any + * variables that you want to show the player as well. + * + * ============================================================================ + * Instructions - Data Columns + * ============================================================================ + * + * For those who wish to show additional data in the save menu for each save + * file, you can add various data categories within the 'Data Columns' inside + * the plugin parameters. Separate each category with a comma (,). You can use + * the following entries for data categories: + * + * Data Column Categories: + * + * Empty + * - Leaves an empty box in the category location. This won't even show the + * dark rectangle in the category slot. + * + * Null + * - Won't draw any text, but it will draw the dark rectangle in the + * category slot. + * + * Location + * - Draws the current map location of the save file. + * + * Playtime + * - Draws the playtime spent for the save file. + * + * Save Count + * - Draws the number of times saved in that playthrough. + * + * Gold Count + * - Draws the current gold count of the safe file. + * + * Variable x + * - Draws the name of the variable and value of the variable. You can use + * text codes in the variable name. Any text between << and >> will be not + * be shown when drawn. If the variable name is empty, the value will be + * centered. + * + * text: stuff + * left text: stuff + * center text: stuff + * right text: stuff + * - This will draw 'stuff' (Replace it with your own text) as text by itself + * with no data attached. Use 'left', 'center', or 'right' to decide the text + * alignment. If no alignment is used, it will default to 'left' alignment. + * You can use text codes within the drawn text. + * + * ============================================================================ + * Technical - Save Modes + * ============================================================================ + * + * For developers who are planning to publish their RPG Maker MV games on the + * web, you may want to look into the 'Technical' parameters. Here, you can + * force the game into thinking the game is running on 'local' or 'web' mode. + * By default, you'll want it on 'auto' but the forced modes are for testing + * purposes. Despite being for testing purposes, if you wish for your game to + * adjust saves as per 'web' mode, you can keep it that way even if your game + * is to be local-only. Games on the web, however, cannot use 'local' mode and + * will automatically default to 'web' mode. + * + * ============================================================================ + * Technical - Save Files + * ============================================================================ + * + * The 'Local Config', 'Local Global', and 'Local Save' can have their filename + * format changed to your liking. Personally, I don't recommend messing with + * this unless you know what you're doing. + * + * --- + * + * However, if you are making a web-based (mobile included), I strongly suggest + * you look into the 'Web Config', 'Web Global', and 'Web Save' parameters. By + * default, RPG Maker MV defaults all of the saves to RPG FileX. All web-based + * RPG Maker MV games would then use the same configuration, same global save + * file, and all RPG Maker MV games played by an individual would share the + * same save slots. This can be very problematic. + * + * This plugin's default settings will solve this sharing issue by making the + * web save named accordingly to your game's name provided that you keep the + * current plugin settings as is or adjust it accordingly. Now, your game will + * have its own individual identity, use its own configuration, global, and + * save files without clashing with any other RPG Maker MV games players may + * have played. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.06: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.05: + * - Added anti-crash measure for nonexistent $dataMapInfos entries. + * + * Version 1.04: + * - Added 'Map Display Name' plugin parameter. Enabling this option will now + * display the display name for the map instead of the editor name. + * + * Version 1.03: + * - Fixed a bug that caused web saving to not work properly. + * + * Version 1.02: + * - Fixed a bug that caused the actor's default name to appear in the save + * screen instead of the actor's current name (if it was changed.) + * + * Version 1.01: + * - Added a wait time update for save info data to load when moving across the + * various save files. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_SaveCore'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.SaveMaxFiles = Number(Yanfly.Parameters['Max Files']); +Yanfly.Param.SaveIconSaved = Number(Yanfly.Parameters['Saved Icon']); +Yanfly.Param.SaveIconEmpty = Number(Yanfly.Parameters['Empty Icon']); +Yanfly.Param.SavePop = eval(String(Yanfly.Parameters['Return After Saving'])); +Yanfly.Param.SaveAutoIndex = eval(String(Yanfly.Parameters['Auto New Index'])); + +Yanfly.Param.SaveCmdLoad = String(Yanfly.Parameters['Load Command']); +Yanfly.Param.SaveCmdSave = String(Yanfly.Parameters['Save Command']); +Yanfly.Param.SaveCmdDelete = String(Yanfly.Parameters['Delete Command']); + +Yanfly.Param.SaveHelpSelect = String(Yanfly.Parameters['Select Help']); +Yanfly.Param.SaveLoadSelect = String(Yanfly.Parameters['Load Help']); +Yanfly.Param.SaveSaveSelect = String(Yanfly.Parameters['Save Help']); +Yanfly.Param.SaveDeleteSelect = String(Yanfly.Parameters['Delete Help']); + +Yanfly.Param.SaveDeleteSound = { + name: String(Yanfly.Parameters['Delete Filename']), + volume: Number(Yanfly.Parameters['Delete Volume']), + pitch: Number(Yanfly.Parameters['Delete Pitch']), + pan: Number(Yanfly.Parameters['Delete Pan']) +}; + +Yanfly.Param.SaveInfoTitle = String(Yanfly.Parameters['Show Game Title']); +Yanfly.Param.SaveInfoTitle = eval(Yanfly.Param.SaveInfoTitle); +Yanfly.Param.SaveInfoInvalid = String(Yanfly.Parameters['Invalid Game Text']); +Yanfly.Param.SaveInfoEmpty = String(Yanfly.Parameters['Empty Game Text']); +Yanfly.Param.SaveMapDisplayName = String(Yanfly.Parameters['Map Display Name']); +Yanfly.Param.SaveMapDisplayName = eval(Yanfly.Param.SaveMapDisplayName); +Yanfly.Param.SaveInfoPartyType = Number(Yanfly.Parameters['Party Display']); +Yanfly.Param.SaveInfoPartyType = Yanfly.Param.SaveInfoPartyType.clamp(0, 3); +Yanfly.Param.SaveInfoPartyY = String(Yanfly.Parameters['Party Y Position']); +Yanfly.Param.SaveInfoActorName = String(Yanfly.Parameters['Show Actor Names']); +Yanfly.Param.SaveInfoActorName = eval(Yanfly.Param.SaveInfoActorName); +Yanfly.Param.SaveInfoActorNameSz = Number(Yanfly.Parameters['Name Font Size']); +Yanfly.Param.SaveInfoActorLv = String(Yanfly.Parameters['Show Actor Level']); +Yanfly.Param.SaveInfoActorLv = eval(Yanfly.Param.SaveInfoActorLv); +Yanfly.Param.SaveInfoActorLvSz = Number(Yanfly.Parameters['Level Font Size']); +Yanfly.Param.SaveInfoActorLvFmt = String(Yanfly.Parameters['Level Format']); +Yanfly.Param.SaveInfoDataSz = Number(Yanfly.Parameters['Data Font Size']); +Yanfly.Param.SaveInfoDataCol1 = String(Yanfly.Parameters['Data Column 1']); +Yanfly.Param.SaveInfoDataCol1 = Yanfly.Param.SaveInfoDataCol1.split(','); +Yanfly.Param.SaveInfoDataCol2 = String(Yanfly.Parameters['Data Column 2']); +Yanfly.Param.SaveInfoDataCol2 = Yanfly.Param.SaveInfoDataCol2.split(','); +Yanfly.Param.SaveInfoDataCol3 = String(Yanfly.Parameters['Data Column 3']); +Yanfly.Param.SaveInfoDataCol3 = Yanfly.Param.SaveInfoDataCol3.split(','); +Yanfly.Param.SaveInfoDataCol4 = String(Yanfly.Parameters['Data Column 4']); +Yanfly.Param.SaveInfoDataCol4 = Yanfly.Param.SaveInfoDataCol4.split(','); + +Yanfly.trimSaveDataColumns = function(array) { + var length = array.length; + for (var i = 0; i < length; ++i) { + array[i] = array[i].trim(); + } + if (length === 1 && array[0] === '') array.splice(0); +}; + +Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol1); +Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol2); +Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol3); +Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol4); + +Yanfly.Param.SaveVocabLocation = String(Yanfly.Parameters['Map Location']); +Yanfly.Param.SaveVocabPlaytime = String(Yanfly.Parameters['Playtime']); +Yanfly.Param.SaveVocabSaveCount = String(Yanfly.Parameters['Save Count']); +Yanfly.Param.SaveVocabGoldCount = String(Yanfly.Parameters['Gold Count']); + +Yanfly.Param.SaveTechSaveMode = String(Yanfly.Parameters['Save Mode']).trim(); +Yanfly.Param.SaveTechSaveMode = Yanfly.Param.SaveTechSaveMode.toLowerCase(); +Yanfly.Param.SaveTechLocalConfig = String(Yanfly.Parameters['Local Config']); +Yanfly.Param.SaveTechLocalGlobal = String(Yanfly.Parameters['Local Global']); +Yanfly.Param.SaveTechLocalSave = String(Yanfly.Parameters['Local Save']); +Yanfly.Param.SaveTechWebConfig = String(Yanfly.Parameters['Web Config']); +Yanfly.Param.SaveTechWebGlobal = String(Yanfly.Parameters['Web Global']); +Yanfly.Param.SaveTechWebSave = String(Yanfly.Parameters['Web Save']); + +Yanfly.Param.SaveConfirmLoad = String(Yanfly.Parameters['Load Confirmation']); +Yanfly.Param.SaveConfirmLoad = eval(Yanfly.Param.SaveConfirmLoad); +Yanfly.Param.SaveConfirmLoadTx = String(Yanfly.Parameters['Load Text']); +Yanfly.Param.SaveConfirmSave = String(Yanfly.Parameters['Save Confirmation']); +Yanfly.Param.SaveConfirmSave = eval(Yanfly.Param.SaveConfirmSave); +Yanfly.Param.SaveConfirmSaveTx = String(Yanfly.Parameters['Save Text']); +Yanfly.Param.SaveConfirmDel = String(Yanfly.Parameters['Delete Confirmation']); +Yanfly.Param.SaveConfirmDel = eval(Yanfly.Param.SaveConfirmDel); +Yanfly.Param.SaveConfirmDelTx = String(Yanfly.Parameters['Delete Text']); +Yanfly.Param.SaveConfirmYes = String(Yanfly.Parameters['Confirm Yes']); +Yanfly.Param.SaveConfirmNo = String(Yanfly.Parameters['Confirm No']); + +//============================================================================= +// DataManager +//============================================================================= + +DataManager.maxSavefiles = function() { + return Yanfly.Param.SaveMaxFiles; +}; + +Yanfly.Save.DataManager_selectSavefileForNewGame = + DataManager.selectSavefileForNewGame; +DataManager.selectSavefileForNewGame = function() { + Yanfly.Save.DataManager_selectSavefileForNewGame.call(this); + if (Yanfly.Param.SaveAutoIndex) return; + this._lastAccessedId = 1; +}; + +Yanfly.Save.DataManager_makeSaveContents = DataManager.makeSaveContents; +DataManager.makeSaveContents = function() { + var contents = Yanfly.Save.DataManager_makeSaveContents.call(this); + contents.map.locationDisplayName = $dataMap.displayName; + return contents; +}; + +//============================================================================= +// StorageManager +//============================================================================= + +Yanfly.Save.StorageManager_isLocalMode = StorageManager.isLocalMode; +StorageManager.isLocalMode = function() { + if (Yanfly.Param.SaveTechSaveMode === 'local') { + if (!Utils.isNwjs()) return false; + return true; + } else if (Yanfly.Param.SaveTechSaveMode === 'web') { + return false; + } else { + return Yanfly.Save.StorageManager_isLocalMode.call(this); + } +}; + +StorageManager.localFilePath = function(savefileId) { + var name; + if (savefileId < 0) { + name = Yanfly.Param.SaveTechLocalConfig; + } else if (savefileId === 0) { + name = Yanfly.Param.SaveTechLocalGlobal; + } else { + name = Yanfly.Param.SaveTechLocalSave.format(savefileId); + } + return this.localFileDirectoryPath() + name; +}; + +Yanfly.Save.StorageManager_webStorageKey = StorageManager.webStorageKey; +StorageManager.webStorageKey = function(savefileId) { + if (!$dataSystem) return Yanfly.Save.StorageManager_webStorageKey.call(this); + var title = $dataSystem.gameTitle; + this.loadConfig(); + if (savefileId < 0) { + return Yanfly.Param.SaveTechWebConfig.format(title); + } else if (savefileId === 0) { + return Yanfly.Param.SaveTechWebGlobal.format(title); + } else { + return Yanfly.Param.SaveTechWebSave.format(title, savefileId); + } +}; + +StorageManager.loadConfig = function() { + if (this._configLoaded) return; + this._configLoaded = true; + ConfigManager.load(); +}; + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.Save.BattleManager_setBattleTest = BattleManager.setBattleTest; +BattleManager.setBattleTest = function(battleTest) { + Yanfly.Save.BattleManager_setBattleTest.call(this, battleTest); + if (battleTest) StorageManager.loadConfig(); +}; + +//============================================================================= +// Window_Base +//============================================================================= + +Window_Base.prototype.drawSvActor = function(actor, x, y) { + var filename = actor.battlerName(); + var bitmap = ImageManager.loadSvActor(filename); + var pw = bitmap.width / 9; + var ph = bitmap.height / 6; + var sx = 0; + var sy = 0; + this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph); +}; + +Window_Base.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +//============================================================================= +// Window_MenuCommand +//============================================================================= + +Window_MenuCommand.prototype.isSaveEnabled = function() { + if (DataManager.isEventTest()) return false; + return true; +}; + +//============================================================================= +// Window_SavefileList +//============================================================================= + +Window_SavefileList.prototype.itemHeight = function() { + return this.lineHeight(); +}; + +Window_SavefileList.prototype.drawItem = function(index) { + var id = index + 1; + var valid = DataManager.isThisGameFile(id); + var rect = this.itemRect(index); + this.resetTextColor(); + //if (this._mode === 'load') this.changePaintOpacity(valid); + this.changePaintOpacity(valid); + var icon = valid ? Yanfly.Param.SaveIconSaved : Yanfly.Param.SaveIconEmpty; + this.drawIcon(icon, rect.x + 2, rect.y + 2); + this.drawFileId(id, rect.x + Window_Base._iconWidth + 4, rect.y); +}; + +Window_SavefileList.prototype.playOkSound = function() { + Window_Selectable.prototype.playOkSound.call(this); +}; + +//============================================================================= +// Window_SaveAction +//============================================================================= + +function Window_SaveAction() { + this.initialize.apply(this, arguments); +} + +Window_SaveAction.prototype = Object.create(Window_HorzCommand.prototype); +Window_SaveAction.prototype.constructor = Window_SaveAction; + +Window_SaveAction.prototype.initialize = function(x, y, mode) { + this._width = Graphics.boxWidth - x; + this._currentFile = 0; + this._mode = mode; + Window_HorzCommand.prototype.initialize.call(this, x, y); + this.deactivate(); + this.deselect(); +}; + +Window_SaveAction.prototype.windowWidth = function() { + return this._width; +}; + +Window_SaveAction.prototype.maxCols = function() { + return 3; +}; + +Window_SaveAction.prototype.savefileId = function() { + return SceneManager._scene._listWindow.index() + 1; +}; + +Window_SaveAction.prototype.makeCommandList = function() { + var id = this.savefileId(); + var enabled = DataManager.isThisGameFile(id); + var valid = DataManager.loadSavefileInfo(id); + this.addCommand(this.getCommandName('load'), 'load', valid); + this.addCommand(this.getCommandName('save'), 'save', this.isSaveEnabled()); + this.addCommand(this.getCommandName('delete'), 'delete', enabled); +}; + +Window_SaveAction.prototype.getCommandName = function(type) { + if (type === 'load') { + return Yanfly.Param.SaveCmdLoad; + } else if (type === 'save') { + return Yanfly.Param.SaveCmdSave; + } else { + return Yanfly.Param.SaveCmdDelete; + } +}; + +Window_SaveAction.prototype.isSaveEnabled = function() { + if (this._mode !== 'save') return false; + return $gameSystem.isSaveEnabled(); +}; + +Window_SaveAction.prototype.update = function() { + Window_HorzCommand.prototype.update.call(this); + if (this.savefileId() !== this._currentFile) this.updateIndex(); +}; + +Window_SaveAction.prototype.updateIndex = function() { + this._currentFile = this.savefileId(); + this.refresh(); +}; + +Window_SaveAction.prototype.playOkSound = function() { +}; + +Window_SaveAction.prototype.updateHelp = function() { + var text = ''; + if (this.currentSymbol() === 'load') { + text = Yanfly.Param.SaveLoadSelect; + } else if (this.currentSymbol() === 'save') { + text = Yanfly.Param.SaveSaveSelect; + } else if (this.currentSymbol() === 'delete') { + text = Yanfly.Param.SaveDeleteSelect; + } + this._helpWindow.setText(text); +}; + +//============================================================================= +// Window_SaveInfo +//============================================================================= + +function Window_SaveInfo() { + this.initialize.apply(this, arguments); +} + +Window_SaveInfo.prototype = Object.create(Window_Base.prototype); +Window_SaveInfo.prototype.constructor = Window_SaveInfo; + +Window_SaveInfo.prototype.initialize = function(x, y, width, height, mode) { + this._currentFile = 0; + this._waitTime = 0; + this._mode = mode; + Window_Base.prototype.initialize.call(this, x, y, width, height); +}; + +Window_SaveInfo.prototype.resetFontSettings = function() { + Window_Base.prototype.resetFontSettings.call(this); + if (this._drawLevel) this.contents.fontSize = Yanfly.Param.SaveInfoActorLvSz; + if (this._drawData) this.contents.fontSize = Yanfly.Param.SaveInfoDataSz; +}; + +Window_SaveInfo.prototype.savefileId = function() { + return SceneManager._scene._listWindow.index() + 1; +}; + +Window_SaveInfo.prototype.drawDarkRect = function(dx, dy, dw, dh) { + var color = this.gaugeBackColor(); + this.changePaintOpacity(false); + this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color); + this.changePaintOpacity(true); +}; + +Window_SaveInfo.prototype.update = function() { + Window_Base.prototype.update.call(this); + if (this.savefileId() !== this._currentFile) this.updateIndex(); + if (this._waitTime > 0) this.updateTimer(); +}; + +Window_SaveInfo.prototype.systemColorEx = function() { + if (Imported.YEP_CoreEngine) { + return '\\c[' + Yanfly.Param.ColorSystem + ']'; + } else { + return '\\c[16]'; + } +}; + +Window_SaveInfo.prototype.updateIndex = function() { + var id = this.savefileId(); + this._currentFile = id; + this._waitTime = 30; + this.contents.clear(); +}; + +Window_SaveInfo.prototype.updateTimer = function() { + this._waitTime -= 1; + if (this._waitTime > 0) return; + var id = this.savefileId(); + this._valid = DataManager.isThisGameFile(id); + this._info = DataManager.loadSavefileInfo(id); + this.refresh(); +}; + +Window_SaveInfo.prototype.refresh = function() { + this.contents.clear(); + this.resetFontSettings(); + var dy = 0; + dy = this.drawGameTitle(dy); + if (!this._valid) return this.drawInvalidText(dy); + this._saveContents = StorageManager.load(this.savefileId()); + this.drawContents(dy); +}; + +Window_SaveInfo.prototype.drawGameTitle = function(dy) { + if (!Yanfly.Param.SaveInfoTitle) return dy; + if (!this._info) return dy; + if (!this._info.title) return dy; + this.resetFontSettings(); + var text = this._info.title; + this.drawText(text, 0, dy, this.contents.width, 'center'); + return dy + this.lineHeight(); +}; + +Window_SaveInfo.prototype.drawInvalidText = function(dy) { + this.drawDarkRect(0, dy, this.contents.width, this.contents.height - dy); + dy = (this.contents.height - dy - this.lineHeight()) / 2; + if (this._info) { + var text = Yanfly.Param.SaveInfoInvalid; + } else { + var text = Yanfly.Param.SaveInfoEmpty; + } + this.changeTextColor(this.systemColor()); + this.drawText(text, 0, dy, this.contents.width, 'center'); +}; + +Window_SaveInfo.prototype.drawContents = function(dy) { + if (!this._saveContents) { + return setTimeout(this.drawContents.bind(this, dy), 50); + } + this._saveContents = JsonEx.parse(this._saveContents); + dy = this.drawPartyGraphics(dy); + dy = this.drawPartyNames(dy); + dy = this.drawPartyLevels(dy); + this.drawColumnData(dy); +}; + +Window_SaveInfo.prototype.drawPartyGraphics = function(dy) { + if (Yanfly.Param.SaveInfoPartyType === 0) return dy; + dy = eval(Yanfly.Param.SaveInfoPartyY); + var length = this._saveContents.party.maxBattleMembers(); + var dw = this.contents.width / length;; + dw = Math.floor(dw); + var dx = Math.floor(dw / 2); + for (var i = 0; i < length; ++i) { + var actorId = this._saveContents.party._actors[i]; + var member = this._saveContents.actors._data[actorId]; + if (member) { + if (Yanfly.Param.SaveInfoPartyType === 1) { + var name = member.characterName(); + var index = member.characterIndex(); + this.drawCharacter(name, index, dx, dy); + } else if (Yanfly.Param.SaveInfoPartyType === 2) { + var fh = Window_Base._faceHeight; + var fw = Window_Base._faceWidth; + var fx = dx - Math.floor(Math.min(fh, dw) / 2); + var dif = Math.floor(Math.max(0, dw - fw) / 2); + var name = member.faceName(); + var index = member.faceIndex(); + this.drawFace(name, index, fx - dif, dy - fh, dw, fh); + } else if (Yanfly.Param.SaveInfoPartyType === 3) { + this.drawSvActor(member, dx, dy); + } + } + dx += dw; + } + return dy; +}; + +Window_SaveInfo.prototype.drawCharacter = function(name, index, x, y) { + var bitmap = ImageManager.loadCharacter(name); + if (bitmap.width <= 0) { + return setTimeout(this.drawCharacter.bind(this, name, index, x, y), 50); + } + Window_Base.prototype.drawCharacter.call(this, name, index, x, y); +}; + +Window_SaveInfo.prototype.drawFace = function(name, index, x, y, w, h) { + var bitmap = ImageManager.loadFace(name); + if (bitmap.width <= 0) { + return setTimeout(this.drawFace.bind(this, name, index, x, y, w, h), 50); + } + Window_Base.prototype.drawFace.call(this, name, index, x, y, w, h); +}; + +Window_SaveInfo.prototype.drawSvActor = function(actor, x, y) { + var filename = actor.battlerName(); + var bitmap = ImageManager.loadSvActor(filename); + if (bitmap.width <= 0) { + return setTimeout(this.drawSvActor.bind(this, actor, x, y), 50); + } + Window_Base.prototype.drawSvActor.call(this, actor, x, y); +}; + +Window_SaveInfo.prototype.drawPartyNames = function(dy) { + if (!Yanfly.Param.SaveInfoActorName) return dy; + this.resetFontSettings(); + this.contents.fontSize = Yanfly.Param.SaveInfoActorNameSz; + var length = this._saveContents.party.maxBattleMembers(); + var dw = this.contents.width / length;; + dw = Math.floor(dw); + var dx = 0; + for (var i = 0; i < length; ++i) { + var actorId = this._saveContents.party._actors[i]; + var member = this._saveContents.actors._data[actorId]; + if (member) { + var name = member._name; + this.drawText(name, dx, dy, dw, 'center'); + } + dx += dw + } + return dy += this.lineHeight(); +}; + +Window_SaveInfo.prototype.drawPartyLevels = function(dy) { + if (!Yanfly.Param.SaveInfoActorLv) return dy; + this._drawLevel = true; + var length = this._saveContents.party.maxBattleMembers(); + var dw = this.contents.width / length;; + dw = Math.floor(dw); + var dx = 0; + var fmt = Yanfly.Param.SaveInfoActorLvFmt; + for (var i = 0; i < length; ++i) { + var actorId = this._saveContents.party._actors[i]; + var member = this._saveContents.actors._data[actorId]; + if (member) { + var lv = Yanfly.Util.toGroup(member.level); + var text = fmt.format(TextManager.levelA, TextManager.level, lv); + var tw = this.textWidthEx(text); + var dif = Math.floor(Math.max(0, dw - tw) / 2); + this.drawTextEx(text, dx + dif, dy); + } + dx += dw + } + this._drawLevel = false; + return dy += this.lineHeight(); +}; + +Window_SaveInfo.prototype.drawColumnData = function(dy) { + var totalColumns = 0; + var drawnArrays = []; + if (Yanfly.Param.SaveInfoDataCol1.length > 0) { + totalColumns += 1; + drawnArrays.push(Yanfly.Param.SaveInfoDataCol1); + } + if (Yanfly.Param.SaveInfoDataCol2.length > 0) { + totalColumns += 1; + drawnArrays.push(Yanfly.Param.SaveInfoDataCol2); + } + if (Yanfly.Param.SaveInfoDataCol3.length > 0) { + totalColumns += 1; + drawnArrays.push(Yanfly.Param.SaveInfoDataCol3); + } + if (Yanfly.Param.SaveInfoDataCol4.length > 0) { + totalColumns += 1; + drawnArrays.push(Yanfly.Param.SaveInfoDataCol4); + } + if (totalColumns <= 0) return; + var dw = Math.floor(this.contents.width / totalColumns); + var dif = totalColumns > 1 ? this.textPadding() : 0; + for (var i = 0; i < totalColumns; ++i) { + var column = drawnArrays[i]; + var dx = i * dw; + this.drawColumn(column, dx, dy, dw - dif); + } +}; + +Window_SaveInfo.prototype.drawColumn = function(column, dx, dy, dw) { + var length = column.length; + var tp = this.textPadding(); + for (var i = 0; i < length; ++i) { + this.resetFontSettings(); + this.contents.fontSize = Yanfly.Param.SaveInfoDataSz; + var data = column[i]; + if (data.toUpperCase().trim() !== 'EMPTY') { + this.drawDarkRect(dx, dy, dw, this.lineHeight()); + this.drawData(data, dx + tp, dy, dw - tp * 2); + } + dy += this.lineHeight(); + } +}; + +Window_SaveInfo.prototype.drawData = function(data, dx, dy, dw) { + if (data.toUpperCase().trim() === 'NULL') { + return; + } else if (data.toUpperCase().trim() === 'LOCATION') { + this.drawLocation(dx, dy, dw); + } else if (data.toUpperCase().trim() === 'PLAYTIME') { + this.drawPlaytime(dx, dy, dw); + } else if (data.toUpperCase().trim() === 'SAVE COUNT') { + this.drawSaveCount(dx, dy, dw); + } else if (data.toUpperCase().trim() === 'GOLD COUNT') { + this.drawGoldCount(dx, dy, dw); + } else if (data.match(/VARIABLE[ ](\d+)/i)) { + this.drawVariable(parseInt(RegExp.$1), dx, dy, dw); + } else if (data.match(/(.*)[ ]TEXT:(.*)/i)) { + this.drawDataText(String(RegExp.$1), String(RegExp.$2), dx, dy, dw); + } else if (data.match(/TEXT:(.*)/i)) { + this.drawDataText('left', String(RegExp.$1), dx, dy, dw); + } +}; + +Window_SaveInfo.prototype.drawLocation = function(dx, dy, dw) { + var id = this._saveContents.map._mapId; + if (Yanfly.Param.SaveMapDisplayName) { + var text = this._saveContents.map.locationDisplayName || ''; + if (text.length <= 0 && $dataMapInfos[id]) text = $dataMapInfos[id].name; + } else if ($dataMapInfos[id]) { + var text = $dataMapInfos[id].name; + } else { + var text = ''; + } + if (Yanfly.Param.SaveVocabLocation.length > 0) { + this.changeTextColor(this.systemColor()); + this.drawText(Yanfly.Param.SaveVocabLocation, dx, dy, dw, 'left'); + this.changeTextColor(this.normalColor()); + this.drawText(text, dx, dy, dw, 'right'); + } else { + this.drawText(text, dx, dy, dw, 'center'); + } +}; + +Window_SaveInfo.prototype.drawPlaytime = function(dx, dy, dw) { + if (!this._info.playtime) return; + var text = this._info.playtime; + if (Yanfly.Param.SaveVocabPlaytime.length > 0) { + this.changeTextColor(this.systemColor()); + this.drawText(Yanfly.Param.SaveVocabPlaytime, dx, dy, dw, 'left'); + this.changeTextColor(this.normalColor()); + this.drawText(text, dx, dy, dw, 'right'); + } else { + this.drawText(text, dx, dy, dw, 'center'); + } +}; + +Window_SaveInfo.prototype.drawSaveCount = function(dx, dy, dw) { + var text = Yanfly.Util.toGroup(this._saveContents.system._saveCount); + if (Yanfly.Param.SaveVocabSaveCount.length > 0) { + this.changeTextColor(this.systemColor()); + this.drawText(Yanfly.Param.SaveVocabSaveCount, dx, dy, dw, 'left'); + this.changeTextColor(this.normalColor()); + this.drawText(text, dx, dy, dw, 'right'); + } else { + this.drawText(text, dx, dy, dw, 'center'); + } +}; + +Window_SaveInfo.prototype.drawGoldCount = function(dx, dy, dw) { + var text = Yanfly.Util.toGroup(this._saveContents.party._gold); + if (Yanfly.Param.SaveVocabGoldCount.length > 0) { + this.changeTextColor(this.systemColor()); + var fmt = Yanfly.Param.SaveVocabGoldCount; + this.drawText(fmt.format(TextManager.currencyUnit), dx, dy, dw, 'left'); + this.changeTextColor(this.normalColor()); + + this.drawText(text, dx, dy, dw, 'right'); + } else { + var fmt = '\\c[0]%1' + this.systemColorEx() + '%2'; + var ftext = fmt.format(text, TextManager.currencyUnit); + this._drawData = true; + var fw = this.textWidthEx(ftext); + dx += Math.max(0, Math.floor((dw - fw) / 2)); + this.drawTextEx(ftext, dx, dy); + this._drawData = false; + } +}; + +Window_SaveInfo.prototype.drawVariable = function(id, dx, dy, dw) { + var varName = $dataSystem.variables[id]; + varName = varName.replace(/<<(.*?)>>/i, ''); + var text = Yanfly.Util.toGroup(this._saveContents.variables.value(id)); + var diff = Math.max(0, (this.standardFontSize() - + this.contents.fontSize) / 2); + if (varName.length > 0) { + this._drawData = true; + this.changeTextColor(this.systemColor()); + dy += diff; + this.drawTextEx(this.systemColorEx() + varName, dx, dy, dw, 'left'); + dy -= diff; + this.changeTextColor(this.normalColor()); + this._drawData = false; + this.drawText(text, dx, dy, dw, 'right'); + } else { + this.drawText(text, dx, dy, dw, 'center'); + } +}; + +Window_SaveInfo.prototype.drawDataText = function(align, text, dx, dy, dw) { + this._drawData = true; + dy += Math.max(0, (this.standardFontSize() - this.contents.fontSize) / 2); + var align = align.toLowerCase().trim(); + var text = text.trim(); + if (align === 'left') { + this.drawTextEx(text, dx, dy); + } else if (align === 'right') { + var tw = this.textWidthEx(text); + this.drawTextEx(text, dx + dw - tw, dy); + } else { + var tw = this.textWidthEx(text); + this.drawTextEx(text, dx + (dw - tw) / 2, dy); + } + this._drawData = false; +}; + +//============================================================================= +// Window_SaveConfirm +//============================================================================= + +function Window_SaveConfirm() { + this.initialize.apply(this, arguments); +} + +Window_SaveConfirm.prototype = Object.create(Window_Command.prototype); +Window_SaveConfirm.prototype.constructor = Window_SaveConfirm; + +Window_SaveConfirm.prototype.initialize = function() { + Window_Command.prototype.initialize.call(this, 0, 0); + this.openness = 0; +}; + +Window_SaveConfirm.prototype.makeCommandList = function() { + this.addCommand(Yanfly.Param.SaveConfirmYes, 'confirm'); + this.addCommand(Yanfly.Param.SaveConfirmNo, 'cancel'); +}; + +Window_SaveConfirm.prototype.setData = function(text) { + this._text = text; + var ww = this.textWidthEx(this._text) + this.standardPadding() * 2; + ww += this.textPadding() * 2; + this.width = ww; + this.refresh(); + this.x = (Graphics.boxWidth - this.width) / 2; + this.y = (Graphics.boxHeight - this.height) / 2; + this.drawTextEx(this._text, this.textPadding(), 0); +}; + +Window_SaveConfirm.prototype.itemTextAlign = function() { + return 'center'; +}; + +Window_SaveConfirm.prototype.windowHeight = function() { + return this.fittingHeight(3); +}; + +Window_SaveConfirm.prototype.itemRect = function(index) { + var rect = Window_Selectable.prototype.itemRect.call(this, index); + rect.y += this.lineHeight(); + return rect; +}; + +//============================================================================= +// Scene_File +//============================================================================= + +Scene_File.prototype.terminate = function() { + Scene_MenuBase.prototype.terminate.call(this); + if (this._loadSuccess) $gameSystem.onAfterLoad(); +}; + +Scene_Load.prototype.terminate = function() { + Scene_File.prototype.terminate.call(this); +}; + +Scene_File.prototype.create = function() { + Scene_MenuBase.prototype.create.call(this); + DataManager.loadAllSavefileImages(); + this.createHelpWindow(); + this.createListWindow(); + this.createActionWindow(); + this.createInfoWindow(); + this.createConfirmWindow(); +}; + +Scene_File.prototype.createHelpWindow = function() { + this._helpWindow = new Window_Help(2); + this._helpWindow.setText(Yanfly.Param.SaveHelpSelect); + this.addWindow(this._helpWindow); +}; + +Scene_File.prototype.createListWindow = function() { + var x = 0; + var y = this._helpWindow.height; + var width = 240; + var height = Graphics.boxHeight - y; + this._listWindow = new Window_SavefileList(x, y, width, height); + this.addWindow(this._listWindow); + this._listWindow.setHandler('ok', this.onSavefileOk.bind(this)); + this._listWindow.setHandler('cancel', this.popScene.bind(this)); + this._listWindow.select(this.firstSavefileIndex()); + this._listWindow.setTopRow(this.firstSavefileIndex() - 2); + this._listWindow.setMode(this.mode()); + this._listWindow.refresh(); + +}; + +Scene_File.prototype.createActionWindow = function() { + var x = this._listWindow.width; + var y = this._listWindow.y; + this._actionWindow = new Window_SaveAction(x, y, this.mode()); + this.addWindow(this._actionWindow); + this._actionWindow.setHelpWindow(this._helpWindow); + this._actionWindow.setHandler('load', this.onActionLoad.bind(this)); + this._actionWindow.setHandler('save', this.onActionSave.bind(this)); + this._actionWindow.setHandler('delete', this.onActionDelete.bind(this)); + this._actionWindow.setHandler('cancel', this.onActionCancel.bind(this)); +}; + +Scene_File.prototype.createInfoWindow = function() { + var x = this._actionWindow.x; + var y = this._actionWindow.y + this._actionWindow.height; + var width = Graphics.boxWidth - x; + var height = Graphics.boxHeight - y; + this._infoWindow = new Window_SaveInfo(x, y, width, height, this.mode()); + this.addWindow(this._infoWindow); +}; + +Scene_File.prototype.createConfirmWindow = function() { + this._confirmWindow = new Window_SaveConfirm(); + var win = this._confirmWindow; + win.setHandler('confirm', this.onConfirmOk.bind(this)); + win.setHandler('cancel', this.onConfirmCancel.bind(this)); + this.addWindow(this._confirmWindow); +}; + +Scene_File.prototype.onSavefileOk = function() { + this._actionWindow.activate(); + if (this.mode() === 'load') { + this._actionWindow.select(0); + } else if (this.mode() === 'save') { + this._actionWindow.select(1); + } +}; + +Scene_Save.prototype.onSavefileOk = function() { + Scene_File.prototype.onSavefileOk.call(this); +}; + +Scene_Load.prototype.onSavefileOk = function() { + Scene_File.prototype.onSavefileOk.call(this); +}; + +Scene_File.prototype.onActionLoad = function() { + if (Yanfly.Param.SaveConfirmLoad) { + this.startConfirmWindow(Yanfly.Param.SaveConfirmLoadTx); + } else { + this.performActionLoad(); + } +}; + +Scene_File.prototype.performActionLoad = function() { + if (DataManager.loadGame(this.savefileId())) { + this.onLoadSuccess(); + } else { + this.onLoadFailure(); + } +}; + +Scene_File.prototype.onLoadSuccess = function() { + SoundManager.playLoad(); + this.fadeOutAll(); + this.reloadMapIfUpdated(); + SceneManager.goto(Scene_Map); + this._loadSuccess = true; +}; + +Scene_Load.prototype.onLoadSuccess = function() { + Scene_File.prototype.onLoadSuccess.call(this); +}; + +Scene_File.prototype.onLoadFailure = function() { + SoundManager.playBuzzer(); + this.onActionCancel(); +}; + +Scene_Load.prototype.onLoadFailure = function() { + Scene_File.prototype.onLoadFailure.call(this); +}; + +Scene_File.prototype.reloadMapIfUpdated = function() { + if ($gameSystem.versionId() === $dataSystem.versionId) return; + $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y); + $gamePlayer.requestMapReload(); +}; + +Scene_File.prototype.onActionSave = function() { + var id = this.savefileId(); + if (Yanfly.Param.SaveConfirmSave && StorageManager.exists(id)) { + this.startConfirmWindow(Yanfly.Param.SaveConfirmSaveTx); + } else { + this.performActionSave(); + } +}; + +Scene_File.prototype.performActionSave = function() { + $gameSystem.onBeforeSave(); + if (DataManager.saveGame(this.savefileId())) { + this.onSaveSuccess(); + } else { + this.onSaveFailure(); + } +}; + +Scene_File.prototype.onSaveSuccess = function() { + SoundManager.playSave(); + StorageManager.cleanBackup(this.savefileId()); + if (Yanfly.Param.SavePop) { + this.popScene(); + } else { + this._listWindow.refresh(); + this._actionWindow._currentFile = this.savefileId() - 1; + this._infoWindow._currentFile = this.savefileId() - 1; + this.onActionCancel(); + } +}; + +Scene_Save.prototype.onSaveSuccess = function() { + Scene_File.prototype.onSaveSuccess.call(this); +}; + +Scene_File.prototype.onSaveFailure = function() { + SoundManager.playBuzzer(); + this.onActionCancel(); +}; + +Scene_Save.prototype.onSaveFailure = function() { + Scene_File.prototype.onSaveFailure.call(this); +}; + +Scene_File.prototype.onActionDelete = function() { + if (Yanfly.Param.SaveConfirmDel) { + this.startConfirmWindow(Yanfly.Param.SaveConfirmDelTx); + } else { + this.performActionDelete(); + } +}; + +Scene_File.prototype.performActionDelete = function() { + AudioManager.playSe(Yanfly.Param.SaveDeleteSound); + StorageManager.remove(this.savefileId()); + this.onActionCancel(); + this._listWindow.refresh(); + this._actionWindow._currentFile = this.savefileId() - 1; + this._infoWindow._currentFile = this.savefileId() - 1; +}; + +Scene_File.prototype.onActionCancel = function() { + this._actionWindow.deselect(); + this._listWindow.activate(); + this._helpWindow.setText(Yanfly.Param.SaveHelpSelect); +}; + +Scene_File.prototype.startConfirmWindow = function(text) { + SoundManager.playOk(); + this._confirmWindow.setData(text); + this._confirmWindow.open(); + this._confirmWindow.activate(); + this._confirmWindow.select(0); +}; + +Scene_File.prototype.onConfirmOk = function() { + this._confirmWindow.deactivate(); + this._confirmWindow.close(); + if (this._actionWindow.currentSymbol() === 'load') { + setTimeout(this.performActionLoad.bind(this), 200); + } else if (this._actionWindow.currentSymbol() === 'save') { + setTimeout(this.performActionSave.bind(this), 200); + } else if (this._actionWindow.currentSymbol() === 'delete') { + setTimeout(this.performActionDelete.bind(this), 200); + } else { + this.onConfirmCancel(); + } +}; + +Scene_File.prototype.onConfirmCancel = function() { + var index = this._actionWindow.index(); + this._confirmWindow.deactivate(); + this._confirmWindow.close(); + this.onSavefileOk(); + this._actionWindow.select(index); +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_SaveEventLocations.js b/js/plugins/YEP_SaveEventLocations.js new file mode 100644 index 0000000..e5b949e --- /dev/null +++ b/js/plugins/YEP_SaveEventLocations.js @@ -0,0 +1,280 @@ +//============================================================================= +// Yanfly Engine Plugins - Save Event Locations +// YEP_SaveEventLocations.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_SaveEventLocations = true; + +var Yanfly = Yanfly || {}; +Yanfly.SEL = Yanfly.SEL || {}; +Yanfly.SEL.version = 1.06; + +//============================================================================= + /*: + * @plugindesc v1.06 Enable specified maps to memorize the locations of + * events when leaving and loading them upon reentering map. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * Normally in RPG Maker MV, leaving a map and returning to it will reset the + * map positions of all the events. For certain types of maps, such as puzzles, + * you would want the map to retain their locations. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * Map Notetag: + * + * This will cause the map to save every event's location on that map. After + * leaving and returning to that map, the events will be reloaded onto their + * last saved positions in addition to the direction they were facing. + * + * Event Notetag: + * + * This will enable this specific event to save its location on this map. + * After leaving and returning to the map, the event will be reloaded onto + * its last saved position in addition to the direction it was facing. + * + * If you wish to reset the position of the Event, simply use the Event Editor + * and use "Set Event Location" to anchor the event's location to the desired + * point as if you would normally. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * Plugin Command + * ResetAllEventLocations + * - This resets all the event locations on the map. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.06: + * - Fixed an issue where using an event to instantly move an event would not + * save the event's location. + * + * Version 1.05: + * - Fixed a bug where if an event whose location is to be saved starts with a + * direction other than down, the direction would be overwritten when loaded. + * + * Version 1.04: + * - Updated the to save an event's direction even if it + * didn't move. + * + * Version 1.03: + * - Fixed a bug where reset locations would not save properly. + * + * Version 1.02: + * - Fixed a bug where battles would reset saved location notetags. + * + * Version 1.01: + * - Fixed an incompatibility with the Set Event Location event command. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// DataManager +//============================================================================= + +DataManager.processSELNotetags1 = function() { + if (!$dataMap) return; + if (!$dataMap.note) return; + var notedata = $dataMap.note.split(/[\r\n]+/); + $dataMap.saveEventLocations = false; + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SAVE EVENT LOCATION|save event locations)>/i)) { + $dataMap.saveEventLocations = true; + } + } +}; + +DataManager.processSELNotetags2 = function(obj) { + var notedata = obj.note.split(/[\r\n]+/); + obj.saveEventLocation = false; + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SAVE EVENT LOCATION|save event locations)>/i)) { + obj.saveEventLocation = true; + } + } +}; + +//============================================================================= +// Game_System +//============================================================================= + +Yanfly.SEL.Game_System_initialize = Game_System.prototype.initialize; +Game_System.prototype.initialize = function() { + Yanfly.SEL.Game_System_initialize.call(this); + this.initSavedEventLocations(); +}; + +Game_System.prototype.initSavedEventLocations = function() { + this._savedEventLocations = {}; +}; + +Game_System.prototype.savedEventLocations = function() { + if (this._savedEventLocations === undefined) this.initSavedEventLocations(); + return this._savedEventLocations; +}; + +Game_System.prototype.isSavedEventLocation = function(mapId, eventId) { + if (this._savedEventLocations === undefined) this.initSavedEventLocations(); + return this._savedEventLocations[[mapId, eventId]] !== undefined; +}; + +Game_System.prototype.getSavedEventX = function(mapId, eventId) { + if (this._savedEventLocations === undefined) this.initSavedEventLocations(); + return this._savedEventLocations[[mapId, eventId]][0]; +}; + +Game_System.prototype.getSavedEventY = function(mapId, eventId) { + if (this._savedEventLocations === undefined) this.initSavedEventLocations(); + return this._savedEventLocations[[mapId, eventId]][1]; +}; + +Game_System.prototype.getSavedEventDir = function(mapId, eventId) { + if (this._savedEventLocations === undefined) this.initSavedEventLocations(); + return this._savedEventLocations[[mapId, eventId]][2]; +}; + +Game_System.prototype.saveEventLocation = function(mapId, event) { + if (this._savedEventLocations === undefined) this.initSavedEventLocations(); + var eventId = event.eventId(); + var eventX = event.x; + var eventY = event.y; + var eventDir = event.direction(); + this._savedEventLocations[[mapId, eventId]] = [eventX, eventY, eventDir]; +}; + +//============================================================================= +// Game_Map +//============================================================================= + +Yanfly.SEL.Game_Map_setup = Game_Map.prototype.setup; +Game_Map.prototype.setup = function(mapId) { + if ($dataMap) DataManager.processSELNotetags1(); + Yanfly.SEL.Game_Map_setup.call(this, mapId); +}; + +Game_Map.prototype.isSaveEventLocations = function() { + return $dataMap.saveEventLocations; +}; + +Game_Map.prototype.resetAllEventLocations = function() { + for (var i = 0; i < this.events().length; ++i) { + var ev = this.events()[i]; + ev.resetLocation(); + } +}; + +//============================================================================= +// Game_CharacterBase +//============================================================================= + +Yanfly.SEL.Game_CharacterBase_setDirection = + Game_CharacterBase.prototype.setDirection; +Game_CharacterBase.prototype.setDirection = function(d) { + Yanfly.SEL.Game_CharacterBase_setDirection.call(this, d); + this.saveLocation(); +}; + +Game_CharacterBase.prototype.saveLocation = function() { +}; + +//============================================================================= +// Game_Event +//============================================================================= + +Yanfly.SEL.Game_Event_locate = Game_Event.prototype.locate; +Game_Event.prototype.locate = function(x, y) { + DataManager.processSELNotetags2(this.event()); + Yanfly.SEL.Game_Event_locate.call(this, x, y); + if (!$gameTemp._bypassLoadLocation) this.loadLocation(); + this.saveLocation(); +}; + +Yanfly.SEL.Game_Event_updateMove = Game_Event.prototype.updateMove; +Game_Event.prototype.updateMove = function() { + Yanfly.SEL.Game_Event_updateMove.call(this); + this.saveLocation(); +}; + +Game_Event.prototype.isSaveLocation = function() { + if ($gameMap.isSaveEventLocations()) return true; + if (this.event().saveEventLocation === undefined) { + DataManager.processSELNotetags2(this.event()); + } + return this.event().saveEventLocation; +}; + +Game_Event.prototype.saveLocation = function() { + if (!this.isSaveLocation()) return; + $gameSystem.saveEventLocation($gameMap.mapId(), this); +}; + +Game_Event.prototype.isLoadLocation = function() { + if (!this.isSaveLocation()) return false; + return $gameSystem.isSavedEventLocation($gameMap.mapId(), this.eventId()); +}; + +Game_Event.prototype.loadLocation = function() { + if (!this.isLoadLocation()) return; + var x = $gameSystem.getSavedEventX($gameMap.mapId(), this.eventId()); + var y = $gameSystem.getSavedEventY($gameMap.mapId(), this.eventId()); + this.setPosition(x, y); + var dir = $gameSystem.getSavedEventDir($gameMap.mapId(), this.eventId()); + $gameTemp._loadLocationDirection = dir; +}; + +Yanfly.SEL.Game_Event_setupPageSettings = + Game_Event.prototype.setupPageSettings; +Game_Event.prototype.setupPageSettings = function() { + Yanfly.SEL.Game_Event_setupPageSettings.call(this); + if ($gameTemp._loadLocationDirection) { + this.setDirection($gameTemp._loadLocationDirection); + $gameTemp._loadLocationDirection = undefined; + } +}; + +Game_Event.prototype.resetLocation = function() { + Yanfly.SEL.Game_Event_locate.call(this, this.event().x, this.event().y); + this.setDirection(this._originalDirection); + this.saveLocation(); +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.SEL.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.SEL.Game_Interpreter_pluginCommand.call(this, command, args) + if (command === 'ResetAllEventLocations') $gameMap.resetAllEventLocations(); +}; + +// Set Event Location +Yanfly.SEL.Game_Interpreter_command203 = Game_Interpreter.prototype.command203; +Game_Interpreter.prototype.command203 = function() { + $gameTemp._bypassLoadLocation = true; + var result = Yanfly.SEL.Game_Interpreter_command203.call(this); + $gameTemp._bypassLoadLocation = undefined; + return result; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_ScriptCallPluginCmd.js b/js/plugins/YEP_ScriptCallPluginCmd.js new file mode 100644 index 0000000..1886f6c --- /dev/null +++ b/js/plugins/YEP_ScriptCallPluginCmd.js @@ -0,0 +1,85 @@ +//============================================================================= +// Yanfly Engine Plugins - Script Call Plugin Command +// YEP_ScriptCallPluginCmd.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_ScriptCallPluginCmd = true; + +var Yanfly = Yanfly || {}; +Yanfly.CsTxCo = Yanfly.CsTxCo || {}; +Yanfly.CsTxCo.version = 1.00; + +//============================================================================= + /*: + * @plugindesc v1.00 (Req YEP_MessageCore.js) Allows you to create your own + * custom text codes and determine what they do. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * Have you ever came across the odd situation where you wanted to use a + * Plugin Command during a script call or Lunatic Mode code? This plugin will + * help facilitate the process in doing so by creating a new function for you + * to use in JavaScript that will transcribe the Plugin Command string and run + * it during a script call. + * + * ============================================================================ + * Script Call + * ============================================================================ + * + * The script call to run plugin commands from script call is as follows: + * + * CallPluginCommand('str'); + * - Replace 'str' with the Plugin Command you wish to run as a string. + * + * Example: + * + * var line = 'GainGold 1234567890'; + * CallPluginCommand(line); + * + * This will run the plugin command 'GainGold' from YEP_CoreEngine and give the + * player 1,234,567,890 gold. + * + * ------- + * WARNING + * ------- + * + * Not all plugin commands are compatible with script calls. What do I mean by + * this? Well, certain plugin commands (for example, adjusting wait times) + * will not necessarily work together with this method. This is due to the way + * JavaScript works itself as all code inside a function and called functions + * are instantaneous. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.00: + * - Finished Plugin! + * + * ============================================================================ + * End of Helpfile + * ============================================================================ + * + */ +//============================================================================= + +//============================================================================= +// New Function +//============================================================================= + +CallPluginCommand = function(line) { + var args = line.split(" "); + var command = args.shift(); + var interpreter = new Game_Interpreter(); + interpreter._params = [line]; + interpreter.pluginCommand(command, args); +}; + +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_SkillCore.js b/js/plugins/YEP_SkillCore.js new file mode 100644 index 0000000..199ecab --- /dev/null +++ b/js/plugins/YEP_SkillCore.js @@ -0,0 +1,1370 @@ +//============================================================================= +// Yanfly Engine Plugins - Skill Core +// YEP_SkillCore.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_SkillCore = true; + +var Yanfly = Yanfly || {}; +Yanfly.Skill = Yanfly.Skill || {}; +Yanfly.Skill.version = 1.13; + +//============================================================================= +/*: + * @plugindesc v1.13 Skills are now given more functions and the ability + * to require different types of costs. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Cost Padding + * @parent ---General--- + * @type number + * @min 0 + * @desc If a skill has multiple costs, this is the amount of pixels + * used as padding in between the costs. + * @default 4 + * + * @param Command Alignment + * @parent ---General--- + * @type combo + * @option left + * @option center + * @option right + * @desc Adjusts the text alignment of the skill type window. + * left center right + * @default center + * + * @param Window Columns + * @parent ---General--- + * @type number + * @min 1 + * @desc Choose how many columns to use for the skill window. + * Default: 2 + * @default 2 + * + * @param ---HP Costs--- + * @default + * + * @param HP Format + * @parent ---HP Costs--- + * @desc Adjusts the way HP cost appears in the skill list window. + * %1 - Cost %2 - HP + * @default %1%2 + * + * @param HP Font Size + * @parent ---HP Costs--- + * @type number + * @min 1 + * @desc Adjusts the font size used to display HP. + * Default: 28 + * @default 20 + * + * @param HP Text Color + * @parent ---HP Costs--- + * @type number + * @min 0 + * @max 31 + * @desc Adjusts the text color used from the Window skin for HP. + * Default: 21 + * @default 18 + * + * @param HP Icon + * @parent ---HP Costs--- + * @type number + * @min 0 + * @desc Choose what icon to use to represent HP costs. + * Use 0 if you wish to not use an icon. + * @default 162 + * + * @param ---MP Costs--- + * @default + * + * @param MP Format + * @parent ---MP Costs--- + * @desc Adjusts the way MP cost appears in the skill list window. + * %1 - Cost %2 - MP + * @default %1%2 + * + * @param MP Font Size + * @parent ---MP Costs--- + * @type number + * @min 1 + * @desc Adjusts the font size used to display MP. + * Default: 28 + * @default 20 + * + * @param MP Text Color + * @parent ---MP Costs--- + * @type number + * @min 0 + * @max 31 + * @desc Adjusts the text color used from the Window skin for MP. + * Default: 23 + * @default 23 + * + * @param MP Icon + * @parent ---MP Costs--- + * @type number + * @min 0 + * @desc Choose what icon to use to represent MP costs. + * Use 0 if you wish to not use an icon. + * @default 165 + * + * @param ---TP Costs--- + * @default + * + * @param TP Format + * @parent ---TP Costs--- + * @desc Adjusts the way TP cost appears in the skill list window. + * %1 - Cost %2 - TP + * @default %1%2 + * + * @param TP Font Size + * @parent ---TP Costs--- + * @type number + * @min 1 + * @desc Adjusts the font size used to display TP. + * Default: 28 + * @default 20 + * + * @param TP Text Color + * @parent ---TP Costs--- + * @type number + * @min 0 + * @max 31 + * @desc Adjusts the text color used from the Window skin for TP. + * Default: 29 + * @default 29 + * + * @param TP Icon + * @parent ---TP Costs--- + * @type number + * @min 0 + * @desc Choose what icon to use to represent TP costs. + * Use 0 if you wish to not use an icon. + * @default 164 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * Skills in RPG's consist of three main components: Costs, Damage, and + * Effects. Although not all components are required for a skill, they + * certainly make up a good chunk of it. Damage will be handled by another + * plugin, but this plugin will provide a core handling for skill costs and + * skill effects. + * + * This plugin also includes the ability for battlers to swap their HP, MP, + * and/or TP gauges for something different if it would fit the character + * better (for example, some classes don't use MP and/or TP). + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * These notetags can adjust either skill costs or special skill effects. + * + * Skill Notetags: + * + * Changes the skill to have x as its HP cost. RPG Maker MV's editor lacks + * HP cost functions so this would allow skills to use HP as their cost. + * + * + * Changes the skill to cost a percentage of the character's MaxHP value. + * + * + * Changes the skill to have x as its MP cost. + * This helps bypass the database's hard limit of 9999. + * + * + * Changes the skill to cost a percentage of the character's MaxMP value. + * + * + * Changes the skill to have x as its TP cost. + * This helps bypass the database's hard limit of 99. + * + * + * Changes the skill to cost a percentage of the character's MaxTP value. + * Although the default MaxTP is 100, this tag will be useful for any + * plugins that will alter a character's MaxTP values. + * + * + * This will hide and disable the skill during battle. + * + * + * This will hide and disable the skill outside of battle. + * + * + * + * + * Will hide and disable this skill if skill x has been learned. If multiple + * skills are listed, the skill will be hidden and disabled if any one of the + * listed skills have been learned. This will ONLY apply to skills that have + * been learned and not skills added through traits. + * + * ============================================================================ + * Gauge Swapping + * ============================================================================ + * + * This plugin also lets you swap around the HP, MP, and TP Gauges to any order + * you want assuming that all the plugins you use will keep the same order of + * HP, MP, and TP and does not override the default gauge drawing process. If + * you use any plugin extensions, they can be swaped in as well. + * + * Note: If you do not have 'Display TP in Battle' checked under the System tab + * in the database, nothing will be shown for the third slot. + * + * Class Notetag: + * + * This will change gauge x (1, 2, or 3) to y. Replace y with 'HP', 'MP', or + * 'TP' to have it display that gauge type in that gauge slot. If you wish + * for that slot to display nothing, insert 'Nothing' or 'Null' in place of + * y in the notetag. + * + * Weapon, Armor, and State Notetags: + * + * Actors with equipment or states that contain these notetags or enemies + * with states that contain these notetags will display those swapped gauges + * in place of the default settings or settings defined by the Class or + * Enemy notetags. + * + * Priority will go in the following order: + * Weapons, Armors, States, Class, Enemy + * + * ============================================================================ + * Lunatic Mode - Skill Costs + * ============================================================================ + * + * For users who want more control over skill costs and skill effects, there + * exists notetags that allow you to apply code to the costs and/or effects of + * a skill. For effects, this will also extend towards item control, as well. + * + * Example: + * code cost += $gameVariables.value(1); + * code + * + * This allows the skill to have a custom HP cost based off of code. For the + * piece of code, 'cost' is a variable already predefined with the HP Cost + * and the HP percentage cost. + * + * Example: + * code cost += $gameVariables.value(1); + * code + * + * This allows the skill to have a custom MP cost based off of code. For the + * piece of code, 'cost' is a variable already predefined with the MP Cost + * and the MP percentage cost. + * + * Example: + * code cost += $gameVariables.value(1); + * code + * + * This allows the skill to have a custom TP cost based off of code. For the + * piece of code, 'cost' is a variable already predefined with the TP Cost + * and the TP percentage cost. + * + * ============================================================================ + * Lunatic Mode - Custom Show Requirements + * ============================================================================ + * + * For those who would like to show certain skills and disable them under any + * custom conditions using their JavaScript knowledge, use the following: + * + * Skill Notetag: + * + * if (user.level > 50) { + * visible = true; + * } else { + * visible = false; + * } + * + * If the visible is set to true, the skill is shown (not hidden) and enabled + * if all other conditions are met. If visible is set to false, the skill is + * disabled and hidden from the list. + * + * ============================================================================ + * Lunatic Mode - Custom Requirements and Execution + * ============================================================================ + * + * For those with a bit of JavaScript experience, you can use the following + * notetags to restrict a skill and what kind of code to process when executing + * the said skill. + * + * Skill Notetags: + * + * + * if ($gameParty.gold() > 1000) { + * value = true; + * } else { + * value = false; + * } + * + * If value is set to true, the skill will be useable provided that all other + * requirements have been met. If the value is set to false, the skill won't + * be useable. + * + * + * $gameParty.loseGold(1000); + * + * This runs the code between the notetags upon using the skill. + * + * ============================================================================ + * Lunatic Mode - Custom Cost Display + * ============================================================================ + * + * For those with a bit of JavaScript experience, you can add new ways to + * display the skill cost. + * + * Skill Notetags: + * + * + * var variableId = 1; + * var value = 1000; + * $gameVariables.setValue(variableId, value); + * + * This notetag runs an eval before displaying the skill's cost. This is so + * you can set up variables and whatnot for your skill cost display text. + * + * + * \c[4]\v[1]\c[0] Gold + * + * This is the custom text displayed before the rest of the skill costs. You + * can use text codes with this notetag. + * + * ============================================================================ + * Lunatic Mode - The Skill Phases + * ============================================================================ + * + * For this skill, multiple effects are applied and at different phases. The + * various phases are as follows: + * + * Before Effect Phase (influenced by this plugin) + * if skill successfully lands: + * - Pre-Damage Effect Phase (influenced by this plugin) + * - Damage Phase + * - Post-Damage Effect Phase (influenced by this plugin) + * - Item Trait Effects Phase + * After Effect Phase (influenced by this plugin) + * + * There's four phases which can be influenced by this plugin. Two of which do + * not matter if the effect successfully lands or not, two of which do matter + * if the skill does land. + * + * Skill and Item Notetags: + * + * code + * code + * + * + * + * code + * code + * + * + * + * code + * code + * + * + * + * code + * code + * + * If you wish to use custom effects for your skill, you can insert the + * respective notetags into the skill (or item) noteboxes and it will run the + * code that appears in between the tags. However, using any form of comments + * in this tag will block out code that follows. + * + * Those using the and are able to make + * use of the damage to be dealt and the damage that has been dealt through + * the 'value' variable. The notetag is capable of altering + * the 'value' variable and return it to have damage affected by its code. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.13: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.12: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.11a: + * - Lunatic Mode fail safes added. + * - Documentation fix for the help file. Lunatic Mode tags didn't end right. + * The help file is now updated to show the correct notetags. + * + * Version 1.10b: + * - Fixed a visual bug when using text code font changing for custom skill + * cost display. + * - documentation updated. + * - Compatibility update for future plugins. + * + * Version 1.09: + * - The notetag now has the ability alter damage dealt. The + * 'value' variable refers to and returns the damage affected by the action. + * + * Version 1.08: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.07: + * - Fixed a bug that prevented immortal actors at 0 HP from using skills. + * + * Version 1.06a: + * - Added and notetags. + * - Added a failsafe to check for undefined skills. + * + * Version 1.05: + * - Added notetags. + * - Added Lunatic Mode notetag. + * + * Version 1.04: + * - Added four Lunatic Modes notetags: Custom Requirement, Custom Execution, + * Cost Display Eval, Custom Cost Display. + * + * Version 1.03: + * - Fixed a bug with the Lunatic Mode notetags not working. + * + * Version 1.02: + * - Added 'Window Columns' parameter to let users adjust the number of columns + * used for the skill window. + * + * Version 1.01: + * - Fixed a mathematical error for skill cost padding. + * - Added return for drawSkillCost to assist others scripters when making + * compatibility notes. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_SkillCore'); +Yanfly.Param = Yanfly.Param || {}; +Yanfly.Icon = Yanfly.Icon || {}; + +Yanfly.Param.SCCCostPadding = Number(Yanfly.Parameters['Cost Padding']); +Yanfly.Param.SCCTextAlign = String(Yanfly.Parameters['Command Alignment']); +Yanfly.Param.SCCWindowCol = Number(Yanfly.Parameters['Window Columns']); +Yanfly.Param.SCCTpFormat = String(Yanfly.Parameters['TP Format']); +Yanfly.Param.SCCTpFontSize = Number(Yanfly.Parameters['TP Font Size']); +Yanfly.Param.SCCTpTextColor = Number(Yanfly.Parameters['TP Text Color']); +Yanfly.Icon.Tp = Number(Yanfly.Parameters['TP Icon']); +Yanfly.Param.SCCMpFormat = String(Yanfly.Parameters['MP Format']); +Yanfly.Param.SCCMpFontSize = Number(Yanfly.Parameters['MP Font Size']); +Yanfly.Param.SCCMpTextColor = Number(Yanfly.Parameters['MP Text Color']); +Yanfly.Icon.Mp = Number(Yanfly.Parameters['MP Icon']); +Yanfly.Param.SCCHpFormat = String(Yanfly.Parameters['HP Format']); +Yanfly.Param.SCCHpFontSize = Number(Yanfly.Parameters['HP Font Size']); +Yanfly.Param.SCCHpTextColor = Number(Yanfly.Parameters['HP Text Color']); +Yanfly.Icon.Hp = Number(Yanfly.Parameters['HP Icon']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.Skill.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.Skill.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_SkillCore) { + this.processSkillNotetags($dataSkills); + this.processObjectNotetags($dataSkills); + this.processObjectNotetags($dataItems); + this.processGSCNotetags1($dataClasses); + this.processGSCNotetags1($dataEnemies); + this.processGSCNotetags2($dataWeapons); + this.processGSCNotetags2($dataArmors); + this.processGSCNotetags2($dataStates); + Yanfly._loaded_YEP_SkillCore = true; + } + return true; +}; + +DataManager.processSkillNotetags = function(group) { + var note1 = /<(?:MP COST):[ ](\d+)>/i; + var note2 = /<(?:MP COST):[ ](\d+)([%%])>/i; + var note3 = /<(?:TP COST):[ ](\d+)>/i; + var note4 = /<(?:TP COST):[ ](\d+)([%%])>/i; + var note5 = /<(?:HP COST):[ ](\d+)>/i; + var note6 = /<(?:HP COST):[ ](\d+)([%%])>/i; + var note7a = /<(?:HIDE IF LEARNED SKILL):[ ]*(\d+(?:\s*,\s*\d+)*)>/i; + var note7b = /<(?:HIDE IF LEARNED SKILL):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i; + var note8a = /<(?:HIDE IN BATTLE|hide during battle)>/i; + var note8b = /<(?:HIDE IN FIELD|hide during field)>/i; + var noteMpEval1 = /<(?:MP COST EVAL|custom mp cost)>/i; + var noteMpEval2 = /<\/(?:MP COST EVAL|custom mp cost)>/i; + var noteTpEval1 = /<(?:TP COST EVAL|custom tp cost)>/i; + var noteTpEval2 = /<\/(?:TP COST EVAL|custom tp cost)>/i; + var noteHpEval1 = /<(?:HP COST EVAL|custom hp cost)>/i; + var noteHpEval2 = /<\/(?:HP COST EVAL|custom hp cost)>/i; + var noteEvalReq1 = /<(?:EVAL REQUIREMENT|custom requirement)>/i; + var noteEvalReq2 = /<\/(?:EVAL REQUIREMENT|custom requirement)>/i; + var noteEvalExe1 = /<(?:EVAL EXECUTION|custom execution)>/i; + var noteEvalExe2 = /<\/(?:EVAL EXECUTION|custom execution)>/i; + var noteCostEval1 = /<(?:COST DISPLAY EVAL|display cost eval)>/i; + var noteCostEval2 = /<\/(?:COST DISPLAY EVAL|display cost eval)>/i; + var noteCostText1 = /<(?:CUSTOM COST DISPLAY|custom display cost)>/i; + var noteCostText2 = /<\/(?:CUSTOM COST DISPLAY|custom display cost)>/i; + var noteShowEval1 = /<(?:CUSTOM SHOW EVAL)>/i; + var noteShowEval2 = /<\/(?:CUSTOM SHOW EVAL)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.hpCost = 0; + obj.hpCostPer = 0.0; + obj.mpCostPer = 0.0; + obj.tpCostPer = 0.0; + obj.hideInBattle = false; + obj.hideInField = false; + obj.hideIfLearnedSkill = []; + var evalMode = 'none'; + obj.hpCostEval = ''; + obj.mpCostEval = ''; + obj.tpCostEval = ''; + obj.requireEval = ''; + obj.executeEval = ''; + obj.costdisplayEval = ''; + obj.costShowEval = ''; + obj.customCostText = ''; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + obj.mpCost = parseInt(RegExp.$1); + } else if (line.match(note2)) { + obj.mpCostPer = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(note3)) { + obj.tpCost = parseInt(RegExp.$1); + } else if (line.match(note4)) { + obj.tpCostPer = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(note5)) { + obj.hpCost = parseInt(RegExp.$1); + } else if (line.match(note6)) { + obj.hpCostPer = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(note7a)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + obj.hideIfLearnedSkill = obj.hideIfLearnedSkill.concat(array); + } else if (line.match(note7b)) { + var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + var range = Yanfly.Util.getRange(parseInt(RegExp.$1), + parseInt(RegExp.$2)); + obj.hideIfLearnedSkill = obj.hideIfLearnedSkill.concat(range); + } else if (line.match(note8a)) { + obj.hideInBattle = true; + } else if (line.match(note8b)) { + obj.hideInField = true; + } else if (line.match(noteMpEval1)) { + evalMode = 'mp'; + } else if (line.match(noteMpEval2)) { + evalMode = 'none'; + } else if (line.match(noteTpEval1)) { + evalMode = 'tp'; + } else if (line.match(noteTpEval2)) { + evalMode = 'none'; + } else if (line.match(noteHpEval1)) { + evalMode = 'hp'; + } else if (line.match(noteHpEval2)) { + evalMode = 'none'; + } else if (line.match(noteEvalReq1)) { + evalMode = 'custom requirement'; + } else if (line.match(noteEvalReq2)) { + evalMode = 'none'; + } else if (line.match(noteEvalExe1)) { + evalMode = 'custom execute'; + } else if (line.match(noteEvalExe2)) { + evalMode = 'none'; + } else if (line.match(noteCostEval1)) { + evalMode = 'display cost eval'; + } else if (line.match(noteCostEval2)) { + evalMode = 'none'; + } else if (line.match(noteCostText1)) { + evalMode = 'custom display cost'; + } else if (line.match(noteCostText2)) { + evalMode = 'none'; + } else if (line.match(noteShowEval1)) { + evalMode = 'custom show eval'; + } else if (line.match(noteShowEval2)) { + evalMode = 'none'; + } else if (evalMode === 'mp') { + obj.mpCostEval = obj.mpCostEval + line + '\n'; + } else if (evalMode === 'tp') { + obj.tpCostEval = obj.tpCostEval + line + '\n'; + } else if (evalMode === 'hp') { + obj.hpCostEval = obj.hpCostEval + line + '\n'; + } else if (evalMode === 'custom requirement') { + obj.requireEval = obj.requireEval + line + '\n'; + } else if (evalMode === 'custom execute') { + obj.executeEval = obj.executeEval + line + '\n'; + } else if (evalMode === 'display cost eval') { + obj.costdisplayEval = obj.costdisplayEval + line + '\n'; + } else if (evalMode === 'custom display cost') { + obj.customCostText = obj.customCostText + line; + } else if (evalMode === 'custom show eval') { + obj.costShowEval = obj.costShowEval + line + '\n'; + } + } + } +}; + +DataManager.processObjectNotetags = function(group) { + var note1 = /<(?:BEFORE EVAL)>/i; + var note2 = /<\/(?:BEFORE EVAL)>/i; + var note3 = /<(?:PRE-DAMAGE EVAL)>/i; + var note4 = /<\/(?:PRE-DAMAGE EVAL)>/i; + var note5 = /<(?:POST-DAMAGE EVAL)>/i; + var note6 = /<\/(?:POST-DAMAGE EVAL)>/i; + var note7 = /<(?:AFTER EVAL)>/i; + var note8 = /<\/(?:AFTER EVAL)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + var customMode = 'none'; + obj.customBeforeEval = ''; + obj.customPreDamageEval = ''; + obj.customPostDamageEval = ''; + obj.customAfterEval = ''; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(note1)) { + customMode = 'before'; + } else if (line.match(note2)) { + customMode = 'none'; + } else if (line.match(note3)) { + customMode = 'pre-damage'; + } else if (line.match(note4)) { + customMode = 'none'; + } else if (line.match(note5)) { + customMode = 'post-damage'; + } else if (line.match(note6)) { + customMode = 'none'; + } else if (line.match(note7)) { + customMode = 'after'; + } else if (line.match(note8)) { + customMode = 'none'; + } else if (customMode === 'before') { + obj.customBeforeEval = obj.customBeforeEval + line + '\n'; + } else if (customMode === 'pre-damage') { + obj.customPreDamageEval = obj.customPreDamageEval + line + '\n'; + } else if (customMode === 'post-damage') { + obj.customPostDamageEval = obj.customPostDamageEval + line + '\n'; + } else if (customMode === 'after') { + obj.customAfterEval = obj.customAfterEval + line + '\n'; + } + } + } +}; + +DataManager.processGSCNotetags1 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.gauge1 = 'HP'; + obj.gauge2 = 'MP'; + obj.gauge3 = 'TP'; + + obj.gaugeIcon1 = 0; + obj.gaugeIcon2 = 0; + obj.gaugeIcon3 = 0; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SWAP GAUGE|gauge)[ ](\d+):[ ](.*)>/i)) { + var gauge = parseInt(RegExp.$1); + var text = String(RegExp.$2).toUpperCase(); + if (['HP', 'MP', 'TP', 'NOTHING', 'NULL'].contains(text)) { + if (gauge === 1) obj.gauge1 = text; + if (gauge === 2) obj.gauge2 = text; + if (gauge === 3) obj.gauge3 = text; + } + } + } + } +}; + +DataManager.processGSCNotetags2 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.gauge1 = 'UNDEFINED'; + obj.gauge2 = 'UNDEFINED'; + obj.gauge3 = 'UNDEFINED'; + + obj.gaugeIcon1 = 'UNDEFINED'; + obj.gaugeIcon2 = 'UNDEFINED'; + obj.gaugeIcon3 = 'UNDEFINED'; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SWAP GAUGE|gauge)[ ](\d+):[ ](.*)>/i)) { + var gauge = parseInt(RegExp.$1); + var text = String(RegExp.$2).toUpperCase(); + if (['HP', 'MP', 'TP', 'NOTHING', 'NULL'].contains(text)) { + if (gauge === 1) obj.gauge1 = text; + if (gauge === 2) obj.gauge2 = text; + if (gauge === 3) obj.gauge3 = text; + } + } + } + } +}; + +//============================================================================= +// Game_BattlerBase +//============================================================================= + +Yanfly.Skill.Game_BattlerBase_mSC = + Game_BattlerBase.prototype.meetsSkillConditions; +Game_BattlerBase.prototype.meetsSkillConditions = function(skill) { + if (!Yanfly.Skill.Game_BattlerBase_mSC.call(this, skill)) return false; + if (!skill) return false; + if (!this.noHiddenSkillConditionsMet(skill)) return false; + return this.meetsSkillConditionsEval(skill); +}; + +Game_BattlerBase.prototype.noHiddenSkillConditionsMet = function(skill) { + if (!skill) return false; + if (this.isEnemy()) return true; + if (skill.hideIfLearnedSkill) { + for (var i = 0; i < skill.hideIfLearnedSkill.length; ++i) { + var skillId = skill.hideIfLearnedSkill[i]; + if (this.isLearnedSkill(skillId)) return false; + } + } + if (skill.hideInBattle && $gameParty.inBattle()) return false; + if (skill.hideInField && !$gameParty.inBattle()) return false; + if (!this.meetsCustomShowEval(skill)) return false; + return true; +}; + +Game_BattlerBase.prototype.meetsCustomShowEval = function(skill) { + if (skill.costShowEval === '') return true; + var visible = true; + var item = skill; + var a = this; + var user = this; + var subject = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = skill.costShowEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL CUSTOM SHOW EVAL ERROR'); + } + return visible; +}; + +Game_BattlerBase.prototype.meetsSkillConditionsEval = function(skill) { + if (skill.requireEval === '') return true; + var value = true; + var item = skill; + var a = this; + var user = this; + var subject = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = skill.requireEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL CUSTOM REQUIRE EVAL ERROR'); + } + return value; +}; + +Game_BattlerBase.prototype.skillHpCost = function(skill) { + var cost = skill.hpCost; + var item = skill; + var a = this; + var user = this; + var subject = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + cost += this.mhp * skill.hpCostPer; + var code = skill.hpCostEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL CUSTOM HP COST ERROR'); + } + return Math.max(0, Math.floor(cost)); +}; + +Game_BattlerBase.prototype.skillMpCost = function(skill) { + var cost = skill.mpCost; + var item = skill; + var a = this; + var user = this; + var subject = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + cost += this.mmp * skill.mpCostPer; + var code = skill.mpCostEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL CUSTOM MP COST ERROR'); + } + return Math.max(0, Math.floor(cost * this.mcr)); +}; + +Game_BattlerBase.prototype.skillTpCost = function(skill) { + var cost = skill.tpCost; + var item = skill; + var a = this; + var user = this; + var subject = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + cost += this.maxTp() * skill.tpCostPer; + var code = skill.tpCostEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL CUSTOM TP COST ERROR'); + } + return Math.max(0, Math.floor(cost)); +}; + +Yanfly.Skill.Game_BattlerBase_canPaySkillCost = + Game_BattlerBase.prototype.canPaySkillCost; +Game_BattlerBase.prototype.canPaySkillCost = function(skill) { + if (!this.canPaySkillHpCost(skill)) return false; + return Yanfly.Skill.Game_BattlerBase_canPaySkillCost.call(this, skill); +}; + +Game_BattlerBase.prototype.canPaySkillHpCost = function(skill) { + var cost = this.skillHpCost(skill); + if (cost <= 0) return true; + return this._hp > cost; +}; + +Yanfly.Skill.Game_BattlerBase_paySkillCost = + Game_BattlerBase.prototype.paySkillCost +Game_BattlerBase.prototype.paySkillCost = function(skill) { + Yanfly.Skill.Game_BattlerBase_paySkillCost.call(this, skill); + this.paySkillHpCost(skill); + this.paySkillEvalCost(skill); +}; + +Game_BattlerBase.prototype.paySkillHpCost = function(skill) { + this._hp -= this.skillHpCost(skill); +}; + +Game_BattlerBase.prototype.paySkillEvalCost = function(skill) { + if (skill.executeEval === '') return; + var item = skill; + var a = this; + var user = this; + var subject = this; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = skill.executeEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL PAY COST EVAL ERROR'); + } +}; + +Game_BattlerBase.prototype.gauge1 = function() { + return 'HP'; +}; + +Game_BattlerBase.prototype.gauge2 = function() { + return 'MP'; +}; + +Game_BattlerBase.prototype.gauge3 = function() { + return 'TP'; +}; + +Game_BattlerBase.prototype.gaugeIcon1 = function() { + return 0; +}; + +Game_BattlerBase.prototype.gaugeIcon2 = function() { + return 0; +}; + +Game_BattlerBase.prototype.gaugeIcon3 = function() { + return 0; +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.gauge1 = function() { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.gauge1 === 'UNDEFINED') continue; + return equip.gauge1; + } + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gauge1 === 'UNDEFINED') continue; + return state.gauge1; + } + return this.currentClass().gauge1; +}; + +Game_Actor.prototype.gauge2 = function() { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.gauge2 === 'UNDEFINED') continue; + return equip.gauge2; + } + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gauge2 === 'UNDEFINED') continue; + return state.gauge2; + } + return this.currentClass().gauge2; +}; + +Game_Actor.prototype.gauge3 = function() { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.gauge3 === 'UNDEFINED') continue; + return equip.gauge3; + } + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gauge3 === 'UNDEFINED') continue; + return state.gauge3; + } + return this.currentClass().gauge3; +}; + +Game_Actor.prototype.gaugeIcon1 = function() { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.gaugeIcon1 === 'UNDEFINED') continue; + return equip.gaugeIcon1; + } + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gaugeIcon1 === 'UNDEFINED') continue; + return state.gaugeIcon1; + } + return this.currentClass().gaugeIcon1; +}; + +Game_Actor.prototype.gaugeIcon2 = function() { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.gaugeIcon2 === 'UNDEFINED') continue; + return equip.gaugeIcon2; + } + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gaugeIcon2 === 'UNDEFINED') continue; + return state.gaugeIcon2; + } + return this.currentClass().gaugeIcon2; +}; + +Game_Actor.prototype.gaugeIcon3 = function() { + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (!equip) continue; + if (equip.gaugeIcon3 === 'UNDEFINED') continue; + return equip.gaugeIcon3; + } + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gaugeIcon3 === 'UNDEFINED') continue; + return state.gaugeIcon3; + } + return this.currentClass().gaugeIcon3; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.gauge1 = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gauge1 === 'UNDEFINED') continue; + return state.gauge1; + } + return this.enemy().gauge1; +}; + +Game_Enemy.prototype.gauge2 = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gauge2 === 'UNDEFINED') continue; + return state.gauge2; + } + return this.enemy().gauge2; +}; + +Game_Enemy.prototype.gauge3 = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gauge1 === 'UNDEFINED') continue; + return state.gauge1; + } + return this.enemy().gauge3; +}; + +Game_Enemy.prototype.gaugeIcon1 = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gaugeIcon1 === 'UNDEFINED') continue; + return state.gaugeIcon1; + } + return this.enemy().gaugeIcon1; +}; + +Game_Enemy.prototype.gaugeIcon2 = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gaugeIcon2 === 'UNDEFINED') continue; + return state.gaugeIcon2; + } + return this.enemy().gaugeIcon2; +}; + +Game_Enemy.prototype.gaugeIcon3 = function() { + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (!state) continue; + if (state.gaugeIcon3 === 'UNDEFINED') continue; + return state.gaugeIcon3; + } + return this.enemy().gaugeIcon3; +}; + +if (!Game_Enemy.prototype.skills) { + Game_Enemy.prototype.skills = function() { + var skills = [] + for (var i = 0; i < this.enemy().actions.length; ++i) { + var skill = $dataSkills[this.enemy().actions[i].skillId]; + if (skill) skills.push(skill); + } + return skills; + } +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.Skill.Game_Action_apply = Game_Action.prototype.apply; +Game_Action.prototype.apply = function(target) { + this.applyBeforeEffect(target); + this.applyBeforeEval(target); + Yanfly.Skill.Game_Action_apply.call(this, target); + this.applyAfterEffect(target); + this.applyAfterEval(target); +}; + +Game_Action.prototype.applyBeforeEffect = function(target) { +}; + +Game_Action.prototype.applyBeforeEval = function(target) { + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var subject = this.subject(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.customBeforeEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'BEFORE EVAL ERROR'); + } +}; + +Game_Action.prototype.applyAfterEffect = function(target) { +}; + +Game_Action.prototype.applyAfterEval = function(target) { + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var subject = this.subject(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.customAfterEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'AFTER EVAL ERROR'); + } +}; + +Yanfly.Skill.Game_Action_executeDamage = Game_Action.prototype.executeDamage; +Game_Action.prototype.executeDamage = function(target, value) { + this.applyPreDamageEffect(target, value); + value = this.applyPreDamageEval(target, value); + Yanfly.Skill.Game_Action_executeDamage.call(this, target, value); + this.applyPostDamageEffect(target, value); + this.applyPostDamageEval(target, value); +}; + +Game_Action.prototype.applyPreDamageEffect = function(target, value) { +}; + +Game_Action.prototype.applyPreDamageEval = function(target, value) { + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var subject = this.subject(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.customPreDamageEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'PRE-DAMAGE EVAL ERROR'); + } + return value; +}; + +Game_Action.prototype.applyPostDamageEffect = function(target, value) { +}; + +Game_Action.prototype.applyPostDamageEval = function(target, value) { + var item = this.item(); + var a = this.subject(); + var b = target; + var user = this.subject(); + var subject = this.subject(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = item.customPostDamageEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'POST-DAMAGE EVAL ERROR'); + } +}; + +//============================================================================= +// Window_Base +//============================================================================= + +Yanfly.Skill.Window_Base_drawActorHp = Window_Base.prototype.drawActorHp; +Window_Base.prototype.drawActorHp = function(actor, x, y, width) { + if (actor.gauge1() === 'HP') { + Yanfly.Skill.Window_Base_drawActorHp.call(this, actor, x, y, width); + } else if (actor.gauge1() === 'MP') { + Yanfly.Skill.Window_Base_drawActorMp.call(this, actor, x, y, width); + } else if (actor.gauge1() === 'TP') { + Yanfly.Skill.Window_Base_drawActorTp.call(this, actor, x, y, width); + } +}; + +Yanfly.Skill.Window_Base_drawActorMp = Window_Base.prototype.drawActorMp; +Window_Base.prototype.drawActorMp = function(actor, x, y, width) { + if (actor.gauge2() === 'HP') { + Yanfly.Skill.Window_Base_drawActorHp.call(this, actor, x, y, width); + } else if (actor.gauge2() === 'MP') { + Yanfly.Skill.Window_Base_drawActorMp.call(this, actor, x, y, width); + } else if (actor.gauge2() === 'TP') { + Yanfly.Skill.Window_Base_drawActorTp.call(this, actor, x, y, width); + } +}; + +Yanfly.Skill.Window_Base_drawActorTp = Window_Base.prototype.drawActorTp; +Window_Base.prototype.drawActorTp = function(actor, x, y, width) { + if (actor.gauge3() === 'HP') { + Yanfly.Skill.Window_Base_drawActorHp.call(this, actor, x, y, width); + } else if (actor.gauge3() === 'MP') { + Yanfly.Skill.Window_Base_drawActorMp.call(this, actor, x, y, width); + } else if (actor.gauge3() === 'TP') { + Yanfly.Skill.Window_Base_drawActorTp.call(this, actor, x, y, width); + } +}; + +//============================================================================= +// Window_SkillType +//============================================================================= + +Window_SkillType.prototype.itemTextAlign = function() { + return Yanfly.Param.SCCTextAlign; +}; + +//============================================================================= +// Window_SkillList +//============================================================================= + +Window_SkillList.prototype.maxCols = function() { + return Yanfly.Param.SCCWindowCol; +}; + +Yanfly.Skill.Window_SkillList_includes = + Window_SkillList.prototype.includes; +Window_SkillList.prototype.includes = function(item) { + if (this._actor) { + if (!this._actor.noHiddenSkillConditionsMet(item)) return false; + } + return Yanfly.Skill.Window_SkillList_includes.call(this, item); +}; + +Window_SkillList.prototype.drawSkillCost = function(skill, wx, wy, width) { + var dw = width; + dw = this.drawTpCost(skill, wx, wy, dw); + dw = this.drawMpCost(skill, wx, wy, dw); + dw = this.drawHpCost(skill, wx, wy, dw); + dw = this.drawCustomDisplayCost(skill, wx, wy, dw); + dw = this.drawOtherCost(skill, wx, wy, dw); + return dw; +}; + +Window_SkillList.prototype.drawTpCost = function(skill, wx, wy, dw) { + if (this._actor.skillTpCost(skill) <= 0) return dw; + if (Yanfly.Icon.Tp > 0) { + var iw = wx + dw - Window_Base._iconWidth; + this.drawIcon(Yanfly.Icon.Tp, iw, wy + 2); + dw -= Window_Base._iconWidth + 2; + } + this.changeTextColor(this.textColor(Yanfly.Param.SCCTpTextColor)); + var fmt = Yanfly.Param.SCCTpFormat; + var text = fmt.format(Yanfly.Util.toGroup(this._actor.skillTpCost(skill)), + TextManager.tpA); + this.contents.fontSize = Yanfly.Param.SCCTpFontSize; + this.drawText(text, wx, wy, dw, 'right'); + var returnWidth = dw - this.textWidth(text) - Yanfly.Param.SCCCostPadding; + this.resetFontSettings(); + return returnWidth; +}; + +Window_SkillList.prototype.drawMpCost = function(skill, wx, wy, dw) { + if (this._actor.skillMpCost(skill) <= 0) return dw; + if (Yanfly.Icon.Mp > 0) { + var iw = wx + dw - Window_Base._iconWidth; + this.drawIcon(Yanfly.Icon.Mp, iw, wy + 2); + dw -= Window_Base._iconWidth + 2; + } + this.changeTextColor(this.textColor(Yanfly.Param.SCCMpTextColor)); + var fmt = Yanfly.Param.SCCMpFormat; + var text = fmt.format(Yanfly.Util.toGroup(this._actor.skillMpCost(skill)), + TextManager.mpA); + this.contents.fontSize = Yanfly.Param.SCCMpFontSize; + this.drawText(text, wx, wy, dw, 'right'); + var returnWidth = dw - this.textWidth(text) - Yanfly.Param.SCCCostPadding; + this.resetFontSettings(); + return returnWidth; +}; + +Window_SkillList.prototype.drawHpCost = function(skill, wx, wy, dw) { + if (this._actor.skillHpCost(skill) <= 0) return dw; + if (Yanfly.Icon.Hp > 0) { + var iw = wx + dw - Window_Base._iconWidth; + this.drawIcon(Yanfly.Icon.Hp, iw, wy + 2); + dw -= Window_Base._iconWidth + 2; + } + this.changeTextColor(this.textColor(Yanfly.Param.SCCHpTextColor)); + var fmt = Yanfly.Param.SCCHpFormat; + var text = fmt.format(Yanfly.Util.toGroup(this._actor.skillHpCost(skill)), + TextManager.hpA); + this.contents.fontSize = Yanfly.Param.SCCHpFontSize; + this.drawText(text, wx, wy, dw, 'right'); + var returnWidth = dw - this.textWidth(text) - Yanfly.Param.SCCCostPadding; + this.resetFontSettings(); + return returnWidth; +}; + +Window_SkillList.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +Window_SkillList.prototype.drawCustomDisplayCost = function(skill, wx, wy, dw) { + this.runDisplayEvalCost(skill); + if (skill.customCostText === '') return dw; + var width = this.textWidthEx(skill.customCostText); + this.resetFontSettings(); + this.drawTextEx(skill.customCostText, wx - width + dw, wy); + var returnWidth = dw - width - Yanfly.Param.SCCCostPadding; + this.resetFontSettings(); + return returnWidth; +}; + +Window_SkillList.prototype.runDisplayEvalCost = function(skill) { + if (skill.costdisplayEval === '') return; + var item = skill; + var a = this._actor; + var user = this._actor; + var subject = this._actor; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var code = skill.costdisplayEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'SKILL COST DISPLAY EVAL ERROR'); + } +}; + +Window_SkillList.prototype.drawOtherCost = function(skill, wx, wy, dw) { + return dw; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_VictoryAftermath.js b/js/plugins/YEP_VictoryAftermath.js new file mode 100644 index 0000000..93c1408 --- /dev/null +++ b/js/plugins/YEP_VictoryAftermath.js @@ -0,0 +1,1023 @@ +//============================================================================= +// Yanfly Engine Plugins - Victory Aftermath +// YEP_VictoryAftermath.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_VictoryAftermath = true; + +var Yanfly = Yanfly || {}; +Yanfly.VA = Yanfly.VA || {}; +Yanfly.VA.version = 1.07 + +//============================================================================= + /*: + * @plugindesc v1.07 Display an informative window after a battle is over + * instead of message box text stating what the party earned. + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Victory Order + * @parent ---General--- + * @desc This is the order the victory sequence will play out. + * Separate each part with a space. + * @default exp custom drops + * + * @param ---BGM--- + * @default + * + * @param Victory BGM + * @parent ---BGM--- + * @type file + * @dir audio/bgm/ + * @require 1 + * @desc This will be the BGM used when the battle is over. + * @default Ship3 + * + * @param BGM Volume + * @parent ---BGM--- + * @desc This will be the volume of the BGM played. + * @default 90 + * + * @param BGM Pitch + * @parent ---BGM--- + * @desc This will be the pitch of the BGM played. + * @default 100 + * + * @param BGM Pan + * @parent ---BGM--- + * @desc This will be the pan of the BGM played. + * @default 0 + * + * @param ---Battle Results--- + * @default + * + * @param Cheer Wait + * @parent ---Battle Results--- + * @type number + * @min 0 + * @desc This will be how many frames the actors will cheer for + * before the Victory Aftermath windows appear. + * @default 90 + * + * @param Battle Results Text + * @parent ---Battle Results--- + * @desc This is the text used for the battle results text. + * @default Battle Results + * + * @param Battle Drops Text + * @parent ---Battle Results--- + * @desc This is the text used for the drops gained in battle. + * @default Battle Spoils + * + * @param ---EXP Window--- + * @default + * + * @param Font Size + * @parent ---EXP Window--- + * @type number + * @min 1 + * @desc This is the font size used for the EXP Window. + * Default: 28 + * @default 28 + * + * @param Level Up Text + * @parent ---EXP Window--- + * @desc The text to be used when leveling up. + * @default LEVEL UP! + * + * @param Max Level Text + * @parent ---EXP Window--- + * @desc The text to be used when the actor is Max Level. + * @default MAX LEVEL + * + * @param Show Skills Learned + * @parent ---EXP Window--- + * @type boolean + * @on Display Skills + * @off Don't Display + * @desc Display skills learned at level up? + * NO - false YES - true + * @default false + * + * @param Gained EXP Text + * @parent ---EXP Window--- + * @desc The text to label how much EXP was gained in battle. + * @default Gained EXP + * + * @param Gained EXP Format + * @parent ---EXP Window--- + * @desc The text to display how much EXP was gained in battle. + * @default +%1 + * + * @param EXP Gauge Color 1 + * @parent ---EXP Window--- + * @type number + * @min 0 + * @max 31 + * @desc The skin color used in EXP Gauge Color 1 shown in the + * Victory Aftermath Window. + * @default 30 + * + * @param EXP Gauge Color 2 + * @parent ---EXP Window--- + * @type number + * @min 0 + * @max 31 + * @desc The skin color used in EXP Gauge Color 2 shown in the + * Victory Aftermath Window. + * @default 31 + * + * @param Level Gauge Color 1 + * @parent ---EXP Window--- + * @type number + * @min 0 + * @max 31 + * @desc The skin color used for the EXP Gauge Color 1 if the actor + * has leveled up. + * @default 14 + * + * @param Level Gauge Color 2 + * @parent ---EXP Window--- + * @type number + * @min 0 + * @max 31 + * @desc The skin color used for the EXP Gauge Color 2 if the actor + * has leveled up. + * @default 6 + * + * @param Gauge Ticks + * @parent ---EXP Window--- + * @type number + * @min 0 + * @desc This is how many ticks will occur before the gained EXP + * gauge is full. Each tick is 4 frames. + * @default 15 + * + * @param Tick SE + * @parent ---EXP Window--- + * @type file + * @dir audio/se/ + * @require 1 + * @desc This will be the sound used while the EXP gauge fills up. + * @default Absorb2 + * + * @param Tick Volume + * @parent ---EXP Window--- + * @desc This will be the volume of the BGM played. + * @default 90 + * + * @param Tick Pitch + * @parent ---EXP Window--- + * @desc This will be the pitch of the BGM played. + * @default 150 + * + * @param Tick Pan + * @parent ---EXP Window--- + * @desc This will be the pan of the BGM played. + * @default 0 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin swaps out the victory messages from the default battle system in + * favor of more informative windows to display. Adjust the parameters to + * change the settings to fit your game. + * + * ============================================================================ + * Victory Aftermath + * ============================================================================ + * + * In the parameters, there's a 'Victory Order' parameter. This parameter lets + * you choose the order of the steps in the Victory Aftermath. + * + * The default order is as follows: + * exp Displays the EXP window. + * custom Displays any custom plugin extensions. + * drops Displays the drops window. + * + * If you switch the order of these steps, add steps, or remove steps from the + * 'Victory Order' plugin, the Victory Aftermath will correspond to any changes + * you have made. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * If you wish to alter the Victory Aftermath sequence a bit, you can use the + * following Plugin Commands. + * + * Plugin Commands: + * DisableVictoryAftermath - Disables the Victory Aftermath sequence and + * bypasses the Victory Aftermath music, too. + * EnableVictoryAftermath - Enables the Victory Aftermath sequence if + * it has been previously disabled. + * DisableVictoryMusic - Disables the Victory Aftermath music to just + * continue playing whatever was playing. + * EnableVictoryMusic - Enables the Victory Aftermath music if it has + * been previously disabled. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.07: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.06: + * - Updated for RPG Maker MV version 1.3.2. + * + * Version 1.05a: + * - Added 'Font Size' plugin parameter to alter the font size for the battle + * results page. + * - Fixed a graphical issue where an actor in crisis would display its level + * in the crisis color. + * - Changed the Victory Aftermath sequence so that the player can hold down a + * button to quickly go through all the Victory Sequence menus. + * + * Version 1.04: + * - Updated the plugin so it doesn't break visually when party sizes are too + * large. That said, if the party size is beyond a certain amount, this plugin + * will not support that many faces for it and will fit just the bare minimum. + * + * Version 1.03: + * - Added parameter 'Show Skills Learned'. + * + * Version 1.02: + * - If the Battle HUD has been hidden for whatever reason during the victory + * sequence, it will be returned. + * + * Version 1.01: + * - Fixed a bug plugin commands that would cause some victory sequences to + * loop forever. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_VictoryAftermath'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.VAOrder = String(Yanfly.Parameters['Victory Order']); + +Yanfly.Param.VACheerWait = Number(Yanfly.Parameters['Cheer Wait']); +Yanfly.Param.VABattleResults = String(Yanfly.Parameters['Battle Results Text']); +Yanfly.Param.VABattleDrops = String(Yanfly.Parameters['Battle Drops Text']); + +Yanfly.Param.VABgmName = String(Yanfly.Parameters['Victory BGM']); +Yanfly.Param.VABgmVol = Number(Yanfly.Parameters['BGM Volume']); +Yanfly.Param.VABgmPitch = Number(Yanfly.Parameters['BGM Pitch']); +Yanfly.Param.VABgmPan = Number(Yanfly.Parameters['BGM Pan']); + +Yanfly.Param.VAFontSize = Number(Yanfly.Parameters['Font Size']); +Yanfly.Param.VALevelUp = String(Yanfly.Parameters['Level Up Text']); +Yanfly.Param.VAMaxLv = String(Yanfly.Parameters['Max Level Text']); +Yanfly.Param.VAShowSkills = String(Yanfly.Parameters['Show Skills Learned']); +Yanfly.Param.VAGainedExp = String(Yanfly.Parameters['Gained EXP Text']); +Yanfly.Param.VAGainedExpfmt = String(Yanfly.Parameters['Gained EXP Format']); +Yanfly.Param.ColorExp1 = Number(Yanfly.Parameters['EXP Gauge Color 1']); +Yanfly.Param.ColorExp2 = Number(Yanfly.Parameters['EXP Gauge Color 2']); +Yanfly.Param.ColorLv1 = Number(Yanfly.Parameters['Level Gauge Color 1']); +Yanfly.Param.ColorLv2 = Number(Yanfly.Parameters['Level Gauge Color 2']); +Yanfly.Param.VAGaugeTicks = Number(Yanfly.Parameters['Gauge Ticks']); +Yanfly.Param.VATickName = String(Yanfly.Parameters['Tick SE']); +Yanfly.Param.VATickVol = Number(Yanfly.Parameters['Tick Volume']); +Yanfly.Param.VATickPitch = Number(Yanfly.Parameters['Tick Pitch']); +Yanfly.Param.VATickPan = Number(Yanfly.Parameters['Tick Pan']); + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.VA.BattleManager_initMembers = BattleManager.initMembers; +BattleManager.initMembers = function() { + Yanfly.VA.BattleManager_initMembers.call(this); + this.initVictoryData(); +}; + +BattleManager.initVictoryData = function() { + this._victoryPhase = false; + this._victoryCheerWait = 0; + this._victoryStep = 0; +}; + +BattleManager.processVictory = function() { + $gameParty.performVictory(); + if (this.isVictoryPhase()) return; + if (this._windowLayer) this._windowLayer.x = 0; + $gameParty.removeBattleStates(); + this._victoryPhase = true; + if ($gameSystem.skipVictoryAftermath()) { + this.processSkipVictory(); + } else { + this.processNormalVictory(); + } +}; + +BattleManager.isVictoryPhase = function() { + return this._victoryPhase; +}; + +BattleManager.isFinishedVictoryCheer = function() { + return ++this._victoryCheerWait >= Yanfly.Param.VACheerWait; +}; + +BattleManager.processSkipVictory = function() { + this.makeRewards(); + this.gainRewards(); + this.replayBgmAndBgs(); + this.endBattle(0); +}; + +BattleManager.processNormalVictory = function() { + if (!$gameSystem.skipVictoryMusic()) this.playVictoryMe(); + this.makeRewards(); + this.startVictoryPhase(); +}; + +Yanfly.VA.BattleManager_playVictoryMe = BattleManager.playVictoryMe; +BattleManager.playVictoryMe = function() { + Yanfly.VA.BattleManager_playVictoryMe.call(this); + this.playVictoryBGM(); +}; + +BattleManager.playVictoryBGM = function() { + var victoryBgm = { + name: Yanfly.Param.VABgmName, + volume: Yanfly.Param.VABgmVol, + pitch: Yanfly.Param.VABgmPitch, + pan: Yanfly.Param.VABgmPan + }; + AudioManager.playBgm(victoryBgm); +}; + +BattleManager.startVictoryPhase = function() { + this._victoryCheerWait = 0; + this._victoryStep = 0; + this.prepareVictoryInfo(); +}; + +BattleManager.prepareVictoryInfo = function() { + $gameParty.allMembers().forEach(function(actor) { + ImageManager.loadFace(actor.faceName()); + actor._preVictoryExp = actor.currentExp(); + actor._preVictoryLv = actor._level; + actor._victoryPhase = true; + actor._victorySkills = []; + }, this); + this.gainRewards(); + $gameParty.allMembers().forEach(function(actor) { + actor._expGained = actor.currentExp() - actor._preVictoryExp; + actor._postVictoryLv = actor._level; + }, this); +}; + +BattleManager.processVictoryFinish = function() { + $gameParty.clearVictoryData(); + this.endBattle(0); + this.replayBgmAndBgs(); + this._victoryPhase = false; +}; + +//============================================================================= +// Game_System +//============================================================================= + +Yanfly.VA.Game_System_initialize = Game_System.prototype.initialize; +Game_System.prototype.initialize = function() { + Yanfly.VA.Game_System_initialize.call(this); + this._skipVictoryAftermath = false; + this._skipVictoryMusic = false; +}; + +Game_System.prototype.skipVictoryAftermath = function() { + return this._skipVictoryAftermath; +}; + +Game_System.prototype.skipVictoryMusic = function() { + return this._skipVictoryMusic; +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Yanfly.VA.Game_Actor_shouldDisplayLevelUp = + Game_Actor.prototype.shouldDisplayLevelUp; +Game_Actor.prototype.shouldDisplayLevelUp = function() { + if ($gameParty.inBattle()) return false; + return Yanfly.VA.Game_Actor_shouldDisplayLevelUp.call(this); +}; + +Game_Actor.prototype.clearVictoryData = function() { + this._preVictoryExp = undefined; + this._preVictoryLv = undefined; + this._expGained = undefined; + this._postVictoryLv = undefined; + this._victoryPhase = undefined; + this._victorySkills = undefined; +}; + +Game_Actor.prototype.isLearnedSkillRaw = function(skillId) { + return this._skills.contains(skillId); +}; + +Yanfly.VA.Game_Actor_learnSkill = Game_Actor.prototype.learnSkill; +Game_Actor.prototype.learnSkill = function(skillId) { + if (!this.isLearnedSkillRaw(skillId) && this._victoryPhase) { + this._victorySkills.push(skillId); + } + Yanfly.VA.Game_Actor_learnSkill.call(this, skillId); +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Game_Party.prototype.clearVictoryData = function() { + for (var i = 0; i < this.members().length; ++i) { + var actor = this.members()[i]; + if (!actor) continue; + actor.clearVictoryData(); + } +}; + +//============================================================================= +// Game_Interpreter +//============================================================================= + +Yanfly.VA.Game_Interpreter_pluginCommand = + Game_Interpreter.prototype.pluginCommand; +Game_Interpreter.prototype.pluginCommand = function(command, args) { + Yanfly.VA.Game_Interpreter_pluginCommand.call(this, command, args) + if (command === 'DisableVictoryAftermath') { + $gameSystem._skipVictoryAftermath = true; + } + if (command === 'EnableVictoryAftermath') { + $gameSystem._skipVictoryAftermath = false; + } + if (command === 'DisableVictoryMusic') { + $gameSystem._skipVictoryMusic = true; + } + if (command === 'EnableVictoryMusic') { + $gameSystem._skipVictoryMusic = false; + } +}; + +Game_Interpreter.prototype.gotoSceneParty = function() { + if (!$gameParty.inBattle()) SceneManager.push(Scene_Party); + return true; +}; + +Game_Interpreter.prototype.lockActor = function(args, value) { + for (i = 0; i < args.length; i++) { + var actorId = Number(args[i]); + if ($gameActors.actor(actorId)) { + $gameActors.actor(actorId)._locked = value; + } + } +}; + +Game_Interpreter.prototype.requireActor = function(args, value) { + for (i = 0; i < args.length; i++) { + var actorId = Number(args[i]); + if ($gameActors.actor(actorId)) { + $gameActors.actor(actorId)._required = value; + } + } +}; + +//============================================================================= +// Window_VictoryTitle +//============================================================================= + +function Window_VictoryTitle() { + this.initialize.apply(this, arguments); +} + +Window_VictoryTitle.prototype = Object.create(Window_Base.prototype); +Window_VictoryTitle.prototype.constructor = Window_VictoryTitle; + +Window_VictoryTitle.prototype.initialize = function() { + var width = this.windowWidth(); + var height = this.windowHeight(); + Window_Base.prototype.initialize.call(this, 0, 0, width, height); + this.refresh(Yanfly.Param.VABattleResults); + this.openness = 0; +}; + +Window_VictoryTitle.prototype.windowWidth = function() { + return Graphics.boxWidth; +}; + +Window_VictoryTitle.prototype.windowHeight = function() { + return this.fittingHeight(1); +}; + +Window_VictoryTitle.prototype.refresh = function(text) { + this.contents.clear(); + this.drawText(text, 0, 0, this.contents.width, 'center'); +}; + +//============================================================================= +// Window_VictoryExp +//============================================================================= + +function Window_VictoryExp() { + this.initialize.apply(this, arguments); +} + +Window_VictoryExp.prototype = Object.create(Window_Selectable.prototype); +Window_VictoryExp.prototype.constructor = Window_VictoryExp; + +Window_VictoryExp.prototype.initialize = function() { + var wy = this.fittingHeight(1); + var width = this.windowWidth(); + var height = this.windowHeight(); + this._showGainedSkills = eval(Yanfly.Param.VAShowSkills); + Window_Selectable.prototype.initialize.call(this, 0, wy, width, height); + this.defineTickSound(); + this.refresh(); + AudioManager.playSe(this._tickSound); + this._tick = 0; + this.openness = 0; +}; + +Window_VictoryExp.prototype.windowWidth = function() { + return Graphics.boxWidth; +}; + +Window_VictoryExp.prototype.windowHeight = function() { + return Graphics.boxHeight - this.fittingHeight(1); +}; + +Window_VictoryExp.prototype.maxItems = function() { + return $gameParty.maxBattleMembers(); +}; + +Window_VictoryExp.prototype.standardFontSize = function() { + return Yanfly.Param.VAFontSize; +}; + +Window_VictoryExp.prototype.lineHeight = function() { + return this.standardFontSize() + 8; +}; + +Window_VictoryExp.prototype.itemHeight = function() { + var clientHeight = this.height - this.padding * 2; + var clientHeight = Math.floor(clientHeight / this.maxItems()); + var clientHeight = Math.max(clientHeight, this.lineHeight() * 2); + return clientHeight; +}; + +Window_VictoryExp.prototype.textWidthEx = function(text) { + return this.drawTextEx(text, 0, this.contents.height); +}; + +Window_VictoryExp.prototype.defineTickSound = function() { + this._tickSound = { + name: Yanfly.Param.VATickName, + volume: Yanfly.Param.VATickVol, + pitch: Yanfly.Param.VATickPitch, + pan: Yanfly.Param.VATickPan + }; +}; + +Window_VictoryExp.prototype.update = function() { + Window_Selectable.prototype.update.call(this); + if (this.openness >= 255) this.updateTicks(); +}; + +Window_VictoryExp.prototype.updateTicks = function() { + if (this._tick >= Yanfly.Param.VAGaugeTicks) return; + if (Graphics.frameCount % 4 !== 0) return; + if (Input.isPressed('ok') || TouchInput.isPressed()) { + this._tick = Yanfly.Param.VAGaugeTicks; + } else { + this._tick += 1; + } + this.drawAllGauges(); +}; + +Window_VictoryExp.prototype.drawAllGauges = function() { + var topIndex = this.topIndex(); + for (var i = 0; i < this.maxPageItems(); i++) { + var index = topIndex + i; + if (index < this.maxItems()) this.drawItemGauge(index); + } +}; + +Window_VictoryExp.prototype.drawItem = function(index) { + var actor = $gameParty.battleMembers()[index]; + if (!actor) return; + this.drawActorProfile(actor, index); +}; + +Window_VictoryExp.prototype.drawActorProfile = function(actor, index) { + var rect = this.itemRect(index); + var fw = Window_Base._faceWidth; + this.drawActorFace(actor, rect.x + 1, rect.y + 1, fw, rect.height - 2); +}; + +Window_VictoryExp.prototype.drawItemGauge = function(index) { + var actor = $gameParty.battleMembers()[index]; + if (!actor) return; + this.drawActorGauge(actor, index); +}; + +Window_VictoryExp.prototype.gaugeRect = function(index) { + var rect = this.itemRect(index); + var fw = Window_Base._faceWidth; + rect.x += fw + this.standardPadding() * 2; + rect.width -= fw * 2 + this.standardPadding() * 4; + return rect; +}; + +Window_VictoryExp.prototype.clearGaugeRect = function(index) { + var rect = this.gaugeRect(index); + this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); +}; + +Window_VictoryExp.prototype.drawActorGauge = function(actor, index) { + this.clearGaugeRect(index); + var rect = this.gaugeRect(index); + this.changeTextColor(this.normalColor()); + this.drawActorName(actor, rect.x + 2, rect.y); + this.drawLevel(actor, rect); + this.drawExpGauge(actor, rect); + this.drawExpValues(actor, rect); + this.drawExpGained(actor, rect); + this.drawGainedSkills(actor, rect); +}; + +Window_VictoryExp.prototype.drawLevel = function(actor, rect) { + this.changeTextColor(this.normalColor()); + if (this.actorExpRate(actor) >= 1.0) { + var text = Yanfly.Util.toGroup(actor._postVictoryLv); + } else { + var text = Yanfly.Util.toGroup(actor._preVictoryLv); + } + this.drawText(text, rect.x + 2, rect.y, rect.width - 4, 'right'); + var ww = rect.width - 4 - this.textWidth('0' + + Yanfly.Util.toGroup(actor.maxLevel())); + this.changeTextColor(this.systemColor()); + this.drawText(TextManager.levelA, rect.x + 2, rect.y, ww, 'right'); +}; + +Window_VictoryExp.prototype.actorExpRate = function(actor) { + var actorLv = actor._preVictoryLv; + if (actorLv === actor.maxLevel()) return 1.0; + var bonusExp = 1.0 * actor._expGained * this._tick / + Yanfly.Param.VAGaugeTicks; + var nowExp = actor._preVictoryExp - actor.expForLevel(actorLv) + bonusExp; + var nextExp = actor.expForLevel(actorLv + 1) - actor.expForLevel(actorLv); + return (1.0 * nowExp / nextExp).clamp(0.0, 1.0); +}; + +Window_VictoryExp.prototype.drawExpGauge = function(actor, rect) { + var rate = this.actorExpRate(actor); + if (rate >= 1.0) { + var color1 = this.textColor(Yanfly.Param.ColorLv1); + var color2 = this.textColor(Yanfly.Param.ColorLv2); + } else { + var color1 = this.textColor(Yanfly.Param.ColorExp1); + var color2 = this.textColor(Yanfly.Param.ColorExp2); + } + var wy = rect.y + this.lineHeight(); + this.drawGauge(rect.x, wy, rect.width, rate, color1, color2); +}; + +Window_VictoryExp.prototype.drawExpValues = function(actor, rect) { + var wy = rect.y + this.lineHeight(); + var actorLv = actor._preVictoryLv; + var bonusExp = 1.0 * actor._expGained * this._tick / + Yanfly.Param.VAGaugeTicks; + var nowExp = actor._preVictoryExp - actor.expForLevel(actorLv) + bonusExp; + var nextExp = actor.expForLevel(actorLv + 1) - actor.expForLevel(actorLv); + if (actorLv === actor.maxLevel()) { + var text = Yanfly.Param.VAMaxLv; + } else if (nowExp >= nextExp) { + var text = Yanfly.Param.VALevelUp; + } else { + var text = Yanfly.Util.toGroup(parseInt(nextExp - nowExp)); + } + this.changeTextColor(this.normalColor()); + this.drawText(text, rect.x + 2, wy, rect.width - 4, 'right'); +}; + +Window_VictoryExp.prototype.drawExpGained = function(actor, rect) { + var wy = rect.y + this.lineHeight() * 2; + if (wy >= rect.y + rect.height) return; + this.changeTextColor(this.systemColor()); + this.drawText(Yanfly.Param.VAGainedExp, rect.x + 2, wy, rect.width - 4, + 'left'); + var bonusExp = 1.0 * actor._expGained * this._tick / + Yanfly.Param.VAGaugeTicks; + var expParse = Yanfly.Util.toGroup(parseInt(bonusExp)); + var expText = Yanfly.Param.VAGainedExpfmt.format(expParse); + this.changeTextColor(this.normalColor()); + this.drawText(expText, rect.x + 2, wy, rect.width - 4, 'right'); +}; + +Window_VictoryExp.prototype.drawGainedSkills = function(actor, rect) { + if (actor._victorySkills.length <= 0) return; + if (!this.meetDrawGainedSkillsCondition(actor)) return; + var wy = rect.y; + for (var i = 0; i < actor._victorySkills.length; ++i) { + if (wy + this.lineHeight() > rect.y + rect.height) break; + var skillId = actor._victorySkills[i]; + var skill = $dataSkills[skillId]; + if (!skill) continue; + var text = '\\i[' + skill.iconIndex + ']' + skill.name; + text = TextManager.obtainSkill.format(text); + var ww = this.textWidthEx(text); + var wx = rect.x + (rect.width - ww) / 2; + this.drawTextEx(text, wx, wy); + wy += this.lineHeight(); + } +}; + +Window_VictoryExp.prototype.meetDrawGainedSkillsCondition = function(actor) { + if (!this._showGainedSkills) return; + var actorLv = actor._preVictoryLv; + var bonusExp = 1.0 * actor._expGained * this._tick / + Yanfly.Param.VAGaugeTicks; + var nowExp = actor._preVictoryExp - actor.expForLevel(actorLv) + bonusExp; + var nextExp = actor.expForLevel(actorLv + 1) - actor.expForLevel(actorLv); + if (actorLv === actor.maxLevel()) { + return false; + } else if (nowExp >= nextExp) { + return true; + } else { + return false; + } +}; + +Window_VictoryExp.prototype.isReady = function() { + return this._tick >= Yanfly.Param.VAGaugeTicks; +}; + +//============================================================================= +// Window_VictoryDrop +//============================================================================= + +function Window_VictoryDrop() { + this.initialize.apply(this, arguments); +} + +Window_VictoryDrop.prototype = Object.create(Window_ItemList.prototype); +Window_VictoryDrop.prototype.constructor = Window_VictoryDrop; + +Window_VictoryDrop.prototype.initialize = function(titleWindow) { + var wy = titleWindow.height; + var ww = Graphics.boxWidth; + var wh = Graphics.boxHeight - wy; + Window_ItemList.prototype.initialize.call(this, 0, wy, ww, wh); + this.openness = 0; + this.refresh(); +}; + +Window_VictoryDrop.prototype.makeItemList = function() { + if (BattleManager._rewards.gold > 0) { + this._data = ['gold', null]; + } else { + this._data = []; + } + this._dropItems = []; + this._dropWeapons = []; + this._dropArmors = []; + this.extractDrops(); +}; + +Window_VictoryDrop.prototype.extractDrops = function() { + BattleManager._rewards.items.forEach(function(item) { + if (!item) return; + if (DataManager.isItem(item)) this._dropItems.push(item.id); + if (DataManager.isWeapon(item)) this._dropWeapons.push(item.id); + if (DataManager.isArmor(item)) this._dropArmors.push(item.id); + }, this); + this._dropItems.sort(function(a, b){return a-b}); + this._dropWeapons.sort(function(a, b){return a-b}); + this._dropArmors.sort(function(a, b){return a-b}); + this._dropItems.forEach(function(id) { + var item = $dataItems[id]; + if (item && !this._data.contains(item)) this._data.push(item); + }, this); + this._dropWeapons.forEach(function(id) { + var item = $dataWeapons[id]; + if (item && !this._data.contains(item)) this._data.push(item); + }, this); + this._dropArmors.forEach(function(id) { + var item = $dataArmors[id]; + if (item && !this._data.contains(item)) this._data.push(item); + }, this); +}; + +Window_VictoryDrop.prototype.drawItem = function(index) { + var item = this._data[index]; + if (!item) return; + this.drawGold(item, index); + this.drawDrop(item, index); +}; + +Window_VictoryDrop.prototype.drawGold = function(item, index) { + if (item !== 'gold') return; + var rect = this.itemRect(index); + rect.width -= this.textPadding(); + var value = BattleManager._rewards.gold; + var currency = TextManager.currencyUnit; + this.drawCurrencyValue(value, currency, rect.x, rect.y, rect.width); +}; + +Window_VictoryDrop.prototype.drawDrop = function(item, index) { + if (!DataManager.isItem(item) && !DataManager.isWeapon(item) && + !DataManager.isArmor(item)) return; + var rect = this.itemRect(index); + rect.width -= this.textPadding(); + this.drawItemName(item, rect.x, rect.y, rect.width); + this.drawItemNumber(item, rect.x, rect.y, rect.width); +}; + +Window_VictoryDrop.prototype.drawItemNumber = function(item, x, y, width) { + if (!this.needsNumber()) return; + var numItems = Yanfly.Util.toGroup(this.numItems(item)); + var size = Yanfly.Param.ItemQuantitySize || 28; + this.contents.fontSize = size; + this.drawText('\u00d7' + numItems, x, y, width, 'right'); + this.resetFontSettings(); +}; + +Window_VictoryDrop.prototype.numItems = function(item) { + if (DataManager.isItem(item)) { + return Yanfly.Util.getCount(item.id, this._dropItems); + } + if (DataManager.isWeapon(item)) { + return Yanfly.Util.getCount(item.id, this._dropWeapons); + } + if (DataManager.isArmor(item)) { + return Yanfly.Util.getCount(item.id, this._dropArmors); + } + return 0; +}; + +//============================================================================= +// Scene_Battle +//============================================================================= + +Yanfly.VA.Scene_Battle_update = Scene_Battle.prototype.update; +Scene_Battle.prototype.update = function() { + Yanfly.VA.Scene_Battle_update.call(this); + this.updateVictoryAftermath(); +}; + +Scene_Battle.prototype.processNextVictoryStep = function() { + var step = this._victorySteps.shift(); + if (step) { + this.processVictoryStep(step.toUpperCase()); + } else { + this.processVictoryFinish(); + } +}; + +Scene_Battle.prototype.processVictoryStep = function(step) { + this._victoryStep = step; +}; + +Scene_Battle.prototype.processVictoryFinish = function() { + this._victoryTitleWindow.close(); + BattleManager.processVictoryFinish(); +}; + +Scene_Battle.prototype.isVictoryStep = function(value) { + return this._victoryStep && this._victoryStep === value; +}; + +Scene_Battle.prototype.updateVictoryAftermath = function() { + if (!BattleManager.isVictoryPhase()) return; + if (!BattleManager.isFinishedVictoryCheer()) return; + this.activateVictoryStep(); + this.updateVictorySteps(); +}; + +Scene_Battle.prototype.activateVictoryStep = function() { + if (this._activateVictoryStep) return; + this._activateVictoryStep = true; + this.createVictoryTitle(); + this._victorySteps = this.createVictorySteps(); + this.createVictorySteps(); + this.processNextVictoryStep(); +}; + +Scene_Battle.prototype.createVictorySteps = function() { + var steps = Yanfly.Param.VAOrder.split(' '); + var array = []; + for (var i = 0; i < steps.length; ++i) { + var step = steps[i]; + if (step.toUpperCase() === 'CUSTOM') { + array = this.addCustomVictorySteps(array); + } else { + array.push(step.toUpperCase()); + } + } + return array; +}; + +Scene_Battle.prototype.addCustomVictorySteps = function(array) { + return array; +}; + +Scene_Battle.prototype.updateVictorySteps = function() { + if (this.isVictoryStep('EXP')) this.updateVictoryExp(); + if (this.isVictoryStep('DROPS')) this.updateVictoryDrops(); +}; + +Scene_Battle.prototype.updateVictoryExp = function() { + if (!this._victoryExpWindow) { + this.createVictoryExp(); + } else if (this._victoryExpWindow.isReady()) { + if (this.victoryTriggerContinue()) this.finishVictoryExp(); + } +}; + +Scene_Battle.prototype.createVictoryTitle = function() { + this._statusWindow.hide(); + this._logWindow.hide(); + this._victoryTitleWindow = new Window_VictoryTitle(); + this.addWindow(this._victoryTitleWindow); + this._victoryTitleWindow.open(); +}; + +Scene_Battle.prototype.createVictoryExp = function() { + this._victoryTitleWindow.refresh(Yanfly.Param.VABattleResults); + this._victoryExpWindow = new Window_VictoryExp(); + this.addWindow(this._victoryExpWindow); + this._victoryExpWindow.open(); +}; + +Scene_Battle.prototype.finishVictoryExp = function() { + SoundManager.playOk(); + this._victoryExpWindow.close(); + this.processNextVictoryStep(); +}; + +Scene_Battle.prototype.updateVictoryDrops = function() { + if (!this._victoryDropWindow) { + this.createVictoryDrop(); + } else if (this._victoryDropWindow.isOpen()) { + if (this.victoryTriggerContinue()) this.finishVictoryDrop(); + } +}; + +Scene_Battle.prototype.createVictoryDrop = function() { + this._victoryTitleWindow.refresh(Yanfly.Param.VABattleDrops); + this._victoryDropWindow = new Window_VictoryDrop(this._victoryTitleWindow); + this.addWindow(this._victoryDropWindow); + this._victoryDropWindow.open(); + this._victoryDropWindow.activate(); + this._victoryDropWindow.select(0); +}; + +Scene_Battle.prototype.finishVictoryDrop = function() { + SoundManager.playOk(); + this._victoryDropWindow.close(); + this.processNextVictoryStep(); +}; + +Scene_Battle.prototype.victoryTriggerContinue = function() { + if (Input.isRepeated('ok') || TouchInput.isRepeated()) return true; + if (Input.isRepeated('cancel')) return true; + return false; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +if (!Yanfly.Util.toGroup) { + Yanfly.Util.toGroup = function(inVal) { + return inVal; + } +}; + +Yanfly.Util.getCount = function(value, arr){ + var occur = 0; + for(var i = 0; i < arr.length; i++){ + if (arr[i] === value) occur++; + } + return occur; +}; + +//============================================================================= +// End of File +//============================================================================= diff --git a/js/plugins/YEP_X_ActSeqPack1.js b/js/plugins/YEP_X_ActSeqPack1.js new file mode 100644 index 0000000..a72b1ea --- /dev/null +++ b/js/plugins/YEP_X_ActSeqPack1.js @@ -0,0 +1,1553 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle Engine Extension - Action Sequence Pack 1 +// YEP_X_ActSeqPack1.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_ActSeqPack1 = true; + +var Yanfly = Yanfly || {}; +Yanfly.ASP1 = Yanfly.ASP1 || {}; +Yanfly.ASP1.version = 1.13; + +//============================================================================= + /*: + * @plugindesc v1.13 (Requires YEP_BattleEngineCore.js) Basic functions are + * added to the Battle Engine Core's action sequences. + * @author Yanfly Engine Plugins + * + * @param Default Volume + * @desc This will be the volume of the BGM played. + * @type number + * @min 0 + * @max 100 + * @default 90 + * + * @param Default Pitch + * @type number + * @min 0 + * @max 100 + * @desc This will be the pitch of the BGM played. + * @default 100 + * + * @param Default Pan + * @type number + * @min 0 + * @max 100 + * @desc This will be the pan of the BGM played. + * @default 0 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * The Action Sequence Pack 1 plugin is an extension plugin for Yanfly Engine + * Plugins' Battle Engine Core. This extension plugin will not work without the + * main plugin. + * + * This extension plugin contains the more basic functions used for customized + * action sequences on a technical scale. Here, you are able to change switches, + * operate variables, add states, change damage rates, and more. + * + * ============================================================================ + * Action Sequences - ala Melody + * ============================================================================ + * + * Battle Engine Core includes Yanfly Engine Melody's Battle Engine system, + * where each individual aspect of the skill and item effects can be controlled + * to a degree. These are called Action Sequences, where each command in the + * action sequence causes the game to perform a distinct individual action. + * + * Each skill and item consists of five different action sequences. They are as + * follows: + * + * 1. Setup Actions + * They prepare the active battler before carrying out the bulk of the action + * and its individual effects. Usually what you see here are things such as the + * active battler moving forward a bit, unsheathing their weapon, etc. This step + * will occur before the active battler expends their skill or item costs. + * + * 2. Whole Actions + * These actions will affect all of the targets simultaneously. Although this + * section does not need to be used, most actions will use this for displaying + * animations upon all enemies. This step occurs after skill and item costs. + * + * 3. Target Actions + * This section will affect all of the targets individually. Used primarily + * for physical attacks that will deliver more personal forms of damage. Actions + * that occur here will not affect other targets unless specifically ordered to + * do so otherwise. + * + * 4. Follow Actions + * This section will dedicate towards cleanup work after the individual + * targeting actions. Here, it'll do things such as removing immortal flags, + * start up common events, and more. + * + * 5. Finish Actions + * This section will have the active battler close up the action sequence. + * Usually stuff like running waits and holds at the last minute for skills and + * items, moving back to place, and others. + * + * Now that you know each of the five steps each action sequence goes through, + * here's the tags you can insert inside of skills and items. Pay attention to + * each tag name. + * + * 1. 5. + * action list action list + * action list action list + * + * + * 2. 3. 4. + * action list action list action list + * action list action list action list + * + * + * They will do their own respective action sets. The methods to insert for the + * action list can be found below in the core of the Help Manual. + * + * Furthermore, to prevent overflooding every single one of your database item's + * noteboxes with action sequence lists, there's a shortcut you can take to copy + * all of the setup actions, whole actions, target actions, follow actions, and + * finish actions with just one line. + * + * + * + * Replace x with "item" or "skill" to set the type for the action list code to + * directly copy. The integer y is then the ID assigned for that particular + * object type. For example, to copy 45th skill's action sequences, the code + * would be for anything that will accept these action + * codes. If you do use this notetag, it will take priority over any custom + * that you've placed in the notebox. + * + * ============================================================================ + * Target Typing + * ============================================================================ + * + * You may notice that in some of the actions below will say "refer to target + * typing" which is this section right here. Here's a quick run down on the + * various targets you may select. + * + * user; This will select the active battler. + * target, targets; These will select the active targets in question. + * actors, existing actors; These will select all living actors. + * all actors; This will select all actors including dead ones. + * dead actors: This will select only dead actors. + * actors not user; This will select all living actors except for the user. + * actor x; This will select the actor in slot x. + * character x; This will select the specific character with actor ID x. + * enemies, existing enemies; This will select all living enemies. + * all enemies; This will select all enemies, even dead. + * dead enemies: This will select only dead enemies. + * enemies not user; This will select all enemies except for the user. + * enemy x; This will select the enemy in slot x. + * friends; This will select the battler's alive allies. + * all friends; This will select the all of battler's allies, even dead. + * dead friends; This will select the battler's dead allies. + * friends not user; This will select the battler's allies except itself. + * friend x: This will select the battler's ally in slot x. + * opponents; This will select the battler's alive opponents. + * all opponents; This will select the all of the battler's opponents. + * dead opponents; This will select the battler's dead opponents. + * opponent x: This will select the battler's opponent in slot x. + * all alive; Selects all living actors and enemies. + * all members; Selects all living and dead actors and enemies. + * all dead; Selects all dead actors and enemies. + * all not user; This will select all living battlers except user. + * focus; Selects the active battler and its targets. + * not focus; Selects everything but the active battler and its targets. + * + * ============================================================================ + * Action Sequences - Action List + * ============================================================================ + * + * The following contains a list of the actions you can use inside the five + * action sequences. Each action has a unique function and requires certain + * formats to operate properly. + * + *============================================================================= + * ACTION ANIMATION: (target), (mirror) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Plays the animation assigned to the skill/item. The animation will + * automatically select the skill's/item's assigned targets. If 'target' is + * used, it will specify a target to play the animation on. If 'mirror' is + * used, it will mirror the animation. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: action animation + * action animation: target + * action animation: user, mirror + *============================================================================= + * + *============================================================================= + * ACTION COMMON EVENT + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Plays the common event found within the skill's/item's traits list. This + * will only play the last common event on the list, following the game + * engine's original process. Nothing else will continue on the action list + * until the common event is finished (unless it is a forced action, in which + * case, it will wait until the action is complete first). + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: action common event + *============================================================================= + * + *============================================================================= + * ACTION EFFECT: target + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the target(s) to take damage/healing from the skill/item and + * incurs any changes made to the target(s) such as buffs and states. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: action effect + *============================================================================= + * + *============================================================================= + * ADD stat BUFF: target, (turns), (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Affects the target with 'stat' buff. Replace 'stat' with 'hp', 'mp', 'atk', + * 'def', 'mat', 'mdf', 'agi', or 'luk'. If you include a number after the + * target, it will buff the target by that many turns. Include 'show' and it + * will show the target getting the buff applied in the battle log. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: add atk buff: user, 3, show + * add def buff: target, 8 + *============================================================================= + * + *============================================================================= + * ADD stat DEBUFF: target, (turns), (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Affects the target with 'stat' debuff. Replace 'stat' with 'hp', 'mp', + * 'atk', 'def', 'mat', 'mdf', 'agi', or 'luk'. If you include a number after + * the target, it will debuff the target by that many turns. Include 'show' and + * it will show the target getting the debuff applied in the battle log. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: add atk debuff: user, 3, show + * add def debuff: target, 8 + *============================================================================= + * + *============================================================================= + * ADD STATE X: target, (show) + * ADD STATE X, Y, Z: target (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Affects the target with X state (including Y and Z if used in that format). + * If 'show' is included, it will display any state related messages. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: add state 5: target + * add state 6, 7, 8: user, show + *============================================================================= + * + *============================================================================= + * ANIMATION X: target, (mirror) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Plays animation X on target. 'Mirror' will cause the animation to appear + * mirrored. Keep in mind that animations played on actors will automatically + * be mirrored and setting the mirror option will reverse it and have it appear + * unmirrored. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: animation 5: user + * animation 6: target, mirror + *============================================================================= + * + *============================================================================= + * ANIMATION WAIT: X + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits x animaiton frames. Each frame for an animation does not last one game + * frame, but instead, several. To make life easier, you can use this to have + * the game wait x frames played for the animation. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: animation 5: user + * animation 6: target, mirror + *============================================================================= + * + *============================================================================= + * BGM: STOP + * BGM: MEMORIZE + * BGM: MEMORY + * BGM: filename, (volume), (pitch), (pan) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Changes the current background music at hand. 'Stop' will stop any BGM from + * playing. 'Memorize' will memorize the current BGM. 'Memory' will replay the + * memorized BGM if there is one playing. If you choose a filename (without the + * filename extensions), the game will play that BGM instead. Using this + * option opens up access to the volume, pitch, and pan control, all of which + * are optional to use. If no values are inputed for volume, pitch, and pan, + * the game will use the settings in this plugin's parameters. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: bgm: stop + * bgm: memorize + * bgm: memory + * bgm: Battle7 + * bgm: Theme2, 80, 100, 0 + *============================================================================= + * + *============================================================================= + * BGS: STOP + * BGS: MEMORIZE + * BGS: MEMORY + * BGS: filename, (volume), (pitch), (pan) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Changes the current background sound at hand. 'Stop' will stop any BGS from + * playing. 'Memorize' will memorize the current BGS. 'Memory' will replay the + * memorized BGS if there is one playing. If you choose a filename (without the + * filename extensions), the game will play that BGS instead. Using this + * option opens up access to the volume, pitch, and pan control, all of which + * are optional to use. If no values are inputed for volume, pitch, and pan, + * the game will use the settings in this plugin's parameters. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: bgs: stop + * bgs: memorize + * bgs: memory + * bgs: City + * bgs: Darkness, 80, 100, 0 + *============================================================================= + * + *============================================================================= + * BREAK ACTION + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will force the remainder of the action sequences for the part of the + * skill/item to shut down and be skipped. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: break action + *============================================================================= + * + *============================================================================= + * CAST ANIMATION + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Plays an animation on the skill's user. Will not occur if the action is + * an item or the user's default normal attack. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: cast animation + *============================================================================= + * + *============================================================================= + * CLEAR BATTLE LOG + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Clears all the messages at the top of the screen. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: clear battle log + *============================================================================= + * + *============================================================================= + * CHANGE SWITCH X: on/off/toggle/switch z + * CHANGE SWITCH X..Y: on/off/toggle/switch z + * CHANGE SWITCH X TO Y: on/off/toggle/switch z + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Changes Game Switch X to on, off, toggle (switching between on/off), or + * to whatever value the switch y is. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: change switch 1: on + * change switch 2..4: off + * change switch 5 to 8: toggle + * change switch 9: switch 5 + *============================================================================= + * + *============================================================================= + * CHANGE VARIABLE X = Y + * CHANGE VARIABLE X += Y + * CHANGE VARIABLE X -= Y + * CHANGE VARIABLE X *= Y + * CHANGE VARIABLE X /= Y + * CHANGE VARIABLE X %= Y + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Changes variable X in the middle of the action sequence to be modified + * by value Y. Y can be either an integer or a piece of code. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: change variable 1 = 2 + * change variable 3 += 4 + * change variable 5 -= 6 + * change variable 7 *= 8 + * change variable 9 /= 10 + * change variable 11 %= 12 + *============================================================================= + * + *============================================================================= + * COLLAPSE: target, (force) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * If the target is to be dead at this point, this will be the point in the + * action sequence where you can promt the game to kill the target as long + * as the target has 0 HP. If you want to force the death of the target, + * include the 'force' command after the targets. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: collapse: user + * collapse: target, force + *============================================================================= + * + *============================================================================= + * COMMON EVENT: X + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Plays common event X at that point in the action sequence. Nothing else + * will continue until the common event is finished (unless it is a forced + * action, in which case, it will wait until the action is complete first). + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: common event: 1 + *============================================================================= + * + *============================================================================= + * DEATH BREAK + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * If a user were to die for any reason during the middle of the skill + * (either via counter attack or reflection), this will force the remainder + * of the action sequences for the part of the skill/item to shut down and + * be skipped. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: death break + *============================================================================= + * + *============================================================================= + * DISPLAY ACTION + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Displays the action's name at the top of the battle log. It will remain + * there until the battle log is cleared. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: display action + *============================================================================= + * + *============================================================================= + * EVAL: code + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * For those who'd like to do something that the current Battle Engine doesn't + * support, you can use an eval function to have a piece of code occur. Users + * beware, for those unfamiliar with JavaScript should avoid handling this + * action sequence command. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: eval: $gameParty.loseItem($dataItems[3], 10) + *============================================================================= + * + *============================================================================= + * GAIN ITEM X: Y LOSE ITEM X: Y + * GAIN WEAPON X: Y LOSE WEAPON X: Y + * GAIN ARMOR X: Y LOSE ARMOR X: Y + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Your party will gain/lose item x, weapon x, or armor x in the amount of + * y. If you choose to omit y, it will default to 1. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: gain item 1: 20 + * lose weapon 2 + * gain armor 3: 50 + *============================================================================= + * + *============================================================================= + * GOLD +x + * GOLD -x + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Your party will gain/lose gold in the middle of battle by x amount. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: gold +2000 + * gold -500 + *============================================================================= + * + *============================================================================= + * IF ... ELSE STATEMENTS + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * For those familiar with programming, you can use if...else statements to + * perform different actions based on different conditions. Use 'if' to + * specify a block of code to be executed, if a specified condition is true. + * Use 'else' to specify a block of code to be executed, if the same + * condition is false. Use 'else if' to specify a new condition to test, if + * the first condition is false. Use 'end' to specify where the conditions + * are to end. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: + * if $gameSwitches.value(1) + * action effect + * else if $gameSwitches.value(2) + * action effect + * action effect + * else + * action effect + * action effect + * action effect + * end + * + * *Note: You do not have to indent the code in between to work. It just + * looks better that way in your action sequences. + *============================================================================= + * + *============================================================================= + * IMMORTAL: targets, true/false + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Sets the targets to a state of immortality so that they don't die in the + * middle of an attack. This is to ensure every action effect goes through. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: immortal: targets true + *============================================================================= + * + *============================================================================= + * HP +X: target, (show) + * HP -X: target, (show) + * HP +X%: target, (show) + * HP -X%: target, (show) + * HP +VARIABLE X: target, (show) + * HP -VARIABLE X: target, (show) + * HP +VARIABLE X%: target, (show) + * HP -VARIABLE X%: target, (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Target(s) gains HP equal to X values. To show the popup, insert 'show' + * after the target in the action sequence line. Including 'show' is + * entirely optional. If 'show' is omitted, no popup will be displayed. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: hp +500: user + * hp -variable 5: target + * hp +25%: target + * hp -variable 7: user + *============================================================================= + * + *============================================================================= + * ME: STOP + * ME: filename, (volume), (pitch), (pan) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the battle to play a music fanfare. 'Stop' will stop any ME from + * playing. If you choose a filename (without the filename extensions), the + * game will play that ME instead. Using this option opens up access to the + * volume, pitch, and pan control, all of which are optional to use. If no + * values are inputed for volume, pitch, and pan, the game will use the + * settings in this plugin's parameters. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: me: stop + * me: Victory1 + * me: Darkness, 80, 100, 0 + *============================================================================= + * + *============================================================================= + * MOTION WAIT: target + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Makes the game wait 12 frames if the target(s) performing the action is an + * actor. If the target(s) is not an actor, no waiting will be done. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: motion wait: user + *============================================================================= + * + *============================================================================= + * MP +X: target, (show) + * MP -X: target, (show) + * MP +X%: target, (show) + * MP -X%: target, (show) + * MP +VARIABLE X: target, (show) + * MP -VARIABLE X: target, (show) + * MP +VARIABLE X%: target, (show) + * MP -VARIABLE X%: target, (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Target(s) gains MP equal to X values. To show the popup, insert 'show' + * after the target in the action sequence line. Including 'show' is + * entirely optional. If 'show' is omitted, no popup will be displayed. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: mp +500: user + * mp -variable 5: target + * mp +25%: target + * mp -variable 7: user + *============================================================================= + * + *============================================================================= + * PERFORM ACTION + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes actors to step forward and swing their weapon, thrust it, however + * the motion that is determined will be automatically done by the game. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: perform action + *============================================================================= + * + *============================================================================= + * PERFORM FINISH + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes actor to move back to its home spot. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: perform finish + *============================================================================= + * + *============================================================================= + * PERFORM START + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes actor to move forward from its home spot. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: perform start + *============================================================================= + * + *============================================================================= + * REFRESH STATUS + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Refreshes the status window in the middle of an action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: refresh status + *============================================================================= + * + *============================================================================= + * REMOVE stat BUFF: target, (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Removes the 'stat' buff from target. Replace 'stat' with 'hp', 'mp', 'atk', + * 'def', 'mat', 'mdf', 'agi', or 'luk'. Include 'show' and it will show the + * target getting the buff removed in the battle log. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: remove atk buff: user, show + * remove def buff: target + *============================================================================= + * + *============================================================================= + * REMOVE stat DEBUFF: target, (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Removes the 'stat' debuff from target. Replace 'stat' with 'hp', 'mp', + * 'atk', 'def', 'mat', 'mdf', 'agi', or 'luk'. Include 'show' and it will + * show the target getting the debuff removed in the battle log. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: remove atk debuff: user, show + * remove def debuff: target + *============================================================================= + * + *============================================================================= + * REMOVE STATE X: target (show) + * REMOVE STATE X, Y, Z: target (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Removes X state (including Y and Z if used in that format) from target. + * If 'show' is included, it will display any state related messages. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: remove state 5: target + * remove state 6, 7, 8: user, show + *============================================================================= + * + *============================================================================= + * SE: filename, (volume), (pitch), (pan) + * SE: PLAY OK + * SE: PLAY CURSOR + * SE: PLAY CANCEL + * SE: PLAY BUZZER + * SE: PLAY EQUIP + * SE: PLAY SAVE + * SE: PLAY LOAD + * SE: PLAY BATTLE START + * SE: PLAY ESCAPE + * SE: PLAY ENEMY ATTACK + * SE: PLAY ENEMY DAMAGE + * SE: PLAY ENEMY COLLAPSE + * SE: PLAY BOSS COLLAPSE 1 + * SE: PLAY BOSS COLLAPSE 2 + * SE: PLAY ACTOR DAMAGE + * SE: PLAY ACTOR COLLAPSE + * SE: PLAY RECOVERY + * SE: PLAY MISS + * SE: PLAY EVASION + * SE: PLAY MAGIC EVASION + * SE: PLAY REFLECTION + * SE: PLAY SHOP + * SE: PLAY USE ITEM + * SE: PLAY USE SKILL + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the battle to play a Sound Effect. If you choose a filename (without + * the filename extensions), the game will play that ME instead. Using this + * option opens up access to the volume, pitch, and pan control, all of which + * are optional to use. If no values are inputed for volume, pitch, and pan, + * the game will use the settings in this plugin's parameters. Using the action + * sequences with 'play x' in them will cause the game to play a system sound + * set within RPG Maker's database. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: se: play enemy attack + * se: Ice1 + * se: Laser2, 80, 100, 0 + *============================================================================= + * + *============================================================================= + * TP +X: target, (show) + * TP -X: target, (show) + * TP +X%: target, (show) + * TP -X%: target, (show) + * TP +VARIABLE X: target, (show) + * TP -VARIABLE X: target, (show) + * TP +VARIABLE X%: target, (show) + * TP -VARIABLE X%: target, (show) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Target(s) gains TP equal to X values. To show the popup, insert 'show' + * after the target in the action sequence line. Including 'show' is + * entirely optional. If 'show' is omitted, no popup will be displayed. For + * TP to actually show popups, another plugin is needed to display TP popups. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: tp +500: user + * tp -variable 5: target + * tp +25%: target + * tp -variable 7: user + *============================================================================= + * + *============================================================================= + * WAIT: frames + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Makes the game wait a certain amount of frames before going on to the + * next action in the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait: 60 + *============================================================================= + * + *============================================================================= + * WAIT FOR ANIMATION + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all animations to finish before going on to the next action in + * the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for animation + *============================================================================= + * + *============================================================================= + * WAIT FOR EFFECT + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all effects to finish playing before continuing on. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for effect + *============================================================================= + * + *============================================================================= + * WAIT FOR MOVEMENT + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all battler movements to finish before going on to the next + * action in the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for movement + *============================================================================= + * + *============================================================================= + * WAIT FOR NEW LINE + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for a new line to appear in the log window before going on to the + * next action in the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for new line + *============================================================================= + * + *============================================================================= + * WAIT FOR POPUPS + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all popups to finish playing before going on to the next action. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for popups + *============================================================================= + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.13: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.12: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.11: + * - Lunatic Mode fail safes added. + * + * Version 1.10a: + * - Changed the 'Change Variable' action sequence to read more effectively. + * - Documentation update for 'Action Common Event' and 'Common Event' to + * indicate that they will not work immediately if used as a forced action + * since another event is already running. + * + * Version 1.09: + * - Fixed a bug that didn't allow for HP and MP buff/debuff removal. + * + * Version 1.08: + * - Added 'Break Action' action sequence effect to completely cancel out all + * of the remaining action effects. + * + * Version 1.07: + * - Fixed a bug with the forcing a Collapse action sequence. + * + * Version 1.06: + * - If using the Add State action sequence to add the Death state, it will + * remove immortality settings. + * + * Version 1.05: + * - Optimized status window to refresh at a minimum. + * + * Version 1.04: + * - Updated help file to include Character X for target typing. + * + * Version 1.03: + * - Fixed a bug that didn't make the sounds played work properly (again). + * + * Version 1.02: + * - Fixed a bug that didn't make the sounds played work properly. + * + * Version 1.01: + * - Fixed a small bug that didn't allow Change Variable to work properly with + * evaluated strings. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +//============================================================================= +// Parameters +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_ActSeqPack1'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.SoundVolume = Number(Yanfly.Parameters['Default Volume']); +Yanfly.Param.SoundPitch = Number(Yanfly.Parameters['Default Pitch']); +Yanfly.Param.SoundPan = Number(Yanfly.Parameters['Default Pan']); + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.ASP1.BattleManager_processActionSequence = + BattleManager.processActionSequence; +BattleManager.processActionSequence = function(actionName, actionArgs) { + // ADD X BUFF + if (actionName.match(/ADD[ ](.*)[ ]BUFF/i)) { + return this.actionAddBuff(actionName, actionArgs); + } + // ADD X DEBUFF + if (actionName.match(/ADD[ ](.*)[ ]DEBUFF/i)) { + return this.actionAddDebuff(actionName, actionArgs); + } + // ADD STATE X + if (actionName.match(/(?:ADD_STATE|ADD STATE)[ ](\d+(?:\s*,\s*\d+)*)/i)) { + return this.actionAddState(actionName, actionArgs); + } + // ANIMATION X + if (actionName.match(/ANIMATION[ ](\d+)/i)) { + return this.actionAnimation(parseInt(RegExp.$1), actionArgs); + } + // BGM, MUSIC, SONG + if (['BGM', 'MUSIC', 'SONG'].contains(actionName)) { + return this.actionBgmPlay(actionArgs); + } + // BGS, AMBIENCE + if (['BGS', 'AMBIENCE'].contains(actionName)) { + return this.actionBgsPlay(actionArgs); + } + // BREAK ACTION + if (actionName === 'BREAK ACTION') { + return this.actionBreakAction(); + } + // COLLAPSE: target, (force) + if (actionName === 'COLLAPSE') { + return this.actionCollapse(actionArgs); + } + // COMMON EVENT: event id + if (actionName === 'COMMON EVENT') { + return this.actionCommonEvent(actionArgs[0]); + } + // CHANGE SWITCH X + if (actionName.match(/CHANGE[ ]SWITCH[ ](.*)/i)) { + return this.actionChangeSwitch(actionName, actionArgs); + } + // CHANGE VARIABLE X + if (actionName.match(/CHANGE[ ]VARIABLE[ ](.*)/i)) { + return this.actionChangeVariable(actionName); + } + // EVAL, SCRIPT + if (['EVAL', 'SCRIPT'].contains(actionName)) { + return this.actionEval(actionArgs); + } + // GAIN ITEM (item, weapon, armor) X + if (actionName.match(/GAIN[ ](.*)[ ](\d+)/i) || + actionName.match(/LOSE[ ](.*)[ ](\d+)/i)) { + return this.actionGainItem(actionName, actionArgs); + } + // GOLD +/- VALUE + if (actionName.match(/GOLD[ ]([\+\-]\d+)/i)) { + return this.actionGoldModify(parseInt(RegExp.$1)); + } + // ME, FANFARE + if (['ME', 'FANFARE'].contains(actionName)) { + return this.actionMePlay(actionArgs); + } + // REFRESH STATUS, REFRESH WINDOW + if (['REFRESH STATUS', 'REFRESH WINDOW'].contains(actionName)) { + return this.actionRefreshStatus(); + } + // REMOVE X BUFF + if (actionName.match(/REMOVE[ ](.*)[ ]BUFF/i)) { + return this.actionRemoveBuff(actionName, actionArgs); + } + // REMOVE X DEBUFF + if (actionName.match(/REMOVE[ ](.*)[ ]DEBUFF/i)) { + return this.actionRemoveDebuff(actionName, actionArgs); + } + // REMOVE STATE X + if + (actionName.match(/(?:REMOVE_STATE|REMOVE STATE)[ ](\d+(?:\s*,\s*\d+)*)/i)) { + return this.actionRemoveState(actionName, actionArgs); + } + // SE, SOUND, SFX + if (['SE', 'SOUND', 'SFX'].contains(actionName)) { + return this.actionSePlay(actionArgs); + } + // HP +/- VALUE + if (actionName.match(/HP[ ](.*)/i)) { + return this.actionHpModify(actionName, actionArgs); + } + // MP +/- VALUE + if (actionName.match(/MP[ ](.*)/i)) { + return this.actionMpModify(actionName, actionArgs); + } + // TP +/- VALUE + if (actionName.match(/TP[ ](.*)/i)) { + return this.actionTpModify(actionName, actionArgs); + } + return Yanfly.ASP1.BattleManager_processActionSequence.call(this, + actionName, actionArgs); +}; + +BattleManager.getParamId = function(stat) { + switch (stat) { + case 'HP': + case 'MAXHP': + case 'MAX HP': + return 0; + break; + case 'MP': + case 'MAXMP': + case 'MAX MP': + case 'SP': + case 'MAXSP': + case 'MAX SP': + return 1; + break; + case 'ATK': + case 'STR': + return 2; + break; + case 'DEF': + return 3; + break; + case 'MAT': + case 'INT' || 'SPI': + return 4; + break; + case 'MDF': + case 'RES': + return 5; + break; + case 'AGI': + case 'SPD': + return 6; + break; + case 'LUK': + return 7; + break; + } + return -1; +}; + +BattleManager.actionAddBuff = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + if (actionName.match(/ADD[ ](.*)[ ]BUFF/i)) { + var paramId = this.getParamId(String(RegExp.$1).toUpperCase()); + } else { + return true; + } + if (actionArgs[1] && parseInt(actionArgs[1]) > 0) { + var turns = parseInt(actionArgs[1]); + } else { + var turns = 5; + } + if (paramId < 0) return true; + targets.forEach(function(target) { + target.addBuff(paramId, turns); + if (show) this._logWindow.displayActionResults(this._subject, target); + }, this); + return true; +}; + +BattleManager.actionAddDebuff = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + if (actionName.match(/ADD[ ](.*)[ ]DEBUFF/i)) { + var paramId = this.getParamId(String(RegExp.$1).toUpperCase()); + } else { + return true; + } + if (actionArgs[1] && parseInt(actionArgs[1]) > 0) { + var turns = parseInt(actionArgs[1]); + } else { + var turns = 5; + } + if (paramId < 0) return true; + targets.forEach(function(target) { + target.addDebuff(paramId, turns); + if (show) this._logWindow.displayActionResults(this._subject, target); + }, this); + return true; +}; + +BattleManager.actionAddState = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + if (actionName.match(/(?:ADD_STATE|ADD STATE)[ ](\d+(?:\s*,\s*\d+)*)/i)) { + var states = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + } else { + return true; + } + targets.forEach(function(target) { + for (var i = 0; i < states.length; ++i) { + stateId = states[i]; + if (stateId === target.deathStateId()) { + if (target._prevImmortalState === false) target.forceRemoveImmortal(); + } + target.addState(stateId); + if (show) this._logWindow.displayActionResults(this._subject, target); + } + }, this); + return true; +}; + +BattleManager.actionAnimation = function(aniId, actionArgs) { + if (aniId <= 0) return; + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var mirror = false; + if (actionArgs[1] && actionArgs[1].toUpperCase() === 'MIRROR') mirror = true; + this._logWindow.showNormalAnimation(targets, aniId, mirror); + return true; +}; + +BattleManager.actionBgmPlay = function(actionArgs) { + if (actionArgs.length < 1) return true; + if (actionArgs[0].toUpperCase() === 'STOP') { + AudioManager.stopBgm(); + } else if (actionArgs[0].toUpperCase() === 'MEMORIZE') { + this._battleMemorizedBgm = AudioManager.saveBgm(); + return true; + } else if (actionArgs[0].toUpperCase() === 'MEMORY') { + if (this._battleMemorizedBgm) { + AudioManager.replayBgm(this._battleMemorizedBgm); + } + } else { + var name = actionArgs[0]; + if (!name) return true; + var vol = actionArgs[1] || Yanfly.Param.SoundVolume; + var pitch = actionArgs[2] || Yanfly.Param.SoundPitch; + var pan = actionArgs[3] || Yanfly.Param.SoundPan; + var bgm = { + name: name, + volume: vol, + pitch: pitch, + pan: pan + }; + AudioManager.playBgm(bgm); + } + return true; +}; + +BattleManager.actionBgsPlay = function(actionArgs) { + if (actionArgs.length < 1) return true; + if (actionArgs[0].toUpperCase() === 'STOP') { + AudioManager.stopBgs(); + } else if (actionArgs[0].toUpperCase() === 'MEMORIZE') { + this._battleMemorizedBgs = AudioManager.saveBgs(); + return true; + } else if (actionArgs[0].toUpperCase() === 'MEMORY') { + if (this._battleMemorizedBgs) { + AudioManager.replayBgs(this._battleMemorizedBgs); + } + } else { + var name = actionArgs[0]; + if (!name) return true; + var vol = actionArgs[1] || Yanfly.Param.SoundVolume; + var pitch = actionArgs[2] || Yanfly.Param.SoundPitch; + var pan = actionArgs[3] || Yanfly.Param.SoundPan; + var bgs = { + name: name, + volume: vol, + pitch: pitch, + pan: pan + }; + AudioManager.playBgs(bgs); + } + return true; +}; + +BattleManager.actionBreakAction = function() { + this._targets = []; + this._actionList = []; + this._individualTargets = []; + this._phase = 'phaseChange'; + return false; +}; + +BattleManager.actionCollapse = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + var force = false; + if (actionArgs[1]) var force = (actionArgs[1].toUpperCase() === 'FORCE'); + targets.forEach(function(target) { + if (force) { + target.removeImmortal(); + target.addState(target.deathStateId()); + } + if (target.isDeathStateAffected()) target.performCollapse(); + + }, this); + return false; +}; + +BattleManager.actionCommonEvent = function(id) { + if ($gameTroop.isEventRunning()) { + var ev = $dataCommonEvents[id]; + if (!ev) return; + var list = ev.list; + var interpreter = $gameTroop._interpreter; + interpreter.setupChild(list, 0); + } else { + $gameTemp.reserveCommonEvent(id); + } + return false; +}; + +BattleManager.actionChangeSwitch = function(actionName, actionArgs) { + var subject = this._subject; + var user = this._subject; + var target = this._targets[0]; + var targets = this._targets; + var action = this._action; + var item = this._action.item(); + var switches = []; + if (actionName.match(/SWITCH[ ](\d+)/i)) { + switches = [parseInt(RegExp.$1)]; + } else if (actionName.match(/SWITCH[ ](\d+)..(\d+)/i)) { + switches = [getRange(parseInt(RegExp.$1), parseInt(RegExp.$2))]; + } else if (actionName.match(/SWITCH[ ](\d+)[ ]TO[ ](\d+)/i)) { + switches = [getRange(parseInt(RegExp.$1), parseInt(RegExp.$2))]; + } else { + return true; + } + var result = actionArgs[0].toUpperCase(); + var value; + if (['ON', 'TRUE'].contains(result)) { + value = true; + } else if (['OFF', 'FALSE'].contains(result)) { + value = false; + } else if (['TOGGLE', 'OPPOSITE', 'REVERSE'].contains(result)) { + value = 'toggle'; + } else if (result.match(/SWITCH[ ](\d+)/i)) { + value = $gameSwitches.value(parseInt(RegExp.$1)); + } + switches.forEach(function(switchId) { + if (value === 'toggle') { + $gameSwitches.setValue(switchId, !$gameSwitches.value(switchId)); + } else { + $gameSwitches.setValue(switchId, value); + } + }, this); + return true; +}; + +BattleManager.actionChangeVariable = function(actionName) { + var cV1 = + /CHANGE[ ](?:VARIABLE|VAR)[ ](\d+)[ ](.*)[ ](?:VARIABLE|VAR)[ ](\d+)/i; + var cV2 = /CHANGE[ ](?:VARIABLE|VAR)[ ](\d+)[ ](.*?)[ ](.*)/i; + var subject = this._subject; + var user = this._subject; + var target = this._targets[0]; + var targets = this._targets; + var action = this._action; + var item = this._action.item(); + if (this._actSeq[0].match(cV1)) { + var mainVar = parseInt(RegExp.$1); + var operation = String(RegExp.$2); + var editVar = $gameVariables.value(parseInt(RegExp.$3)); + } else if (this._actSeq[0].match(cV2)) { + var mainVar = parseInt(RegExp.$1); + var operation = String(RegExp.$2); + var editVar = eval(String(RegExp.$3)); + } else { + return true; + } + var mainValue = $gameVariables.value(mainVar); + if (['='].contains(operation)) { + $gameVariables.setValue(mainVar, eval(editVar)); + } else if (['+=', '+'].contains(operation)) { + $gameVariables.setValue(mainVar, mainValue + eval(editVar)); + } else if (['-=', '-'].contains(operation)) { + $gameVariables.setValue(mainVar, mainValue - eval(editVar)); + } else if (['*=', '*'].contains(operation)) { + $gameVariables.setValue(mainVar, mainValue * eval(editVar)); + } else if (['/=', '/'].contains(operation)) { + $gameVariables.setValue(mainVar, mainValue / eval(editVar)); + } else if (['%=', '%'].contains(operation)) { + $gameVariables.setValue(mainVar, mainValue % eval(editVar)); + } + return true; +}; + +BattleManager.actionEval = function(actionArgs) { + if (actionArgs.length < 1) return true; + var subject = this._subject; + var user = this._subject; + var target = this._targets[0]; + var targets = this._targets; + var action = this._action; + var item = this._action.item(); + var text = String(actionArgs[0]); + for (var i = 1; i < actionArgs.length; ++i) { + text = text + ', ' + String(actionArgs[i]); + } + try { + eval(text); + } catch (e) { + Yanfly.Util.displayError(e, text, 'ACTION SEQUENCE EVAL ERROR'); + } + return false; +}; + +BattleManager.actionGainItem = function(actionName, actionArgs) { + var gainItem; + var type; + var itemId; + if (actionName.match(/GAIN[ ](.*)[ ](\d+)/i)) { + gainItem = true; + type = String(RegExp.$1).toUpperCase(); + itemId = parseInt(RegExp.$2); + } else if (actionName.match(/LOSE[ ](.*)[ ](\d+)/i)) { + gainItem = false; + type = String(RegExp.$1).toUpperCase(); + itemId = parseInt(RegExp.$2); + } else { + return true; + } + var item; + if (type === 'ITEM') { + item = $dataItems[itemId]; + } else if (['WPN', 'WEAPON'].contains(type)) { + item = $dataWeapons[itemId]; + } else if (['ARM', 'ARMOR', 'ARMOUR'].contains(type)) { + item = $dataArmors[itemId]; + } else { + return true; + } + var amount = Math.max(1, parseInt(actionArgs[0])); + if (isNaN(amount)) amount = 1; + if (gainItem) $gameParty.gainItem(item, amount); + if (!gainItem) $gameParty.loseItem(item, amount); + return true; +}; + +BattleManager.actionGoldModify = function(value) { + $gameParty.gainGold(value); + return true; +}; + +BattleManager.actionHpModify = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var change; + var percent; + if (actionName.match(/HP[ ]([+-])(?:VARIABLE|VAR)[ ](\d+)/i)) { + change = parseInt($gameVariables.value(parseInt(RegExp.$2))); + if (String(RegExp.$1) === '-') change *= -1; + percent = false; + } else if + (actionName.match(/HP[ ]([+-])(?:VARIABLE|VAR)[ ](\d+)([%%])/i)) { + change = parseInt($gameVariables.value(parseInt(RegExp.$2))); + if (String(RegExp.$1) === '-') change *= -1; + percent = true; + } else if (actionName.match(/HP[ ]([\+\-]\d+)([%%])/i)) { + change = parseInt(RegExp.$1); + percent = true; + } else if (actionName.match(/HP[ ]([\+\-]\d+)/i)) { + change = parseInt(RegExp.$1); + percent = false; + } else { + return false; + } + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + var value; + targets.forEach(function(target) { + target.clearResult(); + value = percent ? (target.mhp * change * 0.01) : change; + target.gainHp(parseInt(value)); + if (show) { + target.startDamagePopup(); + this._logWindow.displayActionResults(this._subject, target); + } + }, this); + return true; +}; + +BattleManager.actionMePlay = function(actionArgs) { + if (actionArgs.length < 1) return true; + if (actionArgs[0].toUpperCase() === 'STOP') { + AudioManager.stopMe(); + } else { + var name = actionArgs[0]; + if (!name) return true; + var vol = actionArgs[1] || Yanfly.Param.SoundVolume; + var pitch = actionArgs[2] || Yanfly.Param.SoundPitch; + var pan = actionArgs[3] || Yanfly.Param.SoundPan; + var me = { + name: name, + volume: vol, + pitch: pitch, + pan: pan + }; + AudioManager.playMe(me); + } + return true; +}; + +BattleManager.actionMpModify = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var change; + var percent; + if (actionName.match(/MP[ ]([+-])(?:VARIABLE|VAR)[ ](\d+)/i)) { + change = parseInt($gameVariables.value(parseInt(RegExp.$2))); + if (String(RegExp.$1) === '-') change *= -1; + percent = false; + } else if + (actionName.match(/MP[ ]([+-])(?:VARIABLE|VAR)[ ](\d+)([%%])/i)) { + change = parseInt($gameVariables.value(parseInt(RegExp.$2))); + if (String(RegExp.$1) === '-') change *= -1; + percent = true; + } else if (actionName.match(/MP[ ]([\+\-]\d+)([%%])/i)) { + change = parseInt(RegExp.$1); + percent = true; + } else if (actionName.match(/MP[ ]([\+\-]\d+)/i)) { + change = parseInt(RegExp.$1); + percent = false; + } else { + return false; + } + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + var value; + targets.forEach(function(target) { + target.clearResult(); + value = percent ? (target.mmp * change * 0.01) : change; + target.gainMp(parseInt(value)); + if (show) { + target.startDamagePopup(); + this._logWindow.displayActionResults(this._subject, target); + } + }, this); + return true; +}; + +BattleManager.actionRefreshStatus = function() { + this._statusWindow.refresh(); + return false; +}; + +BattleManager.actionRemoveBuff = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + if (actionName.match(/REMOVE[ ](.*)[ ]BUFF/i)) { + var paramId = this.getParamId(String(RegExp.$1).toUpperCase()); + } else { + return true; + } + if (paramId < 0) return true; + targets.forEach(function(target) { + if (target.isBuffAffected(paramId)) { + target.removeBuff(paramId); + if (show) this._logWindow.displayActionResults(this._subject, target); + } + }, this); + return true; +}; + +BattleManager.actionRemoveDebuff = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + if (actionName.match(/REMOVE[ ](.*)[ ]DEBUFF/i)) { + var paramId = this.getParamId(String(RegExp.$1).toUpperCase()); + } else { + return true; + } + if (paramId < 0) return true; + targets.forEach(function(target) { + if (target.isDebuffAffected(paramId)) { + target.removeBuff(paramId); + if (show) this._logWindow.displayActionResults(this._subject, target); + } + }, this); + return true; +}; + +BattleManager.actionRemoveState = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + if + (actionName.match(/(?:REMOVE_STATE|REMOVE STATE)[ ](\d+(?:\s*,\s*\d+)*)/i)) { + var states = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']'); + } else { + return true; + } + targets.forEach(function(target) { + for (var i = 0; i < states.length; ++i) { + stateId = states[i]; + if (target.isStateAffected(stateId)) { + target.removeState(stateId); + if (show) this._logWindow.displayActionResults(this._subject, target); + } + } + }, this); + return true; +}; + +BattleManager.actionSePlay = function(actionArgs) { + if (actionArgs.length < 1) return true; + if (actionArgs[0].toUpperCase() === 'PLAY CURSOR') { + SoundManager.playCursor(); + } else if (actionArgs[0].toUpperCase() === 'PLAY OK') { + SoundManager.playOk(); + } else if (actionArgs[0].toUpperCase() === 'PLAY CANCEL') { + SoundManager.playCancel(); + } else if (actionArgs[0].toUpperCase() === 'PLAY BUZZER') { + SoundManager.playBuzzer(); + } else if (actionArgs[0].toUpperCase() === 'PLAY EQUIP') { + SoundManager.playEquip(); + } else if (actionArgs[0].toUpperCase() === 'PLAY SAVE') { + SoundManager.playSave(); + } else if (actionArgs[0].toUpperCase() === 'PLAY LOAD') { + SoundManager.playLoad(); + } else if (actionArgs[0].toUpperCase() === 'PLAY BATTLE START') { + SoundManager.playBattleStart(); + } else if (actionArgs[0].toUpperCase() === 'PLAY ESCAPE') { + SoundManager.playEscape(); + } else if (actionArgs[0].toUpperCase() === 'PLAY ENEMY ATTACK') { + SoundManager.playEnemyAttack(); + } else if (actionArgs[0].toUpperCase() === 'PLAY ENEMY DAMAGE') { + SoundManager.playEnemyDamage(); + } else if (actionArgs[0].toUpperCase() === 'PLAY ENEMY COLLAPSE') { + SoundManager.playEnemyCollapse(); + } else if (actionArgs[0].toUpperCase() === 'PLAY BOSS COLLAPSE 1') { + SoundManager.playBossCollapse1(); + } else if (actionArgs[0].toUpperCase() === 'PLAY BOSS COLLAPSE 2') { + SoundManager.playBossCollapse2(); + } else if (actionArgs[0].toUpperCase() === 'PLAY ACTOR DAMAGE') { + SoundManager.playActorDamage(); + } else if (actionArgs[0].toUpperCase() === 'PLAY ACTOR COLLAPSE') { + SoundManager.playActorCollapse(); + } else if (actionArgs[0].toUpperCase() === 'PLAY RECOVERY') { + SoundManager.playRecovery(); + } else if (actionArgs[0].toUpperCase() === 'PLAY MISS') { + SoundManager.playMiss(); + } else if (actionArgs[0].toUpperCase() === 'PLAY EVASION') { + SoundManager.playEvasion(); + } else if (actionArgs[0].toUpperCase() === 'PLAY MAGIC EVASION') { + SoundManager.playMagicEvasion(); + } else if (actionArgs[0].toUpperCase() === 'PLAY REFLECTION') { + SoundManager.playReflection(); + } else if (actionArgs[0].toUpperCase() === 'PLAY SHOP') { + SoundManager.playShop(); + } else if (actionArgs[0].toUpperCase() === 'PLAY USE ITEM') { + SoundManager.playUseItem(); + } else if (actionArgs[0].toUpperCase() === 'PLAY USE SKILL') { + SoundManager.playUseSkill(); + } else { + var name = actionArgs[0]; + if (!name) return true; + var vol = actionArgs[1] || Yanfly.Param.SoundVolume; + var pitch = actionArgs[2] || Yanfly.Param.SoundPitch; + var pan = actionArgs[3] || Yanfly.Param.SoundPan; + var se = { + name: name, + volume: vol, + pitch: pitch, + pan: pan + }; + AudioManager.playSe(se); + } + return true; +}; + +BattleManager.actionTpModify = function(actionName, actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var change; + var percent; + if (actionName.match(/TP[ ]([+-])(?:VARIABLE|VAR)[ ](\d+)/i)) { + change = parseInt($gameVariables.value(parseInt(RegExp.$2))); + if (String(RegExp.$1) === '-') change *= -1; + percent = false; + } else if + (actionName.match(/TP[ ]([+-])(?:VARIABLE|VAR)[ ](\d+)([%%])/i)) { + change = parseInt($gameVariables.value(parseInt(RegExp.$2))); + if (String(RegExp.$1) === '-') change *= -1; + percent = true; + } else if (actionName.match(/TP[ ]([\+\-]\d+)([%%])/i)) { + change = parseInt(RegExp.$1); + percent = true; + } else if (actionName.match(/TP[ ]([\+\-]\d+)/i)) { + change = parseInt(RegExp.$1); + percent = false; + } else { + return false; + } + var show = false; + for (var i = 0; i < actionArgs.length; ++i) { + var actionArg = actionArgs[i]; + if (actionArg.toUpperCase() === 'SHOW') show = true; + } + var value; + targets.forEach(function(target) { + target.clearResult(); + value = percent ? (target.maxTp() * change * 0.01) : change; + target.gainTp(parseInt(value)); + if (show) { + target.startDamagePopup(); + this._logWindow.displayActionResults(this._subject, target); + } + }, this); + return true; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= +}; diff --git a/js/plugins/YEP_X_ActSeqPack2.js b/js/plugins/YEP_X_ActSeqPack2.js new file mode 100644 index 0000000..592472e --- /dev/null +++ b/js/plugins/YEP_X_ActSeqPack2.js @@ -0,0 +1,1446 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle Engine Extension - Action Sequence Pack 2 +// YEP_X_ActSeqPack2.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_ActSeqPack2 = true; + +var Yanfly = Yanfly || {}; +Yanfly.ASP2 = Yanfly.ASP2 || {}; +Yanfly.ASP2.version = 1.13; + +//============================================================================= + /*: + * @plugindesc v1.13 (Requires YEP_BattleEngineCore.js) Visual functions + * are added to the Battle Engine Core's action sequences. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * The Action Sequence Pack 2 plugin is an extension plugin for Yanfly Engine + * Plugins' Battle Engine Core. This extension plugin will not work without the + * main plugin. + * + * This extension plugin contains the more basic functions used for customized + * action sequences on a visual scale. This plugin focuses on making battlers + * perform visual actions. + * + * ============================================================================ + * Action Sequences - ala Melody + * ============================================================================ + * + * Battle Engine Core includes Yanfly Engine Melody's Battle Engine system, + * where each individual aspect of the skill and item effects can be controlled + * to a degree. These are called Action Sequences, where each command in the + * action sequence causes the game to perform a distinct individual action. + * + * Each skill and item consists of five different action sequences. They are as + * follows: + * + * 1. Setup Actions + * They prepare the active battler before carrying out the bulk of the action + * and its individual effects. Usually what you see here are things such as the + * active battler moving forward a bit, unsheathing their weapon, etc. This step + * will occur before the active battler expends their skill or item costs. + * + * 2. Whole Actions + * These actions will affect all of the targets simultaneously. Although this + * section does not need to be used, most actions will use this for displaying + * animations upon all enemies. This step occurs after skill and item costs. + * + * 3. Target Actions + * This section will affect all of the targets individually. Used primarily + * for physical attacks that will deliver more personal forms of damage. Actions + * that occur here will not affect other targets unless specifically ordered to + * do so otherwise. + * + * 4. Follow Actions + * This section will dedicate towards cleanup work after the individual + * targeting actions. Here, it'll do things such as removing immortal flags, + * start up common events, and more. + * + * 5. Finish Actions + * This section will have the active battler close up the action sequence. + * Usually stuff like running waits and holds at the last minute for skills and + * items, moving back to place, and others. + * + * Now that you know each of the five steps each action sequence goes through, + * here's the tags you can insert inside of skills and items. Pay attention to + * each tag name. + * + * 1. 5. + * action list action list + * action list action list + * + * + * 2. 3. 4. + * action list action list action list + * action list action list action list + * + * + * They will do their own respective action sets. The methods to insert for the + * action list can be found below in the core of the Help Manual. + * + * Furthermore, to prevent overflooding every single one of your database item's + * noteboxes with action sequence lists, there's a shortcut you can take to copy + * all of the setup actions, whole actions, target actions, follow actions, and + * finish actions with just one line. + * + * + * + * Replace x with "item" or "skill" to set the type for the action list code to + * directly copy. The integer y is then the ID assigned for that particular + * object type. For example, to copy 45th skill's action sequences, the code + * would be for anything that will accept these action + * codes. If you do use this notetag, it will take priority over any custom + * that you've placed in the notebox. + * + * ============================================================================ + * Target Typing + * ============================================================================ + * + * You may notice that in some of the actions below will say "refer to target + * typing" which is this section right here. Here's a quick run down on the + * various targets you may select. + * + * user; This will select the active battler. + * target, targets; These will select the active targets in question. + * actors, existing actors; These will select all living actors. + * all actors; This will select all actors including dead ones. + * dead actors: This will select only dead actors. + * actors not user; This will select all living actors except for the user. + * actor x; This will select the actor in slot x. + * character x; This will select the specific character with actor ID x. + * enemies, existing enemies; This will select all living enemies. + * all enemies; This will select all enemies, even dead. + * dead enemies: This will select only dead enemies. + * enemies not user; This will select all enemies except for the user. + * enemy x; This will select the enemy in slot x. + * friends; This will select the battler's alive allies. + * all friends; This will select the all of battler's allies, even dead. + * dead friends; This will select the battler's dead allies. + * friends not user; This will select the battler's allies except itself. + * friend x: This will select the battler's ally in slot x. + * opponents; This will select the battler's alive opponents. + * all opponents; This will select the all of the battler's opponents. + * dead opponents; This will select the battler's dead opponents. + * opponent x: This will select the battler's opponent in slot x. + * all alive; Selects all living actors and enemies. + * all members; Selects all living and dead actors and enemies. + * all dead; Selects all dead actors and enemies. + * all not user; This will select all living battlers except user. + * focus; Selects the active battler and its targets. + * not focus; Selects everything but the active battler and its targets. + * + * ============================================================================ + * Action Sequences - Action List + * ============================================================================ + * + * The following contains a list of the actions you can use inside the five + * action sequences. Each action has a unique function and requires certain + * formats to operate properly. + * + *============================================================================= + * ATTACK ANIMATION: target, (mirror) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Displays the active battler's attack animation on the target(s). This will + * be the animation determined by the actor's weapon(s). If it's an enemy, it + * will be determined by the enemy's attack animation. If 'mirror' is used, + * the animation will be flipped. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: attack animation: target + *============================================================================= + * + *============================================================================= + * ENEMY EFFECT: target, effect-type + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This affects enemies only. Makes the target display either a 'whiten' effect + * or a 'blink' effect. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: enemy effect: targets, whiten + * enemy effect: targets, blink + *============================================================================= + * + *============================================================================= + * FACE target: args + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * FACE target1: FORWARD + * FACE target1: BACKWARD + * FACE target1: HOME + * FACE target1: AWAY FROM HOME + * FACE target1: POINT, x coordinate, y coordinate + * FACE target1: AWAY FROM POINT, x coordinate, y coordinate + * FACE target1: target2 + * FACE target1: AWAY FROM target2 + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will cause the battler to face a certain direction. Arguments can be + * used in the above formats. This action sequence command will cause target1 + * to face any of those directions. If target2 is used, then target1 will face + * directions relative to target2. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: face user: forward + * face target: backward + * face enemies: home + * face allies: away from home + * face target: point, 20, 40 + * face target: away from point, 500, 600 + * face user: target + * face target: away from user + *============================================================================= + * + *============================================================================= + * FADE OUT: (frames) + * FADE IN: (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Fades the screen out and fades the screen in respectively. You can set the + * amount of frames for the fading process. If you omit frames, 60 frames will + * be used by default. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: fade out + * fade in: 10 + *============================================================================= + * + *============================================================================= + * FLASH SCREEN: args + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * FLASH SCREEN: WHITE, (frames) + * FLASH SCREEN: RED, (frames) + * FLASH SCREEN: ORANGE, (frames) + * FLASH SCREEN: YELLOW, (frames) + * FLASH SCREEN: GREEN, (frames) + * FLASH SCREEN: BLUE, (frames) + * FLASH SCREEN: PURPLE, (frames) + * FLASH SCREEN: MAGENTA, (frames) + * FLASH SCREEN: BLACK, (frames) + * FLASH SCREEN: (red), (green), (blue), (intensity), (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the game screen to flash a set color. If for the arguments, you use a + * color name, it will use a premade flash setting. If you choose to use your + * own settings, use the red, green, blue, intensity format to determine what + * color flash you would like. Red, green, blue, and intensity settings range + * from 0 to 255. If frames are used, that will be the duration of the screen + * flash. If omitted, the default frame count will be 60 frames. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: flash screen: white + * flash screen: red, 45 + * flash screen: 128, 170, 214, 170 + * flash screen: 68, 68, 68, 170, 45 + *============================================================================= + * + *============================================================================= + * FLOAT target: (height), (frames) + * FLOAT target: (height%), (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the target to float into the air above the ground by height%. The + * height is relative to the floating target. Using 100% means the target will + * float above the ground 100% higher than its height. If no '%' sign is used, + * the target will float that many pixels rather than a percentage of the + * target's height. The frames determine how many frames it will take for the + * target to reach that height. Using 0% for the height will bring the target + * back to the ground. + * Note: Floating only works with Sideview. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: float user: 200% + * float enemies: 500, 30 + * float target: 0%, 30 + *============================================================================= + * + *============================================================================= + * HIDE BATTLE HUD + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Hides the battle hud to not obstruct any animations being played. You + * can reveal the battle hud again using 'show battle hud'. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: hide battle hud + *============================================================================= + * + *============================================================================= + * JUMP target: (height), (frames) + * JUMP target: (height%), (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the target to jump a height relative to the target itself. If the + * target jumps a height of 200%, the height will be 200% of the target's + * height. If no '%' sign is used, the target will jump that many pixels rather + * than a percentage of the target's height. The frame count is how long the + * target will be in the air. You can use this with the 'Move' action sequence + * to make the target appear like it is jumping a distance. + * Note: Jumping only works with Sideview. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: jump user: 150% + * jump target: 300, 60 + *============================================================================= + * + *============================================================================= + * MOTION type: target, (no weapon) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * MOTION WALK: target + * MOTION STANDBY: target + * MOTION CHANT: target + * MOTION GUARD: target + * MOTION DAMAGE: target + * MOTION EVADE: target + * MOTION ATTACK: target + * MOTION THRUST: target + * MOTION SWING: target + * MOTION MISSILE: target + * MOTION SKILL: target + * MOTION SPELL: target + * MOTION ITEM: target + * MOTION ESCAPE: target + * MOTION VICTORY: target + * MOTION DYING: target + * MOTION ABNORMAL: target + * MOTION SLEEP: target + * MOTION DEAD: target + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Forces the target to perform the specific type of action in sideview. If you + * issue an action sequence command for the target to perform 'attack', the + * target will automatically determine based on the weapon it has equipped to + * use either a thrust, swing, or missile motion. Attack, thrust, swing, and + * missile will also display the target's weapon if the target has one. + * + * If 'no weapon' is used after the target, no weapons will be displayed. This + * effect will only work with the Thrust, Swing, and Missile motions. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: motion walk: user + * motion thrust: user, no weapon + *============================================================================= + * + *============================================================================= + * MOVE target: args + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * MOVE target1: HOME, (frames) + * MOVE target1: RETURN, (frames) + * MOVE target1: FORWARD, (distance), (frames) + * MOVE target1: BACKWARD, (distance), (frames) + * MOVE target1: POINT, x coordinate, y coordinate, (frames) + * MOVE target1: target2, BASE, (frames), (offset) + * MOVE target1: target2, CENTER, (frames), (offset) + * MOVE target1: target2, HEAD, (frames), (offset) + * MOVE target1: target2, FRONT BASE, (frames), (offset) + * MOVE target1: target2, FRONT CENTER, (frames), (offset) + * MOVE target1: target2, FRONT HEAD, (frames), (offset) + * MOVE target1: target2, BACK BASE, (frames), (offset) + * MOVE target1: target2, BACK CENTER, (frames), (offset) + * MOVE target1: target2, BACK HEAD, (frames), (offset) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This is a move command. Arguments can be used in the above formats. This + * action sequence command will move target1 to any of those locations listed + * in the arguments. If it's towards target2, you must include what location + * relative to target2 for target1 to travel to. + * Note: Moving only works with Sideview. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * You may be curious about the optional (offset) argument there for some of + * the entries. You can insert any of the below arguments in place of (offset): + * + * offset x +100 + * offset x -200 + * offset y +300 + * offset y -400 + * + * This will allow you to offset the distance to the destination by a flat + * amount. Positive numbers would indicate forward while negative numbers will + * indicate backward. + * + * auto offset x +500 + * auto offset x -600 + * + * However, if you use either of the above, depending on if the user is an + * actor or enemy and depending on the target (if there is one) is an actor or + * an enemy, it will move them into position accordingly. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: move user: home, 20 + * move target: forward, 48, 12 + * move enemy 1: point, 400, 300 + * move enemy 2: point, 500, 250, offset x -50, offset y -50 + * move actor 3: target, front base, 20 + * move user: target, front base, 20, auto offset x -100 + *============================================================================= + * + *============================================================================= + * OPACITY target: x, (frames) + * OPACITY target: x%, (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Changes the opacity of the target to x (0-255) or x% (0% to 100%). If you + * use 'frames', that will be the frame duration for the change in opacity for + * the target. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: opacity user: 50%, 30 + * opacity not focus: 0 + *============================================================================= + * + *============================================================================= + * SHOW BATTLE HUD + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * If the battle hud was hidden using 'hide battle hud', use this to show the + * battle hud back within the player's screen. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: show battle hud + *============================================================================= + * + *============================================================================= + * SHAKE SCREEN: (power), (speed), (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Causes the game screen to shake. Adjust the power from 0-9, speed from 0-9, + * and the frames to alter the duration of the screen shaking. If those values + * are omitted, they will default to 5 power, 5 speed, and 60 frames. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: shake screen + * shake screen: 9 + * shake screen: 3, 9, 30 + *============================================================================= + * + *============================================================================= + * TINT SCREEN: args + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * TINT SCREEN: NORMAL, (frames) + * TINT SCREEN: DARK, (frames) + * TINT SCREEN: SEPIA, (frames) + * TINT SCREEN: SUNSET, (frames) + * TINT SCREEN: NIGHT, (frames) + * TINT SCREEN: (red), (green), (blue), (gray), (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Tints the battle screen. If using the arguments 'normal', 'dark', 'sepia', + * 'sunset', or 'night' the screen will be be given a premade tint. If not, + * then the arguments for red, green, blue, and gray values must be inputted + * for the tint. Red, green, and blue can range from -255 to 255 while gray + * will range from 0 to 255. If frames are used, that will be the duration for + * which the screen will change to the tint. If omitted, the default amount of + * frames used will be 60 frames. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: tint screen: normal + * tint screen: sepia, 30 + * tint screen: 68, -34, -34, 0 + * tint screen: 68, -68, 0, 68, 45 + *============================================================================= + * + *============================================================================= + * WAIT FOR FLOAT + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all battler float changes to finish before going on to the next + * action in the action sequence. + * Note: Floating only works with Sideview. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for float + *============================================================================= + * + *============================================================================= + * WAIT FOR JUMP + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all battler jumps to finish before going on to the next action + * in the action sequence. + * Note: Jumping only works with Sideview. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for jump + *============================================================================= + * + *============================================================================= + * WAIT FOR OPACITY + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for all battlers to finish changing opacity before going on to the + * next action in the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for opacity + *============================================================================= + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.13: + * - Updated Float and Jump to allow for negative values. + * + * Version 1.12: + * - Updated for RPG Maker MV version 1.5.0. + * - Added new Offset X, Offset Y, arguments for the Move action sequence. + * Check the helpfile for more information. + * + * Version 1.11: + * - Fixed a bug that caused enemies to not mirror the attack animation. + * + * Version 1.10a: + * - Fixed a bug that caused scaled enemies to have their state icons and + * overlays appear in odd places. + * - Documentation update for Move, Float, and Jump related action sequences as + * they only work in Sideview. + * + * Version 1.09: + * - Animations played on a floating or jumping battlers 'Feet' location will + * now be played at the base of the battler regardless of how high the battler + * is floating. This is to provide a more consistent animation image. + * + * Version 1.08a: + * - State Icon and State Overlays will now synch together for floating and + * jumping battlers. + * + * Version 1.07c: + * - Synchronized battle animations to floating and jumping battlers. + * + * Version 1.06: + * - Updated weapon motions for YEP_X_AnimatedSVEnemies to work with sideview + * enemies. + * + * Version 1.05: + * - Creating compatibility for a future plugin. + * + * Version 1.04a: + * - Rewrote and updated movement formulas. + * + * Version 1.03: + * - Made a change to Motion action sequence. 'Wait' is now substituted for + * 'Standby' as to not confuse it with the actual Motion Wait action sequence. + * - Added a 'no weapon' option to Motion action sequences. This new tag will + * only affect the 'Thrust', 'Swing', and 'Missile' motions. + * + * Version 1.02: + * - Added a check for motion attack to differentiate between actor and enemy. + * + * Version 1.01: + * - Updated help file to include Character X for target typing. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +//============================================================================= +// Parameters +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_ActSeqPack2'); +Yanfly.Param = Yanfly.Param || {}; + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.ASP2.BattleManager_processActionSequence = + BattleManager.processActionSequence; +BattleManager.processActionSequence = function(actionName, actionArgs) { + // ATTACK ANIMATION + if (actionName === 'ATTACK ANIMATION') { + return this.actionAttackAnimation(actionArgs); + } + // ENEMY EFFECT + if (actionName === 'ENEMY EFFECT') { + return this.actionEnemyEffect(actionArgs); + } + // FACE TARGET + if (actionName.match(/FACE[ ](.*)/i)) { + var string = String(RegExp.$1); + if (this.makeActionTargets(string).length > 0) { + return this.actionFace(string, actionArgs); + } + } + // FADE IN, FADE OUT + if (['FADE IN', 'FADE OUT'].contains(actionName)) { + return this.actionFadeScreen(actionName, actionArgs); + } + // FLASH SCREEN + if (actionName === 'FLASH SCREEN') { + return this.actionFlashScreen(actionArgs); + } + // FLOAT TARGET + if (actionName.match(/FLOAT[ ](.*)/i)) { + var string = String(RegExp.$1); + if (this.makeActionTargets(string).length > 0) { + return this.actionFloat(string, actionArgs); + } + } + // HIDE BATTLE HUD, SHOW BATTLE HUD + if (['HIDE BATTLE HUD', 'SHOW BATTLE HUD'].contains(actionName)) { + return this.actionBattleHud(actionName); + } + // JUMP TARGET + if (actionName.match(/JUMP[ ](.*)/i)) { + var string = String(RegExp.$1); + if (this.makeActionTargets(string).length > 0) { + return this.actionJump(string, actionArgs); + } + } + // MOTION TYPE + if (actionName.match(/MOTION[ ](.*)/i)) { + return this.actionMotionTarget(String(RegExp.$1), actionArgs); + } + // MOVE TARGET + if (actionName.match(/MOVE[ ](.*)/i)) { + var string = String(RegExp.$1); + if (this.makeActionTargets(string).length > 0) { + return this.actionMove(string, actionArgs); + } + } + // OPACITY TARGET + if (actionName.match(/OPACITY[ ](.*)/i)) { + var string = String(RegExp.$1); + if (this.makeActionTargets(string).length > 0) { + return this.actionOpacity(string, actionArgs); + } + } + // SHAKE SCREEN + if (actionName === 'SHAKE SCREEN') { + return this.actionShakeScreen(actionArgs); + } + // TINT SCREEN + if (actionName === 'TINT SCREEN') { + return this.actionTintScreen(actionArgs); + } + // WAIT FOR FLOAT + if (actionName === 'WAIT FOR FLOAT') { + return this.actionWaitForFloat(); + } + // WAIT FOR JUMP + if (actionName === 'WAIT FOR JUMP') { + return this.actionWaitForJump(); + } + // WAIT FOR OPACITY + if (actionName === 'WAIT FOR OPACITY') { + return this.actionWaitForOpacity(); + } + return Yanfly.ASP2.BattleManager_processActionSequence.call(this, + actionName, actionArgs); +}; + +BattleManager.actionAttackAnimation = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + var mirror = false; + if (actionArgs[1] && actionArgs[1].toUpperCase() === 'MIRROR') mirror = true; + if (mirror) { + this._logWindow.showActorAtkAniMirror(this._subject, + targets.filter(Yanfly.Util.onlyUnique)); + } else { + this._logWindow.showAttackAnimation(this._subject, + targets.filter(Yanfly.Util.onlyUnique)); + } + return true; +}; + +BattleManager.actionBattleHud = function(actionName) { + if (actionName === 'HIDE BATTLE HUD') { + this._windowLayer.x = Graphics.boxWidth * 495; + } else if (actionName === 'SHOW BATTLE HUD') { + this._windowLayer.x = 0; + } + return false; +} + +BattleManager.actionEnemyEffect = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + if (actionArgs[1].toUpperCase() === 'WHITEN') { + targets.forEach(function(target) { + if (target.isEnemy()) target.requestEffect('whiten'); + }); + } else if (actionArgs[1].toUpperCase() === 'BLINK') { + targets.forEach(function(target) { + if (target.isEnemy()) target.requestEffect('blink'); + }); + } + return true; +}; + +BattleManager.actionFace = function(name, actionArgs) { + var movers = this.makeActionTargets(name); + if (movers.length < 1) return true; + var cmd = actionArgs[0].toUpperCase(); + if (['FORWARD', 'NORMAL'].contains(cmd)) { + movers.forEach(function(mover) { + mover.spriteFaceForward(); + }); + } else if (['BACKWARD', 'MIRROR'].contains(cmd)) { + movers.forEach(function(mover) { + mover.spriteFaceBackward(); + }); + } else if (['HOME', 'ORIGIN'].contains(cmd)) { + movers.forEach(function(mover) { + mover.spriteFaceHome(); + }); + } else if (['AWAY FROM HOME', 'AWAY FROM ORIGIN'].contains(cmd)) { + movers.forEach(function(mover) { + mover.spriteFaceAwayHome(); + }); + } else if (['POINT', 'POSITION', 'COORDINATE', 'SCREEN', 'SCREEN POS', + 'COORDINATES'].contains(cmd)) { + var destX = eval(actionArgs[1]) || 0; + var destY = eval(actionArgs[2]) || 0; + movers.forEach(function(mover) { + mover.spriteFacePoint(destX, destY); + }); + } else if (['AWAY FROM POINT', 'AWAY FROM POSITION', 'AWAY FROM COORDINATE', + 'AWAY FROM SCREEN', 'AWAY FROM SCREEN POS', + 'AWAY FROM COORDINATES'].contains(cmd)) { + var destX = eval(actionArgs[1]) || 0; + var destY = eval(actionArgs[2]) || 0; + movers.forEach(function(mover) { + mover.spriteFaceAwayPoint(destX, destY); + }); + } else if (cmd.match(/AWAY[ ]FROM[ ](.*)/i)) { + var targets = this.makeActionTargets(String(RegExp.$1)); + if (targets.length < 1) return false; + var destX = 0; + var destY = 0; + targets.forEach(function(target) { + destX += target.spritePosX(); + destY += target.spritePosY(); + }, this); + destX /= targets.length; + destY /= targets.length; + movers.forEach(function(mover) { + mover.spriteFaceAwayPoint(destX, destY); + }, this); + } else { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var destX = 0; + var destY = 0; + targets.forEach(function(target) { + destX += target.spritePosX(); + destY += target.spritePosY(); + }, this); + destX /= targets.length; + destY /= targets.length; + movers.forEach(function(mover) { + mover.spriteFacePoint(destX, destY); + }, this); + } + return false; +}; + +BattleManager.actionFadeScreen = function(actionName, actionArgs) { + var frames = actionArgs[0] || 60; + if (actionName === 'FADE IN') { + $gameScreen.startFadeIn(frames); + } else if (actionName === 'FADE OUT') { + $gameScreen.startFadeOut(frames); + } + return false; +}; + +BattleManager.actionFlashScreen = function(actionArgs) { + if (actionArgs[0].toUpperCase() === 'WHITE') { + var flash = [255, 255, 255, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'RED') { + var flash = [255, 0, 0, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'ORANGE') { + var flash = [255, 128, 0, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'YELLOW') { + var flash = [255, 255, 0, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'GREEN') { + var flash = [0, 255, 0, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'BLUE') { + var flash = [0, 128, 255, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'PURPLE') { + var flash = [128, 64, 255, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'MAGENTA') { + var flash = [255, 0, 255, 255]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'BLACK') { + var flash = [0, 0, 0, 255]; + var frames = actionArgs[1] || 60; + } else { + var red = actionArgs[0] || 0; + var green = actionArgs[1] || 0; + var blue = actionArgs[2] || 0; + var intensity = actionArgs[3] || 0; + var frames = actionArgs[4] || 60; + var flash = [parseInt(red), parseInt(green), + parseInt(blue), parseInt(intensity)]; + } + $gameScreen.startFlash(flash, frames); + return false; +}; + +BattleManager.actionFloat = function(name, actionArgs) { + var movers = this.makeActionTargets(name); + if (movers.length < 1) return true; + var cmd = actionArgs[0]; + var frames = actionArgs[1] || 12; + var pixels = 0; + if (cmd.match(/(.*)([%%])/i)) { + var floatPeak = parseFloat(RegExp.$1 * 0.01); + } else if (cmd.match(/(\d+)/i)) { + pixels = parseInt(cmd) || 0; + var floatPeak = 0.0; + } else { + var floatPeak = 1.0; + } + movers.forEach(function(mover) { + var floatRate = floatPeak + (pixels / mover.spriteHeight()); + mover.spriteFloat(floatRate, frames); + }); + return false; +}; + +BattleManager.actionJump = function(name, actionArgs) { + var movers = this.makeActionTargets(name); + if (movers.length < 1) return true; + var cmd = actionArgs[0]; + var frames = actionArgs[1] || 12; + var pixels = 0; + if (cmd.match(/(.*)([%%])/i)) { + var jumpPeak = parseFloat(RegExp.$1 * 0.01); + } else if (cmd.match(/(\d+)/i)) { + pixels = parseInt(cmd) || 0; + var jumpPeak = 0.0; + } else { + var jumpPeak = 1.0; + } + movers.forEach(function(mover) { + var jumpRate = jumpPeak + (pixels / mover.spriteHeight()); + mover.spriteJump(jumpRate, frames); + }); + return true; +}; + +BattleManager.actionMotionTarget = function(name, actionArgs) { + if (name.toUpperCase() === 'WAIT') return this.actionMotionWait(actionArgs); + if (name.toUpperCase() === 'STANDBY') name = 'WAIT'; + var movers = this.makeActionTargets(actionArgs[0]); + if (movers.length < 1) return true; + var cmd = name.toLowerCase(); + var motion = 'wait'; + if (actionArgs[1] && actionArgs[1].toUpperCase() === 'NO WEAPON') { + var showWeapon = false; + } else { + var showWeapon = true; + } + if (['wait', 'chant', 'guard', 'evade', 'skill', 'spell', 'item', 'escape', + 'victory', 'dying', 'abnormal', 'sleep', 'dead'].contains(cmd)) { + motion = cmd; + } else if (['walk', 'move'].contains(cmd)) { + motion = 'walk'; + } else if (['damage', 'hit'].contains(cmd)) { + motion = 'damage'; + } else if (['attack'].contains(cmd)) { + movers.forEach(function(mover) { + mover.performAttack(); + }); + return false; + } else if (['randattack'].contains(cmd)) { + var motions = ['thrust', 'swing', 'missile']; + movers.forEach(function(mover) { + var motion = motions[Math.floor(Math.random() * motions.length)]; + mover.forceMotion(motion); + }); + return false; + } else if (['thrust', 'swing', 'missile'].contains(cmd)) { + motion = cmd; + movers.forEach(function(mover) { + mover.forceMotion(motion); + if (mover.isActor() && showWeapon) { + var weapons = mover.weapons(); + var wtypeId = weapons[0] ? weapons[0].wtypeId : 0; + var attackMotion = $dataSystem.attackMotions[wtypeId]; + if (attackMotion && [0, 1, 2].contains(attackMotion.type)) { + mover.startWeaponAnimation(attackMotion.weaponImageId); + } + } + if (Imported.YEP_X_AnimatedSVEnemies) { + if (mover.isEnemy() && mover.hasSVBattler() && showWeapon) { + var attackMotion = $dataSystem.attackMotions[wtypeId]; + mover.startWeaponAnimation(mover.weaponImageId()); + } + } + }); + return false; + } + movers.forEach(function(mover) { + mover.forceMotion(motion); + }); + return false; +}; + +BattleManager.actionMove = function(name, actionArgs) { + if (!$gameSystem.isSideView()) return true; + var movers = this.makeActionTargets(name); + if (movers.length < 1) return true; + var cmd = actionArgs[0].toUpperCase(); + if (['HOME', 'ORIGIN'].contains(cmd)) { + var frames = actionArgs[1] || 12; + movers.forEach(function(mover) { + mover.battler().startMove(0, 0, frames); + mover.requestMotion('walk'); + mover.spriteFaceHome(); + }); + } else if (['RETURN'].contains(cmd)) { + var frames = actionArgs[1] || 12; + movers.forEach(function(mover) { + mover.battler().startMove(0, 0, frames); + mover.requestMotion('evade'); + mover.spriteFaceForward(); + }); + } else if (['FORWARD', 'FORWARDS', 'BACKWARD', + 'BACKWARDS'].contains(cmd)) { + var distance = actionArgs[1] || Yanfly.Param.BECStepDist; + if (['BACKWARD', 'BACKWARDS'].contains(cmd)) distance *= -1; + var frames = actionArgs[2] || 12; + movers.forEach(function(mover) { + mover.battler().moveForward(distance, frames); + mover.requestMotion('walk'); + if (['FORWARD', 'FORWARDS'].contains(cmd)) { + mover.spriteFaceForward(); + } else { + mover.spriteFaceBackward(); + } + }); + } else if (['POINT', 'POSITION', 'COORDINATE', 'SCREEN', 'SCREEN POS', + 'COORDINATES'].contains(cmd)) { + var destX = eval(actionArgs[1]) || 0; + var destY = eval(actionArgs[2]) || 0; + var frames = actionArgs[3] || 12; + movers.forEach(function(mover) { + var offsetX = BattleManager.actionMoveOffsetX(actionArgs, mover, mover); + var offsetY = BattleManager.actionMoveOffsetY(actionArgs, mover, mover); + mover.battler().moveToPoint(destX + offsetX, destY + offsetY, frames); + mover.requestMotion('walk'); + mover.spriteFacePoint(destX, destY); + }); + } else { + var targets = this.makeActionTargets(actionArgs[0]); + var frames = actionArgs[2] || 12; + var type = actionArgs[1].toUpperCase(); + if (targets.length < 1) return false; + for (var i = 0; i < movers.length; ++i) { + var mover = movers[i]; + if (!mover) continue; + if (['BASE', 'FOOT', 'FEET'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'center'); + var destY = this.actionMoveY(mover, targets, 'foot'); + } else if (['CENTER', 'MIDDLE'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'center'); + var destY = this.actionMoveY(mover, targets, 'center'); + } else if (['HEAD', 'TOP'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'center'); + var destY = this.actionMoveY(mover, targets, 'head'); + } else if (['FRONT BASE', 'FRONT FOOT', 'FRONT FEET', + 'FRONT'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'front'); + var destY = this.actionMoveY(mover, targets, 'foot'); + } else if (['BACK BASE', 'BACK FOOT', 'BACK FEET', + 'BACK'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'back'); + var destY = this.actionMoveY(mover, targets, 'foot'); + } else if (['FRONT CENTER', 'FRONT MIDDLE'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'front'); + var destY = this.actionMoveY(mover, targets, 'center'); + } else if (['BACK CENTER', 'BACK MIDDLE',].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'back'); + var destY = this.actionMoveY(mover, targets, 'center'); + } else if (['FRONT HEAD', 'FRONT TOP'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'front'); + var destY = this.actionMoveY(mover, targets, 'head'); + } else if (['BACK HEAD', 'BACK TOP'].contains(type)) { + var destX = this.actionMoveX(mover, targets, 'back'); + var destY = this.actionMoveY(mover, targets, 'head'); + } + var offsetX = this.actionMoveOffsetX(actionArgs, mover, targets[0]); + var offsetY = this.actionMoveOffsetY(actionArgs, mover, targets[0]); + mover.battler().moveToPoint(destX + offsetX, destY + offsetY, frames); + mover.spriteFacePoint(destX, destY); + } + } + return true; +}; + +BattleManager.actionMoveX = function(mover, targets, value) { + value = this.actionMoveXLocation(mover, targets, value); + var max = targets.length; + var moverWidth = mover.spriteWidth(); + if (value === 'center') { + var destX = null; + } else { + var destX = (value === 'left') ? Graphics.boxWidth : 0; + } + for (var i = 0; i < max; ++i) { + var target = targets[i]; + if (!target) continue; + var targetWidth = target.spriteWidth(); + var point = target.spritePosX(); + if (value === 'center') { + destX = (destX === null) ? 0 : destX; + destX += point; + } else if (value === 'left') { + point -= targetWidth / 2; + point -= (mover.isActor() ? 1 : 1) * moverWidth / 2; + destX = Math.min(point, destX); + } else { + point += targetWidth / 2; + point += (mover.isActor() ? 1 : 1) * moverWidth / 2; + destX = Math.max(point, destX); + } + } + if (value === 'center') destX /= max; + return destX; +}; + +BattleManager.actionMoveXLocation = function(mover, targets, value) { + if (value === 'center') return 'center'; + var actors = 0; + var enemies = 0; + var max = targets.length; + for (var i = 0; i < max; ++i) { + var target = targets[i]; + if (!target) continue; + if (target.isActor()) actors += 1; + if (target.isEnemy()) enemies += 1; + } + if (actors > 0 && enemies === 0) { + return (value === 'front') ? 'left' : 'right'; + } else if (actors === 0 && enemies > 0) { + return (value === 'front') ? 'right' : 'left'; + } else { + if (mover.isActor()) { + return (value === 'front') ? 'right' : 'left'; + } else { // enemy + return (value === 'front') ? 'left' : 'right'; + } + } + return 'center'; +}; + +BattleManager.actionMoveY = function(mover, targets, value) { + var max = targets.length; + var destY = 0; + var point = (value === 'head') ? Graphics.boxHeight : 0; + for (var i = 0; i < max; ++i) { + var target = targets[i]; + if (!target) continue; + if (value === 'head') { + point = Math.min(target.spritePosY() - target.spriteHeight(), point); + } else if (value === 'center') { + point += target.spritePosY() - target.spriteHeight() / 2; + } else { // foot + point = Math.max(target.spritePosY(), point); + } + } + destY = (value === 'center') ? point / max : point; + return destY; +}; + +BattleManager.actionMoveOffsetX = function(actionArgs, user, target) { + if (actionArgs && actionArgs.length > 0) { + var length = actionArgs.length; + for (var i = 0; i < length; ++i) { + var line = actionArgs[i]; + if (line.match(/AUTO OFFSET X[ ]([\+\-]\d+)/i)) { + var value = parseInt(RegExp.$1); + if (user.isActor() && !target) { + return value * -1; + } else if (user.isEnemy() && !target) { + return value; + } else if (user.isActor() && target.isActor()) { + return value; + } else if (user.isActor() && target.isEnemy()) { + return value * -1; + } else if (user.isEnemy() && target.isEnemy()) { + return value * -1; + } else if (user.isEnemy() && target.isActor()) { + return value; + } + } else if (line.match(/OFFSET X[ ]([\+\-]\d+)/i)) { + return parseInt(RegExp.$1); + } + } + } + return 0; +}; + +BattleManager.actionMoveOffsetY = function(actionArgs, user, target) { + if (actionArgs && actionArgs.length > 0) { + var length = actionArgs.length; + for (var i = 0; i < length; ++i) { + var line = actionArgs[i]; + if (line.match(/AUTO OFFSET Y[ ]([\+\-]\d+)/i)) { + return parseInt(RegExp.$1); + } else if (line.match(/OFFSET Y[ ]([\+\-]\d+)/i)) { + return parseInt(RegExp.$1); + } + } + } + return 0; +}; + +BattleManager.actionOpacity = function(name, actionArgs) { + var targets = this.makeActionTargets(name); + if (targets.length < 1) return true; + var cmd = actionArgs[0]; + var frames = actionArgs[1] || 12; + if (cmd.match(/(\d+)([%%])/i)) { + var opacity = parseInt(RegExp.$1 * 0.01 * 255).clamp(0, 255); + } else if (cmd.match(/(\d+)/i)) { + var opacity = parseInt(RegExp.$1); + } else { + return false; + } + targets.forEach(function(target) { + target.spriteOpacity(opacity, frames); + }); + return false; +}; + +BattleManager.actionTintScreen = function(actionArgs) { + if (actionArgs[0].toUpperCase() === 'NORMAL') { + var tint = [0, 0, 0, 0]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'DARK') { + var tint = [-68, -68, -68, 0]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'SEPIA') { + var tint = [34, -34, -68, 170]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'SUNSET') { + var tint = [68, -34, -34, 0]; + var frames = actionArgs[1] || 60; + } else if (actionArgs[0].toUpperCase() === 'NIGHT') { + var tint = [68, -68, 0, 68]; + var frames = actionArgs[1] || 60; + } else { + var red = actionArgs[0] || 0; + var green = actionArgs[1] || 0; + var blue = actionArgs[2] || 0; + var gray = actionArgs[3] || 0; + var frames = actionArgs[4] || 60; + var tint = [parseInt(red), parseInt(green), + parseInt(blue), parseInt(gray)]; + } + $gameScreen.startTint(tint, frames); + return false; +}; + +BattleManager.actionShakeScreen = function(actionArgs) { + var power = actionArgs[0] || 5; + var speed = actionArgs[1] || 5; + var frames = actionArgs[2] || 60; + $gameScreen.startShake(parseInt(power), parseInt(speed), parseInt(frames)); + return false; +}; + +BattleManager.actionWaitForFloat = function() { + this._logWindow.waitForFloat(); + return false; +}; + +BattleManager.actionWaitForJump = function() { + this._logWindow.waitForJump(); + return false; +}; + +BattleManager.actionWaitForOpacity = function() { + this._logWindow.waitForOpacity(); + return false; +}; + +BattleManager.setWindowLayer = function(windowLayer) { + this._windowLayer = windowLayer; +}; + +//============================================================================= +// Sprite_Battler +//============================================================================= + +Yanfly.ASP2.Sprite_Battler_initMembers = Sprite_Battler.prototype.initMembers; +Sprite_Battler.prototype.initMembers = function() { + Yanfly.ASP2.Sprite_Battler_initMembers.call(this); + this.resetFloat(); + this.setupJump(0, 0); + this.resetOpacity(); +}; + +Sprite_Battler.prototype.resetFloat = function() { + this._floatHeight = 0.0; + this._floatTarget = 0; + this._floatDur = 0; + this._floatRate = 0; +}; + +Sprite_Battler.prototype.resetOpacity = function() { + this._opacityTarget = 255; + this._opacityDur = 0; + this._opacityRate = 0; + this._opacityChanging = false; +}; + +Sprite_Battler.prototype.setupFloat = function(floatHeight, floatDuration) { + floatDuration = Math.max(1, floatDuration); + this._floatTarget = floatHeight; + this._floatDur = floatDuration; + var rate = Math.abs(this._floatHeight - floatHeight) / floatDuration; + this._floatRate = rate; +}; + +Sprite_Battler.prototype.setupJump = function(jumpHeight, jumpDuration) { + this._jumpHeight = jumpHeight; + this._jumpDur = jumpDuration; + this._jumpFull = jumpDuration; +}; + +Sprite_Battler.prototype.setupOpacityChange = function(target, duration) { + duration = Math.max(1, duration); + this._opacityTarget = target; + this._opacityDur = duration; + var rate = Math.abs(this.opacity - target) / duration; + this._opacityRate = rate; + this._opacityChanging = true; +}; + +Yanfly.ASP2.Sprite_Battler_update = Sprite_Battler.prototype.update; +Sprite_Battler.prototype.update = function() { + Yanfly.ASP2.Sprite_Battler_update.call(this); + if (this._battler) { + this.updateFloat(); + this.updateStateSprites(); + this.updateWeapon(); + this.updateOpacity(); + } +}; + +Sprite_Battler.prototype.updateFloat = function() { + if (!this._battler) return; + if (this._floatDur > 0) this._floatDur--; + if (this._jumpDur > 0) this._jumpDur--; + var baseY = this._battler.anchorY(); + var floatHeight = this.getFloatHeight(); + var jumpHeight = this.getJumpHeight(); + var height = floatHeight + jumpHeight; + if (this._mainSprite && this._mainSprite.bitmap) { + var rate = this._battler.spriteHeight() / this._mainSprite.height; + this._mainSprite.anchor.y = (baseY + height * rate); + this._weaponSprite.anchor.y = this._mainSprite.anchor.y; + } else { + this.anchor.y = (baseY + height); + } +}; + +Sprite_Battler.prototype.updateStateSprites = function() { + if (this._stateIconSprite) { + var height = this._battler.spriteHeight() * -1; + height -= Sprite_StateIcon._iconHeight; + height /= this.scale.y; + this._stateIconSprite.y = height; + } + if (this._stateSprite) { + var height = (this._battler.spriteHeight() - 64 * this.scale.y) * -1; + this._stateSprite.y = height; + } + var heightRate = 0; + heightRate += this.getFloatHeight(); + heightRate += this.getJumpHeight(); + if (Imported.YEP_X_AnimatedSVEnemies) { + if (this._enemy && this._enemy.isFloating()) { + heightRate += this.addFloatingHeight(); + }; + } + var height = this._battler.spriteHeight(); + if (this._stateIconSprite) { + this._stateIconSprite.y += Math.ceil(heightRate * -height); + } + if (this._stateSprite) { + this._stateSprite.y += Math.ceil(heightRate * -height); + } +}; + +Sprite_Battler.prototype.updateWeapon = function() { + if (!this._battler) return; + if (!this._battler.isActor()) return; + this._weaponSprite.anchor.y = this._mainSprite.anchor.y; +}; + +Sprite_Battler.prototype.getFloatHeight = function() { + if (this._floatDur <= 0) { + this._floatHeight = this._floatTarget; + } else { + var target = this._floatTarget; + var rate = this._floatRate; + if (this._floatHeight >= target) { + this._floatHeight = Math.max(target, this._floatHeight - rate); + } else { + this._floatHeight = Math.min(target, this._floatHeight + rate); + } + } + return this._floatHeight; +}; + +Sprite_Battler.prototype.getJumpHeight = function() { + if (this._jumpDur <= 0) { + return 0; + } else { + var x = this._jumpFull - this._jumpDur; + var h = this._jumpFull / 2; + var k = this._jumpHeight; + var a = -k / Math.pow(h, 2); + var height = a * Math.pow((x - h), 2) + k; + } + return height; +}; + +Sprite_Battler.prototype.updateOpacity = function() { + if (this.antiOpacityChange()) return; + this._opacityDur--; + if (this._opacityDur <= 0) { + if (this.opacity !== this._opacityTarget) { + this.opacity = this._opacityTarget; + } + this._opacityChanging = false; + } else { + var target = this._opacityTarget; + var rate = this._opacityRate; + if (this.opacity >= target) { + this.opacity = Math.max(target, this.opacity - rate); + } else { + this.opacity = Math.min(target, this.opacity + rate); + } + } +}; + +Sprite_Battler.prototype.antiOpacityChange = function() { + if (!this._opacityChanging) return true; + return false; +}; + +Sprite_Battler.prototype.isFloating = function() { + return this._floatDur > 0; +}; + +Sprite_Battler.prototype.isJumping = function() { + return this._jumpDur > 0; +}; + +Sprite_Battler.prototype.isChangingOpacity = function() { + return this._opacityDur > 0; +}; + +//============================================================================= +// Sprite_Animation +//============================================================================= + +Yanfly.ASP2.Sprite_Animation_updatePosition = + Sprite_Animation.prototype.updatePosition; +Sprite_Animation.prototype.updatePosition = function() { + Yanfly.ASP2.Sprite_Animation_updatePosition.call(this); + if ([0, 1].contains(this._animation.position)) { + if (this.isBattlerRelated()) this.updateBattlerPosition(); + } +}; + +Sprite_Animation.prototype.isBattlerRelated = function() { + if (this._target instanceof Sprite_Battler) return true; + if (this._target.parent instanceof Sprite_Battler) return true; + return false; +}; + +Sprite_Animation.prototype.updateBattlerPosition = function() { + if (this._target instanceof Sprite_Battler) { + var target = this._target; + } else if (this._target.parent instanceof Sprite_Battler) { + var target = this._target.parent; + } else { + return; + } + if (!target.bitmap) return; + if (target.bitmap.height <= 0) return; + var heightRate = target.getFloatHeight() + target.getJumpHeight(); + var height = heightRate * target.bitmap.height; + this.y -= height; +}; + +//============================================================================= +// Spriteset_Battle +//============================================================================= + +Spriteset_Battle.prototype.isAnyoneFloating = function() { + return this.battlerSprites().some(function(sprite) { + return sprite.isFloating(); + }); +}; + +Spriteset_Battle.prototype.isAnyoneJumping = function() { + return this.battlerSprites().some(function(sprite) { + return sprite.isJumping(); + }); +}; + +Spriteset_Battle.prototype.isAnyoneChangingOpacity = function() { + return this.battlerSprites().some(function(sprite) { + return sprite.isChangingOpacity(); + }); +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.spriteFloat = function(floatHeight, floatDuration) { + if (!this.battler()) return; + if (!this.spriteCanMove()) return; + if (!$gameSystem.isSideView()) return; + this.battler().setupFloat(floatHeight, floatDuration); +}; + +Game_Battler.prototype.spriteJump = function(jumpHeight, jumpDuration) { + if (!this.battler()) return; + if (!this.spriteCanMove()) return; + if (!$gameSystem.isSideView()) return; + this.battler().setupJump(jumpHeight, jumpDuration); +}; + +Game_Battler.prototype.spriteOpacity = function(opacity, duration) { + if (!this.battler()) return; + this.battler().setupOpacityChange(opacity, duration); +}; + +//============================================================================= +// Scene_Battle +//============================================================================= + +Yanfly.ASP2.Scene_Base_createWindowLayer = + Scene_Base.prototype.createWindowLayer; +Scene_Base.prototype.createWindowLayer = function() { + Yanfly.ASP2.Scene_Base_createWindowLayer.call(this); + BattleManager.setWindowLayer(this._windowLayer); +}; + +//============================================================================= +// Window_BattleLog +//============================================================================= + +Yanfly.ASP2.Window_BattleLog_updateWaitMode = + Window_BattleLog.prototype.updateWaitMode; +Window_BattleLog.prototype.updateWaitMode = function() { + if (this._waitMode === 'float') { + if (this._spriteset.isAnyoneFloating()) return true; + } else if (this._waitMode === 'jump') { + if (this._spriteset.isAnyoneJumping()) return true; + } else if (this._waitMode === 'opacity') { + if (this._spriteset.isAnyoneChangingOpacity()) return true; + } + return Yanfly.ASP2.Window_BattleLog_updateWaitMode.call(this); +}; + +Window_BattleLog.prototype.waitForFloat = function() { + this.setWaitMode('float'); +}; + +Window_BattleLog.prototype.waitForJump = function() { + this.setWaitMode('jump'); +}; + +Window_BattleLog.prototype.waitForOpacity = function() { + this.setWaitMode('opacity'); +}; + +//============================================================================= +// End of File +//============================================================================= +}; diff --git a/js/plugins/YEP_X_ActSeqPack3.js b/js/plugins/YEP_X_ActSeqPack3.js new file mode 100644 index 0000000..2b6f259 --- /dev/null +++ b/js/plugins/YEP_X_ActSeqPack3.js @@ -0,0 +1,977 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle Engine Extension - Action Sequence Pack 3 +// YEP_X_ActSeqPack3.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_ActSeqPack3 = true; + +var Yanfly = Yanfly || {}; +Yanfly.ASP3 = Yanfly.ASP3 || {}; +Yanfly.ASP3.version = 1.05; + +//============================================================================= + /*: + * @plugindesc v1.05 (Requires YEP_BattleEngineCore.js) Camera control is + * added to the Battle Engine Core's action sequences. + * @author Yanfly Engine Plugins + * + * @param Camera Option + * @desc Options text used for Camera movement shown in battle. + * @default Battle Camera + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * The Action Sequence Pack 3 plugin is an extension plugin for Yanfly Engine + * Plugins' Battle Engine Core. This extension plugin will not work without the + * main plugin. + * + * This extension plugin contains the more basic functions used for customized + * action sequences on a visual scale. This plugin focuses on camera control + * and screen zooming. + * + * ============================================================================ + * Action Sequences - ala Melody + * ============================================================================ + * + * Battle Engine Core includes Yanfly Engine Melody's Battle Engine system, + * where each individual aspect of the skill and item effects can be controlled + * to a degree. These are called Action Sequences, where each command in the + * action sequence causes the game to perform a distinct individual action. + * + * Each skill and item consists of five different action sequences. They are as + * follows: + * + * 1. Setup Actions + * They prepare the active battler before carrying out the bulk of the action + * and its individual effects. Usually what you see here are things such as the + * active battler moving forward a bit, unsheathing their weapon, etc. This step + * will occur before the active battler expends their skill or item costs. + * + * 2. Whole Actions + * These actions will affect all of the targets simultaneously. Although this + * section does not need to be used, most actions will use this for displaying + * animations upon all enemies. This step occurs after skill and item costs. + * + * 3. Target Actions + * This section will affect all of the targets individually. Used primarily + * for physical attacks that will deliver more personal forms of damage. Actions + * that occur here will not affect other targets unless specifically ordered to + * do so otherwise. + * + * 4. Follow Actions + * This section will dedicate towards cleanup work after the individual + * targeting actions. Here, it'll do things such as removing immortal flags, + * start up common events, and more. + * + * 5. Finish Actions + * This section will have the active battler close up the action sequence. + * Usually stuff like running waits and holds at the last minute for skills and + * items, moving back to place, and others. + * + * Now that you know each of the five steps each action sequence goes through, + * here's the tags you can insert inside of skills and items. Pay attention to + * each tag name. + * + * 1. 5. + * action list action list + * action list action list + * + * + * 2. 3. 4. + * action list action list action list + * action list action list action list + * + * + * They will do their own respective action sets. The methods to insert for the + * action list can be found below in the core of the Help Manual. + * + * Furthermore, to prevent overflooding every single one of your database item's + * noteboxes with action sequence lists, there's a shortcut you can take to copy + * all of the setup actions, whole actions, target actions, follow actions, and + * finish actions with just one line. + * + * + * + * Replace x with "item" or "skill" to set the type for the action list code to + * directly copy. The integer y is then the ID assigned for that particular + * object type. For example, to copy 45th skill's action sequences, the code + * would be for anything that will accept these action + * codes. If you do use this notetag, it will take priority over any custom + * that you've placed in the notebox. + * + * ============================================================================ + * Target Typing + * ============================================================================ + * + * You may notice that in some of the actions below will say "refer to target + * typing" which is this section right here. Here's a quick run down on the + * various targets you may select. + * + * user; This will select the active battler. + * target, targets; These will select the active targets in question. + * actors, existing actors; These will select all living actors. + * all actors; This will select all actors including dead ones. + * dead actors: This will select only dead actors. + * actors not user; This will select all living actors except for the user. + * actor x; This will select the actor in slot x. + * character x; This will select the specific character with actor ID x. + * enemies, existing enemies; This will select all living enemies. + * all enemies; This will select all enemies, even dead. + * dead enemies: This will select only dead enemies. + * enemies not user; This will select all enemies except for the user. + * enemy x; This will select the enemy in slot x. + * friends; This will select the battler's alive allies. + * all friends; This will select the all of battler's allies, even dead. + * dead friends; This will select the battler's dead allies. + * friends not user; This will select the battler's allies except itself. + * friend x: This will select the battler's ally in slot x. + * opponents; This will select the battler's alive opponents. + * all opponents; This will select the all of the battler's opponents. + * dead opponents; This will select the battler's dead opponents. + * opponent x: This will select the battler's opponent in slot x. + * all alive; Selects all living actors and enemies. + * all members; Selects all living and dead actors and enemies. + * all dead; Selects all dead actors and enemies. + * all not user; This will select all living battlers except user. + * focus; Selects the active battler and its targets. + * not focus; Selects everything but the active battler and its targets. + * + * ============================================================================ + * Action Sequences - Action List + * ============================================================================ + * + * The following contains a list of the actions you can use inside the five + * action sequences. Each action has a unique function and requires certain + * formats to operate properly. + * + *============================================================================= + * CAMERA CLAMP ON + * CAMERA CLAMP OFF + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * By default, the camera clamp is on, which forces the camera to never pan + * outside of the battlefield's boundaries. However, in the event you wish to + * turn this off, use 'camera clamp off' to shut off the clamp. The clamp, + * however, will be turned back on at the end of each 'perform finish' action. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: camera clamp on + * camera clamp off + *============================================================================= + * + *============================================================================= + * CAMERA FOCUS: target, (location), (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * CAMERA FOCUS: target, FRONT BASE, (frames) + * CAMERA FOCUS: target, BASE, (frames) + * CAMERA FOCUS: target, BACK BASE, (frames) + * CAMERA FOCUS: target, FRONT CENTER, (frames) + * CAMERA FOCUS: target, CENTER, (frames) + * CAMERA FOCUS: target, BACK CENTER, (frames) + * CAMERA FOCUS: target, FRONT HEAD, (frames) + * CAMERA FOCUS: target, HEAD, (frames) + * CAMERA FOCUS: target, BACK HEAD, (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * This will focus on a target(s) (refer to target typing) and a location. If + * the location is omitted, the camera will focus on the target(s)'s center. + * Note: The camera will not shift past screen boundaries. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: camera focus: user + * camera focus: target, front, 40 + * camera focus: enemies, center, 30 + *============================================================================= + * + *============================================================================= + * CAMERA OFFSET: DIRECTION, DISTANCE + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * CAMERA OFFSET: LEFT, distance + * CAMERA OFFSET: RIGHT, distance + * CAMERA OFFSET: UP, distance + * CAMERA OFFSET: DOWN, distance + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Offsets the camera a direction by (distance) amount. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: camera offset: left, 200 + * camera offset: right, Graphics.boxWidth / 4 + * camera offset: up, 300 + * camera offset: down, $gameVariables.value(3); + *============================================================================= + * + *============================================================================= + * CAMERA PAN + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * CAMERA PAN: LEFT, distance, (frames) + * CAMERA PAN: RIGHT, distance, (frames) + * CAMERA PAN: UP, distance, (frames) + * CAMERA PAN: DOWN, distance, (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Pans the camera a direction a certain distance in pixels. You can use a + * combination of left/right and up/down to perform a diagonal camera pan. + * Using 'frames' will allow you to adjust the duration of the camera pan. + * Omitting 'frames' will set the camera pan duration to 30 frames. + * Note: The camera will not shift past screen boundaries. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: camera pan: left, 200 + * camera pan: up, 250 + * camera pan: right, 500, 60 + * camera pan: down: 300, 60 + *============================================================================= + * + *============================================================================= + * CAMERA SCREEN + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * CAMERA SCREEN: TOP LEFT, (frames) + * CAMERA SCREEN: FAR LEFT, (frames) + * CAMERA SCREEN: BOTTOM LEFT, (frames) + * CAMERA SCREEN: TOP CENTER, (frames) + * CAMERA SCREEN: CENTER, (frames) + * CAMERA SCREEN: BOTTOM CENTER, (frames) + * CAMERA SCREEN: TOP RIGHT, (frames) + * CAMERA SCREEN: FAR RIGHT, (frames) + * CAMERA SCREEN: BOTTOM RIGHT, (frames) + * CAMERA SCREEN: POINT, x, y, (frames) + * CAMERA SCREEN: target, FRONT, (frames) + * CAMERA SCREEN: target, BASE, (frames) + * CAMERA SCREEN: target, BACK, (frames) + * CAMERA SCREEN: target, FRONT CENTER, (frames) + * CAMERA SCREEN: target, CENTER, (frames) + * CAMERA SCREEN: target, BACK CENTER, (frames) + * CAMERA SCREEN: target, FRONT TOP, (frames) + * CAMERA SCREEN: target, TOP, (frames) + * CAMERA SCREEN: target, BACK TOP, (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Moves the camera to a certain part of the screen. If you choose a target, + * the camera will lock to that part of the target. Using (frames) will + * determine the duration of the time the camera will move over to the target + * location. Omitting (frames) will set the camera pan duration to 30 frames. + * Note: The camera will not shift past screen boundaries. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: camera screen: top left + * camera screen: far right, 30 + * camera screen: point, 400, 300, 60 + * camera screen: user, base + * camera screen: targets, base, 60 + *============================================================================= + * + *============================================================================= + * RESET CAMERA: (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Resets the camera location back to default location, which is the center of + * the battlefield. Using (frames) will allow you to adjust the duration in + * which the camera resets. Omitting 'frames' will set the camera to reset in + * 30 frames. + * Note: The camera will not shift past screen boundaries. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: reset camera + * reset camera: 30 + *============================================================================= + * + *============================================================================= + * RESET ZOOM: (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Resets the camera zoom back to default zoom, which is 100%. Using (frames) + * will allow you to adjust the duration in which the zoom resets. Omitting + * 'frames' will set the zoom to reset in 30 frames. + * Note: The camera will not shift past screen boundaries. + * Note: Zooming only works with Sideview. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: reset zoom + * reset zoom: 30 + *============================================================================= + * + *============================================================================= + * WAIT FOR CAMERA + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for the camera to finish panning before going on to the next action in + * the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for camera + *============================================================================= + * + *============================================================================= + * WAIT FOR ZOOM + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Waits for the zoom to finish changing before going on to the next action in + * the action sequence. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: wait for zoom + *============================================================================= + * + *============================================================================= + * ZOOM: x%, (frames) + * ZOOM: x.y, (frames) + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Zooms to x% or x.y rate. Using (frames) will allow you to adjust the + * duration in which the zooming occurs. Omitting 'frames' will set the zoom + * duration to 30 frames. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: zoom: 200% + * zoom: 1.5, 45 + *============================================================================= + * + * ============================================================================ + * Options Core Settings - Adding the New Options + * ============================================================================ + * + * If you are using YEP_OptionsCore.js, you can add a new Option using this + * plugin. Here's the following code/parameter settings you can use with it. + * + * --------- + * Settings: + * --------- + * + * Name: + * \i[302]Battle Camera + * + * Help Description: + * If ON, the camera in battle will move around. + * If OFF, the camera in battle will be locked in place. + * + * Symbol: + * battleCamera + * + * Show/Hide: + * show = Imported.YEP_X_ActSeqPack3; + * + * Enable: + * enabled = true; + * + * Ext: + * ext = 0; + * + * ---------- + * Functions: + * ---------- + * + * Make Option Code: + * this.addCommand(name, symbol, enabled, ext); + * + * Draw Option Code: + * var rect = this.itemRectForText(index); + * var statusWidth = this.statusWidth(); + * var titleWidth = rect.width - statusWidth; + * this.resetTextColor(); + * this.changePaintOpacity(this.isCommandEnabled(index)); + * this.drawOptionsName(index); + * this.drawOptionsOnOff(index); + * + * Process OK Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, !value); + * + * Cursor Right Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, true); + * + * Cursor Left Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * this.changeValue(symbol, false); + * + * Default Config Code: + * // Empty. Provided by this plugin. + * + * Save Config Code: + * // Empty. Provided by this plugin. + * + * Load Config Code: + * // Empty. Provided by this plugin. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.05: + * - Compatibility update with YEP_OptionsCore.js. + * + * Version 1.04: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.03: + * - Restriction on Camera and Zoom action sequences lifted from being Sideview + * only. Use them at your own caution. + * + * Version 1.02a: + * - Updated the Game_Screen.startZoom() function from beta to newest version. + * - Decided to separate the methods as it breaks panning. + * - Changed priority of IF action sequences to higher to no longer interfere + * other action sequences. + * + * Version 1.01: + * - Updated help file to include Character X for target typing. + * + * Version 1.00: + * - Finished plugin! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_ActSeqPack3'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.ASP3CameraOption = String(Yanfly.Parameters['Camera Option']); + +//============================================================================= +// BattleManager +//============================================================================= + +Yanfly.ASP3.BattleManager_processActionSequence = + BattleManager.processActionSequence; +BattleManager.processActionSequence = function(actionName, actionArgs) { + // CAMERA CLAMP + if (['CAMERA CLAMP ON', 'CAMERA CLAMP OFF'].contains(actionName)) { + return this.actionCameraClamp(actionName); + } + // CAMERA FOCUS + if (['CAMERA FOCUS', 'FOCUS CAMERA'].contains(actionName)) { + return this.actionCameraFocus(actionArgs); + } + // CAMERA OFFSET + if (['CAMERA OFFSET', 'OFFSET CAMERA'].contains(actionName)) { + return this.actionCameraOffset(actionArgs); + } + // CAMERA PAN + if (['CAMERA PAN', 'PAN CAMERA'].contains(actionName)) { + return this.actionCameraPan(actionArgs); + } + // CAMERA SCREEN + if (actionName === 'CAMERA SCREEN') { + return this.actionCameraScreen(actionArgs); + } + // RESET CAMERA + if (actionName === 'RESET CAMERA') { + return this.actionResetCamera(actionArgs); + } + // RESET ZOOM + if (actionName === 'RESET ZOOM') { + return this.actionResetZoom(actionArgs); + } + // WAIT FOR CAMERA + if (actionName === 'WAIT FOR CAMERA') { + return this.actionWaitForCamera(); + } + // WAIT FOR ZOOM + if (actionName === 'WAIT FOR ZOOM') { + return this.actionWaitForZoom(); + } + // ZOOM + if (actionName === 'ZOOM') { + return this.actionZoom(actionArgs); + } + return Yanfly.ASP3.BattleManager_processActionSequence.call(this, + actionName, actionArgs); +}; + +Yanfly.ASP3.BattleManager_actionPerformFinish = + BattleManager.actionPerformFinish; +BattleManager.actionPerformFinish = function() { + this.actionResetZoom([30]); + this.resetCamera([30]); + return Yanfly.ASP3.BattleManager_actionPerformFinish.call(this); +}; + +BattleManager.actionCameraClamp = function(actionName) { + if (!ConfigManager.battleCamera) return true; + if (actionName === 'CAMERA CLAMP ON') { + this._cameraClamp = true; + } else if (actionName === 'CAMERA CLAMP OFF') { + this._cameraClamp = false; + } + return true; +}; + +BattleManager.actionCameraFocus = function(actionArgs) { + if (!ConfigManager.battleCamera) return true; + this._cameraFocusGroup = this.makeActionTargets(actionArgs[0]); + if (this._cameraFocusGroup.length < 1) return false; + var type = (actionArgs[1]) ? actionArgs[1].toUpperCase() : 'CENTER'; + var frames = actionArgs[2] || 30; + if (['FRONT BASE', 'FRONT FOOT', 'FRONT FEET'].contains(type)) { + this._cameraFocusPosX = 'FRONT'; + this._cameraFocusPosY = 'BASE'; + } else if (['BASE', 'FOOT', 'FEET'].contains(type)) { + this._cameraFocusPosX = 'MIDDLE'; + this._cameraFocusPosY = 'BASE'; + } else if (['BACK BASE', 'BACK FOOT', 'BACK FEET'].contains(type)) { + this._cameraFocusPosX = 'BACK'; + this._cameraFocusPosY = 'BASE'; + } else if (['FRONT CENTER', 'FRONT MIDDLE', 'FRONT'].contains(type)) { + this._cameraFocusPosX = 'FRONT'; + this._cameraFocusPosY = 'MIDDLE'; + } else if (['CENTER', 'MIDDLE'].contains(type)) { + this._cameraFocusPosX = 'MIDDLE'; + this._cameraFocusPosY = 'MIDDLE'; + } else if (['BACK CENTER', 'BACK MIDDLE', 'BACK'].contains(type)) { + this._cameraFocusPosX = 'BACK'; + this._cameraFocusPosY = 'MIDDLE'; + } else if (['FRONT HEAD', 'FRONT TOP'].contains(type)) { + this._cameraFocusPosX = 'FRONT'; + this._cameraFocusPosY = 'TOP'; + } else if (['HEAD', 'TOP'].contains(type)) { + this._cameraFocusPosX = 'MIDDLE'; + this._cameraFocusPosY = 'TOP'; + } else if (['BACK HEAD', 'BACK TOP'].contains(type)) { + this._cameraFocusPosX = 'BACK'; + this._cameraFocusPosY = 'TOP'; + } else { + this._cameraFocusPosX = 'MIDDLE'; + this._cameraFocusPosY = 'MIDDLE'; + } + $gameScreen.setCameraDuration(frames) + return true; +}; + +BattleManager.actionCameraOffset = function(actionArgs) { + if (!ConfigManager.battleCamera) return true; + var cmd = actionArgs[0].toUpperCase(); + if (['LEFT'].contains(cmd)) { + this._cameraOffsetX = -1 * eval(actionArgs[1]) || 100;; + } else if (['RIGHT'].contains(cmd)) { + this._cameraOffsetX = eval(actionArgs[1]) || 100;; + } else if (['UP'].contains(cmd)) { + this._cameraOffsetY = -1 * eval(actionArgs[1]) || 100;; + } else if (['DOWN'].contains(cmd)) { + this._cameraOffsetY = eval(actionArgs[1]) || 100;; + } + return true; +}; + +BattleManager.actionCameraPan = function(actionArgs) { + if (!ConfigManager.battleCamera) return true; + var cmd = actionArgs[0].toUpperCase(); + var frames = 30; + if (['LEFT'].contains(cmd)) { + this._cameraX -= eval(actionArgs[1]) || 100;; + frames = actionArgs[2] || 30; + } else if (['RIGHT'].contains(cmd)) { + this._cameraX += eval(actionArgs[1]) || 100;; + frames = actionArgs[2] || 30; + } else if (['UP'].contains(cmd)) { + this._cameraY -= eval(actionArgs[1]) || 100;; + frames = actionArgs[2] || 30; + } else if (['DOWN'].contains(cmd)) { + this._cameraY += eval(actionArgs[1]) || 100;; + frames = actionArgs[2] || 30; + } + $gameScreen.setCameraDuration(frames) + return true; +}; + +BattleManager.actionCameraScreen = function(actionArgs) { + if (!ConfigManager.battleCamera) return true; + var cmd = actionArgs[0].toUpperCase(); + var frames = 30; + if (['TOP LEFT', 'UPPER LEFT'].contains(cmd)) { + this._cameraX = 0; + this._cameraY = 0; + frames = actionArgs[1] || 30; + } else if (['FAR LEFT', 'ABSOLUTE LEFT'].contains(cmd)) { + this._cameraX = 0; + this._cameraY = Graphics.boxHeight / 2; + frames = actionArgs[1] || 30; + } else if (['BOTTOM LEFT', 'LOWER LEFT'].contains(cmd)) { + this._cameraX = 0; + this._cameraY = Graphics.boxHeight; + frames = actionArgs[1] || 30; + } else if (['TOP CENTER', 'UPPER CENTER'].contains(cmd)) { + this._cameraX = Graphics.boxWidth / 2; + this._cameraY = 0; + frames = actionArgs[1] || 30; + } else if (['CENTER', 'MIDDLE'].contains(cmd)) { + this._cameraX = Graphics.boxWidth / 2; + this._cameraY = Graphics.boxHeight / 2; + frames = actionArgs[1] || 30; + } else if (['BOTTOM CENTER', 'LOWER CENTER'].contains(cmd)) { + this._cameraX = Graphics.boxWidth / 2; + this._cameraY = Graphics.boxHeight; + frames = actionArgs[1] || 30; + } else if (['TOP RIGHT', 'UPPER RIGHT'].contains(cmd)) { + this._cameraX = Graphics.boxWidth; + this._cameraY = 0; + frames = actionArgs[1] || 30; + } else if (['FAR RIGHT', 'ABSOLUTE RIGHT'].contains(cmd)) { + this._cameraX = Graphics.boxWidth; + this._cameraY = Graphics.boxHeight / 2; + frames = actionArgs[1] || 30; + } else if (['BOTTOM RIGHT', 'LOWER RIGHT'].contains(cmd)) { + this._cameraX = Graphics.boxWidth; + this._cameraY = Graphics.boxHeight; + frames = actionArgs[1] || 30; + } else if (['POINT', 'POSITION', 'COORDINATE', 'SCREEN', 'SCREEN POS', + 'COORDINATES'].contains(cmd)) { + this._cameraX = eval(actionArgs[1]) || 0; + this._cameraY = eval(actionArgs[2]) || 0; + frames = actionArgs[3] || 30; + } else { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return false; + var type = actionArgs[1].toUpperCase(); + var frames = actionArgs[2] || 30; + if (['FRONT BASE', 'FRONT FOOT', 'FRONT FEET', + 'FRONT'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'FRONT'); + this._cameraY = this.targetPosY(targets, 'BASE'); + } else if (['BASE', 'FOOT', 'FEET'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'MIDDLE'); + this._cameraY = this.targetPosY(targets, 'BASE'); + } else if (['BACK BASE', 'BACK FOOT', 'BACK FEET', + 'BACK'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'BACK'); + this._cameraY = this.targetPosY(targets, 'BASE'); + } else if (['FRONT CENTER', 'FRONT MIDDLE'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'FRONT'); + this._cameraY = this.targetPosY(targets, 'MIDDLE'); + } else if (['CENTER', 'MIDDLE'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'MIDDLE'); + this._cameraY = this.targetPosY(targets, 'MIDDLE'); + } else if (['BACK CENTER', 'BACK MIDDLE',].contains(type)) { + this._cameraX = this.targetPosX(targets, 'BACK'); + this._cameraY = this.targetPosY(targets, 'MIDDLE'); + } else if (['FRONT HEAD', 'FRONT TOP'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'FRONT'); + this._cameraY = this.targetPosY(targets, 'TOP'); + } else if (['HEAD', 'TOP'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'MIDDLE'); + this._cameraY = this.targetPosY(targets, 'TOP'); + } else if (['BACK HEAD', 'BACK TOP'].contains(type)) { + this._cameraX = this.targetPosX(targets, 'BACK'); + this._cameraY = this.targetPosY(targets, 'TOP'); + } else { + return true; + } + } + $gameScreen.setCameraDuration(frames) + return true; +}; + +BattleManager.actionResetCamera = function(actionArgs) { + var duration = parseInt(actionArgs[0]) || 30; + this.resetCamera(duration); + return true; +}; + +BattleManager.actionResetZoom = function(actionArgs) { + var duration = parseInt(actionArgs[0]) || 30; + $gameScreen.startBattleZoom(1, duration); + return true; +}; + +BattleManager.actionWaitForCamera = function() { + if (!ConfigManager.battleCamera) return true; + this._logWindow.waitForCamera(); + return false; +}; + +BattleManager.actionWaitForZoom = function() { + if (!ConfigManager.battleCamera) return true; + this._logWindow.waitForZoom(); + return false; +}; + +BattleManager.actionZoom = function(actionArgs) { + if (!ConfigManager.battleCamera) return true; + if (actionArgs[0].match(/(\d+)([%%])/i)) { + var scale = parseFloat(RegExp.$1 * 0.01) || 1.0; + } else { + var scale = parseFloat(actionArgs[0]) || 1.0; + } + var duration = parseInt(actionArgs[1]) || 30; + $gameScreen.startBattleZoom(scale, duration); + return true; +}; + +Yanfly.ASP3.BattleManager_setup = BattleManager.setup; +BattleManager.setup = function(troopId, canEscape, canLose) { + this.resetCamera(); + this.actionResetZoom([1]); + Yanfly.ASP3.BattleManager_setup.call(this, troopId, canEscape, canLose); +}; + +BattleManager.resetCamera = function(duration) { + this._cameraX = Graphics.boxWidth / 2; + this._cameraY = Graphics.boxHeight / 2; + this._cameraOffsetX = 0; + this._cameraOffsetY = 0; + this._cameraFocusGroup = []; + this._cameraFocusPosX = 'BASE'; + this._cameraFocusPosY = 'BASE'; + this._cameraClamp = true; + $gameScreen.setCameraDuration(duration); +}; + +BattleManager.cameraClamp = function() { + return this._cameraClamp; +}; + +BattleManager.cameraX = function() { + if (this._cameraFocusGroup.length > 0) { + var value = this.cameraFocusX(); + } else { + var value = this._cameraX; + } + value += this._cameraOffsetX; + return value; +}; + +BattleManager.cameraY = function() { + if (this._cameraFocusGroup.length > 0) { + var value = this.cameraFocusY(); + } else { + var value = this._cameraY; + } + value += this._cameraOffsetY; + return value; +}; + +BattleManager.cameraFocusX = function() { + var i = this.targetPosX(this._cameraFocusGroup, this._cameraFocusPosX); + return i; +}; + +BattleManager.cameraFocusY = function() { + var i = this.targetPosY(this._cameraFocusGroup, this._cameraFocusPosY); + return i; +}; + +BattleManager.targetPosX = function(group, position) { + var value = 0; + if (position === 'MIDDLE') { + for (var i = 0; i < group.length; ++i) { + var battler = group[i]; + if (!battler) continue; + value += battler.cameraPosX(); + } + } else if (position === 'FRONT') { + for (var i = 0; i < group.length; ++i) { + var battler = group[i]; + if (!battler) continue; + if (battler.isActor()) var offset = -1 * battler.spriteWidth() / 2; + if (battler.isEnemy()) var offset = battler.spriteWidth() / 2; + value = Math.max(battler.cameraPosX() + offset, value); + } + value *= group.length; + } else if (position === 'BACK') { + value = Graphics.boxWidth; + for (var i = 0; i < group.length; ++i) { + var battler = group[i]; + if (!battler) continue; + if (battler.isActor()) var offset = battler.spriteWidth() / 2; + if (battler.isEnemy()) var offset = -1 * battler.spriteWidth() / 2; + value = Math.min(battler.cameraPosX() + offset, value); + } + value *= group.length; + } + value /= group.length; + return value; +}; + +BattleManager.targetPosY = function(group, position) { + var value = 0; + if (position === 'BASE') { + for (var i = 0; i < group.length; ++i) { + var battler = group[i]; + if (!battler) continue; + value = Math.max(battler.cameraPosY(), value); + } + value *= group.length; + } else if (position === 'MIDDLE') { + for (var i = 0; i < group.length; ++i) { + var battler = group[i]; + if (!battler) continue; + value += battler.cameraPosY() - battler.spriteHeight() / 2; + } + } else if (position === 'TOP') { + value = Graphics.boxHeight; + for (var i = 0; i < group.length; ++i) { + var battler = group[i]; + if (!battler) continue; + value = Math.min(battler.cameraPosY() - battler.spriteHeight(), value); + } + value *= group.length; + } + value /= group.length; + return value; +}; + +//============================================================================= +// Spriteset_Battle +//============================================================================= + +Spriteset_Battle.prototype.updatePosition = function() { + var zoom = $gameScreen.zoomScale(); + var clamp = BattleManager.cameraClamp(); + this.scale.x = zoom; + this.scale.y = zoom; + var screenX = -1 * $gameScreen.zoomX() * zoom + Graphics.boxWidth / 2; + var screenY = -1 * $gameScreen.zoomY() * zoom + Graphics.boxHeight / 2; + if (clamp && zoom >= 1.0) { + var clampX1 = -Graphics.boxWidth * zoom + Graphics.boxWidth; + var clampY2 = -Graphics.boxHeight * zoom + Graphics.boxHeight; + this.x = Math.round(screenX.clamp(clampX1, 0)); + this.y = Math.round(screenY.clamp(clampY2, 0)); + } else if (clamp && zoom < 1.0) { + this.x = Math.round((Graphics.boxWidth - Graphics.boxWidth * zoom) / 2); + this.y = Math.round((Graphics.boxHeight - Graphics.boxHeight * zoom) / 2); + } else { + this.x = Math.round(screenX); + this.y = Math.round(screenY); + } +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.cameraPosX = function() { + var value = this.spritePosX(); + return value; +}; + +Game_Battler.prototype.cameraPosY = function() { + var value = this.spritePosY(); + if (Imported.YEP_X_ActSeqPack2) { + value -= this.battler().getFloatHeight() * this.spriteHeight(); + value -= this.battler().getJumpHeight() * this.spriteHeight(); + } + return value; +}; + +//============================================================================= +// Game_Screen +//============================================================================= + +Yanfly.ASP3.Game_Screen_clearZoom = Game_Screen.prototype.clearZoom; +Game_Screen.prototype.clearZoom = function() { + Yanfly.ASP3.Game_Screen_clearZoom.call(this); + this._cameraDuration = 0; +}; + +Yanfly.ASP3.Game_Screen_update = Game_Screen.prototype.update; +Game_Screen.prototype.update = function() { + Yanfly.ASP3.Game_Screen_update.call(this); + this.updateBattleCamera(); +}; + +Game_Screen.prototype.startBattleZoom = function(scale, duration) { + this._zoomScaleTarget = scale; + this._zoomDuration = duration; +}; + +Game_Screen.prototype.isZooming = function() { + return this._zoomDuration > 0; +}; + +Game_Screen.prototype.setCameraDuration = function(duration) { + this._cameraDuration = duration; +}; + +Game_Screen.prototype.updateBattleCamera = function() { + if (!$gameParty.inBattle()) return; + if (this._cameraDuration > 0) { + var d = this._cameraDuration; + var tx = BattleManager.cameraX(); + var ty = BattleManager.cameraY(); + this._zoomX = (this._zoomX * (d - 1) + tx) / d; + this._zoomY = (this._zoomY * (d - 1) + ty) / d; + this._cameraDuration--; + } else { + this._zoomX = BattleManager.cameraX(); + this._zoomY = BattleManager.cameraY(); + } +}; + +Game_Screen.prototype.isBattleCameraPanning = function() { + if ($gameParty.inBattle()) return this._cameraDuration > 0; + return false; +}; + +//============================================================================= +// ConfigManager +//============================================================================= + +ConfigManager.battleCamera = true; + +Yanfly.ASP3.ConfigManager_makeData = ConfigManager.makeData; +ConfigManager.makeData = function() { + var config = Yanfly.ASP3.ConfigManager_makeData.call(this); + config.battleCamera = this.battleCamera; + return config; +}; + +Yanfly.ASP3.ConfigManager_applyData = ConfigManager.applyData; +ConfigManager.applyData = function(config) { + Yanfly.ASP3.ConfigManager_applyData.call(this, config); + this.battleCamera = this.readConfigBattleCamera(config, 'battleCamera'); +}; + +ConfigManager.readConfigBattleCamera = function(config, name) { + var value = config[name]; + if (value !== undefined) { + return value; + } else { + return true; + } +}; + +//============================================================================= +// Window_Options +//============================================================================= + +Yanfly.ASP3.Window_Options_addGeneralOptions = + Window_Options.prototype.addGeneralOptions; +Window_Options.prototype.addGeneralOptions = function() { + Yanfly.ASP3.Window_Options_addGeneralOptions.call(this); + if (!Imported.YEP_OptionsCore) { + this.addCommand(Yanfly.Param.ASP3CameraOption, 'battleCamera'); + } +}; + +//============================================================================= +// Window_BattleLog +//============================================================================= + +Yanfly.ASP3.Window_BattleLog_updateWaitMode = + Window_BattleLog.prototype.updateWaitMode; +Window_BattleLog.prototype.updateWaitMode = function() { + if (this._waitMode === 'camera') { + if ($gameScreen.isBattleCameraPanning()) return true; + } else if (this._waitMode === 'zoom') { + if ($gameScreen.isZooming()) return true; + } + return Yanfly.ASP3.Window_BattleLog_updateWaitMode.call(this); +}; + +Window_BattleLog.prototype.waitForCamera = function() { + this.setWaitMode('camera'); +}; + +Window_BattleLog.prototype.waitForZoom = function() { + this.setWaitMode('zoom'); +}; + +//============================================================================= +// Scene_Map +//============================================================================= + +Yanfly.ASP3.Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded; +Scene_Map.prototype.onMapLoaded = function() { + Yanfly.ASP3.Scene_Map_onMapLoaded.call(this); + $gameScreen.clearZoom(); +}; + +//============================================================================= +// End of File +//============================================================================= +}; diff --git a/js/plugins/YEP_X_AnimatedSVEnemies.js b/js/plugins/YEP_X_AnimatedSVEnemies.js new file mode 100644 index 0000000..ace4242 --- /dev/null +++ b/js/plugins/YEP_X_AnimatedSVEnemies.js @@ -0,0 +1,2809 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle Engine Extension - Animated Sideview Enemies +// YEP_X_AnimatedSVEnemies.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_AnimatedSVEnemies = true; + +var Yanfly = Yanfly || {}; +Yanfly.SVE = Yanfly.SVE || {}; +Yanfly.SVE.version = 1.20; + +//============================================================================= + /*: + * @plugindesc v1.20 (Requires YEP_BattleEngineCore.js) This plugin lets + * you use Animated Sideview Actors for enemies! + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Anchor X + * @parent ---General--- + * @type number + * @decimals 1 + * @desc Sets the default anchor position of the sprite. + * Default: 0.5 + * @default 0.5 + * + * @param Anchor Y + * @parent ---General--- + * @type number + * @decimals 1 + * @desc Sets the default anchor position of the sprite. + * Default: 1.0 + * @default 1.0 + * + * @param Sprite Smoothing + * @parent ---General--- + * @type boolean + * @on Enable + * @off Disable + * @desc Enable Sprite Smoothing? This is a global setting. + * NO - false YES - true + * @default true + * + * @param Sprite Width + * @parent ---General--- + * @desc Sets the minimum width for sideview sprites. + * Use 'auto' for automatic detection. Default: 64 + * @default auto + * + * @param Sprite Height + * @parent ---General--- + * @desc Sets the minimum height for sideview sprites. + * Use 'auto' for automatic detection. Default: 64 + * @default auto + * + * @param Collapse + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc When a sprite dies, have it collapse and vanish? + * NO - false YES - true + * @default false + * + * @param Frame Speed + * @parent ---General--- + * @type number + * @min 0 + * @desc The default frame speed used in between motions. + * Default: 12 + * @default 12 + * + * @param Show State Overlay + * @parent ---General--- + * @type boolean + * @on Show + * @off Hide + * @desc Show state overlays on sideview enemies? + * NO - false YES - true + * @default true + * + * @param ---Shadows--- + * @default + * + * @param Show Shadow + * @parent ---Shadows--- + * @type boolean + * @on Show + * @off Hide + * @desc Show shadows on sideview enemies? + * NO - false YES - true + * @default false + * + * @param Shadow Scale X + * @parent ---Shadows--- + * @desc Sets the default horizontal shadow scale. + * Use 'auto' for automatic detection. Default: 1 + * @default auto + * + * @param Shadow Scale Y + * @parent ---Shadows--- + * @desc Sets the default vertical shadow scale. + * Use 'auto' for automatic detection. Default: 1 + * @default auto + * + * @param ---Breathing--- + * @default + * + * @param Enable Breathing + * @parent ---Breathing--- + * @desc Breathing option for enemies. + * @type select + * @option None + * @value 0 + * @option Static + * @value 1 + * @option Sideview + * @value 2 + * @option Both + * @value 3 + * 0 - None, 1 - Static, 2 - Sideview, 3 - Both + * @default 1 + * + * @param Breathing Speed + * @parent ---Breathing--- + * @type number + * @min 0 + * @desc The default breathing rate for enemies. + * Lower - Faster Larger - Slower + * @default 20 + * + * @param Breathing X Rate + * @parent ---Breathing--- + * @type number + * @decimals 3 + * @desc The default breathing X rate for enemies. + * Lower - Static Larger - Dynamic + * @default 0.001 + * + * @param Breathing Y Rate + * @parent ---Breathing--- + * @type number + * @decimals 3 + * @desc The default breathing Y rate for enemies. + * Lower - Static Larger - Dynamic + * @default 0.020 + * + * @param HP Link Breathing + * @parent ---Breathing--- + * @type boolean + * @on Link + * @off Don't Link + * @desc Link breathing rate to HP Rate? + * NO - false YES - true + * @default false + * + * @param ---Floating--- + * @default + * + * @param Floating Speed + * @parent ---Floating--- + * @type number + * @min 0 + * @desc The default floating speed for enemies. + * Lower - Faster Larger - Slower + * @default 20 + * + * @param Floating Rate + * @parent ---Floating--- + * @type number + * @decimals 1 + * @desc The default floating rate for enemies. + * Lower - Faster Larger - Slower + * @default 0.3 + * + * @param Floating Height + * @parent ---Floating--- + * @type number + * @min 0 + * @desc The default minimum floating height for enemies. + * Lower - Closer to Ground Larger - Higher Up + * @default 50 + * + * @param Floating Death + * @parent ---Floating--- + * @type boolean + * @on Allow + * @off Disallow + * @desc Allow enemies to remain floating while dead? + * NO - false YES - true + * @default true + * + * @param ---Motions--- + * @default + * + * @param Attack Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the default attack motion for no weapons. + * Attack Motion Types: swing thrust missile + * @default thrust + * + * @param Idle Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's idle motion. + * Default: walk + * @default walk + * + * @param Damage Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's taking damage motion. + * Default: damage + * @default damage + * + * @param Evade Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's evasion motion. + * Default: evade + * @default evade + * + * @param Escape Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's escape motion. + * Default: escape + * @default escape + * + * @param Guard Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's guard motion. + * Default: guard + * @default guard + * + * @param Abnormal Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's abnormal (status afflicted) motion. + * Default: abnormal + * @default abnormal + * + * @param Sleep Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's sleeping motion. + * Default: sleep + * @default sleep + * + * @param Dying Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's dying (crisis) motion. + * Default: dying + * @default dying + * + * @param Dead Motion + * @parent ---Motions--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Sets the sprite's dead motion. + * Default: dead + * @default dead + * + * @param ---Weapons--- + * @default + * + * @param Weapon Image Index + * @parent ---Weapons--- + * @type number + * @min 0 + * @desc Sets the default weapon image index for the sprite. + * Use 0 for no image. + * @default 0 + * + * @param Weapon 1 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 1: Dagger Motion: swing + * @default swing + * + * @param Weapon 1 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 6 + * + * @param Weapon 2 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 2: Sword Motion: swing + * @default swing + * + * @param Weapon 2 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 6 + * + * @param Weapon 3 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 3: Flail Motion: swing + * @default swing + * + * @param Weapon 3 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 4 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 4: Axe Motion: swing + * @default swing + * + * @param Weapon 4 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 6 + * + * @param Weapon 5 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 5: Whip Motion: swing + * @default swing + * + * @param Weapon 5 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 6 + * + * @param Weapon 6 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 6: Staff Motion: swing + * @default swing + * + * @param Weapon 6 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 7 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 7: Long Bow Motion: missile + * @default missile + * + * @param Weapon 7 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 11 + * + * @param Weapon 8 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 8: Crossbow Motion: missile + * @default missile + * + * @param Weapon 8 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 11 + * + * @param Weapon 9 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 9: Gun Motion: missile + * @default missile + * + * @param Weapon 9 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 111 + * + * @param Weapon 10 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 10: Claw Motion: thrust + * @default thrust + * + * @param Weapon 10 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 16 + * + * @param Weapon 11 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 11: Glove Motion: thrust + * @default thrust + * + * @param Weapon 11 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 12 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 12: Spear Motion: thrust + * @default thrust + * + * @param Weapon 12 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 11 + * + * @param Weapon 13 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 13: Mace Motion: swing + * @default swing + * + * @param Weapon 13 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 14 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 14: Rod Motion: swing + * @default swing + * + * @param Weapon 14 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 15 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 15: Club Motion: swing + * @default swing + * + * @param Weapon 15 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 16 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 16: Chain Motion: swing + * @default swing + * + * @param Weapon 16 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 6 + * + * @param Weapon 17 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 17: Sword#2 Motion: swing + * @default swing + * + * @param Weapon 17 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 7 + * + * @param Weapon 18 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 18: Iron Pipe Motion: swing + * @default swing + * + * @param Weapon 18 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 19 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 19: Sling Shot Motion: missile + * @default missile + * + * @param Weapon 19 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 11 + * + * @param Weapon 20 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 20: Shotgun Motion: missile + * @default missile + * + * @param Weapon 20 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 111 + * + * @param Weapon 21 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 21: Rifle Motion: missile + * @default missile + * + * @param Weapon 21 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 111 + * + * @param Weapon 22 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 22: Chainsaw Motion: thrust + * @default thrust + * + * @param Weapon 22 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 7 + * + * @param Weapon 23 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 23: Railgun Motion: missile + * @default missile + * + * @param Weapon 23 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 15 + * + * @param Weapon 24 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 24: Stun Rod Motion: thrust + * @default thrust + * + * @param Weapon 24 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 15 + * + * @param Weapon 25 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 25: Spell Book Motion: swing + * @default swing + * + * @param Weapon 25 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 26 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 26: custom Motion: thrust + * @default thrust + * + * @param Weapon 26 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 27 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 27: custom Motion: thrust + * @default thrust + * + * @param Weapon 27 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 28 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 28: custom Motion: thrust + * @default thrust + * + * @param Weapon 28 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 29 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 29: custom Motion: thrust + * @default thrust + * + * @param Weapon 29 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @param Weapon 30 Motion + * @parent ---Weapons--- + * @type combo + * @option swing + * @option thrust + * @option missile + * @option walk + * @option wait + * @option chant + * @option guard + * @option damage + * @option evade + * @option skill + * @option spell + * @option item + * @option escape + * @option victory + * @option dying + * @option abnormal + * @option sleep + * @option dead + * @desc Motion used by default for this weapon image. + * Weapon 30: custom Motion: thrust + * @default thrust + * + * @param Weapon 30 Animation + * @parent ---Weapons--- + * @type animation + * @desc Battle animation used by default for this weapon image. + * @default 1 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin requires YEP_BattleEngineCore. + * Make sure this plugin is located under YEP_BattleEngineCore in the + * plugin list. + * + * This extension plugin allows you to animate enemies in a number of ways, + * from giving static enemies breathing, floating, and scaled attributes to + * utilizing animated sideview actors as potential battlers for your enemies + * instead of static graphics to help make your enemies appear more lively! + * + * If you are using YEP_X_ActSeqPack2, and would like the ability to add in + * floating enemies, place this plugin under YEP_X_ActSeqPack2 as well. + * + * To use this plugin, insert within the enemy's notebox the notetags you see + * in the section below: + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * Insert these notetags into the enemy noteboxes below to change their + * sidewview battler aspects. + * + * Enemy Notetags: + * + * --- General --- + * + * + * + * Enables or disables a 'breathing' effect for the enemy sprite. + * + * + * How many frames does it take to make a full breathing cycle? The lower the + * x value, the faster the enemy breathes. The higher the x value, the slower + * the enemy breathes. + * + * + * + * Sets the horizontal and vertical breathing rate to x.y. 1.0 is a 100% + * variance change while 0.0 is a 0% variance. + * + * + * + * Will enable/disable HP Link Breathing. The lower the HP on the enemy, the + * slower the enemy will breathe. + * + * + * Sets the enemy to be animated as if it was floating. + * + * + * How many frames does it take to do a full floating cycle? The lower the x + * value, the faster the enemy floats. The higher the x value, the slower the + * enemy floats. + * + * + * Sets the floating rate for the enemy to x.y. 1.0 is a 100% variance change + * while 0.0 is a 0% variance change. + * + * + * Sets the minimum float height for the enemy to x. + * + * + * + * Decide whether or not this particular enemy will float while dead or + * instead, drop to the ground instantly and will bypass the 'Floating Death' + * plugin parameter for the particular enemy. + * + * + * This allows you to scale the sprite larger or smaller by x% of the + * original sprite size. If you wish to only scale either the width or the + * height, use the notetags below: + * + * + * + * This will scale the sprite's width or height by x% amount specifically + * rather than the whole sprite itself by the same ratio. + * + * --- Sideview --- + * + * + * This is the filename used for the sideview battler found within your + * project's img/sv_actors/ folder. Doing this will enable the following + * notetags to be applied to the battler. This is case-sensitive and used + * without the image's file extension. + * + * *Example: SF_Actor3_8.png would be + * + * *Note: If more than one of these tags is used, the sideview battler + * selected will be picked from a random pool. Their settings, however, will + * match all of the other sideview settings set in the notetags for the sake + * of simplicity. + * + * --- Sideview Specific --- + * + * + * + * This sets the anchor location for the enemy's sideview battler at y.z. + * This is used for the event you have an odd-proportioned sideview battler. + * + * + * + * Sets the width/height of the sideview battler. This is for the event + * you're using a battler image that may have different proportions than + * normal sideview battlers. + * + * + * Sets it so that the enemy when it dies will collapse and vanish. + * + * + * Sets it so that the enemy when it dies will leave behind a corpse and + * will not vanish. + * + * + * Sets the frame speed of this sideview battler to x. The lower the x value, + * the faster the sideview battler animates. The higher it is, the slower the + * battler animates. + * + * --- State Overlays --- + * + * + * + * This will either show or hide the state overlay for the sideview enemy and + * ignore the default setting within the plugin parameters. + * + * --- Motions --- + * + * + * + * + * Sets the basic attack motion for your sideview enemy if the sideview + * enemy is not using any weapons. You can use any of the following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * This sets the sprite's weapon image to x. If you haven't modified your + * system images of the weapons, they would be as follows: + * + * 0 - Nothing + * 1 - Dagger 7 - Long Bow 13 - Mace 19 - Slingshot 25 - Book + * 2 - Sword 8 - Crossbow 14 - Rod 20 - Shotgun 26 - Custom + * 3 - Flail 9 - Gun 15 - Club 21 - Rifle 27 - Custom + * 4 - Axe 10 - Claw 16 - Chain 22 - Chainsaw 28 - Custom + * 5 - Whip 11 - Glove 17 - Sword#2 23 - Railgun 29 - Custom + * 6 - Staff 12 - Spear 18 - Iron Pipe 24 - Stun Rod 30 - Custom + * + * * Note: Inserting multiple of these notetags will put them inside a random + * pool of weapons to use. Keep in mind if you use this notetag, it will use + * all the default settings found in the plugin's parameters. If you wish to + * use more unique settings, use the notetag below: + * + * + * This sets the sprite's weapon image to x, motion to y, and attack + * animation to z. An example of how this notetag would be used would be + * as such: + * + * + * + * This will give the battler a sword with the swing motion and playing + * battle animation 6 when attacking. + * + * + * Sets the idling motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * * Note: Inserting multiple of these notetags will put them inside a random + * pool of motions to use. + * + * + * Sets the damaged motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the evasion motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the escaping motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the guard motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the abnormal motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the sleep motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the dying (crisis) motion for your sideview enemy. You can use any + * of the following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * + * Sets the dead motion for your sideview enemy. You can use any of the + * following motions: + * walk wait chant guard damage evade + * thrust swing missile skill spell item + * escape victory dying abnormal sleep dead + * + * --- Shadows --- + * + * + * Sets it so the enemy will show its shadow for its sideview sprite. The + * default setting of this is tied to Battle Engine Core's 'Show Shadows'. + * + * + * Sets it so the enemy will hide its shadow for its sideview sprite. The + * default setting of this is tied to Battle Engine Core's 'Show Shadows'. + * + * + * Sets the shadow width to x% larger/smaller than the default shadow size + * found within the img/system folder. + * + * + * Sets the shadow height to x% larger/smaller than the default shadow size + * found within the img/system folder. + * + * State Notetags: + * + * + * This will cause the animated sideview enemy battler to hide its sideview + * weapon effect. The attack motion will revert back to the barehanded attack + * motion set for the enemy and the attack animation will be the enemy's + * default attack animation. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.20: + * - Bugfix provided by YoraeRasante regarding the animation positioning on + * animated sideview enemies. + * + * Version 1.19: + * - Bugfix provided by SwiftIllusion regarding the animation positioning on + * animated sideview enemies. + * + * Version 1.18: + * - Updated for RPG Maker MV version 1.5.0. + * + * Verison 1.17: + * - Visual graphic update to sync attack animations properly with how actor + * animations are now handled in the more updated RPG Maker MV versions. + * + * Version 1.16: + * - Added 'Floating Death' plugin parameter. + * - Optimization update. + * + * Version 1.15: + * - Updated for RPG Maker MV version 1.3.2. + * + * Version 1.14: + * - Pixi4 update to fix bug that caused state icons to fly off the screen. + * - Fixed a compatibility issue with YEP_X_VisualStateFX regarding state + * sprites being disabled and causing crashes. + * + * Version 1.13: + * - Compatibility update with YEP_X_VisualStateFX to disable State Overlays on + * enemies properly. + * + * Version 1.12: + * - Fixed a bug that caused the and + * notetags to not work. + * - Fixed a bug that caused scaled enemies to have their state icons and + * overlays appear in odd places. + * + * Version 1.11: + * - Fixed a bug that caused hidden enemies to appear early on. + * + * Version 1.10: + * - Optimized plugin to use less resources. Animated enemies will no longer + * have a static graphic once the game is loaded. + * + * Version 1.09: + * - Added a fix for state icons appearing behind battlers for the users who + * aren't using the Action Sequence Packs. + * + * Version 1.08: + * - State Icon and State Overlays will now synch together for floating and + * jumping battlers. + * + * Version 1.07: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.06a: + * - Fixed a bug that prevented animated sideview enemies from not mirroring. + * - Added and + * notetags to make certain enemies show/hide state overlays. + * - Fixed a bug that was caused by motion notetags not retrieved properly. + * + * Version 1.05: + * - Made adjustments to the notetag to also affect the + * location of the state icons and effects. + * + * Version 1.04: + * - Fixed a bug with Sprite Smoothing disabled on Shadows. + * - Fixed a bug with the anchor Y positions being overwritten. + * + * Version 1.03: + * - Fixed a bug that would cause & + * notetags to crash the game. + * + * Version 1.02: + * - Synchronized state icons and overlays with floating enemies. + * + * Version 1.01: + * - Added 'HP Link Breathing' plugin parameter. If enabled, the lower the HP, + * the slower the enemy breathes. + * - Added and notetags. + * + * Version 1.00: + * - Finished plugin! Hooray! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +if (Yanfly.BEC.version && Yanfly.BEC.version >= 1.42) { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_AnimatedSVEnemies'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.SVEAnchorX = Number(Yanfly.Parameters['Anchor X']); +Yanfly.Param.SVEAnchorY = Number(Yanfly.Parameters['Anchor Y']); +Yanfly.Param.SVESmoothing = eval(String(Yanfly.Parameters['Sprite Smoothing'])); +Yanfly.Param.SVEWidth = String(Yanfly.Parameters['Sprite Width']); +Yanfly.Param.SVEWidth = Yanfly.Param.SVEWidth.toLowerCase(); +Yanfly.Param.SVEHeight = String(Yanfly.Parameters['Sprite Height']); +Yanfly.Param.SVEHeight = Yanfly.Param.SVEHeight.toLowerCase(); +Yanfly.Param.SVECollapse = eval(String(Yanfly.Parameters['Collapse'])); +Yanfly.Param.SVEFrameSpeed = Number(Yanfly.Parameters['Frame Speed']); +Yanfly.Param.SVEOverlay = eval(String(Yanfly.Parameters['Show State Overlay'])); + +Yanfly.Param.SVEBreathing = Number(Yanfly.Parameters['Enable Breathing']); +Yanfly.Param.SVEBreathSpeed = Number(Yanfly.Parameters['Breathing Speed']); +Yanfly.Param.SVEBreathXRate = Number(Yanfly.Parameters['Breathing X Rate']); +Yanfly.Param.SVEBreathYRate = Number(Yanfly.Parameters['Breathing Y Rate']); +Yanfly.Param.SVELinkBreathing = eval(Yanfly.Parameters['HP Link Breathing']); + +Yanfly.Param.SVEFloatSpeed = Number(Yanfly.Parameters['Floating Speed']); +Yanfly.Param.SVEFloatRate = Number(Yanfly.Parameters['Floating Rate']); +Yanfly.Param.SVEFloatHeight = Number(Yanfly.Parameters['Floating Height']); +Yanfly.Param.SVEFloatDeath = String(Yanfly.Parameters['Floating Death']); +Yanfly.Param.SVEFloatDeath = eval(Yanfly.Param.SVEFloatDeath); + +Yanfly.Param.SVEShowShadow = eval(String(Yanfly.Parameters['Show Shadow'])); +Yanfly.Param.SVEShadowScaleX = String(Yanfly.Parameters['Shadow Scale X']); +Yanfly.Param.SVEShadowScaleY = String(Yanfly.Parameters['Shadow Scale Y']); + +Yanfly.Param.SVEAttackMotion = String(Yanfly.Parameters['Attack Motion']); +Yanfly.Param.SVEIdleMotion = String(Yanfly.Parameters['Idle Motion']); +Yanfly.Param.SVEDmgMotion = String(Yanfly.Parameters['Damage Motion']); +Yanfly.Param.SVEEvadeMotion = String(Yanfly.Parameters['Evade Motion']); +Yanfly.Param.SVEEscMotion = String(Yanfly.Parameters['Escape Motion']); +Yanfly.Param.SVEGuardMotion = String(Yanfly.Parameters['Guard Motion']); +Yanfly.Param.SVEAbnMotion = String(Yanfly.Parameters['Abnormal Motion']); +Yanfly.Param.SVESleepMotion = String(Yanfly.Parameters['Sleep Motion']); +Yanfly.Param.SVEDyingMotion = String(Yanfly.Parameters['Dying Motion']); +Yanfly.Param.SVEDeadMotion = String(Yanfly.Parameters['Dead Motion']); + +Yanfly.Param.SVEWeaponIndex = Number(Yanfly.Parameters['Weapon Image Index']); +Yanfly.Param.SVEWeaponMotion = {}; +Yanfly.Param.SVEWeaponAnimation = {}; +Yanfly.Param.SVEWeaponMotion[0] = Yanfly.Param.SVEAttackMotion.toLowerCase(); +for (Yanfly.i = 1; Yanfly.i < 31; ++Yanfly.i) { + Yanfly.s1 = 'Weapon ' + Yanfly.i + ' Motion'; + Yanfly.s2 = String(Yanfly.Parameters[Yanfly.s1]); + Yanfly.Param.SVEWeaponMotion[Yanfly.i] = Yanfly.s2.toLowerCase(); + Yanfly.s1 = 'Weapon ' + Yanfly.i + ' Animation'; + Yanfly.s2 = Number(Yanfly.Parameters[Yanfly.s1]); + Yanfly.Param.SVEWeaponAnimation[Yanfly.i] = Yanfly.s2; +}; + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.SVE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.SVE.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_X_AnimatedSVEnemies) { + this.processSVENotetags1($dataEnemies); + this.processSVENotetags2($dataStates); + Yanfly._loaded_YEP_X_AnimatedSVEnemies = true; + } + return true; +}; + +DataManager.processSVENotetags1 = function(group) { + var noteWeapon = /<(?:SIDEVIEW WEAPON):[ ](\d+),[ ](.*),[ ](\d+)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.sideviewBattler = []; + obj.sideviewAttackMotion = Yanfly.Param.SVEAttackMotion.toLowerCase(); + obj.sideviewIdleMotion = []; + obj.sideviewDmgMotion = Yanfly.Param.SVEDmgMotion.toLowerCase(); + obj.sideviewEvadeMotion = Yanfly.Param.SVEEvadeMotion.toLowerCase(); + obj.sideviewEscMotion = Yanfly.Param.SVEEscMotion.toLowerCase(); + obj.sideviewGuardMotion = Yanfly.Param.SVEGuardMotion.toLowerCase(); + obj.sideviewAbnMotion = Yanfly.Param.SVEAbnMotion.toLowerCase(); + obj.sideviewSleepMotion = Yanfly.Param.SVESleepMotion.toLowerCase(); + obj.sideviewDyingMotion = Yanfly.Param.SVEDyingMotion.toLowerCase(); + obj.sideviewDeadMotion = Yanfly.Param.SVEDeadMotion.toLowerCase(); + obj.sideviewAnchorX = Yanfly.Param.SVEAnchorX; + obj.sideviewAnchorY = Yanfly.Param.SVEAnchorY; + obj.sideviewWeaponImage = []; + obj.sideviewWidth = Yanfly.Param.SVEWidth; + obj.sideviewHeight = Yanfly.Param.SVEHeight; + obj.sideviewCollapse = Yanfly.Param.SVECollapse; + obj.sideviewShadowShow = Yanfly.Param.SVEShowShadow; + obj.sideviewShadowScaleX = Yanfly.Param.SVEShadowScaleX; + obj.sideviewShadowScaleY = Yanfly.Param.SVEShadowScaleY; + obj.spriteScaleX = 1; + obj.spriteScaleY = 1; + obj.sideviewFrameSpeed = Yanfly.Param.SVEFrameSpeed; + obj.sideviewBreathing = [1, 3].contains(Yanfly.Param.SVEBreathing); + obj.sideviewBreathSpeed = Math.max(1, Yanfly.Param.SVEBreathSpeed); + obj.sideviewBreathXRate = Math.max(0, Yanfly.Param.SVEBreathXRate); + obj.sideviewBreathYRate = Math.max(0, Yanfly.Param.SVEBreathYRate); + obj.sideviewLinkBreathing = Yanfly.Param.SVELinkBreathing; + obj.sideviewFloating = false; + obj.sideviewFloatSpeed = Yanfly.Param.SVEFloatSpeed; + obj.sideviewFloatRate = Yanfly.Param.SVEFloatRate; + obj.sideviewFloatHeight = Yanfly.Param.SVEFloatHeight; + obj.sideviewFloatDeath = Yanfly.Param.SVEFloatDeath; + obj.sideviewStateOverlay = Yanfly.Param.SVEOverlay; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:SCALE SPRITE):[ ](\d+)([%%])>/i)) { + obj.spriteScaleX = parseFloat(RegExp.$1) * 0.01; + obj.spriteScaleY = obj.spriteScaleX; + } else if (line.match(/<(?:SCALE SPRITE WIDTH):[ ](\d+)([%%])>/i)) { + obj.spriteScaleX = parseFloat(RegExp.$1) * 0.01; + } else if (line.match(/<(?:SCALE SPRITE HEIGHT):[ ](\d+)([%%])>/i)) { + obj.spriteScaleY = parseFloat(RegExp.$1) * 0.01; + } else if (line.match(/<(?:SIDEVIEW BATTLER):[ ](.*)>/i)) { + obj.sideviewBattler.push(String(RegExp.$1)); + obj.sideviewBreathing = [2, 3].contains(Yanfly.Param.SVEBreathing); + } else if (line.match(/<(?:SIDEVIEW ATTACK MOTION):[ ](.*)>/i)) { + obj.sideviewAttackMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW IDLE MOTION):[ ](.*)>/i)) { + obj.sideviewIdleMotion.push(String(RegExp.$1).toLowerCase()); + } else if (line.match(/<(?:SIDEVIEW DAMAGE MOTION):[ ](.*)>/i)) { + obj.sideviewDmgMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW EVADE MOTION):[ ](.*)>/i)) { + obj.sideviewEvadeMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW ESCAPE MOTION):[ ](.*)>/i)) { + obj.sideviewEscMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW GUARD MOTION):[ ](.*)>/i)) { + obj.sideviewGuardMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW ABNORMAL MOTION):[ ](.*)>/i)) { + obj.sideviewAbnMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW SLEEP MOTION):[ ](.*)>/i)) { + obj.sideviewSleepMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW DYING MOTION):[ ](.*)>/i)) { + obj.sideviewDyingMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW DEAD MOTION):[ ](.*)>/i)) { + obj.sideviewDeadMotion = String(RegExp.$1).toLowerCase(); + } else if (line.match(/<(?:SIDEVIEW ANCHOR X):[ ](\d+)[.](\d+)>/i)) { + obj.sideviewAnchorX = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + } else if (line.match(/<(?:SIDEVIEW ANCHOR Y):[ ](\d+)[.](\d+)>/i)) { + obj.sideviewAnchorY = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + } else if (line.match(/<(?:SIDEVIEW WEAPON):[ ](\d+)>/i)) { + var weaponId = parseInt(RegExp.$1); + var motionId = Yanfly.Param.SVEWeaponMotion[weaponId].toLowerCase(); + var aniId = Yanfly.Param.SVEWeaponAnimation[weaponId]; + var index = obj.sideviewWeaponImage.length; + obj.sideviewWeaponImage[index] = [weaponId, motionId, aniId]; + } else if (line.match(noteWeapon)) { + var weaponId = parseInt(RegExp.$1); + var motionId = String(RegExp.$2).toLowerCase(); + var aniId = parseInt(RegExp.$3); + var index = obj.sideviewWeaponImage.length; + obj.sideviewWeaponImage[index] = [weaponId, motionId, aniId]; + } else if (line.match(/<(?:SIDEVIEW WIDTH):[ ](\d+)>/i)) { + obj.sideviewWidth = parseInt(RegExp.$1); + } else if (line.match(/<(?:SIDEVIEW HEIGHT):[ ](\d+)>/i)) { + obj.sideviewHeight = parseInt(RegExp.$1); + } else if (line.match(/<(?:SIDEVIEW COLLAPSE)>/i)) { + obj.sideviewCollapse = true; + } else if (line.match(/<(?:SIDEVIEW NO COLLAPSE)>/i)) { + obj.sideviewCollapse = false; + } else if (line.match(/<(?:SIDEVIEW SHOW SHADOW)>/i)) { + obj.sideviewShadowShow = true; + } else if (line.match(/<(?:SIDEVIEW HIDE SHADOW)>/i)) { + obj.sideviewShadowShow = false; + } else if (line.match(/<(?:SIDEVIEW SHADOW WIDTH):[ ](\d+)([%%])>/i)) { + obj.sideviewShadowScaleX = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(/<(?:SIDEVIEW SHADOW HEIGHT):[ ](\d+)([%%])>/i)) { + obj.sideviewShadowScaleY = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(/<(?:SIDEVIEW FRAME SPEED):[ ](\d+)>/i)) { + obj.sideviewFrameSpeed = parseInt(RegExp.$1); + } else if (line.match(/<(?:FLOATING|float)>/i)) { + obj.sideviewFloating = true; + } else if (line.match(/<(?:FLOATING SPEED):[ ](\d+)>/i)) { + obj.sideviewFloatSpeed = Math.max(1, parseInt(RegExp.$1)); + } else if (line.match(/<(?:FLOATING RATE):[ ](\d+)[.](\d+)>/i)) { + var rate = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + obj.sideviewFloatRate = rate; + } else if (line.match(/<(?:FLOATING HEIGHT):[ ](\d+)>/i)) { + obj.sideviewFloatHeight = parseInt(RegExp.$1); + } else if (line.match(/<(?:FLOATING DEATH|FLOAT DEATH)>/i)) { + obj.sideviewFloatDeath = true; + } else if (line.match(/<(?:NO FLOATING DEATH|NO FLOAT DEATH)>/i)) { + obj.sideviewFloatDeath = false; + } else if (line.match(//i)) { + obj.sideviewStateOverlay = true; + } else if (line.match(//i)) { + obj.sideviewStateOverlay = false; + } + } + // Breathing + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:BREATHING)>/i)) { + obj.sideviewBreathing = true; + } else if (line.match(/<(?:NO BREATHING)>/i)) { + obj.sideviewBreathing = false; + } else if (line.match(/<(?:BREATHING SPEED):[ ](\d+)>/i)) { + obj.sideviewBreathSpeed = Math.max(1, parseInt(RegExp.$1)); + } else if (line.match(/<(?:BREATHING RATE X):[ ](\d+)[.](\d+)>/i)) { + var rate = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + obj.sideviewBreathXRate = rate; + } else if (line.match(/<(?:BREATHING RATE Y):[ ](\d+)[.](\d+)>/i)) { + var rate = eval(String(RegExp.$1) + '.' + String(RegExp.$2)); + obj.sideviewBreathYRate = rate; + } else if (line.match(/<(?:ENABLE HP LINK BREATHING)>/i)) { + obj.sideviewLinkBreathing = true; + } else if (line.match(/<(?:DISABLE HP LINK BREATHING)>/i)) { + obj.sideviewLinkBreathing = false; + } + } + // Create Defaults + if (obj.sideviewIdleMotion.length <= 0) { + obj.sideviewIdleMotion = [Yanfly.Param.SVEIdleMotion.toLowerCase()]; + } + if (obj.sideviewWeaponImage.length <= 0) { + var weaponId = Yanfly.Param.SVEWeaponIndex; + var motionId = Yanfly.Param.SVEWeaponMotion[weaponId].toLowerCase(); + var aniId = Yanfly.Param.SVEWeaponAnimation[weaponId]; + obj.sideviewWeaponImage = [[weaponId, motionId, aniId]]; + } + obj.sideviewFrameSpeed = Math.max(1, obj.sideviewFrameSpeed); + if (obj.sideviewBattler.length > 0) { + if (Imported.YEP_X_BattleSysCTB) { + Yanfly.Param.CTBEnemySVBattler = true; + } + obj.battlerName = ''; + obj.battlerHue = 0; + } + } +}; + +DataManager.processSVENotetags2 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.hideSVWeapon; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:HIDE SIDEVIEW WEAPON)>/i)) { + obj.hideSVWeapon = true; + } + } + } +}; + +//============================================================================= +// ImageManager +//============================================================================= + +if (Yanfly.Param.SVESmoothing) { + +ImageManager.loadSvActor = function(filename, hue) { + return this.loadBitmap('img/sv_actors/', filename, hue, true); +}; + +ImageManager.loadSystemSmooth = function(filename, hue) { + return this.loadBitmap('img/system/', filename, hue, true); +}; + +}; // Yanfly.Param.SVESmoothing + +//============================================================================= +// Game_Battler +//============================================================================= + +Yanfly.SVE.Game_Battler_spriteWidth = Game_Battler.prototype.spriteWidth; +Game_Battler.prototype.spriteWidth = function() { + if (this.isSideviewDimensions('width')) { + var value = this.sideviewWidth(); + } else { + var value = Yanfly.SVE.Game_Battler_spriteWidth.call(this); + } + //value *= Math.abs(this.spriteScaleX()); + return Math.floor(value); +}; + +Yanfly.SVE.Game_Battler_spriteHeight = Game_Battler.prototype.spriteHeight; +Game_Battler.prototype.spriteHeight = function() { + if (this.isSideviewDimensions('height')) { + var value = this.sideviewHeight(); + } else { + var value = Yanfly.SVE.Game_Battler_spriteHeight.call(this); + } + //value *= Math.abs(this.spriteScaleY()); + return Math.floor(value); +}; + +Game_Battler.prototype.isSideviewDimensions = function(value) { + if (!this.isEnemy()) return false; + if (!this.hasSVBattler()) return false; + if (value === 'width') return this.sideviewWidth() !== 'auto'; + if (value === 'height') return this.sideviewHeight() !== 'auto'; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.actor = function() { + return this.enemy(); +}; + +Game_Enemy.prototype.clearSVAttributes = function() { + this._svWeaponImageId = undefined; + this._svAttackMotion = undefined; + this._svAttackAnimationId = undefined; + this._svBattlerName = undefined; + this._svIdleMotion = undefined; +}; + +Game_Enemy.prototype.setupSVAttributes = function() { + var array = this.enemy().sideviewWeaponImage; + var newArray = Yanfly.Util.getRandomElement(array); + this._svWeaponImageId = newArray[0]; + this._svAttackMotion = newArray[1]; + this._svAttackAnimationId = newArray[2]; + if (this._svAttackAnimationId === undefined) this._svAttackAnimationId = + Yanfly.SVE.Game_Enemy_attackAnimationId.call(this); +}; + +Yanfly.SVE.Game_Enemy_attackAnimationId = + Game_Enemy.prototype.attackAnimationId; +Game_Enemy.prototype.attackAnimationId = function() { + if (this.hasSVBattler() && !this.isHideSVWeapon()) { + if (this._svAttackAnimationId) return this._svAttackAnimationId; + this.setupSVAttributes(); + return this._svAttackAnimationId; + } + return Yanfly.SVE.Game_Enemy_attackAnimationId.call(this); +}; + +Game_Enemy.prototype.svBattlerName = function() { + if (this._svBattlerName) return this._svBattlerName; + var array = this.enemy().sideviewBattler; + this._svBattlerName = Yanfly.Util.getRandomElement(array); + return this._svBattlerName; +}; + +Game_Enemy.prototype.hasSVBattler = function() { + return this.svBattlerName() !== undefined; +}; + +Game_Enemy.prototype.weaponImageId = function() { + if (this.isHideSVWeapon()) return 0; + if (this._svWeaponImageId) return this._svWeaponImageId; + this.setupSVAttributes(); + return this._svWeaponImageId; +}; + +Game_Enemy.prototype.attackMotion = function() { + if (this.weaponImageId() === 0) return this.enemy().sideviewAttackMotion; + if (this._svAttackMotion) return this._svAttackMotion; + this.setupSVAttributes(); + return this._svAttackMotion; +}; + +Game_Enemy.prototype.idleMotion = function() { + if (this._svIdleMotion) return this._svIdleMotion; + var array = this.enemy().sideviewIdleMotion; + this._svIdleMotion = Yanfly.Util.getRandomElement(array); + return this._svIdleMotion; +}; + +Game_Enemy.prototype.damageMotion = function() { + return this.enemy().sideviewDmgMotion; +}; + +Game_Enemy.prototype.evadeMotion = function() { + return this.enemy().sideviewEvadeMotion; +}; + +Game_Enemy.prototype.escapeMotion = function() { + return this.enemy().sideviewEscMotion; +}; + +Game_Enemy.prototype.guardMotion = function() { + return this.enemy().sideviewGuardMotion; +}; + +Game_Enemy.prototype.abnormalMotion = function() { + return this.enemy().sideviewAbnMotion; +}; + +Game_Enemy.prototype.sleepMotion = function() { + return this.enemy().sideviewSleepMotion; +}; + +Game_Enemy.prototype.dyingMotion = function() { + return this.enemy().sideviewDyingMotion; +}; + +Game_Enemy.prototype.deadMotion = function() { + return this.enemy().sideviewDeadMotion; +}; + +Game_Enemy.prototype.sideviewAnchorX = function() { + return this.enemy().sideviewAnchorX; +}; + +Game_Enemy.prototype.sideviewAnchorY = function() { + return this.enemy().sideviewAnchorY; +}; + +Game_Enemy.prototype.anchorX = function() { + if (this.hasSVBattler()) return this.sideviewAnchorX(); + return Game_Battler.prototype.anchorX.call(this); +}; + +Game_Enemy.prototype.anchorY = function() { + if (this.hasSVBattler()) return this.sideviewAnchorY(); + return Game_Battler.prototype.anchorY.call(this); +}; + +Game_Enemy.prototype.sideviewWidth = function() { + return this.enemy().sideviewWidth; +}; + +Game_Enemy.prototype.sideviewHeight = function() { + return this.enemy().sideviewHeight; +}; + +Game_Enemy.prototype.sideviewCollapse = function() { + return this.enemy().sideviewCollapse; +}; + +Game_Enemy.prototype.showSideviewShadow = function() { + return this.enemy().sideviewShadowShow; +}; + +Game_Enemy.prototype.sideviewShadowScaleX = function() { + return this.enemy().sideviewShadowScaleX; +}; + +Game_Enemy.prototype.sideviewShadowScaleY = function() { + return this.enemy().sideviewShadowScaleY; +}; + +Game_Enemy.prototype.spriteScaleX = function() { + if (this.hasSVBattler()) return this.enemy().spriteScaleX * -1; + return this.enemy().spriteScaleX; +}; + +Game_Enemy.prototype.spriteScaleY = function() { + return this.enemy().spriteScaleY; +}; + +Game_Enemy.prototype.sideviewFrameSpeed = function() { + return this.enemy().sideviewFrameSpeed; +}; + +Game_Enemy.prototype.performAttack = function() { + if (!this.hasSVBattler()) { + return Game_Battler.prototype.performAttack.call(this); + } + this.forceMotion(this.attackMotion()); + this.startWeaponAnimation(this.weaponImageId()); +}; + +Game_Enemy.prototype.performAction = function(action) { + if (!this.hasSVBattler()) { + return Game_Battler.prototype.performAction.call(this, action); + } + Game_Actor.prototype.performAction.call(this, action); +}; + +Yanfly.SVE.Game_Enemy_performDamage = Game_Enemy.prototype.performDamage; +Game_Enemy.prototype.performDamage = function() { + if (!this.hasSVBattler()) { + return Yanfly.SVE.Game_Enemy_performDamage.call(this); + } + Game_Battler.prototype.performDamage.call(this); + if (this.isSpriteVisible()) { + this.requestMotion(this.damageMotion()); + } else { + $gameScreen.startShake(5, 5, 10); + } + SoundManager.playEnemyDamage(); +}; + +Game_Enemy.prototype.performEvasion = function() { + Game_Battler.prototype.performEvasion.call(this); + if (!this.hasSVBattler()) return; + this.requestMotion(this.evadeMotion()); +}; + +Game_Enemy.prototype.performMagicEvasion = function() { + Game_Battler.prototype.performMagicEvasion.call(this); + if (!this.hasSVBattler()) return; + this.requestMotion(this.evadeMotion()); +}; + +Game_Enemy.prototype.performCounter = function() { + Game_Battler.prototype.performCounter.call(this); + if (!this.hasSVBattler()) return; + this.performAttack(); +}; + +Game_Enemy.prototype.performEscape = function() { + if (!this.hasSVBattler()) return; + if (!this.canMove()) return; + this.requestMotion(this.escapeMotion()); +}; + +Game_Enemy.prototype.isBreathing = function() { + if (this.isDead()) return false; + return this.enemy().sideviewBreathing; +}; + +Game_Enemy.prototype.breathingSpeed = function() { + return this.enemy().sideviewBreathSpeed; +}; + +Game_Enemy.prototype.breathXRate = function() { + return this.enemy().sideviewBreathXRate; +}; + +Game_Enemy.prototype.breathYRate = function() { + return this.enemy().sideviewBreathYRate; +}; + +Game_Enemy.prototype.linkBreathing = function() { + return this.enemy().sideviewLinkBreathing; +}; + +Game_Enemy.prototype.isFloating = function() { + if (this.isDead() && !this.enemy().sideviewFloatDeath) return false; + return this.enemy().sideviewFloating; +}; + +Game_Enemy.prototype.floatSpeed = function() { + return this.enemy().sideviewFloatSpeed; +}; + +Game_Enemy.prototype.floatRate = function() { + return this.enemy().sideviewFloatRate; +}; + +Game_Enemy.prototype.floatHeight = function() { + return this.enemy().sideviewFloatHeight; +}; + +Game_Enemy.prototype.isHideSVWeapon = function() { + var max = this.states().length; + for (var i = 0; i < max; ++i) { + var state = this.states()[i]; + if (state && state.hideSVWeapon) return true; + } + return false; +}; + +Yanfly.SVE.Game_Enemy_transform = Game_Enemy.prototype.transform; +Game_Enemy.prototype.transform = function(enemyId) { + this.clearSVAttributes(); + Yanfly.SVE.Game_Enemy_transform.call(this, enemyId); + this.battler().setTransform(this); + this.battler().setBattler(this); +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Yanfly.SVE.Game_Party_requestMotionRefresh = + Game_Party.prototype.requestMotionRefresh; +Game_Party.prototype.requestMotionRefresh = function() { + Yanfly.SVE.Game_Party_requestMotionRefresh.call(this); + $gameTroop.requestMotionRefresh(); +}; + +//============================================================================= +// Sprite_Enemy +//============================================================================= + +Yanfly.SVE.Sprite_Enemy_initMembers = Sprite_Enemy.prototype.initMembers; +Sprite_Enemy.prototype.initMembers = function() { + Yanfly.SVE.Sprite_Enemy_initMembers.call(this); + this._battlerName = null; + this.initSVSprites(); +}; + +Sprite_Enemy.prototype.initSVSprites = function() { + this._svRand = Math.random() * 10000; + this._svBattlerName = ''; + this._motion = null; + this._motionCount = 0; + this._pattern = 0; + this._svBattlerEnabled = false; + this.createShadowSprite(); + this.createWeaponSprite(); + this.createMainSprite(); + this.createStateSprite(); + this._effectTarget = this; +}; + +Sprite_Enemy.prototype.setTransform = function(battler) { + this._shadowSprite.opacity = 0; + this._weaponSprite.opacity = 0; + this._mainSprite.opacity = 0; + this._stateSprite.opacity = 0; + if (battler.svBattlerName()) { + this.createShadowSprite(); + this.createWeaponSprite(); + this.createMainSprite(); + this.createStateSprite(); + this._shadowSprite.opacity = 255; + this._weaponSprite.opacity = 255; + this._mainSprite.opacity = 255; + this._stateSprite.opacity = 255; + } +}; + +Sprite_Enemy.prototype.createMainSprite = function() { + Sprite_Actor.prototype.createMainSprite.call(this); +}; + +Sprite_Enemy.prototype.createShadowSprite = function() { + this._shadowSprite = new Sprite(); + if (Yanfly.Param.SVESmoothing) { + this._shadowSprite.bitmap = ImageManager.loadSystemSmooth('Shadow2'); + } else { + this._shadowSprite.bitmap = ImageManager.loadSystem('Shadow2'); + } + this._shadowSprite.anchor.x = 0.5; + this._shadowSprite.anchor.y = 0.5; + this._shadowSprite.y = -2; + this.addChild(this._shadowSprite); + this._shadowSprite.opacity = 0; +}; + +Sprite_Enemy.prototype.createWeaponSprite = function() { + Sprite_Actor.prototype.createWeaponSprite.call(this); +}; + +Sprite_Enemy.prototype.createStateSprite = function() { + if (Imported.YEP_X_VisualStateFX) { + if (!Yanfly.Param.VSFXEnemyOver) return; + } + Sprite_Actor.prototype.createStateSprite.call(this); +}; + +Yanfly.SVE.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler; +Sprite_Enemy.prototype.setBattler = function(battler) { + this._svBattlerEnabled = false; + this.initSVSprites(); + Yanfly.SVE.Sprite_Enemy_setBattler.call(this, battler); + this.setSVBattler(battler); +}; + +Sprite_Enemy.prototype.setMirror = function(value) { + if (this._svBattlerEnabled) value = !value; + Sprite_Battler.prototype.setMirror.call(this, value); +}; + +Sprite_Enemy.prototype.setSVBattler = function(battler) { + if (!this._enemy) return; + if (this._enemy.svBattlerName() === undefined) return; + this._adjustMainBitmapSettings = false; + this._actor = this._enemy; + this._svBattlerEnabled = true; + if (this._stateSprite) this._stateSprite.setup(battler); +}; + +Yanfly.SVE.Sprite_Enemy_update = Sprite_Enemy.prototype.update; +Sprite_Enemy.prototype.update = function() { + Yanfly.SVE.Sprite_Enemy_update.call(this); + if (this._svBattlerEnabled) this.updateMotion(); + this.updateBreathing(); + if (!Imported.YEP_X_ActSeqPack2) this.updateStateIconHeight(); +}; + +Yanfly.SVE.Sprite_Enemy_updateStateSprite = + Sprite_Enemy.prototype.updateStateSprite; +Sprite_Enemy.prototype.updateStateSprite = function() { + if (this._enemy && this._enemy.hasSVBattler()) { + this.updateSVStateSprite(); + } else { + Yanfly.SVE.Sprite_Enemy_updateStateSprite.call(this); + } + this.updateFloatingStateSprite(); +}; + +Sprite_Enemy.prototype.updateSVStateSprite = function() { + if (!this._stateSprite) return; + this._stateSprite.visible = this._enemy.enemy().sideviewStateOverlay; + return; + var height = this._enemy.spriteHeight() * -1; + height -= Sprite_StateIcon._iconHeight; + this._stateIconSprite.y = height; + this._stateSprite.y = (this._enemy.spriteHeight() - 64) * -1; +}; + +Sprite_Enemy.prototype.updateFloatingStateSprite = function() { + if (this._enemy && this._enemy.isFloating()) { + var heightRate = this.addFloatingHeight(); + var height = this._enemy.spriteHeight(); + this._stateIconSprite.y += Math.ceil(heightRate * height); + this._stateSprite.y += Math.ceil(heightRate * height); + }; +}; + +Sprite_Enemy.prototype.updateBreathing = function() { + if (!this._enemy) return; + if (this._enemy.isBreathing()) { + var c = Graphics.frameCount + this._svRand; + var s = this._enemy.breathingSpeed(); + var rateX = this._enemy.breathXRate(); + var rateY = this._enemy.breathYRate(); + if (this._enemy.linkBreathing()) s /= this._enemy.hpRate(); + var scaleX = Math.cos(c / s) * rateX; + var scaleY = Math.cos(c / s) * rateY; + } else { + var scaleX = 0; + var scaleY = 0; + } + var mirror = this.scale.x > 0 ? 1 : -1; + this.scale.x = this._enemy.spriteScaleX() + scaleX; + this.scale.x = Math.abs(this.scale.x) * mirror; + this.scale.y = this._enemy.spriteScaleY() + scaleY; +}; + +if (Imported.YEP_X_ActSeqPack2) { + +Yanfly.SVE.Sprite_Battler_getFloatHeight = + Sprite_Battler.prototype.getFloatHeight; +Sprite_Battler.prototype.getFloatHeight = function() { + var value = Yanfly.SVE.Sprite_Battler_getFloatHeight.call(this); + value -= this.addFloatingHeight(); + return value; +}; + +Sprite_Battler.prototype.addFloatingHeight = function() { + value = 0; + if (this._enemy && this._enemy.isFloating()) { + var c = Graphics.frameCount + this._svRand; + var s = this._enemy.floatSpeed(); + var rate = this._enemy.floatRate(); + value += Math.cos(c / s) * rate - rate; + var height = this._enemy.floatHeight(); + value -= height / this._enemy.spriteHeight(); + } + return value; +}; + +} else { // If YEP_X_ActSeqPack2 is NOT installed + +Sprite_Enemy.prototype.updateStateIconHeight = function() { + if (!this._stateIconSprite) return; + var height = this._battler.spriteHeight() * -1; + height -= Sprite_StateIcon._iconHeight; + height /= this.scale.y; + this._stateIconSprite.y = height; +}; + +} // Imported.YEP_X_ActSeqPack2 + +Yanfly.SVE.Sprite_Enemy_updateBitmap = Sprite_Enemy.prototype.updateBitmap; +Sprite_Enemy.prototype.updateBitmap = function() { + Yanfly.SVE.Sprite_Enemy_updateBitmap.call(this); + if (!this._svBattlerEnabled) this.updateScale(); + this.updateSVBitmap(); + this.adjustAnchor(); +}; + +Sprite_Enemy.prototype.updateSVBitmap = function() { + Sprite_Battler.prototype.updateBitmap.call(this); + var name = this._enemy.svBattlerName(); + if (this._svBattlerEnabled && this._svBattlerName !== name) { + this._createdDummyMainSprite = false; + this._svBattlerName = name; + this._mainSprite.bitmap = ImageManager.loadSvActor(name); + this.adjustAnchor(); + this.refreshMotion(); + this.updateScale(); + } else if (this._svBattlerName === '') { + this._svBattlerName = ''; + this._svBattlerEnabled = false; + if (this._createdDummyMainSprite) return; + this._createdDummyMainSprite = true; + this._mainSprite = new Sprite_Base(); + this._mainSprite.anchor.x = 0.5; + this._mainSprite.anchor.y = 1; + } +}; + +Sprite_Enemy.prototype.adjustAnchor = function() { + if (!this._mainSprite) return; + this._mainSprite.anchor.x = this._enemy.sideviewAnchorX(); + this._mainSprite.anchor.y = this._enemy.sideviewAnchorY(); +}; + +Sprite_Enemy.prototype.updateScale = function() { + this.scale.x = this._enemy.spriteScaleX(); + this.scale.y = this._enemy.spriteScaleY(); + if (this._stateIconSprite) { + var safe = 1 / 100000; + var sprite = this._stateIconSprite; + sprite.scale.x = 1 / Math.max(safe, Math.abs(this.scale.x)); + sprite.scale.y = 1 / Math.max(safe, Math.abs(this.scale.y)); + } +}; + +Yanfly.SVE.Sprite_Enemy_updateFrame = Sprite_Enemy.prototype.updateFrame; +Sprite_Enemy.prototype.updateFrame = function() { + if (this._svBattlerEnabled) return this.updateSVFrame(); + Yanfly.SVE.Sprite_Enemy_updateFrame.call(this); +}; + +Sprite_Enemy.prototype.updateSVFrame = function() { + Sprite_Battler.prototype.updateFrame.call(this); + var bitmap = this._mainSprite.bitmap; + if (bitmap.width <= 0) return; + this._effectTarget = this._mainSprite; + var motionIndex = this._motion ? this._motion.index : 0; + var pattern = this._pattern < 3 ? this._pattern : 1; + var cw = bitmap.width / 9; + var ch = bitmap.height / 6; + var cx = Math.floor(motionIndex / 6) * 3 + pattern; + var cy = motionIndex % 6; + var cdh = 0; + if (this._effectType === 'bossCollapse') { + cdh = ch - this._effectDuration; + } + // this.setFrame(cx * cw, cy * ch, cw, ch); + this._mainSprite.setFrame(cx * cw, cy * ch, cw, ch - cdh); + this.adjustMainBitmapSettings(bitmap); + this.adjustSVShadowSettings(); +}; + +Sprite_Enemy.prototype.adjustMainBitmapSettings = function(bitmap) { + if (this._adjustMainBitmapSettings) return; + this._adjustMainBitmapSettings = true; + var svw = this._enemy.sideviewWidth(); + var svh = this._enemy.sideviewHeight(); + if (svw === 'auto') svw = bitmap.width / 9; + if (svh === 'auto') svh = bitmap.height / 6; + svw = Math.floor(Math.abs(svw * this._enemy.spriteScaleX())); + svh = Math.floor(Math.abs(svh * this._enemy.spriteScaleY())); + this.bitmap = new Bitmap(svw, svh); +}; + +Sprite_Enemy.prototype.adjustSVShadowSettings = function() { + if (this._enemy.showSideviewShadow()) this._shadowSprite.opacity = 255; + var scaleX = this._enemy.sideviewShadowScaleX(); + var scaleY = this._enemy.sideviewShadowScaleY(); + if (scaleX === 'auto') scaleX = this._mainSprite.bitmap.width / 9 / 64; + if (scaleY === 'auto') scaleY = this._mainSprite.bitmap.width / 9 / 64; + this._shadowSprite.scale.x = scaleX; + this._shadowSprite.scale.y = scaleY; +}; + +Sprite_Enemy.prototype.updateMotion = function() { + if (!this._svBattlerEnabled) return; + this.setupMotion(); + this.setupWeaponAnimation(); + if (this._enemy.isMotionRefreshRequested()) { + Sprite_Actor.prototype.refreshMotion.call(this); + this._enemy.clearMotion(); + } + this.updateMotionCount(); +}; + +Sprite_Enemy.prototype.setupMotion = function() { + if (!this._svBattlerEnabled) return; + if (!this._enemy.isMotionRequested()) return; + this.startMotion(this._enemy.motionType()); + this._enemy.clearMotion(); +}; + +Sprite_Enemy.prototype.startMotion = function(motionType) { + if (!this._svBattlerEnabled) return; + var newMotion = Sprite_Actor.MOTIONS[motionType]; + if (this._motion === newMotion) return; + this._motion = newMotion; + this._motionCount = 0; + this._pattern = 0; +}; + +Sprite_Enemy.prototype.setupWeaponAnimation = function() { + if (!this._svBattlerEnabled) return; + if (!this._enemy.isWeaponAnimationRequested()) return; + this._weaponSprite.setup(this._enemy.weaponImageId()); + this._enemy.clearWeaponAnimation(); +}; + +Sprite_Enemy.prototype.updateMotionCount = function() { + if (!this._svBattlerEnabled) return; + if (this._motion && ++this._motionCount >= this.motionSpeed()) { + if (this._motion.loop) { + this._pattern = (this._pattern + 1) % 4; + } else if (this._pattern < 2) { + this._pattern++; + } else if (this._pattern >= 2) { + this.startMotion(this._enemy.idleMotion()); + } else { + this.refreshMotion(); + } + this._motionCount = 0; + } +}; + +Sprite_Enemy.prototype.refreshMotion = function() { + if (!this._svBattlerEnabled) return; + var enemy = this._enemy; + if (!enemy) return; + var motionGuard = Sprite_Actor.MOTIONS['guard']; + if (this._motion === motionGuard && !BattleManager.isInputting()) return; + var stateMotion = enemy.stateMotionIndex(); + if (enemy.isInputting() || enemy.isActing()) { + this.startMotion('walk'); + } else if (stateMotion === 3) { + this.startMotion(enemy.deadMotion()); + } else if (stateMotion === 2) { + this.startMotion(enemy.sleepMotion()); + } else if (enemy.isGuard() || enemy.isGuardWaiting()) { + this.startMotion(enemy.guardMotion()); + } else if (stateMotion === 1) { + this.startMotion(enemy.abnormalMotion()); + } else if (enemy.isDying()) { + this.startMotion(enemy.dyingMotion()); + } else { + this.startMotion(enemy.idleMotion()); + } +}; + +Sprite_Enemy.prototype.motionSpeed = function() { + if (!this._enemy) return 12; + return this._enemy.sideviewFrameSpeed() || 12; +}; + +Sprite_Enemy.prototype.updateSelectionEffect = function() { + if (!this._svBattlerEnabled) { + return Sprite_Battler.prototype.updateSelectionEffect.call(this); + } + var target = this._mainSprite; + if (this._battler.isSelected()) { + this._selectionEffectCount++; + if (this._selectionEffectCount % 30 < 15) { + target.setBlendColor([255, 255, 255, 64]); + } else { + target.setBlendColor([0, 0, 0, 0]); + } + } else if (this._selectionEffectCount > 0) { + this._selectionEffectCount = 0; + target.setBlendColor([0, 0, 0, 0]); + } +}; + +Sprite_Enemy.prototype.isSideviewCollapse = function() { + if (!this._svBattlerEnabled) return true; + return this._enemy.sideviewCollapse(); +}; + +Yanfly.SVE.Sprite_Enemy_updateCollapse = Sprite_Enemy.prototype.updateCollapse; +Sprite_Enemy.prototype.updateCollapse = function() { + if (!this.isSideviewCollapse()) return; + if (this._svBattlerEnabled) { + this._mainSprite.blendMode = Graphics.BLEND_ADD; + this._mainSprite.setBlendColor([255, 128, 128, 128]); + this.opacity *= this._effectDuration / (this._effectDuration + 1); + } else { + Yanfly.SVE.Sprite_Enemy_updateCollapse.call(this); + } +}; + +Yanfly.SVE.Sprite_Enemy_startBossCollapse = + Sprite_Enemy.prototype.startBossCollapse; +Sprite_Enemy.prototype.startBossCollapse = function() { + if (this._svBattlerEnabled) { + this._effectDuration = Math.ceil(this._mainSprite.height * this.scale.y); + this._appeared = false; + } else { + Yanfly.SVE.Sprite_Enemy_startBossCollapse.call(this); + } +}; + +Yanfly.SVE.Sprite_Enemy_updateBossCollapse = + Sprite_Enemy.prototype.updateBossCollapse; +Sprite_Enemy.prototype.updateBossCollapse = function() { + if (!this.isSideviewCollapse()) return; + if (this._svBattlerEnabled) { + this._shake = this._effectDuration % 2 * 4 - 2; + this._mainSprite.blendMode = Graphics.BLEND_ADD; + this._mainSprite.setBlendColor([255, 255, 255, 255 - this.opacity]); + this.opacity *= this._effectDuration / (this._effectDuration + 1); + if (this._effectDuration % 20 === 19) { + SoundManager.playBossCollapse2(); + } + } else { + Yanfly.SVE.Sprite_Enemy_updateBossCollapse.call(this); + } +}; + +Yanfly.SVE.Sprite_Enemy_updateInstantCollapse = + Sprite_Enemy.prototype.updateInstantCollapse; +Sprite_Enemy.prototype.updateInstantCollapse = function() { + if (!this.isSideviewCollapse()) return; + Yanfly.SVE.Sprite_Enemy_updateInstantCollapse.call(this); +}; + +Sprite_Enemy.prototype.forceMotion = function(motionType) { + var newMotion = Sprite_Actor.MOTIONS[motionType]; + this._motion = newMotion; + this._motionCount = 0; + this._pattern = 0; +}; + +//============================================================================= +// Sprite_Animation +// ---------------------------------------------------------------------------- +// Code provided by SwiftIllusion and YoraeRasante +//============================================================================= + +Yanfly.SVE.Sprite_Animation_updatePosition = + Sprite_Animation.prototype.updatePosition; +Sprite_Animation.prototype.updatePosition = function() { + Yanfly.SVE.Sprite_Animation_updatePosition.call(this); + this.updateSvePosition(); +}; + +Sprite_Animation.prototype.updateSvePosition = function() { + if (typeof this._target.parent._battler != 'undefined' && this._target.parent._battler.isEnemy() && typeof this._target.parent._mainSprite != 'undefined'){ + if (this._animation.position !== 3) { + if (this._animation.position === 0) { + this.y += this._target.parent._mainSprite.height - this._target.parent.texture.height; + } else if (this._animation.position === 1) { + this.y += (this._target.parent._mainSprite.height - this._target.parent.texture.height) / 2; + } + } + } +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.getRandomElement = function(array) { + var value = array[Math.floor(Math.random() * array.length)]; + return value; +}; + +//============================================================================= +// End of File +//============================================================================= +} else { // Yanfly.BEC.version + +var text = '================================================================\n'; +text += 'YEP_X_AnimatedSVEnemies requires YEP_BattleEngineCore to be at the '; +text += 'latest version to run properly.\n\nPlease go to www.yanfly.moe and '; +text += 'update to the latest version for the YEP_BattleEngineCore plugin.\n'; +text += '================================================================\n'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // Yanfly.BEC.version +}; // YEP_BattleEngineCore \ No newline at end of file diff --git a/js/plugins/YEP_X_BattleSysATB.js b/js/plugins/YEP_X_BattleSysATB.js new file mode 100644 index 0000000..02e1e10 --- /dev/null +++ b/js/plugins/YEP_X_BattleSysATB.js @@ -0,0 +1,2562 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle System - Active Turn Battle +// YEP_X_BattleSysATB.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_BattleSysATB = true; + +var Yanfly = Yanfly || {}; +Yanfly.ATB = Yanfly.ATB || {}; +Yanfly.ATB.version = 1.28; + +//============================================================================= + /*: + * @plugindesc v1.28 (Requires YEP_BattleEngineCore.js) Add ATB (Active + * Turn Battle) into your game using this plugin! + * @author Yanfly Engine Plugins + * + * @param ---ATB Settings--- + * @default + * + * @param Per Tick + * @parent ---ATB Settings--- + * @desc This is how much speed is gained per tick. + * @default user.agi + * + * @param Initial Speed + * @parent ---ATB Settings--- + * @desc The speed position of the battler at the start of battle. + * This is a formula processed as an eval. + * @default 0 + * + * @param Full Gauge + * @parent ---ATB Settings--- + * @desc The target speed for an ATB gauge to be full. + * This is a formula processed as an eval. + * @default Math.max(5000, BattleManager.highestBaseAgi() * 100) + * + * @param Charge Gauge + * @parent ---ATB Settings--- + * @desc The wind-up time after selecting an action. + * This is a formula processed as an eval. + * @default Math.max(2000, BattleManager.highestBaseAgi() * 20) + * + * @param Pre-Emptive Bonuses + * @parent ---ATB Settings--- + * @type number + * @decimals 1 + * @desc How much of the ATB bar do you want filled up for an + * ATB pre-emptive bonus from 0 to 1. + * @default 0.8 + * + * @param Surprise Bonuses + * @parent ---ATB Settings--- + * @type number + * @decimals 1 + * @desc How much of the ATB bar do you want filled up for an + * ATB surprise bonus from 0 to 1. + * @default 0.8 + * + * @param ---Escape--- + * @default + * + * @param Escape Ratio + * @parent ---Escape--- + * @desc How ATB calculates escape ratios. + * Default: 0.5 * $gameParty.agility() / $gameTroop.agility() + * @default 0.125 * $gameParty.agility() / $gameTroop.agility() + * + * @param Fail Escape Boost + * @parent ---Escape--- + * @type number + * @decimals 3 + * @desc Each time the player fails escape, increase the success + * rate by this much. This is a formula. Default: 0.1 + * @default 0.025 + * + * @param ---Turn--- + * @default + * + * @param Full Turn + * @parent ---Escape--- + * @desc This is how many ticks to equal a full battle turn. + * This is a formula processed as an eval. + * @default Math.min(200, BattleManager.lowestBaseAgi() * 8) + * + * @param Flash Enemy + * @parent ---Escape--- + * @type boolean + * @on Flash + * @off Don't Flash + * @desc Flash enemies when they start charging their skills? + * NO - false YES - true + * @default true + * + * @param ---Rubberband--- + * @default + * + * @param Enable Rubberband + * @parent ---Rubberband--- + * @type boolean + * @on Enable + * @off Disable + * @desc This is an auto-balance mechanic for AGI. + * Disable - false Enable - true + * @default true + * + * @param Minimum Speed + * @parent ---Rubberband--- + * @desc If rubberbanding is enabled, what is the minimum + * speed increase? This is a formula. + * @default 0.5 * BattleManager.highestBaseAgi() + * + * @param Maximum Speed + * @parent ---Rubberband--- + * @desc If rubberbanding is enabled, what is the maximum + * speed increase? This is a formula. + * @default 1.5 * BattleManager.highestBaseAgi() + * + * @param ---Sound--- + * @default + * + * @param Ready Sound + * @parent ---Sound--- + * @type file + * @dir audio/se/ + * @require 1 + * @desc This is the sound played when the battler is ready. + * @default Decision1 + * + * @param Ready Volume + * @parent ---Sound--- + * @type number + * @min 0 + * @max 100 + * @desc This is the volume of the ready sound. + * @default 90 + * + * @param Ready Pitch + * @parent ---Sound--- + * @type number + * @min 0 + * @desc This is the pitch of the ready sound. + * @default 120 + * + * @param Ready Pan + * @parent ---Sound--- + * @type number + * @min -100 + * @max 100 + * @desc This is the pan of the ready sound. + * @default 0 + * + * @param ---Options--- + * @default + * + * @param ATB Speed Text + * @parent ---Options--- + * @desc Text used for ATB speed in options window. + * @default ATB Speed + * + * @param Default ATB Speed + * @parent ---Options--- + * @type number + * @min 0 + * @max 10 + * @desc Default speed at which the gauges fill up. + * 1 - slowest 10 - fastest + * @default 10 + * + * @param ---Windows--- + * @default + * + * @param Lock Status Window + * @parent ---Windows--- + * @type boolean + * @on Lock Status + * @off Don't Lock + * @desc While ATB is active, lock the status window from moving? + * OFF - false ON - true + * @default true + * + * @param Gauge Style + * @parent ---Windows--- + * @type select + * @option None + * @value 0 + * @option Under Name + * @value 1 + * @option Right Side + * @value 2 + * @desc This is the style of the ATB gauges: + * 0 - None 1 - Under Name 2 - Right Side + * @default 1 + * + * @param Gauge Text + * @parent ---Windows--- + * @desc If style 2 is used, this is the text displayed. + * @default Turn + * + * @param Gauge Text Align + * @parent ---Windows--- + * @type combo + * @option left + * @option center + * @option right + * @desc If style 2 is used, this is the text alignment. + * left center right + * @default center + * + * @param ATB Gauge Color 1 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc The 1st gauge color of the ATB gauge as it loads up. + * @default 13 + * + * @param ATB Gauge Color 2 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc The 2nd gauge color of the ATB gauge as it loads up. + * @default 5 + * + * @param Slow Gauge Color 1 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc 1st gauge color of the ATB gauge if actor is slowed. + * @default 12 + * + * @param Slow Gauge Color 2 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc 2nd gauge color of the ATB gauge if actor is slowed. + * @default 4 + * + * @param Fast Gauge Color 1 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc 1st gauge color of the ATB gauge if actor is hasted. + * @default 26 + * + * @param Fast Gauge Color 2 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc 2nd gauge color of the ATB gauge if actor is hasted. + * @default 27 + * + * @param Stop Gauge Color 1 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc 1st gauge color of the ATB gauge if actor is stopped. + * @default 7 + * + * @param Stop Gauge Color 2 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc 2nd gauge color of the ATB gauge if actor is stopped. + * @default 8 + * + * @param Full Gauge Color 1 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc The 1st gauge color of the ATB gauge when full. + * @default 14 + * + * @param Full Gauge Color 2 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc The 2nd gauge color of the ATB gauge when full. + * @default 6 + * + * @param Charge Gauge Color 1 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc The 1st gauge color of the ATB gauge when charging. + * @default 2 + * + * @param Charge Gauge Color 2 + * @parent ---Windows--- + * @type number + * @min 0 + * @max 31 + * @desc The 2nd gauge color of the ATB gauge when charging. + * @default 10 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * The Battle System - Active Turn Battle plugin is an extension plugin for + * Yanfly Engine Plugins' Battle Engine Core. This extension plugin will not + * work without the main plugin. + * + * To use the ATB system, go to the Battle Engine Core plugin and change the + * 'Default System' setting in the parameters to 'atb'. + * + * The Active Turn Battle system functions in such where battlers will have a + * new gauge in battle functioning as their turn gauge. As time goes by without + * anything happening such as actions, menu selection, etc, the gauge fills up. + * Once it is full, the battler can commit to an action. + * + * After committing to an action, the battler charges the skill before using it + * in battle to either attack an enemy, heal an ally, etc. Upon finishing the + * action, the gauge drains to empty and the battler must charge it up again. + * + * This is a battle system where agility plays an important factor in the + * progress of battle where higher agility values give battlers more advantage + * and lower agility values give battlers less advantage. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * To change your battle system to Active Turn Battle if it isn't the default + * battle system, you can use the following Plugin Command: + * + * Plugin Command: + * setBattleSys ATB Sets battle system to Active Turn Battle. + * setBattleSys DTB Sets battle system to Default Turn Battle. + * + * Using the above Plugin Commands, you can toggle between the Default Battle + * System and Active Turn Battle! + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * The following are notetags that pertain to and affect the ATB system. + * + * Skill and Item Notetags: + * + * text + * text + * + * For those planning on using multiple battle systems, sometimes you may + * have your skills perform differently while using ATB. If so, using this + * notetag will allow skills and items to display different help text while + * ATB is enabled. + * + * + * + * + * Usable only during ATB. This sets the target's current speed or charge to + * x. If 'speed' or 'charge' is used, it will only affect those gauges while + * in the respective phase. If 'gauge' is used, it will affect either. + * + * + * + * + * Usable only during ATB. This sets the target's current speed or charge to + * x% of the whole gauge. If 'speed' or 'charge' is used, it will only affect + * those gauges while in the respective phase. If 'gauge' is used, it will + * affect either. + * + * or + * or + * or + * Usable only during ATB. This increases or decreases the target's current + * speed or charge by x. If 'speed' or 'charge' is used, it will only affect + * those gauges while in the respective phase. If 'gauge' is used, it will + * affect either. + * + * or + * or + * or + * Usable only during ATB. This increases or decreases the target's current + * speed or charge by x% of the whole gauge. If 'speed' or 'charge' is used, + * it will only affect those gauges while in the respective phase. If 'gauge' + * is used, it will affect either. + * + * + * + * This will set the skill/item user's ATB speed value to x or x%. If 'x' is + * used, this will be the exact ATB value. If x% is used, this will be the + * percentage of the ATB gauge that it will be at. + * + * + * + * This will give the skill the ability to interrupt and cancel out the + * target's current action while it is in the charging phase. If the 'x%' + * notetag version is used, it will have a x% chance of success. + * + * + * This causes the skill to be unable to be interrupted and prevent the + * battler's ATB to reset. + * + * Actor, Class, Enemy, Weapon, Armor, and State Notetags: + * + * + * Usable only during ATB. This will give the actor, class, enemy, weapon, + * armor, or state the property of starting battle with X ATB Speed or X% of + * the ATB gauge filled up. + * + * + * + * Usable only during ATB. This will give the actor, class, enemy, weapon, + * armor, or state the property of starting a turn with X ATB Speed or X% of + * the ATB gauge filled up. + * + * ============================================================================ + * Lunatic Mode - Conditional ATB Speed and Conditional ATB Charge + * ============================================================================ + * + * For those who have a bit of JavaScript experience and would like to have + * more unique ways of performing ATB speed and charge changes, you can use the + * following notetags: + * + * Skill and Item Notetags: + * + * speed = x; + * charge = x; + * + * You can omit speed and/or charge. Whatever you set 'speed' to will change + * the ATB speed of the target. If the target is charging, 'charge' will + * cause the target's charge to change to that value. To make things more + * simple, 'max' will be the full gauge value. + * + * Here is an example: + * + * + * speed = target.hp / target.mhp * max; + * charge = target.hp / target.mhp * max; + * + * The above code will set the user's current ATB gauge to position equal to + * the target's HP ratio. If the target has 25% HP, the ATB gauge will go to + * 25% full for the target. + * + * --- --- --- --- --- + * + * + * speed = x; + * + * This is the ATB set after the user has used the skill/item and the custom + * ATB amount you want the user to be at after. 'max' be the value of the + * full gauge value. Whatever you set 'speed', the user's ATB speed value + * will change to that much: + * + * Here is an example: + * + * + * speed = user.mp / user.mmp * max; + * + * The above code will set the user's ATB gauge after using the skill/item to + * equal the user's MP ratio. If the user has 25% MP, the ATB gauge will go + * to 25% full for the user. + * + * --- --- --- --- --- + * + * + * interrupt = true; + * + * This will allow you to set custom conditions for interrupting a target. + * Keep in mind that even though it is a custom condition, it still requires + * the target to be in the charging phase for the interrupt to work. By + * setting 'interrupt = true', the target will be interrupted. + * + * Here is an example: + * + * + * if (user.hp > target.hp) { + * interrupt = true; + * } + * + * The above code will state that if the user has more HP than the target, + * the target will be interrupted. + * + * ============================================================================ + * Yanfly Engine Plugins - Battle Engine Extension - Action Sequence Commands + * ============================================================================ + * + * You can make use of these extra ATB related action sequences. + * + *============================================================================= + * ATB CHARGE: target, X + * ATB CHARGE: target, X% + * ATB CHARGE: targets, +X + * ATB CHARGE: targets, +X% + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usable only for ATB. Sets the target's ATB charge to X or X%. This only + * applies when the target is in the ATB charge phase. This will not affect + * the user to prevent mechanical issues. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: atb charge: targets, +5000 + * atb charge: target, -50% + *============================================================================= + * + *============================================================================= + * ATB GAUGE: target, X + * ATB GAUGE: target, X% + * ATB GAUGE: targets, +X + * ATB GAUGE: targets, +X% + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usable only for ATB. Sets the target's ATB speed or charge (whichever the + * user is currently filling up) to X or X%. This only. This will not affect + * the user to prevent mechanical issues. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: atb gauge: targets, +5000 + * atb gauge: target, -50% + *============================================================================= + * + *============================================================================= + * ATB INTERRUPT: target + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usable only for ATB. If the target is in the charging phase, interrupt it. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: atb interrupt: targets + *============================================================================= + * + *============================================================================= + * ATB SPEED: target, X + * ATB SPEED: target, X% + * ATB SPEED: targets, +X + * ATB SPEED: targets, +X% + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usable only for ATB. Sets the target's ATB speed to X or X%. This only + * applies when the target is filling up its ATB gauge. This will not affect + * the user to prevent mechanical issues. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: atb speed: targets, +5000 + * atb speed: target, -50% + *============================================================================= + * + * ============================================================================ + * Options Core Settings - Adding the New Options + * ============================================================================ + * + * If you are using YEP_OptionsCore.js, you can add a new Option using this + * plugin. Here's the following code/parameter settings you can use with it. + * + * --------- + * Settings: + * --------- + * + * Name: + * \i[87]ATB Speed + * + * Help Description: + * Determines how fast the ATB Gauge fills up during battle. + * + * Symbol: + * atbSpeed + * + * Show/Hide: + * if (Imported.YEP_X_BattleSysATB) { + * show = $gameSystem.getBattleSystem() === 'atb'; + * } else { + * show = false; + * } + * + * Enable: + * enabled = true; + * + * Ext: + * ext = 0; + * + * ---------- + * Functions: + * ---------- + * + * Make Option Code: + * this.addCommand(name, symbol, enabled, ext); + * + * Draw Option Code: + * var rect = this.itemRectForText(index); + * var statusWidth = this.statusWidth(); + * var titleWidth = rect.width - statusWidth; + * this.resetTextColor(); + * this.changePaintOpacity(this.isCommandEnabled(index)); + * this.drawOptionsName(index); + * var value = this.getConfigValue(symbol); + * var rate = value / 10; + * var gaugeColor1 = this.textColor(13); + * var gaugeColor2 = this.textColor(5); + * this.drawOptionsGauge(index, rate, gaugeColor1, gaugeColor2); + * this.drawText(this.statusText(index), titleWidth, rect.y, statusWidth, 'center'); + * + * Process OK Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * value += 1; + * if (value > 10) value = 1; + * this.changeValue(symbol, value); + * + * Cursor Right Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * value += 1; + * if (value > 10) value = 1; + * this.changeValue(symbol, value); + * + * Cursor Left Code: + * var index = this.index(); + * var symbol = this.commandSymbol(index); + * var value = this.getConfigValue(symbol); + * value -= 1; + * if (value < 1) value = 10; + * this.changeValue(symbol, value); + * + * Default Config Code: + * // Empty. Provided by this plugin. + * + * Save Config Code: + * // Empty. Provided by this plugin. + * + * Load Config Code: + * // Empty. Provided by this plugin. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.28: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.27: + * - Compatibility update with YEP_OptionsCore.js. + * + * Version 1.26: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.25: + * - Lunatic Mode fail safes added. + * + * Version 1.24: + * - During action end, a single tick will be forced to occur to prevent clash + * amongst actors with similar AGI values and make tick values more unique. + * + * Version 1.23: + * - Timing has been changed for states that update turns at Turn Start. Now, + * the states will update prior to the actor's command box opening or the enemy + * make a decision on which action it will use. + * + * Version 1.22: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.21: + * - Counterattacks no longer cause interrupts if attack actions have interrupt + * functionality. + * + * Version 1.20: + * - Updated plugin to update the AI more accordingly with Battle AI Core. + * + * Version 1.19: + * - Fixed a bug where forced actions clear out an action's effects before the + * turn is over, making post-turn effects to not occur. + * + * Version 1.18: + * - Fixed a bug where changing back and forth between the Fight/Escape window + * would prompt on turn start effects. + * + * Version 1.17: + * - Made a mechanic change so that turn 0 ends immediately upon battle start + * rather than requiring a full turn to end. + * + * Version 1.16: + * - Added a fail safe setting up ATB Charges when the Cannot Move restriction + * is imposed upon an actor. + * + * Verison 1.15: + * - Implemented a Forced Action queue list. This means if a Forced Action + * takes place in the middle of an action, the action will resume after the + * forced action finishes rather than cancels it out like MV does. + * + * Version 1.14: + * - Added a speed position check for Instant Casts to maintain order position. + * + * Version 1.13: + * - Fixed a bug that doesn't update state turns properly. + * - Removed 'Turn Structure parameter' as it goes against the nature of a + * Tick-Based battle system. + * + * Version 1.12: + * - Added speed rebalance formulas for tick-based systems (innate). + * + * Version 1.11: + * - Fixed a bug that would still allow battlers to perform actions even if the + * actions got sealed midway through charging the action. + * + * Version 1.10: + * - Fixed a bug that would cause AutoBattlers to stall if they got added into + * the party mid-battle. + * + * Version 1.09: + * - Mechanic change for states that update on Action End to end at the end of + * a battler's turn instead of at the start. + * + * Version 1.08a: + * - Fixed a bug that crashed the game when enemies were confused. + * - Preparation for Enemy ATB Gauges. + * + * Version 1.07: + * - Added 'Flash Enemy' to plugin parameters to flash the enemy once when it + * starts charging a skill. + * + * Version 1.06: + * - Added pre-emptive and surprise attack mechanic plugin parameters! + * + * Version 1.05: + * - Fixed a bug with Forced Actions locking out the battle. + * + * Version 1.04: + * - Added the 'Per Tick' parameter for you to adjust the formula that governs + * the speed rate at which the ATB gauge fills up. + * + * Version 1.03: + * - Fixed a bug that caused the ATB Gauge appear slow with maxed AGI. + * + * Version 1.02c: + * - Fixed a bug with the ATB GAUGE and ATB CHARGE action sequences. + * - Fixed a bug with battlers still getting a turn after the battle is over. + * - Fixed a bug that prevented escaping. + * - Added math fail safes for calculating ATB charging. + * + * Version 1.01: + * - Fixed a bug with escaping causing battlers to go into infinite lock. + * - Fixed a bug with multiple victory messages. + * - Added fail safe to prevent infinite charging. + * - Added . + * + * Version 1.00: + * - It's doooooooone! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +if (Yanfly.BEC.version && Yanfly.BEC.version >= 1.42) { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_BattleSysATB'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.ATBPerTick = String(Yanfly.Parameters['Per Tick']); +Yanfly.Param.ATBInitSpeed = String(Yanfly.Parameters['Initial Speed']); +Yanfly.Param.ATBFullGauge = String(Yanfly.Parameters['Full Gauge']); +Yanfly.Param.ATBChargeGauge = String(Yanfly.Parameters['Charge Gauge']); +Yanfly.Param.ATBPreEmptive = Number(Yanfly.Parameters['Pre-Emptive Bonuses']); +Yanfly.Param.ATBSurprise = Number(Yanfly.Parameters['Surprise Bonuses']); +Yanfly.Param.ATBEscapeRatio = String(Yanfly.Parameters['Escape Ratio']); +Yanfly.Param.ATBEscapeBoost = String(Yanfly.Parameters['Fail Escape Boost']); +Yanfly.Param.ATBFullTurn = String(Yanfly.Parameters['Full Turn']); +Yanfly.Param.ATBTurnStructure = false; +Yanfly.Param.ATBFlashEnemy = eval(String(Yanfly.Parameters['Flash Enemy'])); +Yanfly.Param.ATBRubberband = String(Yanfly.Parameters['Enable Rubberband']); +Yanfly.Param.ATBMinSpeed = String(Yanfly.Parameters['Minimum Speed']); +Yanfly.Param.ATBMaxSpeed = String(Yanfly.Parameters['Maximum Speed']); +Yanfly.Param.ATBReadyName = String(Yanfly.Parameters['Ready Sound']); +Yanfly.Param.ATBReadyVol = Number(Yanfly.Parameters['Ready Volume']); +Yanfly.Param.ATBReadyPitch = Number(Yanfly.Parameters['Ready Pitch']); +Yanfly.Param.ATBReadyPan = Number(Yanfly.Parameters['Ready Pan']); +Yanfly.Param.ATBOptionSpeedTx = String(Yanfly.Parameters['ATB Speed Text']); +Yanfly.Param.ATBDefaultSpeed = Number(Yanfly.Parameters['Default ATB Speed']); +Yanfly.Param.ATBLockStatusWin = String(Yanfly.Parameters['Lock Status Window']); +Yanfly.Param.ATBGaugeStyle = Number(Yanfly.Parameters['Gauge Style']); +Yanfly.Param.ATBGaugeText = String(Yanfly.Parameters['Gauge Text']); +Yanfly.Param.ATBGaugeAlign = String(Yanfly.Parameters['Gauge Text Align']); +Yanfly.Param.ATBColorAtb1 = Number(Yanfly.Parameters['ATB Gauge Color 1']); +Yanfly.Param.ATBColorAtb2 = Number(Yanfly.Parameters['ATB Gauge Color 2']); +Yanfly.Param.ATBColorSlow1 = Number(Yanfly.Parameters['Slow Gauge Color 1']); +Yanfly.Param.ATBColorSlow2 = Number(Yanfly.Parameters['Slow Gauge Color 2']); +Yanfly.Param.ATBColorFast1 = Number(Yanfly.Parameters['Fast Gauge Color 1']); +Yanfly.Param.ATBColorFast2 = Number(Yanfly.Parameters['Fast Gauge Color 2']); +Yanfly.Param.ATBColorStop1 = Number(Yanfly.Parameters['Stop Gauge Color 1']); +Yanfly.Param.ATBColorStop2 = Number(Yanfly.Parameters['Stop Gauge Color 2']); +Yanfly.Param.ATBColorFull1 = Number(Yanfly.Parameters['Full Gauge Color 1']); +Yanfly.Param.ATBColorFull2 = Number(Yanfly.Parameters['Full Gauge Color 2']); +Yanfly.Param.ATBColorChar1 = Number(Yanfly.Parameters['Charge Gauge Color 1']); +Yanfly.Param.ATBColorChar2 = Number(Yanfly.Parameters['Charge Gauge Color 2']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.ATB.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.ATB.DataManager_isDatabaseLoaded.call(this)) return false; + if (!Yanfly._loaded_YEP_X_BattleSysATB) { + this.processATBNotetags1($dataSkills); + this.processATBNotetags1($dataItems); + this.processATBNotetags2($dataActors); + this.processATBNotetags2($dataClasses); + this.processATBNotetags2($dataEnemies); + this.processATBNotetags2($dataWeapons); + this.processATBNotetags2($dataArmors); + this.processATBNotetags2($dataStates); + Yanfly._loaded_YEP_X_BattleSysATB = true; + } + return true; +}; + +DataManager.processATBNotetags1 = function(group) { + var noteA1 = /<(?:ATB GAUGE):[ ](\d+)>/i; + var noteA2 = /<(?:ATB GAUGE):[ ]([\+\-]\d+)>/i; + var noteA3 = /<(?:ATB GAUGE):[ ](\d+)([%%])>/i; + var noteA4 = /<(?:ATB GAUGE):[ ]([\+\-]\d+)([%%])>/i; + var noteB1 = /<(?:ATB SPEED):[ ](\d+)>/i; + var noteB2 = /<(?:ATB SPEED):[ ]([\+\-]\d+)>/i; + var noteB3 = /<(?:ATB SPEED):[ ](\d+)([%%])>/i; + var noteB4 = /<(?:ATB SPEED):[ ]([\+\-]\d+)([%%])>/i; + var noteC1 = /<(?:ATB CHARGE):[ ](\d+)>/i; + var noteC2 = /<(?:ATB CHARGE):[ ]([\+\-]\d+)>/i; + var noteC3 = /<(?:ATB CHARGE):[ ](\d+)([%%])>/i; + var noteC4 = /<(?:ATB CHARGE):[ ]([\+\-]\d+)([%%])>/i; + var noteS1 = /<(?:AFTER ATB):[ ](\d+)>/i; + var noteS2 = /<(?:AFTER ATB):[ ](\d+)([%%])>/i; + var noteI1 = /<(?:ATB INTERRUPT)>/i; + var noteI2 = /<(?:ATB INTERRUPT):[ ](\d+)([%%])>/i; + var noteI3 = /<(?:CANNOT ATB INTERRUPT)>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.setATBGaugeFlat = undefined; + obj.addATBGaugeFlat = 0; + obj.setATBGaugeRate = undefined; + obj.addATBGaugeRate = 0.0; + obj.setATBSpeedFlat = undefined; + obj.addATBSpeedFlat = 0; + obj.setATBSpeedRate = undefined; + obj.addATBSpeedRate = 0.0; + obj.setATBChargeFlat = undefined; + obj.addATBChargeFlat = 0; + obj.setATBChargeRate = undefined; + obj.addATBChargeRate = 0.0; + obj.afterATBFlat = undefined; + obj.afterATBRate = undefined; + obj.atbInterruptRate = 0; + obj.cannotAtbInterrupt = false; + var evalMode = 'none'; + obj.atbEval = ''; + obj.atbAfterEval = ''; + obj.atbInterruptEval = ''; + obj.atbHelp = undefined; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(noteA1)) { + obj.setATBGaugeFlat = parseInt(RegExp.$1); + } else if (line.match(noteA2)) { + obj.addATBGaugeFlat = parseInt(RegExp.$1); + } else if (line.match(noteA3)) { + obj.setATBGaugeRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteA4)) { + obj.addATBGaugeRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteB1)) { + obj.setATBSpeedFlat = parseInt(RegExp.$1); + } else if (line.match(noteB2)) { + obj.addATBSpeedFlat = parseInt(RegExp.$1); + } else if (line.match(noteB3)) { + obj.setATBSpeedRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteB4)) { + obj.addATBSpeedRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteC1)) { + obj.setATBChargeFlat = parseInt(RegExp.$1); + } else if (line.match(noteC2)) { + obj.addATBChargeFlat = parseInt(RegExp.$1); + } else if (line.match(noteC3)) { + obj.setATBChargeRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteC4)) { + obj.addATBChargeRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteS1)) { + obj.afterATBFlat = parseInt(RegExp.$1); + } else if (line.match(noteS2)) { + obj.afterATBRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteI1)) { + obj.atbInterruptRate = 1; + } else if (line.match(noteI2)) { + obj.atbInterruptRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteI3)) { + obj.cannotAtbInterrupt = true; + } else if (line.match(/<(?:TARGET ATB EVAL)>/i)) { + evalMode = 'atb eval'; + } else if (line.match(/<\/(?:TARGET ATB EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:AFTER ATB EVAL)>/i)) { + evalMode = 'after atb eval'; + } else if (line.match(/<\/(?:AFTER ATB EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:ATB INTERRUPT EVAL)>/i)) { + evalMode = 'atb interrupt eval'; + } else if (line.match(/<\/(?:ATB INTERRUPT EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:ATB HELP)>/i)) { + evalMode = 'atb help'; + obj.atbHelp = ''; + } else if (line.match(/<\/(?:ATB HELP)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'atb help') { + obj.atbHelp = obj.atbHelp + line + '\n'; + } else if (evalMode === 'atb eval') { + obj.atbEval = obj.atbEval + line + '\n'; + } else if (evalMode === 'after atb eval') { + obj.atbAfterEval = obj.atbAfterEval + line + '\n'; + } else if (evalMode === 'atb interrupt eval') { + obj.atbInterruptEval = obj.atbInterruptEval + line + '\n'; + } + } + } +}; + +DataManager.processATBNotetags2 = function(group) { + var noteA1 = /<(?:ATB START):[ ]([\+\-]\d+)>/i; + var noteA2 = /<(?:ATB START):[ ]([\+\-]\d+)([%%])>/i; + var noteB1 = /<(?:ATB TURN):[ ]([\+\-]\d+)>/i; + var noteB2 = /<(?:ATB TURN):[ ]([\+\-]\d+)([%%])>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.atbStartFlat = 0; + obj.atbStartRate = 0; + obj.atbTurnFlat = 0; + obj.atbTurnRate = 0; + var evalMode = 'none'; + obj.atbHelp = undefined; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(noteA1)) { + obj.atbStartFlat = parseInt(RegExp.$1); + } else if (line.match(noteA2)) { + obj.atbStartRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteB1)) { + obj.atbTurnFlat = parseInt(RegExp.$1); + } else if (line.match(noteB2)) { + obj.atbTurnRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(/<(?:ATB HELP)>/i)) { + evalMode = 'atb help'; + obj.atbHelp = ''; + } else if (line.match(/<\/(?:ATB HELP)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'atb help') { + obj.atbHelp = obj.atbHelp + line + '\n'; + } + } + } +}; + +//============================================================================= +// ConfigManager +//============================================================================= + +ConfigManager.atbSpeed = Yanfly.Param.ATBDefaultSpeed; + +Yanfly.ATB.ConfigManager_makeData = ConfigManager.makeData; +ConfigManager.makeData = function() { + var config = Yanfly.ATB.ConfigManager_makeData.call(this); + config.atbSpeed = this.atbSpeed; + return config; +}; + +Yanfly.ATB.ConfigManager_applyData = ConfigManager.applyData; +ConfigManager.applyData = function(config) { + Yanfly.ATB.ConfigManager_applyData.call(this, config); + this.atbSpeed = this.readConfigATBSpeed(config, 'atbSpeed'); +}; + +ConfigManager.readConfigATBSpeed = function(config, name) { + var value = config[name]; + if (value !== undefined) { + return Number(value).clamp(1, 10); + } else { + return Yanfly.Param.ATBDefaultSpeed.clamp(1, 10); + } +}; + +//============================================================================= +// BattleManager +//============================================================================= + +BattleManager.isATB = function() { + return this.isBattleSystem('atb'); +}; + +Yanfly.ATB.BattleManager_isTurnBased = BattleManager.isTurnBased; +BattleManager.isTurnBased = function() { + if (this.isATB()) return false; + return Yanfly.ATB.BattleManager_isTurnBased.call(this); +}; + +Yanfly.ATB.BattleManager_tickRate = BattleManager.tickRate; +BattleManager.tickRate = function() { + var rate = Yanfly.ATB.BattleManager_tickRate.call(this); + if (this.isATB()) rate *= this.atbTickRate(); + return rate; +}; + +BattleManager.atbTickRate = function() { + var rate = 0.1 * ConfigManager.atbSpeed; + return rate; +}; + +Yanfly.ATB.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio; +BattleManager.makeEscapeRatio = function() { + if (this.isATB()) { + var code = Yanfly.Param.ATBEscapeRatio; + try { + this._escapeRatio = eval(code); + } catch (e) { + this._escapeRatio = 0; + Yanfly.Util.displayError(e, code, 'ATB ESCAPE RATIO ERROR'); + } + var code = Yanfly.Param.ATBEscapeBoost; + try { + this._escapeFailBoost = eval(code); + } catch (e) { + this._escapeFailBoost = 0; + Yanfly.Util.displayError(e, code, 'ATB ESCAPE BOOST ERROR'); + } + } else { + this._escapeFailBoost = 0.1; + Yanfly.ATB.BattleManager_makeEscapeRatio.call(this); + } +}; + +Yanfly.ATB.BattleManager_startBattle = BattleManager.startBattle; +BattleManager.startBattle = function() { + Yanfly.ATB.BattleManager_startBattle.call(this); + if (this.isATB()) { + this._phase = null; + this._counterAttacking = false; + this.startATB(); + } +}; + +Yanfly.ATB.BattleManager_endBattle = BattleManager.endBattle; +BattleManager.endBattle = function(result) { + Yanfly.ATB.BattleManager_endBattle.call(this, result); + this.clearATBData(); +}; + +BattleManager.startATB = function() { + if (this._phase === 'battleEnd') return; + this.clearATBData(); + this._atbTarget = Math.max(1, eval(Yanfly.Param.ATBFullGauge)); + this._atbCharge = Math.max(1, eval(Yanfly.Param.ATBChargeGauge)); + this._atbFullTurn = Math.max(1, eval(Yanfly.Param.ATBFullTurn)); + this._atbRubberband = eval(Yanfly.Param.ATBRubberband); + if (this.atbRubberband()) { + this._atbMinimumSpeed = Math.max(1, eval(Yanfly.Param.ATBMinSpeed)); + this._atbMaximumSpeed = Math.max(1, eval(Yanfly.Param.ATBMaxSpeed)); + } + this._atbTicks = this._atbFullTurn; + this._atbReadySound = { + name: Yanfly.Param.ATBReadyName, + volume: Yanfly.Param.ATBReadyVol, + pitch: Yanfly.Param.ATBReadyPitch, + pan: Yanfly.Param.ATBReadyPan + } + $gameParty.onATBStart(); + $gameTroop.onATBStart(); + this._phase = 'start'; +}; + +BattleManager.clearATBData = function() { + this._highestBaseAgi = undefined; + this._averageBaseAgi = undefined; + this._lowestBaseAgi = undefined; + this._atbTarget = undefined; + this._atbCharge = undefined; + this._atbTarget = undefined; + this._atbCharge = undefined; + this._atbFullTurn = undefined; + this._atbRubberband = undefined; + this._atbMinimumSpeed = undefined; + this._atbMaximumSpeed = undefined; + this._atbTicks = 0; +}; + +BattleManager.atbTarget = function() { + if (!this._atbTarget) this.startATB(); + return this._atbTarget; +}; + +BattleManager.atbCharge = function() { + if (!this._atbCharge) this.startATB(); + return this._atbCharge; +}; + +BattleManager.atbRubberband = function() { + return this._atbRubberband; +}; + +BattleManager.atbMinimumSpeed = function() { + return this._atbMinimumSpeed; +}; + +BattleManager.atbMaximumSpeed = function() { + return this._atbMaximumSpeed; +}; + +BattleManager.highestBaseAgi = function() { + if (this._highestBaseAgi) return this._highestBaseAgi; + var agi = 0; + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var battler = $gameParty.battleMembers()[i]; + if (battler) agi = Math.max(agi, battler.agi); + } + for (var i = 0; i < $gameTroop.members().length; ++i) { + var battler = $gameTroop.members()[i]; + if (battler) agi = Math.max(agi, battler.agi); + } + this._highestBaseAgi = agi; + return this._highestBaseAgi; +}; + +BattleManager.averageBaseAgi = function() { + if (this._averageBaseAgi) return this._averageBaseAgi; + var agi = 0; + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var battler = $gameParty.battleMembers()[i]; + if (battler) agi += battler.agi; + } + for (var i = 0; i < $gameTroop.members().length; ++i) { + var battler = $gameTroop.members()[i]; + if (battler) agi += battler.agi; + } + var sum = $gameParty.battleMembers().length; + sum += $gameTroop.members().length; + this._averageBaseAgi = agi / sum; + return this._averageBaseAgi; +}; + +BattleManager.lowestBaseAgi = function() { + if (this._lowestBaseAgi) return this._lowestBaseAgi; + var agi = this.highestBaseAgi(); + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var battler = $gameParty.battleMembers()[i]; + if (battler) agi = Math.min(agi, battler.agi); + } + for (var i = 0; i < $gameTroop.members().length; ++i) { + var battler = $gameTroop.members()[i]; + if (battler) agi = Math.min(agi, battler.agi); + } + this._lowestBaseAgi = agi; + return this._lowestBaseAgi; +}; + +Yanfly.ATB.BattleManager_update = BattleManager.update; +BattleManager.update = function() { + if (this.isATB()) { + if (this.isBusy()) return; + if (this.updateEvent()) return; + if (this._phase === 'battleEnd') { + return Yanfly.ATB.BattleManager_update.call(this); + } + if (this.checkBattleEnd()) return; + if (this._phase === 'atb') { + this.updateATBPhase(); + } else { + Yanfly.ATB.BattleManager_update.call(this); + } + } else { + Yanfly.ATB.BattleManager_update.call(this); + } +}; + +Yanfly.ATB.BattleManager_updateEventMain = BattleManager.updateEventMain; +BattleManager.updateEventMain = function() { + if (this.isATB()) { + $gameTroop.updateInterpreter(); + $gameParty.requestMotionRefresh(); + if ($gameTroop.isEventRunning()) { + return true; + } + $gameTroop.setupBattleEvent(); + if ($gameTroop.isEventRunning() || SceneManager.isSceneChanging()) { + return true; + } + return false; + } else { + return Yanfly.ATB.BattleManager_updateEventMain.call(this); + } +}; + +BattleManager.updateATBPhase = function() { + var chargedBattler = this.getChargedATBBattler(); + if (chargedBattler) return this.startATBAction(chargedBattler); + var readyBattler = this.getReadyATBBattler(); + if (readyBattler) { + return this.startATBInput(readyBattler); + } else { + this.updateATBTicks(); + this.updateBattlerATB(); + } +}; + +BattleManager.updateATBTicks = function() { + this._atbTicks += 1 * this.tickRate(); + if (this._atbTicks < this._atbFullTurn) return; + $gameTroop.increaseTurn(); + this._atbTicks = 0; + if (this.isTurnBased()) { + this.endTurn(); + } else { + this.endTurn(); + } +}; + +BattleManager.getChargedATBBattler = function() { + if ($gameParty.aliveMembers() <= 0 || $gameTroop.aliveMembers() <= 0) { + return false; + } + var fastest = false; + for (var i = 0; i < this.allBattleMembers().length; ++i) { + var battler = this.allBattleMembers()[i]; + if (!battler) continue; + if (!this.isBattlerATBCharged(battler)) continue; + if (!fastest) { + fastest = battler; + } else if (battler.atbCharge() > fastest.atbCharge()) { + fastest = battler; + } + } + return fastest; +}; + +BattleManager.isBattlerATBCharged = function(battler) { + if (!battler.isATBCharging()) return false; + if (battler.atbChargeRate() < 1) return false; + if (battler.isConfused()) { + battler.makeActions(); + if (battler.isActor()) battler.makeConfusionActions(); + } + return battler.currentAction() && battler.currentAction().item(); +}; + +BattleManager.getReadyATBBattler = function() { + var fastest = false; + for (var i = 0; i < this.allBattleMembers().length; ++i) { + var battler = this.allBattleMembers()[i]; + if (!battler) continue; + if (!this.isBattlerATBReady(battler)) continue; + if (!fastest) { + fastest = battler; + } else if (battler.atbSpeed() > fastest.atbSpeed()) { + fastest = battler; + } + } + return fastest; +}; + +BattleManager.isBattlerATBReady = function(battler) { + if (battler.atbRate() < 1) return false; + if (battler.isATBCharging()) return false; + if (battler.currentAction() && battler.currentAction().item()) { + battler.makeActions(); + battler.setupATBCharge(); + return false; + } + return true; +}; + +BattleManager.updateBattlerATB = function(ignore) { + $gameParty.updateTick(); + $gameTroop.updateTick(); + if (ignore) return; + if (this._statusWindow) this.statusUpdateATB(); +}; + +BattleManager.setATBPhase = function() { + this._phase = 'atb'; +}; + +Yanfly.ATB.BattleManager_startInput = BattleManager.startInput; +BattleManager.startInput = function() { + if (this.isATB()) { + this.setATBPhase(); + } else { + Yanfly.ATB.BattleManager_startInput.call(this); + } +}; + +Yanfly.ATB.BattleManager_selectNextCommand = BattleManager.selectNextCommand; +BattleManager.selectNextCommand = function() { + if (this.isATB()) { + if (!this.actor()) return this.setATBPhase(); + this.resetNonPartyActorATB(); + this.actor().setupATBCharge(); + this.actor().spriteStepBack(); + this.actor().requestMotionRefresh(); + this._actorIndex = undefined; + var chargedBattler = this.getChargedATBBattler(); + if (chargedBattler) { + this.startATBAction(chargedBattler); + } else { + this.setATBPhase(); + } + } else { + Yanfly.ATB.BattleManager_selectNextCommand.call(this); + } +}; + +BattleManager.resetNonPartyActorATB = function() { + for (var i = 0; i < $gameParty.allMembers().length; ++i) { + var actor = $gameParty.allMembers()[i]; + if (!actor) continue; + if ($gameParty.battleMembers().contains(actor)) continue; + actor.resetAllATB(); + } +}; + +Yanfly.ATB.BattleManager_selectPreviousCommand = + BattleManager.selectPreviousCommand; +BattleManager.selectPreviousCommand = function() { + if (this.isATB()) { + var actorIndex = this._actorIndex; + var scene = SceneManager._scene; + this._bypassAtbEndTurn = true; + scene.startPartyCommandSelection(); + this._actorIndex = actorIndex; + BattleManager.actor().setActionState('undecided'); + BattleManager.actor().requestMotionRefresh(); + this._bypassAtbEndTurn = undefined; + } else { + Yanfly.ATB.BattleManager_selectPreviousCommand.call(this); + } +}; + +Yanfly.ATB.BattleManager_startTurn = BattleManager.startTurn; +BattleManager.startTurn = function() { + if (this.isATB() && !this.isTurnBased()) return; + Yanfly.ATB.BattleManager_startTurn.call(this); +}; + +Yanfly.ATB.BattleManager_updateTurnEnd = BattleManager.updateTurnEnd; +BattleManager.updateTurnEnd = function() { + if (this.isATB()) { + this.setATBPhase(); + } else { + Yanfly.ATB.BattleManager_updateTurnEnd.call(this); + } +}; + +BattleManager.startATBInput = function(battler) { + if (battler.isDead()) return; + battler.onTurnStart(); + battler.makeActions(); + if (battler.isEnemy()) { + battler.setupATBCharge(); + if (Yanfly.Param.ATBFlashEnemy) battler.requestEffect('whiten'); + var chargedBattler = this.getChargedATBBattler(); + if (chargedBattler) this.startATBAction(chargedBattler); + } else if (battler.canInput()) { + this._actorIndex = battler.index(); + this.playATBReadySound(); + battler.setActionState('inputting'); + battler.spriteStepForward(); + this._phase = 'input'; + } else if (battler.isConfused()) { + battler.makeConfusionActions(); + battler.setupATBCharge(); + } else { + battler.makeAutoBattleActions(); + battler.setupATBCharge(); + } +}; + +BattleManager.playATBReadySound = function() { + AudioManager.playSe(this._atbReadySound); +}; + +BattleManager.startATBAction = function(battler) { + this._subject = battler; + var action = this._subject.currentAction(); + if (action && action.isValid()) { + this.startAction(); + } else { + this.endAction(); + } +}; + +Yanfly.ATB.BattleManager_processForcedAction = + BattleManager.processForcedAction; +BattleManager.processForcedAction = function() { + var forced = false; + if (this._actionForcedBattler && this.isATB()) { + var action = this._actionForcedBattler.currentAction(); + forced = true; + } + Yanfly.ATB.BattleManager_processForcedAction.call(this); + if (forced) this._subject.setAction(0, action); +}; + +Yanfly.ATB.BattleManager_endAction = BattleManager.endAction; +BattleManager.endAction = function() { + if (this.isATB()) { + this.endATBAction(); + } else { + Yanfly.ATB.BattleManager_endAction.call(this); + } +}; + +BattleManager.endATBAction = function() { + if (Imported.YEP_BattleEngineCore) { + if (this._processingForcedAction) this._phase = this._preForcePhase; + this._processingForcedAction = false; + } + if (this._subject) this._subject.onAllActionsEnd(); + if (this.updateEventMain()) return; + this._subject.endTurnAllATB(); + if (this.loadPreForceActionSettings()) return; + this.updateBattlerATB(true); + var chargedBattler = this.getChargedATBBattler(); + if (chargedBattler) { + this.startATBAction(chargedBattler); + } else { + this.setATBPhase(); + } +}; + +Yanfly.ATB.BattleManager_invokeCounterAttack = + BattleManager.invokeCounterAttack; +BattleManager.invokeCounterAttack = function(subject, target) { + if (this.isATB()) this._counterAttacking = true; + Yanfly.ATB.BattleManager_invokeCounterAttack.call(this, subject, target); + if (this.isATB()) this._counterAttacking = false; +}; + +BattleManager.isCounterAttacking = function() { + return this._counterAttacking; +}; + +BattleManager.statusUpdateATB = function() { + this._statusWindow.redrawATB(); +}; + +Yanfly.ATB.BattleManager_processEscape = BattleManager.processEscape; +BattleManager.processEscape = function() { + if (this.isATB()) { + return this.processEscapeATB(); + } else { + return Yanfly.ATB.BattleManager_processEscape.call(this); + } +}; + +BattleManager.processEscapeATB = function() { + $gameParty.performEscape(); + SoundManager.playEscape(); + var success = this._preemptive ? true : (Math.random() < this._escapeRatio); + if (success) { + $gameParty.removeBattleStates(); + $gameParty.performEscapeSuccess(); + this.displayEscapeSuccessMessage(); + this._escaped = true; + this.processAbort(); + } else { + this.actor().spriteStepBack(); + this.actor().clearActions(); + this.displayEscapeFailureMessage(); + this._escapeRatio += this._escapeFailBoost; + this.startTurn(); + this.processFailEscapeATB(); + } + return success; +}; + +BattleManager.processFailEscapeATB = function() { + var actor = $gameParty.members()[this._actorIndex]; + if (!actor) return; + actor.resetAllATB(); +}; + +Yanfly.ATB.BattleManager_processActionSequence = + BattleManager.processActionSequence; +BattleManager.processActionSequence = function(actionName, actionArgs) { + if (this.isATB()) { + // ATB CHARGE + if (actionName === 'ATB CHARGE') { + return this.actionATBCharge(actionArgs); + } + // ATB GAUGE + if (actionName === 'ATB GAUGE') { + return this.actionATBCharge(actionArgs) && this.actionATBSpeed(actionArgs); + } + // ATB INTERRUPT + if (actionName === 'ATB INTERRUPT') { + return this.actionATBInterrupt(actionArgs); + } + // ATB SPEED + if (actionName === 'ATB SPEED') { + return this.actionATBSpeed(actionArgs); + } + } + return Yanfly.ATB.BattleManager_processActionSequence.call(this, + actionName, actionArgs); +}; + +BattleManager.actionATBCharge = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + var cmd = actionArgs[1]; + if (cmd.match(/([\+\-]\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isATBCharging()) continue; + var max = target.atbChargeDenom(); + var value = rate * max + target.atbCharge(); + target.setATBCharge(value); + target.refresh(); + } + } else if (cmd.match(/([\+\-]\d+)/i)) { + var plus = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isATBCharging()) continue; + var value = plus + target.atbCharge(); + target.setATBCharge(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isATBCharging()) continue; + var max = target.atbChargeDenom(); + var value = rate * max; + target.setATBCharge(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)/i)) { + var value = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isATBCharging()) continue; + target.setATBCharge(value); + target.refresh(); + } + } + return true; +}; + +BattleManager.actionATBInterrupt = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isATBCharging()) continue; + target.processATBInterrupt(); + } + return true; +}; + +BattleManager.actionATBSpeed = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + var cmd = actionArgs[1]; + if (cmd.match(/([\+\-]\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + var max = this.atbTarget(); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isATBCharging()) continue; + var value = rate * max + target.atbSpeed(); + target.setATBSpeed(value); + target.refresh(); + } + } else if (cmd.match(/([\+\-]\d+)/i)) { + var plus = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isATBCharging()) continue; + var value = plus + target.atbSpeed(); + target.setATBSpeed(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + var max = this.atbTarget(); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isATBCharging()) continue; + var value = rate * max; + target.setATBSpeed(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)/i)) { + var value = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isATBCharging()) continue; + target.setATBSpeed(value); + target.refresh(); + } + } + return true; +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.ATB.Game_Action_applyItemUserEffect = + Game_Action.prototype.applyItemUserEffect; +Game_Action.prototype.applyItemUserEffect = function(target) { + Yanfly.ATB.Game_Action_applyItemUserEffect.call(this, target); + if (BattleManager.isATB() && $gameParty.inBattle()) { + this.applyItemATBEffect(target); + } +}; + +Game_Action.prototype.applyItemATBEffect = function(target) { + if (!target) return; + this.applyItemATBSetEffects(target); + this.applyItemATBAddEffects(target); + this.applyItemATBEvalEffect(target); + if (BattleManager.isCounterAttacking()) return; + this.applyItemATBInterrupt(target); + this.applyItemATBInterruptEval(target); +}; + +Game_Action.prototype.applyItemATBSetEffects = function(target) { + var item = this.item(); + if (!item) return; + var value = undefined; + if (target.isATBCharging()) { + var max = target.atbChargeDenom(); + if (item.setATBChargeFlat !== undefined) { + value = item.setATBChargeFlat; + } else if (item.setATBGaugeFlat !== undefined) { + value = item.setATBGaugeFlat; + } else if (item.setATBChargeRate !== undefined) { + value = item.setATBChargeRate * max; + } else if (item.setATBGaugeRate !== undefined) { + value = item.setATBGaugeRate * max; + } + if (value !== undefined) target.setATBCharge(value); + } else { + var max = BattleManager.atbTarget(); + if (item.setATBSpeedFlat !== undefined) { + value = item.setATBSpeedFlat; + } else if (item.setATBGaugeFlat !== undefined) { + value = item.setATBGaugeFlat; + } else if (item.setATBSpeedRate !== undefined) { + value = item.setATBSpeedRate * max; + } else if (item.setATBGaugeRate !== undefined) { + value = item.setATBGaugeRate * max; + } + if (value !== undefined) target.setATBSpeed(value); + } + if (value !== undefined && target.isActor()) BattleManager.statusUpdateATB(); +}; + +Game_Action.prototype.applyItemATBAddEffects = function(target) { + var item = this.item(); + if (!item) return; + if (target.isATBCharging()) { + var value = target.atbCharge(); + var max = target.atbChargeDenom(); + value += item.addATBChargeRate * max; + value += item.addATBGaugeRate * max; + value += item.addATBChargeFlat; + value += item.addATBGaugeFlat; + target.setATBCharge(value); + } else { + var value = target.atbSpeed(); + var max = BattleManager.atbTarget() + value += item.addATBSpeedRate * max; + value += item.addATBGaugeRate * max; + value += item.addATBSpeedFlat; + value += item.addATBGaugeFlat; + target.setATBSpeed(value); + } + if (value !== 0 && target.isActor()) BattleManager.statusUpdateATB(); +}; + +Game_Action.prototype.applyItemATBEvalEffect = function(target) { + var a = this.subject(); + var user = this.subject(); + var b = target; + var item = this.item(); + var skill = this.item(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var speed = target.atbSpeed(); + var charge = target.atbCharge(); + if (target.isATBCharging()) { + var max = target.atbChargeDenom(); + } else { + var max = BattleManager.atbTarget(); + } + var code = item.atbEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'ATB EVAL ERROR'); + } + target.setATBSpeed(speed); + target.setATBCharge(charge); +}; + +Game_Action.prototype.applyItemATBInterrupt = function(target) { + var item = this.item(); + if (!item) return; + if (target === this.subject()) return; + if (!target.isATBCharging()) return; + if (item.atbInterruptRate <= 0) return; + var success = (Math.random() < item.atbInterruptRate); + if (success) target.processATBInterrupt(); +}; + +Game_Action.prototype.applyItemATBInterruptEval = function(target) { + var item = this.item(); + if (!item) return; + if (target === this.subject()) return; + if (!target.isATBCharging()) return; + if (item.atbInterruptEval === '') return; + var interrupt = false; + var a = this.subject(); + var user = this.subject(); + var b = target; + var item = this.item(); + var skill = this.item(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var speed = target.atbSpeed(); + var charge = target.atbCharge(); + var code = item.atbInterruptEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'ATB INTERRUPT EVAL ERROR'); + } + if (interrupt) target.processATBInterrupt(); +}; + +Game_Action.prototype.rebalanceATBSpeed = function(target) { + var speed = this.subject().atbSpeed(); + var offset = 00000000001; + speed = Math.max(speed + offset, target.atbSpeed() + target.atbCharge()); + this.subject().setATBSpeed(speed); +}; + +//============================================================================= +// Game_Battlerbase +//============================================================================= + +Yanfly.ATB.Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh; +Game_BattlerBase.prototype.refresh = function() { + Yanfly.ATB.Game_BattlerBase_refresh.call(this); + if (BattleManager.isATB() && $gameParty.inBattle()) { + this._atbTickValue = undefined; + } +}; + +Yanfly.ATB.Game_BattlerBase_die = Game_BattlerBase.prototype.die; +Game_BattlerBase.prototype.die = function() { + Yanfly.ATB.Game_BattlerBase_die.call(this); + if (BattleManager.isATB() && $gameParty.inBattle()) this.resetAllATB(); +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.onATBStart = function() { + this._atbSpeed = eval(Yanfly.Param.ATBInitSpeed); + this._atbSpeed += BattleManager.atbTarget() * this.atbStartRate(); + this._atbSpeed += this.atbStartFlat(); + this._atbCharge = 0; + this._atbCharging = false; + this._atbChargeMod = 0; + this.applyPreemptiveBonusATB(); + this.applySurpriseBonusATB(); + this.refresh(); +}; + +Game_Battler.prototype.applyPreemptiveBonusATB = function() { + if (!BattleManager._preemptive) return; + if (!this.isActor()) return; + var rate = Yanfly.Param.ATBPreEmptive; + this._atbSpeed += rate * BattleManager.atbTarget(); +}; + +Game_Battler.prototype.applySurpriseBonusATB = function() { + if (!BattleManager._surprise) return; + if (!this.isEnemy()) return; + var rate = Yanfly.Param.ATBSurprise; + this._atbSpeed += rate * BattleManager.atbTarget(); +}; + +Yanfly.ATB.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd; +Game_Battler.prototype.onBattleEnd = function() { + Yanfly.ATB.Game_Battler_onBattleEnd.call(this); + this._atbSpeed = 0; + this._atbCharge = 0; + this._atbCharging = false; + this._atbChargeMod = 0; +}; + +Game_Battler.prototype.atbSpeed = function() { + if (this._atbSpeed === undefined) this.onATBStart(); + return this._atbSpeed; +}; + +Game_Battler.prototype.atbRate = function() { + if (this._atbSpeed === undefined) this.onATBStart(); + var rate = this._atbSpeed / BattleManager.atbTarget(); + return rate.clamp(0, 1); +}; + +Game_Battler.prototype.isATBCharging = function() { + return this._atbCharging; +}; + +Game_Battler.prototype.setATBCharging = function(value) { + this._atbCharging = value; +}; + +Game_Battler.prototype.atbCharge = function() { + if (this._atbCharge === undefined) this.onATBStart(); + return this._atbCharge; +}; + +Game_Battler.prototype.atbChargeDenom = function() { + var denom = Math.max(1, BattleManager.atbCharge() - this._atbChargeMod); + return denom; +}; + +Game_Battler.prototype.atbChargeRate = function() { + if (this._atbCharge === undefined) this.onATBStart(); + if (!this.isATBCharging()) return 0; + var rate = this._atbCharge / this.atbChargeDenom(); + return rate.clamp(0, 1); +}; + +Game_Battler.prototype.setATBSpeed = function(value) { + this._atbSpeed = Math.max(0, value); +}; + +Game_Battler.prototype.setATBCharge = function(value) { + if (this.isATBCharging()) this._atbCharge = Math.max(0, value); +}; + +Game_Battler.prototype.setupATBCharge = function() { + if (this._bypassAtbEndTurn) return; + this.setATBCharging(true); + if (!this.currentAction()) this.makeActions(); + if (this.currentAction()) { + var item = this.currentAction().item(); + if (item) { + this._atbChargeMod = item.speed; + } else { + this._atbChargeMod = 0; + } + } else { + this._atbChargeMod = 0; + } + this.setATBCharge(0); + this.setActionState('waiting'); +}; + +Yanfly.ATB.Game_Battler_updateTick = Game_Battler.prototype.updateTick; +Game_Battler.prototype.updateTick = function() { + Yanfly.ATB.Game_Battler_updateTick.call(this); + if (BattleManager.isATB()) this.updateATB(); +}; + +Game_Battler.prototype.updateATB = function() { + if (this.isDead()) return this.resetAllATB(); + if (!this.canMove()) { + this.updateATBStates(); + return; + } + if (this.isATBCharging()) { + if (!this.currentAction()) this.resetAllATB(); + if (this.currentAction() && this.currentAction().item() === null) { + this.resetAllATB(); + } + } + if (this.isATBCharging()) { + var value = this.atbCharge() + this.atbSpeedTick(); + this.setATBCharge(value); + } else if (this.atbRate() < 1) { + var value = this.atbSpeed() + this.atbSpeedTick(); + this.setATBSpeed(value); + } +}; + +Game_Battler.prototype.updateATBStates = function() { + if (BattleManager.timeBasedBuffs()) return; + for (var i = 0; i < this._states.length; ++i) { + var stateId = this._states[i]; + var state = $dataStates[stateId]; + if (!state) continue; + if (!this._stateTurns[stateId]) continue; + if (state.restriction >= 4 && state.autoRemovalTiming !== 0) { + var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime; + this._stateTurns[stateId] -= value; + if (this._stateTurns[stateId] <= 0) this.removeState(stateId); + } + } +}; + +Game_Battler.prototype.resetAllATB = function() { + this._atbCharge = 0; + this._atbChargeMod = 0; + this._atbCharging = false; + this._atbSpeed = 0; + this.clearActions(); +}; + +Game_Battler.prototype.endTurnAllATB = function() { + this._atbCharge = 0; + this._atbChargeMod = 0; + this._atbCharging = false; + if (this.checkATBEndInstantCast()) return; + this.setEndActionATBSpeed(); + this.clearActions(); + this.setActionState('undecided'); + if (this.battler()) this.battler().refreshMotion(); + if (BattleManager.isTickBased()) this.onTurnEnd(); +}; + +Game_Battler.prototype.checkATBEndInstantCast = function() { + if (!Imported.YEP_InstantCast) return false; + var action = this.currentAction(); + if (!action) return false; + var item = action.item(); + if (!item) return false; + if (!this.isInstantCast(item)) return false; + var length = BattleManager.allBattleMembers().length; + for (var i = 0; i < length; ++i) { + var member = BattleManager.allBattleMembers()[i]; + if (!member) continue; + var max = member.atbSpeed() + member.atbCharge(); + this._atbSpeed = Math.max(this._atbSpeed, max); + } + this._atbSpeed = Math.max(this._atbSpeed, BattleManager.atbTarget()); + this._atbSpeed += 0.00000000001; + return true; +}; + +Game_Battler.prototype.atbSpeedRate = function() { + if (!this.canMove()) return 0; + var base = this.paramBase(6) + this.paramPlus(6); + if (base >= this.paramMax(6) && this.agi >= this.paramMax(6)) return 1; + var rate = this.agi / base; + return rate; +}; + +Game_Battler.prototype.atbSpeedTick = function() { + var value = this.atbTickValue(); + if (BattleManager.atbRubberband()) { + var min = BattleManager.atbMinimumSpeed(); + var max = BattleManager.atbMaximumSpeed(); + value = value.clamp(min, max); + } + return value * BattleManager.tickRate(); +}; + +Game_Battler.prototype.atbTickValue = function() { + if (this._atbTickValue !== undefined) return this._atbTickValue; + var a = this; + var user = this; + var subject = this; + this._atbTickValue = eval(Yanfly.Param.ATBPerTick); + return this._atbTickValue; +}; + +Game_Battler.prototype.setEndActionATBSpeed = function() { + this._atbSpeed = 0; + var action = this.currentAction(); + if (!action) return; + var item = action.item();; + if (item) { + if (item.afterATBFlat !== undefined) this.setATBSpeed(item.afterATBFlat); + if (item.afterATBRate !== undefined) { + this.setATBSpeed(item.afterATBRate * BattleManager.atbTarget()); + } + } + this._atbSpeed += BattleManager.atbTarget() * this.atbTurnRate(); + this._atbSpeed += this.atbTurnFlat(); + if (item) this.afterATBEval(item); +}; + +Game_Battler.prototype.afterATBEval = function(item) { + if (!item) return; + var a = this; + var user = this; + var skill = item; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var speed = this._atbSpeed; + var max = BattleManager.atbTarget(); + eval(item.atbAfterEval); + this.setATBSpeed(speed); +}; + +Game_Battler.prototype.processATBInterrupt = function() { + if (this.currentAction()) { + var item = this.currentAction().item(); + if (item && item.cannotAtbInterrupt) return; + } + this.resetAllATB(); + this.refresh(); +}; + +Game_Battler.prototype.atbStartFlat = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.atbStartFlat; + } + return value; +}; + +Game_Battler.prototype.atbStartRate = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.atbStartRate; + } + return value; +}; + +Game_Battler.prototype.atbTurnFlat = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.atbTurnFlat; + } + return value; +}; + +Game_Battler.prototype.atbTurnRate = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.atbTurnRate; + } + return value; +}; + +Yanfly.ATB.Game_Battler_removeState = Game_Battler.prototype.removeState; +Game_Battler.prototype.removeState = function(stateId) { + if (BattleManager.isATB()) { + var confuseCondition = this.isConfused(); + } + Yanfly.ATB.Game_Battler_removeState.call(this, stateId); + if (BattleManager.isATB()) { + if (confuseCondition !== this.isConfused()) this.resetAllATB(); + } +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.atbStartFlat = function() { + var value = Game_Battler.prototype.atbStartFlat.call(this); + value += this.actor().atbStartFlat; + value += this.currentClass().atbStartFlat; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.atbStartFlat) value += equip.atbStartFlat; + } + return value; +}; + +Game_Actor.prototype.atbStartRate = function() { + var value = Game_Battler.prototype.atbStartRate.call(this); + value += this.actor().atbStartRate; + value += this.currentClass().atbStartRate; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.atbStartRate) value += equip.atbStartRate; + } + return value; +}; + +Game_Actor.prototype.atbTurnFlat = function() { + var value = Game_Battler.prototype.atbTurnFlat.call(this); + value += this.actor().atbTurnFlat; + value += this.currentClass().atbTurnFlat; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.atbTurnFlat) value += equip.atbTurnFlat; + } + return value; +}; + +Game_Actor.prototype.atbTurnRate = function() { + var value = Game_Battler.prototype.atbTurnRate.call(this); + value += this.actor().atbTurnRate; + value += this.currentClass().atbTurnRate; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.atbTurnRate) value += equip.atbTurnRate; + } + return value; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.atbStartFlat = function() { + var value = Game_Battler.prototype.atbStartFlat.call(this); + value += this.enemy().atbStartFlat; + return value; +}; + +Game_Enemy.prototype.atbStartRate = function() { + var value = Game_Battler.prototype.atbStartRate.call(this); + value += this.enemy().atbStartRate; + return value; +}; + +Game_Enemy.prototype.atbTurnFlat = function() { + var value = Game_Battler.prototype.atbTurnFlat.call(this); + value += this.enemy().atbTurnFlat; + return value; +}; + +Game_Enemy.prototype.atbTurnRate = function() { + var value = Game_Battler.prototype.atbTurnRate.call(this); + value += this.enemy().atbTurnRate; + return value; +}; + +//============================================================================= +// Game_Unit +//============================================================================= + +Game_Unit.prototype.onATBStart = function() { + if (!BattleManager.isATB()) return; + for (var i = 0; i < this.members().length; ++i) { + var member = this.members()[i]; + if (member) member.onATBStart(); + } +}; + +Game_Unit.prototype.increaseTurnTimeBasedATB = function() { + for (var i = 0; i < this.members().length; ++i) { + var member = this.members()[i]; + if (!member) continue; + if (member.isDead()) continue; + if (member.isHidden()) continue; + if (member.canMove()) continue; + member.onTurnEnd(); + } +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Yanfly.ATB.Game_Party_performEscape = Game_Party.prototype.performEscape; +Game_Party.prototype.performEscape = function() { + if (BattleManager.isATB()) return; + Yanfly.ATB.Game_Party_performEscape.call(this); +}; + +//============================================================================= +// Game_Troop +//============================================================================= + +Yanfly.ATB.Game_Troop_increaseTurn = Game_Troop.prototype.increaseTurn; +Game_Troop.prototype.increaseTurn = function() { + Yanfly.ATB.Game_Troop_increaseTurn.call(this); + if (BattleManager.isATB() && BattleManager.timeBasedStates()) { + $gameParty.increaseTurnTimeBasedATB(); + this.increaseTurnTimeBasedATB(); + } +}; + +//============================================================================= +// Window_Base +//============================================================================= + +Window_Base.prototype.atbGaugeStyle = function() { + return Yanfly.Param.ATBGaugeStyle +}; + +Window_Base.prototype.atbGaugeColor1 = function(actor) { + if (actor.atbRate() < 1) { + if (actor.atbSpeedRate() === 0) { + return this.textColor(Yanfly.Param.ATBColorStop1); + } else if (actor.atbSpeedRate() > 1) { + return this.textColor(Yanfly.Param.ATBColorFast1); + } else if (actor.atbSpeedRate() < 1) { + return this.textColor(Yanfly.Param.ATBColorSlow1); + } else { + return this.textColor(Yanfly.Param.ATBColorAtb1); + } + } else if (actor.atbRate() >= 1 && actor.atbChargeRate() >= 0) { + return this.textColor(Yanfly.Param.ATBColorFull1); + } else { + return this.gaugeBackColor(); + } +}; + +Window_Base.prototype.atbGaugeColor2 = function(actor) { + if (actor.atbRate() < 1) { + if (actor.atbSpeedRate() === 0) { + return this.textColor(Yanfly.Param.ATBColorStop2); + } else if (actor.atbSpeedRate() > 1) { + return this.textColor(Yanfly.Param.ATBColorFast2); + } else if (actor.atbSpeedRate() < 1) { + return this.textColor(Yanfly.Param.ATBColorSlow2); + } else { + return this.textColor(Yanfly.Param.ATBColorAtb2); + } + } else if (actor.atbRate() >= 1 && actor.atbChargeRate() >= 0) { + return this.textColor(Yanfly.Param.ATBColorFull2); + } else { + return this.gaugeBackColor(); + } +}; + +Window_Base.prototype.drawActorAtbGauge = function(actor, wx, wy, ww) { + ww = ww || 96; + if (!actor) return; + var color1 = this.atbGaugeColor1(actor); + var color2 = this.atbGaugeColor2(actor); + if (actor.atbRate() < 1) { + var rate = actor.atbRate(); + } else if (actor.atbRate() >= 1 && actor.atbChargeRate() >= 0) { + var rate = 1; + } else { + var rate = 0; + } + this.drawGauge(wx, wy, ww, rate, color1, color2); + if (actor.atbChargeRate() > 0) this.drawAtbChargeGauge(actor, wx, wy, ww); + if (this.atbGaugeStyle() === 2) { + var text = Yanfly.Param.ATBGaugeText; + var align =Yanfly.Param.ATBGaugeAlign; + if (actor.atbRate() >= 1) { + this.changeTextColor(this.normalColor()); + } else { + this.changeTextColor(this.systemColor()); + } + this.drawText(text, wx, wy, ww, align); + this.resetTextColor(); + } +}; + +Window_Base.prototype.drawAtbChargeGauge = function(actor, wx, wy, ww) { + var color1 = this.textColor(Yanfly.Param.ATBColorChar1); + var color2 = this.textColor(Yanfly.Param.ATBColorChar2); + var rate = actor.atbChargeRate(); + this.drawGauge(wx, wy, ww * rate, 1, color1, color2); +}; + +//============================================================================= +// Window_Help +//============================================================================= + +Yanfly.ATB.Window_Help_setItem = Window_Help.prototype.setItem; +Window_Help.prototype.setItem = function(item) { + if (this.meetATBConditions(item)) return this.setText(item.atbHelp); + Yanfly.ATB.Window_Help_setItem.call(this, item); +}; + +Window_Help.prototype.meetATBConditions = function(item) { + if (!item) return false; + if (!BattleManager.isATB()) return false; + return item.atbHelp !== undefined; +}; + +//============================================================================= +// Window_BattleStatus +//============================================================================= + +Window_BattleStatus.prototype.redrawATB = function() { + if (this.isATBGaugeStyle(0)) return; + var rect; + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var actor = $gameParty.battleMembers()[i]; + if (this.isATBGaugeStyle(1)) { + rect = this.basicAreaRect(i); + this.contents.clearRect(rect.x - 1, rect.y, rect.width + 2, rect.height); + this.drawBasicArea(rect, actor); + } else if (this.isATBGaugeStyle(2)) { + this.redrawATBGaugeRect(i, actor); + } + } +}; + +Window_BattleStatus.prototype.redrawATBGaugeRect = function(index, actor) { + var rect = this.gaugeAreaRect(index); + var clrect = this.gaugeAreaRect(index); + var totalArea = this.gaugeAreaWidth(); + if ($dataSystem.optDisplayTp) { + var gw = totalArea / 4 - 15; + clrect.x = rect.x + gw * 3 + 44; + clrect.y = rect.y; + clrect.width = gw + 2; + this.contents.clearRect(clrect.x, clrect.y, clrect.width, clrect.height); + this.drawActorAtbGauge(actor, rect.x + gw * 3 + 45, rect.y, gw); + } else { + totalArea -= 30; + var hpW = parseInt(totalArea * 108 / 300); + var otW = parseInt(totalArea * 96 / 300); + clrect.x = rect.x + hpW + otW + 29; + clrect.y = rect.y; + clrect.width = otW + 2; + this.contents.clearRect(clrect.x, clrect.y, clrect.width, clrect.height); + this.drawActorAtbGauge(actor, rect.x + hpW + otW + 30, rect.y, otW); + } +}; + +Window_BattleStatus.prototype.isATBGaugeStyle = function(type) { + if (this.atbGaugeStyle() !== type) return false; + if (!BattleManager.isATB()) return false; + return (SceneManager._scene instanceof Scene_Battle); +}; + +Yanfly.ATB.Window_BattleStatus_drawBasicArea = + Window_BattleStatus.prototype.drawBasicArea; +Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) { + if (this.isATBGaugeStyle(1)) { + this.drawActorAtbGauge(actor, rect.x, rect.y, rect.width); + } + Yanfly.ATB.Window_BattleStatus_drawBasicArea.call(this, rect, actor); +}; + +Yanfly.ATB.Window_BattleStatus_drawGaugeAreaWithTp = + Window_BattleStatus.prototype.drawGaugeAreaWithTp; +Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) { + if (this.isATBGaugeStyle(2)) { + var totalArea = this.gaugeAreaWidth(); + var gw = totalArea / 4 - 15; + this.drawActorHp(actor, rect.x + 0, rect.y, gw); + this.drawActorMp(actor, rect.x + gw * 1 + 15, rect.y, gw); + this.drawActorTp(actor, rect.x + gw * 2 + 30, rect.y, gw); + this.drawActorAtbGauge(actor, rect.x + gw * 3 + 45, rect.y, gw); + } else { + Yanfly.ATB.Window_BattleStatus_drawGaugeAreaWithTp.call(this, rect, actor); + } +}; + +Yanfly.ATB.Window_BattleStatus_drawGaugeAreaWOTp = + Window_BattleStatus.prototype.drawGaugeAreaWithoutTp; +Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) { + if (this.isATBGaugeStyle(2)) { + var totalArea = this.gaugeAreaWidth() - 30; + var hpW = parseInt(totalArea * 108 / 300); + var otW = parseInt(totalArea * 96 / 300); + this.drawActorHp(actor, rect.x + 0, rect.y, hpW); + this.drawActorMp(actor, rect.x + hpW + 15, rect.y, otW); + this.drawActorAtbGauge(actor, rect.x + hpW + otW + 30, rect.y, otW); + } else { + Yanfly.ATB.Window_BattleStatus_drawGaugeAreaWOTp.call(this, rect, actor); + } +}; + +//============================================================================= +// Window_Options +//============================================================================= + +Yanfly.ATB.Window_Options_addGeneralOptions = + Window_Options.prototype.addGeneralOptions; +Window_Options.prototype.addGeneralOptions = function() { + Yanfly.ATB.Window_Options_addGeneralOptions.call(this); + if (Imported.YEP_OptionsCore) return; + if ($gameSystem.getBattleSystem() === 'atb') this.addATBOptions(); +}; + +Window_Options.prototype.addATBOptions = function() { + var text = Yanfly.Param.ATBOptionSpeedTx; + this.addCommand(text, 'atbSpeed'); +}; + +Yanfly.ATB.Window_Options_statusText = Window_Options.prototype.statusText; +Window_Options.prototype.statusText = function(index) { + var symbol = this.commandSymbol(index); + if (symbol === 'atbSpeed') { + return this.getConfigValue('atbSpeed'); + } else { + return Yanfly.ATB.Window_Options_statusText.call(this, index); + } +}; + +if (!Imported.YEP_OptionsCore) { + +Yanfly.ATB.Window_Options_processOk = Window_Options.prototype.processOk; +Window_Options.prototype.processOk = function() { + var index = this.index(); + var symbol = this.commandSymbol(index); + if (symbol === 'atbSpeed') { + var value = this.getConfigValue(symbol); + value += 1; + if (value > 10) value = 1; + this.changeValue(symbol, value); + } else { + Yanfly.ATB.Window_Options_processOk.call(this); + } +}; + +Yanfly.ATB.Window_Options_cursorRight = Window_Options.prototype.cursorRight; +Window_Options.prototype.cursorRight = function(wrap) { + var index = this.index(); + var symbol = this.commandSymbol(index); + if (symbol === 'atbSpeed') { + var value = this.getConfigValue(symbol); + value += 1; + if (value > 10) value = 1; + this.changeValue(symbol, value); + } else { + Yanfly.ATB.Window_Options_cursorRight.call(this, wrap); + } +}; + +Yanfly.ATB.Window_Options_cursorLeft = Window_Options.prototype.cursorLeft; +Window_Options.prototype.cursorLeft = function(wrap) { + var index = this.index(); + var symbol = this.commandSymbol(index); + if (symbol === 'atbSpeed') { + var value = this.getConfigValue(symbol); + value -= 1; + if (value < 1) value = 10; + this.changeValue(symbol, value); + } else { + Yanfly.ATB.Window_Options_cursorLeft.call(this, wrap); + } +}; + +}; // Imported.YEP_OptionsCore + + +//============================================================================= +// Scene_Battle +//============================================================================= + +Yanfly.ATB.Scene_Battle_updateWindowPositions = + Scene_Battle.prototype.updateWindowPositions; +Scene_Battle.prototype.updateWindowPositions = function() { + if (BattleManager.isATB() && !this._atbLockStatusWin) { + this._atbLockStatusWin = eval(Yanfly.Param.ATBLockStatusWin); + } + if (BattleManager.isATB() && this._atbLockStatusWin) { + this.updateWindowPositionsATB(); + } else { + Yanfly.ATB.Scene_Battle_updateWindowPositions.call(this); + } +}; + +Yanfly.ATB.Scene_Battle_isStartActorCommand = + Scene_Battle.prototype.isStartActorCommand; +Scene_Battle.prototype.isStartActorCommand = function() { + if (BattleManager.isATB()) return true; + return Yanfly.ATB.Scene_Battle_isStartActorCommand.call(this); +}; + +Scene_Battle.prototype.updateWindowPositionsATB = function() { + var activeWin = null; + if (this._partyCommandWindow.active) activeWin = this._partyCommandWindow; + if (this._actorCommandWindow.active) activeWin = this._actorCommandWindow; + if (activeWin === null) return; + if (activeWin.x <= Graphics.boxWidth / 2) { + this._statusWindow.x = Graphics.boxWidth - this._statusWindow.width; + } else { + this._statusWindow.x = 0; + } +}; + +Yanfly.ATB.Scene_Battle_commandFight = Scene_Battle.prototype.commandFight; +Scene_Battle.prototype.commandFight = function() { + if (BattleManager.isATB()) { + this.startActorCommandSelection(); + BattleManager._phase = 'input'; + } else { + Yanfly.ATB.Scene_Battle_commandFight.call(this); + } +}; + +Yanfly.ATB.Scene_Battle_startActorCommandSelection = + Scene_Battle.prototype.startActorCommandSelection; +Scene_Battle.prototype.startActorCommandSelection = function() { + Yanfly.ATB.Scene_Battle_startActorCommandSelection.call(this); + if (BattleManager.isATB()) { + BattleManager._bypassAtbEndTurn = true; + BattleManager.actor().spriteStepForward(); + BattleManager.actor().setActionState('undecided'); + BattleManager.actor().requestMotionRefresh(); + BattleManager.actor().makeActions(); + BattleManager._bypassAtbEndTurn = undefined; + } +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= +} else { // Yanfly.BEC.version + +var text = '================================================================\n'; +text += 'YEP_X_AnimatedSVEnemies requires YEP_BattleEngineCore to be at the '; +text += 'latest version to run properly.\n\nPlease go to www.yanfly.moe and '; +text += 'update to the latest version for the YEP_BattleEngineCore plugin.\n'; +text += '================================================================\n'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // Yanfly.BEC.version +}; // YEP_BattleEngineCore \ No newline at end of file diff --git a/js/plugins/YEP_X_BattleSysCTB.js b/js/plugins/YEP_X_BattleSysCTB.js new file mode 100644 index 0000000..0c8ca5e --- /dev/null +++ b/js/plugins/YEP_X_BattleSysCTB.js @@ -0,0 +1,2698 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle System - Charge Turn Battle +// YEP_X_BattleSysCTB.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_BattleSysCTB = true; + +var Yanfly = Yanfly || {}; +Yanfly.CTB = Yanfly.CTB || {}; +Yanfly.CTB.version = 1.17; + +//============================================================================= + /*: + * @plugindesc v1.17 (Requires YEP_BattleEngineCore.js) Add CTB (Charge + * Turn Battle) into your game using this plugin! + * @author Yanfly Engine Plugins + * + * @param ---CTB Settings--- + * @default + * + * @param Per Tick + * @parent ---CTB Settings--- + * @desc This is how much speed is gained per tick. + * @default user.agi + * + * @param Initial Speed + * @parent ---CTB Settings--- + * @desc The speed position of the battler at the start of battle. + * This is a formula processed as an eval. + * @default 0 + * + * @param Full Gauge + * @parent ---CTB Settings--- + * @desc The target speed for an CTB gauge to be full. + * This is a formula processed as an eval. + * @default Math.max(7000, BattleManager.highestBaseAgi() * 120) + * + * @param Pre-Emptive Bonuses + * @parent ---CTB Settings--- + * @desc How much of the CTB bar do you want filled up for an + * CTB pre-emptive bonus from 0 to 1. + * @default 0.8 + * + * @param Surprise Bonuses + * @parent ---CTB Settings--- + * @desc How much of the CTB bar do you want filled up for an + * CTB surprise bonus from 0 to 1. + * @default 0.8 + * + * @param ---Escape--- + * @default + * + * @param Escape Ratio + * @parent ---Escape--- + * @desc How CTB calculates escape ratios. + * Default: 0.5 * $gameParty.agility() / $gameTroop.agility() + * @default 0.125 * $gameParty.agility() / $gameTroop.agility() + * + * @param Fail Escape Boost + * @parent ---Escape--- + * @type number + * @decimals 3 + * @min 0 + * @desc Each time the player fails escape, increase the success + * rate by this much. Default: 0.1 + * @default 0.025 + * + * @param ---Turn--- + * @default + * + * @param Full Turn + * @parent ---Turn--- + * @desc This is how many ticks to equal a full battle turn. + * This is a formula processed as an eval. + * @default Math.min(200, BattleManager.lowestBaseAgi() * 8) + * + * @param ---Rubberband--- + * @default + * + * @param Enable Rubberband + * @parent ---Rubberband--- + * @type boolean + * @on YES + * @off NO + * @desc This is an auto-balance mechanic for AGI. + * Disable - false Enable - true + * @default true + * + * @param Minimum Speed + * @parent ---Rubberband--- + * @desc If rubberbanding is enabled, what is the minimum + * speed increase? This is a formula. + * @default 0.5 * BattleManager.highestBaseAgi() + * + * @param Maximum Speed + * @parent ---Rubberband--- + * @desc If rubberbanding is enabled, what is the maximum + * speed increase? This is a formula. + * @default 1.5 * BattleManager.highestBaseAgi() + * + * @param ---Sound--- + * @default + * + * @param Ready Sound + * @parent ---Sound--- + * @type file + * @dir audio/se/ + * @require 1 + * @desc This is the sound played when the battler is ready. + * @default Decision1 + * + * @param Ready Volume + * @parent ---Sound--- + * @type number + * @min 0 + * @max 100 + * @desc This is the volume of the ready sound. + * @default 90 + * + * @param Ready Pitch + * @parent ---Sound--- + * @type number + * @min 0 + * @desc This is the pitch of the ready sound. + * @default 120 + * + * @param Ready Pan + * @parent ---Sound--- + * @type number + * @desc This is the pan of the ready sound. + * @default 0 + * + * @param ---Turn Order--- + * @default + * + * @param Show Turn Order + * @parent ---Turn Order--- + * @type boolean + * @on YES + * @off NO + * @desc Show the battler turn order? + * NO - false YES - true + * @default true + * + * @param Icon Size + * @parent ---Turn Order--- + * @type number + * @min 1 + * @desc This is the size of the icons displayed for the turn order. + * Default: 32 + * @default 32 + * + * @param Position Y + * @parent ---Turn Order--- + * @type number + * @desc Where do you want to align the Y turn order? + * @default 54 + * + * @param Position X + * @parent ---Turn Order--- + * @type number + * @desc Which side of the screen should the turn order appear? + * left center right + * @default right + * + * @param Turn Direction + * @parent ---Turn Order--- + * @type combo + * @option left + * @option right + * @desc Which way do you want the turn icons going? + * left right + * @default left + * + * @param Ally Border Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc Text Color used for the borders of allies. + * @default 4 + * + * @param Ally Back Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc Text Color used for the ally background color. + * @default 22 + * + * @param Ally Icon + * @parent ---Turn Order--- + * @type number + * @min 0 + * @desc Default icon used for allies. If this value is 0, + * the icon will be the ally's face graphic instead. + * @default 0 + * + * @param Enemy Border Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc Text Color used for the borders of enemies. + * @default 2 + * + * @param Enemy Back Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc Text Color used for the ally background color. + * @default 19 + * + * @param Enemy Icon + * @parent ---Turn Order--- + * @type number + * @min 0 + * @desc Default icon used for enemies. If this value is 0, + * the icon will be the enemy's drawn battler instead. + * @default 0 + * + * @param Enemy SV Battlers + * @parent ---Turn Order--- + * @type boolean + * @on YES + * @off NO + * @desc If using Animated SV Enemies, draw their battlers if no icon + * is being used? This can become laggy. NO - false YES - true + * @default false + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * The Battle System - Charge Turn Battle plugin is an extension plugin for + * Yanfly Engine Plugins' Battle Engine Core. This extension plugin will not + * work without the main plugin. + * + * To use the CTB system, go to the Battle Engine Core plugin and change the + * 'Default System' setting in the parameters to 'ctb'. + * + * The Charge Turn Battle system functions by calculating every battlers' speed + * and balancing them relative to one another. When it's a battler's turn, the + * battler will either choose an action to perform immediately or charge it for + * later depending if the skill requires charging. + * + * This is a battle system where agility plays an important factor in the + * progress of battle where higher agility values give battlers more advantage + * and lower agility values give battlers less advantage. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * To change your battle system to Charge Turn Battle if it isn't the default + * battle system, you can use the following Plugin Command: + * + * Plugin Command: + * setBattleSys CTB Sets battle system to Charge Turn Battle. + * setBattleSys DTB Sets battle system to Default Turn Battle. + * + * Using the above Plugin Commands, you can toggle between the Default Battle + * System and Charge Turn Battle! + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * The following are notetags that pertain to and affect the CTB system. + * + * Actor and Enemy Notetags: + * + * This sets the icon used for the actor/enemy to be x. + * + * + * This sets the border color used for the actor/enemy to text color x. + * + * + * This sets the background color used for the actor/enemy to text color x. + * + * Actor only Notetags: + * + * This sets it so that if the actor is a specific class, the actor will get + * a specific icon used for the CTB Turn Order. If the actor is class x, it + * will receive icon y. + * + * + * + * + * + * If you prefer to use names instead of class ID's, you can use the above + * notetag format. If the actor is the named class, it will receive icon x. + * If you have multiple classes with the same name, priority will be given to + * the class with the highest ID. + * + * Skill and Item Notetags: + * + * text + * text + * + * For those planning on using multiple battle systems, sometimes you may + * have your skills perform differently while using CTB. If so, using this + * notetag will allow skills and items to display different help text while + * CTB is enabled. + * + * + * Usable only during CTB. This sets the target's current speed to x. + * + * + * Usable only during CTB. This sets the target's current speed to x% of + * the CTB turn completion target. + * + * + * + * Usable only during CTB. This increases or decreases the target's current + * speed by x. + * + * + * + * Usable only during CTB. This increases or decreases the target's current + * speed or charge by x% of the CTB turn completion target. + * + * + * + * Moves target's position in the turn order by +x or -x. +x will make the + * target having to wait more before getting their turn while -x will make + * the target having to wait less. The effect is minimal and will only last + * for the current turn cycle. + * * Note: If you use this for multiple targets, each target will shift turns + * individually at a time. + * + * + * + * This will set the skill/item user's CTB speed value to x or x%. If 'x' is + * used, this will be the exact CTB value. If x% is used, this will be the + * percentage of the CTB turn completion target that it will be at. + * + * Actor, Class, Enemy, Weapon, Armor, and State Notetags: + * + * + * Usable only during CTB. This will give the actor, class, enemy, weapon, + * armor, or state the property of starting battle with X CTB Speed or X% of + * the CTB turn completion target. + * + * + * + * Usable only during CTB. This will give the actor, class, enemy, weapon, + * armor, or state the property of starting a turn with X CTB Speed or X% of + * the CTB turn completion target. + * + * ============================================================================ + * Lunatic Mode - Conditional CTB Speed and Conditional CTB Charge + * ============================================================================ + * + * For those who have a bit of JavaScript experience and would like to have + * more unique ways of performing CTB speed and charge changes, you can use the + * following notetags: + * + * Skill and Item Notetags: + * + * speed = x; + * charge = x; + * + * You can omit speed and/or charge. Whatever you set 'speed' to will change + * the CTB speed of the target. If the target is charging, 'charge' will + * cause the target's charge to change to that value. To make things more + * simple, 'max' will be the full gauge value. + * + * Here is an example: + * + * + * speed = target.hp / target.mhp * max; + * charge = target.hp / target.mhp * max; + * + * The above code will set the user's current CTB gauge to position equal to + * the target's HP ratio. If the target has 25% HP, the CTB gauge will go to + * 25% full for the target. + * + * --- --- --- --- --- + * + * + * order = x; + * + * Set the 'order' variable to how much you want to alter the target's + * current turn order by. If 'order' is positive, the order will need to wait + * that many more turns before its turn comes up. If 'order' is negative, it + * will will that amount of turns less before the order comes up. + * + * Here is an example: + * + * + * if (target.hp > 1000) { + * order = 3; + * } else { + * order = -1; + * } + * + * If the target when attacked has over 1000 HP left, the target will have to + * wait 3 more turns before its turn arrives. If the target has 1000 or less, + * the target actually waits 1 less turn. + * + * --- --- --- --- --- + * + * + * speed = x; + * + * This is the CTB set after the user has used the skill/item and the custom + * CTB amount you want the user to be at after. 'max' be the value of the + * full gauge value. Whatever you set 'speed', the user's CTB speed value + * will change to that much: + * + * Here is an example: + * + * + * speed = user.mp / user.mmp * max; + * + * The above code will set the user's CTB gauge after using the skill/item to + * equal the user's MP ratio. If the user has 25% MP, the CTB gauge will go + * to 25% full for the user. + * + * ============================================================================ + * Yanfly Engine Plugins - Battle Engine Extension - Action Sequence Commands + * ============================================================================ + * + * You can make use of these extra CTB related action sequences. + * + *============================================================================= + * CTB ORDER: target, +X + * CTB ORDER: target, -X + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usable only for CTB. Moves target's position in the turn order by +x or -x. + * +x will make the target having to wait more before getting their turn while + * -x will make the target having to wait less. The effect is minimal and will + * only last for the current turn cycle. + * * Note: If you use this for multiple targets, each target will shift turns + * individually at a time. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: ctb order: target, -2 + * ctb order: target, +3 + *============================================================================= + * + *============================================================================= + * CTB SPEED: target, X + * CTB SPEED: target, X% + * CTB SPEED: targets, +X + * CTB SPEED: targets, +X% + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usable only for CTB. Sets the target's CTB speed to X or X%. This only + * applies when the target is filling up its CTB gauge. This will not affect + * the user to prevent mechanical issues. + *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Usage Example: ctb speed: targets, +5000 + * ctb speed: target, -50% + *============================================================================= + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.17: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.16: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.15: + * - Lunatic Mode fail safes added. + * + * Version 1.14a: + * - Updated check for CTB Charging. Units in the turn order will not be + * considered 'ready' unless they are in the front of the CTB Turn Order. + * + * Version 1.13: + * - Timing has been changed for states that update turns at Turn Start. Now, + * the states will update prior to the actor's command box opening or the enemy + * make a decision on which action it will use. + * + * Version 1.12: + * - Updated for RPG Maker MV version 1.1.0. + * + * Version 1.11: + * - Counterattacks no longer cause turn order inconsistencies. + * + * Version 1.10a: + * - Updated plugin to update the AI more accordingly with Battle AI Core. + * - Optimized CTB Turn Order further to reduce lag when there are larger + * quantities of battle members. + * + * Version 1.09: + * - Fixed a bug where forced actions clear out an action's effects before the + * turn is over, making post-turn effects to not occur. + * + * Version 1.08a: + * - Fixed a bug where changing back and forth between the Fight/Escape window + * would prompt on turn start effects. + * - Made an update where if using Battle Engine Core's "Lower Windows" to + * false, the icons no longer show above the windows. + * + * Version 1.07: + * - Made a mechanic change so that turn 0 ends immediately upon battle start + * rather than requiring a full turn to end. + * + * Version 1.06: + * - Fixed a bug that would cause a crash when a party member leaves the party. + * + * Version 1.05c: + * - Implemented a Forced Action queue list. This means if a Forced Action + * takes place in the middle of an action, the action will resume after the + * forced action finishes rather than cancels it out like MV does. + * - Fixed a graphical issue where enemies appearing midway don't have letters + * attached to their icons. + * - Added a fail safe for loaded saves that did not have CTB installed before. + * + * Version 1.04: + * - Added a speed position check for Instant Casts to maintain order position. + * + * Version 1.03: + * - Fixed a bug that doesn't update state turns properly. + * - Removed 'Turn Structure parameter' as it goes against the nature of a + * Tick-Based battle system. + * + * Version 1.02: + * - Added failsafe for battlers without actions. + * - Added speed rebalance formulas for tick-based systems (innate). + * - Added and notetags. + * + * Version 1.01: + * - Provided loop breaks to prevent lock-ups with non-Yanfly plugins. + * - Added 'Icon Size' parameter to allow customization of icon sizes. + * + * Version 1.00: + * - It's doooooooooone! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { + +if (Yanfly.BEC.version && Yanfly.BEC.version >= 1.42) { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_BattleSysCTB'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.CTBPerTick = String(Yanfly.Parameters['Per Tick']); +Yanfly.Param.CTBInitSpeed = String(Yanfly.Parameters['Initial Speed']); +Yanfly.Param.CTBFullGauge = String(Yanfly.Parameters['Full Gauge']); +Yanfly.Param.CTBPreEmptive = Number(Yanfly.Parameters['Pre-Emptive Bonuses']); +Yanfly.Param.CTBSurprise = Number(Yanfly.Parameters['Surprise Bonuses']); + +Yanfly.Param.CTBEscapeRatio = String(Yanfly.Parameters['Escape Ratio']); +Yanfly.Param.CTBEscapeBoost = Number(Yanfly.Parameters['Fail Escape Boost']); + +Yanfly.Param.CTBFullTurn = String(Yanfly.Parameters['Full Turn']); +Yanfly.Param.CTBTurnStructure = false; + +Yanfly.Param.CTBRubberband = String(Yanfly.Parameters['Enable Rubberband']); +Yanfly.Param.CTBMinSpeed = String(Yanfly.Parameters['Minimum Speed']); +Yanfly.Param.CTBMaxSpeed = String(Yanfly.Parameters['Maximum Speed']); + +Yanfly.Param.CTBReadyName = String(Yanfly.Parameters['Ready Sound']); +Yanfly.Param.CTBReadyVol = Number(Yanfly.Parameters['Ready Volume']); +Yanfly.Param.CTBReadyPitch = Number(Yanfly.Parameters['Ready Pitch']); +Yanfly.Param.CTBReadyPan = Number(Yanfly.Parameters['Ready Pan']); + +Yanfly.Param.CTBOptionSpeedTx = String(Yanfly.Parameters['CTB Speed Text']); +Yanfly.Param.CTBDefaultSpeed = Number(Yanfly.Parameters['Default CTB Speed']); + +Yanfly.Param.CTBTurnOrder = eval(String(Yanfly.Parameters['Show Turn Order'])); +Yanfly.Param.CTBTurnPosY = Number(Yanfly.Parameters['Position Y']); +Yanfly.Param.CTBTurnPosX = String(Yanfly.Parameters['Position X']); +Yanfly.Param.CTBIconSize = Number(Yanfly.Parameters['Icon Size']); +Yanfly.Param.CTBTurnDirection = String(Yanfly.Parameters['Turn Direction']); +Yanfly.Param.CTBColorAllyBr = Number(Yanfly.Parameters['Ally Border Color']); +Yanfly.Param.CTBColorAllyBg = Number(Yanfly.Parameters['Ally Back Color']); +Yanfly.Param.CTBAllyIcon = Number(Yanfly.Parameters['Ally Icon']); +Yanfly.Param.CTBColorEnemyBr = Number(Yanfly.Parameters['Enemy Border Color']); +Yanfly.Param.CTBColorEnemyBg = Number(Yanfly.Parameters['Enemy Back Color']); +Yanfly.Param.CTBColorBackground = Number(Yanfly.Parameters['Background Color']); +Yanfly.Param.CTBEnemyIcon = Number(Yanfly.Parameters['Enemy Icon']); +Yanfly.Param.CTBEnemySVBattler = String(Yanfly.Parameters['Enemy SV Battlers']); +Yanfly.Param.CTBEnemySVBattler = eval(Yanfly.Param.CTBEnemySVBattler); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.CTB.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.CTB.DataManager_isDatabaseLoaded.call(this)) return false; + this.processCTBNotetagsC($dataClasses); + this.processCTBNotetags1($dataSkills); + this.processCTBNotetags1($dataItems); + this.processCTBNotetags2($dataActors); + this.processCTBNotetags2($dataClasses); + this.processCTBNotetags2($dataEnemies); + this.processCTBNotetags2($dataWeapons); + this.processCTBNotetags2($dataArmors); + this.processCTBNotetags2($dataStates); + this.processCTBNotetags3($dataActors, true); + this.processCTBNotetags3($dataEnemies, false); + return true; +}; + +DataManager.processCTBNotetagsC = function(group) { + if (Yanfly.ClassIdRef) return; + Yanfly.ClassIdRef = {}; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + if (obj.name.length <= 0) continue; + Yanfly.ClassIdRef[obj.name.toUpperCase()] = n; + } +}; + +DataManager.processCTBNotetags1 = function(group) { + var noteA1 = /<(?:CTB SPEED):[ ](\d+)>/i; + var noteA2 = /<(?:CTB SPEED):[ ]([\+\-]\d+)>/i; + var noteA3 = /<(?:CTB SPEED):[ ](\d+)([%%])>/i; + var noteA4 = /<(?:CTB SPEED):[ ]([\+\-]\d+)([%%])>/i; + var noteB1 = /<(?:CTB ORDER):[ ]([\+\-]\d+)>/i; + var noteS1 = /<(?:AFTER CTB):[ ](\d+)>/i; + var noteS2 = /<(?:AFTER CTB):[ ](\d+)([%%])>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.setCTBGaugeFlat = undefined; + obj.addCTBGaugeFlat = 0; + obj.setCTBGaugeRate = undefined; + obj.addCTBGaugeRate = 0.0; + obj.ctbOrderModifier = 0; + obj.afterCTBFlat = undefined; + obj.afterCTBRate = undefined; + var evalMode = 'none'; + obj.ctbEval = ''; + obj.ctbOrderEval = ''; + obj.ctbAfterEval = ''; + obj.ctbHelp = undefined; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(noteA1)) { + obj.setCTBGaugeFlat = parseInt(RegExp.$1); + } else if (line.match(noteA2)) { + obj.addCTBGaugeFlat = parseInt(RegExp.$1); + } else if (line.match(noteA3)) { + obj.setCTBGaugeRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteA4)) { + obj.addCTBGaugeRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteB1)) { + obj.ctbOrderModifier = parseInt(RegExp.$1); + } else if (line.match(noteS1)) { + obj.afterCTBFlat = parseInt(RegExp.$1); + } else if (line.match(noteS2)) { + obj.afterCTBRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(/<(?:TARGET CTB SPEED EVAL)>/i)) { + evalMode = 'ctb speed eval'; + } else if (line.match(/<\/(?:TARGET CTB SPEED EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:TARGET CTB ORDER EVAL)>/i)) { + evalMode = 'ctb order eval'; + } else if (line.match(/<\/(?:TARGET CTB ORDER EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:AFTER CTB EVAL)>/i)) { + evalMode = 'after ctb eval'; + } else if (line.match(/<\/(?:AFTER CTB EVAL)>/i)) { + evalMode = 'none'; + } else if (line.match(/<(?:CTB HELP)>/i)) { + evalMode = 'ctb help'; + obj.ctbHelp = ''; + } else if (line.match(/<\/(?:CTB HELP)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'ctb help') { + obj.ctbHelp = obj.ctbHelp + line + '\n'; + } else if (evalMode === 'ctb speed eval') { + obj.ctbEval = obj.ctbEval + line + '\n'; + } else if (evalMode === 'ctb order eval') { + obj.ctbOrderEval = obj.ctbOrderEval + line + '\n'; + } else if (evalMode === 'after ctb eval') { + obj.ctbAfterEval = obj.ctbAfterEval + line + '\n'; + } + } + } +}; + +DataManager.processCTBNotetags2 = function(group) { + var noteA1 = /<(?:CTB START):[ ]([\+\-]\d+)>/i; + var noteA2 = /<(?:CTB START):[ ]([\+\-]\d+)([%%])>/i; + var noteB1 = /<(?:CTB TURN):[ ]([\+\-]\d+)>/i; + var noteB2 = /<(?:CTB TURN):[ ]([\+\-]\d+)([%%])>/i; + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + obj.ctbStartFlat = 0; + obj.ctbStartRate = 0; + obj.ctbTurnFlat = 0; + obj.ctbTurnRate = 0; + var evalMode = 'none'; + obj.ctbHelp = undefined; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(noteA1)) { + obj.ctbStartFlat = parseInt(RegExp.$1); + } else if (line.match(noteA2)) { + obj.ctbStartRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(noteB1)) { + obj.ctbTurnFlat = parseInt(RegExp.$1); + } else if (line.match(noteB2)) { + obj.ctbTurnRate = parseFloat(RegExp.$1 * 0.01); + } else if (line.match(/<(?:CTB HELP)>/i)) { + evalMode = 'ctb help'; + obj.ctbHelp = ''; + } else if (line.match(/<\/(?:CTB HELP)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'ctb help') { + obj.ctbHelp = obj.ctbHelp + line + '\n'; + } + } + } +}; + +DataManager.processCTBNotetags3 = function(group, isActor) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + if (isActor) obj.ctbIcon = Yanfly.Param.CTBAllyIcon; + if (isActor) obj.ctbBorderColor = Yanfly.Param.CTBColorAllyBr; + if (isActor) obj.ctbBackgroundColor = Yanfly.Param.CTBColorAllyBg; + if (isActor) obj.ctbClassIcon = {}; + if (!isActor) obj.ctbIcon = Yanfly.Param.CTBEnemyIcon; + if (!isActor) obj.ctbBorderColor = Yanfly.Param.CTBColorEnemyBr; + if (!isActor) obj.ctbBackgroundColor = Yanfly.Param.CTBColorEnemyBg; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:CTB ICON):[ ](\d+)>/i)) { + obj.ctbIcon = parseInt(RegExp.$1); + } else if (line.match(/<(?:CTB BORDER COLOR):[ ](\d+)>/i)) { + obj.ctbBorderColor = parseInt(RegExp.$1); + } else if (line.match(/<(?:CTB BACKGROUND COLOR):[ ](\d+)>/i)) { + obj.ctbBackgroundColor = parseInt(RegExp.$1); + } else if (line.match(/<(?:CLASS)[ ](\d+)[ ](?:CTB ICON):[ ](\d+)>/i)) { + var classId = parseInt(RegExp.$1); + var icon = parseInt(RegExp.$2); + obj.ctbClassIcon[classId] = icon; + } else if (line.match(/<(.*)[ ](?:CTB ICON):[ ](\d+)>/i)) { + var name = String(RegExp.$1).toUpperCase(); + var icon = parseInt(RegExp.$2); + var classId = Yanfly.ClassIdRef[name]; + if (classId) obj.ctbClassIcon[classId] = icon; + } + } + } +}; + +//============================================================================= +// BattleManager +//============================================================================= + +BattleManager.isCTB = function() { + return this.isBattleSystem('ctb'); +}; + +Yanfly.CTB.BattleManager_isTurnBased = BattleManager.isTurnBased; +BattleManager.isTurnBased = function() { + if (this.isCTB()) return false; + return Yanfly.CTB.BattleManager_isTurnBased.call(this); +}; + +BattleManager.ctbTickRate = function() { + var rate = 0.1 * ConfigManager.ctbSpeed; + return rate; +}; + +Yanfly.CTB.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio; +BattleManager.makeEscapeRatio = function() { + if (this.isCTB()) { + var code = Yanfly.Param.CTBEscapeRatio; + try { + this._escapeRatio = eval(code); + } catch (e) { + this._escapeRatio = 0; + Yanfly.Util.displayError(e, code, 'CTB ESCAPE RATIO ERROR'); + } + var code = Yanfly.Param.CTBEscapeBoost; + try { + this._escapeFailBoost = eval(code); + } catch (e) { + this._escapeFailBoost = 0; + Yanfly.Util.displayError(e, code, 'CTB ESCAPE BOOST ERROR'); + } + } else { + this._escapeFailBoost = 0.1; + Yanfly.CTB.BattleManager_makeEscapeRatio.call(this); + } +}; + +Yanfly.CTB.BattleManager_startBattle = BattleManager.startBattle; +BattleManager.startBattle = function() { + Yanfly.CTB.BattleManager_startBattle.call(this); + if (this.isCTB()) { + this._phase = null; + this._counterAttacking = false; + this.ctbTicksToReadyClear(); + this.startCTB(); + } +}; + +Yanfly.CTB.BattleManager_endBattle = BattleManager.endBattle; +BattleManager.endBattle = function(result) { + Yanfly.CTB.BattleManager_endBattle.call(this, result); + this.ctbTicksToReadyClear(); + this.clearCTBData(); +}; + +BattleManager.startCTB = function() { + if (this._phase === 'battleEnd') return; + this.clearCTBData(); + this._ctbTarget = Math.max(1, eval(Yanfly.Param.CTBFullGauge)); + this._ctbFullTurn = Math.max(1, eval(Yanfly.Param.CTBFullTurn)); + this._ctbRubberband = eval(Yanfly.Param.CTBRubberband); + if (this.ctbRubberband()) { + this._ctbMinimumSpeed = Math.max(1, eval(Yanfly.Param.CTBMinSpeed)); + this._ctbMaximumSpeed = Math.max(1, eval(Yanfly.Param.CTBMaxSpeed)); + } + this._ctbTicks = this._ctbFullTurn; + this._ctbReadySound = { + name: Yanfly.Param.CTBReadyName, + volume: Yanfly.Param.CTBReadyVol, + pitch: Yanfly.Param.CTBReadyPitch, + pan: Yanfly.Param.CTBReadyPan + } + $gameParty.onCTBStart(); + $gameTroop.onCTBStart(); + this._phase = 'start'; +}; + +BattleManager.clearCTBData = function() { + this._highestBaseAgi = undefined; + this._averageBaseAgi = undefined; + this._lowestBaseAgi = undefined; + this._ctbTarget = undefined; + this._ctbCharge = undefined; + this._ctbTarget = undefined; + this._ctbCharge = undefined; + this._ctbFullTurn = undefined; + this._ctbRubberband = undefined; + this._ctbMinimumSpeed = undefined; + this._ctbMaximumSpeed = undefined; + this._ctbTicks = 0; +}; + +BattleManager.ctbTarget = function() { + if (!this._ctbTarget) this.startCTB(); + return this._ctbTarget; +}; + +BattleManager.ctbRubberband = function() { + return this._ctbRubberband; +}; + +BattleManager.ctbMinimumSpeed = function() { + return this._ctbMinimumSpeed; +}; + +BattleManager.ctbMaximumSpeed = function() { + return this._ctbMaximumSpeed; +}; + +BattleManager.highestBaseAgi = function() { + if (this._highestBaseAgi) return this._highestBaseAgi; + var agi = 0; + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var battler = $gameParty.battleMembers()[i]; + if (battler) agi = Math.max(agi, battler.agi); + } + for (var i = 0; i < $gameTroop.members().length; ++i) { + var battler = $gameTroop.members()[i]; + if (battler) agi = Math.max(agi, battler.agi); + } + this._highestBaseAgi = agi; + return this._highestBaseAgi; +}; + +BattleManager.averageBaseAgi = function() { + if (this._averageBaseAgi) return this._averageBaseAgi; + var agi = 0; + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var battler = $gameParty.battleMembers()[i]; + if (battler) agi += battler.agi; + } + for (var i = 0; i < $gameTroop.members().length; ++i) { + var battler = $gameTroop.members()[i]; + if (battler) agi += battler.agi; + } + var sum = $gameParty.battleMembers().length; + sum += $gameTroop.members().length; + this._averageBaseAgi = agi / sum; + return this._averageBaseAgi; +}; + +BattleManager.lowestBaseAgi = function() { + if (this._lowestBaseAgi) return this._lowestBaseAgi; + var agi = this.highestBaseAgi(); + for (var i = 0; i < $gameParty.battleMembers().length; ++i) { + var battler = $gameParty.battleMembers()[i]; + if (battler) agi = Math.min(agi, battler.agi); + } + for (var i = 0; i < $gameTroop.members().length; ++i) { + var battler = $gameTroop.members()[i]; + if (battler) agi = Math.min(agi, battler.agi); + } + this._lowestBaseAgi = agi; + return this._lowestBaseAgi; +}; + +BattleManager.ctbTurnOrder = function() { + var battlers = $gameParty.aliveMembers().concat($gameTroop.aliveMembers()); + battlers.sort(function(a, b) { + if (a.ctbTicksToReady() > b.ctbTicksToReady()) return 1; + if (a.ctbTicksToReady() < b.ctbTicksToReady()) return -1; + return 0; + }); + return battlers; +}; + +BattleManager.ctbTicksToReadyClear = function() { + var length = this.allBattleMembers().length; + for (var i = 0; i < length; ++i) { + var member = this.allBattleMembers()[i]; + if (member) member._ctbTicksToReady = undefined; + } +}; + +Yanfly.CTB.BattleManager_update = BattleManager.update; +BattleManager.update = function() { + if (this.isCTB()) { + if (this.isBusy()) return; + if (this.updateEvent()) return; + if (this._phase === 'battleEnd') { + return Yanfly.CTB.BattleManager_update.call(this); + } + if (this.checkBattleEnd()) return; + if (this._phase === 'ctb') { + this.updateCTBPhase(); + } else { + Yanfly.CTB.BattleManager_update.call(this); + } + } else { + Yanfly.CTB.BattleManager_update.call(this); + } +}; + +Yanfly.CTB.BattleManager_updateEventMain = BattleManager.updateEventMain; +BattleManager.updateEventMain = function() { + if (this.isCTB()) { + $gameTroop.updateInterpreter(); + $gameParty.requestMotionRefresh(); + if ($gameTroop.isEventRunning()) { + return true; + } + $gameTroop.setupBattleEvent(); + if ($gameTroop.isEventRunning() || SceneManager.isSceneChanging()) { + return true; + } + return false; + } else { + return Yanfly.CTB.BattleManager_updateEventMain.call(this); + } +}; + +BattleManager.updateCTBPhase = function() { + this._ctbLoops = 0; + for (;;) { + if (this.breakCTBPhase()) break; + var chargedBattler = this.getChargedCTBBattler(); + if (chargedBattler) return this.startCTBAction(chargedBattler); + var readyBattler = this.getReadyCTBBattler(); + if (readyBattler) { + return this.startCTBInput(readyBattler); + } else { + if (this.updateCTBTicks()) break; + this.updateBattlerCTB(); + } + } +}; + +BattleManager.breakCTBPhase = function() { + if (this._victoryPhase) return true; + if (this._processingForcedAction) return true; + if ($gameTroop.isEventRunning()) return true; + if (++this._ctbLoops >= 1000000) return true; + return this._phase !== 'ctb'; +}; + +BattleManager.updateCTBTicks = function() { + this._ctbTicks += 1 * this.tickRate(); + if (this._ctbTicks < this._ctbFullTurn) return false; + this._ctbTicks = 0; + $gameTroop.increaseTurn(); + this.endTurn(); + return true; +}; + +BattleManager.getChargedCTBBattler = function() { + if ($gameParty.aliveMembers() <= 0 || $gameTroop.aliveMembers() <= 0) { + return false; + } + var fastest = false; + for (var i = 0; i < this.allBattleMembers().length; ++i) { + var battler = this.allBattleMembers()[i]; + if (!battler) continue; + if (!this.isBattlerCTBCharged(battler)) continue; + if (!fastest) { + fastest = battler; + } else if (battler.ctbTicksToReady() < fastest.ctbTicksToReady()) { + fastest = battler; + } + } + return fastest; +}; + +BattleManager.isBattlerCTBCharged = function(battler) { + if (!battler.isCTBCharging()) return false; + if (battler.isConfused()) { + battler.makeActions(); + if (battler.isActor()) battler.makeConfusionActions(); + } + if (battler.ctbChargeRate() < 1) return false; + if (battler.ctbTurnOrder() > 0) return false; + return battler.currentAction() && battler.currentAction().item(); +}; + +BattleManager.getReadyCTBBattler = function() { + var fastest = false; + for (var i = 0; i < this.allBattleMembers().length; ++i) { + var battler = this.allBattleMembers()[i]; + if (!battler) continue; + if (!this.isBattlerCTBReady(battler)) continue; + if (!fastest) { + fastest = battler; + } else if (battler.ctbTicksToReady() < fastest.ctbTicksToReady()) { + fastest = battler; + } + } + return fastest; +}; + +BattleManager.isBattlerCTBReady = function(battler) { + if (battler.ctbRate() < 1) return false; + if (battler.isCTBCharging()) return false; + if (battler.ctbTurnOrder() > 0) return false; + if (battler.currentAction() && battler.currentAction().item()) { + this._subject = battler; + battler.makeActions(); + battler.setupCTBCharge(); + return true; + } + return true; +}; + +BattleManager.updateBattlerCTB = function() { + $gameParty.updateTick(); + $gameTroop.updateTick(); +}; + +BattleManager.setCTBPhase = function() { + this._phase = 'ctb'; +}; + +Yanfly.CTB.BattleManager_startInput = BattleManager.startInput; +BattleManager.startInput = function() { + if (this.isCTB()) { + this.setCTBPhase(); + } else { + Yanfly.CTB.BattleManager_startInput.call(this); + } +}; + +Yanfly.CTB.BattleManager_selectNextCommand = BattleManager.selectNextCommand; +BattleManager.selectNextCommand = function() { + if (this.isCTB()) { + if (!this.actor()) return this.setCTBPhase(); + this.resetNonPartyActorCTB(); + this._subject = this.actor(); + this.actor().setupCTBCharge(); + if (this.actor().isCTBCharging()) { + this.actor().spriteStepBack(); + this.actor().requestMotionRefresh(); + this._actorIndex = undefined; + this.setCTBPhase(); + } else if (this.isValidCTBActorAction()) { + this.startCTBAction(this.actor()); + } else { + if (this.actor()) this.ctbSkipTurn(); + $gameParty.requestMotionRefresh(); + this.setCTBPhase(); + } + } else { + Yanfly.CTB.BattleManager_selectNextCommand.call(this); + } +}; + +BattleManager.ctbSkipTurn = function() { + this.actor().clearActions(); + this.actor().setActionState('undecided'); + this.actor().requestMotionRefresh(); + if (!this._bypassCtbEndTurn) this.actor().endTurnAllCTB(); + this.actor().spriteStepBack(); +}; + +BattleManager.isValidCTBActorAction = function() { + if (!this.actor()) return false; + if (!this.actor().currentAction()) return false; + return this.actor().currentAction().item(); +}; + +BattleManager.resetNonPartyActorCTB = function() { + for (var i = 0; i < $gameParty.allMembers().length; ++i) { + var actor = $gameParty.allMembers()[i]; + if (!actor) continue; + if ($gameParty.battleMembers().contains(actor)) continue; + actor.resetAllCTB(); + } +}; + +Yanfly.CTB.BattleManager_selectPreviousCommand = + BattleManager.selectPreviousCommand; +BattleManager.selectPreviousCommand = function() { + if (this.isCTB()) { + if (this.actor()) this.actor().spriteStepBack(); + var actorIndex = this._actorIndex; + var scene = SceneManager._scene; + this._bypassCtbEndTurn = true; + scene.startPartyCommandSelection(); + this._bypassCtbEndTurn = undefined; + this._actorIndex = actorIndex; + } else { + Yanfly.CTB.BattleManager_selectPreviousCommand.call(this); + } +}; + +Yanfly.CTB.BattleManager_startTurn = BattleManager.startTurn; +BattleManager.startTurn = function() { + if (this.isCTB() && !this.isTurnBased()) return; + Yanfly.CTB.BattleManager_startTurn.call(this); +}; + +Yanfly.CTB.BattleManager_updateTurnEnd = BattleManager.updateTurnEnd; +BattleManager.updateTurnEnd = function() { + if (this.isCTB()) { + this.setCTBPhase(); + } else { + Yanfly.CTB.BattleManager_updateTurnEnd.call(this); + } +}; + +BattleManager.startCTBInput = function(battler) { + if (battler.isDead()) return; + battler.onTurnStart(); + battler.makeActions(); + if (battler.isEnemy()) { + battler.setupCTBCharge(); + } else if (battler.canInput()) { + this._actorIndex = battler.index(); + this.playCTBReadySound(); + battler.setActionState('inputting'); + battler.spriteStepForward(); + this._phase = 'input'; + return; + } else if (battler.isConfused()) { + battler.makeConfusionActions(); + battler.setupCTBCharge(); + } else { + battler.makeAutoBattleActions(); + battler.setupCTBCharge(); + } + if (battler.isCTBCharging()) { + this.setCTBPhase(); + } else { + this.startCTBAction(battler); + } +}; + +BattleManager.playCTBReadySound = function() { + AudioManager.playSe(this._ctbReadySound); +}; + +BattleManager.startCTBAction = function(battler) { + this._subject = battler; + var action = this._subject.currentAction(); + if (action && action.isValid()) { + this.startAction(); + } else { + this.endAction(); + } +}; + +Yanfly.CTB.BattleManager_processForcedAction = + BattleManager.processForcedAction; +BattleManager.processForcedAction = function() { + var forced = false; + if (this._actionForcedBattler && this.isCTB()) { + var action = this._actionForcedBattler.currentAction(); + forced = true; + } + Yanfly.CTB.BattleManager_processForcedAction.call(this); + if (forced) this._subject.setAction(0, action); +}; + +Yanfly.CTB.BattleManager_endAction = BattleManager.endAction; +BattleManager.endAction = function() { + if (this.isCTB()) { + this.endCTBAction(); + } else { + Yanfly.CTB.BattleManager_endAction.call(this); + } +}; + +BattleManager.endCTBAction = function() { + if (Imported.YEP_BattleEngineCore) { + if (this._processingForcedAction) this._phase = this._preForcePhase; + this._processingForcedAction = false; + } + if (this._subject) this._subject.onAllActionsEnd(); + if (this.updateEventMain()) return; + this._subject.endTurnAllCTB(); + if (this.loadPreForceActionSettings()) return; + var chargedBattler = this.getChargedCTBBattler(); + if (chargedBattler) { + this.startCTBAction(chargedBattler); + } else { + this.setCTBPhase(); + } +}; + +Yanfly.CTB.BattleManager_invokeCounterAttack = + BattleManager.invokeCounterAttack; +BattleManager.invokeCounterAttack = function(subject, target) { + if (this.isCTB()) this._counterAttacking = true; + Yanfly.CTB.BattleManager_invokeCounterAttack.call(this, subject, target); + if (this.isCTB()) this._counterAttacking = false; +}; + +BattleManager.isCounterAttacking = function() { + return this._counterAttacking; +}; + +Yanfly.CTB.BattleManager_processEscape = BattleManager.processEscape; +BattleManager.processEscape = function() { + if (this.isCTB()) { + return this.processEscapeCTB(); + } else { + return Yanfly.CTB.BattleManager_processEscape.call(this); + } +}; + +BattleManager.processEscapeCTB = function() { + $gameParty.performEscape(); + SoundManager.playEscape(); + var success = this._preemptive ? true : (Math.random() < this._escapeRatio); + if (success) { + $gameParty.removeBattleStates(); + $gameParty.performEscapeSuccess(); + this.displayEscapeSuccessMessage(); + this._escaped = true; + this.processAbort(); + } else { + this.actor().spriteStepBack(); + this.actor().clearActions(); + this.displayEscapeFailureMessage(); + this._escapeRatio += this._escapeFailBoost; + this.startTurn(); + this.processFailEscapeCTB(); + } + return success; +}; + +BattleManager.processFailEscapeCTB = function() { + var actor = $gameParty.members()[this._actorIndex]; + if (!actor) return; + actor.resetAllCTB(); +}; + +BattleManager.redrawCTBIcons = function() { + var max = $gameTroop.members().length; + for (var i = 0; i < max; ++i) { + var member = $gameTroop.members()[i]; + if (!member) continue; + if (!member.battler()._ctbIcon) continue; + member.battler()._ctbIcon.forceRedraw(); + } +}; + +Yanfly.CTB.BattleManager_processActionSequence = + BattleManager.processActionSequence; +BattleManager.processActionSequence = function(actionName, actionArgs) { + if (this.isCTB()) { + // CTB SPEED + if (actionName === 'CTB SPEED') { + this.actionCTBCharge(actionArgs); + return this.actionCTBSpeed(actionArgs); + } + // CTB ORDER + if (actionName === 'CTB ORDER') { + return this.actionCTBOrder(actionArgs); + } + } + return Yanfly.CTB.BattleManager_processActionSequence.call(this, + actionName, actionArgs); +}; + +BattleManager.actionCTBCharge = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + var cmd = actionArgs[1]; + if (cmd.match(/([\+\-]\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isCTBCharging()) continue; + var max = target.ctbChargeDestination(); + var value = rate * max + target.ctbCharge(); + target.setCTBCharge(value); + target.refresh(); + } + } else if (cmd.match(/([\+\-]\d+)/i)) { + var plus = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isCTBCharging()) continue; + var value = plus + target.ctbCharge(); + target.setCTBCharge(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isCTBCharging()) continue; + var max = target.ctbChargeDestination(); + var value = rate * max; + target.setCTBCharge(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)/i)) { + var value = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (!target.isCTBCharging()) continue; + target.setCTBCharge(value); + target.refresh(); + } + } + return true; +}; + +BattleManager.actionCTBSpeed = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + var cmd = actionArgs[1]; + if (cmd.match(/([\+\-]\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + var max = this.ctbTarget(); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isCTBCharging()) continue; + var value = rate * max + target.ctbSpeed(); + target.setCTBSpeed(value); + target.refresh(); + } + } else if (cmd.match(/([\+\-]\d+)/i)) { + var plus = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isCTBCharging()) continue; + var value = plus + target.ctbSpeed(); + target.setCTBSpeed(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)([%%])/i)) { + var rate = parseFloat(RegExp.$1 * 0.01); + var max = this.ctbTarget(); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isCTBCharging()) continue; + var value = rate * max; + target.setCTBSpeed(value); + target.refresh(); + } + } else if (cmd.match(/(\d+)/i)) { + var value = parseInt(RegExp.$1); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + if (target === this._subject) continue; + if (target.isCTBCharging()) continue; + target.setCTBSpeed(value); + target.refresh(); + } + } + return true; +}; + +BattleManager.actionCTBOrder = function(actionArgs) { + var targets = this.makeActionTargets(actionArgs[0]); + if (targets.length < 1) return true; + var value = parseInt(actionArgs[1]); + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + if (!target) continue; + target.ctbAlterTurnOrder(value); + } + return true; +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.CTB.Game_Action_applyItemUserEffect = + Game_Action.prototype.applyItemUserEffect; +Game_Action.prototype.applyItemUserEffect = function(target) { + Yanfly.CTB.Game_Action_applyItemUserEffect.call(this, target); + if (BattleManager.isCTB() && $gameParty.inBattle()) { + this.applyItemCTBEffect(target); + } +}; + +Game_Action.prototype.applyItemCTBEffect = function(target) { + if (!target) return; + this.applyItemCTBOrderEffect(target); + this.applyItemCTBOrderEvalEffect(target); + this.applyItemCTBSetEffects(target); + this.applyItemCTBAddEffects(target); + this.applyItemCTBEvalEffect(target); + if (BattleManager.isCounterAttacking()) return; + this.rebalanceCTBSpeed(target); +}; + +Game_Action.prototype.applyItemCTBOrderEffect = function(target) { + var item = this.item(); + if (!item) return; + if (item.ctbOrderModifier === 0) return; + target.ctbAlterTurnOrder(item.ctbOrderModifier); +}; + +Game_Action.prototype.applyItemCTBSetEffects = function(target) { + var item = this.item(); + if (!item) return; + var value = undefined; + if (target.isCTBCharging()) { + var max = target.ctbChargeDestination(); + if (item.setCTBGaugeFlat !== undefined) { + value = item.setCTBGaugeFlat; + } else if (item.setCTBGaugeRate !== undefined) { + value = item.setCTBGaugeRate * max; + } + if (value !== undefined) target.setCTBCharge(value); + } else { + var max = BattleManager.ctbTarget(); + if (item.setCTBGaugeFlat !== undefined) { + value = item.setCTBGaugeFlat; + } else if (item.setCTBGaugeRate !== undefined) { + value = item.setCTBGaugeRate * max; + } + if (value !== undefined) target.setCTBSpeed(value); + } +}; + +Game_Action.prototype.applyItemCTBAddEffects = function(target) { + var item = this.item(); + if (!item) return; + if (target.isCTBCharging()) { + var value = target.ctbCharge(); + var max = target.ctbChargeDestination(); + value += item.addCTBGaugeRate * max; + value += item.addCTBGaugeFlat; + target.setCTBCharge(value); + } else { + var value = target.ctbSpeed(); + var max = BattleManager.ctbTarget() + value += item.addCTBGaugeRate * max; + value += item.addCTBGaugeFlat; + target.setCTBSpeed(value); + } +}; + +Game_Action.prototype.applyItemCTBEvalEffect = function(target) { + if (this.item().ctbEval === '') return; + var a = this.subject(); + var user = this.subject(); + var b = target; + var item = this.item(); + var skill = this.item(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var speed = target.ctbSpeed(); + var charge = target.ctbCharge(); + if (target.isCTBCharging()) { + var max = target.ctbChargeDestination(); + } else { + var max = BattleManager.ctbTarget(); + } + var code = item.ctbEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CTB EVAL ERROR'); + } + target.setCTBSpeed(speed); + target.setCTBCharge(charge); +}; + +Game_Action.prototype.applyItemCTBOrderEvalEffect = function(target) { + if (this.item().ctbOrderEval === '') return; + var a = this.subject(); + var user = this.subject(); + var b = target; + var item = this.item(); + var skill = this.item(); + var s = $gameSwitches._data; + var v = $gameVariables._data; + var order = 0; + var code = item.ctbOrderEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CTB ORDER EVAL ERROR'); + } + target.ctbAlterTurnOrder(order); +}; + +Game_Action.prototype.rebalanceCTBSpeed = function(target) { + var speed = this.subject().ctbSpeed(); + var offset = 00000000001; + speed = Math.max(speed + offset, target.ctbSpeed() + target.ctbCharge()); + this.subject().setCTBSpeed(speed); +}; + +//============================================================================= +// Game_Battlerbase +//============================================================================= + +Yanfly.CTB.Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh; +Game_BattlerBase.prototype.refresh = function() { + if (BattleManager.isCTB() && $gameParty.inBattle()) { + BattleManager.ctbTicksToReadyClear(); + this._ctbTickValue = undefined; + this.clearCTBCommandWindowCache(); + } + Yanfly.CTB.Game_BattlerBase_refresh.call(this); +}; + +Game_BattlerBase.prototype.clearCTBCommandWindowCache = function() { + this._commandWindowIndex = undefined; + this._commandWindowItem = undefined; + this._skillWindowIndex = undefined; + this._skillWindowItem = undefined; + this._itemWindowIndex = undefined; + this._itemWindowItem = undefined; +}; + +Yanfly.CTB.Game_BattlerBase_die = Game_BattlerBase.prototype.die; +Game_BattlerBase.prototype.die = function() { + Yanfly.CTB.Game_BattlerBase_die.call(this); + if (BattleManager.isCTB() && $gameParty.inBattle()) this.resetAllCTB(); +}; + +Yanfly.CTB.Game_BattlerBase_appear = Game_BattlerBase.prototype.appear; +Game_BattlerBase.prototype.appear = function() { + Yanfly.CTB.Game_BattlerBase_appear.call(this); + if (BattleManager.isCTB() && this.isEnemy()) { + BattleManager.redrawCTBIcons(); + } +}; + +//============================================================================= +// Game_Battler +//============================================================================= + +Game_Battler.prototype.ctbIcon = function() { + return 0; +}; + +Game_Battler.prototype.ctbBorderColor = function() { + return 0; +}; + +Game_Battler.prototype.ctbBackgroundColor = function() { + return 0; +}; + +Game_Battler.prototype.onCTBStart = function() { + this._ctbSpeed = eval(Yanfly.Param.CTBInitSpeed); + this._ctbSpeed += BattleManager.ctbTarget() * this.ctbStartRate(); + this._ctbSpeed += this.ctbStartFlat(); + this._ctbCharge = 0; + this._ctbCharging = false; + this._ctbChargeMod = 0; + this.applyPreemptiveBonusCTB(); + this.applySurpriseBonusCTB(); + this.refresh(); +}; + +Game_Battler.prototype.applyPreemptiveBonusCTB = function() { + if (!BattleManager._preemptive) return; + if (!this.isActor()) return; + var rate = Yanfly.Param.CTBPreEmptive; + this._ctbSpeed += rate * BattleManager.ctbTarget(); +}; + +Game_Battler.prototype.applySurpriseBonusCTB = function() { + if (!BattleManager._surprise) return; + if (!this.isEnemy()) return; + var rate = Yanfly.Param.CTBSurprise; + this._ctbSpeed += rate * BattleManager.ctbTarget(); +}; + +Yanfly.CTB.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd; +Game_Battler.prototype.onBattleEnd = function() { + Yanfly.CTB.Game_Battler_onBattleEnd.call(this); + this._ctbSpeed = 0; + this._ctbCharge = 0; + this._ctbCharging = false; + this._ctbChargeMod = 0; + this.clearCTBCommandWindowCache(); +}; + +Game_Battler.prototype.ctbTicksToReady = function() { + if (this._ctbTicksToReady !== undefined) return this._ctbTicksToReady; + var goal = BattleManager.ctbTarget(); + if (this.isCTBCharging()) goal += this.ctbChargeDestination(); + goal -= this.ctbSpeed(); + goal -= (this.isCTBCharging()) ? this.ctbCharge() : 0; + var rate = this.ctbSpeedTick(); + if (this.ctbTicksToReadyActionCheck()) { + var item = this.ctbTicksToReadyActionCheck(); + if (item.speed < 0) goal -= item.speed; + } + this._ctbTicksToReady = goal / Math.max(1, rate); + return this._ctbTicksToReady; +}; + +Game_Battler.prototype.ctbTicksToReadyActionCheck = function() { + if (!BattleManager.isInputting()) return false; + if (BattleManager.actor() !== this) return false; + var scene = SceneManager._scene; + if (scene._skillWindow.active) { + if (this._skillWindowIndex === scene._skillWindow.index()) { + return this._skillWindowItem; + } + this._skillWindowIndex = scene._skillWindow.index(); + this._skillWindowItem = scene._skillWindow.item(); + return this._skillWindowItem; + } else if (scene._itemWindow.active) { + if (this._itemWindowIndex === scene._itemWindow.index()) { + return this._itemWindowItem; + } + this._itemWindowIndex = scene._itemWindow.index(); + this._itemWindowItem = scene._itemWindow.item(); + return this._itemWindowItem; + } else if (scene._actorCommandWindow.active) { + if (this._commandWindowIndex === scene._actorCommandWindow.index()) { + return this._commandWindowItem; + } + var win = scene._actorCommandWindow; + var symbol = win.currentSymbol(); + this._commandWindowIndex = win.index(); + if (symbol === 'attack') { + this._commandWindowItem = $dataSkills[this.attackSkillId()]; + return this._commandWindowItem; + } else if (symbol === 'guard') { + this._commandWindowItem = $dataSkills[this.guardSkillId()]; + return this._commandWindowItem; + } else { + this._commandWindowItem = undefined; + return false; + } + } + if (!this.currentAction()) return false; + return this.currentAction().item(); +}; + +Game_Battler.prototype.ctbSpeed = function() { + if (this.isDead()) return -1 * BattleManager.ctbTarget(); + if (this.isHidden()) return -1 * BattleManager.ctbTarget(); + if (this._ctbSpeed === undefined) this.onCTBStart(); + return this._ctbSpeed; +}; + +Game_Battler.prototype.ctbRate = function() { + if (this._ctbSpeed === undefined) this.onCTBStart(); + var rate = this._ctbSpeed / BattleManager.ctbTarget(); + return rate.clamp(0, 1); +}; + +Game_Battler.prototype.isCTBCharging = function() { + return this._ctbCharging; +}; + +Game_Battler.prototype.setCTBCharging = function(value) { + this._ctbCharging = value; +}; + +Game_Battler.prototype.ctbCharge = function() { + if (this._ctbCharge === undefined) this.onCTBStart(); + return this._ctbCharge; +}; + +Game_Battler.prototype.ctbChargeDestination = function() { + var denom = Math.max(1, -1 * this._ctbChargeMod); + return denom; +}; + +Game_Battler.prototype.ctbChargeRate = function() { + if (this._ctbCharge === undefined) this.onCTBStart(); + if (!this.isCTBCharging()) return 0; + var rate = this._ctbCharge / this.ctbChargeDestination(); + return rate.clamp(0, 1); +}; + +Game_Battler.prototype.setCTBSpeed = function(value) { + this._ctbSpeed = value; +}; + +Game_Battler.prototype.setCTBCharge = function(value) { + if (this.isCTBCharging()) this._ctbCharge = value; +}; + +Game_Battler.prototype.setupCTBCharge = function() { + if (BattleManager._subject !== this) return; + if (BattleManager._bypassCtbEndTurn) return; + if (!this.currentAction()) this.makeActions(); + if (this.currentAction()) { + var item = this.currentAction().item(); + if (item && item.speed < 0) { + this.setCTBCharging(true); + this._ctbChargeMod = item.speed; + this.setCTBCharge(0); + } else if (!item) { + this._ctbChargeMod = 0; + } else { + this._ctbChargeMod = 0; + } + } else { + this._ctbChargeMod = 0; + } + this.setActionState('waiting'); +}; + +Yanfly.CTB.Game_Battler_updateTick = Game_Battler.prototype.updateTick; +Game_Battler.prototype.updateTick = function() { + Yanfly.CTB.Game_Battler_updateTick.call(this); + if (BattleManager.isCTB()) this.updateCTB(); +}; + +Game_Battler.prototype.updateCTB = function() { + if (this.isDead()) return this.resetAllCTB(); + if (!this.canMove()) { + this.updateCTBStates(); + return; + } + if (this.isCTBCharging()) { + if (!this.currentAction()) this.resetAllCTB(); + if (this.currentAction() && this.currentAction().item() === null) { + this.resetAllCTB(); + } + } + if (this.isCTBCharging()) { + var value = this.ctbCharge() + this.ctbSpeedTick(); + this.setCTBCharge(value); + } else if (this.ctbRate() < 1) { + var value = this.ctbSpeed() + this.ctbSpeedTick(); + this.setCTBSpeed(value); + } +}; + +Game_Battler.prototype.updateCTBStates = function() { + if (BattleManager.timeBasedBuffs()) return; + for (var i = 0; i < this._states.length; ++i) { + var stateId = this._states[i]; + var state = $dataStates[stateId]; + if (!state) continue; + if (!this._stateTurns[stateId]) continue; + if (state.restriction >= 4 && state.autoRemovalTiming !== 0) { + var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime; + this._stateTurns[stateId] -= value; + if (this._stateTurns[stateId] <= 0) this.removeState(stateId); + } + } +}; + +Game_Battler.prototype.resetAllCTB = function() { + this._ctbCharge = 0; + this._ctbChargeMod = 0; + this._ctbCharging = false; + this._ctbSpeed = 0; + this.clearActions(); +}; + +Game_Battler.prototype.endTurnAllCTB = function() { + this._ctbCharge = 0; + this._ctbChargeMod = 0; + this._ctbCharging = false; + if (this.checkCTBEndInstantCast()) return; + this.setEndActionCTBSpeed(); + this.clearActions(); + this.setActionState('undecided'); + if (this.battler()) this.battler().refreshMotion(); + if (BattleManager.isTickBased()) this.onTurnEnd(); +}; + +Game_Battler.prototype.checkCTBEndInstantCast = function() { + if (!Imported.YEP_InstantCast) return false; + var action = this.currentAction(); + if (!action) return false; + var item = action.item(); + if (!item) return false; + if (!this.isInstantCast(item)) return false; + var length = BattleManager.allBattleMembers().length; + for (var i = 0; i < length; ++i) { + var member = BattleManager.allBattleMembers()[i]; + if (!member) continue; + var max = member.ctbSpeed() + member.ctbCharge(); + this._ctbSpeed = Math.max(this._ctbSpeed, max); + } + this._ctbSpeed = Math.max(this._ctbSpeed, BattleManager.ctbTarget()); + this._ctbSpeed += 0.00000000001; + return true; +}; + +Game_Battler.prototype.ctbSpeedRate = function() { + if (!this.canMove()) return 0; + var base = this.paramBase(6) + this.paramPlus(6); + if (base >= this.paramMax(6) && this.agi >= this.paramMax(6)) return 1; + var rate = this.agi / base; + return rate; +}; + +Game_Battler.prototype.ctbSpeedTick = function() { + var value = this.ctbTickValue(); + if (BattleManager.ctbRubberband()) { + var min = BattleManager.ctbMinimumSpeed(); + var max = BattleManager.ctbMaximumSpeed(); + value = value.clamp(min, max); + value += this.minorCTBOffset(); + } + return value * BattleManager.tickRate(); +}; + +Game_Battler.prototype.ctbTickValue = function() { + if (this._ctbTickValue !== undefined) return this._ctbTickValue; + var a = this; + var user = this; + var subject = this; + this._ctbTickValue = eval(Yanfly.Param.CTBPerTick); + return this._ctbTickValue; +}; + +Game_Battler.prototype.setEndActionCTBSpeed = function() { + this._ctbSpeed = 0; + var action = this.currentAction(); + if (!action) return; + var item = action.item();; + if (item) { + if (item.afterCTBFlat !== undefined) this.setCTBSpeed(item.afterCTBFlat); + if (item.afterCTBRate !== undefined) { + this.setCTBSpeed(item.afterCTBRate * BattleManager.ctbTarget()); + } + if (item.speed > 0) this._ctbSpeed += item.speed; + } + this._ctbSpeed += BattleManager.ctbTarget() * this.ctbTurnRate(); + this._ctbSpeed += this.ctbTurnFlat(); + if (item) this.afterCTBEval(item); +}; + +Game_Battler.prototype.afterCTBEval = function(item) { + if (!item) return; + var a = this; + var user = this; + var skill = item; + var s = $gameSwitches._data; + var v = $gameVariables._data; + var speed = this._ctbSpeed; + var max = BattleManager.ctbTarget(); + var code = item.ctbAfterEval; + try { + eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'AFTER CTB ERROR'); + } + this.setCTBSpeed(speed); +}; + +Game_Battler.prototype.ctbStartFlat = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.ctbStartFlat; + } + return value; +}; + +Game_Battler.prototype.ctbStartRate = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.ctbStartRate; + } + return value; +}; + +Game_Battler.prototype.ctbTurnFlat = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.ctbTurnFlat; + } + return value; +}; + +Game_Battler.prototype.ctbTurnRate = function() { + var value = 0; + for (var i = 0; i < this.states().length; ++i) { + var state = this.states()[i]; + if (state) value += state.ctbTurnRate; + } + return value; +}; + +Yanfly.CTB.Game_Battler_removeState = Game_Battler.prototype.removeState; +Game_Battler.prototype.removeState = function(stateId) { + if (BattleManager.isCTB()) { + var confuseCondition = this.isConfused(); + } + Yanfly.CTB.Game_Battler_removeState.call(this, stateId); + if (BattleManager.isCTB()) { + if (confuseCondition !== this.isConfused()) this.resetAllCTB(); + } +}; + +Game_Battler.prototype.minorCTBOffset = function() { + var value = 0.00000000001; + if (this.isActor()) value *= $gameParty.members().length - this.index(); + if (this.isEnemy()) value *= -1 * this.index(); + return value; +}; + +Game_Battler.prototype.ctbTurnOrder = function() { + var index = BattleManager.ctbTurnOrder().indexOf(this); + return index; +}; + +Game_Battler.prototype.ctbAlterTurnOrder = function(value) { + var sign = (value > 0) ? 1 : -1; + var max = BattleManager.ctbTurnOrder().length - 1; + var index = this.ctbTurnOrder(); + index += value; + index = index.clamp(0, max); + var battler = BattleManager.ctbTurnOrder()[index]; + if (!battler) battler = this; + var ticksTarget = battler.ctbTicksToReady(); + var ticksCurrent = this.ctbTicksToReady(); + var ticksChange = ticksTarget - ticksCurrent; + ticksChange += sign * Math.abs(this.minorCTBOffset()); + this._ctbSpeed -= this.ctbSpeedTick() * ticksChange; +}; + +//============================================================================= +// Game_Actor +//============================================================================= + +Game_Actor.prototype.ctbIcon = function() { + if (this.actor().ctbClassIcon) { + if (this.actor().ctbClassIcon[this._classId]) { + return this.actor().ctbClassIcon[this._classId]; + } + } + return this.actor().ctbIcon; +}; + +Game_Actor.prototype.ctbBorderColor = function() { + return this.actor().ctbBorderColor; +}; + +Game_Actor.prototype.ctbBackgroundColor = function() { + return this.actor().ctbBackgroundColor; +}; + +Game_Actor.prototype.ctbStartFlat = function() { + var value = Game_Battler.prototype.ctbStartFlat.call(this); + value += this.actor().ctbStartFlat; + value += this.currentClass().ctbStartFlat; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.ctbStartFlat) value += equip.ctbStartFlat; + } + return value; +}; + +Game_Actor.prototype.ctbStartRate = function() { + var value = Game_Battler.prototype.ctbStartRate.call(this); + value += this.actor().ctbStartRate; + value += this.currentClass().ctbStartRate; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.ctbStartRate) value += equip.ctbStartRate; + } + return value; +}; + +Game_Actor.prototype.ctbTurnFlat = function() { + var value = Game_Battler.prototype.ctbTurnFlat.call(this); + value += this.actor().ctbTurnFlat; + value += this.currentClass().ctbTurnFlat; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.ctbTurnFlat) value += equip.ctbTurnFlat; + } + return value; +}; + +Game_Actor.prototype.ctbTurnRate = function() { + var value = Game_Battler.prototype.ctbTurnRate.call(this); + value += this.actor().ctbTurnRate; + value += this.currentClass().ctbTurnRate; + for (var i = 0; i < this.equips().length; ++i) { + var equip = this.equips()[i]; + if (equip && equip.ctbTurnRate) value += equip.ctbTurnRate; + } + return value; +}; + +Yanfly.CTB.Game_Actor_changeClass = Game_Actor.prototype.changeClass; +Game_Actor.prototype.changeClass = function(classId, keepExp) { + Yanfly.CTB.Game_Actor_changeClass.call(this, classId, keepExp); + this.ctbTransform(); +}; + +Yanfly.CTB.Game_Actor_setCharacterImage = + Game_Actor.prototype.setCharacterImage; +Game_Actor.prototype.setCharacterImage = function(name, index) { + Yanfly.CTB.Game_Actor_setCharacterImage.call(this, name, index) + this.ctbTransform(); +}; + +Yanfly.CTB.Game_Actor_setFaceImage = Game_Actor.prototype.setFaceImage; +Game_Actor.prototype.setFaceImage = function(faceName, faceIndex) { + Yanfly.CTB.Game_Actor_setFaceImage.call(this, faceName, faceIndex); + this.ctbTransform(); +}; + +Yanfly.CTB.Game_Actor_setBattlerImage = Game_Actor.prototype.setBattlerImage; +Game_Actor.prototype.setBattlerImage = function(battlerName) { + Yanfly.CTB.Game_Actor_setBattlerImage.call(this, battlerName); + this.ctbTransform(); +}; + +Game_Actor.prototype.ctbTransform = function() { + if (!$gameParty.inBattle()) return; + if (!BattleManager.isCTB()) return; + this._ctbTransformed = true; +}; + +//============================================================================= +// Game_Enemy +//============================================================================= + +Game_Enemy.prototype.ctbIcon = function() { + return this.enemy().ctbIcon; +}; + +Game_Enemy.prototype.ctbBorderColor = function() { + return this.enemy().ctbBorderColor; +}; + +Game_Enemy.prototype.ctbBackgroundColor = function() { + return this.enemy().ctbBackgroundColor; +}; + +Game_Enemy.prototype.ctbStartFlat = function() { + var value = Game_Battler.prototype.ctbStartFlat.call(this); + value += this.enemy().ctbStartFlat; + return value; +}; + +Game_Enemy.prototype.ctbStartRate = function() { + var value = Game_Battler.prototype.ctbStartRate.call(this); + value += this.enemy().ctbStartRate; + return value; +}; + +Game_Enemy.prototype.ctbTurnFlat = function() { + var value = Game_Battler.prototype.ctbTurnFlat.call(this); + value += this.enemy().ctbTurnFlat; + return value; +}; + +Game_Enemy.prototype.ctbTurnRate = function() { + var value = Game_Battler.prototype.ctbTurnRate.call(this); + value += this.enemy().ctbTurnRate; + return value; +}; + +Yanfly.CTB.Game_Enemy_transform = Game_Enemy.prototype.transform; +Game_Enemy.prototype.transform = function(enemyId) { + Yanfly.CTB.Game_Enemy_transform.call(this, enemyId); + this._ctbTransformed = true; +}; + +//============================================================================= +// Game_Unit +//============================================================================= + +Game_Unit.prototype.onCTBStart = function() { + if (!BattleManager.isCTB()) return; + for (var i = 0; i < this.members().length; ++i) { + var member = this.members()[i]; + if (member) member.onCTBStart(); + } +}; + +Game_Unit.prototype.increaseTurnTimeBasedCTB = function() { + for (var i = 0; i < this.members().length; ++i) { + var member = this.members()[i]; + if (!member) continue; + if (member.isDead()) continue; + if (member.isHidden()) continue; + if (member.canMove()) continue; + member.onTurnEnd(); + } +}; + +//============================================================================= +// Game_Party +//============================================================================= + +Yanfly.CTB.Game_Party_performEscape = Game_Party.prototype.performEscape; +Game_Party.prototype.performEscape = function() { + if (BattleManager.isCTB()) return; + Yanfly.CTB.Game_Party_performEscape.call(this); +}; + +//============================================================================= +// Game_Troop +//============================================================================= + +Yanfly.CTB.Game_Troop_increaseTurn = Game_Troop.prototype.increaseTurn; +Game_Troop.prototype.increaseTurn = function() { + Yanfly.CTB.Game_Troop_increaseTurn.call(this); + if (BattleManager.isCTB() && BattleManager.timeBasedStates()) { + $gameParty.increaseTurnTimeBasedCTB(); + this.increaseTurnTimeBasedCTB(); + } +}; + +//============================================================================= +// Sprite_Battler +//============================================================================= + +Yanfly.CTB.Sprite_Battler_postSpriteInitialize = + Sprite_Battler.prototype.postSpriteInitialize; +Sprite_Battler.prototype.postSpriteInitialize = function() { + Yanfly.CTB.Sprite_Battler_postSpriteInitialize.call(this); + if (BattleManager.isCTB()) this.createCTBIcon(); +}; + +Sprite_Battler.prototype.createCTBIcon = function() { + if (!Yanfly.Param.CTBTurnOrder) return; + this._ctbIcon = new Window_CTBIcon(this); +}; + +Yanfly.CTB.Sprite_Battler_update = Sprite_Battler.prototype.update; +Sprite_Battler.prototype.update = function() { + Yanfly.CTB.Sprite_Battler_update.call(this); + this.addCTBIcon(); +}; + +Sprite_Battler.prototype.addCTBIcon = function() { + if (!this._ctbIcon) return; + if (this._addedCTBIcon) return; + if (!SceneManager._scene) return; + var scene = SceneManager._scene; + if (!scene._windowLayer) return; + this._addedCTBIcon = true; + this._ctbIcon.setWindowLayer(scene._windowLayer); + scene.addChild(this._ctbIcon); +}; + +//============================================================================= +// Window_Help +//============================================================================= + +Yanfly.CTB.Window_Help_setItem = Window_Help.prototype.setItem; +Window_Help.prototype.setItem = function(item) { + if (this.meetCTBConditions(item)) return this.setText(item.ctbHelp); + Yanfly.CTB.Window_Help_setItem.call(this, item); +}; + +Window_Help.prototype.meetCTBConditions = function(item) { + if (!item) return false; + if (!BattleManager.isCTB()) return false; + return item.ctbHelp !== undefined; +}; + +//============================================================================= +// Window_Selectable +//============================================================================= + +Yanfly.CTB.Window_Selectable_select = Window_Selectable.prototype.select; +Window_Selectable.prototype.select = function(index) { + if ($gameParty.inBattle() && BattleManager.isCTB()) { + BattleManager.ctbTicksToReadyClear(); + } + Yanfly.CTB.Window_Selectable_select.call(this, index); +}; + +//============================================================================= +// Window_CTBIcon +//============================================================================= + +function Window_CTBIcon() { + this.initialize.apply(this, arguments); +} + +Window_CTBIcon.prototype = Object.create(Window_Base.prototype); +Window_CTBIcon.prototype.constructor = Window_CTBIcon; + +Window_CTBIcon.prototype.initialize = function(mainSprite) { + this._mainSprite = mainSprite; + var width = this.iconWidth() + 8 + this.standardPadding() * 2; + var height = this.iconHeight() + 8 + this.standardPadding() * 2; + this._redraw = false; + this._position = Yanfly.Param.CTBTurnPosX.toLowerCase(); + this._direction = Yanfly.Param.CTBTurnDirection.toLowerCase(); + this._lowerWindows = eval(Yanfly.Param.BECLowerWindows); + Window_Base.prototype.initialize.call(this, 0, 0, width, height); + this.opacity = 0; + this.contentsOpacity = 0; +}; + +Window_CTBIcon.prototype.iconWidth = function() { + return Yanfly.Param.CTBIconSize; +}; + +Window_CTBIcon.prototype.iconHeight = function() { + return Yanfly.Param.CTBIconSize; +}; + +Window_CTBIcon.prototype.setWindowLayer = function(windowLayer) { + this._windowLayer = windowLayer; +}; + +Window_CTBIcon.prototype.update = function() { + Window_Base.prototype.update.call(this); + this.updateBattler(); + this.updateIconIndex(); + this.updateRedraw(); + this.updateDestinationX(); + this.updateOpacity(); + this.updatePositionX(); + this.updatePositionY(); +}; + +Window_CTBIcon.prototype.updateBattler = function() { + var changed = this._battler !== this._mainSprite._battler; + if (this._battler && this._battler._ctbTransformed) changed = true; + if (!changed) return; + this._battler = this._mainSprite._battler; + if (!this._battler) return this.removeCTBIcon(); + this._battler._ctbTransformed = undefined; + this._iconIndex = this._battler.ctbIcon(); + if (this._iconIndex > 0) { + this._image = ImageManager.loadSystem('IconSet'); + } else if (this._battler.isEnemy()) { + if (this.isUsingSVBattler()) { + var name = this._battler.svBattlerName(); + this._image = ImageManager.loadSvActor(name); + } else { + var battlerName = this._battler.battlerName(); + var battlerHue = this._battler.battlerHue(); + if ($gameSystem.isSideView()) { + this._image = ImageManager.loadSvEnemy(battlerName, battlerHue); + } else { + this._image = ImageManager.loadEnemy(battlerName, battlerHue); + } + } + } else if (this._battler.isActor()) { + var faceName = this._battler.faceName(); + this._image = ImageManager.loadFace(faceName); + } + this._redraw = true; +}; + +Window_CTBIcon.prototype.removeCTBIcon = function() { + this.contents.clear(); + this.opacity = 0; + this.contentsOpacity =0; +}; + +Window_CTBIcon.prototype.isUsingSVBattler = function() { + if (!Imported.YEP_X_AnimatedSVEnemies) return false; + if (!this._battler.hasSVBattler()) return false; + return Yanfly.Param.CTBEnemySVBattler; +}; + +Window_CTBIcon.prototype.updateIconIndex = function() { + if (!this._battler) return; + var changed = this._iconIndex !== this._battler.ctbIcon(); + if (changed) { + this._iconIndex = this._battler.ctbIcon(); + this._redraw = true; + } +}; + +Window_CTBIcon.prototype.forceRedraw = function() { + this._redraw = true; +}; + +Window_CTBIcon.prototype.updateRedraw = function() { + if (!this._redraw) return; + if (!this._image) return; + if (this._image.width <= 0) return; + this._redraw = false; + this.contents.clear(); + this.drawBorder(); + if (this._iconIndex > 0) { + this.drawIcon(this._iconIndex, 4, 4); + } else if (this._battler.isActor()) { + this.redrawActorFace(); + } else if (this._battler.isEnemy()) { + this.redrawEnemy(); + } + this.redrawLetter(); +}; + +Window_CTBIcon.prototype.drawIcon = function(iconIndex, x, y) { + var bitmap = ImageManager.loadSystem('IconSet'); + var pw = Window_Base._iconWidth; + var ph = Window_Base._iconHeight; + var sx = iconIndex % 16 * pw; + var sy = Math.floor(iconIndex / 16) * ph; + var ww = this.iconWidth(); + var wh = this.iconHeight(); + this.contents.blt(bitmap, sx, sy, pw, ph, x, y, ww, wh); +}; + +Window_CTBIcon.prototype.drawBorder = function() { + var width = this.contents.width; + var height = this.contents.height; + this.contents.fillRect(0, 0, width, height, this.gaugeBackColor()); + width -= 2; + height -= 2; + this.contents.fillRect(1, 1, width, height, this.ctbBorderColor()); + width -= 4; + height -= 4; + this.contents.fillRect(3, 3, width, height, this.gaugeBackColor()); + width -= 2; + height -= 2; + this.contents.fillRect(4, 4, width, height, this.ctbBackgroundColor()); +}; + +Window_CTBIcon.prototype.ctbBorderColor = function() { + var colorId = this._battler.ctbBorderColor() || 0; + return this.textColor(colorId); +}; + +Window_CTBIcon.prototype.ctbBackgroundColor = function() { + var colorId = this._battler.ctbBackgroundColor() || 0; + return this.textColor(colorId); +}; + +Window_CTBIcon.prototype.redrawActorFace = function() { + var width = Window_Base._faceWidth; + var height = Window_Base._faceHeight; + var faceIndex = this._battler.faceIndex(); + var bitmap = this._image; + var pw = Window_Base._faceWidth; + var ph = Window_Base._faceHeight; + var sw = Math.min(width, pw); + var sh = Math.min(height, ph); + var dx = Math.floor(Math.max(width - pw, 0) / 2); + var dy = Math.floor(Math.max(height - ph, 0) / 2); + var sx = faceIndex % 4 * pw + (pw - sw) / 2; + var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2; + var dw = this.contents.width - 8; + var dh = this.contents.height - 8; + this.contents.blt(bitmap, sx, sy, sw, sh, dx + 4, dy + 4, dw, dh); +}; + +Window_CTBIcon.prototype.redrawEnemy = function() { + if (this.isUsingSVBattler()) { + return this.redrawSVEnemy(); + }; + var bitmap = this._image; + var sw = bitmap.width; + var sh = bitmap.height; + var dw = this.contents.width - 8; + var dh = this.contents.height - 8; + var dx = 0; + var dy = 0; + if (sw >= sh) { + var rate = sh / sw; + dh *= rate; + dy += this.contents.height - 8 - dh; + } else { + var rate = sw / sh; + dw *= rate; + dx += Math.floor((this.contents.width - 8 - dw) / 2); + } + this.contents.blt(bitmap, 0, 0, sw, sh, dx + 4, dy + 4, dw, dh); +}; + +Window_CTBIcon.prototype.redrawSVEnemy = function() { + var bitmap = this._image; + var sw = bitmap.width / 9; + var sh = bitmap.height / 6; + var dw = this.contents.width - 8; + var dh = this.contents.height - 8; + var dx = 0; + var dy = 0; + if (sw >= sh) { + var rate = sh / sw; + dh *= rate; + dy += this.contents.height - 8 - dh; + } else { + var rate = sw / sh; + dw *= rate; + dx += Math.floor((this.contents.width - 8 - dw) / 2); + } + this.contents.blt(bitmap, 0, 0, sw, sh, dx + 4, dy + 4, dw, dh); +}; + +Window_CTBIcon.prototype.redrawLetter = function() { + if (!this._battler.isEnemy()) return; + if (!this._battler._plural) return; + var letter = this._battler._letter; + var dy = this.contents.height - this.lineHeight(); + this.drawText(letter, 0, dy, this.contents.width - 4, 'right'); +}; + +Window_CTBIcon.prototype.destinationXConstant = function() { + return this.contents.width + 2; +}; + +Window_CTBIcon.prototype.updateDestinationX = function() { + if (!this._battler) return; + if (this._battler.isDead()) return; + if (this._position === 'left') this.updateDestinationLeftAlign(); + if (this._position === 'center') this.updateDestinationCenterAlign(); + if (this._position === 'right') this.updateDestinationRightAlign(); + if (this._direction === 'left') this.updateDestinationGoingLeft(); + if (this._direction === 'right') this.updateDestinationGoingRight(); +}; + +Window_CTBIcon.prototype.updateDestinationLeftAlign = function() { + this._destinationX = 0; +}; + +Window_CTBIcon.prototype.updateDestinationCenterAlign = function() { + this._destinationX = 0; + var width = this.standardPadding() * 2; + var size = BattleManager.ctbTurnOrder().length; + var constant = this.destinationXConstant(); + width += constant * size; + width += constant / 2 - 2; + this._destinationX = Math.floor((Graphics.boxWidth - width) / 2); +}; + +Window_CTBIcon.prototype.updateDestinationRightAlign = function() { + this._destinationX = Graphics.boxWidth; + this._destinationX -= this.standardPadding() * 2; + var size = BattleManager.ctbTurnOrder().length; + var constant = this.destinationXConstant(); + this._destinationX -= constant * size; + this._destinationX -= constant / 2; + this._destinationX += 2; +}; + +Window_CTBIcon.prototype.updateDestinationGoingLeft = function(index) { + var index = BattleManager.ctbTurnOrder().indexOf(this._battler); + if (index < 0) index = BattleManager.ctbTurnOrder().length + 5; + var constant = this.destinationXConstant(); + this._destinationX += index * constant; + if (index !== 0) { + this._destinationX += constant / 2; + } +}; + +Window_CTBIcon.prototype.updateDestinationGoingRight = function(index) { + var index = BattleManager.ctbTurnOrder().reverse().indexOf(this._battler); + if (index < 0) index = -5; + var constant = this.destinationXConstant(); + this._destinationX += index * constant; + if (index === BattleManager.ctbTurnOrder().length - 1) { + this._destinationX += constant / 2; + } +}; + +Window_CTBIcon.prototype.updatePositionX = function() { + if (this._destinationX === undefined) return; + if (BattleManager._escaped) return; + var desX = this._destinationX; + var moveAmount = Math.max(1, Math.abs(desX - this.x) / 4); + if (this.x > desX) this.x = Math.max(this.x - moveAmount, desX); + if (this.x < desX) this.x = Math.min(this.x + moveAmount, desX); +}; + +Window_CTBIcon.prototype.destinationY = function() { + var value = Yanfly.Param.CTBTurnPosY - this.standardPadding(); + var scene = SceneManager._scene; + if (scene && scene._helpWindow.visible) { + value = Math.max(value, scene._helpWindow.height); + } + if (!this._battler) return value; + if (this._battler.isSelected()) { + value -= this.contents.height / 4; + } + return value; +}; + +Window_CTBIcon.prototype.updatePositionY = function() { + if (BattleManager._escaped) return; + if (this._destinationX !== this.x) { + var desX = this._destinationX; + var cap1 = this.destinationY() - this.contents.height / 2; + var cap2 = this.destinationY() + this.contents.height / 2; + var moveAmount = Math.max(1, Math.abs(cap2 - this.y) / 4); + if (this.x > desX) this.y = Math.max(this.y - moveAmount, cap1); + if (this.x < desX) this.y = Math.min(this.y + moveAmount, cap2); + } else if (this.destinationY() !== this.y) { + var desY = this.destinationY(); + var moveAmount = Math.max(1, Math.abs(desY - this.y) / 4); + if (this.y > desY) this.y = Math.max(this.y - moveAmount, desY); + if (this.y < desY) this.y = Math.min(this.y + moveAmount, desY); + } +}; + +Window_CTBIcon.prototype.opacityFadeRate = function() { + return 8; +}; + +Window_CTBIcon.prototype.updateOpacity = function() { + var rate = this.opacityFadeRate(); + if (this._foreverHidden) return this.reduceOpacity(); + if (this.isReduceOpacity()) return this.reduceOpacity(); + if (BattleManager._victoryPhase) { + this._foreverHidden = true; + return this.reduceOpacity(); + } + if (BattleManager._escaped) { + this._foreverHidden = true; + return this.reduceOpacity(); + } + if (this._battler) { + var index = BattleManager.ctbTurnOrder().reverse().indexOf(this._battler); + if (index < 0) return this.reduceOpacity(); + } + this.contentsOpacity += rate; +}; + +Window_CTBIcon.prototype.isReduceOpacity = function() { + if (!this._lowerWindows) { + if (this.isLargeWindowShowing()) return true; + } + return this._windowLayer && this._windowLayer.x !== 0; +}; + +Window_CTBIcon.prototype.isLargeWindowShowing = function() { + if (SceneManager._scene._itemWindow.visible) return true; + if (SceneManager._scene._skillWindow.visible) return true; + return false; +}; + +Window_CTBIcon.prototype.reduceOpacity = function() { + this.contentsOpacity -= this.opacityFadeRate(); +}; + +//============================================================================= +// Scene_Battle +//============================================================================= + +Yanfly.CTB.Scene_Battle_isStartActorCommand = + Scene_Battle.prototype.isStartActorCommand; +Scene_Battle.prototype.isStartActorCommand = function() { + if (BattleManager.isCTB()) return true; + return Yanfly.CTB.Scene_Battle_isStartActorCommand.call(this); +}; + +Yanfly.CTB.Scene_Battle_commandFight = Scene_Battle.prototype.commandFight; +Scene_Battle.prototype.commandFight = function() { + if (BattleManager.isCTB()) { + this.startActorCommandSelection(); + BattleManager._phase = 'input'; + } else { + Yanfly.CTB.Scene_Battle_commandFight.call(this); + } +}; + +Yanfly.CTB.Scene_Battle_startActorCommandSelection = + Scene_Battle.prototype.startActorCommandSelection; +Scene_Battle.prototype.startActorCommandSelection = function() { + Yanfly.CTB.Scene_Battle_startActorCommandSelection.call(this); + if (BattleManager.isCTB()) { + BattleManager.actor().spriteStepForward(); + BattleManager.actor().setActionState('undecided'); + BattleManager.actor().requestMotionRefresh(); + BattleManager.actor().makeActions(); + } +}; + +Yanfly.CTB.Scene_Battle_updateWindowPositions = + Scene_Battle.prototype.updateWindowPositions; +Scene_Battle.prototype.updateWindowPositions = function() { + if (BattleManager.isCTB()) return this.updateWindowPositionsCTB(); + Yanfly.CTB.Scene_Battle_updateWindowPositions.call(this); +}; + +Scene_Battle.prototype.updateWindowPositionsCTB = function() { + if (this._ctbWindowPosCount === undefined) this._ctbWindowPosCount = 0; + if (this._partyCommandWindow.active) { + this._ctbWindowPosCount = 16; + var statusX = 0; + statusX = this._partyCommandWindow.width; + if (this._statusWindow.x < statusX) { + this._statusWindow.x += 16; + if (this._statusWindow.x > statusX) this._statusWindow.x = statusX; + } + if (this._statusWindow.x > statusX) { + this._statusWindow.x -= 16; + if (this._statusWindow.x < statusX) this._statusWindow.x = statusX; + } + } else if (this._actorCommandWindow.active) { + this._ctbWindowPosCount = 16; + Yanfly.CTB.Scene_Battle_updateWindowPositions.call(this); + } else { + if (--this._ctbWindowPosCount > 0) return; + Yanfly.CTB.Scene_Battle_updateWindowPositions.call(this); + } +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +//============================================================================= +// End of File +//============================================================================= +} else { // Yanfly.BEC.version + +var text = '================================================================\n'; +text += 'YEP_X_AnimatedSVEnemies requires YEP_BattleEngineCore to be at the '; +text += 'latest version to run properly.\n\nPlease go to www.yanfly.moe and '; +text += 'update to the latest version for the YEP_BattleEngineCore plugin.\n'; +text += '================================================================\n'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // Yanfly.BEC.version +}; // YEP_BattleEngineCore \ No newline at end of file diff --git a/js/plugins/YEP_X_BattleSysSTB.js b/js/plugins/YEP_X_BattleSysSTB.js new file mode 100644 index 0000000..16adb4b --- /dev/null +++ b/js/plugins/YEP_X_BattleSysSTB.js @@ -0,0 +1,728 @@ +//============================================================================= +// Yanfly Engine Plugins - Battle System - Standard Turn Battle +// YEP_X_BattleSysSTB.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_BattleSysSTB = true; + +var Yanfly = Yanfly || {}; +Yanfly.STB = Yanfly.STB || {}; +Yanfly.STB.version = 1.05; + +//============================================================================= + /*: + * @plugindesc v1.05 (Requires YEP_BattleEngineCore.js) Add STB (Standard + * Turn Battle) into your game using this plugin! + * @author Yanfly Engine Plugins + * + * @param ---General--- + * @default + * + * @param Action Speed + * @parent ---General--- + * @desc This is the formula used for an action's base speed. + * Default: agi + Math.randomInt(Math.floor(5 + agi / 4)) + * @default agi + * + * @param Delay Status Adjust + * @parent ---General--- + * @type boolean + * @on YES + * @off NO + * @desc Delay the time it takes for the Status Window to move towards + * the center. YES - true NO - false + * @default true + * + * @param ---Escape--- + * @default + * + * @param Escape Ratio + * @parent ---Escape--- + * @desc How STB calculates escape ratios. + * Default: 0.5 * $gameParty.agility() / $gameTroop.agility() + * @default 0.125 * $gameParty.agility() / $gameTroop.agility() + * + * @param Fail Escape Boost + * @parent ---Escape--- + * @desc Each time the player fails escape, increase the success + * rate by this much. Default: 0.1 + * @default 0.025 + * + * @param ---Turn Order--- + * @default + * + * @param Show Turn Window + * @parent ---Turn Order--- + * @type boolean + * @on Show + * @off Hide + * @desc Show the turn order window? + * YES - true NO - false + * @default false + * + * @param Turn Window X + * @parent ---Turn Order--- + * @desc The turn order window's x position. + * You can use a formula. + * @default Graphics.boxWidth - width + * + * @param Turn Window Y + * @parent ---Turn Order--- + * @desc The turn order window's y position. + * You can use a formula. + * @default this.fittingHeight(2) + * + * @param Turn Window Width + * @parent ---Turn Order--- + * @desc The turn order window's width. + * You can use a formula. + * @default 200 + * + * @param Turn Window Height + * @parent ---Turn Order--- + * @desc The turn order window's height. + * You can use a formula. + * @default Graphics.boxHeight - statusHeight - this.fittingHeight(2) + * + * @param Current Battler Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc The text color used for the current battler. + * @default 6 + * + * @param Actor Battler Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc The text color used for the actors. + * @default 4 + * + * @param Enemy Battler Color + * @parent ---Turn Order--- + * @type number + * @min 0 + * @max 31 + * @desc The text color used for the enemies. + * @default 2 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin requires YEP_BattleEngineCore. Make sure this plugin is located + * under YEP_BattleEngineCore in the plugin list. + * + * To use the STB system, go to the Battle Engine Core plugin and change the + * 'Default System' setting in the parameters to 'stb'. + * + * The Standard Turn Battle system functions off of the Default Turn Battle + * system's structure. Action orders are determined by the battlers' AGI values + * and they go from highest to lowest. However, actions are not selected at the + * start of the turn. Instead, the turn progresses and the actions are picked + * as each battler's turn appears, then proceeds to be executed immediately. + * + * Each battler is only allowed one action per battle turn, meaning a single + * battler cannot have twice the number of turns as another battler even if the + * battler's AGI value is double that of the other. This is to prevent any + * balancing issues that come from tick-based battle systems as they tend to be + * far more difficult to balance compared to turn-based battle systems. + * + * Because of the nature of the Standard Turn Battle System, an item or skill's + * action speed value found in the database will be disabled as it cannot push + * forward a battler's in the turn order. + * + * ============================================================================ + * Plugin Commands + * ============================================================================ + * + * To change your battle system to Standard Turn Battle if it isn't the default + * battle system, you can use the following Plugin Command: + * + * Plugin Command: + * setBattleSys STB Sets battle system to Standard Turn Battle. + * setBattleSys DTB Sets battle system to Default Turn Battle. + * + * Using the above Plugin Commands, you can toggle between the Default Battle + * System and Standard Turn Battle! + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * The following are notetags that pertain to and affect the STB system. + * + * Skill and Item Notetags: + * + * + * text + * text + * + * For those planning on using multiple battle systems, sometimes you may + * have your skills perform differently while using STB. If so, using this + * notetag will allow skills and items to display different help text while + * STB is enabled. + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.05: + * - Fixed Forced Action endless bug and added compatibility with Instant Cast. + * + * Version 1.04: + * - Bypass the isDevToolsOpen() error when bad code is inserted into a script + * call or custom Lunatic Mode code segment due to updating to MV 1.6.1. + * + * Version 1.03: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.02: + * - Instant Cast compatibility update. + * + * Version 1.01: + * - Fixed a bug that caused escaping to crash the game if not using STB. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +if (Imported.YEP_BattleEngineCore) { +if (Yanfly.BEC.version && Yanfly.BEC.version >= 1.42) { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_BattleSysSTB'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.Param.STBActionSpeed = String(Yanfly.Parameters['Action Speed']); +Yanfly.Param.STBDelayStatus = String(Yanfly.Parameters['Delay Status Adjust']); +Yanfly.Param.STBDelayStatus = eval(Yanfly.Param.STBDelayStatus); + +Yanfly.Param.STBEscapeRatio = String(Yanfly.Parameters['Escape Ratio']); +Yanfly.Param.STBEscapeBoost = String(Yanfly.Parameters['Fail Escape Boost']); + +Yanfly.Param.STBShowWindow = String(Yanfly.Parameters['Show Turn Window']); +Yanfly.Param.STBShowWindow = eval(Yanfly.Param.STBShowWindow); +Yanfly.Param.STBWindowX = String(Yanfly.Parameters['Turn Window X']); +Yanfly.Param.STBWindowY = String(Yanfly.Parameters['Turn Window Y']); +Yanfly.Param.STBWindowW = String(Yanfly.Parameters['Turn Window Width']); +Yanfly.Param.STBWindowH = String(Yanfly.Parameters['Turn Window Height']); +Yanfly.Param.STBWinSubject = Number(Yanfly.Parameters['Current Battler Color']); +Yanfly.Param.STBWinActor = Number(Yanfly.Parameters['Actor Battler Color']); +Yanfly.Param.STBWinEnemy = Number(Yanfly.Parameters['Enemy Battler Color']); + +//============================================================================= +// DataManager +//============================================================================= + +Yanfly.STB.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; +DataManager.isDatabaseLoaded = function() { + if (!Yanfly.STB.DataManager_isDatabaseLoaded.call(this)) return false; + + if (!Yanfly._loaded_YEP_X_BattleSysSTB) { + this.processSTBNotetags1($dataSkills); + this.processSTBNotetags1($dataItems); + Yanfly._loaded_YEP_X_BattleSysSTB = true; + } + + return true; +}; + +DataManager.processSTBNotetags1 = function(group) { + for (var n = 1; n < group.length; n++) { + var obj = group[n]; + var notedata = obj.note.split(/[\r\n]+/); + + var evalMode = 'none'; + obj.stbHelp = undefined; + + for (var i = 0; i < notedata.length; i++) { + var line = notedata[i]; + if (line.match(/<(?:STB HELP)>/i)) { + evalMode = 'stb help'; + obj.stbHelp = ''; + } else if (line.match(/<\/(?:STB HELP)>/i)) { + evalMode = 'none'; + } else if (evalMode === 'stb help') { + obj.stbHelp += line + '\n'; + } + } + } +}; + +//============================================================================= +// BattleManager +//============================================================================= + +BattleManager.isSTB = function() { + return this.isBattleSystem('stb'); +}; + +Yanfly.STB.BattleManager_isTurnBased = BattleManager.isTurnBased; +BattleManager.isTurnBased = function() { + if (this.isSTB()) return true; + return Yanfly.STB.BattleManager_isTurnBased.call(this); +}; + +Yanfly.STB.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio; +BattleManager.makeEscapeRatio = function() { + if (this.isSTB()) { + var code = Yanfly.Param.STBEscapeRatio; + try { + this._escapeRatio = eval(code); + } catch (e) { + this._escapeRatio = 0; + Yanfly.Util.displayError(e, code, 'STB ESCAPE RATIO ERROR'); + } + var code = Yanfly.Param.STBEscapeBoost; + try { + this._escapeFailBoost = eval(code); + } catch (e) { + this._escapeFailBoost = 0; + Yanfly.Util.displayError(e, code, 'STB ESCAPE BOOST ERROR'); + } + } else { + this._escapeFailBoost = 0.1; + Yanfly.STB.BattleManager_makeEscapeRatio.call(this); + } +}; + +Yanfly.STB.BattleManager_startInput = BattleManager.startInput; +BattleManager.startInput = function() { + Yanfly.STB.BattleManager_startInput.call(this); + if (this.isSTB() && this._phase !== 'turn') this.startTurn(); +}; + +Yanfly.STB.BattleManager_startTurn = BattleManager.startTurn; +BattleManager.startTurn = function() { + if (this._stbFailedEscape) { + this.stbFailedEscape(); + } else { + Yanfly.STB.BattleManager_startTurn.call(this); + } +}; + +BattleManager.stbFailedEscape = function() { + this._stbFailedEscape = false; + $gameParty.requestMotionRefresh(); +}; + +Yanfly.STB.BattleManager_processTurn = BattleManager.processTurn; +BattleManager.processTurn = function() { + var subject = this._subject; + SceneManager._scene.refreshSTBTurnOrderWindow(); + if (this.isSTB() && subject.isActor()) { + this.startSTBInput(); + } else { + Yanfly.STB.BattleManager_processTurn.call(this); + } +}; + +BattleManager.startSTBInput = function() { + this._phase = 'input'; + var battler = this._subject; + BattleManager.changeActor(battler.index(), 'undecided'); + if (!battler.canInput()) { + battler.makeActions(); + this.startAction(); + } +}; + +Yanfly.STB.BattleManager_selectPreviousCommand = + BattleManager.selectPreviousCommand; +BattleManager.selectPreviousCommand = function() { + if (this.isSTB()) { + this._activeSTBActor = this._actorIndex; + this._subject = null; + this.changeActor(-1, 'undecided'); + } else { + Yanfly.STB.BattleManager_selectPreviousCommand.call(this); + } +}; + +Yanfly.STB.BattleManager_displayEscapeFailureMessage = + BattleManager.displayEscapeFailureMessage; +BattleManager.displayEscapeFailureMessage = function() { + Yanfly.STB.BattleManager_displayEscapeFailureMessage.call(this); + if (this.isSTB()) { + this.endAction(); + this._stbFailedEscape = true; + } +}; + +BattleManager.stbSetSubject = function() { + BattleManager.changeActor(this._activeSTBActor, 'undecided'); + this._subject = this.actor(); +}; + +Yanfly.STB.BattleManager_selectNextCommand = BattleManager.selectNextCommand; +BattleManager.selectNextCommand = function() { + if (this.isSTB()) { + if (this._subject) { + this.startAction(); + } else { + this.stbSetSubject(); + this.startSTBInput(); + } + } else { + Yanfly.STB.BattleManager_selectNextCommand.call(this); + } +}; + +Yanfly.STB.BattleManager_startAction = BattleManager.startAction; +BattleManager.startAction = function() { + if (Imported.YEP_InstantCast) this.detectStbInstantCast(); + Yanfly.STB.BattleManager_startAction.call(this); +}; + +Yanfly.STB.BattleManager_endAction = BattleManager.endAction; +BattleManager.endAction = function() { + if (this.isSTB()) { + this.endSTBAction(); + } else { + Yanfly.STB.BattleManager_endAction.call(this); + } +}; + +BattleManager.endSTBAction = function() { + this._phase = 'turn'; + if (this._stbInstantCast) { + this._stbInstantCast = false; + return Yanfly.BEC.BattleManager_endAction.call(this); + } + if (this._subject) { + this._performedBattlers.push(this._subject); + this._subject.spriteStepBack(); + this._subject.onAllActionsEnd(); + this._subject.removeCurrentAction(); + } + if (this._processingForcedAction) { + this._phase = this._preForcePhase; + this._processingForcedAction = false; + } + if (this.loadPreForceActionSettings()) return; + this._subject = null; + Yanfly.BEC.BattleManager_endAction.call(this); +}; + +BattleManager.detectStbInstantCast = function() { + this._stbInstantCast = false; + if (!this.isSTB()) return; + if (!this._subject) return; + if (!this._subject.currentAction()) return; + if (!this._subject.currentAction().item()) return; + var item = this._subject.currentAction().item(); + this._stbInstantCast = this._subject.isInstantCast(item); +}; + +//============================================================================= +// Game_Action +//============================================================================= + +Yanfly.STB.Game_Action_speed = Game_Action.prototype.speed; +Game_Action.prototype.speed = function() { + if (BattleManager.isSTB()) { + var user = this.subject(); var a = user; + var maxhp = user.mhp; var mhp = user.mhp; var hp = user.hp; + var maxmp = user.mmp; var mmp = user.mmp; var mp = user.mp; + var maxtp = user.maxTp(); var mtp = user.maxTp(); var tp = user.tp; + var atk = user.atk; var def = user.def; var mat = user.mat; + var int = user.mat; var mdf = user.mdf; var res = user.res; + var agi = user.agi; var luk = user.luk; + var code = Yanfly.Param.STBActionSpeed; + try { + var speed = eval(code); + } catch (e) { + var speed = agi; + Yanfly.Util.displayError(e, code, 'STB ACTION SPEED FORMULA ERROR'); + } + return speed; + } else { + return Yanfly.STB.Game_Action_speed.call(this); + } +}; + +//============================================================================= +// Scene_Battle +//============================================================================= + +Yanfly.STB.Scene_Battle_createHelpWindow = + Scene_Battle.prototype.createHelpWindow; +Scene_Battle.prototype.createHelpWindow = function() { + if (BattleManager.isSTB()) this.createSTBTurnOrderWindow(); + Yanfly.STB.Scene_Battle_createHelpWindow.call(this); +}; + +Scene_Battle.prototype.createSTBTurnOrderWindow = function() { + if (!Yanfly.Param.STBShowWindow) return; + var statusWindow = this._statusWindow; + this._stbTurnOrderWindow = new Window_STB_TurnOrder(statusWindow); + this.addWindow(this._stbTurnOrderWindow); +}; + +Scene_Battle.prototype.refreshSTBTurnOrderWindow = function() { + if (!this._stbTurnOrderWindow) return; + this._stbTurnOrderWindow.refresh(); +}; + +Yanfly.STB.Scene_Battle_commandFight = Scene_Battle.prototype.commandFight; +Scene_Battle.prototype.commandFight = function() { + if (BattleManager.isSTB()) { + BattleManager.stbSetSubject(); + BattleManager.startSTBInput(); + } else { + Yanfly.STB.Scene_Battle_commandFight.call(this); + } +}; + +Yanfly.STB.Scene_Battle_commandEscape = Scene_Battle.prototype.commandEscape; +Scene_Battle.prototype.commandEscape = function() { + if (BattleManager.isSTB()) { + BattleManager.processEscape(); + } else { + Yanfly.STB.Scene_Battle_commandEscape.call(this); + } +}; + +if (Yanfly.Param.STBDelayStatus) { + +Yanfly.STB.Scene_Battle_updateWindowPositions = + Scene_Battle.prototype.updateWindowPositions; +Scene_Battle.prototype.updateWindowPositions = function() { + if (BattleManager.isSTB()) return this.updateWindowPositionsSTB(); + Yanfly.STB.Scene_Battle_updateWindowPositions.call(this); +}; + +Scene_Battle.prototype.updateWindowPositionsSTB = function() { + if (this._STBWindowPosCount === undefined) this._STBWindowPosCount = 0; + if (this._partyCommandWindow.active) { + this._STBWindowPosCount = 16; + var statusX = 0; + statusX = this._partyCommandWindow.width; + if (this._statusWindow.x < statusX) { + this._statusWindow.x += 16; + if (this._statusWindow.x > statusX) this._statusWindow.x = statusX; + } + if (this._statusWindow.x > statusX) { + this._statusWindow.x -= 16; + if (this._statusWindow.x < statusX) this._statusWindow.x = statusX; + } + } else if (this._actorCommandWindow.active) { + this._STBWindowPosCount = 16; + Yanfly.STB.Scene_Battle_updateWindowPositions.call(this); + } else { + if (--this._STBWindowPosCount > 0) return; + Yanfly.STB.Scene_Battle_updateWindowPositions.call(this); + } +}; + +}; // Yanfly.Param.STBDelayStatus + +//============================================================================= +// Window_Help +//============================================================================= + +Yanfly.STB.Window_Help_setItem = Window_Help.prototype.setItem; +Window_Help.prototype.setItem = function(item) { + if (this.meetSTBConditions(item)) return this.setText(item.stbHelp); + Yanfly.STB.Window_Help_setItem.call(this, item); +}; + +Window_Help.prototype.meetSTBConditions = function(item) { + if (!item) return false; + if (!BattleManager.isSTB()) return false; + return item.stbHelp !== undefined; +}; + +//============================================================================= +// Window_STB_TurnOrder +//============================================================================= + +function Window_STB_TurnOrder() { + this.initialize.apply(this, arguments); +} + +Window_STB_TurnOrder.prototype = Object.create(Window_Base.prototype); +Window_STB_TurnOrder.prototype.constructor = Window_STB_TurnOrder; + +Window_STB_TurnOrder.prototype.initialize = function(statusWindow) { + if (statusWindow) { + var statusHeight = statusWindow.height; + } else { + statusHeight = this.fittingHeight(4); + } + var code = Yanfly.Param.STBWindowW; + try { + var width = eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'STB TURN ORDER WINDOW WIDTH ERROR'); + var width = 200; + } + var code = Yanfly.Param.STBWindowH; + try { + var height = eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'STB TURN ORDER WINDOW HEIGHT ERROR'); + var height = Graphics.boxHeight - statusHeight - this.fittingHeight(2); + } + var code = Yanfly.Param.STBWindowX; + try { + var x = eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'STB TURN ORDER WINDOW X ERROR'); + var x = Graphics.boxWidth - width; + } + var code = Yanfly.Param.STBWindowY; + try { + var y = eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'STB TURN ORDER WINDOW Y ERROR'); + var y = this.fittingHeight(2); + } + Window_Base.prototype.initialize.call(this, x, y, width, height); + this.opacity = 0; + this.refresh(); +}; + +Window_STB_TurnOrder.prototype.refresh = function() { + this.getTurnOrderData(); + this.drawTurnOrders(); +}; + +Window_STB_TurnOrder.prototype.getTurnOrderData = function() { + if (!BattleManager._actionBattlers) return; + if (!BattleManager._performedBattlers) return; + var array = BattleManager._actionBattlers; + this._actionBattlers = array.filter(Yanfly.Util.onlyUnique); + array = BattleManager._performedBattlers; + this._performedBattlers = array.filter(Yanfly.Util.onlyUnique); +}; + +Window_STB_TurnOrder.prototype.drawTurnOrders = function() { + if (!this._actionBattlers) return; + if (!this._performedBattlers) return; + this.contents.clear(); + var dy = 0; + dy = this.drawPerformedActors(dy); + dy = this.drawSubject(dy); + dy = this.drawActionActors(dy); +}; + +Window_STB_TurnOrder.prototype.drawPerformedActors = function(dy) { + var dx = this.textPadding(); + var dw = this.contents.width - this.textPadding() * 2; + this.resetFontSettings(); + this.changePaintOpacity(false); + var array = this._performedBattlers; + var length = array.length; + for (var i = 0; i < length; ++i) { + var battler = array[i]; + if (!battler) continue; + if (battler.isDead()) continue; + if (battler === BattleManager._subject) continue; + if (battler.isActor()) { + this.changeTextColor(this.textColor(Yanfly.Param.STBWinActor)); + } else { + this.changeTextColor(this.textColor(Yanfly.Param.STBWinEnemy)); + } + var text = this.getBattlerName(battler); + this.drawText(text, dx, dy, dw); + dy += this.lineHeight(); + } + return dy; +}; + +Window_STB_TurnOrder.prototype.drawSubject = function(dy) { + if (!BattleManager._subject) return dy; + if (BattleManager._subject.isDead()) return dy; + var dx = this.textPadding(); + var dw = this.contents.width - this.textPadding() * 2; + this.resetFontSettings(); + this.changePaintOpacity(true); + this.changeTextColor(this.textColor(Yanfly.Param.STBWinSubject)); + var battler = BattleManager._subject; + var text = this.getBattlerName(battler); + this.drawText(text, dx, dy, dw); + dy += this.lineHeight(); + return dy; +}; + +Window_STB_TurnOrder.prototype.drawActionActors = function(dy) { + var dx = this.textPadding(); + var dw = this.contents.width - this.textPadding() * 2; + this.resetFontSettings(); + this.changePaintOpacity(true); + var array = this._actionBattlers; + var length = array.length; + for (var i = 0; i < length; ++i) { + var battler = array[i]; + if (!battler) continue; + if (battler.isDead()) continue; + if (battler === BattleManager._subject) continue; + if (this._performedBattlers.contains(battler)) continue; + if (battler.isActor()) { + this.changeTextColor(this.textColor(Yanfly.Param.STBWinActor)); + } else { + this.changeTextColor(this.textColor(Yanfly.Param.STBWinEnemy)); + } + var text = this.getBattlerName(battler); + this.drawText(text, dx, dy, dw); + dy += this.lineHeight(); + } + return dy; +}; + +Window_STB_TurnOrder.prototype.getBattlerName = function(battler) { + if (Imported.YEP_EnemyLevels && battler.isEnemy()) { + var text = Yanfly.ELV.Game_Enemy_name.call(battler); + } else { + var text = battler.name(); + } + return text; +}; + +//============================================================================= +// Utilities +//============================================================================= + +Yanfly.Util = Yanfly.Util || {}; + +Yanfly.Util.displayError = function(e, code, message) { + console.log(message); + console.log(code || 'NON-EXISTENT'); + console.error(e); + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return; + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + if (!require('nw.gui').Window.get().isDevToolsOpen()) { + require('nw.gui').Window.get().showDevTools(); + } + } +}; + +Yanfly.Util.onlyUnique = function(value, index, self) { + return self.indexOf(value) === index; +}; + +//============================================================================= +// End of File +//============================================================================= +} else { // Yanfly.BEC.version + +var text = '================================================================\n'; +text += 'YEP_X_BattleSysSTB requires YEP_BattleEngineCore to be at the '; +text += 'latest version to run properly.\n\nPlease go to www.yanfly.moe and '; +text += 'update to the latest version for the YEP_BattleEngineCore plugin.\n'; +text += '================================================================\n'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // Yanfly.BEC.version +}; // YEP_BattleEngineCore \ No newline at end of file diff --git a/js/plugins/YEP_X_CoreUpdatesOpt.js b/js/plugins/YEP_X_CoreUpdatesOpt.js new file mode 100644 index 0000000..8127e99 --- /dev/null +++ b/js/plugins/YEP_X_CoreUpdatesOpt.js @@ -0,0 +1,8338 @@ +//============================================================================= +// Yanfly Engine Plugins - Core Extension - Updates and Desktop Optimization +// YEP_X_CoreUpdatesOpt.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_CoreUpdatesOpt = true; + +var Yanfly = Yanfly || {}; +Yanfly.Updates = Yanfly.Updates || {}; +Yanfly.Updates.version = 1.62; + +//============================================================================= + /*: + * @plugindesc v1.62 (Req YEP_CoreEngine.js) Update your game without needing + * to change your base rpg_x.js files and optimize it for desktop. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin requires the following: + * - YEP_CoreEngine plugin installed + * - Installing this plugin under YEP_CoreEngine + * - RPG Maker MV version base code 1.4.0 or above + * - Follow the instructions listed in the Help File's "Instructions" section + * + * Does your game project have at least base code (rpg_x.js) 1.4.0 or above? + * And has RPG Maker MV updated past that, but you don't feel like updating the + * base code manually, probably because you've made some edits to the code + * itself? Yet, you still want to take advantage of the changes from the + * version ups? This plugin will take care of that for you while keeping your + * base code intact, while 'patching' the changes made from higher version ups. + * + * This plugin also adds in the updates and new functions from the versions + * leading up to 1.5.2 to ensure that your project has the most up to date + * functions even if it is running 1.4.0. This way, you do not have to tamper + * with the game project's base code files yourself. + * + * Note: you will still have to download the newest Pixi libraries and to get + * things working properly with this plugin. More will be explained in this + * plugin's instructions section under the help file. + * + * ============================================================================ + * Instructions + * ============================================================================ + * + * If you have an old project that needs updating, do the following: + * + * 1. Make a backup of your project. + * 2. Create a new project or go to the "NewData" folder in your RPG Maker MV + * root folder (where RPG Maker MV is installed). + * 3. Copy the "libs" folder under "js" and replace the one in your old project. + * 4. Copy the new index.html file to your current project. + * 5. Update gamefont.css just in case. + * 6. Make sure you have the latest version of YEP_CoreEngine.js installed. + * 7. Install YEP_X_CoreUpdatesOpt.js (this plugin) under YEP_CoreEngine in the + * game project's Plugin Manager list. + * 8. Run your game! + * + * ============================================================================ + * Desktop Optimization Option + * ============================================================================ + * + * This plugin also includes Yanfly's Desktop Optimization base code changes + * for those who wish to optimize their projects as primarily desktop-only + * games. The reason behind such an option is that since the 1.5.0 update, RPG + * Maker MV has added a lot of wonderful new features to the editor as a whole. + * However, the base code has been updated such a way that RPG Maker MV games + * favor mobile game optimization over desktop games. Because of this, RPG + * Maker MV games running off 1.5.0 and up have strange issues when images are + * loading unlike versions 1.4.0 and below. + * + * This feature serves as a hybrid between the latest versions of RPG Maker MV + * by utilizing the 1.4.0 source code that was better suited for desktop + * optimization. This way, for developers who aim primarily at the development + * of games for desktop, your games will be running as they did with the 1.4.0 + * base code while being able to make full use of the most recent updated RPG + * Maker MV version's features! + * + * ============================================================================ + * RPG Maker MV 1.1.0 Changelog + * ============================================================================ + * + * rpg_core.js + * Sprite.prototype.updateTransform – no longer needs rounding down. + * Tilemap.prototype.update – animation frame removed + * Tilemap.prototype.refresh – repaint flag removed + * Tilemap.prototype.updateTransform – removed a lot of animation checks + * Tilemap.prototype._paintTiles – animation frame check moved to here + * Tilemap.prototype._drawAutotile – fixed error with variable names + * + * rpg_managers.js + * + * DataManager.saveGame – no longer corrupts save file while saving during a + * parallel process + * StorageManager.backup – new function added + * StorageManager.backupExists – new function added + * StorageManager.cleanBackup – new function added + * StorageManager.restoreBackup – new function added + * StorageManager.loadFromLocalBackupFile – new function added + * StorageManager.loadFromWebStorageBackup – new function added + * StorageManager.webStorageBackupExists – new function added + * SceneManager – added FPS synch + * SceneManager.updateMain – added in FPS synch + * BattleManager.processEscape – removed battle state removal process from + * wrong spot + * BattleManager.processAbort – inserted battle state removal process to + * correct timing + * + * rpg_objects.js + * Game_Action.prototype.decideRandomTarget – random target index bug fixed + * Game_Action.prototype.evaluate – target index bug fixed + * Game_Action.prototype.evalDamageFormula – if formulas are used that return + * NaN, return 0 instead + * Game_Actor.prototype.changeClass – exp bug fixed + * Game_Event.prototype.updateSelfMovement – added extra check to see if the + * event is not locked + * Game_Interpreter.prototype.command321 – class change command now has the + * option to keep exp across changing classes + * + * rpg_scenes.js + * Scene_Save.prototype.onSaveSuccess – backup process functionality added + * + * rpg_sprites.js + * Sprite_Actor.prototype.refreshMotion – added a fix for guard motion + * Spriteset_Map.prototype._canvasReAddParallax – new function added + * Spriteset_Map.prototype.updateParallax – implemented fix for parallax bug + * + * rpg_windows.js + * Window_MenuStatus.prototype.drawItemImage – fixed bug involving variable + * face dimensions + * Window_ActorCommand.prototype.selectLast – fixed bug with saved last + * selected command + * + * ============================================================================ + * RPG Maker MV 1.2.0 Changelog + * ============================================================================ + * + * rpg_core.js + * TilingSprite.prototype.generateTilingTexture added. + * + * rpg_objects.js + * Game_Picture.prototype.updateRotation updated. This is to accomodate for the + * set rotation value. + * + * rpg_sprites.js + * Sprite_Animation.prototype.updateCellSprite updated. The sprite will always + * be visible if the pattern exists. + * + * ============================================================================ + * RPG Maker MV 1.3.0 Changelog + * ============================================================================ + * + * rpg_core.js + * Arrays get a new function: equals + * CacheEntry new class + * Bitmap gets many lines updated from Pixi2 to Pixi4 + * Bitmap.initialize + * Bitmap.load + * Bitmap.snap + * Bitmap.onLoad + * Bitmap._setDirty + * Bitmap.touch, Bitmap.bltImage new functions + * Graphics gets line updated from Pixi2 to Pixi4 + * Graphics.isWebGL + * Graphics gets new function: callGC + * Sprite gets many lines updated from Pixi2 to Pixi4 + * Sprite.constructor + * Sprite._refresh + * Sprite._renderCanvas + * Sprite._renderWebGL + * Sprite gets a new function: _speedUpCustomBlendModes + * Tilemap gets many lines updated from Pixi2 to Pixi4 + * Tilemap.initialize + * Tilemap.update + * Tilemap.refresh + * Tilemap.updateTransform + * Tilemap._paintTiles + * Tilemap._drawNormalTile + * Tilemap._drawAutotile + * Tilemap.isWallSideTile + * ShaderTilemap new class + * TilingSprite gets many lines updated from Pixi2 to Pixi4 + * TilingSprite.initialize + * TilingSprite.updateTransform + * TilingSprite._refresh + * TilingSprite._renderCanvas, TilingSprite._renderWebGL new functions + * ScreenSprite gets many lines updated from Pixi2 to Pixi4 + * ScreenSprite.initialize + * ScreenSprite._renderCanvas + * Window gets many lines updated from Pixi2 to Pixi4 + * Window.initialize + * Window.updateTransform + * Window._createAllParts + * WindowLayer gets many lines updated from Pixi2 to Pixi4 + * WindowLayer.initialize + * WindowLayer._renderCanvas + * WindowLayer._renderWebGL + * WindowLayer._webglMaskWindow + * Weather gets line updated from Pixi2 to Pixi4 + * Weather.initialize + * ToneFilter gets many lines updated from Pixi2 to Pixi4 + * ToneFilter.initialize removed + * ToneFilter.reset removed + * ToneFilter.adjustHue + * ToneFilter.adjustSaturation + * ToneFilter.adjustTone + * ToneSprite gets many lines updated from Pixi2 to Pixi4 + * ToneSprite.initialize + * ToneSprite._renderCanvas + * ToneSprite._renderWebGL + * Stage gets line updated from Pixi2 to Pixi4 + * Stage.initialize + * WebAudio gets functions updated to work with the new Decrypter + * WebAudio._load + * WebAudio._onXhrLoad + * Html5Audio gets function updated to work with the new Decrypter + * Html5Audio.setup + * Decrypter new class + * + * rpg_managers.js + * DataManager.onLoad gets update check for Decrypter added + * ImageManager._cache no longer exists. ImageManager.cache now takes its place + * as a new CacheMap + * ImageManager.loadEmptyBitmap, ImageManager.loadNormalBitmap, + * ImageManager.clear, ImageManager.isReady are now all updated from _cache to + * cache + * AudioManager gains AudioManager._blobUrl + * AudioManager.playBgm gets update check for Decrypter + * AudioManager.playEncryptedBgm, AudioManager.createDecryptBuffer new functions + * AudioManager.createBuffer updated to utilize _blobUrl + * AudioManager.shouldUseHtml5Audio updated for Decrypter + * SceneManager.update gets updated for a MobileSafari check + * SceneManager.updateMain gets updated to function differently if using + * MobileSafari + * SceneManager.updateManagers new function + * + * rpg_objects.js + * Game_Picture.updateRotation now accepts negative speed + * Game_BattlerBase.tpRate now utilizes Game_BattlerBase.maxTp function + * + * rpg_scenes.js + * Scene_Boot.create now loads the window image separately + * Scene_Boot.loadSystemWindowImage new function + * Scene_Boot.loadSystemImages no longer loads the window image + * + * rpg_sprites.js + * Sprite_Animation.initialize gets new _reduceArtifacts variable + * Sprite_Animation.updateCellSprite gets an update where the pattern sprite is + * now always visible if the pattern is at least 0 + * Sprite_Picture.initialize gets new _isPicture variable + * Spriteset_Map.createTilemap is updated to check if WebGL is being used. If it + * is, the tilemap will be a ShaderTilemap instead of a regular Tilemap + * Spriteset_Map.loadTileset is updated to refresh tilemap flags when loading a + * new one + * + * ============================================================================ + * RPG Maker MV 1.3.1 Changelog + * ============================================================================ + * + * rpg_core.js + * CacheEntry.free function fixed + * Tilemap’s TileRenderer mode will automatically default to Nearest Neighbor + * ScreenSprite updates + * New properties added: anchor and blendMode + * ScreenSprite.initialize + * ScreenSprite.setColor + * WebAudio.onXhrLoad function fixed + * + * ============================================================================ + * RPG Maker MV 1.3.2 Changelog + * ============================================================================ + * + * rpg_core.js + * Added waitForLoading and register variables. + * Graphics.playVideo function updated to add a Mobile Safari check for video + * playing. + * Graphics.isVideoPlaying function updated to add a Mobile Safari check for + * video playing. + * Graphics._onVideoLoad function updated to add a Mobile Safari check for + * video playing. + * Graphics._onVideoEnd function updated to add a Mobile Safari check for video + * playing. + * Input._updateGamepadState function updated to provide Direct Input + * Controller support. + * Sprite.prototype.initialize function updated to no longer have an offset + * variable. It is now replaced by the pivot. + * Sprite.prototype._refresh updated offset variable to work with pivot and + * texture update ID. + * Sprite.prototype.updateTransform function removed. + * TilingSprite is now a different object type (PictureTilingSprite). + * TilingSprite.prototype.initialize function updated to call + * PictureTilingSprite instead. + * TilingSprite.prototype._renderCanvas_PIXI and TilingSprite._renderWebGL_PIXI + * updated to work with PictureTilingSprite instead. + * TilingSprite.prototype._refresh function updated to work with + * PictureTilingSprite and texture update ID. + * TilingSprite.prototype._speedUpCustomBlendModes new. + * TilingSprite.prototype._renderWebGL new function. + * WindowLayer.prototype.initialize function updated to fix memory leak. + * WindowLayer.prototype.onRemoveAsAChild new function. + * WindowLayer.prototype.renderWebGL updated to work with PIXI.Point shift. + * WindowLayer.prototype._maskWindow function updated to require shift. + * + * rpg_managers.js + * SceneManager.onKeyDown function updated to have a warning message for + * Japanese game systems: Reloading the game with a gamepad connected will + * cause a disconnect. + * BattleManager.invokeCounterAttack function updated to display the target as + * the counter target instead of the subject. + * BattleManager.invokeMagicReflection function updated to register the + * reflection target and display the target as the reflect target instead of the + * subject. + * + * rpg_objects.js + * Game_Action.prototype.gainDrainedHp function updated to work with reflected + * targets. + * Game_Action.prototype.gainDrainedMp function updated to work with reflected + * targets. + * Game_Actor.prototype.isLearnedSkill function updated to now include skills + * added through traits. + * Game_Interpreter.prototype.command337 (Show Battle Animation) now updated to + * work with new Editor update. + * + * rpg_scenes.js + * Scene_Map.prototype.terminate updated to fix memory leak bug. + * + * ============================================================================ + * RPG Maker MV 1.3.3 Changelog + * ============================================================================ + * + * Strictly an editor update. + * + * ============================================================================ + * RPG Maker MV 1.3.4 Changelog + * ============================================================================ + * + * rpg_core.js + * Bitmap.snap now destroys the previously saved snapshot + * TilingSprite.prototype.updateTransform gets comments removed + * WindowLayer.prototype.renderWebG now rounds up the shifted window coordinates + * + * rpg_managers.js + * SceneManager.onKeyDown gets that terrible popup removed when pressing F5 + * BattleManager.updateEvent now uses BattleManager.checkAbort2 function + * BattleManager.checkAbort2 is a new function used to play an extra sound + * effect, mark the battle as escaped + * BattleManager.updateBattleEnd now checks if the battle is aborted if the + * party is all dead and not escaped + * + * rpg_objects.js + * Game_Actor.prototype.isLearnedSkill reverted back to its 1.0.0 to 1.3.1 + * version + * Game_Actor.prototype.hasSkill now checks if the skill exists, whether it is + * inherently or gained through a temporary trait + * Game_Actor.prototype.testEscape new function that checks if an action (item + * or skill) has the escape effect + * Game_Actor.prototype.meetsUsableItemConditions now checks specifically for + * actor usage and to check if the item has an escape effect + * Game_Interpreter.prototype.command111 (Conditional Branch) updated to make + * use of the new Game_Actor.hasSkill function + * + * ============================================================================ + * RPG Maker MV 1.4.0 Changelog + * ============================================================================ + * + * rpg_core.js + * TouchInput.isMousePressed function removed + * + * rpg_objects.js + * Game_Temp.prototype.initialize function removes map touch boolean + * Game_Temp.prototype.isMapTouched function removed + * Game_Temp.prototype.setIsMapTouched function removed + * Game_Actor.prototype.meetsUsableItemConditions altered to return a reference + * to Game_BattlerBase.prototype.meetsUsableItemConditions for checking + * Game_Player.prototype.updateDashing now checks if the dash button is pressed + * instead of if the game map is being touched + * + * rpg_scenes.js + * Scene_Map.prototype.processMapTouch updated to reflect the removal of the + * map touch functions + * + * ============================================================================ + * RPG Maker MV 1.5.0 Changelog + * ============================================================================ + * + * rpg_core.js + * Utils.isSupportPassiveEvent new function added + * ImageCache added and respective functions + * iOS memory function updates for reusing images + * Bitmap.prototype.initialize split into new functions for iOS memory function + * update + * Bitmap.load split into new functions for iOS memory function update + * Bitmap.prototype.isReady and Bitmap.prototype.isError now has extra checks + * Bitmap properties updated for Pixi4.4 + * Bitmap.prototype.addLoadListener updated as per updated ready functions + * Bitmap.prototype.addLoadListener updated as per updated listener functions + * Bitmap.request new function added + * Graphics.initialize updated with new variables added + * Graphics._setupCssFontLoading new function added + * Graphics.render updated + * Graphics.printLoadingError new function added + * Graphics.isFontLoaded updated + * Graphics.playVideo updated + * Graphics._createVideo updated + * Graphics._createRenderer updated + * Graphics._onVideoLoad updated + * Graphics._onVideoError updated + * Graphics._setupEventHandlers updated with new listener functions + * Input._onKeyDown updated + * TouchInput._setupEventHandlers updated + * Sprite.prototype.setFrame updated + * Sprite.prototype._onBitmapLoad updated + * Sprite.prototype._renderCanvas updated + * Sprite.prototype._renderWebGL updated + * ShaderTilemap.prototype._hackRenderer updated + * WindowLayer.prototype.renderWebGL updated + * WindowLayer.prototype._maskWindow updated + * WebAudio._standAlone new function added + * WebAudio._createMasterGainNode updated + * WebAudio._fadeIn updated + * WebAudio._fadeOut updated + * WebAudio.prototype.fadeOut updated + * WebAudio.prototype._load updated + * WebAudio.prototype._createNodes updated + * JsonEx.stringify updated + * JsonEx.parse updated + * JsonEx._encode updated + * JsonEx._decode updated + * Decrypter.decryptImg updated + * ResourceHandler new class + * + * rpg_managers.js + * DataManager.loadDataFile updated + * DataManager.loadMapData updated + * DataManager.loadSavefileImage updated with function rename + * ImageManager._imageCache, ImageManager._requestQueue, + * ImageManager._systemReservationId, ImageManager._generateCacheKey newly added + * ImageManager.loadEmptyBitmap updated with function rename + * ImageManager.loadNormalBitmap updated with function rename + * ImageManager.clear updated with new ImageCache + * ImageManager.isReady updated with new ImageCache + * New functions (renamed): + * ImageManager.reserveAnimation + * ImageManager.reserveBattleback1 + * ImageManager.reserveBattleback2 + * ImageManager.reserveEnemy + * ImageManager.reserveCharacter + * ImageManager.reserveFace + * ImageManager.reserveParallax + * ImageManager.reservePicture + * ImageManager.reserveSvActor + * ImageManager.reserveSvEnemy + * ImageManager.reserveSystem + * ImageManager.reserveTileset + * ImageManager.reserveTitle1 + * ImageManager.reserveTitle2 + * ImageManager.reserveBitmap + * ImageManager.reserveNormalBitmap + * ImageManager.releaseReservation + * ImageManager.setDefaultReservationId + * ImageManager.requestAnimation + * ImageManager.requestBattleback1 + * ImageManager.requestBattleback2 + * ImageManager.requestEnemy + * ImageManager.requestCharacter + * ImageManager.requestFace + * ImageManager.requestParallax + * ImageManager.requestPicture + * ImageManager.requestSvActor + * ImageManager.requestSvEnemy + * ImageManager.requestSystem + * ImageManager.requestTileset + * ImageManager.requestTitle1 + * ImageManager.requestTitle2 + * ImageManager.requestBitmap + * ImageManager.requestNormalBitmap new function + * ImageManager.update new function + * ImageManager.clearRequest new function + * AudioManager._masterVolume added + * SceneManager._getTimeInMs renamed to + * SceneManager._getTimeInMsWithoutMobileSafari + * SceneManager.preferableRendererType updated per new graphics updates + * SceneManager.update added new updatemanagers + * SceneManager.updateMain updated for the new + * SceneManager._getTimeInMsWithoutMobileSafari + * SceneManager.updateManagers updated to utilize ImageManager.update() function + * SceneManager.changeScene updated with new reservation system + * SceneManager.resume new function added + * + * rpg_objects.js + * Game_System.prototype.saveWalkingBgm2 new function added + * Game_Message.prototype.allText updated + * Game_Map.prototype.autoplay updated for vehicle bgm to take into + * consideration the new Game_System.prototype.saveWalkingBgm2 function + * Game_Character.prototype.findDirectionTo updated + * Game_Interpreter.prototype.setup updated to now request images at the start + * Game_Interpreter.prototype.command282 (change tileset) updated per the new + * image reservation system + * Game_Interpreter.requestImages new function added to preload images that will + * be used by the event + * + * rpg_scenes.js + * Scene_Base.prototype.initialize updated with new reservation system + * Scene_Base.prototype.attachReservation new function added + * Scene_Base.prototype.detachReservation new function added + * Scene_Base.prototype.update no longer checks audio errors + * Scene_Boot.prototype.loadSystemWindowImage updated now to reserve images + * instead of loading them + * Scene_Boot.loadSystemImages updated now to reserve images instead of loading + * them + * Scene_Boot.prototype.isGameFontLoaded updated now with CSS and elapsed + * loading time increased from 20 seconds to 60 seconds + * Scene_Map.prototype.terminate updated now to clear requests + * Scene_Menu.prototype.createStatusWindow updated now to reserve face images + * Scene_Skill.prototype.start new function added + * Scene_Skill.prototype.createStatusWindow updated now to reserve face images + * Scene_Status.prototype.create updated now to reserve face images + * Scene_Status.prototype.start new function added + * Scene_Battle.prototype.terminate now clears images used + * + * rpg_sprites.js + * Sprite_Animation.prototype.isReady uses new image ready system + * Sprite_Animation.prototype.updateCellSprite updated + * + * rpg_windows.js + * Window_Base.prototype.reserveFaceImages new function added + * Window_MenuStatus.prototype.initialize no longer loads images + * Window_MenuStatus.prototype.loadImages now uses reserve image functions + * Window_Status.prototype.initialize updated to have an initial null actor + * Window_NameEdit.prototype.initialize now uses reserve image functions + * Window_Message.prototype.initMembers updated with Utils.generateRuntimeId() + * function added + * Window_Message.prototype.updateLoading now uses image ready system + * Window_Message.prototype.loadMessageFace now uses reserve image functions + * Window_Message.prototype.drawMessageFace updated with reserve image functions + * + * ============================================================================ + * RPG Maker MV 1.5.1 Changelog + * ============================================================================ + * + * rpg_core.js + * Sprite.prototype._renderWebGL updated to be picky when detecting usage for a + * heavy renderer + * PIXI.GC_MODES.DEFAULT = PIXI.GC_MODES.AUTO; changed to PIXI.settings.GC_MODE + * = PIXI.GC_MODES.AUTO; + * + * rpg_managers.js + * BattleManager.initMembers added new this._turnForced variable + * BattleManager.endTurn updated to check if a turn has been forced + * BattleManager.isForcedTurn new function + * BattleManager.processForcedAction updated for new forced turn variable + * + * rpg_objects.js + * Game_Battler.prototype.onTurnEnd updated to have a check for a forced turn + * Game_Interpreter.prototype.command122 (control variables) updated to have a + * proper range calculation change + * + * ============================================================================ + * RPG Maker MV 1.5.2 Changelog + * ============================================================================ + * + * rpg_core.js + * Graphics.initialize starts with _videoUnlocked with a false boolean. + * Graphics._setupEventHandlers added keydown and mousedown Event Listeners + * WebAudio._setupEventHandlers function updated to have keydown, mousedown, + * touchend listeners resume function. + * + * rpg_managers.js + * BattleManager.updateEvent now returns checkAbort instead of checkAbort2 + * BattleManager.checkAbort2 removed and became BattleManager.checkAbort + * + * rpg_objects.js + * Game_Interpreter.prototype.command113 (break loop) event fixed + * + * rpg_scenes.js + * No changes (good, since it doesn’t have the Scene_Item active window breaker) + * + * rpg_sprites.js + * Spriteset_Battle.prototype.overworldBattleback1Name and + * Spriteset_Battle.prototype.overworldBattleback2Name functions updated to + * return no backdrop if an empty string is determined + * + * ============================================================================ + * RPG Maker MV 1.6.1 Changelog + * ============================================================================ + * + * rpg_core.js + * Utils.isOptionValid function updated with fail saves + * WebAudio.prototype._startPlaying function updated for loopLength variable + * + * rpg_objects.js + * Game_Interpreter.prototype.command113 (break loop) function updated + * + * ============================================================================ + * End of Helpfile + * ============================================================================ + * + * @param ---Official Updates--- + * @default + * + * @param 110_Updates + * @text 1.0.0 to 1.1.0 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.0.0 to 1.1.0 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 120_Updates + * @text 1.1.0 to 1.2.0 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.1.0 to 1.2.0 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 130_Updates + * @text 1.2.0 to 1.3.0 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.2.0 to 1.3.0 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 131_Updates + * @text 1.3.0 to 1.3.1 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.3.0 to 1.3.1 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 132_Updates + * @text 1.3.1 to 1.3.2 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.3.1 to 1.3.2 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 133_Updates + * @text 1.3.2 to 1.3.3 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.3.2 to 1.3.3 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 134_Updates + * @text 1.3.3 to 1.3.4 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.3.3 to 1.3.4 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 140_Updates + * @text 1.3.4 to 1.4.0 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.3.4 to 1.4.0 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 150_Updates + * @text 1.4.0 to 1.5.0 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.4.0 to 1.5.0 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 151_Updates + * @text 1.5.0 to 1.5.1 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.5.0 to 1.5.1 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 152_Updates + * @text 1.5.1 to 1.5.2 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.5.1 to 1.5.2 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param 162_Updates + * @text 1.5.2 to 1.6.1 + * @parent ---Official Updates--- + * @type boolean + * @on YES + * @off NO + * @desc Add the 1.5.2 to 1.6.1 updates? This will be automatically + * disabled if a higher version is detected. + * @default true + * + * @param ---Custom--- + * @default + * + * @param Desktop_Updates + * @text Desktop Optimization + * @parent ---Custom--- + * @type boolean + * @on YES + * @off NO + * @desc Add Yanfly's Desktop Optimization Updates? + * @default true + */ +//============================================================================= + +Yanfly.PluginRequirements = function() { + return Imported.YEP_CoreEngine && + Utils.RPGMAKER_VERSION && + Utils.RPGMAKER_VERSION >= '1.4.0'; +}; + +if (Yanfly.PluginRequirements()) { + +//============================================================================= +// Parameter Variables +//============================================================================= + +Yanfly.Parameters = PluginManager.parameters('YEP_X_CoreUpdatesOpt'); +Yanfly.Param = Yanfly.Param || {}; + +Yanfly.ParameterVersionCheck = function(version, key, parameter) { + if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION === version) { + Yanfly.Param[key] = false; + } else if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION > version) { + Yanfly.Param[key] = false; + } else { + Yanfly.Param[key] = eval(String(Yanfly.Parameters[parameter])); + } +}; + +Yanfly.SetupParameters = function() { + // Official Updates + Yanfly.ParameterVersionCheck('1.1.0', 'Update110', '110_Updates'); + Yanfly.ParameterVersionCheck('1.2.0', 'Update120', '120_Updates'); + Yanfly.ParameterVersionCheck('1.3.0', 'Update130', '130_Updates'); + Yanfly.ParameterVersionCheck('1.3.1', 'Update131', '131_Updates'); + Yanfly.ParameterVersionCheck('1.3.2', 'Update132', '132_Updates'); + Yanfly.ParameterVersionCheck('1.3.3', 'Update133', '133_Updates'); + Yanfly.ParameterVersionCheck('1.3.4', 'Update134', '134_Updates'); + Yanfly.ParameterVersionCheck('1.4.0', 'Update140', '140_Updates'); + Yanfly.ParameterVersionCheck('1.5.0', 'Update150', '150_Updates'); + Yanfly.ParameterVersionCheck('1.5.1', 'Update151', '151_Updates'); + Yanfly.ParameterVersionCheck('1.5.2', 'Update152', '152_Updates'); + Yanfly.ParameterVersionCheck('1.6.1', 'Update161', '161_Updates'); + // Desktop Optimization + Yanfly.Param.UpdateDesktop = eval(String(Yanfly.Parameters['Desktop_Updates'])); +}; +Yanfly.SetupParameters(); + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.0.0 to 1.1.0 Changes +//============================================================================= + +if (Yanfly.Param.Update110) { + +//----------------------------------------------------------------------------- +// 1.1.0 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.1.0. +Utils.RPGMAKER_VERSION = '1.1.0'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Sprite.prototype.updateTransform = function() { + PIXI.Sprite.prototype.updateTransform.call(this); + this.worldTransform.tx += this._offset.x; + this.worldTransform.ty += this._offset.y; +}; + +Tilemap.prototype.update = function() { + this.animationCount++; + this.children.forEach(function(child) { + if (child.update) { + child.update(); + } + }); +}; + +Tilemap.prototype.refresh = function() { + this._lastTiles.length = 0; +}; + +Tilemap.prototype.updateTransform = function() { + var ox = Math.floor(this.origin.x); + var oy = Math.floor(this.origin.y); + var startX = Math.floor((ox - this._margin) / this._tileWidth); + var startY = Math.floor((oy - this._margin) / this._tileHeight); + this._updateLayerPositions(startX, startY); + this._paintAllTiles(startX, startY); + this._sortChildren(); + PIXI.DisplayObjectContainer.prototype.updateTransform.call(this); +}; + +Tilemap.prototype._paintTiles = function(startX, startY, x, y) { + var tableEdgeVirtualId = 10000; + var mx = startX + x; + var my = startY + y; + var dx = (mx * this._tileWidth).mod(this._layerWidth); + var dy = (my * this._tileHeight).mod(this._layerHeight); + var lx = dx / this._tileWidth; + var ly = dy / this._tileHeight; + var tileId0 = this._readMapData(mx, my, 0); + var tileId1 = this._readMapData(mx, my, 1); + var tileId2 = this._readMapData(mx, my, 2); + var tileId3 = this._readMapData(mx, my, 3); + var shadowBits = this._readMapData(mx, my, 4); + var upperTileId1 = this._readMapData(mx, my - 1, 1); + var lowerTiles = []; + var upperTiles = []; + + if (this._isHigherTile(tileId0)) { + upperTiles.push(tileId0); + } else { + lowerTiles.push(tileId0); + } + if (this._isHigherTile(tileId1)) { + upperTiles.push(tileId1); + } else { + lowerTiles.push(tileId1); + } + + lowerTiles.push(-shadowBits); + + if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) { + if (!Tilemap.isShadowingTile(tileId0)) { + lowerTiles.push(tableEdgeVirtualId + upperTileId1); + } + } + + if (this._isOverpassPosition(mx, my)) { + upperTiles.push(tileId2); + upperTiles.push(tileId3); + } else { + if (this._isHigherTile(tileId2)) { + upperTiles.push(tileId2); + } else { + lowerTiles.push(tileId2); + } + if (this._isHigherTile(tileId3)) { + upperTiles.push(tileId3); + } else { + lowerTiles.push(tileId3); + } + } + + var count = 1000 + this.animationCount - my; + var frameUpdated = (count % 30 === 0); + this._animationFrame = Math.floor(count / 30); + + var lastLowerTiles = this._readLastTiles(0, lx, ly); + if (!lowerTiles.equals(lastLowerTiles) || + (Tilemap.isTileA1(tileId0) && frameUpdated)) { + this._lowerBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight); + for (var i = 0; i < lowerTiles.length; i++) { + var lowerTileId = lowerTiles[i]; + if (lowerTileId < 0) { + this._drawShadow(this._lowerBitmap, shadowBits, dx, dy); + } else if (lowerTileId >= tableEdgeVirtualId) { + this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy); + } else { + this._drawTile(this._lowerBitmap, lowerTileId, dx, dy); + } + } + this._writeLastTiles(0, lx, ly, lowerTiles); + } + + var lastUpperTiles = this._readLastTiles(1, lx, ly); + if (!upperTiles.equals(lastUpperTiles)) { + this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight); + for (var j = 0; j < upperTiles.length; j++) { + this._drawTile(this._upperBitmap, upperTiles[j], dx, dy); + } + this._writeLastTiles(1, lx, ly, upperTiles); + } +}; + +Tilemap.prototype._drawAutotile = function(bitmap, tileId, dx, dy) { + var autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE; + var kind = Tilemap.getAutotileKind(tileId); + var shape = Tilemap.getAutotileShape(tileId); + var tx = kind % 8; + var ty = Math.floor(kind / 8); + var bx = 0; + var by = 0; + var setNumber = 0; + var isTable = false; + + if (Tilemap.isTileA1(tileId)) { + var waterSurfaceIndex = [0, 1, 2, 1][this._animationFrame % 4]; + setNumber = 0; + if (kind === 0) { + bx = waterSurfaceIndex * 2; + by = 0; + } else if (kind === 1) { + bx = waterSurfaceIndex * 2; + by = 3; + } else if (kind === 2) { + bx = 6; + by = 0; + } else if (kind === 3) { + bx = 6; + by = 3; + } else { + bx = Math.floor(tx / 4) * 8; + by = ty * 6 + Math.floor(tx / 2) % 2 * 3; + if (kind % 2 === 0) { + bx += waterSurfaceIndex * 2; + } + else { + bx += 6; + autotileTable = Tilemap.WATERFALL_AUTOTILE_TABLE; + by += this._animationFrame % 3; + } + } + } else if (Tilemap.isTileA2(tileId)) { + setNumber = 1; + bx = tx * 2; + by = (ty - 2) * 3; + isTable = this._isTableTile(tileId); + } else if (Tilemap.isTileA3(tileId)) { + setNumber = 2; + bx = tx * 2; + by = (ty - 6) * 2; + autotileTable = Tilemap.WALL_AUTOTILE_TABLE; + } else if (Tilemap.isTileA4(tileId)) { + setNumber = 3; + bx = tx * 2; + by = Math.floor((ty - 10) * 2.5 + (ty % 2 === 1 ? 0.5 : 0)); + if (ty % 2 === 1) { + autotileTable = Tilemap.WALL_AUTOTILE_TABLE; + } + } + + var table = autotileTable[shape]; + var source = this.bitmaps[setNumber]; + + if (table && source) { + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + for (var i = 0; i < 4; i++) { + var qsx = table[i][0]; + var qsy = table[i][1]; + var sx1 = (bx * 2 + qsx) * w1; + var sy1 = (by * 2 + qsy) * h1; + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + if (isTable && (qsy === 1 || qsy === 5)) { + var qsx2 = qsx; + var qsy2 = 3; + if (qsy === 1) { + qsx2 = [0,3,2,1][qsx]; + } + var sx2 = (bx * 2 + qsx2) * w1; + var sy2 = (by * 2 + qsy2) * h1; + bitmap.blt(source, sx2, sy2, w1, h1, dx1, dy1, w1, h1); + dy1 += h1/2; + bitmap.blt(source, sx1, sy1, w1, h1/2, dx1, dy1, w1, h1/2); + } else { + bitmap.blt(source, sx1, sy1, w1, h1, dx1, dy1, w1, h1); + } + } + } +}; + +//----------------------------------------------------------------------------- +// 1.1.0 rpg_managers.js changes +//----------------------------------------------------------------------------- + +DataManager.saveGame = function(savefileId) { + try { + StorageManager.backup(savefileId); + return this.saveGameWithoutRescue(savefileId); + } catch (e) { + console.error(e); + try { + StorageManager.remove(savefileId); + StorageManager.restoreBackup(savefileId); + } catch (e2) { + } + return false; + } +}; + +StorageManager.backup = function(savefileId) { + if (this.exists(savefileId)) { + if (this.isLocalMode()) { + var data = this.loadFromLocalFile(savefileId); + var compressed = LZString.compressToBase64(data); + var fs = require('fs'); + var dirPath = this.localFileDirectoryPath(); + var filePath = this.localFilePath(savefileId) + ".bak"; + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath); + } + fs.writeFileSync(filePath, compressed); + } else { + var data = this.loadFromWebStorage(savefileId); + var compressed = LZString.compressToBase64(data); + var key = this.webStorageKey(savefileId) + "bak"; + localStorage.setItem(key, compressed); + } + } +}; + +StorageManager.backupExists = function(savefileId) { + if (this.isLocalMode()) { + return this.localFileBackupExists(savefileId); + } else { + return this.webStorageBackupExists(savefileId); + } +}; + +StorageManager.cleanBackup = function(savefileId) { + if (this.backupExists(savefileId)) { + if (this.isLocalMode()) { + var fs = require('fs'); + var dirPath = this.localFileDirectoryPath(); + var filePath = this.localFilePath(savefileId); + fs.unlinkSync(filePath + ".bak"); + } else { + var key = this.webStorageKey(savefileId); + localStorage.removeItem(key + "bak"); + } + } +}; + +StorageManager.restoreBackup = function(savefileId) { + if (this.backupExists(savefileId)) { + if (this.isLocalMode()) { + var data = this.loadFromLocalBackupFile(savefileId); + var compressed = LZString.compressToBase64(data); + var fs = require('fs'); + var dirPath = this.localFileDirectoryPath(); + var filePath = this.localFilePath(savefileId); + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath); + } + fs.writeFileSync(filePath, compressed); + fs.unlinkSync(filePath + ".bak"); + } else { + var data = this.loadFromWebStorageBackup(savefileId); + var compressed = LZString.compressToBase64(data); + var key = this.webStorageKey(savefileId); + localStorage.setItem(key, compressed); + localStorage.removeItem(key + "bak",""); + } + } +}; + +StorageManager.loadFromLocalBackupFile = function(savefileId) { + var data = null; + var fs = require('fs'); + var filePath = this.localFilePath(savefileId) + ".bak"; + if (fs.existsSync(filePath)) { + data = fs.readFileSync(filePath, { encoding: 'utf8' }); + } + return LZString.decompressFromBase64(data); +}; + +StorageManager.loadFromWebStorageBackup = function(savefileId) { + var key = this.webStorageKey(savefileId) + "bak"; + var data = localStorage.getItem(key); + return LZString.decompressFromBase64(data); +}; + +StorageManager.webStorageBackupExists = function(savefileId) { + var key = this.webStorageKey(savefileId) + "bak"; + return !!localStorage.getItem(key); +}; + +SceneManager._getTimeInMs = function() { + return performance.now(); +}; + +SceneManager._deltaTime = 1.0 / 60.0; +SceneManager._currentTime = SceneManager._getTimeInMs(); +SceneManager._accumulator = 0.0; + +SceneManager.update = function() { + try { + this.tickStart(); + this.updateMain(); + this.tickEnd(); + } catch (e) { + this.catchException(e); + } +}; + +SceneManager.onKeyDown = function(event) { + if (!event.ctrlKey && !event.altKey) { + switch (event.keyCode) { + case 116: // F5 + if (Utils.isNwjs()) { + location.reload(); + } + break; + case 119: // F8 + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + require('nw.gui').Window.get().showDevTools(); + } + break; + } + } +}; + +SceneManager.updateMain = function() { + var newTime = this._getTimeInMs(); + var fTime = (newTime - this._currentTime) / 1000; + if (fTime > 0.25) fTime = 0.25; + this._currentTime = newTime; + this._accumulator += fTime; + while (this._accumulator >= this._deltaTime) { + this.updateInputData(); + this.changeScene(); + this.updateScene(); + this._accumulator -= this._deltaTime; + } + this.renderScene(); + this.requestUpdate(); +}; + +BattleManager.processEscape = function() { + $gameParty.performEscape(); + SoundManager.playEscape(); + var success = this._preemptive ? true : (Math.random() < this._escapeRatio); + if (success) { + this.displayEscapeSuccessMessage(); + this._escaped = true; + this.processAbort(); + } else { + this.displayEscapeFailureMessage(); + this._escapeRatio += 0.1; + $gameParty.clearActions(); + this.startTurn(); + } + return success; +}; + +BattleManager.processAbort = function() { + $gameParty.removeBattleStates(); + this.replayBgmAndBgs(); + this.endBattle(1); +}; + +//----------------------------------------------------------------------------- +// 1.1.0 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_Action.prototype.decideRandomTarget = function() { + var target; + if (this.isForDeadFriend()) { + target = this.friendsUnit().randomDeadTarget(); + } else if (this.isForFriend()) { + target = this.friendsUnit().randomTarget(); + } else { + target = this.opponentsUnit().randomTarget(); + } + if (target) { + this._targetIndex = target.index(); + } else { + this.clear(); + } +}; + +Game_Action.prototype.evaluate = function() { + var value = 0; + this.itemTargetCandidates().forEach(function(target) { + var targetValue = this.evaluateWithTarget(target); + if (this.isForAll()) { + value += targetValue; + } else if (targetValue > value) { + value = targetValue; + this._targetIndex = target.index(); + } + }, this); + value *= this.numRepeats(); + if (value > 0) { + value += Math.random(); + } + return value; +}; + +Game_Action.prototype.evalDamageFormula = function(target) { + var item = this.item(); + var a = this.subject(); + var b = target; + var v = $gameVariables._data; + var sign = ([3, 4].contains(item.damage.type) ? -1 : 1); + try { + var value = Math.max(eval(item.damage.formula), 0) * sign; + if (isNaN(value)) value = 0; + return value; + } catch (e) { + Yanfly.Util.displayError(e, item.damage.formula, 'DAMAGE FORMULA ERROR'); + return 0; + } +}; + +Game_Actor.prototype.changeClass = function(classId, keepExp) { + if (keepExp) { + this._exp[classId] = this.currentExp(); + } + this._classId = classId; + this.changeExp(this._exp[this._classId] || 0, false); + this.refresh(); +}; + +Game_Event.prototype.updateSelfMovement = function() { + if (!this._locked && this.isNearTheScreen() && + this.checkStop(this.stopCountThreshold())) { + switch (this._moveType) { + case 1: + this.moveTypeRandom(); + break; + case 2: + this.moveTypeTowardPlayer(); + break; + case 3: + this.moveTypeCustom(); + break; + } + } +}; + +// Change Class +Game_Interpreter.prototype.command321 = function() { + var actor = $gameActors.actor(this._params[0]); + if (actor && $dataClasses[this._params[1]]) { + actor.changeClass(this._params[1], this._params[2]); + } + return true; +}; + +//----------------------------------------------------------------------------- +// 1.1.0 rpg_scenes.js changes +//----------------------------------------------------------------------------- + +Scene_Save.prototype.onSaveSuccess = function() { + SoundManager.playSave(); + StorageManager.cleanBackup(this.savefileId()); + this.popScene(); +}; + +//----------------------------------------------------------------------------- +// 1.1.0 rpg_sprites.js changes +//----------------------------------------------------------------------------- + +Sprite_Actor.prototype.refreshMotion = function() { + var actor = this._actor; + var motionGuard = Sprite_Actor.MOTIONS['guard']; + if (actor) { + if (this._motion === motionGuard && !BattleManager.isInputting()) { + return; + } + var stateMotion = actor.stateMotionIndex(); + if (actor.isInputting() || actor.isActing()) { + this.startMotion('walk'); + } else if (stateMotion === 3) { + this.startMotion('dead'); + } else if (stateMotion === 2) { + this.startMotion('sleep'); + } else if (actor.isChanting()) { + this.startMotion('chant'); + } else if (actor.isGuard() || actor.isGuardWaiting()) { + this.startMotion('guard'); + } else if (stateMotion === 1) { + this.startMotion('abnormal'); + } else if (actor.isDying()) { + this.startMotion('dying'); + } else if (actor.isUndecided()) { + this.startMotion('walk'); + } else { + this.startMotion('wait'); + } + } +}; + +Spriteset_Map.prototype._canvasReAddParallax = function() { + var index = this._baseSprite.children.indexOf(this._parallax); + this._baseSprite.removeChild(this._parallax); + this._parallax = new TilingSprite(); + this._parallax.move(0, 0, Graphics.width, Graphics.height); + this._parallax.bitmap = ImageManager.loadParallax(this._parallaxName); + this._baseSprite.addChildAt(this._parallax,index); +}; + +Spriteset_Map.prototype.updateParallax = function() { + if (this._parallaxName !== $gameMap.parallaxName()) { + this._parallaxName = $gameMap.parallaxName(); + + if (this._parallax.bitmap && Graphics.isWebGL() != true) { + this._canvasReAddParallax(); + } else { + this._parallax.bitmap = ImageManager.loadParallax(this._parallaxName); + } + } + if (this._parallax.bitmap) { + this._parallax.origin.x = $gameMap.parallaxOx(); + this._parallax.origin.y = $gameMap.parallaxOy(); + } +}; + +//----------------------------------------------------------------------------- +// 1.1.0 rpg_windows.js changes +//----------------------------------------------------------------------------- + +Window_MenuStatus.prototype.drawItemImage = function(index) { + var actor = $gameParty.members()[index]; + var rect = this.itemRect(index); + this.changePaintOpacity(actor.isBattleMember()); + this.drawActorFace(actor, rect.x + 1, rect.y + 1, Window_Base._faceWidth, Window_Base._faceHeight); + this.changePaintOpacity(true); +}; + +Window_ActorCommand.prototype.selectLast = function() { + this.select(0); + if (this._actor && ConfigManager.commandRemember) { + var symbol = this._actor.lastCommandSymbol(); + this.selectSymbol(symbol); + if (symbol === 'skill') { + var skill = this._actor.lastBattleSkill(); + if (skill) { + this.selectExt(skill.stypeId); + } + } + } +}; + +//============================================================================= +// Version 1.0.0 to 1.1.0 Changes End +//============================================================================= + +}; // Yanfly.Param.Update110 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.1.0 to 1.2.0 Changes +//============================================================================= + +if (Yanfly.Param.Update120) { + +//----------------------------------------------------------------------------- +// 1.2.0 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.2.0. +Utils.RPGMAKER_VERSION = '1.2.0'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +TilingSprite.prototype.generateTilingTexture = function(arg) { + PIXI.TilingSprite.prototype.generateTilingTexture.call(this, arg); + // Purge from Pixi's Cache + if (this.tilingTexture.canvasBuffer) + PIXI.Texture.removeTextureFromCache(this.tilingTexture.canvasBuffer.canvas._pixiId); +}; + +//----------------------------------------------------------------------------- +// 1.2.0 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_Picture.prototype.updateRotation = function() { + if (this._rotationSpeed !== 0) { + this._angle += this._rotationSpeed / 2; + } +}; + +//----------------------------------------------------------------------------- +// 1.2.0 rpg_sprites.js changes +//----------------------------------------------------------------------------- + +Sprite_Animation.prototype.updateCellSprite = function(sprite, cell) { + var pattern = cell[0]; + if (pattern >= 0) { + var sx = pattern % 5 * 192; + var sy = Math.floor(pattern % 100 / 5) * 192; + var mirror = this._mirror; + sprite.bitmap = pattern < 100 ? this._bitmap1 : this._bitmap2; + sprite.setFrame(sx, sy, 192, 192); + sprite.x = cell[1]; + sprite.y = cell[2]; + if (this._mirror) { + sprite.x *= -1; + } + sprite.rotation = cell[4] * Math.PI / 180; + sprite.scale.x = cell[3] / 100; + if ((cell[5] && !mirror) || (!cell[5] && mirror)) { + sprite.scale.x *= -1; + } + sprite.scale.y = cell[3] / 100; + sprite.opacity = cell[6]; + sprite.blendMode = cell[7]; + sprite.visible = true; + } else { + sprite.visible = false; + } +}; + +//============================================================================= +// Version 1.1.0 to 1.2.0 Changes End +//============================================================================= + +}; // Yanfly.Param.Update120 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.2.0 to 1.3.0 Changes +//============================================================================= + +if (Yanfly.Param.Update130) { + +//----------------------------------------------------------------------------- +// 1.3.0 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.3.0. +Utils.RPGMAKER_VERSION = '1.3.0'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Object.defineProperties(Array.prototype, { + equals: { + enumerable: false, + value: function(array) { + if (!array || this.length !== array.length) { + return false; + } + for (var i = 0; i < this.length; i++) { + if (this[i] instanceof Array && array[i] instanceof Array) { + if (!this[i].equals(array[i])) { + return false; + } + } else if (this[i] !== array[i]) { + return false; + } + } + return true; + } + }, + clone: { + enumerable: false, + value: function() { + return this.slice(0); + } + }, + contains : { + enumerable: false, + value: function(element) { + return this.indexOf(element) >= 0; + } + } +}); + +CacheEntry = function(cache, key, item) { + this.cache = cache; + this.key = key; + this.item = item; + this.cached = false; + this.touchTicks = 0; + this.touchSeconds = 0; + this.ttlTicks = 0; + this.ttlSeconds = 0; + this.freedByTTL = false; +} + +CacheEntry.prototype.free = function(byTTL) { + this.freedByTTL = byTTL || false; + if (this.cached) { + this.cached = false; + delete this.cache._inner[key]; + } +}; + +CacheEntry.prototype.allocate = function() { + if (!this.cached) { + this.cache._inner[this.key] = this; + this.cached = true; + } + this.touch(); + return this; +}; + +CacheEntry.prototype.setTimeToLive = function(ticks, seconds) { + this.ttlTicks = ticks || 0; + this.ttlSeconds = seconds || 0; + return this; +}; + +CacheEntry.prototype.isStillAlive = function() { + var cache = this.cache; + return ((this.ttlTicks == 0) || (this.touchTicks + this.ttlTicks < cache.updateTicks )) && + ((this.ttlSeconds == 0) || (this.touchSeconds + this.ttlSeconds < cache.updateSeconds )); +}; + +CacheEntry.prototype.touch = function() { + var cache = this.cache; + if (this.cached) { + this.touchTicks = cache.updateTicks; + this.touchSeconds = cache.updateSeconds; + } else if (this.freedByTTL) { + this.freedByTTL = false; + //TODO: shall we log this event? its not normal + if (!cache._inner[this.key]) { + cache._inner[this.key] = this; + } + } +}; + +CacheMap = function(manager) { + this.manager = manager; + this._inner = {}; + this._lastRemovedEntries = {}; + this.updateTicks = 0; + this.lastCheckTTL = 0; + this.delayCheckTTL = 100.0; + this.updateSeconds = Date.now(); +} + +CacheMap.prototype.checkTTL = function() { + var cache = this._inner; + var temp = this._lastRemovedEntries; + if (!temp) { + temp = []; + this._lastRemovedEntries = temp; + } + for (var key in cache) { + var entry = cache[key]; + if (!entry.isStillAlive()) { + temp.push(entry); + } + } + for (var i = 0; i < temp.length; i++) { + temp[i].free(true); + } + temp.length = 0; +}; + +CacheMap.prototype.getItem = function(key) { + var entry = this._inner[key]; + if (entry) { + return entry.item; + } + return null; +}; + +CacheMap.prototype.clear = function() { + var keys = Object.keys(this._inner); + for (var i = 0; i < keys.length; i++) { + this._inner[keys[i]].free(); + } +}; + +CacheMap.prototype.setItem = function(key, item) { + return new CacheEntry(this, key, item).allocate(); +}; + +CacheMap.prototype.update = function(ticks, delta) { + this.updateTicks += ticks; + this.updateSeconds += delta; + if (this.updateSeconds >= this.delayCheckTTL + this.lastCheckTTL) { + this.lastCheckTTL = this.updateSeconds; + this.checkTTL(); + } +}; + +Bitmap.prototype.initialize = function(width, height) { + this._canvas = document.createElement('canvas'); + this._context = this._canvas.getContext('2d'); + this._canvas.width = Math.max(width || 0, 1); + this._canvas.height = Math.max(height || 0, 1); + this._baseTexture = new PIXI.BaseTexture(this._canvas); + this._baseTexture.mipmap = false; + this._baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST; + this._image = null; + this._url = ''; + this._paintOpacity = 255; + this._smooth = false; + this._loadListeners = []; + this._isLoading = false; + this._hasError = false; + this.cacheEntry = null; + this.fontFace = 'GameFont'; + this.fontSize = 28; + this.fontItalic = false; + this.textColor = '#ffffff'; + this.outlineColor = 'rgba(0, 0, 0, 0.5)'; + this.outlineWidth = 4; +}; + +Bitmap.load = function(url) { + var bitmap = new Bitmap(); + bitmap._image = new Image(); + bitmap._url = url; + bitmap._isLoading = true; + + if(!Decrypter.checkImgIgnore(url) && Decrypter.hasEncryptedImages) { + Decrypter.decryptImg(url, bitmap); + } else { + bitmap._image.src = url; + bitmap._image.onload = Bitmap.prototype._onLoad.bind(bitmap); + bitmap._image.onerror = Bitmap.prototype._onError.bind(bitmap); + } + + return bitmap; +}; + +Bitmap.snap = function(stage) { + var width = Graphics.width; + var height = Graphics.height; + var bitmap = new Bitmap(width, height); + var context = bitmap._context; + var renderTexture = PIXI.RenderTexture.create(width, height); + if (stage) { + Graphics._renderer.render(stage, renderTexture); + stage.worldTransform.identity(); + var canvas = null; + if (Graphics.isWebGL()) { + canvas = Graphics._renderer.extract.canvas(renderTexture); + } else { + canvas = renderTexture.baseTexture._canvasRenderTarget.canvas; + } + context.drawImage(canvas, 0, 0); + } else { + //TODO: Ivan: what if stage is not present? + } + bitmap._setDirty(); + return bitmap; +}; + +Bitmap.prototype.touch = function() { + if (this.cacheEntry) { + this.cacheEntry.touch(); + } +}; + +Object.defineProperty(Bitmap.prototype, 'smooth', { + get: function() { + return this._smooth; + }, + set: function(value) { + if (this._smooth !== value) { + this._smooth = value; + if (this._smooth) { + this._baseTexture.scaleMode = PIXI.SCALE_MODES.LINEAR; + } else { + this._baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST; + } + } + }, + configurable: true +}); + +Bitmap.prototype.bltImage = function(source, sx, sy, sw, sh, dx, dy, dw, dh) { + dw = dw || sw; + dh = dh || sh; + if (sx >= 0 && sy >= 0 && sw > 0 && sh > 0 && dw > 0 && dh > 0 && + sx + sw <= source.width && sy + sh <= source.height) { + this._context.globalCompositeOperation = 'source-over'; + this._context.drawImage(source._image, sx, sy, sw, sh, dx, dy, dw, dh); + this._setDirty(); + } +}; + +Bitmap.prototype._onLoad = function() { + if(Decrypter.hasEncryptedImages) { + window.URL.revokeObjectURL(this._image.src); + } + this._isLoading = false; + this.resize(this._image.width, this._image.height); + this._context.drawImage(this._image, 0, 0); + this._setDirty(); + this._callLoadListeners(); +}; + +Bitmap.prototype._setDirty = function() { + this._dirty = true; +}; + +Bitmap.prototype.checkDirty = function() { + if (this._dirty) { + this._baseTexture.update(); + this._dirty = false; + } +}; + +Graphics.isWebGL = function() { + return this._renderer && this._renderer.type === PIXI.RENDERER_TYPE.WEBGL; +}; + +Graphics.callGC = function() { + if (Graphics.isWebGL()) { + Graphics._renderer.textureGC.run(); + } +} + +Sprite.voidFilter = new PIXI.filters.VoidFilter(); + +Sprite.prototype.initialize = function(bitmap) { + var texture = new PIXI.Texture(new PIXI.BaseTexture()); + + PIXI.Sprite.call(this, texture); + + this._bitmap = null; + this._frame = new Rectangle(); + this._realFrame = new Rectangle(); + this._offset = new Point(); + this._blendColor = [0, 0, 0, 0]; + this._colorTone = [0, 0, 0, 0]; + this._canvas = null; + this._context = null; + this._tintTexture = null; + this._isPicture = false; + this.spriteId = Sprite._counter++; + this.opaque = false; + this.bitmap = bitmap; +}; + +Object.defineProperty(Sprite.prototype, 'bitmap', { + get: function() { + return this._bitmap; + }, + set: function(value) { + if (this._bitmap !== value) { + this._bitmap = value; + if (this._bitmap) { + this.setFrame(0, 0, 0, 0); + this._bitmap.addLoadListener(this._onBitmapLoad.bind(this)); + } else { + this.texture.frame = Rectangle.emptyRectangle; + } + } + }, + configurable: true +}); + +Sprite.prototype._refresh = function() { + var frameX = Math.floor(this._frame.x); + var frameY = Math.floor(this._frame.y); + var frameW = Math.floor(this._frame.width); + var frameH = Math.floor(this._frame.height); + var bitmapW = this._bitmap ? this._bitmap.width : 0; + var bitmapH = this._bitmap ? this._bitmap.height : 0; + var realX = frameX.clamp(0, bitmapW); + var realY = frameY.clamp(0, bitmapH); + var realW = (frameW - realX + frameX).clamp(0, bitmapW - realX); + var realH = (frameH - realY + frameY).clamp(0, bitmapH - realY); + + this._realFrame.x = realX; + this._realFrame.y = realY; + this._realFrame.width = realW; + this._realFrame.height = realH; + this._offset.x = realX - frameX; + this._offset.y = realY - frameY; + + if (realW > 0 && realH > 0) { + if (this._needsTint()) { + this._createTinter(realW, realH); + this._executeTint(realX, realY, realW, realH); + this._tintTexture.update(); + this.texture.baseTexture = this._tintTexture; + this.texture.frame = new Rectangle(0, 0, realW, realH); + } else { + if (this._bitmap) { + this.texture.baseTexture = this._bitmap.baseTexture; + } + this.texture.frame = this._realFrame; + } + } else if (this._bitmap) { + this.texture.frame = Rectangle.emptyRectangle; + } else { + //TODO: remove this + this.texture.baseTexture.width = Math.max(this.texture.baseTexture.width, this._frame.x + this._frame.width); + this.texture.baseTexture.height = Math.max(this.texture.baseTexture.height, this._frame.y + this._frame.height); + this.texture.frame = this._frame; + } +}; + +Sprite.prototype._renderCanvas_PIXI = PIXI.Sprite.prototype._renderCanvas; +Sprite.prototype._renderWebGL_PIXI = PIXI.Sprite.prototype._renderWebGL; + +Sprite.prototype._renderCanvas = function(renderer) { + if (this.bitmap) { + this.bitmap.touch(); + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + this._renderCanvas_PIXI(renderer); + } +}; + +Sprite.prototype._speedUpCustomBlendModes = function(renderer) { + var picture = renderer.plugins.picture; + var blend = this.blendMode; + if (renderer.renderingToScreen && renderer._activeRenderTarget.root) { + if (picture.drawModes[blend]) { + var stage = renderer._lastObjectRendered; + var f = stage._filters; + if (!f || !f[0]) { + setTimeout(function() { + var f = stage._filters; + if (!f || !f[0]) { + stage.filters = [Sprite.voidFilter]; + stage.filterArea = new PIXI.Rectangle(0, 0, Graphics.width, Graphics.height); + } + }, 0); + } + } + } +}; + +Sprite.prototype._renderWebGL = function(renderer) { + if (this.bitmap) { + this.bitmap.touch(); + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + if (this._bitmap) { + this._bitmap.checkDirty(); + } + this.calculateVertices(); + if (this._isPicture) { + this._speedUpCustomBlendModes(renderer); + renderer.setObjectRenderer(renderer.plugins.picture); + renderer.plugins.picture.render(this); + } else { + renderer.setObjectRenderer(renderer.plugins.sprite); + renderer.plugins.sprite.render(this); + } + } +}; + +Tilemap = function() { + this.initialize.apply(this, arguments); +} + +Tilemap.prototype = Object.create(PIXI.Container.prototype); +Tilemap.prototype.constructor = Tilemap; + +Tilemap.prototype.initialize = function() { + PIXI.Container.call(this); + + this._margin = 20; + this._width = Graphics.width + this._margin * 2; + this._height = Graphics.height + this._margin * 2; + this._tileWidth = 48; + this._tileHeight = 48; + this._mapWidth = 0; + this._mapHeight = 0; + this._mapData = null; + this._layerWidth = 0; + this._layerHeight = 0; + this._lastTiles = []; + this.bitmaps = []; + this.origin = new Point(); + this.flags = []; + this.animationCount = 0; + this.horizontalWrap = false; + this.verticalWrap = false; + this._createLayers(); + this.refresh(); +}; + +Object.defineProperty(Tilemap.prototype, 'width', { + get: function() { + return this._width; + }, + set: function(value) { + if (this._width !== value) { + this._width = value; + this._createLayers(); + } + } +}); + +Object.defineProperty(Tilemap.prototype, 'height', { + get: function() { + return this._height; + }, + set: function(value) { + if (this._height !== value) { + this._height = value; + this._createLayers(); + } + } +}); + +Object.defineProperty(Tilemap.prototype, 'tileWidth', { + get: function() { + return this._tileWidth; + }, + set: function(value) { + if (this._tileWidth !== value) { + this._tileWidth = value; + this._createLayers(); + } + } +}); + +Object.defineProperty(Tilemap.prototype, 'tileHeight', { + get: function() { + return this._tileHeight; + }, + set: function(value) { + if (this._tileHeight !== value) { + this._tileHeight = value; + this._createLayers(); + } + } +}); + +Tilemap.prototype.setData = function(width, height, data) { + this._mapWidth = width; + this._mapHeight = height; + this._mapData = data; +}; + +Tilemap.prototype.isReady = function() { + for (var i = 0; i < this.bitmaps.length; i++) { + if (this.bitmaps[i] && !this.bitmaps[i].isReady()) { + return false; + } + } + return true; +}; + +Tilemap.prototype.update = function() { + this.animationCount++; + this.animationFrame = Math.floor(this.animationCount / 30); + this.children.forEach(function(child) { + if (child.update) { + child.update(); + } + }); + for (var i=0; i= tableEdgeVirtualId) { + this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy); + } else { + this._drawTile(this._lowerBitmap, lowerTileId, dx, dy); + } + } + this._writeLastTiles(0, lx, ly, lowerTiles); + } + + var lastUpperTiles = this._readLastTiles(1, lx, ly); + if (!upperTiles.equals(lastUpperTiles)) { + this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight); + for (var j = 0; j < upperTiles.length; j++) { + this._drawTile(this._upperBitmap, upperTiles[j], dx, dy); + } + this._writeLastTiles(1, lx, ly, upperTiles); + } +}; + +Tilemap.prototype._readLastTiles = function(i, x, y) { + var array1 = this._lastTiles[i]; + if (array1) { + var array2 = array1[y]; + if (array2) { + var tiles = array2[x]; + if (tiles) { + return tiles; + } + } + } + return []; +}; + +Tilemap.prototype._writeLastTiles = function(i, x, y, tiles) { + var array1 = this._lastTiles[i]; + if (!array1) { + array1 = this._lastTiles[i] = []; + } + var array2 = array1[y]; + if (!array2) { + array2 = array1[y] = []; + } + array2[x] = tiles; +}; + +Tilemap.prototype._drawTile = function(bitmap, tileId, dx, dy) { + if (Tilemap.isVisibleTile(tileId)) { + if (Tilemap.isAutotile(tileId)) { + this._drawAutotile(bitmap, tileId, dx, dy); + } else { + this._drawNormalTile(bitmap, tileId, dx, dy); + } + } +}; + +Tilemap.prototype._drawNormalTile = function(bitmap, tileId, dx, dy) { + var setNumber = 0; + + if (Tilemap.isTileA5(tileId)) { + setNumber = 4; + } else { + setNumber = 5 + Math.floor(tileId / 256); + } + + var w = this._tileWidth; + var h = this._tileHeight; + var sx = (Math.floor(tileId / 128) % 2 * 8 + tileId % 8) * w; + var sy = (Math.floor(tileId % 256 / 8) % 16) * h; + + var source = this.bitmaps[setNumber]; + if (source) { + bitmap.bltImage(source, sx, sy, w, h, dx, dy, w, h); + } +}; + +Tilemap.prototype._drawAutotile = function(bitmap, tileId, dx, dy) { + var autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE; + var kind = Tilemap.getAutotileKind(tileId); + var shape = Tilemap.getAutotileShape(tileId); + var tx = kind % 8; + var ty = Math.floor(kind / 8); + var bx = 0; + var by = 0; + var setNumber = 0; + var isTable = false; + + if (Tilemap.isTileA1(tileId)) { + var waterSurfaceIndex = [0, 1, 2, 1][this.animationFrame % 4]; + setNumber = 0; + if (kind === 0) { + bx = waterSurfaceIndex * 2; + by = 0; + } else if (kind === 1) { + bx = waterSurfaceIndex * 2; + by = 3; + } else if (kind === 2) { + bx = 6; + by = 0; + } else if (kind === 3) { + bx = 6; + by = 3; + } else { + bx = Math.floor(tx / 4) * 8; + by = ty * 6 + Math.floor(tx / 2) % 2 * 3; + if (kind % 2 === 0) { + bx += waterSurfaceIndex * 2; + } + else { + bx += 6; + autotileTable = Tilemap.WATERFALL_AUTOTILE_TABLE; + by += this.animationFrame % 3; + } + } + } else if (Tilemap.isTileA2(tileId)) { + setNumber = 1; + bx = tx * 2; + by = (ty - 2) * 3; + isTable = this._isTableTile(tileId); + } else if (Tilemap.isTileA3(tileId)) { + setNumber = 2; + bx = tx * 2; + by = (ty - 6) * 2; + autotileTable = Tilemap.WALL_AUTOTILE_TABLE; + } else if (Tilemap.isTileA4(tileId)) { + setNumber = 3; + bx = tx * 2; + by = Math.floor((ty - 10) * 2.5 + (ty % 2 === 1 ? 0.5 : 0)); + if (ty % 2 === 1) { + autotileTable = Tilemap.WALL_AUTOTILE_TABLE; + } + } + + var table = autotileTable[shape]; + var source = this.bitmaps[setNumber]; + + if (table && source) { + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + for (var i = 0; i < 4; i++) { + var qsx = table[i][0]; + var qsy = table[i][1]; + var sx1 = (bx * 2 + qsx) * w1; + var sy1 = (by * 2 + qsy) * h1; + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + if (isTable && (qsy === 1 || qsy === 5)) { + var qsx2 = qsx; + var qsy2 = 3; + if (qsy === 1) { + qsx2 = [0,3,2,1][qsx]; + } + var sx2 = (bx * 2 + qsx2) * w1; + var sy2 = (by * 2 + qsy2) * h1; + bitmap.bltImage(source, sx2, sy2, w1, h1, dx1, dy1, w1, h1); + dy1 += h1/2; + bitmap.bltImage(source, sx1, sy1, w1, h1/2, dx1, dy1, w1, h1/2); + } else { + bitmap.bltImage(source, sx1, sy1, w1, h1, dx1, dy1, w1, h1); + } + } + } +}; + +Tilemap.prototype._drawTableEdge = function(bitmap, tileId, dx, dy) { + if (Tilemap.isTileA2(tileId)) { + var autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE; + var kind = Tilemap.getAutotileKind(tileId); + var shape = Tilemap.getAutotileShape(tileId); + var tx = kind % 8; + var ty = Math.floor(kind / 8); + var setNumber = 1; + var bx = tx * 2; + var by = (ty - 2) * 3; + var table = autotileTable[shape]; + + if (table) { + var source = this.bitmaps[setNumber]; + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + for (var i = 0; i < 2; i++) { + var qsx = table[2 + i][0]; + var qsy = table[2 + i][1]; + var sx1 = (bx * 2 + qsx) * w1; + var sy1 = (by * 2 + qsy) * h1 + h1/2; + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + bitmap.bltImage(source, sx1, sy1, w1, h1/2, dx1, dy1, w1, h1/2); + } + } + } +}; + +Tilemap.prototype._drawShadow = function(bitmap, shadowBits, dx, dy) { + if (shadowBits & 0x0f) { + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + var color = 'rgba(0,0,0,0.5)'; + for (var i = 0; i < 4; i++) { + if (shadowBits & (1 << i)) { + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + bitmap.fillRect(dx1, dy1, w1, h1, color); + } + } + } +}; + +Tilemap.prototype._readMapData = function(x, y, z) { + if (this._mapData) { + var width = this._mapWidth; + var height = this._mapHeight; + if (this.horizontalWrap) { + x = x.mod(width); + } + if (this.verticalWrap) { + y = y.mod(height); + } + if (x >= 0 && x < width && y >= 0 && y < height) { + return this._mapData[(z * height + y) * width + x] || 0; + } else { + return 0; + } + } else { + return 0; + } +}; + +Tilemap.prototype._isHigherTile = function(tileId) { + return this.flags[tileId] & 0x10; +}; + +Tilemap.prototype._isTableTile = function(tileId) { + return Tilemap.isTileA2(tileId) && (this.flags[tileId] & 0x80); +}; + +Tilemap.prototype._isOverpassPosition = function(mx, my) { + return false; +}; + +Tilemap.prototype._sortChildren = function() { + this.children.sort(this._compareChildOrder.bind(this)); +}; + +Tilemap.prototype._compareChildOrder = function(a, b) { + if (a.z !== b.z) { + return a.z - b.z; + } else if (a.y !== b.y) { + return a.y - b.y; + } else { + return a.spriteId - b.spriteId; + } +}; + +Tilemap.TILE_ID_B = 0; +Tilemap.TILE_ID_C = 256; +Tilemap.TILE_ID_D = 512; +Tilemap.TILE_ID_E = 768; +Tilemap.TILE_ID_A5 = 1536; +Tilemap.TILE_ID_A1 = 2048; +Tilemap.TILE_ID_A2 = 2816; +Tilemap.TILE_ID_A3 = 4352; +Tilemap.TILE_ID_A4 = 5888; +Tilemap.TILE_ID_MAX = 8192; + +Tilemap.isVisibleTile = function(tileId) { + return tileId > 0 && tileId < this.TILE_ID_MAX; +}; + +Tilemap.isAutotile = function(tileId) { + return tileId >= this.TILE_ID_A1; +}; + +Tilemap.getAutotileKind = function(tileId) { + return Math.floor((tileId - this.TILE_ID_A1) / 48); +}; + +Tilemap.getAutotileShape = function(tileId) { + return (tileId - this.TILE_ID_A1) % 48; +}; + +Tilemap.makeAutotileId = function(kind, shape) { + return this.TILE_ID_A1 + kind * 48 + shape; +}; + +Tilemap.isSameKindTile = function(tileID1, tileID2) { + if (this.isAutotile(tileID1) && this.isAutotile(tileID2)) { + return this.getAutotileKind(tileID1) === this.getAutotileKind(tileID2); + } else { + return tileID1 === tileID2; + } +}; + +Tilemap.isTileA1 = function(tileId) { + return tileId >= this.TILE_ID_A1 && tileId < this.TILE_ID_A2; +}; + +Tilemap.isTileA2 = function(tileId) { + return tileId >= this.TILE_ID_A2 && tileId < this.TILE_ID_A3; +}; + +Tilemap.isTileA3 = function(tileId) { + return tileId >= this.TILE_ID_A3 && tileId < this.TILE_ID_A4; +}; + +Tilemap.isTileA4 = function(tileId) { + return tileId >= this.TILE_ID_A4 && tileId < this.TILE_ID_MAX; +}; + +Tilemap.isTileA5 = function(tileId) { + return tileId >= this.TILE_ID_A5 && tileId < this.TILE_ID_A1; +}; + +Tilemap.isWaterTile = function(tileId) { + if (this.isTileA1(tileId)) { + return !(tileId >= this.TILE_ID_A1 + 96 && tileId < this.TILE_ID_A1 + 192); + } else { + return false; + } +}; + +Tilemap.isWaterfallTile = function(tileId) { + if (tileId >= this.TILE_ID_A1 + 192 && tileId < this.TILE_ID_A2) { + return this.getAutotileKind(tileId) % 2 === 1; + } else { + return false; + } +}; + +Tilemap.isGroundTile = function(tileId) { + return this.isTileA1(tileId) || this.isTileA2(tileId) || this.isTileA5(tileId); +}; + +Tilemap.isShadowingTile = function(tileId) { + return this.isTileA3(tileId) || this.isTileA4(tileId); +}; + +Tilemap.isRoofTile = function(tileId) { + return this.isTileA3(tileId) && this.getAutotileKind(tileId) % 16 < 8; +}; + +Tilemap.isWallTopTile = function(tileId) { + return this.isTileA4(tileId) && this.getAutotileKind(tileId) % 16 < 8; +}; + +Tilemap.isWallSideTile = function(tileId) { + return (this.isTileA3(tileId) || this.isTileA4(tileId)) && + this.getAutotileKind(tileId) % 16 >= 8; +}; + +Tilemap.isWallTile = function(tileId) { + return this.isWallTopTile(tileId) || this.isWallSideTile(tileId); +}; + +Tilemap.isFloorTypeAutotile = function(tileId) { + return (this.isTileA1(tileId) && !this.isWaterfallTile(tileId)) || + this.isTileA2(tileId) || this.isWallTopTile(tileId); +}; + +Tilemap.isWallTypeAutotile = function(tileId) { + return this.isRoofTile(tileId) || this.isWallSideTile(tileId); +}; + +Tilemap.isWaterfallTypeAutotile = function(tileId) { + return this.isWaterfallTile(tileId); +}; + +Tilemap.FLOOR_AUTOTILE_TABLE = [ + [[2,4],[1,4],[2,3],[1,3]],[[2,0],[1,4],[2,3],[1,3]], + [[2,4],[3,0],[2,3],[1,3]],[[2,0],[3,0],[2,3],[1,3]], + [[2,4],[1,4],[2,3],[3,1]],[[2,0],[1,4],[2,3],[3,1]], + [[2,4],[3,0],[2,3],[3,1]],[[2,0],[3,0],[2,3],[3,1]], + [[2,4],[1,4],[2,1],[1,3]],[[2,0],[1,4],[2,1],[1,3]], + [[2,4],[3,0],[2,1],[1,3]],[[2,0],[3,0],[2,1],[1,3]], + [[2,4],[1,4],[2,1],[3,1]],[[2,0],[1,4],[2,1],[3,1]], + [[2,4],[3,0],[2,1],[3,1]],[[2,0],[3,0],[2,1],[3,1]], + [[0,4],[1,4],[0,3],[1,3]],[[0,4],[3,0],[0,3],[1,3]], + [[0,4],[1,4],[0,3],[3,1]],[[0,4],[3,0],[0,3],[3,1]], + [[2,2],[1,2],[2,3],[1,3]],[[2,2],[1,2],[2,3],[3,1]], + [[2,2],[1,2],[2,1],[1,3]],[[2,2],[1,2],[2,1],[3,1]], + [[2,4],[3,4],[2,3],[3,3]],[[2,4],[3,4],[2,1],[3,3]], + [[2,0],[3,4],[2,3],[3,3]],[[2,0],[3,4],[2,1],[3,3]], + [[2,4],[1,4],[2,5],[1,5]],[[2,0],[1,4],[2,5],[1,5]], + [[2,4],[3,0],[2,5],[1,5]],[[2,0],[3,0],[2,5],[1,5]], + [[0,4],[3,4],[0,3],[3,3]],[[2,2],[1,2],[2,5],[1,5]], + [[0,2],[1,2],[0,3],[1,3]],[[0,2],[1,2],[0,3],[3,1]], + [[2,2],[3,2],[2,3],[3,3]],[[2,2],[3,2],[2,1],[3,3]], + [[2,4],[3,4],[2,5],[3,5]],[[2,0],[3,4],[2,5],[3,5]], + [[0,4],[1,4],[0,5],[1,5]],[[0,4],[3,0],[0,5],[1,5]], + [[0,2],[3,2],[0,3],[3,3]],[[0,2],[1,2],[0,5],[1,5]], + [[0,4],[3,4],[0,5],[3,5]],[[2,2],[3,2],[2,5],[3,5]], + [[0,2],[3,2],[0,5],[3,5]],[[0,0],[1,0],[0,1],[1,1]] +]; + +Tilemap.WALL_AUTOTILE_TABLE = [ + [[2,2],[1,2],[2,1],[1,1]],[[0,2],[1,2],[0,1],[1,1]], + [[2,0],[1,0],[2,1],[1,1]],[[0,0],[1,0],[0,1],[1,1]], + [[2,2],[3,2],[2,1],[3,1]],[[0,2],[3,2],[0,1],[3,1]], + [[2,0],[3,0],[2,1],[3,1]],[[0,0],[3,0],[0,1],[3,1]], + [[2,2],[1,2],[2,3],[1,3]],[[0,2],[1,2],[0,3],[1,3]], + [[2,0],[1,0],[2,3],[1,3]],[[0,0],[1,0],[0,3],[1,3]], + [[2,2],[3,2],[2,3],[3,3]],[[0,2],[3,2],[0,3],[3,3]], + [[2,0],[3,0],[2,3],[3,3]],[[0,0],[3,0],[0,3],[3,3]] +]; + +Tilemap.WATERFALL_AUTOTILE_TABLE = [ + [[2,0],[1,0],[2,1],[1,1]],[[0,0],[1,0],[0,1],[1,1]], + [[2,0],[3,0],[2,1],[3,1]],[[0,0],[3,0],[0,1],[3,1]] +]; + +ShaderTilemap = function() { + Tilemap.apply(this, arguments); + this.roundPixels = true; +}; + +ShaderTilemap.prototype = Object.create(Tilemap.prototype); +ShaderTilemap.prototype.constructor = ShaderTilemap; + +PIXI.glCore.VertexArrayObject.FORCE_NATIVE = true; + +ShaderTilemap.prototype._hackRenderer = function(renderer) { + var af = this.animationFrame % 4; + if (af==3) af = 1; + renderer.plugins.tile.tileAnim[0] = af * this._tileWidth; + renderer.plugins.tile.tileAnim[1] = (this.animationFrame % 3) * this._tileHeight; + return renderer; +}; + +ShaderTilemap.prototype.renderCanvas = function(renderer) { + this._hackRenderer(renderer); + PIXI.Container.prototype.renderCanvas.call(this, renderer); +}; + +ShaderTilemap.prototype.renderWebGL = function(renderer) { + this._hackRenderer(renderer); + PIXI.Container.prototype.renderWebGL.call(this, renderer); +}; + +ShaderTilemap.prototype.refresh = function() { + if (this._lastBitmapLength !== this.bitmaps.length) { + this._lastBitmapLength = this.bitmaps.length; + this.refreshTileset(); + }; + this._needsRepaint = true; +}; + +ShaderTilemap.prototype.refreshTileset = function() { + var bitmaps = this.bitmaps.map(function(x) { return x._baseTexture ? new PIXI.Texture(x._baseTexture) : x; } ); + this.lowerLayer.setBitmaps(bitmaps); + this.upperLayer.setBitmaps(bitmaps); +}; + +ShaderTilemap.prototype.updateTransform = function() { + if (this.roundPixels) { + var ox = Math.floor(this.origin.x); + var oy = Math.floor(this.origin.y); + } else { + ox = this.origin.x; + oy = this.origin.y; + } + var startX = Math.floor((ox - this._margin) / this._tileWidth); + var startY = Math.floor((oy - this._margin) / this._tileHeight); + this._updateLayerPositions(startX, startY); + if (this._needsRepaint || + this._lastStartX !== startX || this._lastStartY !== startY) { + this._lastStartX = startX; + this._lastStartY = startY; + this._paintAllTiles(startX, startY); + this._needsRepaint = false; + } + this._sortChildren(); + PIXI.Container.prototype.updateTransform.call(this); +}; + +ShaderTilemap.prototype._createLayers = function() { + var width = this._width; + var height = this._height; + var margin = this._margin; + var tileCols = Math.ceil(width / this._tileWidth) + 1; + var tileRows = Math.ceil(height / this._tileHeight) + 1; + var layerWidth = this._layerWidth = tileCols * this._tileWidth; + var layerHeight = this._layerHeight = tileRows * this._tileHeight; + this._needsRepaint = true; + + if (!this.lowerZLayer) { + //@hackerham: create layers only in initialization. Doesn't depend on width/height + this.addChild(this.lowerZLayer = new PIXI.tilemap.ZLayer(this, 0)); + this.addChild(this.upperZLayer = new PIXI.tilemap.ZLayer(this, 4)); + + var parameters = PluginManager.parameters('ShaderTilemap'); + var useSquareShader = Number(parameters.hasOwnProperty('squareShader') ? parameters['squareShader'] : 0); + + this.lowerZLayer.addChild(this.lowerLayer = new PIXI.tilemap.CompositeRectTileLayer(0, [], useSquareShader)); + this.lowerLayer.shadowColor = new Float32Array([0.0, 0.0, 0.0, 0.5]); + this.upperZLayer.addChild(this.upperLayer = new PIXI.tilemap.CompositeRectTileLayer(4, [], useSquareShader)); + } +}; + +ShaderTilemap.prototype._updateLayerPositions = function(startX, startY) { + if (this.roundPixels) { + var ox = Math.floor(this.origin.x); + var oy = Math.floor(this.origin.y); + } else { + ox = this.origin.x; + oy = this.origin.y; + } + this.lowerZLayer.position.x = startX * this._tileWidth - ox; + this.lowerZLayer.position.y = startY * this._tileHeight - oy; + this.upperZLayer.position.x = startX * this._tileWidth - ox; + this.upperZLayer.position.y = startY * this._tileHeight - oy; +}; + +ShaderTilemap.prototype._paintAllTiles = function(startX, startY) { + this.lowerZLayer.clear(); + this.upperZLayer.clear(); + var tileCols = Math.ceil(this._width / this._tileWidth) + 1; + var tileRows = Math.ceil(this._height / this._tileHeight) + 1; + for (var y = 0; y < tileRows; y++) { + for (var x = 0; x < tileCols; x++) { + this._paintTiles(startX, startY, x, y); + } + } +}; + +ShaderTilemap.prototype._paintTiles = function(startX, startY, x, y) { + var mx = startX + x; + var my = startY + y; + var dx = x * this._tileWidth, dy = y * this._tileHeight; + var tileId0 = this._readMapData(mx, my, 0); + var tileId1 = this._readMapData(mx, my, 1); + var tileId2 = this._readMapData(mx, my, 2); + var tileId3 = this._readMapData(mx, my, 3); + var shadowBits = this._readMapData(mx, my, 4); + var upperTileId1 = this._readMapData(mx, my - 1, 1); + var lowerLayer = this.lowerLayer.children[0]; + var upperLayer = this.upperLayer.children[0]; + + if (this._isHigherTile(tileId0)) { + this._drawTile(upperLayer, tileId0, dx, dy); + } else { + this._drawTile(lowerLayer, tileId0, dx, dy); + } + if (this._isHigherTile(tileId1)) { + this._drawTile(upperLayer, tileId1, dx, dy); + } else { + this._drawTile(lowerLayer, tileId1, dx, dy); + } + + this._drawShadow(lowerLayer, shadowBits, dx, dy); + if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) { + if (!Tilemap.isShadowingTile(tileId0)) { + this._drawTableEdge(lowerLayer, upperTileId1, dx, dy); + } + } + + if (this._isOverpassPosition(mx, my)) { + this._drawTile(upperLayer, tileId2, dx, dy); + this._drawTile(upperLayer, tileId3, dx, dy); + } else { + if (this._isHigherTile(tileId2)) { + this._drawTile(upperLayer, tileId2, dx, dy); + } else { + this._drawTile(lowerLayer, tileId2, dx, dy); + } + if (this._isHigherTile(tileId3)) { + this._drawTile(upperLayer, tileId3, dx, dy); + } else { + this._drawTile(lowerLayer, tileId3, dx, dy); + } + } +}; + +ShaderTilemap.prototype._drawTile = function(layer, tileId, dx, dy) { + if (Tilemap.isVisibleTile(tileId)) { + if (Tilemap.isAutotile(tileId)) { + this._drawAutotile(layer, tileId, dx, dy); + } else { + this._drawNormalTile(layer, tileId, dx, dy); + } + } +}; + +ShaderTilemap.prototype._drawNormalTile = function(layer, tileId, dx, dy) { + var setNumber = 0; + + if (Tilemap.isTileA5(tileId)) { + setNumber = 4; + } else { + setNumber = 5 + Math.floor(tileId / 256); + } + + var w = this._tileWidth; + var h = this._tileHeight; + var sx = (Math.floor(tileId / 128) % 2 * 8 + tileId % 8) * w; + var sy = (Math.floor(tileId % 256 / 8) % 16) * h; + + layer.addRect(setNumber, sx, sy, dx, dy, w, h); +}; + +ShaderTilemap.prototype._drawAutotile = function(layer, tileId, dx, dy) { + var autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE; + var kind = Tilemap.getAutotileKind(tileId); + var shape = Tilemap.getAutotileShape(tileId); + var tx = kind % 8; + var ty = Math.floor(kind / 8); + var bx = 0; + var by = 0; + var setNumber = 0; + var isTable = false; + var animX = 0, animY = 0; + + if (Tilemap.isTileA1(tileId)) { + setNumber = 0; + if (kind === 0) { + animX = 2; + by = 0; + } else if (kind === 1) { + animX = 2; + by = 3; + } else if (kind === 2) { + bx = 6; + by = 0; + } else if (kind === 3) { + bx = 6; + by = 3; + } else { + bx = Math.floor(tx / 4) * 8; + by = ty * 6 + Math.floor(tx / 2) % 2 * 3; + if (kind % 2 === 0) { + animX = 2; + } + else { + bx += 6; + autotileTable = Tilemap.WATERFALL_AUTOTILE_TABLE; + animY = 1; + } + } + } else if (Tilemap.isTileA2(tileId)) { + setNumber = 1; + bx = tx * 2; + by = (ty - 2) * 3; + isTable = this._isTableTile(tileId); + } else if (Tilemap.isTileA3(tileId)) { + setNumber = 2; + bx = tx * 2; + by = (ty - 6) * 2; + autotileTable = Tilemap.WALL_AUTOTILE_TABLE; + } else if (Tilemap.isTileA4(tileId)) { + setNumber = 3; + bx = tx * 2; + by = Math.floor((ty - 10) * 2.5 + (ty % 2 === 1 ? 0.5 : 0)); + if (ty % 2 === 1) { + autotileTable = Tilemap.WALL_AUTOTILE_TABLE; + } + } + + var table = autotileTable[shape]; + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + for (var i = 0; i < 4; i++) { + var qsx = table[i][0]; + var qsy = table[i][1]; + var sx1 = (bx * 2 + qsx) * w1; + var sy1 = (by * 2 + qsy) * h1; + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + if (isTable && (qsy === 1 || qsy === 5)) { + var qsx2 = qsx; + var qsy2 = 3; + if (qsy === 1) { + //qsx2 = [0, 3, 2, 1][qsx]; + qsx2 = (4-qsx)%4; + } + var sx2 = (bx * 2 + qsx2) * w1; + var sy2 = (by * 2 + qsy2) * h1; + layer.addRect(setNumber, sx2, sy2, dx1, dy1, w1, h1, animX, animY); + layer.addRect(setNumber, sx1, sy1, dx1, dy1+h1/2, w1, h1/2, animX, animY); + } else { + layer.addRect(setNumber, sx1, sy1, dx1, dy1, w1, h1, animX, animY); + } + } +}; + +ShaderTilemap.prototype._drawTableEdge = function(layer, tileId, dx, dy) { + if (Tilemap.isTileA2(tileId)) { + var autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE; + var kind = Tilemap.getAutotileKind(tileId); + var shape = Tilemap.getAutotileShape(tileId); + var tx = kind % 8; + var ty = Math.floor(kind / 8); + var setNumber = 1; + var bx = tx * 2; + var by = (ty - 2) * 3; + var table = autotileTable[shape]; + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + for (var i = 0; i < 2; i++) { + var qsx = table[2 + i][0]; + var qsy = table[2 + i][1]; + var sx1 = (bx * 2 + qsx) * w1; + var sy1 = (by * 2 + qsy) * h1 + h1 / 2; + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + layer.addRect(setNumber, sx1, sy1, dx1, dy1, w1, h1/2); + } + } +}; + +ShaderTilemap.prototype._drawShadow = function(layer, shadowBits, dx, dy) { + if (shadowBits & 0x0f) { + var w1 = this._tileWidth / 2; + var h1 = this._tileHeight / 2; + for (var i = 0; i < 4; i++) { + if (shadowBits & (1 << i)) { + var dx1 = dx + (i % 2) * w1; + var dy1 = dy + Math.floor(i / 2) * h1; + layer.addRect(-1, 0, 0, dx1, dy1, w1, h1); + } + } + } +}; + +TilingSprite = function() { + this.initialize.apply(this, arguments); +} + +TilingSprite.prototype = Object.create(PIXI.extras.TilingSprite.prototype); +TilingSprite.prototype.constructor = TilingSprite; + +TilingSprite.prototype.initialize = function(bitmap) { + var texture = new PIXI.Texture(new PIXI.BaseTexture()); + + PIXI.extras.TilingSprite.call(this, texture); + + this._bitmap = null; + this._width = 0; + this._height = 0; + this._frame = new Rectangle(); + this.spriteId = Sprite._counter++; + this.origin = new Point(); + + this.bitmap = bitmap; +}; + +TilingSprite.prototype._renderCanvas_PIXI = PIXI.extras.TilingSprite.prototype._renderCanvas; +TilingSprite.prototype._renderWebGL_PIXI = PIXI.extras.TilingSprite.prototype._renderWebGL; + +TilingSprite.prototype._renderCanvas = function(renderer) { + if (this._bitmap) { + this._bitmap.touch(); + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + this._renderCanvas_PIXI(renderer); + } +}; + +TilingSprite.prototype._renderWebGL = function(renderer) { + if (this._bitmap) { + this._bitmap.touch(); + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + if (this._bitmap) { + this._bitmap.checkDirty(); + } + this._renderWebGL_PIXI(renderer); + } +}; + +Object.defineProperty(TilingSprite.prototype, 'bitmap', { + get: function() { + return this._bitmap; + }, + set: function(value) { + if (this._bitmap !== value) { + this._bitmap = value; + if (this._bitmap) { + this._bitmap.addLoadListener(this._onBitmapLoad.bind(this)); + } else { + this.texture.frame = Rectangle.emptyRectangle; + } + } + }, + configurable: true +}); + +Object.defineProperty(TilingSprite.prototype, 'opacity', { + get: function() { + return this.alpha * 255; + }, + set: function(value) { + this.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +TilingSprite.prototype.update = function() { + this.children.forEach(function(child) { + if (child.update) { + child.update(); + } + }); +}; + +TilingSprite.prototype.move = function(x, y, width, height) { + this.x = x || 0; + this.y = y || 0; + this._width = width || 0; + this._height = height || 0; +}; + +TilingSprite.prototype.setFrame = function(x, y, width, height) { + this._frame.x = x; + this._frame.y = y; + this._frame.width = width; + this._frame.height = height; + this._refresh(); +}; + +TilingSprite.prototype.updateTransform = function() { + this.tilePosition.x = Math.round(-this.origin.x); + this.tilePosition.y = Math.round(-this.origin.y); + this.updateTransformTS(); +}; + +TilingSprite.prototype.updateTransformTS = PIXI.extras.TilingSprite.prototype.updateTransform; + +TilingSprite.prototype._onBitmapLoad = function() { + this.texture.baseTexture = this._bitmap.baseTexture; + this._refresh(); +}; + +TilingSprite.prototype._refresh = function() { + var frame = this._frame.clone(); + if (frame.width === 0 && frame.height === 0 && this._bitmap) { + frame.width = this._bitmap.width; + frame.height = this._bitmap.height; + } + var lastTrim = this.texture.trim; + this.texture.trim = frame; + this.texture.frame = frame; + this.texture.trim = lastTrim; + this.tilingTexture = null; +}; + +ScreenSprite.prototype.initialize = function() { + var texture = new PIXI.Texture(new PIXI.BaseTexture()); + + PIXI.Sprite.call(this, texture); + + this._bitmap = new Bitmap(1, 1); + this.texture.baseTexture = this._bitmap.baseTexture; + this.texture.frame = new Rectangle(0, 0, 1, 1); + this.scale.x = Graphics.width; + this.scale.y = Graphics.height; + this.opacity = 0; + + this._red = -1; + this._green = -1; + this._blue = -1; + this._colorText = ''; + this.setBlack(); +}; + +ScreenSprite.prototype._renderCanvas = function(renderer) { + if (this.visible && this.alpha > 0) { + var context = renderer.context; + var t = this.worldTransform; + var r = renderer.resolution; + context.setTransform(t.a, t.b, t.c, t.d, t.tx * r, t.ty * r); + context.globalCompositeOperation = renderer.blendModes[this.blendMode]; + context.globalAlpha = this.alpha; + context.fillStyle = this._colorText; + context.fillRect(0, 0, Graphics.width, Graphics.height); + } +}; + +Window = function() { + this.initialize.apply(this, arguments); +} + +Window.prototype = Object.create(PIXI.Container.prototype); +Window.prototype.constructor = Window; + +Window.prototype.initialize = function() { + PIXI.Container.call(this); + + this._isWindow = true; + this._windowskin = null; + this._width = 0; + this._height = 0; + this._cursorRect = new Rectangle(); + this._openness = 255; + this._animationCount = 0; + + this._padding = 18; + this._margin = 4; + this._colorTone = [0, 0, 0]; + + this._windowSpriteContainer = null; + this._windowBackSprite = null; + this._windowCursorSprite = null; + this._windowFrameSprite = null; + this._windowContentsSprite = null; + this._windowArrowSprites = []; + this._windowPauseSignSprite = null; + + this._createAllParts(); + + this.origin = new Point(); + + this.active = true; + + this.downArrowVisible = false; + + this.upArrowVisible = false; + + this.pause = false; +}; + +Object.defineProperty(Window.prototype, 'windowskin', { + get: function() { + return this._windowskin; + }, + set: function(value) { + if (this._windowskin !== value) { + this._windowskin = value; + this._windowskin.addLoadListener(this._onWindowskinLoad.bind(this)); + } + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'contents', { + get: function() { + return this._windowContentsSprite.bitmap; + }, + set: function(value) { + this._windowContentsSprite.bitmap = value; + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'width', { + get: function() { + return this._width; + }, + set: function(value) { + this._width = value; + this._refreshAllParts(); + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'height', { + get: function() { + return this._height; + }, + set: function(value) { + this._height = value; + this._refreshAllParts(); + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'padding', { + get: function() { + return this._padding; + }, + set: function(value) { + this._padding = value; + this._refreshAllParts(); + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'margin', { + get: function() { + return this._margin; + }, + set: function(value) { + this._margin = value; + this._refreshAllParts(); + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'opacity', { + get: function() { + return this._windowSpriteContainer.alpha * 255; + }, + set: function(value) { + this._windowSpriteContainer.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'backOpacity', { + get: function() { + return this._windowBackSprite.alpha * 255; + }, + set: function(value) { + this._windowBackSprite.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'contentsOpacity', { + get: function() { + return this._windowContentsSprite.alpha * 255; + }, + set: function(value) { + this._windowContentsSprite.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +Object.defineProperty(Window.prototype, 'openness', { + get: function() { + return this._openness; + }, + set: function(value) { + if (this._openness !== value) { + this._openness = value.clamp(0, 255); + this._windowSpriteContainer.scale.y = this._openness / 255; + this._windowSpriteContainer.y = this.height / 2 * (1 - this._openness / 255); + } + }, + configurable: true +}); + +Window.prototype.update = function() { + if (this.active) { + this._animationCount++; + } + this.children.forEach(function(child) { + if (child.update) { + child.update(); + } + }); +}; + +Window.prototype.move = function(x, y, width, height) { + this.x = x || 0; + this.y = y || 0; + if (this._width !== width || this._height !== height) { + this._width = width || 0; + this._height = height || 0; + this._refreshAllParts(); + } +}; + +Window.prototype.isOpen = function() { + return this._openness >= 255; +}; + +Window.prototype.isClosed = function() { + return this._openness <= 0; +}; + +Window.prototype.setCursorRect = function(x, y, width, height) { + var cx = Math.floor(x || 0); + var cy = Math.floor(y || 0); + var cw = Math.floor(width || 0); + var ch = Math.floor(height || 0); + var rect = this._cursorRect; + if (rect.x !== cx || rect.y !== cy || rect.width !== cw || rect.height !== ch) { + this._cursorRect.x = cx; + this._cursorRect.y = cy; + this._cursorRect.width = cw; + this._cursorRect.height = ch; + this._refreshCursor(); + } +}; + +Window.prototype.setTone = function(r, g, b) { + var tone = this._colorTone; + if (r !== tone[0] || g !== tone[1] || b !== tone[2]) { + this._colorTone = [r, g, b]; + this._refreshBack(); + } +}; + +Window.prototype.addChildToBack = function(child) { + var containerIndex = this.children.indexOf(this._windowSpriteContainer); + return this.addChildAt(child, containerIndex + 1); +}; + +Window.prototype.updateTransform = function() { + this._updateCursor(); + this._updateArrows(); + this._updatePauseSign(); + this._updateContents(); + PIXI.Container.prototype.updateTransform.call(this); +}; + +Window.prototype._createAllParts = function() { + this._windowSpriteContainer = new PIXI.Container(); + this._windowBackSprite = new Sprite(); + this._windowCursorSprite = new Sprite(); + this._windowFrameSprite = new Sprite(); + this._windowContentsSprite = new Sprite(); + this._downArrowSprite = new Sprite(); + this._upArrowSprite = new Sprite(); + this._windowPauseSignSprite = new Sprite(); + this._windowBackSprite.bitmap = new Bitmap(1, 1); + this._windowBackSprite.alpha = 192 / 255; + this.addChild(this._windowSpriteContainer); + this._windowSpriteContainer.addChild(this._windowBackSprite); + this._windowSpriteContainer.addChild(this._windowFrameSprite); + this.addChild(this._windowCursorSprite); + this.addChild(this._windowContentsSprite); + this.addChild(this._downArrowSprite); + this.addChild(this._upArrowSprite); + this.addChild(this._windowPauseSignSprite); +}; + +Window.prototype._onWindowskinLoad = function() { + this._refreshAllParts(); +}; + +Window.prototype._refreshAllParts = function() { + this._refreshBack(); + this._refreshFrame(); + this._refreshCursor(); + this._refreshContents(); + this._refreshArrows(); + this._refreshPauseSign(); +}; + +Window.prototype._refreshBack = function() { + var m = this._margin; + var w = this._width - m * 2; + var h = this._height - m * 2; + var bitmap = new Bitmap(w, h); + + this._windowBackSprite.bitmap = bitmap; + this._windowBackSprite.setFrame(0, 0, w, h); + this._windowBackSprite.move(m, m); + + if (w > 0 && h > 0 && this._windowskin) { + var p = 96; + bitmap.blt(this._windowskin, 0, 0, p, p, 0, 0, w, h); + for (var y = 0; y < h; y += p) { + for (var x = 0; x < w; x += p) { + bitmap.blt(this._windowskin, 0, p, p, p, x, y, p, p); + } + } + var tone = this._colorTone; + bitmap.adjustTone(tone[0], tone[1], tone[2]); + } +}; + +Window.prototype._refreshFrame = function() { + var w = this._width; + var h = this._height; + var m = 24; + var bitmap = new Bitmap(w, h); + + this._windowFrameSprite.bitmap = bitmap; + this._windowFrameSprite.setFrame(0, 0, w, h); + + if (w > 0 && h > 0 && this._windowskin) { + var skin = this._windowskin; + var p = 96; + var q = 96; + bitmap.blt(skin, p+m, 0+0, p-m*2, m, m, 0, w-m*2, m); + bitmap.blt(skin, p+m, 0+q-m, p-m*2, m, m, h-m, w-m*2, m); + bitmap.blt(skin, p+0, 0+m, m, p-m*2, 0, m, m, h-m*2); + bitmap.blt(skin, p+q-m, 0+m, m, p-m*2, w-m, m, m, h-m*2); + bitmap.blt(skin, p+0, 0+0, m, m, 0, 0, m, m); + bitmap.blt(skin, p+q-m, 0+0, m, m, w-m, 0, m, m); + bitmap.blt(skin, p+0, 0+q-m, m, m, 0, h-m, m, m); + bitmap.blt(skin, p+q-m, 0+q-m, m, m, w-m, h-m, m, m); + } +}; + +Window.prototype._refreshCursor = function() { + var pad = this._padding; + var x = this._cursorRect.x + pad - this.origin.x; + var y = this._cursorRect.y + pad - this.origin.y; + var w = this._cursorRect.width; + var h = this._cursorRect.height; + var m = 4; + var x2 = Math.max(x, pad); + var y2 = Math.max(y, pad); + var ox = x - x2; + var oy = y - y2; + var w2 = Math.min(w, this._width - pad - x2); + var h2 = Math.min(h, this._height - pad - y2); + var bitmap = new Bitmap(w2, h2); + + this._windowCursorSprite.bitmap = bitmap; + this._windowCursorSprite.setFrame(0, 0, w2, h2); + this._windowCursorSprite.move(x2, y2); + + if (w > 0 && h > 0 && this._windowskin) { + var skin = this._windowskin; + var p = 96; + var q = 48; + bitmap.blt(skin, p+m, p+m, q-m*2, q-m*2, ox+m, oy+m, w-m*2, h-m*2); + bitmap.blt(skin, p+m, p+0, q-m*2, m, ox+m, oy+0, w-m*2, m); + bitmap.blt(skin, p+m, p+q-m, q-m*2, m, ox+m, oy+h-m, w-m*2, m); + bitmap.blt(skin, p+0, p+m, m, q-m*2, ox+0, oy+m, m, h-m*2); + bitmap.blt(skin, p+q-m, p+m, m, q-m*2, ox+w-m, oy+m, m, h-m*2); + bitmap.blt(skin, p+0, p+0, m, m, ox+0, oy+0, m, m); + bitmap.blt(skin, p+q-m, p+0, m, m, ox+w-m, oy+0, m, m); + bitmap.blt(skin, p+0, p+q-m, m, m, ox+0, oy+h-m, m, m); + bitmap.blt(skin, p+q-m, p+q-m, m, m, ox+w-m, oy+h-m, m, m); + } +}; + +Window.prototype._refreshContents = function() { + this._windowContentsSprite.move(this.padding, this.padding); +}; + +Window.prototype._refreshArrows = function() { + var w = this._width; + var h = this._height; + var p = 24; + var q = p/2; + var sx = 96+p; + var sy = 0+p; + this._downArrowSprite.bitmap = this._windowskin; + this._downArrowSprite.anchor.x = 0.5; + this._downArrowSprite.anchor.y = 0.5; + this._downArrowSprite.setFrame(sx+q, sy+q+p, p, q); + this._downArrowSprite.move(w/2, h-q); + this._upArrowSprite.bitmap = this._windowskin; + this._upArrowSprite.anchor.x = 0.5; + this._upArrowSprite.anchor.y = 0.5; + this._upArrowSprite.setFrame(sx+q, sy, p, q); + this._upArrowSprite.move(w/2, q); +}; + +Window.prototype._refreshPauseSign = function() { + var sx = 144; + var sy = 96; + var p = 24; + this._windowPauseSignSprite.bitmap = this._windowskin; + this._windowPauseSignSprite.anchor.x = 0.5; + this._windowPauseSignSprite.anchor.y = 1; + this._windowPauseSignSprite.move(this._width / 2, this._height); + this._windowPauseSignSprite.setFrame(sx, sy, p, p); + this._windowPauseSignSprite.alpha = 0; +}; + +Window.prototype._updateCursor = function() { + var blinkCount = this._animationCount % 40; + var cursorOpacity = this.contentsOpacity; + if (this.active) { + if (blinkCount < 20) { + cursorOpacity -= blinkCount * 8; + } else { + cursorOpacity -= (40 - blinkCount) * 8; + } + } + this._windowCursorSprite.alpha = cursorOpacity / 255; + this._windowCursorSprite.visible = this.isOpen(); +}; + +Window.prototype._updateContents = function() { + var w = this._width - this._padding * 2; + var h = this._height - this._padding * 2; + if (w > 0 && h > 0) { + this._windowContentsSprite.setFrame(this.origin.x, this.origin.y, w, h); + this._windowContentsSprite.visible = this.isOpen(); + } else { + this._windowContentsSprite.visible = false; + } +}; + +Window.prototype._updateArrows = function() { + this._downArrowSprite.visible = this.isOpen() && this.downArrowVisible; + this._upArrowSprite.visible = this.isOpen() && this.upArrowVisible; +}; + +Window.prototype._updatePauseSign = function() { + var sprite = this._windowPauseSignSprite; + var x = Math.floor(this._animationCount / 16) % 2; + var y = Math.floor(this._animationCount / 16 / 2) % 2; + var sx = 144; + var sy = 96; + var p = 24; + if (!this.pause) { + sprite.alpha = 0; + } else if (sprite.alpha < 1) { + sprite.alpha = Math.min(sprite.alpha + 0.1, 1); + } + sprite.setFrame(sx+x*p, sy+y*p, p, p); + sprite.visible = this.isOpen(); +}; + +WindowLayer = function() { + this.initialize.apply(this, arguments); +} + +WindowLayer.prototype = Object.create(PIXI.Container.prototype); +WindowLayer.prototype.constructor = WindowLayer; + +WindowLayer.prototype.initialize = function() { + PIXI.Container.call(this); + this._width = 0; + this._height = 0; + this._tempCanvas = null; + this._translationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1]; + + this._windowMask = new PIXI.Graphics(); + this._windowMask.beginFill(0xffffff, 1); + this._windowMask.drawRect(0, 0, 0, 0); + this._windowMask.endFill(); + this._windowRect = this._windowMask.graphicsData[0].shape; + + this._renderSprite = null; + this.filterArea = new PIXI.Rectangle(); + this.filters = [WindowLayer.voidFilter]; +}; + +WindowLayer.voidFilter = new PIXI.filters.VoidFilter(); + +Object.defineProperty(WindowLayer.prototype, 'width', { + get: function() { + return this._width; + }, + set: function(value) { + this._width = value; + }, + configurable: true +}); + +Object.defineProperty(WindowLayer.prototype, 'height', { + get: function() { + return this._height; + }, + set: function(value) { + this._height = value; + }, + configurable: true +}); + +WindowLayer.prototype.move = function(x, y, width, height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; +}; + +WindowLayer.prototype.update = function() { + this.children.forEach(function(child) { + if (child.update) { + child.update(); + } + }); +}; + +WindowLayer.prototype.renderCanvas = function(renderer) { + if (!this.visible || !this.renderable) { + return; + } + + if (!this._tempCanvas) { + this._tempCanvas = document.createElement('canvas'); + } + + this._tempCanvas.width = Graphics.width; + this._tempCanvas.height = Graphics.height; + + var realCanvasContext = renderer.context; + var context = this._tempCanvas.getContext('2d'); + + context.save(); + context.clearRect(0, 0, Graphics.width, Graphics.height); + context.beginPath(); + context.rect(this.x, this.y, this.width, this.height); + context.closePath(); + context.clip(); + + renderer.context = context; + + for (var i = 0; i < this.children.length; i++) { + var child = this.children[i]; + if (child._isWindow && child.visible && child.openness > 0) { + this._canvasClearWindowRect(renderer, child); + context.save(); + child.renderCanvas(renderer); + context.restore(); + } + } + + context.restore(); + + renderer.context = realCanvasContext; + renderer.context.setTransform(1, 0, 0, 1, 0, 0); + renderer.context.globalCompositeOperation = 'source-over'; + renderer.context.globalAlpha = 1; + renderer.context.drawImage(this._tempCanvas, 0, 0); + + for (var j = 0; j < this.children.length; j++) { + if (!this.children[j]._isWindow) { + this.children[j].renderCanvas(renderer); + } + } +}; + +WindowLayer.prototype._canvasClearWindowRect = function(renderSession, window) { + var rx = this.x + window.x; + var ry = this.y + window.y + window.height / 2 * (1 - window._openness / 255); + var rw = window.width; + var rh = window.height * window._openness / 255; + renderSession.context.clearRect(rx, ry, rw, rh); +}; + +WindowLayer.prototype.renderWebGL = function(renderer) { + if (!this.visible || !this.renderable) { + return; + } + + renderer.currentRenderer.flush(); + this.filterArea.copy(this); + renderer.filterManager.pushFilter(this, this.filters); + renderer.currentRenderer.start(); + + for (var i = 0; i < this.children.length; i++) { + var child = this.children[i]; + if (child._isWindow && child.visible && child.openness > 0) { + this._maskWindow(child); + renderer.maskManager.pushScissorMask(this, this._windowMask); + renderer.clear(); + renderer.maskManager.popScissorMask(); + renderer.currentRenderer.start(); + child.renderWebGL(renderer); + renderer.currentRenderer.flush(); + } + } + + renderer.filterManager.popFilter(); + renderer.maskManager.popScissorMask(); + + for (var j = 0; j < this.children.length; j++) { + if (!this.children[j]._isWindow) { + this.children[j].renderWebGL(renderer); + } + } +}; + +WindowLayer.prototype._maskWindow = function(window) { + this._windowMask._currentBounds = null; + this._windowMask.boundsDirty = true; + var rect = this._windowRect; + rect.x = window.x; + rect.y = window.y + window.height / 2 * (1 - window._openness / 255); + rect.width = window.width; + rect.height = window.height * window._openness / 255; +}; + +Weather = function() { + this.initialize.apply(this, arguments); +} + +Weather.prototype = Object.create(PIXI.Container.prototype); +Weather.prototype.constructor = Weather; + +Weather.prototype.initialize = function() { + PIXI.Container.call(this); + + this._width = Graphics.width; + this._height = Graphics.height; + this._sprites = []; + + this._createBitmaps(); + this._createDimmer(); + + this.type = 'none'; + + this.power = 0; + + this.origin = new Point(); +}; + +Weather.prototype.update = function() { + this._updateDimmer(); + this._updateAllSprites(); +}; + +Weather.prototype._createBitmaps = function() { + this._rainBitmap = new Bitmap(1, 60); + this._rainBitmap.fillAll('white'); + this._stormBitmap = new Bitmap(2, 100); + this._stormBitmap.fillAll('white'); + this._snowBitmap = new Bitmap(9, 9); + this._snowBitmap.drawCircle(4, 4, 4, 'white'); +}; + +Weather.prototype._createDimmer = function() { + this._dimmerSprite = new ScreenSprite(); + this._dimmerSprite.setColor(80, 80, 80); + this.addChild(this._dimmerSprite); +}; + +Weather.prototype._updateDimmer = function() { + this._dimmerSprite.opacity = Math.floor(this.power * 6); +}; + +Weather.prototype._updateAllSprites = function() { + var maxSprites = Math.floor(this.power * 10); + while (this._sprites.length < maxSprites) { + this._addSprite(); + } + while (this._sprites.length > maxSprites) { + this._removeSprite(); + } + this._sprites.forEach(function(sprite) { + this._updateSprite(sprite); + sprite.x = sprite.ax - this.origin.x; + sprite.y = sprite.ay - this.origin.y; + }, this); +}; + +Weather.prototype._addSprite = function() { + var sprite = new Sprite(this.viewport); + sprite.opacity = 0; + this._sprites.push(sprite); + this.addChild(sprite); +}; + +Weather.prototype._removeSprite = function() { + this.removeChild(this._sprites.pop()); +}; + +Weather.prototype._updateSprite = function(sprite) { + switch (this.type) { + case 'rain': + this._updateRainSprite(sprite); + break; + case 'storm': + this._updateStormSprite(sprite); + break; + case 'snow': + this._updateSnowSprite(sprite); + break; + } + if (sprite.opacity < 40) { + this._rebornSprite(sprite); + } +}; + +Weather.prototype._updateRainSprite = function(sprite) { + sprite.bitmap = this._rainBitmap; + sprite.rotation = Math.PI / 16; + sprite.ax -= 6 * Math.sin(sprite.rotation); + sprite.ay += 6 * Math.cos(sprite.rotation); + sprite.opacity -= 6; +}; + +Weather.prototype._updateStormSprite = function(sprite) { + sprite.bitmap = this._stormBitmap; + sprite.rotation = Math.PI / 8; + sprite.ax -= 8 * Math.sin(sprite.rotation); + sprite.ay += 8 * Math.cos(sprite.rotation); + sprite.opacity -= 8; +}; + +Weather.prototype._updateSnowSprite = function(sprite) { + sprite.bitmap = this._snowBitmap; + sprite.rotation = Math.PI / 16; + sprite.ax -= 3 * Math.sin(sprite.rotation); + sprite.ay += 3 * Math.cos(sprite.rotation); + sprite.opacity -= 3; +}; + +Weather.prototype._rebornSprite = function(sprite) { + sprite.ax = Math.randomInt(Graphics.width + 100) - 100 + this.origin.x; + sprite.ay = Math.randomInt(Graphics.height + 200) - 200 + this.origin.y; + sprite.opacity = 160 + Math.randomInt(60); +}; + +ToneFilter = function() { + PIXI.filters.ColorMatrixFilter.call(this); +} + +ToneFilter.prototype = Object.create(PIXI.filters.ColorMatrixFilter.prototype); +ToneFilter.prototype.constructor = ToneFilter; + +ToneFilter.prototype.adjustHue = function(value) { + this.hue(value, true); +}; + +ToneFilter.prototype.adjustSaturation = function(value) { + value = (value || 0).clamp(-255, 255) / 255; + this.saturate(value, true); +}; + +ToneFilter.prototype.adjustTone = function(r, g, b) { + r = (r || 0).clamp(-255, 255) / 255; + g = (g || 0).clamp(-255, 255) / 255; + b = (b || 0).clamp(-255, 255) / 255; + + if (r !== 0 || g !== 0 || b !== 0) { + var matrix = [ + 1, 0, 0, r, 0, + 0, 1, 0, g, 0, + 0, 0, 1, b, 0, + 0, 0, 0, 1, 0 + ]; + + this._loadMatrix(matrix, true); + } +}; + +ToneSprite = function() { + this.initialize.apply(this, arguments); +} + +ToneSprite.prototype = Object.create(PIXI.Container.prototype); +ToneSprite.prototype.constructor = ToneSprite; + +ToneSprite.prototype.initialize = function() { + PIXI.Container.call(this); + this.clear(); +}; + +ToneSprite.prototype.clear = function() { + this._red = 0; + this._green = 0; + this._blue = 0; + this._gray = 0; +}; + +ToneSprite.prototype.setTone = function(r, g, b, gray) { + this._red = Math.round(r || 0).clamp(-255, 255); + this._green = Math.round(g || 0).clamp(-255, 255); + this._blue = Math.round(b || 0).clamp(-255, 255); + this._gray = Math.round(gray || 0).clamp(0, 255); +}; + +ToneSprite.prototype._renderCanvas = function(renderer) { + if (this.visible) { + var context = renderer.context; + var t = this.worldTransform; + var r = renderer.resolution; + var width = Graphics.width; + var height = Graphics.height; + context.save(); + context.setTransform(t.a, t.b, t.c, t.d, t.tx * r, t.ty * r); + if (Graphics.canUseSaturationBlend() && this._gray > 0) { + context.globalCompositeOperation = 'saturation'; + context.globalAlpha = this._gray / 255; + context.fillStyle = '#ffffff'; + context.fillRect(0, 0, width, height); + } + context.globalAlpha = 1; + var r1 = Math.max(0, this._red); + var g1 = Math.max(0, this._green); + var b1 = Math.max(0, this._blue); + if (r1 || g1 || b1) { + context.globalCompositeOperation = 'lighter'; + context.fillStyle = Utils.rgbToCssColor(r1, g1, b1); + context.fillRect(0, 0, width, height); + } + if (Graphics.canUseDifferenceBlend()) { + var r2 = Math.max(0, -this._red); + var g2 = Math.max(0, -this._green); + var b2 = Math.max(0, -this._blue); + if (r2 || g2 || b2) { + context.globalCompositeOperation = 'difference'; + context.fillStyle = '#ffffff'; + context.fillRect(0, 0, width, height); + context.globalCompositeOperation = 'lighter'; + context.fillStyle = Utils.rgbToCssColor(r2, g2, b2); + context.fillRect(0, 0, width, height); + context.globalCompositeOperation = 'difference'; + context.fillStyle = '#ffffff'; + context.fillRect(0, 0, width, height); + } + } + context.restore(); + } +}; + +ToneSprite.prototype._renderWebGL = function(renderer) { +}; + +Stage = function() { + this.initialize.apply(this, arguments); +} + +Stage.prototype = Object.create(PIXI.Container.prototype); +Stage.prototype.constructor = Stage; + +Stage.prototype.initialize = function() { + PIXI.Container.call(this); + this.interactive = false; +}; + +WebAudio.prototype._load = function(url) { + if (WebAudio._context) { + var xhr = new XMLHttpRequest(); + if(Decrypter.hasEncryptedAudio) url = Decrypter.extToEncryptExt(url); + xhr.open('GET', url); + xhr.responseType = 'arraybuffer'; + xhr.onload = function() { + if (xhr.status < 400) { + this._onXhrLoad(xhr); + } + }.bind(this); + xhr.onerror = function() { + this._hasError = true; + }.bind(this); + xhr.send(); + } +}; + +WebAudio.prototype._onXhrLoad = function(xhr) { + var array = xhr.response; + this._readLoopComments(array); + if(Decrypter.hasEncryptedAudio) array = Decrypter.decryptArrayBuffer(array); + WebAudio._context.decodeAudioData(array, function(buffer) { + this._buffer = buffer; + this._totalTime = buffer.duration; + if (this._loopLength > 0 && this._sampleRate > 0) { + this._loopStart /= this._sampleRate; + this._loopLength /= this._sampleRate; + } else { + this._loopStart = 0; + this._loopLength = this._totalTime; + } + this._onLoad(); + }.bind(this)); +}; + +Html5Audio.setup = function(url) { + if (!this._initialized) { + this.initialize(); + } + this.clear(); + + if(Decrypter.hasEncryptedAudio && this._audioElement.src) { + window.URL.revokeObjectURL(this._audioElement.src); + } + this._url = url; +}; + +Decrypter = function() { + throw new Error('This is a static class'); +} + +Decrypter.hasEncryptedImages = false; +Decrypter.hasEncryptedAudio = false; +Decrypter._requestImgFile = []; +Decrypter._headerlength = 16; +Decrypter._xhrOk = 400; +Decrypter._encryptionKey = ""; +Decrypter._ignoreList = [ + "img/system/Window.png" +]; +Decrypter.SIGNATURE = "5250474d56000000"; +Decrypter.VER = "000301"; +Decrypter.REMAIN = "0000000000"; + +Decrypter.checkImgIgnore = function(url){ + for(var cnt = 0; cnt < this._ignoreList.length; cnt++) { + if(url === this._ignoreList[cnt]) return true; + } + return false; +}; + +Decrypter.decryptImg = function(url, bitmap) { + url = this.extToEncryptExt(url); + + var requestFile = new XMLHttpRequest(); + requestFile.open("GET", url); + requestFile.responseType = "arraybuffer"; + requestFile.send(); + + requestFile.onload = function() { + if(this.status < Decrypter._xhrOk) { + var arrayBuffer = Decrypter.decryptArrayBuffer(requestFile.response); + bitmap._image.src = Decrypter.createBlobUrl(arrayBuffer); + bitmap._image.onload = Bitmap.prototype._onLoad.bind(bitmap); + bitmap._image.onerror = Bitmap.prototype._onError.bind(bitmap); + } + }; +}; + +Decrypter.decryptHTML5Audio = function(url, bgm, pos) { + var requestFile = new XMLHttpRequest(); + requestFile.open("GET", url); + requestFile.responseType = "arraybuffer"; + requestFile.send(); + + requestFile.onload = function() { + if(this.status < Decrypter._xhrOk) { + var arrayBuffer = Decrypter.decryptArrayBuffer(requestFile.response); + var url = Decrypter.createBlobUrl(arrayBuffer); + AudioManager.createDecryptBuffer(url, bgm, pos); + } + }; +}; + +Decrypter.cutArrayHeader = function(arrayBuffer, length) { + return arrayBuffer.slice(length); +}; + +Decrypter.decryptArrayBuffer = function(arrayBuffer) { + if (!arrayBuffer) return null; + var header = new Uint8Array(arrayBuffer, 0, this._headerlength); + + var i; + var ref = this.SIGNATURE + this.VER + this.REMAIN; + var refBytes = new Uint8Array(16); + for (i = 0; i < this._headerlength; i++) { + refBytes[i] = parseInt("0x" + ref.substr(i * 2, 2), 16); + } + for (i = 0; i < this._headerlength; i++) { + if (header[i] !== refBytes[i]) { + throw new Error("Header is wrong"); + } + } + + arrayBuffer = this.cutArrayHeader(arrayBuffer, Decrypter._headerlength); + var view = new DataView(arrayBuffer); + this.readEncryptionkey(); + if (arrayBuffer) { + var byteArray = new Uint8Array(arrayBuffer); + for (i = 0; i < this._headerlength; i++) { + byteArray[i] = byteArray[i] ^ parseInt(Decrypter._encryptionKey[i], 16); + view.setUint8(i, byteArray[i]); + } + } + + return arrayBuffer; +}; + +Decrypter.createBlobUrl = function(arrayBuffer){ + var blob = new Blob([arrayBuffer]); + return window.URL.createObjectURL(blob); +}; + +Decrypter.extToEncryptExt = function(url) { + var ext = url.split('.').pop(); + var encryptedExt = ext; + + if(ext === "ogg") encryptedExt = ".rpgmvo"; + else if(ext === "m4a") encryptedExt = ".rpgmvm"; + else if(ext === "png") encryptedExt = ".rpgmvp"; + else encryptedExt = ext; + + return url.slice(0, url.lastIndexOf(ext) - 1) + encryptedExt; +}; + +Decrypter.readEncryptionkey = function(){ + this._encryptionKey = $dataSystem.encryptionKey.split(/(.{2})/).filter(Boolean); +}; + +//----------------------------------------------------------------------------- +// 1.3.0 rpg_managers.js changes +//----------------------------------------------------------------------------- + +DataManager.onLoad = function(object) { + var array; + if (object === $dataMap) { + this.extractMetadata(object); + array = object.events; + } else { + array = object; + } + if (Array.isArray(array)) { + for (var i = 0; i < array.length; i++) { + var data = array[i]; + if (data && data.note !== undefined) { + this.extractMetadata(data); + } + } + } + if (object === $dataSystem) { + Decrypter.hasEncryptedImages = !!object.hasEncryptedImages; + Decrypter.hasEncryptedAudio = !!object.hasEncryptedAudio; + Scene_Boot.loadSystemImages(); + } +}; + +StorageManager.restoreBackup = function(savefileId) { + if (this.backupExists(savefileId)) { + if (this.isLocalMode()) { + var data = this.loadFromLocalBackupFile(savefileId); + var compressed = LZString.compressToBase64(data); + var fs = require('fs'); + var dirPath = this.localFileDirectoryPath(); + var filePath = this.localFilePath(savefileId); + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath); + } + fs.writeFileSync(filePath, compressed); + fs.unlinkSync(filePath + ".bak"); + } else { + var data = this.loadFromWebStorageBackup(savefileId); + var compressed = LZString.compressToBase64(data); + var key = this.webStorageKey(savefileId); + localStorage.setItem(key, compressed); + localStorage.removeItem(key + "bak"); + } + } +}; + +StorageManager.localFileDirectoryPath = function() { + var path = require('path'); + + var base = path.dirname(process.mainModule.filename); + return path.join(base, 'save/'); +}; + +ImageManager.cache = new CacheMap(ImageManager); + +ImageManager.loadEmptyBitmap = function() { + var empty = this.cache.getItem('empty'); + if (!empty) { + empty = new Bitmap(); + this.cache.setItem('empty', empty); + } + return empty; +}; + +ImageManager.loadNormalBitmap = function(path, hue) { + var key = path + ':' + hue; + var bitmap = this.cache.getItem(key); + if (!bitmap) { + bitmap = Bitmap.load(path); + bitmap.addLoadListener(function() { + bitmap.rotateHue(hue); + }); + this.cache.setItem(key, bitmap); + } + return bitmap; +}; + +ImageManager.clear = function() { + this.cache.clear(); +}; + +ImageManager.isReady = function() { + for (var key in this.cache._inner) { + var bitmap = this.cache._inner[key].item; + if (bitmap.isError()) { + throw new Error('Failed to load: ' + bitmap.url); + } + if (!bitmap.isReady()) { + return false; + } + } + return true; +}; + +AudioManager._blobUrl = null; + +AudioManager.playBgm = function(bgm, pos) { + if (this.isCurrentBgm(bgm)) { + this.updateBgmParameters(bgm); + } else { + this.stopBgm(); + if (bgm.name) { + if(Decrypter.hasEncryptedAudio && this.shouldUseHtml5Audio()){ + this.playEncryptedBgm(bgm, pos); + } + else { + this._bgmBuffer = this.createBuffer('bgm', bgm.name); + this.updateBgmParameters(bgm); + if (!this._meBuffer) { + this._bgmBuffer.play(true, pos || 0); + } + } + } + } + this.updateCurrentBgm(bgm, pos); +}; + +AudioManager.playEncryptedBgm = function(bgm, pos) { + var ext = this.audioFileExt(); + var url = this._path + 'bgm/' + encodeURIComponent(bgm.name) + ext; + url = Decrypter.extToEncryptExt(url); + Decrypter.decryptHTML5Audio(url, bgm, pos); +}; + +AudioManager.createBuffer = function(folder, name) { + var ext = this.audioFileExt(); + var url = this._path + folder + '/' + encodeURIComponent(name) + ext; + if (this.shouldUseHtml5Audio() && folder === 'bgm') { + if(this._blobUrl) Html5Audio.setup(this._blobUrl); + else Html5Audio.setup(url); + return Html5Audio; + } else { + return new WebAudio(url); + } +}; + +AudioManager.shouldUseHtml5Audio = function() { + // We use HTML5 Audio to play BGM instead of Web Audio API + // because decodeAudioData() is very slow on Android Chrome. + return Utils.isAndroidChrome() && !Decrypter.hasEncryptedAudio; +}; + +SceneManager.update = function() { + try { + this.tickStart(); + if (Utils.isMobileSafari()) { + this.updateInputData(); + } + this.updateMain(); + this.tickEnd(); + } catch (e) { + this.catchException(e); + } +}; + +SceneManager.onKeyDown = function(event) { + if (!event.ctrlKey && !event.altKey) { + switch (event.keyCode) { + case 116: // F5 + if (Utils.isNwjs()) { + location.reload(); + } + break; + case 119: // F8 + if (Utils.isNwjs() && Utils.isOptionValid('test')) { + require('nw.gui').Window.get().showDevTools(); + } + break; + } + } +}; + +SceneManager.updateMain = function() { + if (Utils.isMobileSafari()) { + this.changeScene(); + this.updateScene(); + } else { + var newTime = this._getTimeInMs(); + var fTime = (newTime - this._currentTime) / 1000; + if (fTime > 0.25) fTime = 0.25; + this._currentTime = newTime; + this._accumulator += fTime; + while (this._accumulator >= this._deltaTime) { + this.updateInputData(); + this.changeScene(); + this.updateScene(); + this._accumulator -= this._deltaTime; + } + } + this.renderScene(); + this.requestUpdate(); +}; + +SceneManager.updateManagers = function(ticks, delta) { + ImageManager.cache.update(ticks, delta); +}; + +//----------------------------------------------------------------------------- +// 1.3.0 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_BattlerBase.prototype.tpRate = function() { + return this.tp / this.maxTp(); +}; + +//----------------------------------------------------------------------------- +// 1.3.0 rpg_scenes.js changes +//----------------------------------------------------------------------------- + +Scene_Boot.prototype.create = function() { + Scene_Base.prototype.create.call(this); + DataManager.loadDatabase(); + ConfigManager.load(); + this.loadSystemWindowImage(); +}; + +Scene_Boot.prototype.loadSystemWindowImage = function() { + ImageManager.loadSystem('Window'); +}; + +Scene_Boot.loadSystemImages = function() { + ImageManager.loadSystem('IconSet'); + ImageManager.loadSystem('Balloon'); + ImageManager.loadSystem('Shadow1'); + ImageManager.loadSystem('Shadow2'); + ImageManager.loadSystem('Damage'); + ImageManager.loadSystem('States'); + ImageManager.loadSystem('Weapons1'); + ImageManager.loadSystem('Weapons2'); + ImageManager.loadSystem('Weapons3'); + ImageManager.loadSystem('ButtonSet'); +}; + +//----------------------------------------------------------------------------- +// 1.3.0 rpg_sprites.js changes +//----------------------------------------------------------------------------- + +Sprite_Animation.prototype.initialize = function() { + Sprite.prototype.initialize.call(this); + this._reduceArtifacts = true; + this.initMembers(); +}; + +Sprite_Picture.prototype.initialize = function(pictureId) { + Sprite.prototype.initialize.call(this); + this._pictureId = pictureId; + this._pictureName = ''; + this._isPicture = true; + this.update(); +}; + +Spriteset_Map.prototype.createTilemap = function() { + if (Graphics.isWebGL()) { + this._tilemap = new ShaderTilemap(); + } else { + this._tilemap = new Tilemap(); + } + this._tilemap.tileWidth = $gameMap.tileWidth(); + this._tilemap.tileHeight = $gameMap.tileHeight(); + this._tilemap.setData($gameMap.width(), $gameMap.height(), $gameMap.data()); + this._tilemap.horizontalWrap = $gameMap.isLoopHorizontal(); + this._tilemap.verticalWrap = $gameMap.isLoopVertical(); + this.loadTileset(); + this._baseSprite.addChild(this._tilemap); +}; + +Spriteset_Map.prototype.loadTileset = function() { + this._tileset = $gameMap.tileset(); + if (this._tileset) { + var tilesetNames = this._tileset.tilesetNames; + for (var i = 0; i < tilesetNames.length; i++) { + this._tilemap.bitmaps[i] = ImageManager.loadTileset(tilesetNames[i]); + } + var newTilesetFlags = $gameMap.tilesetFlags(); + this._tilemap.refreshTileset(); + if (!this._tilemap.flags.equals(newTilesetFlags)) { + this._tilemap.refresh(); + } + this._tilemap.flags = newTilesetFlags; + } +}; + +//============================================================================= +// Version 1.2.0 to 1.3.0 Changes End +//============================================================================= + +}; // Yanfly.Param.Update130 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.3.0 to 1.3.1 Changes +//============================================================================= + +if (Yanfly.Param.Update131) { + +//----------------------------------------------------------------------------- +// 1.3.1 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.3.1. +Utils.RPGMAKER_VERSION = '1.3.1'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +CacheEntry.prototype.free = function (byTTL) { + this.freedByTTL = byTTL || false; + if (this.cached) { + this.cached = false; + delete this.cache._inner[this.key]; + } +}; + +PIXI.GC_MODES.DEFAULT = PIXI.GC_MODES.AUTO; +PIXI.tilemap.TileRenderer.SCALE_MODE = PIXI.SCALE_MODES.NEAREST; + +ScreenSprite = function() { + this.initialize.apply(this, arguments); +} + +ScreenSprite.prototype = Object.create(PIXI.Container.prototype); +ScreenSprite.prototype.constructor = ScreenSprite; + +ScreenSprite.prototype.initialize = function () { + PIXI.Container.call(this); + + this._graphics = new PIXI.Graphics(); + this.addChild(this._graphics); + this.opacity = 0; + + this._red = -1; + this._green = -1; + this._blue = -1; + this._colorText = ''; + this.setBlack(); +}; + +Object.defineProperty(ScreenSprite.prototype, 'opacity', { + get: function () { + return this.alpha * 255; + }, + set: function (value) { + this.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +ScreenSprite.YEPWarned = false; +ScreenSprite.warnYep = function () { + if (!ScreenSprite.YEPWarned) { + console.log("Deprecation warning. Please update YEP_CoreEngine. ScreenSprite is not a sprite, it has graphics inside."); + ScreenSprite.YEPWarned = true; + } +}; + +Object.defineProperty(ScreenSprite.prototype, 'anchor', { + get: function () { + ScreenSprite.warnYep(); + this.scale.x = 1; + this.scale.y = 1; + return {x: 0, y: 0}; + }, + set: function (value) { + this.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +Object.defineProperty(ScreenSprite.prototype, 'blendMode', { + get: function () { + return this._graphics.blendMode; + }, + set: function (value) { + this._graphics.blendMode = value; + }, + configurable: true +}); + +ScreenSprite.prototype.setBlack = function () { + this.setColor(0, 0, 0); +}; + +ScreenSprite.prototype.setWhite = function () { + this.setColor(255, 255, 255); +}; + +ScreenSprite.prototype.setColor = function (r, g, b) { + if (this._red !== r || this._green !== g || this._blue !== b) { + r = Math.round(r || 0).clamp(0, 255); + g = Math.round(g || 0).clamp(0, 255); + b = Math.round(b || 0).clamp(0, 255); + this._red = r; + this._green = g; + this._blue = b; + this._colorText = Utils.rgbToCssColor(r, g, b); + + var graphics = this._graphics; + graphics.clear(); + var intColor = (r << 16) | (g << 8) | b; + graphics.beginFill(intColor, 1); + graphics.drawRect(-Graphics.width * 5, -Graphics.height * 5, Graphics.width * 10, Graphics.height * 10); + } +}; + +WebAudio.prototype._onXhrLoad = function(xhr) { + var array = xhr.response; + if(Decrypter.hasEncryptedAudio) array = Decrypter.decryptArrayBuffer(array); + this._readLoopComments(new Uint8Array(array)); + WebAudio._context.decodeAudioData(array, function(buffer) { + this._buffer = buffer; + this._totalTime = buffer.duration; + if (this._loopLength > 0 && this._sampleRate > 0) { + this._loopStart /= this._sampleRate; + this._loopLength /= this._sampleRate; + } else { + this._loopStart = 0; + this._loopLength = this._totalTime; + } + this._onLoad(); + }.bind(this)); +}; + +//============================================================================= +// Version 1.3.0 to 1.3.1 Changes End +//============================================================================= + +}; // Yanfly.Param.Update131 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.3.1 to 1.3.2 Changes +//============================================================================= + +if (Yanfly.Param.Update132) { + +//----------------------------------------------------------------------------- +// 1.3.2 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.3.2. +Utils.RPGMAKER_VERSION = '1.3.2'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +var waitForLoading = false; +var register = false; + +handleiOSTouch = function(ev) { + if (Graphics._video.paused && Graphics.isVideoPlaying())Graphics._video.play(); +} + +Graphics.playVideo = function(src) { + this._video.src = src; + this._video.onloadeddata = this._onVideoLoad.bind(this); + this._video.onerror = this._onVideoError.bind(this); + this._video.onended = this._onVideoEnd.bind(this); + this._video.load(); + + if (Utils.isMobileSafari()) { + waitForLoading = true; + if (!register) { + register = true; + document.addEventListener('touchstart', handleiOSTouch); + } + } +}; + +Graphics.isVideoPlaying = function() { + if (Utils.isMobileSafari()) return waitForLoading || (this._video && this._isVideoVisible()); + return this._video && this._isVideoVisible(); +}; + +Graphics._onVideoEnd = function() { + this._updateVisibility(false); + + if (Utils.isMobileSafari()) { + if (register) { + document.removeEventListener('touchstart', handleiOSTouch); + register = false; + } + } +}; + +Input._updateGamepadState = function(gamepad) { + var lastState = this._gamepadStates[gamepad.index] || []; + var newState = []; + var buttons = gamepad.buttons; + var axes = gamepad.axes; + var threshold = 0.5; + newState[12] = false; + newState[13] = false; + newState[14] = false; + newState[15] = false; + for (var i = 0; i < buttons.length; i++) { + newState[i] = buttons[i].pressed; + } + if (axes[1] < -threshold) { + newState[12] = true; // up + } else if (axes[1] > threshold) { + newState[13] = true; // down + } + if (axes[0] < -threshold) { + newState[14] = true; // left + } else if (axes[0] > threshold) { + newState[15] = true; // right + } + for (var j = 0; j < newState.length; j++) { + if (newState[j] !== lastState[j]) { + var buttonName = this.gamepadMapper[j]; + if (buttonName) { + this._currentState[buttonName] = newState[j]; + } + } + } + this._gamepadStates[gamepad.index] = newState; +}; + +Sprite.prototype.initialize = function(bitmap) { + var texture = new PIXI.Texture(new PIXI.BaseTexture()); + + PIXI.Sprite.call(this, texture); + + this._bitmap = null; + this._frame = new Rectangle(); + this._realFrame = new Rectangle(); + this._blendColor = [0, 0, 0, 0]; + this._colorTone = [0, 0, 0, 0]; + this._canvas = null; + this._context = null; + this._tintTexture = null; + + this._isPicture = false; + + this.spriteId = Sprite._counter++; + this.opaque = false; + + this.bitmap = bitmap; +}; + +Sprite.prototype._refresh = function() { + var frameX = Math.floor(this._frame.x); + var frameY = Math.floor(this._frame.y); + var frameW = Math.floor(this._frame.width); + var frameH = Math.floor(this._frame.height); + var bitmapW = this._bitmap ? this._bitmap.width : 0; + var bitmapH = this._bitmap ? this._bitmap.height : 0; + var realX = frameX.clamp(0, bitmapW); + var realY = frameY.clamp(0, bitmapH); + var realW = (frameW - realX + frameX).clamp(0, bitmapW - realX); + var realH = (frameH - realY + frameY).clamp(0, bitmapH - realY); + + this._realFrame.x = realX; + this._realFrame.y = realY; + this._realFrame.width = realW; + this._realFrame.height = realH; + this.pivot.x = frameX - realX; + this.pivot.y = frameY - realY; + + if (realW > 0 && realH > 0) { + if (this._needsTint()) { + this._createTinter(realW, realH); + this._executeTint(realX, realY, realW, realH); + this._tintTexture.update(); + this.texture.baseTexture = this._tintTexture; + this.texture.frame = new Rectangle(0, 0, realW, realH); + } else { + if (this._bitmap) { + this.texture.baseTexture = this._bitmap.baseTexture; + } + this.texture.frame = this._realFrame; + } + } else if (this._bitmap) { + this.texture.frame = Rectangle.emptyRectangle; + } else { + //TODO: remove this + this.texture.baseTexture.width = Math.max(this.texture.baseTexture.width, this._frame.x + this._frame.width); + this.texture.baseTexture.height = Math.max(this.texture.baseTexture.height, this._frame.y + this._frame.height); + this.texture.frame = this._frame; + } + this.texture._updateID++; +}; + +Sprite.prototype.updateTransform = function() { +}; + +TilingSprite = function() { + this.initialize.apply(this, arguments); +} + +TilingSprite.prototype = Object.create(PIXI.extras.PictureTilingSprite.prototype); +TilingSprite.prototype.constructor = TilingSprite; + +TilingSprite.prototype.initialize = function(bitmap) { + var texture = new PIXI.Texture(new PIXI.BaseTexture()); + + PIXI.extras.PictureTilingSprite.call(this, texture); + + this._bitmap = null; + this._width = 0; + this._height = 0; + this._frame = new Rectangle(); + this.spriteId = Sprite._counter++; + + this.origin = new Point(); + + this.bitmap = bitmap; +}; + +TilingSprite.prototype._renderCanvas_PIXI = PIXI.extras.PictureTilingSprite.prototype._renderCanvas; +TilingSprite.prototype._renderWebGL_PIXI = PIXI.extras.PictureTilingSprite.prototype._renderWebGL; + +TilingSprite.prototype._renderCanvas = function(renderer) { + if (this._bitmap) { + this._bitmap.touch(); + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + this._renderCanvas_PIXI(renderer); + } +}; + +TilingSprite.prototype._renderWebGL = function(renderer) { + if (this._bitmap) { + this._bitmap.touch(); + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + if (this._bitmap) { + this._bitmap.checkDirty(); + } + this._renderWebGL_PIXI(renderer); + } +}; + +Object.defineProperty(TilingSprite.prototype, 'bitmap', { + get: function() { + return this._bitmap; + }, + set: function(value) { + if (this._bitmap !== value) { + this._bitmap = value; + if (this._bitmap) { + this._bitmap.addLoadListener(this._onBitmapLoad.bind(this)); + } else { + this.texture.frame = Rectangle.emptyRectangle; + } + } + }, + configurable: true +}); + +Object.defineProperty(TilingSprite.prototype, 'opacity', { + get: function() { + return this.alpha * 255; + }, + set: function(value) { + this.alpha = value.clamp(0, 255) / 255; + }, + configurable: true +}); + +TilingSprite.prototype.update = function() { + this.children.forEach(function(child) { + if (child.update) { + child.update(); + } + }); +}; + +TilingSprite.prototype.move = function(x, y, width, height) { + this.x = x || 0; + this.y = y || 0; + this._width = width || 0; + this._height = height || 0; +}; + +TilingSprite.prototype.setFrame = function(x, y, width, height) { + this._frame.x = x; + this._frame.y = y; + this._frame.width = width; + this._frame.height = height; + this._refresh(); +}; + +TilingSprite.prototype.updateTransform = function() { + this.tilePosition.x = Math.round(-this.origin.x); + this.tilePosition.y = Math.round(-this.origin.y); + this.updateTransformTS(); +}; + +TilingSprite.prototype.updateTransformTS = PIXI.extras.TilingSprite.prototype.updateTransform; + +TilingSprite.prototype._onBitmapLoad = function() { + this.texture.baseTexture = this._bitmap.baseTexture; + this._refresh(); +}; + +TilingSprite.prototype._refresh = function() { + var frame = this._frame.clone(); + if (frame.width === 0 && frame.height === 0 && this._bitmap) { + frame.width = this._bitmap.width; + frame.height = this._bitmap.height; + } + this.texture.frame = frame; + this.texture._updateID++; + this.tilingTexture = null; +}; + + +TilingSprite.prototype._speedUpCustomBlendModes = Sprite.prototype._speedUpCustomBlendModes; + +TilingSprite.prototype._renderWebGL = function(renderer) { + if (this._bitmap) { + this._bitmap.touch(); + this._bitmap.checkDirty(); + } + + this._speedUpCustomBlendModes(renderer); + + this._renderWebGL_PIXI(renderer); +}; + +WindowLayer.prototype.initialize = function() { + PIXI.Container.call(this); + this._width = 0; + this._height = 0; + this._tempCanvas = null; + this._translationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1]; + + this._windowMask = new PIXI.Graphics(); + this._windowMask.beginFill(0xffffff, 1); + this._windowMask.drawRect(0, 0, 0, 0); + this._windowMask.endFill(); + this._windowRect = this._windowMask.graphicsData[0].shape; + + this._renderSprite = null; + this.filterArea = new PIXI.Rectangle(); + this.filters = [WindowLayer.voidFilter]; + + //temporary fix for memory leak bug + this.on('removed', this.onRemoveAsAChild); +}; + +WindowLayer.prototype.onRemoveAsAChild = function() { + this.removeChildren(); +} + +WindowLayer.prototype.renderWebGL = function(renderer) { + if (!this.visible || !this.renderable) { + return; + } + + renderer.currentRenderer.flush(); + this.filterArea.copy(this); + renderer.filterManager.pushFilter(this, this.filters); + renderer.currentRenderer.start(); + + var shift = new PIXI.Point(); + var rt = renderer._activeRenderTarget; + var projectionMatrix = rt.projectionMatrix; + shift.x = (projectionMatrix.tx + 1) / 2 * rt.size.width; + shift.y = (projectionMatrix.ty + 1) / 2 * rt.size.height; + + for (var i = 0; i < this.children.length; i++) { + var child = this.children[i]; + if (child._isWindow && child.visible && child.openness > 0) { + this._maskWindow(child, shift); + renderer.maskManager.pushScissorMask(this, this._windowMask); + renderer.clear(); + renderer.maskManager.popScissorMask(); + renderer.currentRenderer.start(); + child.renderWebGL(renderer); + renderer.currentRenderer.flush(); + } + } + + renderer.filterManager.popFilter(); + renderer.maskManager.popScissorMask(); + + for (var j = 0; j < this.children.length; j++) { + if (!this.children[j]._isWindow) { + this.children[j].renderWebGL(renderer); + } + } +}; + +WindowLayer.prototype._maskWindow = function(window, shift) { + this._windowMask._currentBounds = null; + this._windowMask.boundsDirty = true; + var rect = this._windowRect; + rect.x = shift.x + window.x; + rect.y = shift.y + window.y + window.height / 2 * (1 - window._openness / 255); + rect.width = window.width; + rect.height = window.height * window._openness / 255; +}; + +//----------------------------------------------------------------------------- +// 1.3.2 rpg_managers.js changes +//----------------------------------------------------------------------------- + +BattleManager.invokeCounterAttack = function(subject, target) { + var action = new Game_Action(target); + action.setAttack(); + action.apply(subject); + this._logWindow.displayCounter(target); + this._logWindow.displayActionResults(target, subject); +}; + +BattleManager.invokeMagicReflection = function(subject, target) { + this._action._reflectionTarget = target; + this._logWindow.displayReflection(target); + this._action.apply(subject); + this._logWindow.displayActionResults(target, subject); +}; + +//----------------------------------------------------------------------------- +// 1.3.2 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_Action.prototype.gainDrainedHp = function(value) { + if (this.isDrain()) { + var gainTarget = this.subject(); + if (this._reflectionTarget !== undefined) { + gainTarget = this._reflectionTarget; + } + gainTarget.gainHp(value); + } +}; + +Game_Action.prototype.gainDrainedMp = function(value) { + if (this.isDrain()) { + var gainTarget = this.subject(); + if (this._reflectionTarget !== undefined) { + gainTarget = this._reflectionTarget; + } + gainTarget.gainMp(value); + } +}; + +// Show Battle Animation +Game_Interpreter.prototype.command337 = function() { + if (this._params[2] == true) { + this.iterateEnemyIndex(-1,function(enemy) { + if (enemy.isAlive()) { + enemy.startAnimation(this._params[1],false,0); + } + }.bind(this)); + } else { + this.iterateEnemyIndex(this._params[0], function (enemy) { + if (enemy.isAlive()) { + enemy.startAnimation(this._params[1], false, 0); + } + }.bind(this)); + } + return true; +}; + +//----------------------------------------------------------------------------- +// 1.3.2 rpg_scenes.js changes +//----------------------------------------------------------------------------- + +Scene_Map.prototype.terminate = function() { + this._bypassFirstClear = true; + Scene_Base.prototype.terminate.call(this); + if (!SceneManager.isNextScene(Scene_Battle)) { + this._spriteset.update(); + this._mapNameWindow.hide(); + SceneManager.snapForBackground(); + } + $gameScreen.clearZoom(); + //TODO: Ivan: investigate why is it working, what keeps Scene_Map from freeing stuff + this.removeChild(this._fadeSprite); + this.removeChild(this._mapNameWindow); + this.removeChild(this._windowLayer); + this.removeChild(this._spriteset); + this.clearChildren(); +}; + +//============================================================================= +// Version 1.3.1 to 1.3.2 Changes End +//============================================================================= + +}; // Yanfly.Param.Update132 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.3.2 to 1.3.3 Changes +//============================================================================= + +if (Yanfly.Param.Update133) { + +//----------------------------------------------------------------------------- +// 1.3.3 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.3.3. +Utils.RPGMAKER_VERSION = '1.3.3'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +//============================================================================= +// Version 1.3.2 to 1.3.3 Changes End +//============================================================================= + +}; // Yanfly.Param.Update133 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.3.3 to 1.3.4 Changes +//============================================================================= + +if (Yanfly.Param.Update134) { + +//----------------------------------------------------------------------------- +// 1.3.4 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.3.4. +Utils.RPGMAKER_VERSION = '1.3.4'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Bitmap.snap = function(stage) { + var width = Graphics.width; + var height = Graphics.height; + var bitmap = new Bitmap(width, height); + var context = bitmap._context; + var renderTexture = PIXI.RenderTexture.create(width, height); + if (stage) { + Graphics._renderer.render(stage, renderTexture); + stage.worldTransform.identity(); + var canvas = null; + if (Graphics.isWebGL()) { + canvas = Graphics._renderer.extract.canvas(renderTexture); + } else { + canvas = renderTexture.baseTexture._canvasRenderTarget.canvas; + } + context.drawImage(canvas, 0, 0); + } else { + //TODO: Ivan: what if stage is not present? + } + renderTexture.destroy({ destroyBase: true }); + bitmap._setDirty(); + return bitmap; +}; + +TilingSprite.prototype.updateTransform = function() { + this.tilePosition.x = Math.round(-this.origin.x); + this.tilePosition.y = Math.round(-this.origin.y); + this.updateTransformTS(); +}; + +WindowLayer.prototype.renderWebGL = function(renderer) { + if (!this.visible || !this.renderable) { + return; + } + + renderer.currentRenderer.flush(); + this.filterArea.copy(this); + renderer.filterManager.pushFilter(this, this.filters); + renderer.currentRenderer.start(); + + var shift = new PIXI.Point(); + var rt = renderer._activeRenderTarget; + var projectionMatrix = rt.projectionMatrix; + shift.x = Math.round((projectionMatrix.tx + 1) / 2 * rt.sourceFrame.width); + shift.y = Math.round((projectionMatrix.ty + 1) / 2 * rt.sourceFrame.height); + + for (var i = 0; i < this.children.length; i++) { + var child = this.children[i]; + if (child._isWindow && child.visible && child.openness > 0) { + this._maskWindow(child, shift); + renderer.maskManager.pushScissorMask(this, this._windowMask); + renderer.clear(); + renderer.maskManager.popScissorMask(); + renderer.currentRenderer.start(); + child.renderWebGL(renderer); + renderer.currentRenderer.flush(); + } + } + + renderer.filterManager.popFilter(); + renderer.maskManager.popScissorMask(); + + for (var j = 0; j < this.children.length; j++) { + if (!this.children[j]._isWindow) { + this.children[j].renderWebGL(renderer); + } + } +}; + +//----------------------------------------------------------------------------- +// 1.3.4 rpg_managers.js changes +//----------------------------------------------------------------------------- + +BattleManager.updateEvent = function() { + switch (this._phase) { + case 'start': + case 'turn': + case 'turnEnd': + if (this.isActionForced()) { + this.processForcedAction(); + return true; + } else { + return this.updateEventMain(); + } + } + return this.checkAbort2(); +}; + +BattleManager.checkAbort2 = function() { + if ($gameParty.isEmpty() || this.isAborting()) { + SoundManager.playEscape(); + this._escaped = true; + this.processAbort(); + } + return false; +}; + +BattleManager.updateBattleEnd = function() { + if (this.isBattleTest()) { + AudioManager.stopBgm(); + SceneManager.exit(); + } else if (!this._escaped && $gameParty.isAllDead()) { + if (this._canLose) { + $gameParty.reviveBattleMembers(); + SceneManager.pop(); + } else { + SceneManager.goto(Scene_Gameover); + } + } else { + SceneManager.pop(); + } + this._phase = null; +}; + +//----------------------------------------------------------------------------- +// 1.3.4 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_Actor.prototype.hasSkill = function(skillId) { + return this.skills().contains($dataSkills[skillId]); +}; + +Game_Actor.prototype.testEscape = function(item) { + return item.effects.some(function(effect, index, ar) { + return effect && effect.code === Game_Action.EFFECT_SPECIAL; + }); +}; + +Game_Actor.prototype.meetsUsableItemConditions = function(item) { + if($gameParty.inBattle() && !BattleManager.canEscape() && this.testEscape(item)){ + return false; + } + return this.canMove() && this.isOccasionOk(item); +}; + +// Conditional Branch +Game_Interpreter.prototype.command111 = function() { + var result = false; + switch (this._params[0]) { + case 0: // Switch + if (this._params[2] === 0) { + result = $gameSwitches.value(this._params[1]); + } else { + result = !$gameSwitches.value(this._params[1]); + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) this.skipBranch(); + return true + break; + case 1: // Variable + var value1 = $gameVariables.value(this._params[1]); + var value2; + if (this._params[2] === 0) { + value2 = this._params[3]; + } else { + value2 = $gameVariables.value(this._params[3]); + } + switch (this._params[4]) { + case 0: // Equal to + result = (value1 === value2); + break; + case 1: // Greater than or Equal to + result = (value1 >= value2); + break; + case 2: // Less than or Equal to + result = (value1 <= value2); + break; + case 3: // Greater than + result = (value1 > value2); + break; + case 4: // Less than + result = (value1 < value2); + break; + case 5: // Not Equal to + result = (value1 !== value2); + break; + } + break; + case 2: // Self Switch + if (this._eventId > 0) { + var key = [this._mapId, this._eventId, this._params[1]]; + if (this._params[2] === 0) { + result = $gameSelfSwitches.value(key); + } else { + result = !$gameSelfSwitches.value(key); + } + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) this.skipBranch(); + return true + break; + case 3: // Timer + if ($gameTimer.isWorking()) { + if (this._params[2] === 0) { + result = ($gameTimer.seconds() >= this._params[1]); + } else { + result = ($gameTimer.seconds() <= this._params[1]); + } + } + break; + case 4: // Actor + var actor = $gameActors.actor(this._params[1]); + if (actor) { + var n = this._params[3]; + switch (this._params[2]) { + case 0: // In the Party + result = $gameParty.members().contains(actor); + break; + case 1: // Name + result = (actor.name() === n); + break; + case 2: // Class + result = actor.isClass($dataClasses[n]); + break; + case 3: // Skill + result = actor.hasSkill(n); + break; + case 4: // Weapon + result = actor.hasWeapon($dataWeapons[n]); + break; + case 5: // Armor + result = actor.hasArmor($dataArmors[n]); + break; + case 6: // State + result = actor.isStateAffected(n); + break; + } + } + break; + case 5: // Enemy + var enemy = $gameTroop.members()[this._params[1]]; + if (enemy) { + switch (this._params[2]) { + case 0: // Appeared + result = enemy.isAlive(); + break; + case 1: // State + result = enemy.isStateAffected(this._params[3]); + break; + } + } + break; + case 6: // Character + var character = this.character(this._params[1]); + if (character) { + result = (character.direction() === this._params[2]); + } + break; + case 7: // Gold + switch (this._params[2]) { + case 0: // Greater than or equal to + result = ($gameParty.gold() >= this._params[1]); + break; + case 1: // Less than or equal to + result = ($gameParty.gold() <= this._params[1]); + break; + case 2: // Less than + result = ($gameParty.gold() < this._params[1]); + break; + } + break; + case 8: // Item + result = $gameParty.hasItem($dataItems[this._params[1]]); + break; + case 9: // Weapon + result = $gameParty.hasItem($dataWeapons[this._params[1]], this._params[2]); + break; + case 10: // Armor + result = $gameParty.hasItem($dataArmors[this._params[1]], this._params[2]); + break; + case 11: // Button + result = Input.isPressed(this._params[1]); + break; + case 12: // Script + var code = this._params[1]; + try { + result = !!eval(code); + } catch (e) { + result = false; + Yanfly.Util.displayError(e, code, 'CONDITIONAL BRANCH SCRIPT ERROR'); + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) this.skipBranch(); + return true + break; + case 13: // Vehicle + result = ($gamePlayer.vehicle() === $gameMap.vehicle(this._params[1])); + break; + } + this._branch[this._indent] = result; + if (this._branch[this._indent] === false) { + this.skipBranch(); + } + return true; +}; + +//============================================================================= +// Version 1.3.3 to 1.3.4 Changes End +//============================================================================= + +}; // Yanfly.Param.Update134 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.3.4 to 1.4.0 Changes +//============================================================================= + +if (Yanfly.Param.Update140) { + +//----------------------------------------------------------------------------- +// 1.4.0 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.4.0. +Utils.RPGMAKER_VERSION = '1.4.0'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +WebAudio._setupEventHandlers = function() { + document.addEventListener("touchend", function() { + var context = WebAudio._context; + if (context && context.state === "suspended" && typeof context.resume === "function") { + context.resume().then(function() { + WebAudio._onTouchStart(); + }) + } else { + WebAudio._onTouchStart(); + } + }); + document.addEventListener('touchstart', this._onTouchStart.bind(this)); + document.addEventListener('visibilitychange', this._onVisibilityChange.bind(this)); +}; + +//----------------------------------------------------------------------------- +// 1.4.0 rpg_managers.js changes +//----------------------------------------------------------------------------- + +AudioManager.shouldUseHtml5Audio = function() { + // The only case where we wanted html5audio was android/ no encrypt + // Atsuma-ru asked to force webaudio there too, so just return false for ALL // return Utils.isAndroidChrome() && !Decrypter.hasEncryptedAudio; + return false; +}; + +//----------------------------------------------------------------------------- +// 1.4.0 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_Actor.prototype.meetsUsableItemConditions = function(item) { + if ($gameParty.inBattle() && !BattleManager.canEscape() && this.testEscape(item)) { + return false; + } + return Game_BattlerBase.prototype.meetsUsableItemConditions.call(this, item); +}; + +//============================================================================= +// Version 1.3.4 to 1.4.0 Changes End +//============================================================================= + +}; // Yanfly.Param.Update140 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.4.0 to 1.5.0 Changes +//============================================================================= + +if (Yanfly.Param.Update150) { + +//----------------------------------------------------------------------------- +// 1.5.0 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.5.0. +Utils.RPGMAKER_VERSION = '1.5.0'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Utils._id = 1; +Utils.generateRuntimeId = function(){ + return Utils._id++; +}; + +Utils._supportPassiveEvent = null; + +Utils.isSupportPassiveEvent = function() { + if (typeof Utils._supportPassiveEvent === "boolean") { + return Utils._supportPassiveEvent; + } + // test support passive event + // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection + var passive = false; + var options = Object.defineProperty({}, "passive", { + get: function() { passive = true; } + }); + window.addEventListener("test", null, options); + Utils._supportPassiveEvent = passive; + return passive; +} + +ImageCache = function(){ + this.initialize.apply(this, arguments); +} + +ImageCache.limit = 10 * 1000 * 1000; + +ImageCache.prototype.initialize = function(){ + this._items = {}; +}; + +ImageCache.prototype.add = function(key, value){ + this._items[key] = { + bitmap: value, + touch: Date.now(), + key: key + }; + + this._truncateCache(); +}; + +ImageCache.prototype.get = function(key){ + if(this._items[key]){ + var item = this._items[key]; + item.touch = Date.now(); + return item.bitmap; + } + + return null; +}; + +ImageCache.prototype.reserve = function(key, value, reservationId){ + if(!this._items[key]){ + this._items[key] = { + bitmap: value, + touch: Date.now(), + key: key + }; + } + + this._items[key].reservationId = reservationId; +}; + +ImageCache.prototype.releaseReservation = function(reservationId){ + var items = this._items; + + Object.keys(items) + .map(function(key){return items[key];}) + .forEach(function(item){ + if(item.reservationId === reservationId){ + delete item.reservationId; + } + }); +}; + +ImageCache.prototype._truncateCache = function(){ + var items = this._items; + var sizeLeft = ImageCache.limit; + + Object.keys(items).map(function(key){ + return items[key]; + }).sort(function(a, b){ + return b.touch - a.touch; + }).forEach(function(item){ + if(sizeLeft > 0 || this._mustBeHeld(item)){ + var bitmap = item.bitmap; + sizeLeft -= bitmap.width * bitmap.height; + }else{ + delete items[item.key]; + } + }.bind(this)); +}; + +ImageCache.prototype._mustBeHeld = function(item){ + // request only is weak so It's purgeable + if(item.bitmap.isRequestOnly()) return false; + // reserved item must be held + if(item.reservationId) return true; + // not ready bitmap must be held (because of checking isReady()) + if(!item.bitmap.isReady()) return true; + // then the item may purgeable + return false; +}; + +ImageCache.prototype.isReady = function(){ + var items = this._items; + return !Object.keys(items).some(function(key){ + return !items[key].bitmap.isRequestOnly() && !items[key].bitmap.isReady(); + }); +}; + +ImageCache.prototype.getErrorBitmap = function(){ + var items = this._items; + var bitmap = null; + if(Object.keys(items).some(function(key){ + if(items[key].bitmap.isError()){ + bitmap = items[key].bitmap; + return true; + } + return false; + })) { + return bitmap; + } + + return null; +}; + +RequestQueue = function(){ + this.initialize.apply(this, arguments); +} + +RequestQueue.prototype.initialize = function(){ + this._queue = []; +}; + +RequestQueue.prototype.enqueue = function(key, value){ + this._queue.push({ + key: key, + value: value, + }); +}; + +RequestQueue.prototype.update = function(){ + if(this._queue.length === 0) return; + + var top = this._queue[0]; + if(top.value.isRequestReady()){ + this._queue.shift(); + if(this._queue.length !== 0){ + this._queue[0].value.startRequest(); + } + }else{ + top.value.startRequest(); + } +}; + +RequestQueue.prototype.raisePriority = function(key){ + for(var n = 0; n < this._queue.length; n++){ + var item = this._queue[n]; + if(item.key === key){ + this._queue.splice(n, 1); + this._queue.unshift(item); + break; + } + } +}; + +RequestQueue.prototype.clear = function(){ + this._queue.splice(0); +}; + +Bitmap._reuseImages = []; + +Bitmap.prototype._createCanvas = function(width, height){ + this.__canvas = this.__canvas || document.createElement('canvas'); + this.__context = this.__canvas.getContext('2d'); + + this.__canvas.width = Math.max(width || 0, 1); + this.__canvas.height = Math.max(height || 0, 1); + + if(this._image){ + var w = Math.max(this._image.width || 0, 1); + var h = Math.max(this._image.height || 0, 1); + this.__canvas.width = w; + this.__canvas.height = h; + this._createBaseTexture(this._canvas); + + this.__context.drawImage(this._image, 0, 0); + } + + this._setDirty(); +}; + +Bitmap.prototype._createBaseTexture = function(source){ + this.__baseTexture = new PIXI.BaseTexture(source); + this.__baseTexture.mipmap = false; + this.__baseTexture.width = source.width; + this.__baseTexture.height = source.height; + + if (this._smooth) { + this._baseTexture.scaleMode = PIXI.SCALE_MODES.LINEAR; + } else { + this._baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST; + } +}; + +Bitmap.prototype._clearImgInstance = function(){ + this._image.src = ""; + this._image.onload = null; + this._image.onerror = null; + this._errorListener = null; + this._loadListener = null; + + Bitmap._reuseImages.push(this._image); + this._image = null; +}; + +Object.defineProperties(Bitmap.prototype, { + _canvas: { + get: function(){ + if(!this.__canvas)this._createCanvas(); + return this.__canvas; + } + }, + _context: { + get: function(){ + if(!this.__context)this._createCanvas(); + return this.__context; + } + }, + + _baseTexture: { + get: function(){ + if(!this.__baseTexture) this._createBaseTexture(this._image || this.__canvas); + return this.__baseTexture; + } + } +}); + +Bitmap.prototype._renewCanvas = function(){ + var newImage = this._image; + if(newImage && this.__canvas && (this.__canvas.width < newImage.width || this.__canvas.height < newImage.height)){ + this._createCanvas(); + } +}; + +Bitmap.prototype.initialize = function(width, height) { + if(!this._defer){ + this._createCanvas(width, height); + } + + this._image = null; + this._url = ''; + this._paintOpacity = 255; + this._smooth = false; + this._loadListeners = []; + this._loadingState = 'none'; + this._decodeAfterRequest = false; + + this.cacheEntry = null; + + this.fontFace = 'GameFont'; + + this.fontSize = 28; + + this.fontItalic = false; + + this.textColor = '#ffffff'; + + this.outlineColor = 'rgba(0, 0, 0, 0.5)'; + + this.outlineWidth = 4; +}; + +Bitmap.load = function(url) { + var bitmap = Object.create(Bitmap.prototype); + bitmap._defer = true; + bitmap.initialize(); + + bitmap._decodeAfterRequest = true; + bitmap._requestImage(url); + + return bitmap; +}; + +Bitmap.prototype.isReady = function() { + return this._loadingState === 'loaded' || this._loadingState === 'none'; +}; + +Bitmap.prototype.isError = function() { + return this._loadingState === 'error'; +}; + +Object.defineProperty(Bitmap.prototype, 'width', { + get: function() { + if(this.isReady()){ + return this._image? this._image.width: this._canvas.width; + } + + return 0; + }, + configurable: true +}); + +Object.defineProperty(Bitmap.prototype, 'height', { + get: function() { + if(this.isReady()){ + return this._image? this._image.height: this._canvas.height; + } + + return 0; + }, + configurable: true +}); + +Object.defineProperty(Bitmap.prototype, 'smooth', { + get: function() { + return this._smooth; + }, + set: function(value) { + if (this._smooth !== value) { + this._smooth = value; + if(this.__baseTexture){ + if (this._smooth) { + this._baseTexture.scaleMode = PIXI.SCALE_MODES.LINEAR; + } else { + this._baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST; + } + } + } + }, + configurable: true +}); + +Bitmap.prototype.addLoadListener = function(listner) { + if (!this.isReady()) { + this._loadListeners.push(listner); + } else { + listner(this); + } +}; + +Bitmap.prototype._onLoad = function() { + this._image.removeEventListener('load', this._loadListener); + this._image.removeEventListener('error', this._errorListener); + + this._renewCanvas(); + + switch(this._loadingState){ + case 'requesting': + this._loadingState = 'requestCompleted'; + if(this._decodeAfterRequest){ + this.decode(); + }else{ + this._loadingState = 'purged'; + this._clearImgInstance(); + } + break; + + case 'decrypting': + window.URL.revokeObjectURL(this._image.src); + this._loadingState = 'decryptCompleted'; + if(this._decodeAfterRequest){ + this.decode(); + }else{ + this._loadingState = 'purged'; + this._clearImgInstance(); + } + break; + } +}; + +Bitmap.prototype.decode = function(){ + switch(this._loadingState){ + case 'requestCompleted': case 'decryptCompleted': + this._loadingState = 'loaded'; + + if(!this.__canvas) this._createBaseTexture(this._image); + this._setDirty(); + this._callLoadListeners(); + break; + + case 'requesting': case 'decrypting': + this._decodeAfterRequest = true; + if (!this._loader) { + this._loader = ResourceHandler.createLoader(this._url, this._requestImage.bind(this, this._url), this._onError.bind(this)); + this._image.removeEventListener('error', this._errorListener); + this._image.addEventListener('error', this._errorListener = this._loader); + } + break; + + case 'pending': case 'purged': case 'error': + this._decodeAfterRequest = true; + this._requestImage(this._url); + break; + } +}; + +Bitmap.prototype._callLoadListeners = function() { + while (this._loadListeners.length > 0) { + var listener = this._loadListeners.shift(); + listener(this); + } +}; + +Bitmap.prototype._onError = function() { + this._image.removeEventListener('load', this._loadListener); + this._image.removeEventListener('error', this._errorListener); + this._loadingState = 'error'; +}; + +Bitmap.request = function(url){ + var bitmap = Object.create(Bitmap.prototype); + bitmap._defer = true; + bitmap.initialize(); + + bitmap._url = url; + bitmap._loadingState = 'pending'; + + return bitmap; +}; + +Bitmap.prototype._requestImage = function(url){ + if(Bitmap._reuseImages.length !== 0){ + this._image = Bitmap._reuseImages.pop(); + }else{ + this._image = new Image(); + } + + if (this._decodeAfterRequest && !this._loader) { + this._loader = ResourceHandler.createLoader(url, this._requestImage.bind(this, url), this._onError.bind(this)); + } + + this._image = new Image(); + this._url = url; + this._loadingState = 'requesting'; + + if(!Decrypter.checkImgIgnore(url) && Decrypter.hasEncryptedImages) { + this._loadingState = 'decrypting'; + Decrypter.decryptImg(url, this); + } else { + this._image.src = url; + + this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this)); + this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this)); + } +}; + +Bitmap.prototype.isRequestOnly = function(){ + return !(this._decodeAfterRequest || this.isReady()); +}; + +Bitmap.prototype.isRequestReady = function(){ + return this._loadingState !== 'pending' && + this._loadingState !== 'requesting' && + this._loadingState !== 'decrypting'; +}; + +Bitmap.prototype.startRequest = function(){ + if(this._loadingState === 'pending'){ + this._decodeAfterRequest = false; + this._requestImage(this._url); + } +}; + +Graphics._cssFontLoading = document.fonts && document.fonts.ready; +Graphics._fontLoaded = null; +Graphics._videoVolume = 1; + +Graphics.initialize = function(width, height, type) { + this._width = width || 800; + this._height = height || 600; + this._rendererType = type || 'auto'; + this._boxWidth = this._width; + this._boxHeight = this._height; + + this._scale = 1; + this._realScale = 1; + + this._errorShowed = false; + this._errorPrinter = null; + this._canvas = null; + this._video = null; + this._videoUnlocked = !Utils.isMobileDevice(); + this._videoLoading = false; + this._upperCanvas = null; + this._renderer = null; + this._fpsMeter = null; + this._modeBox = null; + this._skipCount = 0; + this._maxSkip = 3; + this._rendered = false; + this._loadingImage = null; + this._loadingCount = 0; + this._fpsMeterToggled = false; + this._stretchEnabled = this._defaultStretchMode(); + + this._canUseDifferenceBlend = false; + this._canUseSaturationBlend = false; + this._hiddenCanvas = null; + + this._testCanvasBlendModes(); + this._modifyExistingElements(); + this._updateRealScale(); + this._createAllElements(); + this._disableTextSelection(); + this._disableContextMenu(); + this._setupEventHandlers(); + this._setupCssFontLoading(); +}; + +Graphics._setupCssFontLoading = function(){ + if(Graphics._cssFontLoading){ + document.fonts.ready.then(function(fonts){ + Graphics._fontLoaded = fonts; + }).catch(function(error){ + SceneManager.onError(error); + }); + } +}; + +Graphics.canUseCssFontLoading = function(){ + return !!this._cssFontLoading; +}; + +Graphics.render = function(stage) { + if (this._skipCount === 0) { + var startTime = Date.now(); + if (stage) { + this._renderer.render(stage); + if (this._renderer.gl && this._renderer.gl.flush) { + this._renderer.gl.flush(); + } + } + var endTime = Date.now(); + var elapsed = endTime - startTime; + this._skipCount = Math.min(Math.floor(elapsed / 15), this._maxSkip); + this._rendered = true; + } else { + this._skipCount--; + this._rendered = false; + } + this.frameCount++; +}; + +Graphics.printLoadingError = function(url) { + if (this._errorPrinter && !this._errorShowed) { + this._errorPrinter.innerHTML = this._makeErrorHtml('Loading Error', 'Failed to load: ' + url); + var button = document.createElement('button'); + button.innerHTML = 'Retry'; + button.style.fontSize = '24px'; + button.style.color = '#ffffff'; + button.style.backgroundColor = '#000000'; + button.onmousedown = button.ontouchstart = function(event) { + ResourceHandler.retry(); + event.stopPropagation(); + }; + this._errorPrinter.appendChild(button); + this._loadingCount = -Infinity; + } +}; + +Graphics.eraseLoadingError = function() { + if (this._errorPrinter && !this._errorShowed) { + this._errorPrinter.innerHTML = ''; + this.startLoading(); + } +}; + +Graphics.printError = function(name, message) { + this._errorShowed = true; + if (this._errorPrinter) { + this._errorPrinter.innerHTML = this._makeErrorHtml(name, message); + } + this._applyCanvasFilter(); + this._clearUpperCanvas(); +}; + +Graphics.isFontLoaded = function(name) { + if (Graphics._cssFontLoading) { + if(Graphics._fontLoaded){ + return Graphics._fontLoaded.check('10px "'+name+'"'); + } + + return false; + } else { + if (!this._hiddenCanvas) { + this._hiddenCanvas = document.createElement('canvas'); + } + var context = this._hiddenCanvas.getContext('2d'); + var text = 'abcdefghijklmnopqrstuvwxyz'; + var width1, width2; + context.font = '40px ' + name + ', sans-serif'; + width1 = context.measureText(text).width; + context.font = '40px sans-serif'; + width2 = context.measureText(text).width; + return width1 !== width2; + } +}; + +Graphics.playVideo = function(src) { + this._videoLoader = ResourceHandler.createLoader(null, this._playVideo.bind(this, src), this._onVideoError.bind(this)); + this._playVideo(src); +}; + +Graphics._playVideo = function(src) { + this._video.src = src; + this._video.onloadeddata = this._onVideoLoad.bind(this); + this._video.onerror = this._videoLoader; + this._video.onended = this._onVideoEnd.bind(this); + this._video.load(); + this._videoLoading = true; +}; + +Graphics.isVideoPlaying = function() { + return this._videoLoading || this._isVideoVisible(); +}; + +Graphics.setVideoVolume = function(value) { + this._videoVolume = value; + if (this._video) { + this._video.volume = this._videoVolume; + } +}; + +Graphics._createVideo = function() { + this._video = document.createElement('video'); + this._video.id = 'GameVideo'; + this._video.style.opacity = 0; + this._video.setAttribute('playsinline', ''); + this._video.volume = this._videoVolume; + this._updateVideo(); + makeVideoPlayableInline(this._video); + document.body.appendChild(this._video); +}; + +Graphics._createRenderer = function() { + PIXI.dontSayHello = true; + var width = this._width; + var height = this._height; + var options = { view: this._canvas }; + try { + switch (this._rendererType) { + case 'canvas': + this._renderer = new PIXI.CanvasRenderer(width, height, options); + break; + case 'webgl': + this._renderer = new PIXI.WebGLRenderer(width, height, options); + break; + default: + this._renderer = PIXI.autoDetectRenderer(width, height, options); + break; + } + + if(this._renderer && this._renderer.textureGC) + this._renderer.textureGC.maxIdle = 1; + + } catch (e) { + this._renderer = null; + } +}; + +Graphics._onVideoLoad = function() { + this._video.play(); + this._updateVisibility(true); + this._videoLoading = false; +}; + +Graphics._onVideoError = function() { + this._updateVisibility(false); + this._videoLoading = false; +}; + +Graphics._onVideoEnd = function() { + this._updateVisibility(false); +}; + +Graphics._setupEventHandlers = function() { + window.addEventListener('resize', this._onWindowResize.bind(this)); + document.addEventListener('keydown', this._onKeyDown.bind(this)); + document.addEventListener('touchend', this._onTouchEnd.bind(this)); +}; + +Graphics._onTouchEnd = function(event) { + if (!this._videoUnlocked) { + this._video.play(); + this._videoUnlocked = true; + } + if (this._isVideoVisible() && this._video.paused) { + this._video.play(); + } +}; + +Input._onKeyDown = function(event) { + if (this._shouldPreventDefault(event.keyCode)) { + event.preventDefault(); + } + if (event.keyCode === 144) { // Numlock + this.clear(); + } + var buttonName = this.keyMapper[event.keyCode]; + if (ResourceHandler.exists() && buttonName === 'ok') { + ResourceHandler.retry(); + } else if (buttonName) { + this._currentState[buttonName] = true; + } +}; + +TouchInput._setupEventHandlers = function() { + var isSupportPassive = Utils.isSupportPassiveEvent(); + document.addEventListener('mousedown', this._onMouseDown.bind(this)); + document.addEventListener('mousemove', this._onMouseMove.bind(this)); + document.addEventListener('mouseup', this._onMouseUp.bind(this)); + document.addEventListener('wheel', this._onWheel.bind(this)); + document.addEventListener('touchstart', this._onTouchStart.bind(this), isSupportPassive ? {passive: false} : false); + document.addEventListener('touchmove', this._onTouchMove.bind(this), isSupportPassive ? {passive: false} : false); + document.addEventListener('touchend', this._onTouchEnd.bind(this)); + document.addEventListener('touchcancel', this._onTouchCancel.bind(this)); + document.addEventListener('pointerdown', this._onPointerDown.bind(this)); +}; + +Object.defineProperty(Sprite.prototype, 'bitmap', { + get: function() { + return this._bitmap; + }, + set: function(value) { + if (this._bitmap !== value) { + this._bitmap = value; + + if(value){ + this._refreshFrame = true; + value.addLoadListener(this._onBitmapLoad.bind(this)); + }else{ + this._refreshFrame = false; + this.texture.frame = Rectangle.emptyRectangle; + } + } + }, + configurable: true +}); + +Sprite.prototype.setFrame = function(x, y, width, height) { + this._refreshFrame = false; + var frame = this._frame; + if (x !== frame.x || y !== frame.y || + width !== frame.width || height !== frame.height) { + frame.x = x; + frame.y = y; + frame.width = width; + frame.height = height; + this._refresh(); + } +}; + +Sprite.prototype._onBitmapLoad = function(bitmapLoaded) { + if(bitmapLoaded === this._bitmap){ + if (this._refreshFrame && this._bitmap) { + this._refreshFrame = false; + this._frame.width = this._bitmap.width; + this._frame.height = this._bitmap.height; + } + } + + this._refresh(); +}; + +Sprite.prototype._renderCanvas = function(renderer) { + if (this.bitmap) { + this.bitmap.touch(); + } + if(this.bitmap && !this.bitmap.isReady()){ + return; + } + + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + this._renderCanvas_PIXI(renderer); + } +}; + +Sprite.prototype._renderWebGL = function(renderer) { + if (this.bitmap) { + this.bitmap.touch(); + } + if(this.bitmap && !this.bitmap.isReady()){ + return; + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + if (this._bitmap) { + this._bitmap.checkDirty(); + } + + //copy of pixi-v4 internal code + this.calculateVertices(); + + if (this._isPicture) { + // use heavy renderer, which reduces artifacts and applies corrent blendMode, + // but does not use multitexture optimization + this._speedUpCustomBlendModes(renderer); + renderer.setObjectRenderer(renderer.plugins.picture); + renderer.plugins.picture.render(this); + } else { + // use pixi super-speed renderer + renderer.setObjectRenderer(renderer.plugins.sprite); + renderer.plugins.sprite.render(this); + } + } +}; + +PIXI.tilemap.TileRenderer.DO_CLEAR = true; + +ShaderTilemap.prototype._hackRenderer = function(renderer) { + var af = this.animationFrame % 4; + if (af==3) af = 1; + renderer.plugins.tilemap.tileAnim[0] = af * this._tileWidth; + renderer.plugins.tilemap.tileAnim[1] = (this.animationFrame % 3) * this._tileHeight; + return renderer; +}; + +WindowLayer.prototype.renderWebGL = function(renderer) { + if (!this.visible || !this.renderable) { + return; + } + + if (this.children.length==0) { + return; + } + + renderer.flush(); + this.filterArea.copy(this); + renderer.filterManager.pushFilter(this, this.filters); + renderer.currentRenderer.start(); + + var shift = new PIXI.Point(); + var rt = renderer._activeRenderTarget; + var projectionMatrix = rt.projectionMatrix; + shift.x = Math.round((projectionMatrix.tx + 1) / 2 * rt.sourceFrame.width); + shift.y = Math.round((projectionMatrix.ty + 1) / 2 * rt.sourceFrame.height); + + for (var i = 0; i < this.children.length; i++) { + var child = this.children[i]; + if (child._isWindow && child.visible && child.openness > 0) { + this._maskWindow(child, shift); + renderer.maskManager.pushScissorMask(this, this._windowMask); + renderer.clear(); + renderer.maskManager.popScissorMask(); + renderer.currentRenderer.start(); + child.renderWebGL(renderer); + renderer.currentRenderer.flush(); + } + } + + renderer.flush(); + renderer.filterManager.popFilter(); + renderer.maskManager.popScissorMask(); + + for (var j = 0; j < this.children.length; j++) { + if (!this.children[j]._isWindow) { + this.children[j].renderWebGL(renderer); + } + } +}; + +WindowLayer.prototype._maskWindow = function(window, shift) { + this._windowMask._currentBounds = null; + this._windowMask.boundsDirty = true; + var rect = this._windowRect; + rect.x = this.x + shift.x + window.x; + rect.y = this.x + shift.y + window.y + window.height / 2 * (1 - window._openness / 255); + rect.width = window.width; + rect.height = window.height * window._openness / 255; +}; + +WebAudio._standAlone = (function(top){ + return !top.ResourceHandler; +})(this); + +WebAudio.prototype.initialize = function(url) { + if (!WebAudio._initialized) { + WebAudio.initialize(); + } + this.clear(); + + if(!WebAudio._standAlone){ + this._loader = ResourceHandler.createLoader(url, this._load.bind(this, url), function() { + this._hasError = true; + }.bind(this)); + } + this._load(url); + this._url = url; +}; + +WebAudio._masterVolume = 1; + +WebAudio.setMasterVolume = function(value) { + this._masterVolume = value; + if (this._masterGainNode) { + this._masterGainNode.gain.setValueAtTime(this._masterVolume, this._context.currentTime); + } +}; + +WebAudio._createMasterGainNode = function() { + var context = WebAudio._context; + if (context) { + this._masterGainNode = context.createGain(); + this._masterGainNode.gain.setValueAtTime(this._masterVolume, context.currentTime); + this._masterGainNode.connect(context.destination); + } +}; + +WebAudio._fadeIn = function(duration) { + if (this._masterGainNode) { + var gain = this._masterGainNode.gain; + var currentTime = WebAudio._context.currentTime; + gain.setValueAtTime(0, currentTime); + gain.linearRampToValueAtTime(this._masterVolume, currentTime + duration); + } +}; + +WebAudio._fadeOut = function(duration) { + if (this._masterGainNode) { + var gain = this._masterGainNode.gain; + var currentTime = WebAudio._context.currentTime; + gain.setValueAtTime(this._masterVolume, currentTime); + gain.linearRampToValueAtTime(0, currentTime + duration); + } +}; + +Object.defineProperty(WebAudio.prototype, 'volume', { + get: function() { + return this._volume; + }, + set: function(value) { + this._volume = value; + if (this._gainNode) { + this._gainNode.gain.setValueAtTime(this._volume, WebAudio._context.currentTime); + } + }, + configurable: true +}); + +WebAudio.prototype.fadeOut = function(duration) { + if (this._gainNode) { + var gain = this._gainNode.gain; + var currentTime = WebAudio._context.currentTime; + gain.setValueAtTime(this._volume, currentTime); + gain.linearRampToValueAtTime(0, currentTime + duration); + } + this._autoPlay = false; +}; + +WebAudio.prototype._load = function(url) { + if (WebAudio._context) { + var xhr = new XMLHttpRequest(); + if(Decrypter.hasEncryptedAudio) url = Decrypter.extToEncryptExt(url); + xhr.open('GET', url); + xhr.responseType = 'arraybuffer'; + xhr.onload = function() { + if (xhr.status < 400) { + this._onXhrLoad(xhr); + } + }.bind(this); + xhr.onerror = this._loader || function(){this._hasError = true;}.bind(this); + xhr.send(); + } +}; + +WebAudio.prototype._createNodes = function() { + var context = WebAudio._context; + this._sourceNode = context.createBufferSource(); + this._sourceNode.buffer = this._buffer; + this._sourceNode.loopStart = this._loopStart; + this._sourceNode.loopEnd = this._loopStart + this._loopLength; + this._sourceNode.playbackRate.setValueAtTime(this._pitch, context.currentTime); + this._gainNode = context.createGain(); + this._gainNode.gain.setValueAtTime(this._volume, context.currentTime); + this._pannerNode = context.createPanner(); + this._pannerNode.panningModel = 'equalpower'; + this._updatePanner(); +}; + +JsonEx._id = 1; +JsonEx._generateId = function(){ + return JsonEx._id++; +}; + +JsonEx.stringify = function(object) { + var circular = []; + JsonEx._id = 1; + var json = JSON.stringify(this._encode(object, circular, 0)); + this._cleanMetadata(object); + this._restoreCircularReference(circular); + + return json; +}; + +JsonEx._restoreCircularReference = function(circulars){ + circulars.forEach(function(circular){ + var key = circular[0]; + var value = circular[1]; + var content = circular[2]; + + value[key] = content; + }); +}; + +JsonEx.parse = function(json) { + var circular = []; + var registry = {}; + var contents = this._decode(JSON.parse(json), circular, registry); + this._cleanMetadata(contents); + this._linkCircularReference(contents, circular, registry); + + return contents; +}; + +JsonEx._linkCircularReference = function(contents, circulars, registry){ + circulars.forEach(function(circular){ + var key = circular[0]; + var value = circular[1]; + var id = circular[2]; + + value[key] = registry[id]; + }); +}; + +JsonEx._cleanMetadata = function(object){ + if(!object) return; + + delete object['@']; + delete object['@c']; + + if(typeof object === 'object'){ + Object.keys(object).forEach(function(key){ + var value = object[key]; + if(typeof value === 'object'){ + JsonEx._cleanMetadata(value); + } + }); + } +}; + +JsonEx._encode = function(value, circular, depth) { + depth = depth || 0; + if (++depth >= this.maxDepth) { + throw new Error('Object too deep'); + } + var type = Object.prototype.toString.call(value); + if (type === '[object Object]' || type === '[object Array]') { + value['@c'] = JsonEx._generateId(); + + var constructorName = this._getConstructorName(value); + if (constructorName !== 'Object' && constructorName !== 'Array') { + value['@'] = constructorName; + } + for (var key in value) { + if (value.hasOwnProperty(key) && !key.match(/^@./)) { + if(value[key] && typeof value[key] === 'object'){ + if(value[key]['@c']){ + circular.push([key, value, value[key]]); + value[key] = {'@r': value[key]['@c']}; + }else{ + value[key] = this._encode(value[key], circular, depth + 1); + + if(value[key] instanceof Array){ + //wrap array + circular.push([key, value, value[key]]); + + value[key] = { + '@c': value[key]['@c'], + '@a': value[key] + }; + } + } + }else{ + value[key] = this._encode(value[key], circular, depth + 1); + } + } + } + } + depth--; + return value; +}; + +JsonEx._decode = function(value, circular, registry) { + var type = Object.prototype.toString.call(value); + if (type === '[object Object]' || type === '[object Array]') { + registry[value['@c']] = value; + + if (value['@']) { + var constructor = window[value['@']]; + if (constructor) { + value = this._resetPrototype(value, constructor.prototype); + } + } + for (var key in value) { + if (value.hasOwnProperty(key)) { + if(value[key] && value[key]['@a']){ + //object is array wrapper + var body = value[key]['@a']; + body['@c'] = value[key]['@c']; + value[key] = body; + } + if(value[key] && value[key]['@r']){ + //object is reference + circular.push([key, value, value[key]['@r']]) + } + value[key] = this._decode(value[key], circular, registry); + } + } + } + return value; +}; + +Decrypter.decryptImg = function(url, bitmap) { + url = this.extToEncryptExt(url); + + var requestFile = new XMLHttpRequest(); + requestFile.open("GET", url); + requestFile.responseType = "arraybuffer"; + requestFile.send(); + + requestFile.onload = function () { + if(this.status < Decrypter._xhrOk) { + var arrayBuffer = Decrypter.decryptArrayBuffer(requestFile.response); + bitmap._image.src = Decrypter.createBlobUrl(arrayBuffer); + bitmap._image.addEventListener('load', bitmap._loadListener = Bitmap.prototype._onLoad.bind(bitmap)); + bitmap._image.addEventListener('error', bitmap._errorListener = bitmap._loader || Bitmap.prototype._onError.bind(bitmap)); + } + }; + + requestFile.onerror = function () { + if (bitmap._loader) { + bitmap._loader(); + } else { + bitmap._onError(); + } + }; +}; + +ResourceHandler = function() { + throw new Error('This is a static class'); +} + +ResourceHandler._reloaders = []; +ResourceHandler._defaultRetryInterval = [500, 1000, 3000]; + +ResourceHandler.createLoader = function(url, retryMethod, resignMethod, retryInterval) { + retryInterval = retryInterval || this._defaultRetryInterval; + var reloaders = this._reloaders; + var retryCount = 0; + return function() { + if (retryCount < retryInterval.length) { + setTimeout(retryMethod, retryInterval[retryCount]); + retryCount++; + } else { + if (resignMethod) { + resignMethod(); + } + if (url) { + if (reloaders.length === 0) { + Graphics.printLoadingError(url); + SceneManager.stop(); + } + reloaders.push(function() { + retryCount = 0; + retryMethod(); + }); + } + } + }; +}; + +ResourceHandler.exists = function() { + return this._reloaders.length > 0; +}; + +ResourceHandler.retry = function() { + if (this._reloaders.length > 0) { + Graphics.eraseLoadingError(); + SceneManager.resume(); + this._reloaders.forEach(function(reloader) { + reloader(); + }); + this._reloaders.length = 0; + } +}; + +//----------------------------------------------------------------------------- +// 1.5.0 rpg_managers.js changes +//----------------------------------------------------------------------------- + +DataManager.loadDataFile = function(name, src) { + var xhr = new XMLHttpRequest(); + var url = 'data/' + src; + xhr.open('GET', url); + xhr.overrideMimeType('application/json'); + xhr.onload = function() { + if (xhr.status < 400) { + window[name] = JSON.parse(xhr.responseText); + DataManager.onLoad(window[name]); + } + }; + xhr.onerror = this._mapLoader || function() { + DataManager._errorUrl = DataManager._errorUrl || url; + }; + window[name] = null; + xhr.send(); +}; + +DataManager.loadMapData = function(mapId) { + if (mapId > 0) { + var filename = 'Map%1.json'.format(mapId.padZero(3)); + this._mapLoader = ResourceHandler.createLoader('data/' + filename, this.loadDataFile.bind(this, '$dataMap', filename)); + this.loadDataFile('$dataMap', filename); + } else { + this.makeEmptyMap(); + } +}; + +DataManager.loadSavefileImages = function(info) { + if (info.characters) { + for (var i = 0; i < info.characters.length; i++) { + ImageManager.reserveCharacter(info.characters[i][0]); + } + } + if (info.faces) { + for (var j = 0; j < info.faces.length; j++) { + ImageManager.reserveFace(info.faces[j][0]); + } + } +}; + +ImageManager._imageCache = new ImageCache(); +ImageManager._requestQueue = new RequestQueue(); +ImageManager._systemReservationId = Utils.generateRuntimeId(); + +ImageManager._generateCacheKey = function(path, hue){ + return path + ':' + hue; +}; + +ImageManager.loadEmptyBitmap = function() { + var empty = this._imageCache.get('empty'); + if(!empty){ + empty = new Bitmap(); + this._imageCache.add('empty', empty); + this._imageCache.reserve('empty', empty, this._systemReservationId); + } + + return empty; +}; + +ImageManager.loadNormalBitmap = function(path, hue) { + var key = this._generateCacheKey(path, hue); + var bitmap = this._imageCache.get(key); + if (!bitmap) { + bitmap = Bitmap.load(path); + bitmap.addLoadListener(function() { + bitmap.rotateHue(hue); + }); + this._imageCache.add(key, bitmap); + }else if(!bitmap.isReady()){ + bitmap.decode(); + } + + return bitmap; +}; + +ImageManager.clear = function() { + this._imageCache = new ImageCache(); +}; + +ImageManager.isReady = function() { + return this._imageCache.isReady(); +}; + +ImageManager.reserveAnimation = function(filename, hue, reservationId) { + return this.reserveBitmap('img/animations/', filename, hue, true, reservationId); +}; + +ImageManager.reserveBattleback1 = function(filename, hue, reservationId) { + return this.reserveBitmap('img/battlebacks1/', filename, hue, true, reservationId); +}; + +ImageManager.reserveBattleback2 = function(filename, hue, reservationId) { + return this.reserveBitmap('img/battlebacks2/', filename, hue, true, reservationId); +}; + +ImageManager.reserveEnemy = function(filename, hue, reservationId) { + return this.reserveBitmap('img/enemies/', filename, hue, true, reservationId); +}; + +ImageManager.reserveCharacter = function(filename, hue, reservationId) { + return this.reserveBitmap('img/characters/', filename, hue, false, reservationId); +}; + +ImageManager.reserveFace = function(filename, hue, reservationId) { + return this.reserveBitmap('img/faces/', filename, hue, true, reservationId); +}; + +ImageManager.reserveParallax = function(filename, hue, reservationId) { + return this.reserveBitmap('img/parallaxes/', filename, hue, true, reservationId); +}; + +ImageManager.reservePicture = function(filename, hue, reservationId) { + return this.reserveBitmap('img/pictures/', filename, hue, true, reservationId); +}; + +ImageManager.reserveSvActor = function(filename, hue, reservationId) { + return this.reserveBitmap('img/sv_actors/', filename, hue, false, reservationId); +}; + +ImageManager.reserveSvEnemy = function(filename, hue, reservationId) { + return this.reserveBitmap('img/sv_enemies/', filename, hue, true, reservationId); +}; + +ImageManager.reserveSystem = function(filename, hue, reservationId) { + return this.reserveBitmap('img/system/', filename, hue, false, reservationId || this._systemReservationId); +}; + +ImageManager.reserveTileset = function(filename, hue, reservationId) { + return this.reserveBitmap('img/tilesets/', filename, hue, false, reservationId); +}; + +ImageManager.reserveTitle1 = function(filename, hue, reservationId) { + return this.reserveBitmap('img/titles1/', filename, hue, true, reservationId); +}; + +ImageManager.reserveTitle2 = function(filename, hue, reservationId) { + return this.reserveBitmap('img/titles2/', filename, hue, true, reservationId); +}; + +ImageManager.reserveBitmap = function(folder, filename, hue, smooth, reservationId) { + if (filename) { + var path = folder + encodeURIComponent(filename) + '.png'; + var bitmap = this.reserveNormalBitmap(path, hue || 0, reservationId || this._defaultReservationId); + bitmap.smooth = smooth; + return bitmap; + } else { + return this.loadEmptyBitmap(); + } +}; + +ImageManager.reserveNormalBitmap = function(path, hue, reservationId){ + var bitmap = this.loadNormalBitmap(path, hue); + this._imageCache.reserve(this._generateCacheKey(path, hue), bitmap, reservationId); + + return bitmap; +}; + +ImageManager.releaseReservation = function(reservationId){ + this._imageCache.releaseReservation(reservationId); +}; + +ImageManager.setDefaultReservationId = function(reservationId){ + this._defaultReservationId = reservationId; +}; + + +ImageManager.requestAnimation = function(filename, hue) { + return this.requestBitmap('img/animations/', filename, hue, true); +}; + +ImageManager.requestBattleback1 = function(filename, hue) { + return this.requestBitmap('img/battlebacks1/', filename, hue, true); +}; + +ImageManager.requestBattleback2 = function(filename, hue) { + return this.requestBitmap('img/battlebacks2/', filename, hue, true); +}; + +ImageManager.requestEnemy = function(filename, hue) { + return this.requestBitmap('img/enemies/', filename, hue, true); +}; + +ImageManager.requestCharacter = function(filename, hue) { + return this.requestBitmap('img/characters/', filename, hue, false); +}; + +ImageManager.requestFace = function(filename, hue) { + return this.requestBitmap('img/faces/', filename, hue, true); +}; + +ImageManager.requestParallax = function(filename, hue) { + return this.requestBitmap('img/parallaxes/', filename, hue, true); +}; + +ImageManager.requestPicture = function(filename, hue) { + return this.requestBitmap('img/pictures/', filename, hue, true); +}; + +ImageManager.requestSvActor = function(filename, hue) { + return this.requestBitmap('img/sv_actors/', filename, hue, false); +}; + +ImageManager.requestSvEnemy = function(filename, hue) { + return this.requestBitmap('img/sv_enemies/', filename, hue, true); +}; + +ImageManager.requestSystem = function(filename, hue) { + return this.requestBitmap('img/system/', filename, hue, false); +}; + +ImageManager.requestTileset = function(filename, hue) { + return this.requestBitmap('img/tilesets/', filename, hue, false); +}; + +ImageManager.requestTitle1 = function(filename, hue) { + return this.requestBitmap('img/titles1/', filename, hue, true); +}; + +ImageManager.requestTitle2 = function(filename, hue) { + return this.requestBitmap('img/titles2/', filename, hue, true); +}; + +ImageManager.requestBitmap = function(folder, filename, hue, smooth) { + if (filename) { + var path = folder + encodeURIComponent(filename) + '.png'; + var bitmap = this.requestNormalBitmap(path, hue || 0); + bitmap.smooth = smooth; + return bitmap; + } else { + return this.loadEmptyBitmap(); + } +}; + +ImageManager.requestNormalBitmap = function(path, hue){ + var key = this._generateCacheKey(path, hue); + var bitmap = this._imageCache.get(key); + if(!bitmap){ + bitmap = Bitmap.request(path); + bitmap.addLoadListener(function(){ + bitmap.rotateHue(hue); + }); + this._imageCache.add(key, bitmap); + this._requestQueue.enqueue(key, bitmap); + }else{ + this._requestQueue.raisePriority(key); + } + + return bitmap; +}; + +ImageManager.update = function(){ + this._requestQueue.update(); +}; + +ImageManager.clearRequest = function(){ + this._requestQueue.clear(); +}; + +AudioManager._masterVolume = 1; // (min: 0, max: 1) + +Object.defineProperty(AudioManager, 'masterVolume', { + get: function() { + return this._masterVolume; + }, + set: function(value) { + this._masterVolume = value; + WebAudio.setMasterVolume(this._masterVolume); + Graphics.setVideoVolume(this._masterVolume); + }, + configurable: true +}); + +SceneManager._getTimeInMsWithoutMobileSafari = function() { + return performance.now(); +}; + +if (!Utils.isMobileSafari()) SceneManager._currentTime = SceneManager._getTimeInMsWithoutMobileSafari(); + +SceneManager.preferableRendererType = function() { + if (Utils.isOptionValid('canvas')) { + return 'canvas'; + } else if (Utils.isOptionValid('webgl')) { + return 'webgl'; + } else { + return 'auto'; + } +}; + +SceneManager.update = function() { + try { + this.tickStart(); + if (Utils.isMobileSafari()) { + this.updateInputData(); + } + this.updateManagers(); + this.updateMain(); + this.tickEnd(); + } catch (e) { + this.catchException(e); + } +}; + +SceneManager.updateMain = function() { + if (Utils.isMobileSafari()) { + this.changeScene(); + this.updateScene(); + } else { + var newTime = this._getTimeInMsWithoutMobileSafari(); + var fTime = (newTime - this._currentTime) / 1000; + if (fTime > 0.25) fTime = 0.25; + this._currentTime = newTime; + this._accumulator += fTime; + while (this._accumulator >= this._deltaTime) { + this.updateInputData(); + this.changeScene(); + this.updateScene(); + this._accumulator -= this._deltaTime; + } + } + this.renderScene(); + this.requestUpdate(); +}; + +SceneManager.updateManagers = function() { + ImageManager.update(); +}; + +SceneManager.changeScene = function() { + if (this.isSceneChanging() && !this.isCurrentSceneBusy()) { + if (this._scene) { + this._scene.terminate(); + this._scene.detachReservation(); + this._previousClass = this._scene.constructor; + } + this._scene = this._nextScene; + if (this._scene) { + this._scene.attachReservation(); + this._scene.create(); + this._nextScene = null; + this._sceneStarted = false; + this.onSceneCreate(); + } + if (this._exiting) { + this.terminate(); + } + } +}; + +SceneManager.resume = function() { + this._stopped = false; + this.requestUpdate(); + if (!Utils.isMobileSafari()) { + this._currentTime = this._getTimeInMsWithoutMobileSafari(); + this._accumulator = 0; + } +}; + +//----------------------------------------------------------------------------- +// 1.5.0 rpg_objects.js changes +//----------------------------------------------------------------------------- + +Game_System.prototype.saveWalkingBgm2 = function() { + this._walkingBgm = $dataMap.bgm; +}; + +Game_Message.prototype.allText = function() { + return this._texts.join('\n'); +}; + +Game_Map.prototype.autoplay = function() { + if ($dataMap.autoplayBgm) { + if ($gamePlayer.isInVehicle()) { + $gameSystem.saveWalkingBgm2(); + } else { + AudioManager.playBgm($dataMap.bgm); + } + } + if ($dataMap.autoplayBgs) { + AudioManager.playBgs($dataMap.bgs); + } +}; + +Game_Character.prototype.findDirectionTo = function(goalX, goalY) { + var searchLimit = this.searchLimit(); + var mapWidth = $gameMap.width(); + var nodeList = []; + var openList = []; + var closedList = []; + var start = {}; + var best = start; + + if (this.x === goalX && this.y === goalY) { + return 0; + } + + start.parent = null; + start.x = this.x; + start.y = this.y; + start.g = 0; + start.f = $gameMap.distance(start.x, start.y, goalX, goalY); + nodeList.push(start); + openList.push(start.y * mapWidth + start.x); + + while (nodeList.length > 0) { + var bestIndex = 0; + for (var i = 0; i < nodeList.length; i++) { + if (nodeList[i].f < nodeList[bestIndex].f) { + bestIndex = i; + } + } + + var current = nodeList[bestIndex]; + var x1 = current.x; + var y1 = current.y; + var pos1 = y1 * mapWidth + x1; + var g1 = current.g; + + nodeList.splice(bestIndex, 1); + openList.splice(openList.indexOf(pos1), 1); + closedList.push(pos1); + + if (current.x === goalX && current.y === goalY) { + best = current; + break; + } + + if (g1 >= searchLimit) { + continue; + } + + for (var j = 0; j < 4; j++) { + var direction = 2 + j * 2; + var x2 = $gameMap.roundXWithDirection(x1, direction); + var y2 = $gameMap.roundYWithDirection(y1, direction); + var pos2 = y2 * mapWidth + x2; + + if (closedList.contains(pos2)) { + continue; + } + if (!this.canPass(x1, y1, direction)) { + continue; + } + + var g2 = g1 + 1; + var index2 = openList.indexOf(pos2); + + if (index2 < 0 || g2 < nodeList[index2].g) { + var neighbor; + if (index2 >= 0) { + neighbor = nodeList[index2]; + } else { + neighbor = {}; + nodeList.push(neighbor); + openList.push(pos2); + } + neighbor.parent = current; + neighbor.x = x2; + neighbor.y = y2; + neighbor.g = g2; + neighbor.f = g2 + $gameMap.distance(x2, y2, goalX, goalY); + if (!best || neighbor.f - neighbor.g < best.f - best.g) { + best = neighbor; + } + } + } + } + + var node = best; + while (node.parent && node.parent !== start) { + node = node.parent; + } + + var deltaX1 = $gameMap.deltaX(node.x, start.x); + var deltaY1 = $gameMap.deltaY(node.y, start.y); + if (deltaY1 > 0) { + return 2; + } else if (deltaX1 < 0) { + return 4; + } else if (deltaX1 > 0) { + return 6; + } else if (deltaY1 < 0) { + return 8; + } + + var deltaX2 = this.deltaXFrom(goalX); + var deltaY2 = this.deltaYFrom(goalY); + if (Math.abs(deltaX2) > Math.abs(deltaY2)) { + return deltaX2 > 0 ? 4 : 6; + } else if (deltaY2 !== 0) { + return deltaY2 > 0 ? 8 : 2; + } + + return 0; +}; + +Game_Interpreter.prototype.setup = function(list, eventId) { + this.clear(); + this._mapId = $gameMap.mapId(); + this._eventId = eventId || 0; + this._list = list; + Game_Interpreter.requestImages(list); +}; + +// Change Tileset +Game_Interpreter.prototype.command282 = function() { + var tileset = $dataTilesets[this._params[0]]; + if(!this._imageReservationId){ + this._imageReservationId = Utils.generateRuntimeId(); + } + + var allReady = tileset.tilesetNames.map(function(tilesetName) { + return ImageManager.reserveTileset(tilesetName, 0, this._imageReservationId); + }, this).every(function(bitmap) {return bitmap.isReady();}); + + if (allReady) { + $gameMap.changeTileset(this._params[0]); + ImageManager.releaseReservation(this._imageReservationId); + this._imageReservationId = null; + + return true; + } else { + return false; + } +}; + +Game_Interpreter.requestImages = function(list, commonList){ + if(!list) return; + + list.forEach(function(command){ + var params = command.parameters; + switch(command.code){ + // Show Text + case 101: + ImageManager.requestFace(params[0]); + break; + + // Common Event + case 117: + var commonEvent = $dataCommonEvents[params[0]]; + if (commonEvent) { + if (!commonList) { + commonList = []; + } + if (!commonList.contains(params[0])) { + commonList.push(params[0]); + Game_Interpreter.requestImages(commonEvent.list, commonList); + } + } + break; + + // Change Party Member + case 129: + var actor = $gameActors.actor(params[0]); + if (actor && params[1] === 0) { + var name = actor.characterName(); + ImageManager.requestCharacter(name); + } + break; + + // Set Movement Route + case 205: + if(params[1]){ + params[1].list.forEach(function(command){ + var params = command.parameters; + if(command.code === Game_Character.ROUTE_CHANGE_IMAGE){ + ImageManager.requestCharacter(params[0]); + } + }); + } + break; + + // Show Animation, Show Battle Animation + case 212: case 337: + if(params[1]) { + var animation = $dataAnimations[params[1]]; + var name1 = animation.animation1Name; + var name2 = animation.animation2Name; + var hue1 = animation.animation1Hue; + var hue2 = animation.animation2Hue; + ImageManager.requestAnimation(name1, hue1); + ImageManager.requestAnimation(name2, hue2); + } + break; + + // Change Player Followers + case 216: + if (params[0] === 0) { + $gamePlayer.followers().forEach(function(follower) { + var name = follower.characterName(); + ImageManager.requestCharacter(name); + }); + } + break; + + // Show Picture + case 231: + ImageManager.requestPicture(params[1]); + break; + + // Change Tileset + case 282: + var tileset = $dataTilesets[params[0]]; + tileset.tilesetNames.forEach(function(tilesetName){ + ImageManager.requestTileset(tilesetName); + }); + break; + + // Change Battle Back + case 283: + if ($gameParty.inBattle()) { + ImageManager.requestBattleback1(params[0]); + ImageManager.requestBattleback2(params[1]); + } + break; + + // Change Parallax + case 284: + if (!$gameParty.inBattle()) { + ImageManager.requestParallax(params[0]); + } + break; + + // Change Actor Images + case 322: + ImageManager.requestCharacter(params[1]); + ImageManager.requestFace(params[3]); + ImageManager.requestSvActor(params[5]); + break; + + // Change Vehicle Image + case 323: + var vehicle = $gameMap.vehicle(params[0]); + if(vehicle){ + ImageManager.requestCharacter(params[1]); + } + break; + + // Enemy Transform + case 336: + var enemy = $dataEnemies[params[1]]; + var name = enemy.battlerName; + var hue = enemy.battlerHue; + if ($gameSystem.isSideView()) { + ImageManager.requestSvEnemy(name, hue); + } else { + ImageManager.requestEnemy(name, hue); + } + break; + } + }); +}; + +//----------------------------------------------------------------------------- +// 1.5.0 rpg_scenes.js changes +//----------------------------------------------------------------------------- + +Scene_Base.prototype.initialize = function() { + Stage.prototype.initialize.call(this); + this._active = false; + this._fadeSign = 0; + this._fadeDuration = 0; + this._fadeSprite = null; + this._imageReservationId = Utils.generateRuntimeId(); +}; + +Scene_Base.prototype.attachReservation = function() { + ImageManager.setDefaultReservationId(this._imageReservationId); +}; + +Scene_Base.prototype.detachReservation = function() { + ImageManager.releaseReservation(this._imageReservationId); +}; + +Scene_Base.prototype.update = function() { + this.updateFade(); + this.updateChildren(); +}; + +Scene_Boot.prototype.loadSystemWindowImage = function() { + ImageManager.reserveSystem('Window'); +}; + +Scene_Boot.loadSystemImages = function() { + ImageManager.reserveSystem('IconSet'); + ImageManager.reserveSystem('Balloon'); + ImageManager.reserveSystem('Shadow1'); + ImageManager.reserveSystem('Shadow2'); + ImageManager.reserveSystem('Damage'); + ImageManager.reserveSystem('States'); + ImageManager.reserveSystem('Weapons1'); + ImageManager.reserveSystem('Weapons2'); + ImageManager.reserveSystem('Weapons3'); + ImageManager.reserveSystem('ButtonSet'); +}; + +Scene_Boot.prototype.isGameFontLoaded = function() { + if (Graphics.isFontLoaded('GameFont')) { + return true; + } else if (!Graphics.canUseCssFontLoading()){ + var elapsed = Date.now() - this._startDate; + if (elapsed >= 60000) { + throw new Error('Failed to load GameFont'); + } + } +}; + +Scene_Map.prototype.terminate = function() { + this._bypassFirstClear = true; + Scene_Base.prototype.terminate.call(this); + if (!SceneManager.isNextScene(Scene_Battle)) { + this._spriteset.update(); + this._mapNameWindow.hide(); + SceneManager.snapForBackground(); + } else { + ImageManager.clearRequest(); + } + + if (SceneManager.isNextScene(Scene_Map)) { + ImageManager.clearRequest(); + } + + $gameScreen.clearZoom(); + + this.removeChild(this._fadeSprite); + this.removeChild(this._mapNameWindow); + this.removeChild(this._windowLayer); + this.removeChild(this._spriteset); + this.clearChildren(); +}; + +Scene_Menu.prototype.createStatusWindow = function() { + this._statusWindow = new Window_MenuStatus(this._commandWindow.width, 0); + this._statusWindow.reserveFaceImages(); + this.addWindow(this._statusWindow); +}; + +Scene_Skill.prototype.create = function() { + Scene_ItemBase.prototype.create.call(this); + this.createHelpWindow(); + this.createSkillTypeWindow(); + this.createStatusWindow(); + this.createItemWindow(); + this.createActorWindow(); +}; + +Scene_Skill.prototype.start = function() { + Scene_ItemBase.prototype.start.call(this); + this.refreshActor(); +}; + +Scene_Skill.prototype.createStatusWindow = function() { + var wx = this._skillTypeWindow.width; + var wy = this._helpWindow.height; + var ww = Graphics.boxWidth - wx; + var wh = this._skillTypeWindow.height; + this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh); + this._statusWindow.reserveFaceImages(); + this.addWindow(this._statusWindow); +}; + +Scene_Status.prototype.create = function() { + Scene_MenuBase.prototype.create.call(this); + this._statusWindow = new Window_Status(); + this._statusWindow.setHandler('cancel', this.popScene.bind(this)); + this._statusWindow.setHandler('pagedown', this.nextActor.bind(this)); + this._statusWindow.setHandler('pageup', this.previousActor.bind(this)); + this._statusWindow.reserveFaceImages(); + this.addWindow(this._statusWindow); +}; + +Scene_Status.prototype.start = function() { + Scene_MenuBase.prototype.start.call(this); + this.refreshActor(); +}; + +Scene_Battle.prototype.terminate = function() { + Scene_Base.prototype.terminate.call(this); + $gameParty.onBattleEnd(); + $gameTroop.onBattleEnd(); + AudioManager.stopMe(); + + ImageManager.clearRequest(); +}; + +//----------------------------------------------------------------------------- +// 1.5.0 rpg_sprites.js changes +//----------------------------------------------------------------------------- + +Sprite_Animation.prototype.isReady = function() { + return this._bitmap1 && this._bitmap1.isReady() && this._bitmap2 && this._bitmap2.isReady(); +}; + +Sprite_Animation.prototype.updateCellSprite = function(sprite, cell) { + var pattern = cell[0]; + if (pattern >= 0) { + var sx = pattern % 5 * 192; + var sy = Math.floor(pattern % 100 / 5) * 192; + var mirror = this._mirror; + sprite.bitmap = pattern < 100 ? this._bitmap1 : this._bitmap2; + sprite.setFrame(sx, sy, 192, 192); + sprite.x = cell[1]; + sprite.y = cell[2]; + sprite.rotation = cell[4] * Math.PI / 180; + sprite.scale.x = cell[3] / 100; + + if(cell[5]){ + sprite.scale.x *= -1; + } + if(mirror){ + sprite.x *= -1; + sprite.rotation *= -1; + sprite.scale.x *= -1; + } + + sprite.scale.y = cell[3] / 100; + sprite.opacity = cell[6]; + sprite.blendMode = cell[7]; + sprite.visible = true; + } else { + sprite.visible = false; + } +}; + +//----------------------------------------------------------------------------- +// 1.5.0 rpg_windows.js changes +//----------------------------------------------------------------------------- + +Window_Base.prototype.reserveFaceImages = function() { + $gameParty.members().forEach(function(actor) { + ImageManager.reserveFace(actor.faceName()); + }, this); +}; + +Window_MenuStatus.prototype.initialize = function(x, y) { + var width = this.windowWidth(); + var height = this.windowHeight(); + Window_Selectable.prototype.initialize.call(this, x, y, width, height); + this._formationMode = false; + this._pendingIndex = -1; + this.refresh(); +}; + +Window_MenuStatus.prototype.loadImages = function() { + $gameParty.members().forEach(function(actor) { + ImageManager.reserveFace(actor.faceName()); + }, this); +}; + +Window_Status.prototype.initialize = function() { + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + Window_Selectable.prototype.initialize.call(this, 0, 0, width, height); + this._actor = null; + this.refresh(); + this.activate(); +}; + +Window_NameEdit.prototype.initialize = function(actor, maxLength) { + var width = this.windowWidth(); + var height = this.windowHeight(); + var x = (Graphics.boxWidth - width) / 2; + var y = (Graphics.boxHeight - (height + this.fittingHeight(9) + 8)) / 2; + Window_Base.prototype.initialize.call(this, x, y, width, height); + this._actor = actor; + this._name = actor.name().slice(0, this._maxLength); + this._index = this._name.length; + this._maxLength = maxLength; + this._defaultName = this._name; + this.deactivate(); + this.refresh(); + ImageManager.reserveFace(actor.faceName()); +}; + +Window_Message.prototype.initMembers = function() { + this._imageReservationId = Utils.generateRuntimeId(); + this._background = 0; + this._positionType = 2; + this._waitCount = 0; + this._faceBitmap = null; + this._textState = null; + this.clearFlags(); +}; + +Window_Message.prototype.updateLoading = function() { + if (this._faceBitmap) { + if (this._faceBitmap.isReady()) { + this.drawMessageFace(); + this._faceBitmap = null; + return false; + } else { + return true; + } + } else { + return false; + } +}; + +Window_Message.prototype.loadMessageFace = function() { + this._faceBitmap = ImageManager.reserveFace($gameMessage.faceName(), 0, this._imageReservationId); +}; + +Window_Message.prototype.drawMessageFace = function() { + this.drawFace($gameMessage.faceName(), $gameMessage.faceIndex(), 0, 0); + ImageManager.releaseReservation(this._imageReservationId); +}; + +//============================================================================= +// Version 1.4.0 to 1.5.0 Changes End +//============================================================================= + +}; // Yanfly.Param.Update150 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.5.0 to 1.5.1 Changes +//============================================================================= + +if (Yanfly.Param.Update151) { + +//----------------------------------------------------------------------------- +// 1.5.1 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.5.1. +Utils.RPGMAKER_VERSION = '1.5.1'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Sprite.prototype._renderWebGL = function(renderer) { + if (this.bitmap) { + this.bitmap.touch(); + } + if(this.bitmap && !this.bitmap.isReady()){ + return; + } + if (this.texture.frame.width > 0 && this.texture.frame.height > 0) { + if (this._bitmap) { + this._bitmap.checkDirty(); + } + + //copy of pixi-v4 internal code + this.calculateVertices(); + + if (this.pluginName === 'sprite' && this._isPicture) { + // use heavy renderer, which reduces artifacts and applies corrent blendMode, + // but does not use multitexture optimization + this._speedUpCustomBlendModes(renderer); + renderer.setObjectRenderer(renderer.plugins.picture); + renderer.plugins.picture.render(this); + } else { + // use pixi super-speed renderer + renderer.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + } + } +}; + +PIXI.settings.GC_MODE = PIXI.GC_MODES.AUTO; + +//----------------------------------------------------------------------------- +// 1.5.1 rpg_managers.js changes +//----------------------------------------------------------------------------- + +BattleManager.initMembers = function() { + this._phase = 'init'; + this._canEscape = false; + this._canLose = false; + this._battleTest = false; + this._eventCallback = null; + this._preemptive = false; + this._surprise = false; + this._actorIndex = -1; + this._actionForcedBattler = null; + this._mapBgm = null; + this._mapBgs = null; + this._actionBattlers = []; + this._subject = null; + this._action = null; + this._targets = []; + this._logWindow = null; + this._statusWindow = null; + this._spriteset = null; + this._escapeRatio = 0; + this._escaped = false; + this._rewards = {}; + this._turnForced = false; +}; + +BattleManager.endTurn = function() { + this._phase = 'turnEnd'; + this._preemptive = false; + this._surprise = false; + this.allBattleMembers().forEach(function(battler) { + battler.onTurnEnd(); + this.refreshStatus(); + this._logWindow.displayAutoAffectedStatus(battler); + this._logWindow.displayRegeneration(battler); + }, this); + if (this.isForcedTurn()) { + this._turnForced = false; + } +}; + +BattleManager.processForcedAction = function() { + if (this._actionForcedBattler) { + this._turnForced = true; + this._subject = this._actionForcedBattler; + this._actionForcedBattler = null; + this.startAction(); + this._subject.removeCurrentAction(); + } +}; + +//----------------------------------------------------------------------------- +// 1.5.1 rpg_objects.js Changes +//----------------------------------------------------------------------------- + +// Control Variables +Game_Interpreter.prototype.command122 = function() { + var value = 0; + switch (this._params[3]) { // Operand + case 0: // Constant + value = this._params[4]; + break; + case 1: // Variable + value = $gameVariables.value(this._params[4]); + break; + case 2: // Random + value = this._params[5] - this._params[4] + 1; + for (var i = this._params[0]; i <= this._params[1]; i++) { + this.operateVariable(i, this._params[2], this._params[4] + Math.randomInt(value)); + } + return true; + break; + case 3: // Game Data + value = this.gameDataOperand(this._params[4], this._params[5], this._params[6]); + break; + case 4: // Script + var value = 0; + var code = this._params[4]; + try { + value = eval(code); + } catch (e) { + Yanfly.Util.displayError(e, code, 'CONTROL VARIABLE SCRIPT ERROR'); + } + for (var i = this._params[0]; i <= this._params[1]; i++) { + this.operateVariable(i, this._params[2], value); + } + return true; + break; + } + for (var i = this._params[0]; i <= this._params[1]; i++) { + this.operateVariable(i, this._params[2], value); + } + return true; +}; + +//============================================================================= +// Version 1.5.0 to 1.5.1 Changes End +//============================================================================= + +}; // Yanfly.Param.Update151 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.5.1 to 1.5.2 Changes +//============================================================================= + +if (Yanfly.Param.Update152) { + +//----------------------------------------------------------------------------- +// 1.5.2 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.5.2. +Utils.RPGMAKER_VERSION = '1.5.2'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Graphics.initialize = function(width, height, type) { + this._width = width || 800; + this._height = height || 600; + this._rendererType = type || 'auto'; + this._boxWidth = this._width; + this._boxHeight = this._height; + + this._scale = 1; + this._realScale = 1; + + this._errorShowed = false; + this._errorPrinter = null; + this._canvas = null; + this._video = null; + this._videoUnlocked = false; + this._videoLoading = false; + this._upperCanvas = null; + this._renderer = null; + this._fpsMeter = null; + this._modeBox = null; + this._skipCount = 0; + this._maxSkip = 3; + this._rendered = false; + this._loadingImage = null; + this._loadingCount = 0; + this._fpsMeterToggled = false; + this._stretchEnabled = this._defaultStretchMode(); + + this._canUseDifferenceBlend = false; + this._canUseSaturationBlend = false; + this._hiddenCanvas = null; + + this._testCanvasBlendModes(); + this._modifyExistingElements(); + this._updateRealScale(); + this._createAllElements(); + this._disableTextSelection(); + this._disableContextMenu(); + this._setupEventHandlers(); + this._setupCssFontLoading(); +}; + +Graphics._setupEventHandlers = function() { + window.addEventListener('resize', this._onWindowResize.bind(this)); + document.addEventListener('keydown', this._onKeyDown.bind(this)); + document.addEventListener('keydown', this._onTouchEnd.bind(this)); + document.addEventListener('mousedown', this._onTouchEnd.bind(this)); + document.addEventListener('touchend', this._onTouchEnd.bind(this)); +}; + +WebAudio._setupEventHandlers = function() { + var resumeHandler = function() { + var context = WebAudio._context; + if (context && context.state === "suspended" && typeof context.resume === "function") { + context.resume().then(function() { + WebAudio._onTouchStart(); + }) + } else { + WebAudio._onTouchStart(); + } + }; + document.addEventListener("keydown", resumeHandler); + document.addEventListener("mousedown", resumeHandler); + document.addEventListener("touchend", resumeHandler); + document.addEventListener('touchstart', this._onTouchStart.bind(this)); + document.addEventListener('visibilitychange', this._onVisibilityChange.bind(this)); +}; + +//----------------------------------------------------------------------------- +// 1.5.2 rpg_managers.js changes +//----------------------------------------------------------------------------- + +BattleManager.updateEvent = function() { + switch (this._phase) { + case 'start': + case 'turn': + case 'turnEnd': + if (this.isActionForced()) { + this.processForcedAction(); + return true; + } else { + return this.updateEventMain(); + } + } + return this.checkAbort(); +}; + +BattleManager.checkAbort = function() { + if ($gameParty.isEmpty() || this.isAborting()) { + this.processAbort(); + return true; + } + return false; +}; + +// Break Loop +Game_Interpreter.prototype.command113 = function() { + var depth = 0; + while (this._index < this._list.length - 1) { + this._index++; + var command = this.currentCommand(); + + if (command.code === 112) + depth++; + + if (command.code === 413 && command.indent < this._indent) { + if (depth > 0) + depth--; + else + break; + } + } + return true; +}; + +//----------------------------------------------------------------------------- +// 1.5.2 rpg_sprites.js changes +//----------------------------------------------------------------------------- + +Spriteset_Battle.prototype.overworldBattleback1Name = function() { + if ($gameMap.battleback1Name() === '') return ''; + if ($gamePlayer.isInVehicle()) { + return this.shipBattleback1Name(); + } else { + return this.normalBattleback1Name(); + } +}; + +Spriteset_Battle.prototype.overworldBattleback2Name = function() { + if ($gameMap.battleback2Name() === '') return ''; + if ($gamePlayer.isInVehicle()) { + return this.shipBattleback2Name(); + } else { + return this.normalBattleback2Name(); + } +}; + +//============================================================================= +// Version 1.5.1 to 1.5.2 Changes End +//============================================================================= + +}; // Yanfly.Param.Update152 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version 1.5.2 to 1.6.1 Changes +//============================================================================= + +if (Yanfly.Param.Update161) { + +//----------------------------------------------------------------------------- +// 1.6.1 rpg_core.js changes +//----------------------------------------------------------------------------- + +// Treat the version for the rest of the plugins in the list as version 1.5.2. +Utils.RPGMAKER_VERSION = '1.6.1'; +console.log('RPG Maker Version ' + Utils.RPGMAKER_VERSION + ' updates loaded'); + +Utils.isOptionValid = function(name) { + if (location.search.slice(1).split('&').contains(name)) {return 1;}; + if (typeof nw !== "undefined" && nw.App.argv.length > 0 && nw.App.argv[0].split('&').contains(name)) {return 1;}; + return 0; +}; + +WebAudio.prototype._startPlaying = function(loop, offset) { + if (this._loopLength > 0) { + while (offset >= this._loopStart + this._loopLength) { + offset -= this._loopLength; + } + } + this._removeEndTimer(); + this._removeNodes(); + this._createNodes(); + this._connectNodes(); + this._sourceNode.loop = loop; + this._sourceNode.start(0, offset); + this._startTime = WebAudio._context.currentTime - offset / this._pitch; + this._createEndTimer(); +}; + +//----------------------------------------------------------------------------- +// 1.6.1 rpg_objects.js changes +//----------------------------------------------------------------------------- + +// Break Loop +Game_Interpreter.prototype.command113 = function() { + var depth = 0; + while (this._index < this._list.length - 1) { + this._index++; + var command = this.currentCommand(); + + if (command.code === 112) + depth++; + + if (command.code === 413) { + if (depth > 0) + depth--; + else + break; + } + } + return true; +}; + +//============================================================================= +// Version 1.5.2 to 1.6.1 Changes End +//============================================================================= + +}; // Yanfly.Param.Update152 + +//----------------------------------------------------------------------------- + +//============================================================================= +// Desktop Optimization Changes +//============================================================================= + +//----------------------------------------------------------------------------- +// Desktop Optimization rpg_core.js Changes +//----------------------------------------------------------------------------- + +if (Yanfly.Param.UpdateDesktop) { + +// Set up a flag to signify the Yanfly Desktop Optimization plugin is used. +// This is done for compatibility reasons. +Utils.RPGMAKER_VERSION.Yanfly = true; + +// Replaced ForEach +Sprite.prototype.update = function() { + var length = this.children.length; + for (var i = 0; i < length; ++i) { + var child = this.children[i]; + if (child && child.update) child.update(); + }; +}; + +// Replaced ForEach +Tilemap.prototype.update = function() { + this.animationCount++; + this.animationFrame = Math.floor(this.animationCount / 30); + var length = this.children.length; + for (var i = 0; i < length; ++i) { + var child = this.children[i]; + if (child && child.update) child.update(); + } + var length = this.bitmaps.length; + for (var i = 0; i < length; ++i) { + if (this.bitmaps[i]) this.bitmaps[i].touch(); + } +}; + +// Replaced ForEach +TilingSprite.prototype.update = function() { + var length = this.children.length; + for (var i = 0; i < length; ++i) { + var child = this.children[i]; + if (child && child.update) child.update(); + } +}; + +// Replaced ForEach +Window.prototype.update = function() { + if (this.active) this._animationCount++; + var length = this.children.length; + for (var i = 0; i < length; ++i) { + var child = this.children[i]; + if (child && child.update) child.update(); + } +}; + +// Replaced ForEach +WindowLayer.prototype.update = function() { + var length = this.children.length; + for (var i = 0; i < length; ++i) { + var child = this.children[i]; + if (child && child.update) child.update(); + } +}; + +// Replaced ForEach +Weather.prototype._updateAllSprites = function() { + var maxSprites = Math.floor(this.power * 10); + while (this._sprites.length < maxSprites) { + this._addSprite(); + } + while (this._sprites.length > maxSprites) { + this._removeSprite(); + } + var length = this._sprites.length; + for (var i = 0; i < length; ++i) { + var sprite = this._sprites[i]; + this._updateSprite(sprite); + sprite.x = sprite.ax - this.origin.x; + sprite.y = sprite.ay - this.origin.y; + } +}; + +//----------------------------------------------------------------------------- +// Desktop Optimizatioin rpg_managers.js Changes +//----------------------------------------------------------------------------- + +// Maintaining an old, renamed function +SceneManager._getTimeInMs = function() { + return performance.now(); +}; + +// Switched ImageManager.reserves into ImageManager.loads +DataManager.loadSavefileImages = function(info) { + if (info.characters) { + for (var i = 0; i < info.characters.length; i++) { + ImageManager.loadCharacter(info.characters[i][0]); + } + } + if (info.faces) { + for (var j = 0; j < info.faces.length; j++) { + ImageManager.loadFace(info.faces[j][0]); + } + } +}; + +ImageManager.loadEmptyBitmap = function() { + var empty = this.cache.getItem('empty'); + if (!empty) { + empty = new Bitmap(); + this.cache.setItem('empty', empty); + } + return empty; +}; + +ImageManager.loadNormalBitmap = function(path, hue) { + var key = path + ':' + hue; + var bitmap = this.cache.getItem(key); + if (!bitmap) { + bitmap = Bitmap.load(path); + bitmap.addLoadListener(function() { + bitmap.rotateHue(hue); + }); + this.cache.setItem(key, bitmap); + } + return bitmap; +}; + +ImageManager.clear = function() { + this.cache.clear(); +}; + +ImageManager.isReady = function() { + for (var key in this.cache._inner) { + var bitmap = this.cache._inner[key].item; + if (bitmap.isError()) { + throw new Error('Failed to load: ' + bitmap.url); + } + if (!bitmap.isReady()) { + return false; + } + } + return true; +}; + +// Added shouldUseCanvasRenderer condition +SceneManager.preferableRendererType = function() { + if (Utils.isOptionValid('canvas')) { + return 'canvas'; + } else if (Utils.isOptionValid('webgl')) { + return 'webgl'; + } else if (this.shouldUseCanvasRenderer()) { + return 'canvas'; + } else { + return 'auto'; + } +}; + +// Removed this.updateManagers +SceneManager.update = function() { + try { + this.tickStart(); + if (Utils.isMobileSafari()) { + this.updateInputData(); + } + this.updateMain(); + this.tickEnd(); + } catch (e) { + this.catchException(e); + } +}; + +// Refer to this._getTimeInMs instead of this._getTimeInMsWithoutMobileSafari +SceneManager.updateMain = function() { + if (Utils.isMobileSafari()) { + this.changeScene(); + this.updateScene(); + } else { + var newTime = this._getTimeInMs(); + var fTime = (newTime - this._currentTime) / 1000; + if (fTime > 0.25) fTime = 0.25; + this._currentTime = newTime; + this._accumulator += fTime; + while (this._accumulator >= this._deltaTime) { + this.updateInputData(); + this.changeScene(); + this.updateScene(); + this._accumulator -= this._deltaTime; + } + } + this.renderScene(); + this.requestUpdate(); +}; + +// Utilize former cache system +SceneManager.updateManagers = function(ticks, delta) { + ImageManager.cache.update(ticks, delta); +}; + +//----------------------------------------------------------------------------- +// Desktop Optimization rpg_objects.js Changes +//----------------------------------------------------------------------------- + +// No longer loads reserved images +Game_Interpreter.prototype.setup = function(list, eventId) { + this.clear(); + this._mapId = $gameMap.mapId(); + this._eventId = eventId || 0; + this._list = list; +}; + +// Change Tileset Event: load instead of reserve +Game_Interpreter.prototype.command282 = function() { + var tileset = $dataTilesets[this._params[0]]; + for (var i = 0; i < tileset.tilesetNames.length; i++) { + ImageManager.loadTileset(tileset.tilesetNames[i]); + } + if (ImageManager.isReady()) { + $gameMap.changeTileset(this._params[0]); + return true; + } else { + return false; + } +}; + +//----------------------------------------------------------------------------- +// Desktop Optimization rpg_scenes.js Changes +//----------------------------------------------------------------------------- + +// Removal of reservation ID +Scene_Base.prototype.initialize = function() { + Stage.prototype.initialize.call(this); + this._active = false; + this._fadeSign = 0; + this._fadeDuration = 0; + this._fadeSprite = null; +}; + +// Audio error checking added +Scene_Base.prototype.update = function() { + this.updateFade(); + this.updateChildren(); + AudioManager.checkErrors(); +}; + +// Replaced ForEach +Scene_Base.prototype.updateChildren = function() { + var length = this.children.length; + for (var i = 0; i < length; ++i) { + var child = this.children[i]; + if (child.update) child.update(); + } +}; + +// Loaded image instead of reserving it +Scene_Boot.prototype.loadSystemWindowImage = function() { + ImageManager.loadSystem('Window'); +}; + +// Loaded images instead of reserving them +Scene_Boot.loadSystemImages = function() { + ImageManager.loadSystem('IconSet'); + ImageManager.loadSystem('Balloon'); + ImageManager.loadSystem('Shadow1'); + ImageManager.loadSystem('Shadow2'); + ImageManager.loadSystem('Damage'); + ImageManager.loadSystem('States'); + ImageManager.loadSystem('Weapons1'); + ImageManager.loadSystem('Weapons2'); + ImageManager.loadSystem('Weapons3'); + ImageManager.loadSystem('ButtonSet'); +}; + +// Game font now loads instead of being in the process of loading +// Loading time upped to 60 seconds from 20 +Scene_Boot.prototype.isGameFontLoaded = function() { + if (Graphics.isFontLoaded('GameFont')) { + return true; + } else { + var elapsed = Date.now() - this._startDate; + if (elapsed >= 60000) { + throw new Error('Failed to load GameFont'); + } + } +}; + +// Clear requests removed for image reservation +Scene_Map.prototype.terminate = function() { + this._bypassFirstClear = true; + Scene_Base.prototype.terminate.call(this); + if (!SceneManager.isNextScene(Scene_Battle)) { + this._spriteset.update(); + this._mapNameWindow.hide(); + SceneManager.snapForBackground(); + } + $gameScreen.clearZoom(); + this.removeChild(this._fadeSprite); + this.removeChild(this._mapNameWindow); + this.removeChild(this._windowLayer); + this.removeChild(this._spriteset); + this.clearChildren(); +}; + +// Face reservation removed +Scene_Menu.prototype.createStatusWindow = function() { + this._statusWindow = new Window_MenuStatus(this._commandWindow.width, 0); + this.addWindow(this._statusWindow); +}; + +// Replaced ForEach +Scene_ItemBase.prototype.applyItem = function() { + var action = new Game_Action(this.user()); + action.setItemObject(this.item()); + var repeats = action.numRepeats(); + var items = this.itemTargetActors(); + var length = items.length; + for (var i = 0; i < length; ++i) { + var target = items[i]; + for (var j = 0; j < repeats; ++j) { + action.apply(target); + } + }; + action.applyGlobal(); +}; + +// Refreshing the actor now occurs upon creation and instead of start +Scene_Skill.prototype.create = function() { + Scene_ItemBase.prototype.create.call(this); + this.createHelpWindow(); + this.createSkillTypeWindow(); + this.createStatusWindow(); + this.createItemWindow(); + this.createActorWindow(); + this.refreshActor(); +}; + +// Refreshing the actor now occurs upon creation and instead of start +Scene_Skill.prototype.start = function() { + Scene_ItemBase.prototype.start.call(this); +}; + +// Face reservation removed +Scene_Skill.prototype.createStatusWindow = function() { + var wx = this._skillTypeWindow.width; + var wy = this._helpWindow.height; + var ww = Graphics.boxWidth - wx; + var wh = this._skillTypeWindow.height; + this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh); + this.addWindow(this._statusWindow); +}; + +// Refreshing the actor now occurs upon creation and instead of start +Scene_Status.prototype.create = function() { + Scene_MenuBase.prototype.create.call(this); + this._statusWindow = new Window_Status(); + this._statusWindow.setHandler('cancel', this.popScene.bind(this)); + this._statusWindow.setHandler('pagedown', this.nextActor.bind(this)); + this._statusWindow.setHandler('pageup', this.previousActor.bind(this)); + this._statusWindow.reserveFaceImages(); + this.addWindow(this._statusWindow); + this.refreshActor(); +}; + +// Refreshing the actor now occurs upon creation and instead of start +Scene_Status.prototype.start = function() { + Scene_MenuBase.prototype.start.call(this); +}; + +// Image Reservation Clear Request removed +Scene_Battle.prototype.terminate = function() { + Scene_Base.prototype.terminate.call(this); + $gameParty.onBattleEnd(); + $gameTroop.onBattleEnd(); + AudioManager.stopMe(); +}; + +//----------------------------------------------------------------------------- +// Desktop Optimization rpg_sprites.js Changes +//----------------------------------------------------------------------------- + +// Ready preparation now refers to fully loaded instead of reservation +Sprite_Animation.prototype.isReady = function() { + return ImageManager.isReady(); +}; + +// Replaced ForEach +Sprite_Animation.prototype.updateFrame = function() { + if (this._duration > 0) { + var frameIndex = this.currentFrameIndex(); + this.updateAllCellSprites(this._animation.frames[frameIndex]); + var length = this._animation.timings.length; + for (var i = 0; i < length; ++i) { + var timing = this._animation.timings[i]; + if (timing.frame === frameIndex) this.processTimingData(timing); + }; + } +}; + +// Cleaning algorithm up +Sprite_Animation.prototype.updateCellSprite = function(sprite, cell) { + var pattern = cell[0]; + if (pattern >= 0) { + var sx = pattern % 5 * 192; + var sy = Math.floor(pattern % 100 / 5) * 192; + var mirror = this._mirror; + sprite.bitmap = pattern < 100 ? this._bitmap1 : this._bitmap2; + sprite.setFrame(sx, sy, 192, 192); + sprite.x = cell[1]; + sprite.y = cell[2]; + if (this._mirror) { + sprite.x *= -1; + } + sprite.rotation = cell[4] * Math.PI / 180; + sprite.scale.x = cell[3] / 100; + if ((cell[5] && !mirror) || (!cell[5] && mirror)) { + sprite.scale.x *= -1; + } + sprite.scale.y = cell[3] / 100; + sprite.opacity = cell[6]; + sprite.blendMode = cell[7]; + sprite.visible = true; + } else { + sprite.visible = false; + } +}; + +//----------------------------------------------------------------------------- +// Desktop Optimization rpg_windows.js Changes +//----------------------------------------------------------------------------- + +// Load images upon initializing +Window_MenuStatus.prototype.initialize = function(x, y) { + var width = this.windowWidth(); + var height = this.windowHeight(); + Window_Selectable.prototype.initialize.call(this, x, y, width, height); + this._formationMode = false; + this._pendingIndex = -1; + this.loadImages(); + this.refresh(); +}; + +// Load images instead of reserving +Window_MenuStatus.prototype.loadImages = function() { + $gameParty.members().forEach(function(actor) { + ImageManager.loadFace(actor.faceName()); + }, this); +}; + +// Removed actor null initializing +Window_Status.prototype.initialize = function() { + var width = Graphics.boxWidth; + var height = Graphics.boxHeight; + Window_Selectable.prototype.initialize.call(this, 0, 0, width, height); + this.refresh(); + this.activate(); +}; + +// Actor face loaded instead of reserved +Window_NameEdit.prototype.initialize = function(actor, maxLength) { + var width = this.windowWidth(); + var height = this.windowHeight(); + var x = (Graphics.boxWidth - width) / 2; + var y = (Graphics.boxHeight - (height + this.fittingHeight(9) + 8)) / 2; + Window_Base.prototype.initialize.call(this, x, y, width, height); + this._actor = actor; + this._name = actor.name().slice(0, this._maxLength); + this._index = this._name.length; + this._maxLength = maxLength; + this._defaultName = this._name; + this.deactivate(); + this.refresh(); + ImageManager.loadFace(actor.faceName()); +}; + +// Image reservation ID removal +Window_Message.prototype.initMembers = function() { + this._background = 0; + this._positionType = 2; + this._waitCount = 0; + this._faceBitmap = null; + this._textState = null; + this.clearFlags(); +}; + +// Proper ready check for image loading instead of reservation +Window_Message.prototype.updateLoading = function() { + if (this._faceBitmap) { + if (ImageManager.isReady()) { + this.drawMessageFace(); + this._faceBitmap = null; + return false; + } else { + return true; + } + } else { + return false; + } +}; + +// Face bitmap loaded instead of reserved +Window_Message.prototype.loadMessageFace = function() { + this._faceBitmap = ImageManager.loadFace($gameMessage.faceName()); +}; + +// Removal of reservation release function +Window_Message.prototype.drawMessageFace = function() { + this.drawFace($gameMessage.faceName(), $gameMessage.faceIndex(), 0, 0); +}; + +//============================================================================= +// Desktop Optimization Changes End +//============================================================================= + +}; // Yanfly.Param.UpdateDesktop + +//============================================================================= +// Maximize Path Finding +//============================================================================= + +ImageManager.loadNormalBitmap = function(path, hue) { + var key = path + ':' + hue; + var bitmap = this.cache.getItem(key); + if (!bitmap) { + bitmap = Bitmap.load(decodeURIComponent(path)) + bitmap.addLoadListener(function() { + bitmap.rotateHue(hue); + }); + this.cache.setItem(key, bitmap); + } + return bitmap; +}; + + +//----------------------------------------------------------------------------- + +//============================================================================= +// Version Fail Checks +//============================================================================= +} else if (!Utils.RPGMAKER_VERSION) { + +var text = ''; +text += 'You are getting this error because you are trying to run YEP_X_CoreUp'; +text += 'datesOpt while your project files are lower than version 1.4.0. \n\n'; +text += 'Please visit this thread for instructions on how to update your '; +text += 'project files to 1.4.0 or higher: \n\n'; +text += 'http://forums.rpgmakerweb.com/'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} else if (Utils.RPGMAKER_VERSION < '1.4.0') { + +var text = ''; +text += 'You are getting this error because you are trying to run YEP_X_CoreUp'; +text += 'datesOpt while your project files are lower than version 1.4.0. \n\n'; +text += 'Please visit this thread for instructions on how to update your '; +text += 'project files to 1.4.0 or higher: \n\n'; +text += 'http://forums.rpgmakerweb.com/'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} else { + +var text = ''; +text += 'You are getting this error because you are trying to run '; +text += 'YEP_X_CoreUpdatesOpt without the required plugins. Please visit '; +text += 'Yanfly.moe and install the required plugins neede for this plugin '; +text += 'found in this plugin\'s help file before you can use it.'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +}; // Yanfly.PluginRequirements +//============================================================================= +// End of File +//============================================================================= \ No newline at end of file diff --git a/js/plugins/YEP_X_ExtMovePack1.js b/js/plugins/YEP_X_ExtMovePack1.js new file mode 100644 index 0000000..b450fc6 --- /dev/null +++ b/js/plugins/YEP_X_ExtMovePack1.js @@ -0,0 +1,369 @@ +//============================================================================= +// Yanfly Engine Plugins - Move Route Extension - Extended Move Pack 1 +// YEP_X_ExtMovePack1.js +//============================================================================= + +if (Imported.YEP_MoveRouteCore) { + +var Imported = Imported || {}; +Imported.YEP_X_ExtMovePack1 = true; + +var Yanfly = Yanfly || {}; +Yanfly.EMvP1 = Yanfly.EMvP1 || {}; +Yanfly.EMvP1.version = 1.01; + +//============================================================================= + /*: + * @plugindesc v1.01 (Requires YEP_MoveRouteCore.js) Adds extra movement + * options to create specific behaviors in movement patterns. + * @author Yanfly Engine Plugins + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin requires YEP_MoveRouteCore. Make sure this plugin is located + * under YEP_MoveRouteCore in the plugin list. + * + * This plugin adds extra simplified move routes for your events with the main + * intention of creating specific behaviors in movement patterns. The patterns + * include the option to hug a side of the wall and move along that, moving a + * single direction until coming to a stop, relative opacity adjusting, and + * index shifting. + * + * ============================================================================ + * Instructions - Additional Simplified Movement Routes + * ============================================================================ + * + * If you want to make events move a certain way using the commands from this + * plugin, do the following: + * + * 1. Open the event you wish to move. + * 2. Make a Movement Route command or Automatic Custom Route. + * 3. Press "Script..." + * 4. Type in any of the desired following commands: + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * HUG LEFT WALL + * HUG RIGHT WALL + * + * AVOID HUG LEFT WALL + * AVOID HUG RIGHT WALL + * + * CRASH HUG LEFT WALL + * CRASH HUG RIGHT WALL + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * The designated event will move alongside the wall to its left/right. If + * there is no wall to its left/right side, it will turn that direction and + * move that direction if possible. + * + * 'Avoid Hug Left Wall' and 'Avoid Hug Right Wall' will make the event not + * collide with the player character and the player's followers. + * + * 'Crash Hug Left Wall' and 'Crash Hug Right Wall' will allow collision with + * the player and/or followers. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Hug Left Wall + * Hug Right Wall + * Avoid Hug Left Wall + * Avoid Hug Right Wall + * Crash Hug Left Wall + * Crash Hug Right Wall + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * INDEX: x + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Sets the designated event's current character graphic index to x without + * needing to change its character graphic. + * Replace x with integar values between 0 and 7. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Index: 5 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * INDEX: +x + * INDEX: -x + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Adjusts the designated event's current character graphic index by +x or -x + * without needing to change its character graphic as to move it a few stages. + * The index cannot go under 0 and cannot go over 7. + * Replace x with integar values between 0 and 7. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Index: +1 + * Index: -2 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * MOVE UP UNTIL STOP + * MOVE LEFT UNTIL STOP + * MOVE RIGHT UNTIL STOP + * MOVE DOWN UNTIL STOP + * MOVE UPPER LEFT UNTIL STOP + * MOVE UPPER RIGHT UNTIL STOP + * MOVE LOWER LEFT UNTIL STOP + * MOVE LOWER RIGHT UNTIL STOP + * + * AVOID MOVE UP UNTIL STOP + * AVOID MOVE LEFT UNTIL STOP + * AVOID MOVE RIGHT UNTIL STOP + * AVOID MOVE DOWN UNTIL STOP + * AVOID MOVE UPPER LEFT UNTIL STOP + * AVOID MOVE UPPER RIGHT UNTIL STOP + * AVOID MOVE LOWER LEFT UNTIL STOP + * AVOID MOVE LOWER RIGHT UNTIL STOP + * + * CRASH MOVE UP UNTIL STOP + * CRASH MOVE LEFT UNTIL STOP + * CRASH MOVE RIGHT UNTIL STOP + * CRASH MOVE DOWN UNTIL STOP + * CRASH MOVE UPPER LEFT UNTIL STOP + * CRASH MOVE UPPER RIGHT UNTIL STOP + * CRASH MOVE LOWER LEFT UNTIL STOP + * CRASH MOVE LOWER RIGHT UNTIL STOP + * + * MOVE FORWARD UNTIL STOP + * AVOID MOVE FORWARD UNTIL STOP + * CRASH MOVE FORWARD UNTIL STOP + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * The designated event will keep moving the noted direction until it it cannot + * pass in that direction anymore. Once that happens, it will move onto the + * next movement command in the move route list. + * + * The 'Avoid' versions of this command will make the event not collide with + * the player character and the player's followers. + * + * The 'Crash' versions of this command will allow collision with the player + * and/or followers. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Move Right Until Stop + * Avoid Move Left Until Stop + * Crash Move Forward Until Stop + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * OPACITY: +x + * OPACITY: -x + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Adjusts the designated event's opacity value by +x or -x instead of a set + * value like the editor's opacity command. The opacity value will be added + * upon or subtracted upon the current opacity value. + * Replace x with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Opacity: +50 + * Opacity: -30 + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * OPACITY: +x% + * OPACITY: -x% + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Adjusts the designated event's opacity value by +x% or -x% instead of a set + * value like the editor's opacity command. The opacity value will be added + * upon or subtracted upon the current opacity value. + * Replace x with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Opacity: +10% + * Opacity: -20% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * OPACITY: x% + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Sets the designated event's opacity value to x% instead of a set value like + * the editor's opacity command. The opacity value will be automatically + * adjusted to meet the demands of the sprite. + * Replace x with integar values. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Example: Opacity: 50% + * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + * + * ============================================================================ + * Changelog + * ============================================================================ + * + * Version 1.01: + * - Updated for RPG Maker MV version 1.5.0. + * + * Version 1.00: + * - Finished Plugin! + */ +//============================================================================= + +//============================================================================= +// Game_Character +//============================================================================= + +Yanfly.EMvP1.Game_Character_processMoveRouteScriptCall = + Game_Character.prototype.processMoveRouteScriptCall; +Game_Character.prototype.processMoveRouteScriptCall = function(line) { + // EXTENDED MOVE PACK 1 ADDITIONS + if (line === 'EXTENDED MOVE PACK 1') { + return; + // HUG LEFT WALL + } else if (line.match(/(?:HUG LEFT|HUG LEFT WALL)/i)) { + var collision = this.checkCollisionKeywords(line); + this.processMoveHugWall('left', collision); + // HUG RIGHT WALL + } else if (line.match(/(?:HUG RIGHT|HUG RIGHT WALL)/i)) { + var collision = this.checkCollisionKeywords(line); + this.processMoveHugWall('right', collision); + // INDEX: X + } else if (line.match(/INDEX:[ ](\d+)/i)) { + var value = parseInt(RegExp.$1); + this.processIndexSet(value); + // INDEX: +/-X + } else if (line.match(/INDEX:[ ]([\+\-]\d+)/i)) { + var value = parseInt(RegExp.$1); + this.processIndexAdjust(value); + // MOVE UNTIL WALL + } else if (line.match(/MOVE[ ](.*)[ ](?:UNTIL WALL|UNTIL STOP)/i)) { + var text = String(RegExp.$1); + var collision = this.checkCollisionKeywords(line); + this.processMoveUntilStop(text, collision); + // OPACITY: /-X% + } else if (line.match(/OPACITY:[ ](\d+)([%%])/i)) { + var rate = parseInt(RegExp.$1) * 0.01; + var value = Math.round(255 * rate); + this.processOpacitySet(value); + // OPACITY: +/-X% + } else if (line.match(/OPACITY:[ ]([\+\-]\d+)([%%])/i)) { + var rate = parseInt(RegExp.$1) * 0.01; + var value = Math.round(255 * rate); + this.processOpacityAdjust(value); + // OPACITY: +/-X + } else if (line.match(/OPACITY:[ ]([\+\-]\d+)/i)) { + var value = parseInt(RegExp.$1); + this.processOpacityAdjust(value); + // ELSE + } else { + Yanfly.EMvP1.Game_Character_processMoveRouteScriptCall.call(this, line); + } +}; + +Game_Character.prototype.processMoveHugWall = function(wall, collision) { + collision = collision || false; + var left = {} + left[1] = 3; + left[2] = 6; + left[3] = 9; + left[4] = 2; + left[6] = 8; + left[7] = 1; + left[8] = 4; + left[9] = 7; + var right = {}; + right[1] = 7; + right[2] = 4; + right[3] = 1; + right[4] = 8; + right[6] = 2; + right[7] = 9; + right[8] = 6; + right[9] = 3; + if (wall === 'left') { + var mainDir = left[this.direction()]; + var oppositeDir = right[this.direction()]; + } else if (wall === 'right') { + var mainDir = right[this.direction()]; + var oppositeDir = left[this.direction()]; + } else { + return; + } + if (collision) $gameTemp._moveAllowPlayerCollision = true; + if (this.canPass(this.x, this.y, mainDir)) { + if (wall === 'left') { + this.turnLeft90(); + } else { + this.turnRight90(); + } + } else if (!this.canPass(this.x, this.y, this.direction())) { + if (this.canPass(this.x, this.y, oppositeDir)) { + if (wall === 'left') { + this.turnRight90(); + } else { + this.turnLeft90(); + } + } else { + this.turn180(); + } + } + if (this.canPass(this.x, this.y, this.direction())) { + $gameTemp._moveAllowPlayerCollision = false; + this.moveForward(); + } + $gameTemp._moveAllowPlayerCollision = false; +}; + +Game_Character.prototype.processMoveUntilStop = function(line, collision) { + var direction = 0; + if (line.match(/UPPER RIGHT/i)) { + direction = 9; + } else if (line.match(/UPPER LEFT/i)) { + direction = 7; + } else if (line.match(/LOWER RIGHT/i)) { + direction = 4; + } else if (line.match(/LOWER LEFT/i)) { + direction = 1; + } else if (line.match(/UP/i)) { + direction = 8; + } else if (line.match(/RIGHT/i)) { + direction = 6; + } else if (line.match(/LEFT/i)) { + direction = 4; + } else if (line.match(/DOWN/i)) { + direction = 2; + } else if (line.match(/FORWARD/i)) { + direction = this.direction(); + } else { + return; + } + if (collision) $gameTemp._moveAllowPlayerCollision = true; + if (this.canPass(this.x, this.y, direction)) { + $gameTemp._moveAllowPlayerCollision = false; + this.moveStraight(direction); + this._moveRouteIndex -= 1; + } + $gameTemp._moveAllowPlayerCollision = false; +}; + +Game_Character.prototype.processOpacitySet = function(value) { + this._opacity = Math.round(value); + this._opacity = this._opacity.clamp(0, 255); +}; + +Game_Character.prototype.processOpacityAdjust = function(value) { + this._opacity += Math.round(value); + this._opacity = this._opacity.clamp(0, 255); +}; + +Game_Character.prototype.processIndexSet = function(value) { + if (ImageManager.isBigCharacter(this._characterName)) return; + var charName = this._characterName; + value = value.clamp(0, 7); + this.setImage(charName, value); +}; + +Game_Character.prototype.processIndexAdjust = function(value) { + if (ImageManager.isBigCharacter(this._characterName)) return; + var charName = this._characterName; + value = this._characterIndex + value; + value = value.clamp(0, 7); + this.setImage(charName, value); +}; + +//============================================================================= +// End of File +//============================================================================= +} else { + +var text = '================================================================\n'; +text += 'YEP_X_ExtMovePack1 requires YEP_MoveRouteCore to be at the '; +text += 'latest version to run properly.\n\nPlease go to www.yanfly.moe and '; +text += 'update to the latest version for the YEP_MoveRouteCore plugin.\n'; +text += '================================================================\n'; +console.log(text); +require('nw.gui').Window.get().showDevTools(); + +} // Imported.YEP_MoveRouteCore \ No newline at end of file diff --git a/js/plugins/YEP_X_ItemUpgradeSlots.js b/js/plugins/YEP_X_ItemUpgradeSlots.js new file mode 100644 index 0000000..388d5a7 --- /dev/null +++ b/js/plugins/YEP_X_ItemUpgradeSlots.js @@ -0,0 +1,1257 @@ +//============================================================================= +// Yanfly Engine Plugins - Item Core Extension - Item Upgrade Slots +// YEP_X_ItemUpgradeSlots.js +//============================================================================= + +var Imported = Imported || {}; +Imported.YEP_X_ItemUpgrades = true; + +var Yanfly = Yanfly || {}; +Yanfly.IUS = Yanfly.IUS || {}; +Yanfly.IUS.version = 1.10; + +//============================================================================= + /*: + * @plugindesc v1.10 (Requires YEP_ItemCore.js) Allows independent items to + * be upgradeable and gain better stats. + * @author Yanfly Engine Plugins + * + * @param Default Slots + * @type number + * @min 0 + * @desc The default amount of slots items can be upgraded. + * @default 3 + * + * @param Slot Variance + * @type number + * @desc The default slot variance for items with slots. + * @default 1 + * + * @param Upgrade Command + * @desc Command text for upgrading the selected item. If you don't + * wish for this to appear, keep this blank. %1 - Item Name + * @default Upgrade %1 + * + * @param Show Only + * @type boolean + * @on YES + * @off NO + * @desc The Upgrade Command will only show if item is upgradeable. + * NO - false YES - true + * @default true + * + * @param Slots Available + * @desc Text used for amount of upgrade slots available. To hide + * this from the info window, leave this blank. + * @default Slots Available + * + * @param Show Slot Upgrades + * @type boolean + * @on YES + * @off NO + * @desc Shows what upgrades applied to slots in info window. + * NO - false YES - true + * @default true + * + * @param Slot Upgrade Format + * @desc This is the text format used before a shown slot upgrade. + * %1 - Slot Number %2 - Item Icon and Name + * @default \}Slot%1: %2\{ + * + * @param Default Sound + * @type file + * @dir audio/se/ + * @require 1 + * @desc This is the default sound played when using an + * item upgrade. + * @default Heal2 + * + * @help + * ============================================================================ + * Introduction + * ============================================================================ + * + * This plugin requires YEP_ItemCore. + * Make sure this plugin is located under YEP_ItemCore in the plugin list. + * + * This plugin adds Item Upgraders, where you can select the base item and then + * apply the appropriate Item Upgraders onto it to boost its parameters. + * + * ============================================================================ + * Notetags + * ============================================================================ + * + * The following notetags can be used to modify item upgrades. + * + * Weapon, and Armor Notetags + * + * This sets the number of times an item can be upgraded instead of the + * default amount defined in the database. + * + * + * This makes it so that there is a random variance for the number of slots + * provided through the item. If this notetag isn't used, it will go by the + * setting in the parameters. + * + * + * Changes the upgrade sound played to 'filename'. If this notetag isn't + * used, the 'Default Sound' parameter sound will be used instead. + * + * + * effect + * effect + * + * These are the effects applied (in the order they're listed). Refer to the + * 'Upgrade Effects List' in the next section to have those effects applied + * to the upgraded item. + * + * + * + * + *