let _メニュー_保存変数 = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    _メニュー_保存変数.call(this);
    this.SexTxt = ["", "", "", ""]; 
};
const MenuPic = "pictures/Menu/";
let MenuOpen = false; 
let MenuFlame = 0; 
let MenuLayer = 0; 
const PN_mBase = 40;
const PN_mSelect = PN_mBase + 2; 
const PN_mSbBWin = PN_mSelect + 8; 
const PN_mSbBIcon = PN_mSbBWin + 1; 
const PN_mSbBTxt = PN_mSbBIcon + 2; 
const PN_mInWin = PN_mSbBTxt + 2; 
const PN_mInTxt = PN_mInWin + 1; 
const PN_mTatie = PN_mInTxt + 1; 
const PN_mJhWin = PN_mTatie + 1; 
const PN_mJhTxt = PN_mJhWin + 1; 
const PN_mAdvSell = 300;    
const PN_mL2BaseBtm = 65; 
const PN_mL2Base = 180; 
const PN_mStKnk = PN_mL2BaseBtm + 2;    
const PN_mStYrk = PN_mStKnk + 2;        
const PN_mStPrTxt = PN_mStYrk + 2;     
const PN_mStGage = PN_mStPrTxt + 2;     
const PN_mStBllWin = PN_mStGage + 7;    
const PN_mStBllTxt = PN_mStBllWin + 1;  
const PN_mStTxt = PN_mStBllTxt + 1;     
const PN_mStKTxt = PN_mStTxt + 6;       
const PN_mStBase_2 = PN_mStKTxt + 3;    
const PN_mStSkill = PN_mStBase_2 + 2;   
const PN_mIItmTxt = PN_mL2BaseBtm + 10; 
const PN_mIItmSelH = PN_mIItmTxt + 16;  
const PN_mIItmSetu = PN_mIItmSelH + 1;  
const PN_mItmUWin = PN_mIItmSetu + 7;   
const PN_mItmUTxt = PN_mItmUWin + 1;    
const PN_mSbBrWin = PN_mL2BaseBtm + 2;  
const PN_mSbBrH = PN_mSbBrWin + 1;      
const PN_mSbIcn = PN_mSbBrH + 2;        
const PN_mSbTxt = PN_mSbIcn + 2;        
const PN_mSbMTxt = PN_mSbTxt + 2;       
const PN_mSbViTxt = PN_mSbMTxt + 3;     
const PN_mSbStIco = PN_mSbViTxt + 8;    
const PN_mSbStTxt = PN_mSbStIco + 2;    
const PN_mSbSlBtn = PN_mSbStTxt + 18;   
const PN_mSkWin = PN_mL2BaseBtm + 2;    
const PN_mSkTxt = PN_mSkWin + 1;        
const PN_mSkBlt = PN_mSkTxt + 1;        
const PN_mSkBltSelH = PN_mSkBlt + 3 * 8;  
const PN_mSkBTxt = PN_mSkBltSelH + 1;
const PN_mSkSelTxt = PN_mSkBTxt + 8;    
const PN_mSPsvTxt = PN_mSkSelTxt + 5;   
const PN_mSPsvSBtn = PN_mSPsvTxt + 9;   
const PN_mSkSelBase = 239; 
const PN_mSkSelBtn = PN_mSkSelBase + 1; 
const PN_mSkBltTxt = PN_mSkSelBtn + 15; 
const PN_mSkBltCost = PN_mSkBltTxt + 15; 
const PN_mSkBltSoubi = PN_mSkBltCost + 15; 
const PN_mOpBase = PN_mL2Base + 2;      
const PN_mOpBar = PN_mOpBase + 1;       
const PN_mOpTxt = PN_mOpBar + 4;        
const PN_OpNanido = PN_mOpTxt + 5;
const PN_mSxWin = PN_mL2Base + 2;       
const PN_mSxChara = PN_mSxWin + 1;      
const PN_mSxLine = PN_mSxChara + 1;     
const PN_mSxIrnWin = PN_mSxLine + 1;    
const PN_mSxIrnTxt = PN_mSxIrnWin + 2;  
const PN_mSxKisWin = PN_mSxIrnTxt + 4;  
const PN_mSxSumTxt = PN_mSxKisWin + 1;  
const PN_mSxTxt_1 = PN_mSxSumTxt + 3;   
const PN_mSxTxt_2 = PN_mSxTxt_1 + 6;    
const PN_mSxTxt_3 = PN_mSxTxt_2 + 6;    
const PN_mSxTxt_4 = PN_mSxTxt_3 + 6;    
const PN_mSxKpkTxt = PN_mSxTxt_4 + 6;   
const PN_mSxInrndTxt = PN_mSxKpkTxt + 1;    
const PN_MSvTxt = PN_mSxInrndTxt + 1;    
const PN_mSvBase = PN_mL2Base + 2;      
const PN_MSvPageSel = PN_mSvBase + 1;   
const PN_MSvWin = PN_MSvPageSel + 1;    
const PN_MSvTxt_t = PN_MSvWin + 10;     
const PN_MSvTxt_d = PN_MSvTxt_t + 10;   
const PN_MSvTxt_1 = PN_MSvTxt_d + 10;   
const PN_MSvTxt_2 = PN_MSvTxt_1 + 10;   
const PN_MSvTxt_3 = PN_MSvTxt_2 + 10;   
const PN_MSvTxt_4 = PN_MSvTxt_3 + 10;   
const PN_MSvWin_Sel = PN_MSvTxt_4 + 10;   
const PN_mL3Base = 234; 
const MenuMax = 7; 
let ML0_Selecter = 0;
let menu_l0_flame = 0;
let menuL0TcPic = []; 
let menuOpenLive2DSettingFlg = false;
Game_Interpreter.prototype.Menu_Open = function () {
    SoundManager.playCursor();
    L2dFExp = "H01";
    L2dFadeMdl("Ta_Leona", "rightin", 15, "1neutral", 1);
    L2dTop("Ta_Leona");
    menuOpenLive2DSettingFlg = true;
    Adv_Stop = MenuOpen = true;
    MenuLayer = MenuFlame = 0;
    ML0_Selecter = 0;
    menu_l0_flame = 0;
    this.Menu_L0_StateView();
    this.SetSprite(PN_mBase, MenuPic + "PN_mBase", 0, 0, 0);
    this.MoveSprite(PN_mBase, 0, 0, 5, 255);
    menuL0TcPic = [];
    for (let i = 0; i <= MenuMax; i++) {
        menuL0TcPic.push(PN_mSelect + i);
        this.SetSprite(PN_mSelect + i, MenuPic + "PN_mSelect" + i, 49, 28 + 85 * i, 0);
        this.MoveSprite(PN_mSelect + i, true, true, 5, 255);
    }
    this.SetPictC(PN_mAdvSell, AdvPic + "PN_AdvSell", 45, 66, 0);
    this.MovePict(PN_mAdvSell, true, true, 5, 255);
    this.MovePict(PN_KunrenFree, true, true, 5, 0);
    this.MovePict(PN_KunrenFreeTxt, true, true, 5, 0);
    this.MovePict(PN_AdvSell, true, true, 5, 0);
    this.DelPictSpan(PN_IGoldWin, PN_IGoldTxt);
}
const VN_PLStateBase = 4;
let M_State_Pic = MenuPic + "State/";
Game_Interpreter.prototype.Menu_L0_StateView = function () {
    D_Text_Cng_font = "Makinas"; 
    this.SetSprite(PN_mL2BaseBtm, M_State_Pic + "PN_mBase_st", 0, 0, 0);
    this.MoveSprite(PN_mL2BaseBtm, true, true, 5, 255);
    this.SetSprite(PN_mStBase_2, M_State_Pic + "PN_mBase_st_2", 0, 0, 0);
    this.MoveSprite(PN_mStBase_2, true, true, 5, 255);
    let _Ps = new Pos2D(463, 127);
    this.Menu_KYGageDraw(_Ps)
    this.SpriteStr(PN_mStPrTxt + 0, SCol.Blk0 + "Leona・McBain", 28, 375, 77, 0);
    this.MoveSprite(PN_mStPrTxt + 0, true, true, 10);
    this.SpriteStr(PN_mStPrTxt + 1, SCol.Blk0 + "", 28, 700, 77, 0);
    this.MoveSprite(PN_mStPrTxt + 1, true, true, 10);
    let _StArr = PL_StateGet();
    var maxStValue = 0;
    for (let i = 0; i < _StArr.length; i++) {
        if (_StArr[i] > maxStValue) {
            maxStValue = _StArr[i];
        }
    }
    var f表示倍率X = 1;
    if (maxStValue > 360) f表示倍率X = 360 / maxStValue;
    for (let i = 0; i <= _StArr.length - 1; i++) {
        this.SetSprite(PN_mStGage + i, M_State_Pic + "PN_mStGage", 425, 257 + (40 * i), 0, _StArr[i] / 2 * f表示倍率X);
        this.MoveSprite(PN_mStGage + i, true, true, 10, 255, true, true);
        let _SetColArr = [255, 255, 255];
        switch (i) {
            case 0:
                _SetColArr = [150, 150, 0, 0];
                break;     
            case 1:
                _SetColArr = [150, 16, 21, 0];
                break;    
            case 2:
                _SetColArr = [28, 58, 210, 0];
                break;    
            case 3:
                _SetColArr = [187, 0, 187, 0];
                break;    
            case 4:
                _SetColArr = [50, 229, 229, 0];
                break;    
            case 5:
                _SetColArr = [23, 166, 43, 0];
                break;    
        }
        this.SpriteCngColor(PN_mStGage + i, _SetColArr);
        this.SpriteStr(PN_mStTxt + i, "　\\oc[rgb(72,40,26)]" + _StArr[i] + " ", 25, 510, 236 + (40 * i), 0);
        this.MoveSprite(PN_mStTxt + i, true, true, 10);
    }
    let _Cnt = 0;
    for (let i = 0; i <= $gameSystem.PL_SkillArr.length - 1; i++) {
        let _skPs = new Pos2D(416, 541);
        if ($gameSystem.PL_SkillArr[i] != 0) {
            let _xCnt = Math.floor(_Cnt / 6);
            let _yCnt = _Cnt % 6;
            let _ckSkill = $dataSkills[$gameSystem.PL_SkillArr[i]];
            let _astr = "\\oc[rgb(0,0,0)]\\I[" + _ckSkill.iconIndex + "] " + _ckSkill.name + " ";
            this.SpriteStr(PN_mStSkill + _Cnt, _astr, 25, _skPs._x  + 240 * _xCnt, _skPs._y + (37 * _yCnt), 0);
            this.MoveSprite(PN_mStSkill + _Cnt, true, true, 10);
            _Cnt++;
        }
    }
    D_Text_Cng_font = ""; 
}
let PL_StateGet = function () {
    let Rtn_Arr = [];
    let _WpId = $gameActors._data[1]._equips[0]._itemId;
    for (let i = 0; i <= 5; i++) {
        let _数値 = $gameVariables.value(VN_PLStateBase + i); 
        switch (i) {
            case 0:
                _SetColArr = [150, 150, 0, 0];     
                _数値 += $dataWeapons[_WpId].params[0];
                break;
            case 1:
                _SetColArr = [150, 16, 21, 0];     
                _数値 += $dataWeapons[_WpId].params[2];
                break;
            case 2:
                _SetColArr = [28, 58, 210, 0];     
                _数値 += $dataWeapons[_WpId].params[3];
                break;
            case 3:
                _SetColArr = [187, 0, 187, 0];     
                _数値 += $dataWeapons[_WpId].params[4];
                break;
            case 4:
                _SetColArr = [50, 229, 229, 0];    
                _数値 += $dataWeapons[_WpId].params[6];
                break;
            case 5:
                _SetColArr = [23, 166, 43, 0];     
                _数値 += $dataWeapons[_WpId].params[7];
                break;
        }
        Rtn_Arr.push(_数値);
    }
    return Rtn_Arr;
}
Game_Interpreter.prototype.Menu_KYGageDraw = function (_Ps) {
    let _健康 = $gameVariables.value(VN_PLKenko);
    this.SetSprite(PN_mStKnk, M_State_Pic + "PN_tGage", _Ps._x, _Ps._y, 0, _健康);
    this.MoveSprite(PN_mStKnk, true, true, 10, 255, true);
    this.SpriteCngColor(PN_mStKnk, [0, 255, 0]);
    if (_健康 <= 50) this.SpriteCngColor(PN_mStKnk, [255, 255, 0]);
    if (_健康 <= 25) this.SpriteCngColor(PN_mStKnk, [255, 0, 0]);
    let _やる気 = $gameVariables.value(VN_PLYruki);
    this.SetSprite(PN_mStYrk, M_State_Pic + "PN_tGage_s", _Ps._x, _Ps._y + 37, 0, _やる気);
    this.MoveSprite(PN_mStYrk, true, true, 10, 255, true);
    this.SpriteCngColor(PN_mStYrk, [234, 150, 215]);
    this.SpriteStr(PN_mStKnk + 1, SCol.Blk0 + " " + String(_健康) + " / 100 ", 22, _Ps._x + 245, _Ps._y - 9, 0);
    this.SpriteStr(PN_mStYrk + 1, SCol.Blk0 + " " + String(_やる気) + " / 100 ", 22, _Ps._x + 245, _Ps._y - 9 + 32, 0);
    this.MoveSprite(PN_mStKnk + 1, true, true, 10);
    this.MoveSprite(PN_mStYrk + 1, true, true, 10);
}
let Menu_NUpdate = Game_Interpreter.prototype.NUpdate;
Game_Interpreter.prototype.NUpdate = function () {
    Menu_NUpdate.call(this);
    if (MenuOpen) {
        if (!$gameSwitches.value(SW_奴隷)) {
            this.Menu_Update();
        } else {
            this.D_Menu_Update();
        }
    }
}
Game_Interpreter.prototype.Menu_Update = function () {
    switch (MenuLayer) {
        case 0:
            this.Menu_L0_Update();
            break;
        case 1:
            this.Menu_L1_Update();
            break;
    }
    MenuFlame++;
}
Game_Interpreter.prototype.Menu_Close = function () {
    MenuOpen = Adv_Stop = false;
    this.DelSpriteSpan(PN_mBase, PN_mSelect + MenuMax);
    this.DelSpriteSpan(PN_mSbBWin, PN_mAdvSell);
    this.DelPict(PN_mAdvSell);
    L2dFadeMdl("Ta_Leona", "rightout", 15, "3koshinite", 1);
    this.SetPictC(PN_AdvSell, AdvPic + "PN_AdvSell", L0BtnPos._x - 15, L0BtnPos._y - (_AdvSellSa * L0_Selecter) + 35, 0);
    this.MovePict(PN_AdvSell, true, true, 5, 255);
    this.MovePict(PN_KunrenFree, true, true, 5, 255);
    this.MovePict(PN_KunrenFreeTxt, true, true, 5, 255);
}
Game_Interpreter.prototype.Menu_L0_Update = function () {
    if (menu_l0_flame == 5 && menuOpenLive2DSettingFlg) {
        L2dSetMotion("Ta_Leona","3koshinite"); 
        L2dIdleStart("Ta_Leona", "4koshinite_idle");
        menuOpenLive2DSettingFlg = false;
    }
    if (menu_l0_flame > 10) {
        let _MvFlg = false;
        if (Input.isTriggered('up')) {
            ML0_Selecter--;
            _MvFlg = true;
        }
        if (Input.isTriggered('down')) {
            ML0_Selecter++;
            _MvFlg = true;
        }
        if (ML0_Selecter > MenuMax) ML0_Selecter = 0;
        if (ML0_Selecter < 0) ML0_Selecter = MenuMax;
        let _CNo = overPointerSpCkArr(menuL0TcPic);
        if (_CNo != -1) {
            if (ML0_Selecter != _CNo - PN_mSelect) {
                ML0_Selecter = _CNo - PN_mSelect;
                _MvFlg = true;
            }
        }
        if (_MvFlg) {
            SoundManager.playCursor(); 
            this.MovePict(PN_mAdvSell, 45, 66 + 85 * ML0_Selecter, 5, 255);
        }
        if (Input.isTriggered('ok') || TouchInput.isTriggered()) { 
            SoundManager.playOk(); 
            this.Menu_L1_View(ML0_Selecter);
        }
        if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
            SoundManager.playCancel() 
            this.Menu_Close();
        }
    }
    menu_l0_flame++;
}
Game_Interpreter.prototype.Menu_L0_Back = function () {
    MenuLayer = 0;
    menu_l0_flame = 0;
    this.Menu_Top_PicDel();
    this.Menu_L0_StateView(); 
    for (let i = 0; i <= MenuMax; i++) {
        this.SpriteCngColor(PN_mSelect + i);
    }
}
Game_Interpreter.prototype.Menu_Top_PicDel = function () {
    this.DelSpriteSpan(PN_mL2BaseBtm, PN_L2DView - 1); 
    this.DelSpriteSpan(PN_IFuki, PN_mAdvSell - 1);
    this.MovePict(PN_mAdvSell, 45, 66 + 85 * ML0_Selecter, 5, 255);
}
let menu_l1_flame = 0;
let Menu_L1_ViewNo = 0;
let menuL1TcPic = []; 
Game_Interpreter.prototype.Menu_L1_View = function (_SelectNo) {
    MenuLayer = 1;
    menu_l1_flame = 0;
    Menu_L1_ViewNo = _SelectNo;
    for (let i = 0; i <= MenuMax; i++) {
        if (Menu_L1_ViewNo != i) {
            this.SpriteCngColor(PN_mSelect + i, [-100, -100, -100, 0], 10);
        }
    }
    switch (Menu_L1_ViewNo) {
        case 0: 
            this.Menu_L1Item_Cng();
            break;
        case 1: 
            this.Menu_L1Soubi_Cng();
            break;
        case 2: 
            _MSkiL1Sel = 0; 
            this.Menu_L1Skill_Cng();
            break;
        case 3: 
            this.Menu_L1Sex_Cng();
            break;
        case 4: 
            this.Menu_L1Save_Cng();
            break;
        case 5: 
            this.Menu_L1Load_Cng();
            break;
        case 6: 
            Opt_Zure = new Pos2D(0, 0);
            this.Menu_L1Option_Cng();
            break;
        case 7: 
            this.Menu_L1Title_Cng();
            break;
    }
}
Game_Interpreter.prototype.Menu_L1_Update = function () {
    switch (Menu_L1_ViewNo) {
        case 0: 
            this.Menu_Item_Update();
            break;
        case 1: 
            this.Menu_L1Soubi_Update();
            break;
        case 2: 
            this.Menu_L1Skill_Update();
            break;
        case 3: 
            this.Menu_L1Sex_Update();
            break;
        case 4: 
        case 5: 
            this.Menu_L1Save_Update();
            break;
        case 6: 
            this.Menu_L1Option_Update();
            break;
        case 7: 
            this.Menu_L1Title_Update();
            break;
    }
    menu_l1_flame++;
}
const M_Item_Pic = MenuPic + "Item/";
const CN_ItemUse = 35; 
let _DgArr_m1 = []; 
let _DgSelX = 0; 
let _DgSelY = 0; 
let UseItemNo = -1; 
let _ItmLayer = 0; 
Game_Interpreter.prototype.Menu_L1Item_Cng = function () {
    _DgSelX = _DgSelY = _ItmLayer = 0;
    this.Menu_L1Item_View();
}
Game_Interpreter.prototype.Menu_L1Item_View = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    this.Menu_Top_PicDel();
    this.SetSprite(PN_mL2BaseBtm, M_Item_Pic + "PN_mIItmWin", 0, 0, 0);
    this.MoveSprite(PN_mL2BaseBtm, 0, 0, 10);
    this.Menu_L1Item_GageDraw();
    this.Menu_Item_ReDraw(); 
}
Game_Interpreter.prototype.Menu_L1Item_GageDraw = function () {
    let _Ps = new Pos2D(462, 85);
    this.Menu_KYGageDraw(_Ps); 
}
let MItemPicArr = [];
Game_Interpreter.prototype.Menu_Item_ReDraw = function () {
    this.DelSpriteSpan(PN_mIItmTxt, PN_mIItmTxt + 15);
    D_Text_Cng_font = "Makinas"; 
    let _Cnt = 0; 
    _DgArr_m1 = [[], []]; 
    for (let i = 1; i <= $dataItems.length - 1; i++) {
        let _dgCnt = $gameParty.numItems($dataItems[i]);
        if (_dgCnt > 0 && $dataItems[i].itypeId == 1) { 
            let Check上位絆 = function (valNo) {
                if (i >= valNo && i < valNo + 4) if ($gameParty.numItems($dataItems[i + 1]) > 0) return true;
                return false;
            }
            if (Check上位絆(101)) continue; 
            if (Check上位絆(106)) continue; 
            if (Check上位絆(111)) continue; 
            if (Check上位絆(116)) continue; 
            if (Check上位絆(121)) continue; 
            if (_Cnt % 2 == 0) {
                _DgArr_m1[0].push(i);
            } else {
                _DgArr_m1[1].push(i);
            }
            _Cnt++;
        }
        if (_Cnt == 20) break;
    }
    MItemPicArr = [];
    let _PsI = new Pos2D(385, 316);
    for (let i = 0; i <= _DgArr_m1.length - 1; i++) {
        for (let j = 0; j <= _DgArr_m1[i].length - 1; j++) {
            let _dgCnt = $gameParty.numItems($dataItems[_DgArr_m1[i][j]]);
            let _dgStr = "\\I[" + $dataItems[_DgArr_m1[i][j]].iconIndex + "] " + $dataItems[_DgArr_m1[i][j]].name + "×" + _dgCnt;
            if ($dataItems[_DgArr_m1[i][j]].occasion == 3) {
                _dgStr = SCol.Yel + "\\I[" + $dataItems[_DgArr_m1[i][j]].iconIndex + "] " + $dataItems[_DgArr_m1[i][j]].name;
            }
            this.SpriteStr(PN_mIItmTxt + (j * 2) + i, _dgStr, 24, _PsI._x + (336 * i), _PsI._y + (51 * j));
            this.MoveSprite(PN_mIItmTxt + (j * 2) + i, true, true, 10);
            MItemPicArr.push(PN_mIItmTxt + (j * 2) + i);
        }
    }
    D_Text_Cng_font = ""; 
}
Game_Interpreter.prototype.Menu_Item_Update = function () {
    switch (_ItmLayer) {
        case 0:
            this.Menu_L1Item_Update();
            break;
        case 1:
            this.Menu_L2Item_Update();
            break;
    }
}
let DgPs = new Pos2D(348, 328);
let _ItemUseStop = false;
Game_Interpreter.prototype.Menu_L1Item_Update = function () {
    let _mvFlg = false;
    if (menu_l1_flame == 1) {
        _mvFlg = true;
    }
    if (menu_l1_flame > 10) {
        if (_ItemUseStop) return; 
        _mvFlg = false;
        if (Input.isTriggered('up')) {
            _DgSelY--;
            _mvFlg = true;
        }
        if (Input.isTriggered('down')) {
            _DgSelY++;
            _mvFlg = true;
        }
        if (Input.isTriggered('left')) {
            _DgSelX--;
            _mvFlg = true;
        }
        if (Input.isTriggered('right')) {
            _DgSelX++;
            _mvFlg = true;
        }
        let _okFlg = false;
        let _CNo = overPointerSpCkArr(MItemPicArr);
        if (_CNo != -1) {
            _CNo -= PN_mIItmTxt;
            if (_DgSelX != _CNo % 2 || _DgSelY != Math.floor(_CNo / 2)) {
                _mvFlg = true;
                _DgSelX = _CNo % 2;
                _DgSelY = Math.floor(_CNo / 2);
            }
            if (TouchInput.isTriggered()) {
                _okFlg = true;
            }
        }
        if (Input.isTriggered('ok')) {
            _okFlg = true;
        }
        if (_okFlg) {
            if ($dataItems[_DgArr_m1[_DgSelX][_DgSelY]].occasion == 3) return;
            SoundManager.playOk();
            let _itemUseOkFlg = false;
            try {
                if (_DgArr_m1[_DgSelX][_DgSelY] != undefined) {
                    _itemUseOkFlg = true;
                }
            } catch (e) {
            }
            if (_itemUseOkFlg) { 
                this.Menu_L2Item_View();
            }
        }
        if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
            SoundManager.playCancel()
            this.Menu_L0_Back(); 
        }
    }
    if (_mvFlg) {
        SoundManager.playCursor()
        if (0 > _DgSelX) _DgSelX = 1;
        if (2 <= _DgSelX) _DgSelX = 0;
        if (_DgSelX == 1 && _DgArr_m1[1].length - 1 < _DgSelY) {
            _DgSelX = 0;
        }
        if (0 > _DgSelY) _DgSelY = _DgArr_m1[_DgSelX].length - 1;
        if (_DgArr_m1[_DgSelX].length <= _DgSelY) _DgSelY = 0;
        let _PosX = DgPs._x + 15 + (_DgSelX * 336);
        let _PosY = DgPs._y + (_DgSelY * 51);
        this.MovePict(PN_mAdvSell, _PosX, _PosY, 5);
        let _Item = $dataItems[_DgArr_m1[_DgSelX][_DgSelY]];
        if (_Item != undefined) { 
            let _dgStr = "\\I[" + _Item.iconIndex + "] " + _Item.name;
            let _PsPs = new Pos2D(377, 173);
            this.DelSpriteSpan(PN_mIItmSetu + 0, PN_mIItmSetu + 2);
            this.SpriteStr(PN_mIItmSetu + 0, _dgStr, 25, _PsPs._x, _PsPs._y, 0);
            this.MoveSprite(PN_mIItmSetu + 0, true, true, 5);
            let _SetDescArr = _Item.description.split(/\n/);
            for (let i = 0; i <= _SetDescArr.length - 1; i++) {
                this.SpriteStr(PN_mIItmSetu + 1 + i, _SetDescArr[i], 18, _PsPs._x + 3, _PsPs._y + 39 + 30 * i, 0);
                this.MoveSprite(PN_mIItmSetu + 1 + i + 0, true, true, 5);
            }
        }
    }
}
let _ItmYNCbMap = [
    [487, 359, 141, 49],
    [487 + 254, 359, 141, 49]
];
let _il2Sel = 0; 
let _UseItem = null; 
let _i2flame = 0;
Game_Interpreter.prototype.Menu_L2Item_View = function () {
    _ItmLayer = 1;
    _i2flame = 0;
    _UseItem = $dataItems[_DgArr_m1[_DgSelX][_DgSelY]];
    let _dgStr = "\\I[" + _UseItem.iconIndex + "] " + _UseItem.name;
    this.SpriteStr(PN_mItmUTxt, "Do you want to use " + _dgStr + "？", 25, 445, 310, 0);
    this.MoveSprite(PN_mItmUTxt, true, true, 10);
    this.SetSpriteFIn(PN_mItmUWin, M_Item_Pic + "PN_mItmUWin", 0, 0, 0, 0, 10);
    this.MovePict(PN_mAdvSell, 470 + (253 * _il2Sel), 384, 5);
    _il2Sel = 0;
}
Game_Interpreter.prototype.Menu_L2Item_Close = function () {
    _ItmLayer = 0;
    this.DelSprite(PN_mItmUWin);
    this.DelSprite(PN_mItmUTxt);
    let _PosX = DgPs._x + 15 + (_DgSelX * 336);
    let _PosY = DgPs._y + (_DgSelY * 51);
    this.MovePict(PN_mAdvSell, _PosX, _PosY, 5);
}
Game_Interpreter.prototype.Menu_L2Item_Update = function () {
    _i2flame++;
    if (_i2flame < 10) return;
    let _mvFlg = false;
    let _okFlg = false;
    if (Input.isTriggered('ok') || TouchInput.isTriggered()) _okFlg = true;
    if (_okFlg) {
        SoundManager.playOk()
        _DgSelX = _DgSelY = menu_l1_flame = 0;
        UseItemNo = _UseItem.id;
        //$gameParty.gainItem($dataItems[UseItemNo], -1);
        this.Menu_L2Item_Close(); 
        this.Menu_Item_ReDraw(); 
        _ItemUseStop = true;
        this.SetCmnEventSc(CN_ItemUse); 
    }
    if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
        SoundManager.playCancel()
        this.Menu_L2Item_Close();
    }
}
const M_Soubi_Pic = MenuPic + "Soubi/";
let _Ms装備_Zure = 0;   
let _Ms選択_1 = 0;  
let _Ms武器 = null; 
let _Ms装飾 = null; 
let _MsLayer = 0;   
Game_Interpreter.prototype.Menu_L1Soubi_Cng = function () {
    menu_l1_flame = 0;
    _DgSelX = _DgSelY = 0;
    _Ms選択_1 = _MsLayer = 0;
    this.Menu_L1Soubi_View();
}
Game_Interpreter.prototype.Menu_L1Soubi_View = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    this.Menu_Top_PicDel();
    this.SetSprite(PN_mL2BaseBtm, M_Soubi_Pic + "PN_mSbBase", 0, 0, 0);
    this.MoveSprite(PN_mL2BaseBtm, 0, 0, 10);
    let _opi = 255;
    if (_SetFlg) {
        _opi = 0;
        _ms0_flame = 0;
    }
    this.Menu_L1Soubi_Draw(true);
    this.MsLayer_0_Cng();
}
Game_Interpreter.prototype.Menu_L1Soubi_Draw = function (_SetFpg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    _Ms武器 = $dataWeapons[$gameActors.actor(1).equips()[0].id];
    _Ms装飾 = $dataArmors[$gameActors.actor(1).equips()[4].id];
    let _opi = 255;
    if (_SetFlg) {
        _opi = 0;
        _ms0_flame = 0;
    }
    D_Text_Cng_font = "Makinas"; 
    this.SetPicStrC(PN_mSbIcn + 0, "\\I[" + _Ms武器.iconIndex + "] ", 25, 424, 117, _opi, 150, 150);
    this.SetPicStrC(PN_mSbIcn + 1, "\\I[" + _Ms装飾.iconIndex + "] ", 25, 736, 117, _opi, 150, 150);
    this.MoveSprite(PN_mSbIcn + 0, true, true, 10, 255, true, true);
    this.MoveSprite(PN_mSbIcn + 1, true, true, 10, 255, true, true);
    this.SpriteStr(PN_mSbTxt + 0, SCol.Blk0 + _Ms武器.name, 27, 438 + 40, 100, _opi);
    this.SpriteStr(PN_mSbTxt + 1, SCol.Blk0 + _Ms装飾.name, 27, 748 + 40, 100, _opi);
    this.MoveSprite(PN_mSbTxt + 0, true, true, 10);
    this.MoveSprite(PN_mSbTxt + 1, true, true, 10);
    D_Text_Cng_font = ""; 
}
Game_Interpreter.prototype.Menu_L1Soubi_Update = function () {
    if (menu_l1_flame > 15) {
        switch (_MsLayer) {
            case 0: 
                this.MsLayer_0_Update();
                break;
            case 1:
                this.MsLayer_1_Update();
                break;
        }
    }
}
let _ms0_flame = 0;
let _SbOverPic_1 = [PN_mSbIcn + 0, PN_mSbIcn + 1, PN_mSbTxt + 0, PN_mSbTxt + 1];
let Equip_CMap = [
    [370, 68, 100, 100],
    [682, 68, 100, 100]
];
Game_Interpreter.prototype.MsLayer_0_Update = function () {
    _ms0_flame++;
    if (_ms0_flame < 20) return;
    let _mvFlg = false;
    if (Input.isTriggered('left')) {
        _mvFlg = true;
        _Ms選択_1--;
    }
    if (Input.isTriggered('right')) {
        _mvFlg = true;
        _Ms選択_1++;
    }
    let _okFlg = false;
    let _CNo = overPointerSpCkArr(_SbOverPic_1);
    if (_CNo == -1) {
        _CNo = overSpriteClickable(PN_mL2BaseBtm, Equip_CMap);
        if (_CNo != -1) {
            if (_Ms選択_1 != _CNo) {
                _Ms選択_1 = _CNo;
                _mvFlg = true;
            }
        }
        _CNo = -1;
    }
    if (_CNo != -1) {
        switch (_CNo) {
            case PN_mSbIcn + 0:
            case PN_mSbTxt + 0:
                if (_Ms選択_1 != 0) {
                    _Ms選択_1 = 0;
                    _mvFlg = true;
                }
                break;
            case PN_mSbIcn + 1:
            case PN_mSbTxt + 1:
                if (_Ms選択_1 != 1) {
                    _Ms選択_1 = 1;
                    _mvFlg = true;
                }
                break;
        }
        if (TouchInput.isTriggered()) {
            _okFlg = true;
        }
    }
    _CNo = overPointerSpCkArr(_SbOverPicArr);
    if (_CNo != -1) {
        _CNo -= PN_mSbViTxt;
        _MsLayer = 1;
        _ms1_flame = 0;
        _Ms選択_2 = _CNo;
        this.MsLayer_1_Cng();
    }
    if (Input.isTriggered('down') || Input.isTriggered('ok')) _okFlg = true;
    if (_okFlg) {
        if (_Ms一覧Arr.length <= 0) return;
        SoundManager.playOk();
        _MsLayer = 1;
        _Ms選択_2 = 0;
        _ms1_flame = 0;
        this.MsLayer_1_Cng();
    }
    if (_mvFlg) {
        if (_Ms選択_1 < 0) _Ms選択_1 = 1;
        if (_Ms選択_1 > 1) _Ms選択_1 = 0;
        SoundManager.playCursor();
        this.MsLayer_0_Cng();
    }
    if (Input.isTriggered('escape') || TouchInput.isCancelled()) {
        SoundManager.playCancel();
        this.DelPictSpan(PN_mSbIcn + 0, PN_mSbIcn + 1);
        this.Menu_L0_Back(); 
    }
}
let _Ms一覧個数 = 0;
Game_Interpreter.prototype.MsLayer_0_Cng = function () {
    _MsLayer = 0;
    _Ms装備_Zure = 0;
    this.MovePict(PN_mAdvSell, 372 + (_Ms選択_1 * 310), 120, 5);
    this.SetSprite(PN_mSbBrH, M_Soubi_Pic + "PN_mSbBrH", 356 + (_Ms選択_1 * 312), 54, 0);
    this.MoveSprite(PN_mSbBrH, true, true, 10);
    this.MsLayer_DrawSt();
}
let _ms1_flame = 0;
Game_Interpreter.prototype.MsLayer_1_Update = function () {
    _ms1_flame++;
    if (_ms1_flame < 20) return;
    let _mvFlg = false;
    if (Input.isTriggered('up')) {
        _mvFlg = true;
        if (_Ms選択_2 > 0) {
            _Ms選択_2--;
        } else {
            if (_Ms装備_Zure > 0) {
                _Ms装備_Zure--;
                this.MsLayer_DrawSt();
            } else {
                _Ms選択_2--;
            }
        }
    }
    if (Input.isTriggered('down')) {
        if (_Ms選択_2 + _Ms装備_Zure < _Ms一覧Arr.length - 1) {
            _mvFlg = true;
            if (_Ms選択_2 == _SobiViewCnt - 1) {
                _Ms装備_Zure++;
                this.MsLayer_DrawSt();
            } else {
                _Ms選択_2++;
            }
        }
    }
    if (TouchInput.wheelY < 0) { 
        if (_Ms装備_Zure > 0) {
            _Ms装備_Zure--;
            this.MsLayer_DrawSt();
        }
    }
    if (TouchInput.wheelY > 0) { 
        if (_Ms一覧Arr.length - 1 >= _Ms装備_Zure + _SobiViewCnt) {
            _Ms装備_Zure++;
            this.MsLayer_DrawSt();
        }
    }
    let _okFlg = false;
    let _装備Over = false;
    let _CNo = overPointerSpCkArr(_SbOverPicArr);
    if (_CNo != -1) {
        _CNo -= PN_mSbViTxt;
        _装備Over = true;
        if (_Ms選択_2 != _CNo) {
            _Ms選択_2 = _CNo;
            _mvFlg = true;
        }
        if (TouchInput.isTriggered()) _okFlg = true;
    }
    if (_mvFlg) {
        SoundManager.playCursor();
        if (_Ms選択_2 < 0) {
            this.MsLayer_0_Cng();
        } else {
            this.MsLayer_1_Cng();
        }
    }
    _CNo = overPointerSpCkArr(_SbOverPic_1);
    if (_CNo != -1) {
        switch (_CNo) {
            case PN_mSbIcn + 0:
            case PN_mSbTxt + 0:
                if (_Ms選択_1 != 0) {
                    _Ms選択_1 = 0;
                    _mvFlg = true;
                }
                break;
            case PN_mSbIcn + 1:
            case PN_mSbTxt + 1:
                if (_Ms選択_1 != 1) {
                    _Ms選択_1 = 1;
                    _mvFlg = true;
                }
                break;
        }
        this.MsLayer_0_Cng();
    }
    if (Input.isTriggered('ok')) _okFlg = true;
    if (_okFlg) {
        if (_Ms選択_1 == 0) {
            $gameActors.actor(1).changeEquipById(1, _Ms一覧Arr[_Ms選択_2].id); 
        } else {
            $gameActors.actor(1).changeEquipById(5, _Ms一覧Arr[_Ms選択_2].id); 
        }
        this.Menu_L1Soubi_Draw(false);
        this.MsLayer_0_Cng();
        SoundManager.playOk();
        this.Adv_情報_ステートDraw(255);
        this.Adv_情報_MojiDraw();
    }
    if (Input.isTriggered('escape') || TouchInput.isCancelled()) {
        SoundManager.playCancel();
        if (_装備Over) {
            this.Menu_L0_Back(); 
            this.DelPictSpan(PN_mSbIcn + 0, PN_mSbIcn + 1);
        } else {
            _MsLayer = 0;
            this.MsLayer_0_Cng();
        }
    }
}
let _Ms選択_2 = 0; 
Game_Interpreter.prototype.MsLayer_1_Cng = function () {
    this.MovePict(PN_mAdvSell, 350, 368 + (_Ms選択_2 * _SobiIconYSa), 5);
    this.MsLayer_DrawSt();
}
const _SobiViewCnt = 8; 
let _MsSelId = -1;
let _Ms一覧Arr = [];
let _能力_装備 = null;
_能力_変更 = null;
let _SbOverPicArr = [];
const _SobiIconYSa = 48;
Game_Interpreter.prototype.MsLayer_DrawSt = function () {
    let _dgStr = "";
    let _SetDescArr = [];
    if (_MsLayer == 0) {
        _能力_装備 = null;
        _能力_変更 = null;
        this.DelSpriteSpan(PN_mSbViTxt, PN_mSbViTxt + 7);
        _Ms一覧Arr = [];
        if (_Ms選択_1 == 0) {
            _dgStr = "\\I[" + _Ms武器.iconIndex + "] " + _Ms武器.name + " ";
            _SetDescArr = _Ms武器.description.split(/\n/);
            _能力_装備 = new _MsData(_Ms武器);
            let _wCnt = 0;
            _SbOverPicArr = [];
            for (let i = 0; i <= $dataWeapons.length - 1; i++) {
                if (_Ms武器.id == i) continue;
                if ($gameParty.hasItem($dataWeapons[i], false)) {
                    _Ms一覧Arr.push($dataWeapons[i]);
                    _wCnt++;
                }
            }
            _Ms一覧個数 = $dataWeapons.length - 1;
        } else {
            _dgStr = "\\I[" + _Ms装飾.iconIndex + "] " + _Ms装飾.name;
            _SetDescArr = _Ms装飾.description.split(/\n/);
            _能力_装備 = new _MsData(_Ms装飾);
            let _wCnt = 0;
            for (let i = 1; i <= $dataArmors.length - 1; i++) {
                if ($dataArmors[i].atypeId != 1) continue; 
                if (_Ms装飾.id == i) continue;
                if ($gameParty.hasItem($dataArmors[i], false)) {
                    _Ms一覧Arr.push($dataArmors[i]);
                    _wCnt++;
                }
            }
            _Ms一覧個数 = $dataArmors.length - 1;
        }
        for (let i = 0; i <= _Ms一覧Arr.length - 1; i++) {
            let _WpStr = "\\I[" + _Ms一覧Arr[i].iconIndex + "] " + _Ms一覧Arr[i].name + " ";
            this.SpriteStr(PN_mSbViTxt + i, _WpStr, 25, 375, 354 + (_SobiIconYSa * i), 0);
            this.MoveSprite(PN_mSbViTxt + i, true, true, 5);
            _SbOverPicArr.push(PN_mSbViTxt + i);
            if (i == _SobiViewCnt) break;
        }
    } else {
        _能力_変更 = null;
        let _SCnt = 0;
        for (let i = _Ms装備_Zure; i <= _Ms一覧Arr.length - 1; i++) {
            let _WpStr = "\\I[" + _Ms一覧Arr[i].iconIndex + "] " + _Ms一覧Arr[i].name + " ";
            this.SpriteStr(PN_mSbViTxt + _SCnt, _WpStr, 25, 375, 354 + (_SobiIconYSa * _SCnt), 255);
            if (_SCnt == _SobiViewCnt) break;
            _SCnt++;
        }
        if (_Ms選択_1 == 0) { 
            let _Set武器 = _Ms一覧Arr[_Ms選択_2 + _Ms装備_Zure];
            _dgStr = "\\I[" + _Set武器.iconIndex + "] " + _Set武器.name + " ";
            _SetDescArr = _Set武器.description.split(/\n/);
            _能力_変更 = new _MsData(_Set武器);
        } else { 
            let _Set装飾 = _Ms一覧Arr[_Ms選択_2 + _Ms装備_Zure];
            _dgStr = "\\I[" + _Set装飾.iconIndex + "] " + _Set装飾.name + " ";
            _SetDescArr = _Set装飾.description.split(/\n/);
            _能力_変更 = new _MsData(_Set装飾);
        }
    }
    let _PsPs = new Pos2D(376, 197);
    this.DelSpriteSpan(PN_mSbMTxt, PN_mSbMTxt + 2);
    this.SpriteStr(PN_mSbMTxt + 0, _dgStr, 25, _PsPs._x, _PsPs._y, 0);
    this.MoveSprite(PN_mSbMTxt + 0, true, true, 5);
    for (let i = 0; i <= _SetDescArr.length - 1; i++) {
        this.SpriteStr(PN_mSbMTxt + 1 + i, _SetDescArr[i], 18, _PsPs._x, _PsPs._y + 38 + (30 * i), 0);
        this.MoveSprite(PN_mSbMTxt + 1 + i + 0, true, true, 5);
    }
    this.DelSpriteSpan(PN_mSbStIco + 0, PN_mSbStTxt + 17);
    let _icoStr1 = _icoStr2 = "";
    if (_Ms選択_1 == 0) {
        _icoStr1 = "\\I[" + _Ms武器.iconIndex + "] ";
        if (_MsLayer == 1) {
            _icoStr2 = "\\I[" + _Ms一覧Arr[_Ms選択_2].iconIndex + "] ";
        }
    } else {
        _icoStr1 = "\\I[" + _Ms装飾.iconIndex + "] ";
        if (_MsLayer == 1) {
            _icoStr2 = "\\I[" + _Ms一覧Arr[_Ms選択_2].iconIndex + "] ";
        }
    }
    this.SpriteStr(PN_mSbStIco + 0, _icoStr1, 25, 821, 373, 0);
    this.MoveSprite(PN_mSbStIco + 0, true, true, 5);
    this.SpriteStr(PN_mSbStIco + 1, _icoStr2, 25, 821 + 125, 373, 0);
    this.MoveSprite(PN_mSbStIco + 1, true, true, 5);
    this.DelSprite(PN_mSbSlBtn + 0);
    this.DelSprite(PN_mSbSlBtn + 1);
    if (_Ms装備_Zure > 0) {
        this.SetSprite(PN_mSbSlBtn + 0, M_Soubi_Pic + "PN_mSPsvSBtn_T", 378, 330, 255);
    }
    if (_Ms一覧Arr.length - 1 >= _Ms装備_Zure + _SobiViewCnt) {
        this.SetSprite(PN_mSbSlBtn + 1, M_Soubi_Pic + "PN_mSPsvSBtn_B", 378, 730, 255);
    }
    for (let i = 0; i <= _能力_装備._DrawStr.length - 1; i++) {
        this.SpriteStrR(PN_mSbStTxt + i, _能力_装備._DrawStr[i] + " ", 25, 864, 425 + (40 * i), 255);
    }
    if (_MsLayer == 1) {
        for (let i = 0; i <= _能力_変更._DrawStr.length - 1; i++) {
            this.SpriteStrR(PN_mSbStTxt + i + 9, _能力_変更._DrawStr[i] + " ", 25, 864 + 125, 425 + (40 * i), 255);
        }
    }
}
class _MsData {
    constructor(_Data) {
        this.atk = _Data.params[2]; 
        this.def = _Data.params[3]; 
        this.mat = _Data.params[4]; 
        this.mdf = _Data.params[5]; 
        this.agi = _Data.params[6]; 
        this.luk = _Data.params[7]; 
        this.mhp = _Data.params[0]; 
        this.mmp = _Data.params[1]; 
        this._DrawStr = [
            this.mhp, 
            this.atk, 
            this.def, 
            this.mat, 
            this.agi, 
            this.luk  
        ]
    }
}
const M_Skill_Pic = MenuPic + "Skill/";
let _MSklLayer = 0; 
let _MSkiL1Sel = 0; 
let _MPsvSkSel = 0; 
let _MSk_flame = 0; 
let _MSPicArr = []; 
Game_Interpreter.prototype.Menu_L1Skill_Cng = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    menu_l1_flame = 0;
    _DgSelX = _DgSelY = 0; 
    _MSklLayer = 0
    _MPsvZureY = 0;
    this.Menu_L1Skill_View(_SetFlg);
    if (_MkSelX == 0) {
        this.MovePict(PN_mAdvSell, _mSkXPos, _mSkYPos + (_MSkiL1Sel * _mSkSa), 5);
    }
    for (let i = 0; i <= $gameSystem.PL_SkillArr.length - 1; i++) {
        $gameActors.actor(1).learnSkill($gameSystem.PL_SkillArr[i]); 
    }
}
let _mSkPs = new Pos2D(406, 316);
const _mSkXPos = 400;
const _mSkYPos = 324;
let _mSkSa = 50;
Game_Interpreter.prototype.Menu_L1Skill_View = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    this.Menu_Top_PicDel();
    let _opi = 0;
    if (_SetFlg) {
        _opi = 255;
    } else {
    }
    this.SetSprite(PN_mL2BaseBtm, M_Skill_Pic + "PN_mSkBase", 0, 0, _opi);
    this.MoveSprite(PN_mL2BaseBtm, 0, 0, 10);
    while ($gameSystem.PL_SkillArr.length < 8) {
        $gameSystem.PL_SkillArr.push(0);
    }
    _MSPicArr = [];
    D_Text_Cng_font = "Makinas"; 
    for (let i = 0; i <= 8 - 1; i++) {
        _DoNo = $gameSystem.PL_SkillArr[i];
        _PosX = 415;
        _PosY = 306 + (_mSkSa * i);
        _MSize = 80;
        this.N_Btl_Pl弾丸Draw(PN_mSkBlt + (4 * i), "", "", _DoNo, _PosX, _PosY, _opi, _MSize);
        this.MoveSprite(PN_mSkBlt + (i * 4) + 0, true, true, 5, 255, true, true);
        this.MoveSprite(PN_mSkBlt + (i * 4) + 1, true, true, 5, 255, true, true);
        this.MoveSprite(PN_mSkBlt + (i * 4) + 2, true, true, 5, 255, true, true);
        this.DelSprite(PN_mSkBlt + (4 * i) + 3); 
        this.DelSprite(PN_mSkBlt + (4 * i) + 4); 
        _MSPicArr.push(PN_mSkBlt + (i * 4) + 0);
    }
    D_Text_Cng_font = ""; 
    this.MovePict(PN_mAdvSell, _mSkXPos, _mSkYPos + (_MSkiL1Sel * _mSkSa), 5);
    this.Menu_L1Skill_Description($gameSystem.PL_SkillArr[_MSkiL1Sel]);
    this.Menu_PsvSkillDraw(0, true);
}
Game_Interpreter.prototype.Menu_L1Skill_Description = function (_SkillNo) {
    let _PsPs = new Pos2D(400, 110);
    this.DelSpriteSpan(PN_mSkSelTxt, PN_mSkSelTxt + 2);
    if (_SkillNo == -1) {
        let _SetSSS = "　- Not Learned -";
        this.SpriteStr(PN_mSkSelTxt + 0, _SetSSS, 25, _PsPs._x, _PsPs._y, 0);
        this.MoveSprite(PN_mSkSelTxt + 0, true, true, 5);
        return;
    }
    if (_SkillNo == 0 || _SkillNo == undefined) return;
    let _ckSkill = $dataSkills[_SkillNo];
    let _SetDescArr = _Skill_SetuGetArr(_SkillNo);
    let _dgStr = "\\I[" + _ckSkill.iconIndex + "] " + _ckSkill.name;
    this.SpriteStr(PN_mSkSelTxt + 0, _dgStr, 25, _PsPs._x, _PsPs._y, 0);
    this.MoveSprite(PN_mSkSelTxt + 0, true, true, 5);
    for (let i = 0; i <= _SetDescArr.length - 1; i++) {
        this.SpriteStr(PN_mSkSelTxt + 1 + i, _SetDescArr[i], 18, _PsPs._x, _PsPs._y + 42 + (32 * i), 0);
        this.MoveSprite(PN_mSkSelTxt + 1 + i, true, true, 5);
    }
}
let _MPsvSkillCnt = 0;
let _MPsvSkillArr = [];
let _MPsvPicArr = []; 
let _MPsvZureY = 0;
let _PsvPs = new Pos2D(726, 323);
Game_Interpreter.prototype.Menu_PsvSkillDraw = function (_ZureY, _SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    _MPsvPicArr = [];
    _MPsvSkillCnt = 0;
    _MPsvZureY += _ZureY;
    let _WpCnt = 0;
    for (let i = 0; i <= $dataArmors.length - 1; i++) {
        if ($gameParty.hasItem($dataArmors[i], false)) {
            if ($dataArmors[i].atypeId != 5) continue; 
            _WpCnt++;
        }
    }
    if (_MPsvZureY + 9 > _WpCnt) _MPsvZureY -= _ZureY;
    if (_MPsvZureY < 0) _MPsvZureY = 0;
    let _opi = 255;
    if (_SetFlg) _opi = 0;
    if (_MPsvZureY > 0) {
        this.SetSprite(PN_mSPsvSBtn + 0, M_Skill_Pic + "PN_mSPsvSBtn_T", 728, 298, _opi);
        this.MoveSprite(PN_mSPsvSBtn + 0, true, true, 5, 255);
    } else {
        this.DelSprite(PN_mSPsvSBtn + 0);
    }
    if (_MPsvZureY + 9 < _WpCnt) {
        this.SetSprite(PN_mSPsvSBtn + 1, M_Skill_Pic + "PN_mSPsvSBtn_B", 728, 683, _opi);
        this.MoveSprite(PN_mSPsvSBtn + 1, true, true, 5, 255);
    } else {
        this.DelSprite(PN_mSPsvSBtn + 1);
    }
    let _SkipCnt = 0;
    let _wCnt = 0;
    _MPsvSkillArr = [];
    for (let i = 1; i <= $dataArmors.length - 1; i++) {
        if ($dataArmors[i].atypeId != 5) continue; 
        if ($gameParty.hasItem($dataArmors[i], false)) {
            _SkipCnt++;
            if (_MPsvZureY >= _SkipCnt) continue;
            _MPsvSkillArr.push(i);
            if (_wCnt < 9) {
                let _WpStr = "\\I[" + $dataArmors[i].iconIndex + "] " + $dataArmors[i].name + " ";
                this.SpriteStr(PN_mSPsvTxt + _wCnt, _WpStr, 25, _PsvPs._x, _PsvPs._y + (40 * _wCnt), _opi);
                this.MoveSprite(PN_mSPsvTxt + _wCnt, true, true, 5);
                _MPsvPicArr.push(PN_mSPsvTxt + _wCnt);
                _wCnt++;
            }
        }
    }
    _MPsvSkillCnt = _wCnt;
    //this.MSkl_PsvSetuDraw();
}
Game_Interpreter.prototype.Menu_L1Skill_Update = function () {
    if (menu_l1_flame > 15) { 
        switch (_MSklLayer) {
            case 0:
                this.MSklLayerL0_Update();
                break;
            case 1:
                this.MSklLayerL1_Update();
                break;
        }
    }
}
let _SklArr = []; 
let _MSklSelNo = -1; 
let _SkillPicArr = []; 
let _SkillNoArr = [];   
let _MkSelX = 0; 
let _MSklCPs = new Pos2D(280, 360);
let _MSelBefY = -1;
Game_Interpreter.prototype.MSklLayerL0_Update = function () {
    let _mvFlg = false;
    let _YZure = 0;
    if (Input.isTriggered('up')) {
        _mvFlg = true;
        _MSkiL1Sel--;
    }
    if (Input.isTriggered('down')) {
        _mvFlg = true;
        _MSkiL1Sel++;
    }
    if (Input.isTriggered('left')) {
        _mvFlg = true;
        _MkSelX = 0;
    }
    if (Input.isTriggered('right')) {
        if (_MPsvSkillArr.length <= 0) return;
        _mvFlg = true;
        _MkSelX = 1;
    }
    let _okFlg = false;
    if (Input.isTriggered('ok')) _okFlg = true;
    let _CNo = overPointerSpCkArr(_MSPicArr);
    if (_CNo != -1) {
        _MkSelX = 0;
        _CNo -= PN_mSkBlt;
        _CNo = Math.floor(_CNo / 4);
        if (_CNo != _MSkiL1Sel) {
            _MSkiL1Sel = _CNo;
            _mvFlg = true;
        }
        if (TouchInput.isTriggered()) _okFlg = true;
    }
    let _PCNo = overPointerSpCkArr(_MPsvPicArr);
    if (_PCNo != -1) {
        _MkSelX = 1;
        _PCNo -= PN_mSPsvTxt;
        if (_PCNo != _MSkiL1Sel) {
            _MSkiL1Sel = _PCNo;
            _mvFlg = true;
        }
        if (TouchInput.isTriggered()) _okFlg = true;
    }
    if (_MkSelX == 0) {
        if (_mvFlg) {
            SoundManager.playCursor();
            if (_MSkiL1Sel < 0) _MSkiL1Sel = 7;
            if (_MSkiL1Sel > 7) _MSkiL1Sel = 0;
            this.MovePict(PN_mAdvSell, _mSkXPos, _mSkYPos + (_MSkiL1Sel * _mSkSa), 5);
            this.Menu_L1Skill_Description($gameSystem.PL_SkillArr[_MSkiL1Sel]);
        }
        let _XPosSa = 274;
        if (_okFlg) {
            SoundManager.playOk();
            _Msk1flame = 0;
            _MSklLayer = 1;
            _MSk_flame = 0;
            _SklArr = [[], [], []];
            this.SetSpriteFIn(PN_mSkSelBase, M_Skill_Pic + "PN_mSkSelBase", 0, 0, 0, 0, 5, 255);
            let _bsPs = new Pos2D(279, 336);
            _SkillPicArr = [];
            _SkillNoArr = [];
            for (let i = 0; i <= 3 - 1; i++) { 
                let addSkillNoArr = [];
                for (let j = 0; j <= 5 - 1; j++) { 
                    let _skillNo = 1 + (i * (8 * 5)) + (8 * j);
                    let _LvNo = 0;
                    for (let k = 0; k <= 5 - 1; k++) {
                        if ($gameActors.actor(1).isLearnedSkill(_skillNo + k)) {
                            _LvNo = k;
                        }
                    }
                    _skillNo += _LvNo;
                    let _drawSkill = $dataSkills[_skillNo];
                    addSkillNoArr.push(_skillNo);
                    let _picNo = (i * 5) + j;
                    let _SetOpi = 255;
                    if ($gameActors.actor(1).isLearnedSkill(_skillNo)) {
                        let _装備中Flg = ($gameSystem.PL_SkillArr.indexOf(_skillNo) != -1);
                        let _CostStr = "PN_Cost_";
                        let _astr = "";
                        let PsvNo = MetaChecker(_drawSkill, "Psv", 0);
                        if (PsvNo > 0) {
                            _CostStr = "PN_Cost_brank";
                            _SetOpi = 155;
                        } else {
                            if (_drawSkill.mpCost > 0) {
                                _CostStr += "m" + _drawSkill.mpCost; 
                            } else if (_drawSkill.tpCost > 0) {
                                _CostStr += "p" + _drawSkill.tpCost; 
                            }
                        }
                        if (_drawSkill.iconIndex != 0) {
                            _astr += "\\I[" + _drawSkill.iconIndex + "]" + _drawSkill.name;
                        }
                        this.SetSprite(PN_mSkSelBtn + _picNo, BtlPic + "PN_bEmBltWin", _bsPs._x + (_XPosSa * i), _bsPs._y + (62 * j), 0);
                        this.SetSprite(PN_mSkBltCost + _picNo, BtlPic + _CostStr, _bsPs._x + (_XPosSa * i) + 177, _bsPs._y + (62 * j), 0);
                        this.SpriteStr(PN_mSkBltTxt + _picNo, _astr, 22, _bsPs._x + 10 + (_XPosSa * i), _bsPs._y + 13 + (62 * j), 0);
                        if (_装備中Flg) {
                            this.SetSprite(PN_mSkBltSoubi + _picNo, BtlPic + "PN_mSkBltSoubi", _bsPs._x + (_XPosSa * i) - 14, _bsPs._y + (62 * j) - 12, 0);
                            this.MoveSprite(PN_mSkBltSoubi + _picNo, true, true, 5, _SetOpi);
                        }
                    } else {
                        this.SetSprite(PN_mSkSelBtn + _picNo, BtlPic + "PN_bEmBltWin_brank", _bsPs._x + (_XPosSa * i), _bsPs._y + (62 * j), 0);
                        this.SetSprite(PN_mSkBltCost + _picNo, BtlPic + "PN_Cost_brank", _bsPs._x + (_XPosSa * i) + 177, _bsPs._y + (62 * j), 0);
                        let _SetStr = "　- Not Learned -";
                        this.SpriteStr(PN_mSkBltTxt + _picNo, _SetStr, 22, _bsPs._x + 10 + (_XPosSa * i), _bsPs._y + 13 + (62 * j), 0);
                    }
                    _SkillPicArr.push(PN_mSkSelBtn + _picNo);
                    this.MoveSprite(PN_mSkSelBtn + _picNo, true, true, 5, _SetOpi);
                    this.MoveSprite(PN_mSkBltCost + _picNo, true, true, 5, _SetOpi);
                    this.MoveSprite(PN_mSkBltTxt + _picNo, true, true, 5, _SetOpi);
                }
                _SkillNoArr.push(addSkillNoArr);
            }
            this.MovePict(PN_mAdvSell, _MSklCPs._x + (_DgSelX * 270) - 15, _MSklCPs._y + (_DgSelY * 62), 5);
        }
    }
    if (_MkSelX == 1) {
        if (TouchInput.wheelY < 0) {
            this.Menu_PsvSkillDraw(-1);
        }
        if (TouchInput.wheelY > 0) {
            this.Menu_PsvSkillDraw(+1);
        }
        if (_mvFlg) {
            let _ZureY = 0;
            if (_MSkiL1Sel < 0) {
                _MSkiL1Sel = 0;
                _ZureY--;
            }
            if (_MSkiL1Sel > 8) {
                _MSkiL1Sel = 8;
                _ZureY++;
            }
            if (_MSkiL1Sel >= _MPsvSkillCnt) _MSkiL1Sel = _MPsvSkillCnt - 1;
            this.DelSpriteSpan(PN_mSkSelTxt, PN_mSkSelTxt + 2);
            this.Menu_PsvSkillDraw(_ZureY);
            this.MSkl_PsvSetuDraw();
        }
    }
    if (Input.isTriggered('escape') || TouchInput.isCancelled()) {
        SoundManager.playCancel();
        this.Menu_L0_Back(); 
    }
}
Game_Interpreter.prototype.MSkl_PsvSetuDraw = function () {
    let _PsPs = new Pos2D(400, 110);
    let _iNo = _MPsvSkillArr[_MSkiL1Sel + _MPsvZureY];
    let _ckAmm = $dataArmors[_iNo];
    let _SetDescArr = _ckAmm.description.split(/\n/);
    let _dgStr = "\\I[" + _ckAmm.iconIndex + "] " + _ckAmm.name;
    this.SpriteStr(PN_mSkSelTxt + 0, _dgStr, 25, _PsPs._x, _PsPs._y, 0);
    this.MoveSprite(PN_mSkSelTxt + 0, true, true, 5);
    for (let i = 0; i <= _SetDescArr.length - 1; i++) {
        this.SpriteStr(PN_mSkSelTxt + 1 + i, _SetDescArr[i], 18, _PsPs._x, _PsPs._y + 42 + (32 * i), 0);
        this.MoveSprite(PN_mSkSelTxt + 1 + i, true, true, 5);
    }
    this.MovePict(PN_mAdvSell, _PsvPs._x - 20, _PsvPs._y + 17 + (40 * _MSkiL1Sel), 5);
}
let _Sell_Y = 0;
let _Sell_X = 0;
let _Msk1flame = 0;
Game_Interpreter.prototype.MSklLayerL1_Update = function () {
    _MSk_flame++;
    if (_MSk_flame <= 5) return;
    let _mvFlg = false;
    if (Input.isTriggered('up')) {
        _mvFlg = true;
        _DgSelY--;
    }
    if (Input.isTriggered('down')) {
        _mvFlg = true;
        _DgSelY++;
    }
    if (Input.isTriggered('left')) {
        _mvFlg = true;
        _DgSelX--;
    }
    if (Input.isTriggered('right')) {
        _mvFlg = true;
        _DgSelX++;
    }
    let _okFlg = false;
    let _CNo = overPointerSpCkArr(_SkillPicArr);
    if (_CNo != -1) {
        _CNo -= PN_mSkSelBtn;
        if (_CNo % 5 != _DgSelY || Math.floor(_CNo / 5) != _DgSelX) {
            _DgSelX = Math.floor(_CNo / 5);
            _DgSelY = _CNo % 5;
            _mvFlg = true;
        }
        if (TouchInput.isTriggered()) _okFlg = true;
    }
    if (_mvFlg) {
        SoundManager.playCursor();
        if (_DgSelX < 0) _DgSelX = 2;
        if (_DgSelX > 2) _DgSelX = 0;
        if (_DgSelY < 0) _DgSelY = 4;
        if (_DgSelY > 4) _DgSelY = 0;
        let _skillNo = 1 + (_DgSelX * (8 * 5)) + (8 * _DgSelY);
        if ($gameActors.actor(1).isLearnedSkill(_skillNo)) {
            this.Menu_L1Skill_Description(_SkillNoArr[_DgSelX][_DgSelY]);
        } else {
            this.Menu_L1Skill_Description(-1);
        }
        this.MovePict(PN_mAdvSell, _MSklCPs._x + (_DgSelX * 270) - 15, _MSklCPs._y + (_DgSelY * 62), 5);
    }
    if (Input.isTriggered('ok')) _okFlg = true;
    if (_okFlg) {
        SoundManager.playOk();
        let _skillNo = 1 + (_DgSelX * (8 * 5)) + (8 * _DgSelY);
        let _CkSkill = $dataSkills[_skillNo];
        let PsvNo = MetaChecker(_CkSkill, "Psv", 0);
        if (PsvNo > 0) {
        } else {
            let _befid = $gameSystem.PL_SkillArr[_MSkiL1Sel];
            $gameSystem.PL_SkillArr[_MSkiL1Sel] = 0;
            let _SetSkillNo = 0;
            for (let i = 7; i >= 0; i--) {
                if ($gameActors.actor(1).isLearnedSkill(_skillNo + i)) {
                    $gameSystem.PL_SkillArr[_MSkiL1Sel] = _skillNo + i;
                    _SetSkillNo = _skillNo + i;
                    break;
                }
            }
            for (let i = 0; i <= $gameSystem.PL_SkillArr.length - 1; i++) {
                if (i != _MSkiL1Sel) {
                    if ($gameSystem.PL_SkillArr[i] == _SetSkillNo) {
                        $gameSystem.PL_SkillArr[i] = 0;
                    }
                }
            }
            let _allZeroFlg = true;
            for (let i = 0; i <= $gameSystem.PL_SkillArr.length - 1; i++) {
                if ($gameSystem.PL_SkillArr[i] != 0) {
                    _allZeroFlg = false;
                }
            }
            if (_allZeroFlg) {
                $gameSystem.PL_SkillArr[_MSkiL1Sel] = _befid;
            }
        }
        this.DelSpriteSpan(PN_mSkSelBase, PN_mSkSelBtn + 20);
        this.MovePict(PN_mAdvSell, 375, 290 + (_MSkiL1Sel * _mSkSa), 5);
        _MSklLayer--;
        _MkSelX = 0;
        this.Menu_L1Skill_Cng(true);
    }
    if (Input.isTriggered('escape') || TouchInput.isCancelled()) {
        SoundManager.playCancel();
        _MkSelX = 0;
        this.DelSpriteSpan(PN_mSkSelBase, PN_mSkSelBtn + 20);
        this.MovePict(PN_mAdvSell, 375, 290 + (_MSkiL1Sel * _mSkSa), 5);
        _MSklLayer--;
        this.Menu_L1Skill_Cng();
    }
}
const M_Sex_Pic = MenuPic + "Sex/";
Game_Interpreter.prototype.Menu_SexTxtSet = function (_TxtA, _TxtB, _TxtC, _TxtD) {
    _TxtA = typeof _TxtA !== 'undefined' ? _TxtA : "";
    _TxtB = typeof _TxtB !== 'undefined' ? _TxtB : "";
    _TxtC = typeof _TxtC !== 'undefined' ? _TxtC : "";
    _TxtD = typeof _TxtD !== 'undefined' ? _TxtD : "";
    $gameSystem.SexTxt = ["", "", "", ""]; 
    $gameSystem.SexTxt[0] = _TxtA; 
    $gameSystem.SexTxt[1] = _TxtB; 
    $gameSystem.SexTxt[2] = _TxtC; 
    $gameSystem.SexTxt[3] = _TxtD;
}
const VN_淫乱度 = 3;
const VN_経験人数 = 136; 
const VN_絶頂人数 = 137; 
const VN_射精人数 = 138; 
const VN_口経験 = 122; 
const VN_口経験_2 = 125; 
const VN_胸経験 = 129; 
const VN_膣経験 = 142; 
const VN_尻経験 = 149; 
const VN_各回数 = 156; 
let Menu_SexStopFlg = false;
const CN_性経験Open = 34;
Game_Interpreter.prototype.Menu_L1Sex_Cng = function () {
    L2dFadeMdl("Ta_Leona", "rightout", 15, "3koshinite", 1); 
    _DgSelX = _DgSelY = 0;
    this.SetCmnEventSc(CN_性経験Open);
    this.Menu_L1Sex_View();
    Menu_SexStopFlg = true; 
    Menu_SexDrawFlg = false;
}
Game_Interpreter.prototype.MSex_CharaDraw = function (_ImgName, _PsX, _PsY, _opi) {
    _opi = typeof _opi !== 'undefined' ? _opi : 255;
    this.SetSprite(PN_mSxChara, M_Sex_Pic + _ImgName, _PsX, _PsY, _opi);
}
Game_Interpreter.prototype.MSex_CharaMove = function (_PsX, _PsY, _flame, _opi) {
    _opi = typeof _opi !== 'undefined' ? _opi : 255;
    this.MoveSprite(PN_mSxChara, _PsX, _PsY, _flame, _opi);
}
Game_Interpreter.prototype.Menu_L1Sex_View = function () {
    this.Menu_Top_PicDel();
    this.SetSprite(PN_mL2Base, M_Sex_Pic + "PN_mSxBase", 0, 0, 0);
    this.MoveSprite(PN_mL2Base, true, true, 10, 255, true, true);
    this.MovePict(PN_mAdvSell, true, true, 10, 0, true, true); 
}
Game_Interpreter.prototype.Menu_L1Sex_OpnView2 = function () {
    this.DelSpriteSpan(PN_bRzBase, PN_Dice_Anime); 
    ViewPicReset();
    this.SetSprite(PN_mSxLine, M_Sex_Pic + "PN_mSxLine", 0, 0, 0);
    this.SetSprite(PN_mSxIrnWin, M_Sex_Pic + "PN_mSxIrnWin", 55, 516, 0);
    this.SetSprite(PN_mSxKisWin, M_Sex_Pic + "PN_mSxKisWin", 54, 203, 0);
    D_Text_Cng_font = "Makinas"; 
    this.SpriteStrR(PN_mSxSumTxt + 0, $gameVariables.value(VN_経験人数) + "", 30, 381, 231 + (58 * 0), 0);
    this.SpriteStrR(PN_mSxSumTxt + 1, $gameVariables.value(VN_絶頂人数) + "", 30, 381, 231 + (58 * 1), 0);
    this.SpriteStrR(PN_mSxSumTxt + 2, $gameVariables.value(VN_射精人数) + "", 30, 381, 231 + (58 * 2), 0);
    this.SpriteStr(PN_mSxIrnTxt + 1, $gameSystem.SexTxt[0] || "", 17, 93, 584 + (32 * 0), 0);
    this.SpriteStr(PN_mSxIrnTxt + 2, $gameSystem.SexTxt[1] || "", 17, 93, 584 + (32 * 1), 0);
    this.SpriteStr(PN_mSxIrnTxt + 3, $gameSystem.SexTxt[2] || "", 17, 93, 584 + (32 * 2), 0);
    this.SpriteStr(PN_mSxIrnTxt + 0, $gameSystem.SexTxt[3] || "", 17, 93, 584 + (32 * 3), 0);
    let _OCStr = "\\oc[rgba(255,255,255,1)]";
    let _KaisuSize = 28; 
    let _KaisuYZure = -8;
    $gameVariables.setValue(VN_各回数 + 0 ,($gameVariables.value(VN_口経験) + $gameVariables.value(VN_口経験_2)));
    $gameVariables.setValue(VN_各回数 + 1 ,($gameVariables.value(VN_胸経験)));
    $gameVariables.setValue(VN_各回数 + 2 ,($gameVariables.value(VN_膣経験)));
    $gameVariables.setValue(VN_各回数 + 3 ,($gameVariables.value(VN_尻経験)));
    this.SpriteStrR(PN_mSxTxt_1 + 0, 
        SCol.Blk + _OCStr + $dataSystem.variables[VN_各回数 + 0] + "：" +
        $gameVariables.value(VN_各回数 + 0) + "x ", _KaisuSize, 840, 259 + _KaisuYZure, 0);
    this.SpriteStrR(PN_mSxTxt_1 + 1, 
        SCol.Blk + _OCStr + $dataSystem.variables[VN_各回数 + 2] + "：" +
        $gameVariables.value(VN_胸経験) + "x ", _KaisuSize, 1424, 440 + _KaisuYZure, 0);
    this.SpriteStrR(PN_mSxTxt_1 + 2, 
        SCol.Blk + _OCStr + $dataSystem.variables[VN_各回数 + 1] + "：" +
        $gameVariables.value(VN_膣経験) + "x ", _KaisuSize, 840, 589 + _KaisuYZure, 0);
    this.SpriteStrR(PN_mSxTxt_1 + 3, 
        SCol.Blk + _OCStr + $dataSystem.variables[VN_各回数 + 3] + "：" +
        $gameVariables.value(VN_尻経験) + "x ", _KaisuSize, 1424, 683 + _KaisuYZure, 0);
    this.SpriteStrC(PN_mSxInrndTxt, SCol.Blk0 + _OCStr + $gameVariables.value(VN_淫乱度), 50, 128, 520, 0);
    // for (let i = 0; i <= 6 - 1; i++) {
    //     if($dataSystem.variables[VN_口経験 + i] != ''){
    //             $gameVariables.value(VN_口経験 + i) + "％ " , 24 , 840 , 259 + (-35 * _口cnt) , 0);
    //     if($dataSystem.variables[VN_胸経験 + i] != ''){
    //             $gameVariables.value(VN_胸経験 + i) + "％ " , 24 , 840 , 589 + (-35 * _胸cnt) , 0);
    //     if($dataSystem.variables[VN_膣経験 + i] != ''){
    //             $gameVariables.value(VN_膣経験 + i) + "％ " , 24 , 1424 , 440 + (-35 * _膣cnt) , 0);
    //     if($dataSystem.variables[VN_尻経験 + i] != ''){
    //             $gameVariables.value(VN_尻経験 + i) + "％ " , 24 , 1424 , 683 + (-35 * _尻cnt) , 0);
    this.SetSpriteCell(PN_mSxKpkTxt, MenuPic + "Inran_Hart", 14, 1, 73, 464, 0, 70, 70);
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255, true, true);
    }
    D_Text_Cng_font = ""; 
    this.MovePict(PN_mAdvSell, true, true, 10, 0, true, true); 
}
let Menu_SexDrawFlg = false;
Game_Interpreter.prototype.Menu_L1Sex_Update = function () {
    if (Menu_SexStopFlg) {
        return;
    }
    if (!Menu_SexDrawFlg) {
        this.Menu_L1Sex_OpnView2(); 
        Menu_SexDrawFlg = true;
    }
    if (menu_l1_flame > 15) {
        if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
            SoundManager.playCancel();
            this.Menu_L0_Back(); 
            L2dFExp = "H01";
            L2dFadeMdl("Ta_Leona", "rightin", 15, "3koshinite", 1);
            L2dIdleStart("Ta_Leona", "4koshinite_idle");
            L2dTop("Ta_Leona");
        }
    }
}
const M_Option_Pic = MenuPic + "Option/";
let OptSelNo = 0;
let _befOptSelNo = 0;
const VN_難易度No = 463;
const CN_難易度変更コモン = 599;
Game_Interpreter.prototype.Menu_L1Option_Cng = function () {
    _DgSelX = _DgSelY = 0;
    OptSelNo = _befOptSelNo = 0;
    this.Menu_L1Option_View();
}
let _OptionCbMap = [
    [589, 148 + (91 * 0), 542, 33],
    [589, 148 + (91 * 1), 542, 33],
    [589, 148 + (91 * 2), 542, 33],
    [589, 148 + (91 * 3), 542, 33]
];
let Opt_Zure = new Pos2D(0, 0);
let Opt_BarZureX = 0;
Game_Interpreter.prototype.Menu_L1Option_View = function () {
    this.Menu_Top_PicDel();
    var baseImage = "PN_mOpBase"
    if ($gameSwitches.value(SW_奴隷)) {
        this.SetPictFIn(PN_mL2Base - 1, "Black", 0, 0, 0, 0, 15, 150);
        baseImage = "PN_mOpBase_Dorei";
    }
    this.SetPict(PN_mL2Base, M_Option_Pic + baseImage, 0 + Opt_Zure._x, 0, 0);
    this.MovePict(PN_mL2Base, true, true, 10);
    let _OpPs = new Pos2D(593 + Opt_Zure._x, 152);
    let _音量 = $gameVariables.value(MasterVolVarNo);
    let _BGM = ConfigManager['bgmVolume'];
    let _SE = ConfigManager['seVolume'];
    let _Voice = $gameVariables.value(VoiceVolVarNo);
    this.SetPictFIn(PN_mOpBar + 0, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 0), 0, 0, 10, 255, _音量);
    this.SetPictFIn(PN_mOpBar + 1, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 1), 0, 0, 10, 255, _BGM);
    this.SetPictFIn(PN_mOpBar + 2, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 2), 0, 0, 10, 255, _SE);
    this.SetPictFIn(PN_mOpBar + 3, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 3), 0, 0, 10, 255, _Voice);
    D_Text_Cng_font = "Makinas"; 
    this.SetPicStr(PN_mOpTxt + 0, _音量, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 0), 255);
    this.SetPicStr(PN_mOpTxt + 1, _BGM, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 1), 255);
    this.SetPicStr(PN_mOpTxt + 2, _SE, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 2), 255);
    this.SetPicStr(PN_mOpTxt + 3, _Voice, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 3), 255);
    D_Text_Cng_font = "";
    this.MenuDraw難易度Btn();
    if (title_option_flg) {
        this.SetPictC(PN_mAdvSell, AdvPic + "PN_AdvSell", 358, 169 + (OptSelNo * 91), 0);
    }
    this.MovePict(PN_mAdvSell, 358 + Opt_BarZureX, 169 + (OptSelNo * 91), 5);
    //this.MovePict(PN_mAdvSell , 358 - 150 , 169 + (OptSelNo * 91) , 5);
}
Game_Interpreter.prototype.Option_BarDraw = function () {
    let _OpPs = new Pos2D(593 + Opt_Zure._x, 152);
    let _音量 = $gameVariables.value(MasterVolVarNo);
    let _BGM = ConfigManager['bgmVolume'];
    let _SE = ConfigManager['seVolume'];
    let _Voice = $gameVariables.value(VoiceVolVarNo);
    this.SetPict(PN_mOpBar + 0, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 0), 255, _音量);
    this.SetPict(PN_mOpBar + 1, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 1), 255, _BGM);
    this.SetPict(PN_mOpBar + 2, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 2), 255, _SE);
    this.SetPict(PN_mOpBar + 3, M_Option_Pic + "PN_mOpBar", _OpPs._x + Opt_BarZureX, _OpPs._y + (91 * 3), 255, _Voice);
    D_Text_Cng_font = "Makinas"; 
    this.SetPicStr(PN_mOpTxt + 0, _音量, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 0), 255);
    this.SetPicStr(PN_mOpTxt + 1, _BGM, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 1), 255);
    this.SetPicStr(PN_mOpTxt + 2, _SE, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 2), 255);
    this.SetPicStr(PN_mOpTxt + 3, _Voice, 40, _OpPs._x + 593 + Opt_BarZureX, 140 + (91 * 3), 255);
    D_Text_Cng_font = "";
    this.MenuDraw難易度Btn();
}
Game_Interpreter.prototype.MenuDraw難易度Btn = function () {
    if (!title_option_flg) {
        for (let i = 0; i < 3; i++) {
            let btnName = M_Option_Pic + "PN_OpNanido" + (i + 1) + "_off";
            if ($gameVariables.value(VN_難易度No) == i) btnName = M_Option_Pic + "PN_OpNanido" + (i + 1);
            this.SetPict(PN_OpNanido + i, btnName, 576 + 200 * i, 504);
        }
    } else {
        this.SetPict(PN_OpNanido, M_Option_Pic + "PN_mOpBase_Title", 0, 0);
    }
}
let OptNanidoSelectNo = 0;
Game_Interpreter.prototype.Menu_L1Option_Update = function () {
    if (menu_l1_flame > 15) {
        let _mvFlg = false;
        if (Input.isTriggered('up')) {
            _mvFlg = true;
            OptSelNo--;
        }
        if (Input.isTriggered('down')) {
            _mvFlg = true;
            OptSelNo++;
        }
        if (Input.isTriggered('left')) {
            this.OptionEdit(-1);
        }
        if (Input.isTriggered('right')) {
            this.OptionEdit(+1);
        }
        let _CNo = overPicClickable(PN_mL2Base, _OptionCbMap);
        if (_CNo != -1) {
            if (OptSelNo != _CNo) {
                OptSelNo = _CNo;
                _mvFlg = true;
            }
            if (TouchInput.isPressed()) {
                let _ParX = PL_MouseX - 589 - Opt_Zure._x;
                let _SetPar = Math.floor((_ParX / 542) * 100);
                _OpSetVar = _SetPar;
                OptSelNo = _CNo;
                this.OptionEdit(0);
            }
        }
        _CNo = overPointerCkArr( [PN_OpNanido + 0 , PN_OpNanido + 1 , PN_OpNanido + 2]);
        if (_CNo != -1 && !title_option_flg) {
            OptSelNo = 4;
            if (OptNanidoSelectNo != _CNo - PN_OpNanido) {
                OptNanidoSelectNo = _CNo - PN_OpNanido;
                let xPos = 619 + (OptNanidoSelectNo) * 200;
                this.MovePict(PN_mAdvSell, xPos, 574, 5);
            }
            if (TouchInput.isPressed()) {
                $gameVariables.setValue(VN_難易度No ,OptNanidoSelectNo);
                this.MenuDraw難易度Btn();
                SoundManager.playCursor();
                this.SetCmnEventSc(CN_難易度変更コモン);
            }
        }
        let maxNo = 4;
        if (title_option_flg) maxNo = 3;
        if (OptSelNo < 0) OptSelNo = maxNo;
        if (OptSelNo > maxNo) OptSelNo = 0;
        if (_mvFlg) {
            if (OptSelNo == 4) {
                OptNanidoSelectNo = $gameVariables.value(VN_難易度No);
                let xPos = 619 + OptNanidoSelectNo * 200;
                this.MovePict(PN_mAdvSell, xPos, 574, 5);
            } else {
                this.MovePict(PN_mAdvSell, 358 + Opt_BarZureX, 169 + (OptSelNo * 91), 5);
            }
            SoundManager.playCursor();
            //this.MovePict(PN_mAdvSell , 358 - 150 , 169 + (OptSelNo * 91) , 5);
        }
        if (Input.isTriggered('ok')) {
            if (OptSelNo == 4) {
                Input._latestButton = "";
                $gameVariables.setValue(VN_難易度No ,OptNanidoSelectNo);
                this.MenuDraw難易度Btn();
                SoundManager.playCursor();
                this.SetCmnEventSc(CN_難易度変更コモン);
            }
        }
        if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
            SoundManager.playCancel();
            DelPictSpan(PN_mL2Base, PN_mL3Base); 
            if (title_option_flg) {
                DelPict(PN_mL2Base - 1);
                DelPict(PN_mAdvSell);
                title_option_flg = false;
            } else {
                if ($gameSwitches.value(SW_奴隷)) {
                    DelPict(PN_mL2Base - 1);
                    this.Adv_DoreiL0_Back();
                } else {
                    this.Menu_L0_Back(); 
                }
            }
            this.UTA_Save(); 
            ConfigManager.save(); 
        }
    }
    if (_OpVoiceflame > 0) _OpVoiceflame--;
}
let _OpSetVar = -1; 
let _OpVoiceflame = 0; 
let _OpVoiceNo = 0; 
Game_Interpreter.prototype.OptionEdit = function (_keyInt) {
    switch (OptSelNo) {
        case 0: 
            let _MasVol = $gameVariables.value(MasterVolVarNo);
            _MasVol += _keyInt * 10;
            if (_MasVol == _OpSetVar) break;
            if (_OpSetVar != -1) _MasVol = _OpSetVar;
            _MasVol = VarHani(_MasVol, 0, 100);
            $gameVariables.setValue(MasterVolVarNo, _MasVol); 
            AudioManager.masterVolume = Math.floor($gameVariables.value(MasterVolVarNo)) / 100;
            SoundManager.playCursor(); 
            break;
        case 1: 
            let _BGMVol = ConfigManager['bgmVolume'];
            _BGMVol += _keyInt * 20;
            if (_BGMVol == _OpSetVar) break;
            if (_OpSetVar != -1) _BGMVol = _OpSetVar;
            _BGMVol = VarHani(_BGMVol, 0, 100);
            ConfigManager['bgmVolume'] = _BGMVol;
            SoundManager.playCursor(); 
            break;
        case 2: 
            let _SEMVol = ConfigManager['seVolume'];
            _SEMVol += _keyInt * 20;
            if (_SEMVol == _OpSetVar) break;
            if (_OpSetVar != -1) _SEMVol = _OpSetVar;
            _SEMVol = VarHani(_SEMVol, 0, 100);
            ConfigManager['seVolume'] = _SEMVol;
            SoundManager.playOk(); 
            break;
        case 3: 
            let _VoiceVol = $gameVariables.value(VoiceVolVarNo);
            _VoiceVol += _keyInt * 20;
            if (_VoiceVol == _OpSetVar) break; 
            if (_OpSetVar != -1) _VoiceVol = _OpSetVar;
            _VoiceVol = VarHani(_VoiceVol, 0, 100);
            $gameVariables.setValue(VoiceVolVarNo, _VoiceVol); 
            VoiceVol = $gameVariables.value(VoiceVolVarNo); 
            if (_OpVoiceflame <= 0) {
                this.PVoice("System", "option_" + _OpVoiceNo);
                _OpVoiceNo++;
                if (_OpVoiceNo == 3) _OpVoiceNo = 0;
                _OpVoiceflame = 10;
            }
            break;
        case 4: 
            OptNanidoSelectNo += _keyInt;
            if (OptNanidoSelectNo > 2) OptNanidoSelectNo = 0;
            if (OptNanidoSelectNo < 0) OptNanidoSelectNo = 2;
            let xPos = 619 + OptNanidoSelectNo * 200;
            this.MovePict(PN_mAdvSell, xPos, 574, 5);
            break;
    }
    _OpSetVar = -1;
    this.Option_BarDraw();
}
/* オーディオファイル：自動削除システム対策用
this.PVoice("System","option_0");
this.PVoice("System","option_1");
this.PVoice("System","option_2");
 */
let VarHani = function (_Var, _minVar, _maxVar) {
    if (_Var <= _minVar) {
        _Var = _minVar;
    }
    if (_Var >= _maxVar) {
        _Var = _maxVar;
    }
    return _Var;
}
const M_Title_Pic = MenuPic + "Title/";
let _MTSelX = 1;
let _TbackCbMap = [
    [366, 407, 283, 110],
    [366 + 401, 407, 283, 110]
];
Game_Interpreter.prototype.Menu_L1Title_Cng = function () {
    mItem_flame = 0;
    _DgSelX = _DgSelY = 0;
    _MTSelX = 1;
    this.Menu_L1Title_View();
}
Game_Interpreter.prototype.Menu_L1Title_View = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    this.Menu_Top_PicDel();
    this.SetSprite(PN_mL2Base, M_Title_Pic + "PN_mTbBase", 0, 0, 0);
    this.MoveSprite(PN_mL2Base, 0, 0, 10);
    this.MovePict(PN_mAdvSell, 363 + (390 * _MTSelX), 465, 5);
    this.MovePict(PN_mAdvSell, 363 + (390 * _MTSelX), 465, 5);
}
Game_Interpreter.prototype.Menu_L1Title_Update = function () {
    if (menu_l1_flame > 15) {
        let _mvFlg = false;
        if (Input.isTriggered('right')) {
            _MTSelX--;
            _mvFlg = true;
        }
        if (Input.isTriggered('left')) {
            _MTSelX++;
            _mvFlg = true;
        }
        let _okFlg = false;
        let _CNo = overSpriteClickable(PN_mL2Base, _TbackCbMap);
        if (_CNo != -1) {
            if (_CNo != _MTSelX) {
                _MTSelX = _CNo;
                _mvFlg = true;
            }
            if (TouchInput.isTriggered()) {
                _okFlg = true;
            }
        }
        if (_MTSelX < 0) _MTSelX = 1;
        if (_MTSelX > 1) _MTSelX = 0;
        if (_mvFlg) {
            SoundManager.playCursor();
            this.MovePict(PN_mAdvSell, 363 + (390 * _MTSelX), 465, 5);
        }
        if (Input.isTriggered('ok')) _okFlg = true;
        if (_okFlg) {
            SoundManager.playOk();
            if (_MTSelX == 0) GameResetFlame = 1;
            if (_MTSelX == 1) {
                if ($gameSwitches.value(SW_奴隷)) {
                    this.Adv_DoreiL0_Back();
                } else {
                    this.Menu_L0_Back(); 
                }
            }
        }
        if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
            SoundManager.playCancel();
            if ($gameSwitches.value(SW_奴隷)) {
                this.Adv_DoreiL0_Back();
            } else {
                this.Menu_L0_Back(); 
            }
        }
    }
}
let TitleFlg = false; 
let loadFlg = false; 
const _SavePage数 = 10;
const _Save数 = _SavePage数 * 10; 
const _Save情報数 = 15;
const _SaveGWidth = 200;
let _mSavePicPath = "pictures/Menu/Save/";
let _mSaveCMap = [ 
    [490 + (102 * 0), 35, 88, 31],
    [490 + (102 * 1), 35, 88, 31],
    [490 + (102 * 2), 35, 88, 31],
    [490 + (102 * 3), 35, 88, 31],
    [490 + (102 * 4), 35, 88, 31],
    [490 + (102 * 5), 35, 88, 31],
    [490 + (102 * 6), 35, 88, 31],
    [490 + (102 * 7), 35, 88, 31],
    [490 + (102 * 8), 35, 88, 31],
    [490 - 179 , 35, 145, 31] 
];
let Menu_Save_保存 = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    Menu_Save_保存.call(this);
};
let SaveArr = []; 
let SaveArr_NewSet = function () {
    SaveArr = [];
    let _setArr = [];
    for (let i = 0; i <= _Save情報数 - 1; i++) _setArr.push("");
    for (let i = 0; i <= _Save数 - 1; i++) SaveArr.push(_setArr.slice());
    SaveArr_Save();
};
let SaveArr_Load = function () {
    SaveArr = [];
    let _ckStr = $gameVariables.value(VN_SaveStr);
    let _ckArr = _ckStr.split(',');
    let _Cnt = 0;
    let _setArr = [];
    for (let i = 0; i <= _ckArr.length - 1; i++) {
        _setArr.push(String(_ckArr[i]));
        if (_Cnt == _Save情報数 - 1) {
            _Cnt = 0;
            SaveArr.push(_setArr.slice());
            _setArr = [];
        } else {
            _Cnt++;
        }
    }
    for (let i = SaveArr.length; i < _Save数; i++) {
        let _setArr = [];
        for (let i = 0; i <= _Save情報数 - 1; i++) _setArr.push("");
        SaveArr.push(_setArr);
    }
}
let SaveArr_Save = function () {
    let _RtnStr = "";
    for (let i = 0; i <= SaveArr.length - 1; i++) {
        for (let j = 0; j <= SaveArr[i].length - 1; j++) {
            _RtnStr += SaveArr[i][j];
            if (j != SaveArr[i].length - 1) _RtnStr += ",";
        }
        if (i != SaveArr.length - 1) _RtnStr += ",";
    }
    $gameVariables.setValue(VN_SaveStr, _RtnStr);
};
Game_Interpreter.prototype.Menu_L1SaveLoad_Cng = function () {
    let _BefSaveNo = $gameVariables.value(VN_BefSaveNo)
    SaveAutoSavePageFlg = false;
    SavePageNo = Math.floor(_BefSaveNo / 10);
    let _SelNo = _BefSaveNo % 10;
    SaveSelX = _SelNo % 2;
    SaveSelY = Math.floor(_SelNo / 2);
}
Game_Interpreter.prototype.Menu_L1Save_Cng = function () {
    this.Menu_L1SaveLoad_Cng();
    loadFlg = false; 
    this.Menu_L1Save_View(true);
}
Game_Interpreter.prototype.Menu_L1Load_Cng = function () {
    this.Menu_L1SaveLoad_Cng();
    loadFlg = true; 
    this.Menu_L1Save_View(true);
}
let _Set半角スペース = function (_SetStr, _半角数) {
    let _RtnStr = String(_SetStr);
    for (let i = _RtnStr.length; i <= _半角数; i++) {
        _RtnStr += " ";
    }
    return _RtnStr;
}
let SavePageNo = 0; 
let SaveSelX = 0; //選択X位置(0~1)
let SaveSelY = 0; //選択Y位置(0~4)
Game_Interpreter.prototype.Menu_L1Save_View = function (_SetFlg) {
    let _SWPos = new Pos2D(68, 95); 
    if ($gameVariables.value(VN_SaveStr) == 0) {
        SaveArr_NewSet();   
        this.UTA_Save();    
    } else {
        SaveArr_Load(); 
    }
    let _opi = 255;
    if (_SetFlg) _opi = 0;
    if (loadFlg) {
        this.SetPict(PN_mSvBase, _mSavePicPath + "PN_mSvBase_l", 0, 0, _opi);
    } else {
        this.SetPict(PN_mSvBase, _mSavePicPath + "PN_mSvBase", 0, 0, _opi);
    }
    this.MovePict(PN_mSvBase, 0, 0, 10);
    let _PagePosX = _mSaveCMap[SavePageNo][0];
    let _PagePosY = _mSaveCMap[SavePageNo][1];
    this.SetPictFIn(PN_MSvPageSel, _mSavePicPath + "PN_MSvPageSel", _PagePosX, _PagePosY, 0, 0, 10);
    if (SaveAutoSavePageFlg) {
        _PagePosX = _mSaveCMap[_mSaveCMap.length - 1][0];
        _PagePosY = _mSaveCMap[_mSaveCMap.length - 1][1];
        this.SetPictFIn(PN_MSvPageSel, _mSavePicPath + "PN_MSvAutoSel", _PagePosX, _PagePosY, 0, 0, 10);
    }
    menuL1TcPic = [];
    let CheckSavePageNo = SavePageNo;
    for (let i = 0; i <= 10 - 1; i++) {
        let _ckArr = SaveArr[i + CheckSavePageNo * 10]; 
        let _psX = _SWPos._x + ((i % 2) * 670);
        let _psY = _SWPos._y + (Math.floor(i / 2) * 138);
        menuL1TcPic.push(PN_MSvWin + i);
        if (_ckArr[2] == "dorei") {
            this.SetPict(PN_MSvWin + i, _mSavePicPath + "PN_MSvWin_dorei", _psX, _psY, 255);
        } else {
            this.SetPict(PN_MSvWin + i, _mSavePicPath + "PN_MSvWin", _psX, _psY, 255);
        }
        let saveName = "Save" + (i + 1 + CheckSavePageNo * 10);
        if (SaveAutoSavePageFlg) saveName = "ASave" + (i + 1);
        if (_ckArr[0] == "") {
            let _TxtOL = "\\oc[rgba(0,0,0,1)]";
            this.SetPicStr(PN_MSvTxt_t + i, _TxtOL + saveName + "　-No Data-", 21, _psX + 16, _psY + 5, 155);
            this.SetPicStr(PN_MSvTxt_d + i, _TxtOL + "PlayTime --:--:--", 18, _psX + 484, _psY + 9, 155);
            this.DelPict(PN_MSvTxt_1 + i);
            this.DelPict(PN_MSvTxt_2 + i);
            this.DelPict(PN_MSvTxt_3 + i);
            this.DelPict(PN_MSvTxt_4 + i);
        } else {
            let _TxtOL = "\\oc[rgba(0,0,0,1)]";
            let _タイトル = _ckArr[0];
            let _時刻 = _ckArr[1];
            this.SetPicStr(PN_MSvTxt_t + i, _TxtOL + saveName + "　" + _タイトル, 21, _psX + 16, _psY + 5);
            this.SetPicStr(PN_MSvTxt_d + i, _TxtOL + _時刻, 18, _psX + 454, _psY + 9);
            let _stTxtSize = 14;
            let _GPos = new Pos2D(36, 45);
            this.DelPict(PN_MSvTxt_1 + i);
            if (_ckArr[2] == "dorei") {
                D_Text_Cng_font = "Makinas";
                this.SetPicStr(PN_MSvTxt_2 + i, "\\ow[6]\\oc[rgb(0,0,0)] " + _ckArr[3] + " ％ ", 23, _psX + 104, _psY + 42);
                this.SetPicStr(PN_MSvTxt_3 + i, "\\ow[6]\\oc[rgb(0,0,0)] " + _ckArr[4] + " ", 23, _psX + 109 + 165, _psY + 42);
                this.SetPicStr(PN_MSvTxt_4 + i, "\\ow[6]\\oc[rgb(0,0,0)] " + _ckArr[5] + " ", 23, _psX + 147, _psY + 80);
                D_Text_Cng_font = "";
            } else {
                let _健康 = _ckArr[2];
                this.SetPicStr(PN_MSvTxt_1 + i, _TxtOL + _健康 + " ", _stTxtSize, _psX + 68, _psY + 32);
                let _TxtSpace = "　　　　　　　　　　　　　　　 ";
                let _体力 = _Set半角スペース(_ckArr[4], 3);
                let _攻撃 = _Set半角スペース(_ckArr[5], 3);
                let _防御 = _Set半角スペース(_ckArr[6], 3);
                let _命中 = _Set半角スペース(_ckArr[7], 3);
                let _回避 = _Set半角スペース(_ckArr[8], 3);
                let _直感 = _Set半角スペース(_ckArr[9], 3);
                this.SetPicStr(PN_MSvTxt_2 + i, _TxtOL + _体力 + _TxtSpace + _攻撃 + " ", _stTxtSize, _psX + 68, _psY + 55 + 18 * 0);
                this.SetPicStr(PN_MSvTxt_3 + i, _TxtOL + _防御 + _TxtSpace + _命中 + " ", _stTxtSize, _psX + 68, _psY + 55 + 18 * 1);
                this.SetPicStr(PN_MSvTxt_4 + i, _TxtOL + _回避 + _TxtSpace + _直感 + " ", _stTxtSize, _psX + 68, _psY + 55 + 18 * 2);
                this.SetPict(PN_Cmp, _mSavePicPath + "Gage", 0, 0, 255); 
                let _SetPx = Number(_健康) * 2;
                if (_SetPx == 0) _SetPx = 0.01;
                this.CmpPict(PN_MSvWin + i, PN_Cmp, _GPos._x, _GPos._y, _SetPx);
                _GPos._y += 23;
                for (let j = 0; j <= 6 - 1; j++) { 
                    let _SetCnt = Number(_ckArr[4 + j].replace(" ", ""));
                    _SetCnt /= 2;
                    this.SetPict(PN_Cmp, _mSavePicPath + "Gage", 0, 0, 255, 50);
                    this.CmpPict(PN_MSvWin + i, PN_Cmp, _GPos._x + (j % 2) * 236, _GPos._y + Math.floor(j / 2) * 18, _SetCnt);
                }
            }
            if (_ckArr[2] == "dorei") {
                this.SetPict(PN_Cmp, _mSavePicPath + "PN_MSvWin_Top_dorei", 0, 0);
            } else {
                this.SetPict(PN_Cmp, _mSavePicPath + "PN_MSvWin_Top", 0, 0);
            }
            this.CmpPict(PN_MSvWin + i, PN_Cmp);
        }
        if (i == (SaveSelX + SaveSelY * 2)) {
            this.MovePict(PN_mAdvSell, _psX - 20, _psY + 60, 5);
            this.SetPictFIn(PN_MSvWin_Sel, _mSavePicPath + "PN_MSvWin_Sel", _psX - 26, _psY - 26, 0, 0, 5);
        }
    }
}
let SaveAutoSavePageFlg = false;
Game_Interpreter.prototype.Menu_L1Save_Update = function () {
    if (LoadingFlg) return; 
    let _SWPos = new Pos2D(68, 95); 
    let _mvFlg = false;
    if (menu_l1_flame <= 5) return;
    if (Input.isTriggered('up')) {
        _mvFlg = true;
        SaveSelY--;
    }
    if (Input.isTriggered('down')) {
        _mvFlg = true;
        SaveSelY++;
    }
    if (Input.isTriggered('left')) {
        _mvFlg = true;
        SaveSelX--;
        if (SaveSelX < 0) {
            if (SaveAutoSavePageFlg) {
                SaveSelX = 0;
                return;
            }
            if (SavePageNo > 0) {
                SavePageNo--;
                SaveSelX = 1;
                _mvFlg = false;
                this.Menu_L1Save_View();
            } else {
                if (loadFlg && !SaveAutoSavePageFlg){
                    SavePageNo = _SavePage数 - 1;
                    SaveAutoSavePageFlg = true;
                    this.Menu_L1Save_View();
                }
                SaveSelX = 0; 
            }
        }
    }
    if (Input.isTriggered('right')) {
        _mvFlg = true;
        SaveSelX++;
        if (SaveSelX > 1) {
            if (SaveAutoSavePageFlg) {
                SaveAutoSavePageFlg = false;
                SavePageNo = -1;
            }
            if (SavePageNo < _SavePage数 - 2) {
                SavePageNo++;
                SaveSelX = 0;
                _mvFlg = false;
                this.Menu_L1Save_View();
            } else {
                SaveSelX = 1; 
            }
        }
    }
    if (SaveSelY > 4) SaveSelY = 0;
    if (SaveSelY < 0) SaveSelY = 4;
    let _CNo = overPointerCkArr(menuL1TcPic);
    if (_CNo != -1) {
        if (SaveSelX + SaveSelY * 2 != _CNo - PN_MSvWin) {
            let _SelNo = _CNo - PN_MSvWin;
            SaveSelY = Math.floor(_SelNo / 2);
            SaveSelX = _SelNo % 2;
            _mvFlg = true;
        }
    }
    let _CbMap = overPicClickable(PN_mSvBase, _mSaveCMap);
    if (_CbMap != -1) {
        if (TouchInput.isTriggered()) {
            if (SavePageNo != _CbMap) {
                if (loadFlg && _CbMap == _SavePage数 - 1) SaveAutoSavePageFlg = true;
                else SaveAutoSavePageFlg = false;
                SavePageNo = _CbMap;
                SaveSelX = SaveSelY = 0;
            }
            this.Menu_L1Save_View();
        }
    }
    if (_mvFlg && !LoadingFlg) {
        SoundManager.playCursor();
        menu_l1_flame = 0;
        let _psX = _SWPos._x + (SaveSelX * 670);
        let _psY = _SWPos._y + (SaveSelY * 138);
        this.MovePict(PN_mAdvSell, _psX - 20, _psY + 60, 5);
        this.SetPictFIn(PN_MSvWin_Sel, _mSavePicPath + "PN_MSvWin_Sel", _psX - 26, _psY - 26, 0, 0, 5);
    }
    if (Input.isTriggered('ok') || ((_CNo != -1) && TouchInput.isTriggered())) { 
        let _SelectNo = SaveSelX + SaveSelY * 2 + SavePageNo * 10;
        SoundManager.playOk();
        if (loadFlg) {
            if (SaveArr[_SelectNo][0] != "" && !LoadingFlg) { 
                TitleFlg = false;
                this.Load_Start(_SelectNo + 1);
            }
        } else {
            SoundManager.playSave();
            this.SaveData(_SelectNo);
            $gameVariables.setValue(VN_BefSaveNo, _SelectNo); 
            this.Menu_L1Save_View();
            menu_l1_flame = -15;
        }
    }
    if (Input.isTriggered('escape') || TouchInput.isCancelled()) { 
        SoundManager.playCancel();
        this.DelPictSpan(PN_mSvBase, PN_MSvWin_Sel);
        if (SetSaveFlg) { 
            SetSaveFlg = false;
            return;
        }
        if (TitleFlg) { 
            loadFlg = false; 
            this.Menu_Top_PicDel();
        } else {
            if ($gameVariables.value(SW_奴隷)) {
                this.Adv_DoreiL0_Back();
            } else {
                this.Menu_L0_Back(); 
            }
        }
    }
}
Game_Interpreter.prototype.SaveData = function (SaveNo , autoSaveFlg) {
    autoSaveFlg = typeof autoSaveFlg !== 'undefined' ? autoSaveFlg : false;
    if (!autoSaveFlg) SoundManager.playSave();
    while(SaveArr[SaveNo] == undefined) {
        let _setArr = [];
        for (let i = 0; i <= _Save情報数 - 1; i++) _setArr.push("");
        SaveArr.push(_setArr.slice());
    }
    SaveArr[SaveNo][0] = $gameVariables.value(VN_章Title) + ": Day " + $gameVariables.value(VN_日付);
    SaveArr[SaveNo][1] = "      Time " + $gameSystem.playtimeText();
    if ($gameSwitches.value(SW_奴隷)) {
        SaveArr[SaveNo][2] = "dorei";   
        SaveArr[SaveNo][3] = $gameVariables.value(VN_奴隷_屈服度);   
        SaveArr[SaveNo][4] = $gameVariables.value(VN_奴隷_開発度);   
        let _口経験 = $gameVariables.value(122) + $gameVariables.value(125);
        SaveArr[SaveNo][5] = "Oral:" + _口経験 + " Vag:" + $gameVariables.value(VN_膣経験)
            + " Chest:" + $gameVariables.value(VN_胸経験) + " Anal:" + $gameVariables.value(VN_尻経験);     
        SaveArr[SaveNo][6] = "1";     
        SaveArr[SaveNo][7] = "1";     
        SaveArr[SaveNo][8] = "1";   
        SaveArr[SaveNo][9] = "1";    
    } else {
        let _WpId = $gameActors._data[1]._equips[0]._itemId;
        SaveArr[SaveNo][2] = $gameVariables.value(VN_PLKenko);   
        SaveArr[SaveNo][3] = $gameVariables.value(VN_PLInran);   
        SaveArr[SaveNo][4] = $gameVariables.value(VN_PLHp) + $dataWeapons[_WpId].params[0];      
        SaveArr[SaveNo][5] = $gameVariables.value(VN_PLAtk) + $dataWeapons[_WpId].params[2];     
        SaveArr[SaveNo][6] = $gameVariables.value(VN_PLDef) + $dataWeapons[_WpId].params[3];     
        SaveArr[SaveNo][7] = $gameVariables.value(VN_PLHit) + $dataWeapons[_WpId].params[4];     
        SaveArr[SaveNo][8] = $gameVariables.value(VN_PLkaihi) + $dataWeapons[_WpId].params[6];   
        SaveArr[SaveNo][9] = $gameVariables.value(VN_PLYomi) + $dataWeapons[_WpId].params[7];    
    }
    SaveArr_Save(); 
    this.GameFileSave(SaveNo + 1); 
    this.UTA_Save(); 
}
let SetSaveFlg = false;
Game_Interpreter.prototype.SetSave_Start = function () {
    loadFlg = false;
    SetSaveFlg = true;
    LoadingFlg = false;
    this.Menu_L1Save_View();
}
Game_Interpreter.prototype.SetSave_Update = function () {
    menu_l1_flame++;
    this.Menu_L1Save_Update();
    return SetSaveFlg;
}
Game_Interpreter.prototype.SetSave_End = function () {
}
let LoadingFlg = false; 
let Load_Startflame = 0;
let LoadFileNo = -1;
Game_Interpreter.prototype.Load_Start = function (_FileNo) {
    this.PlaySe("Title_Gun");
    LoadingFlg = true;
    Load_Startflame = 0;
    LoadFileNo = _FileNo;
}
let Loading_Update = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    Loading_Update.call(this);
    if (LoadFileNo != -1) {
        if (Load_Startflame == 0) { 
            this.SetPictFIn(PVS_MaxPicNo, "Black", 0, 0, 0, 0, 60);
        }
        if (Load_Startflame == 60) {
            this.LoadStarting(LoadFileNo); 
        }
        Load_Startflame++;
    }
    if (_LoadCmpFlg) { 
        this.Menu_Close(); 
        this.DelPictSpan(PN_tSelBtn, PN_AdvSell); 
        _LoadCmpFlg = false;
        this.Adv_L0_Cng(); 
        this.DelPict(PVS_MaxPicNo);
        this.DelPict(PN_EnSpine); 
    }
}
let _NLoadComp = function () {
    LoadFileNo = -1;
    Load_Startflame = 0;
    LoadingFlg = false; 
}
const _Load仮Map = 3; 
let _LoadCmpFlg = false; 
Game_Interpreter.prototype.LoadStarting = function (_LoadNo) {
    _LoadSelectNo = _LoadNo;
    SceneManager.push(Scene_Load);
    _MMoveFlame = 0; 
}
Game_Event.prototype.findProperPageIndex = function () {
    if (this.event() == undefined) {
        return -1;
    }
    let pages = this.event().pages;
    for (let i = pages.length - 1; i >= 0; i--) {
        let page = pages[i];
        if (this.meetsConditions(page)) {
            return i;
        }
    }
    return -1;
};
Game_Event.prototype.page = function () {
    try {
        return this.event().pages[this._pageIndex]; 
    } catch (e) {
        console.log(e);
    }
};
let _LoadSelectNo = 0; 
Scene_Load.prototype.update = function () {
    Scene_File.prototype.update.call(this);
    if (_LoadSelectNo != 0) {
        this.onSavefileOk();
        _LoadSelectNo = 0
    }
}
Scene_File.prototype.savefileId = function () {
    return _LoadSelectNo;
};
Scene_Load.prototype.createWindowLayer = function () {
    let width = 0;
    let height = 0;
    let x = (Graphics.width - width) / 2;
    let y = (Graphics.height - height) / 2;
    this._windowLayer = new WindowLayer();
    this._windowLayer.move(x, y, width, height);
    this.addChild(this._windowLayer);
}
Scene_Load.prototype.onLoadSuccess = function () {
    this.fadeOutAll();
    this.reloadMapIfUpdated();
    SceneManager.goto(Scene_Map);
    this._loadSuccess = true;
    _LoadCmpFlg = true;
    N_LoadSuccessFlg = true;
    _NLoadComp();
}
let N_LoadSuccessFlg = false; 
let Loading_CmpUpdate = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    Loading_CmpUpdate.call(this);
    if (N_LoadSuccessFlg) { 
        L2dAutoFadeOut("Title", 2);
        this.DelPictSpan(PN_mSvBase, PN_MSvWin_Sel);
        this.DelSpriteSpan(PN_mSvBase, PN_MSvWin_Sel);
        if ($gameSwitches.value(SW_奴隷)) {
            for (let i = 0; i <= 4 - 1; i++) {
                this.DelPict(PN_tBack_Tp + i);
            }
            this.DelPict(PN_mDBase);
            this.Adv_Dorei_Cng();
        }
        N_LoadSuccessFlg = false;
    }
}
let _autoSaveFlame = -1;
const SetAutoAutoSaveFlame = 60 * 60 * 2; 
let _AutoAutoSaveFlame = SetAutoAutoSaveFlame;
let _AutoSaveWait = 0;
let PN_AutoSaveIcon = 500;
let PN_AutoSaveTxt = PN_AutoSaveIcon + 1;
const AutoSaveSpanFlame = 60 * 60 * 1; 
let BefAutoSaveFlame = AutoSaveSpanFlame;
Game_Interpreter.prototype.AutoSave = function () {
    if (BefAutoSaveFlame > 0) return;
    _autoSaveFlame = 10;
    BefAutoSaveFlame = AutoSaveSpanFlame;
}
let _AutoSaveUpdate = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    _AutoSaveUpdate.call(this);
    BefAutoSaveFlame--;
    if (_AutoAutoSaveFlame > 0) _AutoAutoSaveFlame--;
    if (_AutoSaveWait > -1) _AutoSaveWait--;
    if ($gameMap.isEventRunning() && _autoSaveFlame > 0) {
        _autoSaveFlame++;
    }
    if (_autoSaveFlame >= 0) {
        if (_autoSaveFlame == 0) {
            if ($gameVariables.value(VN_SaveStr) == 0) {
                SaveArr_NewSet();   
            }
            if (SaveArr.length == 0) SaveArr_Load();
            let SaveNo = $gameVariables.value(VN_オートセーブ番号);
            this.SaveData(90 + SaveNo , true);
            SaveNo++;
            if (SaveNo >= 10) SaveNo = 0;
            $gameVariables.setValue(VN_オートセーブ番号 , SaveNo);
            this.SetPictC(PN_AutoSaveIcon , "PN_AutoSaveIcon" , 20 , 792);
            $gameScreen.rotatePicture(PN_AutoSaveIcon, 20);
            StacWaitPict(PN_AutoSaveIcon , 30);
            StacMovePict(PN_AutoSaveIcon , true , true , 30 , 0);
            this.SetPict( PN_AutoSaveTxt , "PN_AutoSaveTxt" , 35 , 785);
            StacWaitPict(PN_AutoSaveTxt , 30);
            StacMovePict(PN_AutoSaveTxt , true , true , 30 , 0);
        }
        _autoSaveFlame--;
    }
}
