const IsyoDotSet = [ //[衣装No , 髪型No , ドット画像(歩き) , ドット画像座り , 座りNo]
    [0, 0, "Player_Seifuku%(6)", "!sitting_player_1", 0],       
    [1, 0, "Player_long_skirt%(6)", "!sitting_player_3", 2],    
    [2, 0, "Player_pony_custom%(6)", "!sitting_player_3", 0],   
    [3, 0, "Player_pony_shitagi%(6)", "!sitting_player_2", 6],  
    [4, 0, "Player_pony_hadaka%(6)", "!sitting_player_2", 4],   
    [5, 0, "Player_pony_swim%(6)", "!sitting_player_2", 0],     //Ex1(水着)
    [6, 0, "Player_pony_negligee%(6)", "!sitting_player_1", 3], //Ex2(寝間着)
    [7, 0, "Player_pony_mnzk%(6)", "!sitting_player_2", 2],     //Ex3(民族)
    [8, 0, "Player_pony_bunny%(6)", "!sitting_player_1", 6],    //Ex4(バニー)
    [9, 0, "Player_robe%(6)", "!sitting_player_1", 5],          //Ex5(ローブ)
    [0, 1, "Player_long_Seifuku%(6)", "!sitting_player_1", 1],  
    [1, 1, "Player%(6)", "!sitting_player_3", 3],               
    [2, 1, "Player_long_custom%(6)", "!sitting_player_3", 1],   
    [3, 1, "Player_long_shitagi%(6)", "!sitting_player_2", 7],  
    [4, 1, "Player_long_hadaka%(6)", "!sitting_player_2", 5],   
    [5, 1, "Player_long_swim%(6)", "!sitting_player_2", 1],     //Ex1(水着)
    [6, 1, "Player_long_negligee%(6)", "!sitting_player_1", 4], //Ex2(寝間着)
    [7, 1, "Player_long_mnzk%(6)", "!sitting_player_2", 3],     //Ex3(民族)
    [8, 1, "Player_long_bunny%(6)", "!sitting_player_1", 7],    //Ex4(バニー)
    [9, 1, "Player_robe%(6)", "!sitting_player_1", 5],          //Ex5(ローブ)
    [99, 99, ""] 
];
const SW_衣装変更禁止 = 33;
const SW_下着ON = 56;
const SW_メニュー全裸選択 = 1380;
let Bef_VN_ExIsyoNo_Value = -1;
let EquiqAutoBackLog_NUpdateSc = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    EquiqAutoBackLog_NUpdateSc.call(this);
    if (Bef_VN_ExIsyoNo_Value != $gameVariables.value(VN_ExIsyoNo)) {
        if ($gameVariables.value(VN_ExIsyoNo) > 0 && Bef_VN_ExIsyoNo_Value == 0) {
            let backLogStr = "";
            switch ($gameVariables.value(VN_ExIsyoNo)) {
                case 1:
                    backLogStr = "水着の着替えが可能になりました。";
                    break;
                case 2:
                    backLogStr = "寝間着の着替えが可能になりました。";
                    break;
                case 3:
                    backLogStr = "竜人の衣の着替えが可能になりました。";
                    break;
                case 4:
                    backLogStr = "バニーの着替えが可能になりました。";
                    break;
            }
            if (_LoadAfterFrame <= 0) {
                this.BLogAdd(180 , SCol.Yel + backLogStr); 
            }
        }
        Bef_VN_ExIsyoNo_Value = $gameVariables.value(VN_ExIsyoNo);
    }
}
let equipIsyoNo = -1;
let equipKamiNo = -1; 
const EnMenuEquipMode = {
    Top: 0,
    Isyo: 1,
    Kami: 2,
    Syogo: 3
}
let menuEquipMode = EnMenuEquipMode.Top; 
let equipExIsyoNo = 0 
let menuEquipBaseFlame = 0;
let EquipSave_SystemInitialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    EquipSave_SystemInitialize.call(this);
    this._NowIsyoNo = 0; 
    this._NowExIsyoNo = -1; 
};
Game_Interpreter.prototype.MenuEquipView = function (fadeInFlg) {
    fadeInFlg = typeof fadeInFlg !== 'undefined' ? fadeInFlg : false;
    ViewSpriteArr_Reset();
    let setOpacity = 255;
    MenuEquipFlame = 0;
    if (fadeInFlg) {
        menuEquipBaseFlame = 0;
        equipExIsyoNo = $gameVariables.value(VN_ExIsyoNo); 
        menuEquipMode = EnMenuEquipMode.Top;
        setOpacity = 0;
        equipIsyoNo = -1;
        equipKamiNo = -1; 
    }
    this.SetSprite(PNo_EBase, MenuUIPath + "Equip/EBase", 213, 177, setOpacity);
    if ($gameSystem.Gob奴隷Mode == false) {
        this.SetSprite(PNo_ESyogBtn, MenuUIPath + "Equip/E_SyogoBtn", 723, 569, setOpacity);
    }
    this.SetSprite(PNo_EIsyoBtn, MenuUIPath + "Equip/E_IsyoBtn1", 700, 313, setOpacity);
    MenuEquipIsyoSet();
    equipIsyoNo = menuEquipIsyoSelectNo; 
    if ($gameSwitches.value(Sw_BtlStartAcs)) { 
        this.SetSprite(PNo_IsyoWaku, MenuUIPath + "Equip/E_ISyoAb", 703, 355, setOpacity);
        this.SpriteCngColor(PNo_EIsyoBtn, [-50, -50, -50, 0]);
    } else {
        this.SetSprite(PNo_IsyoWaku, MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(menuEquipIsyoSelectNo) + "b", 703, 355, setOpacity);
    }
    if ($gameSwitches.value(SW_衣装変更禁止)) {
        this.SetSprite(PN_IsyoKinsi, MenuUIPath + "Equip/PN_IsyoKinsi", 0, 0, setOpacity);
    }
    this.SetSprite(PNo_KamiBtn, MenuUIPath + "Equip/E_IsyoBtn2", 310, 243, setOpacity);
    MenuEquipKamiSet();
    equipKamiNo = menuEquipKamiSelectNo; 
    if ($gameSwitches.value(Sw_BtlStartAcs)) { 
        this.SetSprite(PNo_KamiWaku, MenuUIPath + "Equip/E_KamiA", 312, 285, setOpacity);
        this.SpriteCngColor(PNo_KamiBtn, [-50, -50, -50, 0]);
    } else {
        this.SetSprite(PNo_KamiWaku, MenuUIPath + "Equip/E_Kami" + (menuEquipKamiSelectNo + 1) + "b", 312, 285, setOpacity);
    }
    this.SpineView(PNo_SpineA, "Romasha", "Idl", true, 553, 417, setOpacity, plSpineScaleX, plSpineScaleY);
    this.RomaSpineSkinSet(); 
    if ($gameSwitches.value(Sw_BtlStartAcs)) { 
        this.SpineCngAccess();
    }
    for (let i = 0; i <= $dataArmors.length - 1; i++) {
        if ($gameActors.actor(1).hasArmor($dataArmors[i + 1])) { 
            this.MenuEquip_SyogoTxtView(i + 1); 
        }
    }
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        switch (ViewSpriteArr[i]) {
            case PNo_SpineA:
                this.MovePict(ViewSpriteArr[i], 543, 424, 10, 255, 85, 85);
                break;
            default:
                this.MoveSprite(ViewSpriteArr[i], true, true, 10);
        }
    }
}
let MenuEquipIsyoSet = function () {
    menuEquipIsyoSelectNo = -1;
    if ($gameSwitches.value(SW_MizugiON)) menuEquipIsyoSelectNo = 5;
    if ($gameSwitches.value(SW_NemakiON)) menuEquipIsyoSelectNo = 5;
    if ($gameSwitches.value(SW_MinzokuON)) menuEquipIsyoSelectNo = 5;
    if ($gameSwitches.value(SW_BaniON)) menuEquipIsyoSelectNo = 5;
    if (menuEquipIsyoSelectNo == 5) return;
    switch ($gameVariables.value(VN_TL2DKigae)) {
        case -1: 
            menuEquipIsyoSelectNo = 3;
            if ($gameSwitches.value(SW_BuraOFF) && $gameSwitches.value(SW_PantuOFF)) menuEquipIsyoSelectNo = 4;
            break;
        case 0: 
            menuEquipIsyoSelectNo = 0;
            $gameSystem._NowIsyoNo = 0;
            break;
        case 1: 
            menuEquipIsyoSelectNo = 1;
            $gameSystem._NowIsyoNo = 1;
            break;
        case 2: 
            menuEquipIsyoSelectNo = 2;
            $gameSystem._NowIsyoNo = 2;
            break;
        default: 
            break;
    }
}
let MenuEquipKamiSet = function () {
    switch ($gameVariables.value(VN_TL2DKami)) { 
        case 0: 
            menuEquipKamiSelectNo = menuEquipNowKamiNo = 0;
            break;
        case 30: 
            menuEquipKamiSelectNo = menuEquipNowKamiNo = 1;
            break;
    }
}
let GetIsyoStr_IsyoNo = function (IsyoNo) {
    if (IsyoNo != 5) {
        return (IsyoNo + 1);
    }
    return "Ex" + equipExIsyoNo;
}
let MenuEquipFlame = 0; 
let MenuEquipWaitFlame = 0;
Game_Interpreter.prototype.MenuEquipUpdate = function () {
    if (MenuEquipWaitFlame > 0) {
        MenuEquipWaitFlame--;
        return;
    }
    MenuEquipFlame++;
    switch (menuEquipMode) {
        case 0:
            this.MenuEquip_TopUpdate();
            break;
        case 1:
            this.MenuEquip_IsyoUpdate(); 
            break;
        case 2:
            this.MenuEquip_KamiUpdate(); 
            break;
        case 3:
            this.MenuEquip_SyogoUpdate(); 
            break;
    }
    if (menuEquipBaseFlame == 5) this.MenuEquipView();
    menuEquipBaseFlame++;
}
Game_Interpreter.prototype.MenuEquip_TopUpdate = function () {
    MenuCngOkFlg = true;
    let ckPicArr = [PNo_ESyogBtn];
    if (!$gameSwitches.value(Sw_BtlStartAcs)) { 
        ckPicArr.push(PNo_EIsyoBtn, PNo_KamiBtn);
    }
    let overPicNo = overPointerSpCkArr(ckPicArr);
    this.SpriteCngColorArr(ckPicArr);
    if (overPicNo != -1) this.SpriteCngColor(overPicNo, [100, 100, 100, 0]);
    switch (overPicNo) {
        case PNo_EIsyoBtn: 
            if (TouchInput.isTriggered() && !$gameSwitches.value(SW_衣装変更禁止)) {
                this.DelSprite(PNo_IsyoWaku);
                SoundManager.playOk(); 
                MenuEquipIsyoSet();   
                menuEquipMode = EnMenuEquipMode.Isyo;
                MenuEquipWaitFlame = 3;
                Menu_EditLayer = 2;
                this.SpriteCngColor(PNo_EIsyoBtn); 
                this.MenuEquip_IsyoView(true);
            }
            break;
        case PNo_KamiBtn: 
            if (TouchInput.isTriggered() && !$gameSwitches.value(SW_衣装変更禁止)) {
                this.DelSprite(PNo_KamiWaku);
                SoundManager.playOk(); 
                MenuEquipKamiSet();   
                menuEquipMode = EnMenuEquipMode.Kami;
                MenuEquipWaitFlame = 3;
                Menu_EditLayer = 2;
                this.SpriteCngColor(PNo_KamiBtn); 
                this.MenuEquip_KamiView(true);
            }
            break;
        case PNo_ESyogBtn: 
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                menuEquipMode = EnMenuEquipMode.Syogo;
                MenuEquipWaitFlame = 3;
                Menu_EditLayer = 2;
                this.MenuEquip_SyogoView(true);
                this.SpriteCngColor(PNo_ESyogBtn); 
            }
            break;
    }
}
let menuEquipCkPicArr = [];
let menuEquipDelPicArr = [];
let menuEquipIsyoBasePos = new Pos2D(578, 347);
let menuEquipIsyoSelectNo = 0; 
Game_Interpreter.prototype.MenuEquip_IsyoView = function (fadeInFlg) {
    fadeInFlg = typeof fadeInFlg !== 'undefined' ? fadeInFlg : false;
    ViewSpriteArr_Reset();
    MenuEquipFlame = 0;
    menuEquipCkPicArr = []; 
    menuEquipDelPicArr = [PN_IsyoBase, PN_IsyoSetu]; 
    menuEquipCkPicArr.push(PNo_EIsyoBtn, PNo_KamiBtn); 
    if (menuEquipIsyoSelectNo != $gameSystem._NowIsyoNo)
        $gameSystem._NowIsyoNo = menuEquipIsyoSelectNo;
    let setOpacity = 255;
    if (fadeInFlg) {
        setOpacity = 0;
    }
    this.SetSprite(PN_IsyoBase, MenuUIPath + "Equip/E_ISyoWin", menuEquipIsyoBasePos._x, menuEquipIsyoBasePos._y, setOpacity);
    let setX = menuEquipIsyoBasePos._x + 73;
    let setY = menuEquipIsyoBasePos._y + 76;
    for (let i = 0; i <= 6 - 1; i++) {
        if (i != 5) {
            if ($gameSwitches.value(SW_IsyoOn + i)) { 
                menuEquipCkPicArr.push(PN_IsyoBtn + i);
                if (menuEquipIsyoSelectNo == i) { 
                    this.SetSpriteC(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo" + (i + 1) + "b", setX + (82 * i), setY - 10, setOpacity);
                    this.SetSprite(PN_IsyoSetu, MenuUIPath + "Equip/E_ISyo" + (i + 1) + "_setu", menuEquipIsyoBasePos._x, menuEquipIsyoBasePos._y, setOpacity);
                    setX += 11;
                    $gameSystem._NowIsyoNo = i; 
                } else {
                    this.SetSpriteC(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo" + (i + 1), setX + (82 * i), setY, setOpacity, 80, 80);
                }
            } else {
                if ($gameSystem._GrayKigae[i]) {
                    this.SetSpriteC(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo" + (i + 1) + "c", setX + (82 * i), setY, setOpacity, 80, 80);
                } else {
                    this.SetSpriteC(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo0", setX + (82 * i), setY, setOpacity, 80, 80);
                }
            }
        } else {
            if (equipExIsyoNo != 0) {
                menuEquipCkPicArr.push(PN_IsyoBtn + i);
                this.SetSpriteC(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(i), setX + (82 * i), setY, setOpacity, 80, 80);
                this.SetSprite(PN_IsyoSetu, MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(i) + "_setu", menuEquipIsyoBasePos._x, menuEquipIsyoBasePos._y, setOpacity);
            } else {
                this.SetSpriteC(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo0", setX + (82 * i), setY, setOpacity, 80, 80);
            }
        }
        menuEquipDelPicArr.push(PN_IsyoBtn + i); 
    }
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255, true, true);
    }
}
let EM1CngFlame = 0;
Game_Interpreter.prototype.MenuEquip_IsyoUpdate = function () {
    if (EM1CngFlame > 0) {
        EM1CngFlame--;
        return;
    }
    let overPicNo = overPointerSpCkArr(menuEquipCkPicArr);
    this.SpriteCngColorArr(menuEquipCkPicArr);
    let setX = menuEquipIsyoBasePos._x + 73;
    let setY = menuEquipIsyoBasePos._y + 76;
    if (overPicNo != -1) {
        switch (overPicNo) {
            case PNo_EIsyoBtn:
                this.SpriteCngColor(PNo_EIsyoBtn, [100, 100, 100, 0]);
                if (TouchInput.isTriggered()) {
                    SoundManager.playCancel(); 
                    this.DelSpriteArr(menuEquipDelPicArr);
                    menuEquipMode = EnMenuEquipMode.Top;
                    MenuEquipWaitFlame = 3;
                    Menu_EditLayer = 1;
                    this.MenuEquipView();
                }
                break;
            case PNo_KamiBtn:
                this.SpriteCngColor(PNo_KamiBtn, [100, 100, 100, 0]);
                if (TouchInput.isTriggered()) {
                    SoundManager.playOk(); 
                    this.DelSpriteArr(menuEquipDelPicArr);
                    MenuEquipKamiSet();   
                    menuEquipMode = EnMenuEquipMode.Kami;
                    MenuEquipWaitFlame = 3;
                    this.MenuEquipView();
                    this.DelSprite(PNo_KamiWaku);
                    this.MenuEquip_KamiView(true);
                }
                break;
            default: 
                let isyoSelectNo = overPicNo - PN_IsyoBtn;
                menuEquipIsyoSelectNo = isyoSelectNo;
                this.CngSprite(PN_IsyoSetu, MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(menuEquipIsyoSelectNo) + "_setu");
                if (TouchInput.isTriggered()) { 
                    EM1CngFlame = 5;
                    for (let i = 0; i <= 6 - 1; i++) {
                        if ($gameSwitches.value(SW_IsyoOn + i)) {
                            if (isyoSelectNo == i) { 
                                let setIsyoBtnPicPath = MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(i) + "b";
                                this.CngSprite(PN_IsyoBtn + i, setIsyoBtnPicPath);
                                if ($gameSystem._NowIsyoNo == i && $gameSystem._NowIsyoNo == 5) {
                                    if ($gameSystem._NowExIsyoNo == undefined) $gameSystem._NowExIsyoNo = -1;
                                    if (equipExIsyoNo != $gameSystem._NowExIsyoNo) $gameSystem._NowIsyoNo = -99;
                                }
                                if ($gameSystem._NowIsyoNo != i || $gameSystem._NowIsyoNo == 5) { 
                                    Menu着替え実行Flg = true;
                                    SoundManager.playOk(); 
                                    $gameSystem._NowIsyoNo = i;
                                    equipIsyoNo = $gameSystem._NowIsyoNo; 
                                    $gameSwitches.setValue(SW_MizugiON, false);
                                    $gameSwitches.setValue(SW_NemakiON, false);
                                    $gameSwitches.setValue(SW_MinzokuON, false);
                                    $gameSwitches.setValue(SW_BaniON, false);
                                    if ($gameSystem._NowIsyoNo + 1 != 6) $gameSystem._NowExIsyoNo = -1;
                                    $gameSwitches.setValue(SW_メニュー全裸選択 , false);
                                    switch ($gameSystem._NowIsyoNo + 1) {
                                        case 1: 
                                            $gameVariables.setValue(VN_TL2DKigae, 0);
                                            MenuEquip_下着Setting();
                                            break;
                                        case 2: 
                                            $gameVariables.setValue(VN_TL2DKigae, 1);
                                            MenuEquip_下着Setting();
                                            break;
                                        case 3: 
                                            $gameVariables.setValue(VN_TL2DKigae, 2);
                                            MenuEquip_下着Setting();
                                            break;
                                        case 4: 
                                            $gameSwitches.setValue(SW_下着ON, true);
                                            $gameVariables.setValue(VN_TL2DKigae, -1);
                                            MenuEquip_下着Setting();
                                            $gameSystem._NowIsyoNo = 3;
                                            break;
                                        case 5: 
                                            $gameSwitches.setValue(SW_メニュー全裸選択 , true)
                                            $gameSwitches.setValue(SW_下着ON, false);
                                            MenuEquip_ブラジャーOffAndItemGet();
                                            MenuEquip_パンツOffAndItemGet();
                                            $gameVariables.setValue(VN_TL2DKigae, -1);
                                            $gameSystem._NowIsyoNo = 4;
                                            break;
                                        case 6: 
                                            $gameSwitches.setValue(SW_MizugiON, false);
                                            $gameSwitches.setValue(SW_NemakiON, false);
                                            $gameSwitches.setValue(SW_MinzokuON, false);
                                            $gameSwitches.setValue(SW_BaniON, false);
                                            equipIsyoNo = 4 + equipExIsyoNo; 
                                            switch (equipExIsyoNo) {
                                                case 1: 
                                                    MenuEquip_ブラジャーOffAndItemGet();
                                                    MenuEquip_パンツOffAndItemGet();
                                                    $gameSwitches.setValue(SW_MizugiON, true);
                                                    $gameSystem._NowExIsyoNo = 1;
                                                    break;
                                                case 2: 
                                                    MenuEquip_ブラジャーOffAndItemGet();
                                                    $gameSwitches.setValue(SW_NemakiON, true);
                                                    $gameSystem._NowExIsyoNo = 2;
                                                    break;
                                                case 3: 
                                                    MenuEquip_ブラジャーOffAndItemGet();
                                                    $gameSwitches.setValue(SW_MinzokuON, true);
                                                    $gameSystem._NowExIsyoNo = 3;
                                                    break;
                                                case 4: 
                                                    MenuEquip_ブラジャーOffAndItemGet();
                                                    MenuEquip_パンツOffAndItemGet();
                                                    $gameSwitches.setValue(SW_BaniON, true);
                                                    $gameSystem._NowExIsyoNo = 4;
                                                    break;
                                            }
                                            $gameVariables.setValue(VN_TL2DKigae, -1);
                                            break;
                                    }
                                    L2dFadeMdl("romasha_talk", "rightin", 15); 
                                    Live2DParamSetCmnEventStart("romasha_talk");
                                    //this.RomaSpineSkinSet(); //Spineスキンセット
                                    //this.SpineView(PNo_SpineA, "Romasha", "Idl", true, 553, 417, 255, plSpineScaleX, plSpineScaleY);
                                    RomaSpineSkinSet_WaitFrame = 2;
                                    this.MenuEquip_DotUpdate(equipIsyoNo, equipKamiNo); 
                                    MenuEquipIsyoSet();
                                }
                            } else {
                                this.CngSprite(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(i));
                            }
                        } else {
                            if ($gameSystem._GrayKigae[i]) {
                                this.CngSprite(PN_IsyoBtn + i, MenuUIPath + "Equip/E_ISyo" + GetIsyoStr_IsyoNo(i) + "c");
                            }
                        }
                    }
                }
                break;
        }
        for (let i = 0; i <= 6 - 1; i++) {
            if (menuEquipIsyoSelectNo == i) {
                if (menuEquipIsyoSelectNo != 0) setX += 11;
                this.MoveSprite(PN_IsyoBtn + menuEquipIsyoSelectNo, setX + (82 * menuEquipIsyoSelectNo), setY - 10, 5, 255);
                setX += 11;
            } else {
                this.MoveSprite(PN_IsyoBtn + i, setX + (82 * i), setY, 5, 255, 80, 80);
            }
        }
    }
    if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
        this.DelSpriteArr(menuEquipDelPicArr);
        menuEquipMode = EnMenuEquipMode.Top;
        this.MenuEquipView();
    }
}
let MenuEquip_下着Setting = function () {
    // if ($gameSwitches.value(SW_BuraOFF) &&
    //     $gameParty.hasItem($dataItems[ItN_ブラ]) > 0) {
    //     $gameParty.loseItem($dataItems[ItN_ブラ], 1)
    //     $gameSwitches.setValue(SW_BuraOFF, false);
    // if ($gameSwitches.value(SW_PantuOFF) &&
    //     $gameParty.hasItem($dataItems[ItN_パンツ]) > 0) {
    //     $gameParty.loseItem($dataItems[ItN_パンツ], 1)
    //     $gameSwitches.setValue(SW_PantuOFF, false);
}
let MenuEquip_ブラジャーOffAndItemGet = function () {
    // if (!$gameSwitches.value(SW_BuraOFF)) { //現状のブラの表示状態確認
    //     $gameSwitches.setValue(SW_BuraOFF, true);
    //     $gameParty.gainItem($dataItems[ItN_ブラ], 1); //ブラを所持品に追加
}
let MenuEquip_パンツOffAndItemGet = function () {
    // if (!$gameSwitches.value(SW_PantuOFF)) { //現状のパンツの表示状態確認
    //     $gameSwitches.setValue(SW_PantuOFF, true);
    //     $gameParty.gainItem($dataItems[ItN_パンツ], 1); //パンツを所持品に追加
}
let menuEquipKamiPicArr = [];
let menuEquipKamiDelPicArr = [];
let menuEquipKamiBasePos = new Pos2D(248, 283);
let menuEquipKamiSelectNo = 0; 
let menuEquipNowKamiNo = -1; 
Game_Interpreter.prototype.MenuEquip_KamiView = function (fadeInFlg) {
    fadeInFlg = typeof fadeInFlg !== 'undefined' ? fadeInFlg : false;
    ViewSpriteArr_Reset();
    MenuEquipFlame = 0;
    menuEquipKamiPicArr = []; 
    menuEquipKamiDelPicArr = [PNo_KamiBtn]; 
    menuEquipKamiPicArr.push(PNo_EIsyoBtn, PNo_KamiBtn); 
    let setOpacity = 255;
    if (fadeInFlg) {
        setOpacity = 0;
    }
    this.SetSprite(PN_KamiBase, MenuUIPath + "Equip/E_KamiWin", menuEquipKamiBasePos._x, menuEquipKamiBasePos._y, setOpacity);
    let setX = menuEquipKamiBasePos._x + 73;
    let setY = menuEquipKamiBasePos._y + 77;
    for (let _c = 0; _c <= 2 - 1; _c++) {
        if (menuEquipKamiSelectNo == _c) { 
            if (menuEquipKamiSelectNo != 0) setX += 11;
            this.SetSpriteC(PN_KamiBtn + _c, MenuUIPath + "Equip/E_Kami" + (_c + 1) + "b", setX + (82 * _c), setY - 10, setOpacity);
            setX += 11;
            menuEquipKamiPicArr.push(PN_KamiBtn + _c);
        } else {
            if ($gameSwitches.value(SW_KamiOn + _c)) {
                this.SetSpriteC(PN_KamiBtn + _c, MenuUIPath + "Equip/E_Kami" + (_c + 1), setX + (82 * _c), setY, setOpacity, 80, 80);
                menuEquipKamiPicArr.push(PN_KamiBtn + _c);
            } else {
                if ($gameSystem._GrayKami[_c]) {
                    this.SetSpriteC(PN_KamiBtn + _c, MenuUIPath + "Equip/E_Kami" + (_c + 1) + "c", setX + (82 * _c), setY, setOpacity, 80, 80);
                } else {
                    this.SetSpriteC(PN_KamiBtn + _c, MenuUIPath + "Equip/E_Kami0", setX + (82 * _c), setY, setOpacity, 80, 80);
                }
            }
        }
    }
    menuEquipKamiDelPicArr = ViewSpriteArr.slice();
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255, true, true);
    }
}
Game_Interpreter.prototype.MenuEquip_KamiUpdate = function () {
    let overPicNo = overPointerSpCkArr(menuEquipKamiPicArr);
    this.SpriteCngColorArr(menuEquipKamiPicArr);
    let setX = menuEquipKamiBasePos._x + 73;
    let setY = menuEquipKamiBasePos._y + 77;
    if (overPicNo != -1) {
        switch (overPicNo) {
            case PNo_EIsyoBtn: 
                this.SpriteCngColor(PNo_EIsyoBtn, [100, 100, 100, 0]);
                if (TouchInput.isTriggered()) {
                    SoundManager.playOk(); 
                    this.DelSpriteArr(menuEquipKamiDelPicArr);
                    MenuEquipIsyoSet();   
                    menuEquipMode = EnMenuEquipMode.Isyo;
                    MenuEquipWaitFlame = 3;
                    this.MenuEquipView();
                    this.DelSprite(PNo_IsyoWaku);
                    this.MenuEquip_IsyoView(true);
                }
                break;
            case PNo_KamiBtn: 
                this.SpriteCngColor(PNo_KamiBtn, [100, 100, 100, 0]);
                if (TouchInput.isTriggered()) {
                    SoundManager.playCancel(); 
                    this.DelSpriteArr(menuEquipKamiDelPicArr);
                    menuEquipMode = EnMenuEquipMode.Top;
                    MenuEquipWaitFlame = 3;
                    Menu_EditLayer = 1;
                    this.MenuEquipView();
                }
                break;
            default: 
                let kamiSelectNo = overPicNo - PN_KamiBtn;
                menuEquipKamiSelectNo = kamiSelectNo;
                if (TouchInput.isTriggered()) { 
                    for (let i = 0; i <= 2 - 1; i++) {
                        if (kamiSelectNo == i) {
                            this.CngSprite(PN_KamiBtn + i, MenuUIPath + "Equip/E_Kami" + (i + 1) + "b");
                            if (menuEquipNowKamiNo != i) {
                                SoundManager.playOk(); 
                                menuEquipNowKamiNo = i;
                                equipKamiNo = menuEquipNowKamiNo; 
                                switch (menuEquipNowKamiNo) { 
                                    case 0: 
                                        $gameVariables.setValue(VN_TL2DKami, 0);
                                        menuEquipKamiSelectNo = 0;
                                        break;
                                    case 1: 
                                        $gameVariables.setValue(VN_TL2DKami, 30);
                                        menuEquipKamiSelectNo = 1;
                                        break;
                                }
                                L2dFadeMdl("romasha_talk", "rightin", 15); 
                                Live2DParamSetCmnEventStart("romasha_talk");
                                //this.RomaSpineSkinSet(); //Spineスキンセット
                                //this.SpineView(PNo_SpineA, "Romasha", "Idl", true, 553, 417, 255, plSpineScaleX, plSpineScaleY);
                                RomaSpineSkinSet_WaitFrame = 2;
                                equipIsyoNo = Equip_SWtoIsyoNoSetting(equipIsyoNo); 
                                this.MenuEquip_DotUpdate(equipIsyoNo, equipKamiNo); 
                            }
                        } else {
                            if ($gameSwitches.value(SW_KamiOn + i)) {
                                this.CngSprite(PN_KamiBtn + i, MenuUIPath + "Equip/E_Kami" + (i + 1));
                            } else {
                                if ($gameSystem._GrayKami[i]) {
                                    this.CngSprite(PN_KamiBtn + i, MenuUIPath + "Equip/E_Kami" + (i + 1) + "c");
                                } else {
                                    this.CngSprite(PN_KamiBtn + i, MenuUIPath + "Equip/E_Kami0");
                                }
                            }
                        }
                    }
                }
                break;
        }
    }
    for (let i = 0; i <= 2 - 1; i++) {
        if (menuEquipKamiSelectNo == i) {
            if (menuEquipKamiSelectNo != 0) setX += 11;
            this.MoveSprite(PN_KamiBtn + menuEquipKamiSelectNo, setX + (82 * menuEquipKamiSelectNo), setY - 10, 5, 255);
            setX += 11;
        } else {
            this.MoveSprite(PN_KamiBtn + i, setX + (82 * i), setY, 5, 255, 80, 80);
        }
    }
    if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
        this.DelSpriteArr(menuEquipKamiDelPicArr);
        menuEquipMode = EnMenuEquipMode.Top;
        this.MenuEquipView();
    }
}
let BメニューDotUpdateFlg = false;
Game_Interpreter.prototype.MenuEquip_DotUpdate = function (isyoNo, kamiNo) {
    for (let i = 0; i <= IsyoDotSet.length - 1; i++) {
        if (IsyoDotSet[i][0] == isyoNo && IsyoDotSet[i][1] == kamiNo) {
            if ($gameSwitches.value(SW_L2Dローブ)) {
                this.SetPlayerImg("Player_robe%(6)", 1); 
            } else {
                this.SetPlayerImg(IsyoDotSet[i][2], 1); 
            }
        }
    }
    BメニューDotUpdateFlg = true; 
}
Game_Interpreter.prototype.MenuドットUpdate対応 = function () {
    if (BメニューDotUpdateFlg) {
        BメニューDotUpdateFlg = false;
        this.SetCmnEvent(CN_ロマキャラチップ変更);
    }
}
let MenuDotSetting_Initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    MenuDotSetting_Initialize.call(this);
    this._SittingFlg = false; 
};
Game_Interpreter.prototype.Equip_DotSetting = function (_座りFlg, _向き) {
    _座りFlg = typeof _座りFlg !== 'undefined' ? _座りFlg : false;
    _向き = typeof _向き !== 'undefined' ? _向き : 4;
    let isyoValue = $gameVariables.value(VN_TL2DKigae);
    let kamiValue = $gameVariables.value(VN_TL2DKami)
    let isyoNo = isyoValue;
    switch (isyoValue) {
        case -1: 
            if ($gameSwitches.value(SW_BuraOFF) && $gameSwitches.value(SW_PantuOFF)) {
                isyoNo = 4;
            } else {
                isyoNo = 3;
            }
            break;
    }
    isyoNo = Equip_SWtoIsyoNoSetting(isyoNo); 
    let kamiNo = 0;
    switch (kamiValue) {
        case 0:
            kamiNo = 0;
            break;
        case 30:
            kamiNo = 1;
            break;
    }
    if (_座りFlg) {
        $gameSystem._SittingFlg = true;
        this.PlayerDotSetting(isyoNo, kamiNo, _向き);
    } else {
        $gameSystem._SittingFlg = false;
        this.MenuEquip_DotUpdate(isyoNo, kamiNo);
    }
}
let Equip_SWtoIsyoNoSetting = function (isyoNo) {
    if ($gameSwitches.value(SW_MizugiON)) isyoNo = 5; 
    if ($gameSwitches.value(SW_NemakiON)) isyoNo = 6; 
    if ($gameSwitches.value(SW_MinzokuON)) isyoNo = 7; 
    if ($gameSwitches.value(SW_BaniON)) isyoNo = 8; 
    if ($gameSwitches.value(SW_RobuON)) isyoNo = 9; //Ex5(ローブ)
    return isyoNo;
}
Game_Interpreter.prototype.PlayerDotSetting = function (_IsyoNo, _KamiNo, _向き) {
    for (let i = 0; i <= IsyoDotSet.length - 1; i++) {
        if (IsyoDotSet[i][0] == _IsyoNo && IsyoDotSet[i][1] == _KamiNo) {
            this.SetPlayerImg(IsyoDotSet[i][3], IsyoDotSet[i][4]); 
            $gamePlayer._direction = _向き;
        }
    }
}
let menuSyogoBasePositon = new Pos2D(215, 165);
let menuSyogoPicArr = []; 
let equipSyogoNo = -1; 
let menuSyogoDataFlg = false; 
const Equip隠し称号開始No = 21;
Game_Interpreter.prototype.MenuEquip_SyogoView = function (fadeInFlg) {
    fadeInFlg = typeof fadeInFlg !== 'undefined' ? fadeInFlg : false;
    befSyogoSelectNo = -1;
    let setOpacity = 255;
    if (fadeInFlg) { 
        setOpacity = 0;
        this.SetSprite(PN_SyBlack, MenuUIPath + "Equip/Syogo/SyoBlack", 0, 0, 0); 
        this.MoveSprite(PN_SyBlack, true, true, 10, 170);
    }
    ViewSpriteArr_Reset();
    this.SetSprite(PN_SyoBase, MenuUIPath + "Equip/Syogo/SyogoBase", menuSyogoBasePositon._x, menuSyogoBasePositon._y, setOpacity);
    menuSyogoPicArr = [];
    let kakusiGetFlg = false;
    for (let i = Equip隠し称号開始No; i < 24; i++) {
        if ($gameParty.numItems($dataArmors[i + 1]) > 0) {
            kakusiGetFlg = true; break;
        }
    }
    var loopCnt = 24; 
    if (!kakusiGetFlg) loopCnt = Equip隠し称号開始No - 1;
    if ($gameSwitches.value(SW_エンディング見た)) loopCnt++;
    for (let i = 0; i < loopCnt; i++) {
        let equipFlg = false;
        let spriteStr = MenuUIPath + "Equip/Syogo/Syogo"
        if ($gameParty.numItems($dataArmors[i + 1]) > 0) {
            spriteStr += String(i + 1); 
        } else if ($gameActors.actor(1).hasArmor($dataArmors[i + 1])) {
            spriteStr += String(i + 1); 
            equipSyogoNo = i + 1;
            equipFlg = true;
        } else {
            spriteStr += "0"; 
        }
        let setX = 0;
        let setY = 0;
        let btnPosL = new Pos2D(menuSyogoBasePositon._x + 131, menuSyogoBasePositon._y + 111);
        if (i <= 5) { 
            let spaceY = i * 52;
            setX = btnPosL._x;
            setY = btnPosL._y + spaceY;
        }
        let btnPosC = new Pos2D(btnPosL._x + 207, btnPosL._y - 24);
        if (i > 5 && i <= 12) { 
            let spaceY = (i - 6) * 52;
            setX = btnPosC._x;
            setY = btnPosC._y + spaceY;
        }
        let btnPosR = new Pos2D(btnPosC._x + 207, btnPosC._y + 24);
        if (i > 12) { 
            let spaceY = (i - 13) * 52;
            setX = btnPosR._x;
            setY = btnPosR._y + spaceY;
        }
        if (i == 20) { 
            let spaceY = -1 * 52;
            setX = btnPosC._x;
            setY = btnPosC._y + spaceY;
        }
        if (i == 21) { 
            let spaceY = 6 * 52;
            setX = btnPosL._x;
            setY = btnPosL._y + spaceY;
        }
        if (i == 22) { 
            let spaceY = -1 * 52;
            setX = btnPosR._x;
            setY = btnPosR._y + spaceY;
        }
        if (i == 23) { 
            let spaceY = -1 * 52;
            setX = btnPosL._x;
            setY = btnPosL._y + spaceY;
        }
        this.SetSpriteC(PN_SyoBtn + i, spriteStr, setX, setY, setOpacity);
        menuSyogoPicArr.push(PN_SyoBtn + i);
        if (equipFlg) {
            this.SetSpriteC(PN_SyoWaku, MenuUIPath + "Equip/Syogo/SyoWaku", setX, setY, setOpacity);
        }
    }
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) { 
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255, true, true);
    }
}
const CN_SyogoSoubi = 447;
let befSyogoSelectNo = -1;
Game_Interpreter.prototype.MenuEquip_SyogoUpdate = function () {
    MenuCngOkFlg = false; 
    let backFlg = false; 
    let overPicNo = overPointerSpCkArr(menuSyogoPicArr);
    for (let i = 0; i <= menuSyogoPicArr.length - 1; i++) {
        this.SpriteCngColor(menuSyogoPicArr[i]);
    }
    //this.DelSpriteSpan(PNo_ESyogTxt + 1, PNo_ESyogTxt + 3); //説明文削除
    if (overPicNo != -1) {
        this.SpriteCngColor(overPicNo, [100, 100, 100, 0]);
        let selectNo = overPicNo - PN_SyoBtn + 1;
        if ($gameParty.numItems($dataArmors[selectNo]) > 0 || $gameActors.actor(1).hasArmor($dataArmors[selectNo])) {
            this.MenuEquip_SyogoTxtView(selectNo); 
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                equipSyogoNo = selectNo; 
                $gameActors.actor(1).changeEquipById(4, equipSyogoNo); //装備変更(身体の装備品が称号)
                this.SetCmnEventSc(CN_SyogoSoubi); 
                backFlg = true;
                Menu_EditLayer = 1; 
                menuDataFlame = 0; 
                MainMenuData_TopUpdate_OffFlame = 2;
            }
        } else {
            if (befSyogoSelectNo != selectNo) {
                befSyogoSelectNo = selectNo;
                this.DelSpriteSpan(PNo_ESyogTxt + 1, PNo_ESyogTxt + 3); 
                befSyogoSelectNo = -1;
            }
            let hintStr = MetaChecker($dataArmors[selectNo], "Hint");
            var hintOffVn = MetaChecker($dataArmors[selectNo], "HintOffVN" , false);
            if (hintOffVn != false) {
                if ($gameVariables.value(Number(hintOffVn)) <= 0) hintStr = "？？？？";
            } else {
                let CheckKeiken = function (rnkValue) {
                    let _開発Rank = "D"; 
                    if (rnkValue >= $Nupu_PSData.hStData.cRankValue) _開発Rank = "C";
                    if (rnkValue >= $Nupu_PSData.hStData.bRankValue) _開発Rank = "B";
                    if (rnkValue >= $Nupu_PSData.hStData.aRankValue) _開発Rank = "A";
                    return _開発Rank;
                }
                if (hintStr.indexOf("RNK1") != -1) { 
                    let _Keiken = $gameVariables.value(VN_Kaihatu + 0); 
                    hintStr = hintStr.replace("RNK1" , CheckKeiken(_Keiken));
                }
                if (hintStr.indexOf("RNK2") != -1) { 
                    let _Keiken = $gameVariables.value(VN_Kaihatu + 1); 
                    hintStr = hintStr.replace("RNK2" , CheckKeiken(_Keiken));
                }
                if (hintStr.indexOf("RNK3") != -1) { 
                    let _Keiken = $gameVariables.value(VN_Kaihatu + 2); 
                    hintStr = hintStr.replace("RNK3" , CheckKeiken(_Keiken));
                }
                if (hintStr.indexOf("RNK4") != -1) { 
                    let _Keiken = $gameVariables.value(VN_Kaihatu + 3); 
                    hintStr = hintStr.replace("RNK4" , CheckKeiken(_Keiken));
                }
            }
            D_Text_Cng_font = "Makinas"; 
            this.SpriteStr(PNo_ESyogTxt + 1, hintStr, 25, 248, 631, 200);
            D_Text_Cng_font = ""; 
        }
    } else {
        this.MenuEquip_SyogoTxtView(equipSyogoNo); 
    }
    if (Input.isTriggered('menu') || TouchInput.isCancelled() || backFlg) {
        this.MenuEquip_SyogoTxtView(equipSyogoNo); 
        this.Layer1_DelTop(); 
        this.DelSprite(PN_SyBlack); 
        if (menuSyogoDataFlg) {
            menuData_Mode = EnMenuDataMode.Top;
            Menu_EditLayer = 1;
            MenuCngOkFlg = true;
            menuSyogoDataFlg = false;
            this.DelSpriteSpan(PNo_ESyogTxt, PNo_ESyogRTxt + 1);
            this.DelSprite(PN_SyogoStrBack);
            this.MenuDataView();
        } else {
            menuEquipMode = EnMenuEquipMode.Top;
        }
    }
}
Game_Interpreter.prototype.MenuEquip_SyogoTxtView = function (syogoNo) {
    if (syogoNo == -1) {
        befSyogoSelectNo = -1;
        this.DelSpriteSpan(PNo_ESyogTxt, PNo_ESyogRTxt + 1); 
        return;
    }
    D_Text_Cng_font = "Makinas"; 
    if (syogoNo != befSyogoSelectNo) {
        this.DelSpriteSpan(PNo_ESyogTxt + 1, PNo_ESyogTxt + 3); 
        befSyogoSelectNo = syogoNo;
    }
    this.SpriteStrC(PNo_ESyogTxt, $dataArmors[syogoNo].name, 25, 543, 593);
    if ($dataArmors[syogoNo].description != undefined) {
        let setDescText = $dataArmors[syogoNo].description.split('\n');
        for (let i = 0; i <= setDescText.length - 1; i++) {
            setDescText[i] = setDescText[i].replace("<n>","\n");
            if (i == 0) {
                this.SpriteStr(PNo_ESyogTxt + 1, setDescText[i], 22, 238, 632 + (35 * 0));
            } else {
                this.SpriteStr(PNo_ESyogTxt + 1 + i, setDescText[i], 22, 250 + 55, 635 + (35 * i));
            }
        }
    }
    let rericNo = MetaChecker($dataArmors[syogoNo], "Reric", -1);
    if (rericNo != -1) {
        let rericItemData = $dataItems[Number(rericNo)];
        let iconText = " \\I[" + rericItemData.iconIndex + "] " + rericItemData.name;
        let _効果Str = rericItemData.description;
        this.SpriteStr(PNo_ESyogTxt + 2, iconText, 25, 250 + 40, 635 + (35 * 1));
        this.SpriteStr(PNo_ESyogTxt + 3, _効果Str, 22, 261 + 40, 635 + (35 * 2));
    }
    D_Text_Cng_font = ""; 
}
let RomaSpineSkinSet_WaitFrame = 0;
let RomaSpineSkinSet_NUpdateSc = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    RomaSpineSkinSet_NUpdateSc.call(this);
    if (RomaSpineSkinSet_WaitFrame > 0) {
        RomaSpineSkinSet_WaitFrame--;
        if (RomaSpineSkinSet_WaitFrame <= 0) {
            this.RomaSpineSkinSet();
            this.SpineView(PNo_SpineA, "Romasha", "Idl", true, 553, 417, 255, plSpineScaleX, plSpineScaleY);
        }
    }
}
let Menu1Equipゴブリン奴隷_Initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    Menu1Equipゴブリン奴隷_Initialize.call(this);
    this.Gob奴隷Mode = false; 
};
const SyoNo_GoblinSlave = 13; 
Game_Interpreter.prototype.ゴブリン称号固定 = function () {
    let getArmor = $dataArmors[SyoNo_GoblinSlave];
    $gameParty.gainItem(getArmor, 1, false);
    $gameActors.actor(1).changeEquipById(4, SyoNo_GoblinSlave); //装備変更(身体の装備品が称号)
    $gameSystem.Gob奴隷Mode = true;
}
Game_Interpreter.prototype.ゴブリン称号解除 = function () {
    $gameSystem.Gob奴隷Mode = false;
}
Game_Interpreter.prototype.ゴブリン称号装備確認 = function () {
    return $gameActors.actor(1).hasArmor($dataArmors[SyoNo_GoblinSlave]);
}
