// ==EMEVD==
// @docs    er-common.emedf.json
// @compress    DCX_KRAK
// @game    Sekiro
// @string    "N:\\GR\\data\\Param\\event\\common_func.emevd\u0000N:\\GR\\data\\Param\\event\\common_macro.emevd\u0000\u0000\u0000\u0000\u0000\u0000"
// @linked    [0,82]
// @version    3.6.1
// ==/EMEVD==

// コンストラクタ -- constructor
$Event(0, Default, function() {
    RegisterBonfire(13000003, 13001953, 0, 0, 0, 5);
    RegisterBonfire(13000004, 13001954, 0, 0, 0, 5);
    RegisterBonfire(13000005, 13001955, 0, 0, 0, 5);
    RegisterBonfire(13000006, 13001956, 0, 0, 0, 5);
    RegisterBonfire(13000007, 13001957, 0, 0, 0, 5);
    RegisterBonfire(13000008, 13001958, 0, 0, 0, 5);
    RegisterBonfire(13000009, 13001959, 0, 0, 0, 5);
    RegisterBonfire(13000010, 13001960, 0, 0, 0, 5);
    $InitializeEvent(0, 13002805);
    $InitializeCommonEvent(0, 9005810, 13000830, 13000001, 13000951, 13001951, 5);
    $InitializeCommonEvent(0, 9005810, 13000850, 13000002, 13000952, 13001952, 5);
    $InitializeEvent(0, 13002500);
    $InitializeEvent(0, 13002800);
    $InitializeEvent(0, 13002810);
    $InitializeEvent(0, 13002811);
    $InitializeEvent(0, 13002829);
    $InitializeEvent(0, 13002820);
    $InitializeEvent(0, 13002827);
    $InitializeEvent(0, 13002828);
    $InitializeEvent(0, 13002819);
    $InitializeEvent(0, 13002830);
    $InitializeEvent(0, 13002834);
    $InitializeEvent(0, 13002835);
    $InitializeEvent(0, 13002840);
    $InitializeEvent(0, 13002841);
    $InitializeEvent(0, 13002849);
    $InitializeEvent(0, 13002850);
    $InitializeEvent(0, 13002860);
    $InitializeEvent(0, 13002861);
    $InitializeEvent(0, 13002865);
    $InitializeEvent(0, 13002890, 13002944, 13000851, 13000852, 15504);
    $InitializeEvent(0, 13002891, 13002944, 13003851, 13000852, 15506, 13000851, 13002873);
    $InitializeEvent(1, 13002890, 13002945, 13000852, 13000851, 15454);
    $InitializeEvent(1, 13002891, 13002945, 13003852, 13000851, 15456, 13000852, 13002874);
    $InitializeEvent(0, 13002892);
    $InitializeEvent(0, 13002236, 13002314, 13000235);
    $InitializeCommonEvent(0, 90005300, 13000340, 13000340, 40770, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000341, 13000341, 40772, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000342, 13000342, 40774, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000343, 13000343, 40776, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000369, 13000369, 0, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000490, 13000490, 13002091, 0, 0);
    $InitializeEvent(0, 13002493, 13000490, 13002641, 13002640);
    $InitializeEvent(0, 13002646, 13000492, 13002492, 13000492, 10);
    $InitializeCommonEvent(0, 90005300, 13000494, 13000494, 0, 0, 0);
    $InitializeEvent(2, 13002493, 13000494, 13002645, 13002494);
    $InitializeEvent(1, 13002646, 13000494, 13002646, 13000494, 10);
    $InitializeEvent(0, 13002610);
    $InitializeCommonEvent(0, 90005300, 13000495, 13000495, 13002093, 0, 0);
    $InitializeEvent(2, 13002646, 13000495, 13002495, 13000495, 1);
    $InitializeCommonEvent(0, 90005300, 13000701, 13000701, 0, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000702, 13000702, 0, 0, 0);
    $InitializeEvent(3, 13002493, 13000702, 13002497, 13002493);
    $InitializeCommonEvent(0, 90005300, 13000295, 13000295, 0, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000296, 13000296, 0, 0, 0);
    $InitializeCommonEvent(0, 90005300, 13000496, 13000496, 13002095, 2, 0);
    $InitializeEvent(0, 13002580);
    $InitializeEvent(0, 13002510);
    $InitializeCommonEvent(0, 90005501, 13000510, 13000511, 0, 13001510, 13001511, 13001512, 13000512);
    $InitializeCommonEvent(0, 90005501, 13000515, 13000516, 0, 13001515, 13001516, 13001517, 13000517);
    $InitializeCommonEvent(0, 90005501, 13000520, 13000521, 0, 13001520, 13001521, 13001522, 13000522);
    $InitializeCommonEvent(0, 90005501, 13000525, 13000526, 1, 13001525, 13001526, 13001527, 13000527);
    $InitializeCommonEvent(0, 90005501, 13000530, 13000531, 2, 13001530, 13001531, 13001532, 13000532);
    $InitializeEvent(0, 13002600, 13000600, 13002600, 13002120, 0);
    $InitializeEvent(1, 13002600, 13000600, 13002600, 13002121, 1);
    $InitializeEvent(2, 13002600, 13000600, 13002600, 13002122, 3);
    $InitializeEvent(3, 13002600, 13000600, 13002600, 13002123, 5);
    $InitializeEvent(4, 13002600, 13000600, 13002600, 13002124, 6);
    $InitializeEvent(5, 13002600, 13000600, 13002600, 13002125, 9);
    $InitializeEvent(6, 13002600, 13000600, 13002600, 13002126, 1);
    $InitializeEvent(7, 13002600, 13000600, 13002600, 13002127, 2.5);
    $InitializeEvent(8, 13002600, 13000600, 13002600, 13002128, 7);
    $InitializeCommonEvent(0, 90005620, 13000570, 13001570, 13001571, 13001572, 13002570, 13002571, 13002572);
    $InitializeCommonEvent(0, 90005621, 13000570, 13001573);
    $InitializeCommonEvent(0, 90005780, 13000850, 13002160, 13002161, 13000720, SummonSignType.NPCWhiteSign, 13002721, 13002720, true, 0);
    $InitializeCommonEvent(0, 90005781, 13000850, 13002160, 13002161, 13000720);
    $InitializeEvent(0, 13002859);
    $InitializeCommonEvent(0, 90005780, 13000850, 13002164, 13002165, 13000725, SummonSignType.NPCWhiteSign, 13002726, 13002721, true, 0);
    $InitializeCommonEvent(0, 90005781, 13000850, 13002164, 13002165, 13000725);
    $InitializeCommonEvent(0, 90005782, 13002164, 13002855, 13000725, 13002853, 13002869, 0);
    $InitializeCommonEvent(0, 90005790, 0, 13000180, 13002181, 13002182, 13000710, 22, 13002180, 13002181, 0, 13009300, false, 0);
    $InitializeCommonEvent(0, 90005791, 13000180, 13002181, 13002182, 13000710);
    $InitializeCommonEvent(0, 90005792, 13000180, 13002181, 13002182, 13000710, 102920, 0);
    $InitializeCommonEvent(0, 13002660, 13000180, 13002181, 13002182, 13000710, 13002180, 13002183, 0);
    $InitializeEvent(0, 13003700);
    $InitializeCommonEvent(0, 90005704, 13000700, 13009256, 3660, 13009251, 3);
    $InitializeCommonEvent(0, 90005703, 13000700, 3661, 3662, 13009251, 13009256, 3660, 3663, -1);
    $InitializeCommonEvent(0, 90005702, 13000700, 3663, 3660, 3663);
    $InitializeEvent(0, 13003710, 13000700);
    $InitializeEvent(0, 13003711, 13000700);
    $InitializeCommonEvent(0, 90005750, 13001700, 4110, 101740, 400174, 400174, 13009254, 0);
    $InitializeEvent(0, 13003720);
    $InitializeEvent(0, 13003721);
});

// プリコンストラクタ -- preconstructor
$Event(50, Default, function() {
    $InitializeEvent(0, 13000519);
    $InitializeCommonEvent(0, 90005201, 13000200, 30003, 20003, 2, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005201, 13000201, 30003, 20003, 2, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005201, 13000202, 30003, 20003, 2, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005201, 13000252, 30003, 20003, 2, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000203, 13002203, 20, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000204, 13002201, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000250, 13002201, 3.5, -1);
    $InitializeCommonEvent(0, 90005250, 13000217, 13002217, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000218, 30004, 20004, 13002217, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000206, 13002205, 10, 0, -1);
    $InitializeCommonEvent(0, 90005261, 13000209, 13002209, 10, 0, -1);
    $InitializeCommonEvent(0, 90005211, 13000207, 30003, 20003, 13002207, 3, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000210, 13002210, 0, 3001);
    $InitializeCommonEvent(0, 90005251, 13000210, 3, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000211, 13002207, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000212, 13002207, 1, -1);
    $InitializeCommonEvent(0, 90005271, 13000212, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000213, 13002212, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000214, 13002215, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000215, 13002215, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000216, 13002215, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000219, 13002214, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000251, 13002214, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000221, 13002220, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000222, 13002222, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000223, 13002223, 0, -1);
    $InitializeCommonEvent(0, 90005261, 13000225, 13002225, 20, 0, -1);
    $InitializeCommonEvent(0, 90005210, 13000227, 30004, 20004, 13002227, 5, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000228, 13002228, 0, 3002);
    $InitializeCommonEvent(0, 90005250, 13000230, 13002230, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000231, 30004, 20004, 13002231, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000232, 13002230, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000234, 13002234, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000233, 30003, 20003, 13002233, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000235, 13002235, 20, 0, -1);
    $InitializeCommonEvent(0, 90005251, 13000236, 5, 0, -1);
    $InitializeCommonEvent(0, 90005201, 13000237, 30004, 20004, 5, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000245, 13002245, 0, -1);
    $InitializeCommonEvent(0, 90005221, 13000265, 30004, 20004, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000267, 30004, 20004, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000268, 30004, 20004, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000269, 30004, 20004, 13002269, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005251, 13000270, 40, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000260, 13002296, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000261, 13002296, 1, -1);
    $InitializeCommonEvent(0, 90005250, 13000262, 13002296, 0, -1);
    $InitializeCommonEvent(0, 90005261, 13000278, 13002278, 30, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000275, 13002277, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000276, 13002277, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000277, 13002277, 0, -1);
    $InitializeCommonEvent(0, 90005221, 13000282, 30004, 20004, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000284, 30004, 20004, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000288, 30004, 20004, 13002289, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000289, 30004, 20004, 13002289, 1, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000290, 30004, 20004, 13002289, 0.5, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000410, 13002412, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000412, 13002412, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000400, 13002412, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000409, 13002408, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000405, 30017, 20017, 13002412, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000408, 30017, 20017, 13002412, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000416, 13002416, 0, 3014);
    $InitializeCommonEvent(0, 90005251, 13000417, 1, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000418, 13002418, 0, 3003);
    $InitializeCommonEvent(0, 90005250, 13000419, 13002418, 0.5, 3003);
    $InitializeCommonEvent(0, 90005261, 13000420, 13002420, 10, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000422, 30018, 20018, 13002421, 5.5, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000423, 30018, 20018, 13002421, 7.5, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000424, 30018, 20018, 13002421, 8, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000435, 30017, 20017, 13002435, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000441, 13002435, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000446, 30017, 20017, 13002446, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000451, 30014, 20014, 13002446, 3, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000452, 30014, 20014, 13002446, 1.5, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000298, 13002323, 35, 0, -1);
    $InitializeCommonEvent(0, 90005261, 13000299, 13002323, 35, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000456, 30017, 20017, 13002456, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000457, 30018, 20018, 13002459, 1.5, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000458, 30018, 20018, 13002459, 2, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000459, 30018, 20018, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000461, 30018, 20018, 13002459, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000472, 30018, 20018, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000473, 30018, 20018, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000463, 30018, 20018, 13002463, 3, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000464, 30018, 20018, 13002463, 4, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005221, 13000474, 30018, 20018, 0, 0);
    $InitializeCommonEvent(0, 90005251, 13000460, 3, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000481, 13002481, 0, 3003);
    $InitializeCommonEvent(0, 90005250, 13000482, 13002418, 0.5, 3003);
    $InitializeCommonEvent(0, 90005200, 13000485, 30017, 20017, 13002435, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000487, 30017, 20017, 13002435, 3, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000488, 30017, 20017, 13002488, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000489, 13002488, 2, 0.5, -1);
    $InitializeCommonEvent(0, 90005200, 13000300, 30001, 20001, 13002300, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005201, 13000310, 30000, 20000, 10, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000311, 30000, 20000, 13002311, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000312, 30000, 20000, 13002311, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000314, 13002314, 20, 0, -1);
    $InitializeCommonEvent(0, 90005201, 13000315, 30000, 20000, 20, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005201, 13000315, 30000, 20000, 15, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000320, 30001, 20001, 13002456, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000330, 13002355, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000331, 13002355, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000350, 30001, 20001, 13002350, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000351, 30000, 3009, 13002350, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000352, 13002352, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000352, 30000, 20000, 13002352, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000354, 30000, 20000, 13002355, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000355, 30001, 20001, 13002355, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005210, 13000356, 30000, 20000, 13002356, 9, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005210, 13000357, 30000, 20000, 13002356, 9, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005210, 13000358, 30000, 20000, 13002356, 9, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000360, 30000, 20000, 13002356, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000361, 30001, 20001, 13002356, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000362, 30001, 20001, 13002362, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000363, 30001, 20001, 13002362, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000364, 30000, 20000, 13002362, 1, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000365, 30001, 20001, 13002365, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005201, 13000367, 30000, 20000, 1, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000381, 13002381, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000382, 13002382, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000384, 13002384, 0, -1);
    $InitializeCommonEvent(0, 90005251, 13000385, 10, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000380, 13002380, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000383, 13002380, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000390, 13002390, 0, -1);
    $InitializeCommonEvent(0, 90005251, 13000386, 55, 6, -1);
    $InitializeCommonEvent(0, 90005250, 13000388, 13002388, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000389, 13002389, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000392, 13002392, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000395, 13002395, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000396, 13002396, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000398, 13002398, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000371, 30000, 20000, 13002372, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000372, 30000, 20000, 13002372, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000373, 30001, 20001, 13002300, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000376, 30001, 20001, 13002372, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005261, 13000374, 13002374, 3, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000375, 30000, 20000, 13002375, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000377, 13002377, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000378, 30000, 20000, 13002369, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000379, 30000, 20000, 13002369, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000369, 30001, 20001, 13002369, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000490, 30019, 20019, 13002490, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005200, 13000494, 30019, 20019, 13002494, 0, 0, 0, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000495, 13002495, 0, -1);
    $InitializeCommonEvent(0, 90005200, 13000702, 30010, 20010, 13002498, 0, 0, 1, 0, 0);
    $InitializeCommonEvent(0, 90005250, 13000295, 13002295, 0, -1);
    $InitializeCommonEvent(0, 90005250, 13000296, 13002296, 0, -1);
    $InitializeCommonEvent(0, 90005261, 13000496, 13002496, 40, 0, -1);
});

// メリナ炎上後脱出封印 -- Escape seal after Melina burns
$Event(13002500, Default, function() {
    EndIf(!PlayerIsInOwnWorld());
    EndIf(EventFlag(13000500));
    WaitFor(PlayerInMap(13, 0, 0, 0) && EventFlag(110) && !InArea(10000, 13002502));
    SetSpEffect(10000, 4280);
    SetSpEffect(10000, 4282);
    WaitFor(PlayerIsInOwnWorld() && EventFlag(9000));
    SetEventFlagID(13000500, ON);
    SetSpEffect(10000, 4281);
    SetSpEffect(10000, 4283);
});

// 梯子登録 -- ladder registration
$Event(13002580, Restart, function() {
    RegisterLadder(13000580, 13000581, 13001580);
    RegisterLadder(13000582, 13000583, 13001582);
    RegisterLadder(13000584, 13000585, 13001584);
    RegisterLadder(13000586, 13000587, 13001586);
    RegisterLadder(13000588, 13000589, 13001588);
    RegisterLadder(13000590, 13000591, 13001590);
});

// エレベータイベント起動 -- Elevator event activation
$Event(13002510, Default, function() {
    $InitializeCommonEvent(0, 90005500, 13000510, 13000511, 0, 13001510, 13001511, 13003511, 13001512, 13003512, 13002511, 13002512, 13000512, 13000513, 0);
    $InitializeCommonEvent(0, 90005500, 13000515, 13000516, 0, 13001515, 13001516, 13003516, 13001517, 13003517, 13002516, 13002517, 13000517, 13000518, 0);
    $InitializeCommonEvent(0, 90005500, 13000520, 13000521, 0, 13001520, 13001521, 13003521, 13001522, 13003522, 13002521, 13002522, 13000522, 13000523, 0);
    $InitializeCommonEvent(0, 90005500, 13000525, 13000526, 1, 13001525, 13001526, 13003526, 13001527, 13003527, 13002526, 13002527, 13000527, 13000528, 0);
    $InitializeCommonEvent(0, 90005500, 13000530, 13000531, 2, 13001530, 13001531, 13003531, 13001532, 13003532, 13002531, 13002532, 13000532, 13000533, 0);
});

// エレベータ初期フラグ設定 -- Elevator initial flag setting
$Event(13000519, Default, function() {
    EndIf(ThisEventSlot());
    SetEventFlagID(13000510, ON);
    SetThisEventSlot(ON);
});

// 獣の末裔_ターゲットクリア_XX -- Descendant of the Beast_Target Clear_XX
$Event(13002236, Restart, function(areaEntityId, chrEntityId) {
    WaitFor(
        ((CharacterType(10000, TargetType.BlackPhantom) && CharacterHasSpEffect(10000, 3710))
            || CharacterType(10000, TargetType.Alive)
            || CharacterType(10000, TargetType.GrayPhantom)
            || CharacterType(10000, TargetType.WhitePhantom))
            && InArea(10000, areaEntityId));
    ClearCharactersAITarget(chrEntityId);
    RestartEvent();
});

// 守護末登場_XX -- Shugosue appears_XX
$Event(13002490, Restart, function(chrEntityId, areaEntityId, animationId, eventFlagId) {
    if (EventFlag(eventFlagId)) {
        DisableCharacter(chrEntityId);
        DisableCharacterCollision(chrEntityId);
        EndEvent();
    }
L0:
    DisableCharacter(chrEntityId);
    DisableCharacterCollision(chrEntityId);
    WaitFor(
        ((CharacterType(10000, TargetType.BlackPhantom) && CharacterHasSpEffect(10000, 3710))
            || CharacterType(10000, TargetType.Alive)
            || CharacterType(10000, TargetType.GrayPhantom)
            || CharacterType(10000, TargetType.WhitePhantom))
            && InArea(10000, areaEntityId));
    EnableCharacter(chrEntityId);
    EnableCharacterCollision(chrEntityId);
    ForceAnimationPlayback(chrEntityId, animationId, false, false, false);
});

// 守護者の末裔_ブレス連打_XX -- Descendant of the Guardian_Breath Consecutive Strike_XX
$Event(13002493, Restart, function(chrEntityId, areaEntityId, areaEntityId2) {
    ClearSpEffect(chrEntityId, 18941);
    WaitFor(
        ((CharacterType(10000, TargetType.BlackPhantom) && CharacterHasSpEffect(10000, 3710))
            || CharacterType(10000, TargetType.Alive)
            || CharacterType(10000, TargetType.GrayPhantom)
            || CharacterType(10000, TargetType.WhitePhantom))
            && InArea(10000, areaEntityId)
            && InArea(chrEntityId, areaEntityId2));
    SetSpEffect(chrEntityId, 18941);
    WaitFixedTimeSeconds(4);
    RestartEvent();
});

// 守護末の末裔_撤退_XX -- Descendant of the Last Guardian_Retreat_XX
$Event(13002646, Restart, function(eventFlagId, areaEntityId, chrEntityId, timeSeconds) {
    EndIf(EventFlag(eventFlagId));
    EndIf(ThisEventSlot());
    WaitFor(!InArea(10000, areaEntityId) && CharacterAIState(chrEntityId, AIStateType.Combat));
    WaitFixedTimeSeconds(timeSeconds);
    ForceAnimationPlayback(chrEntityId, 20001, false, false, false);
    WaitFixedTimeSeconds(6);
    DisableCharacter(chrEntityId);
    SetThisEventSlot(ON);
});

// 【専用】敵対NPC_帰還 -- [Exclusive] Hostile NPC_Return
$Event(13002660, Restart, function(eventFlagId, eventFlagId2, eventFlagId3, npcEntityId, entityId, areaEntityId, value) {
    EndIf(EventFlag(eventFlagId));
    EndIf(!PlayerIsInOwnWorld());
    flag = EventFlag(eventFlagId);
    flagArea &= EventFlag(eventFlagId2);
    if (areaEntityId == 0) {
        flagArea &= !EntityInRadiusOfEntity(10000, entityId, 110, 1);
    } else {
        flagArea &= !InArea(10000, areaEntityId);
    }
    flagArea2 &= EventFlag(eventFlagId2);
    if (Signed(value) != 2) {
        GotoIf(S0, Signed(value) == 1);
        flagArea2 &= !EntityInRadiusOfEntity(10000, entityId, 180, 1);
        Goto(S1);
S0:
        flagArea2 &= !EntityInRadiusOfEntity(10000, entityId, 360, 1);
    } else {
        flagArea2 &= !EntityInRadiusOfEntity(10000, entityId, 720, 1);
    }
S1:
    WaitFor(flag || flagArea || flagArea2);
    EndIf(EventFlag(eventFlagId));
    SendNPCSummonHome(npcEntityId);
    EndEvent();
    flag2 = !EventFlag(eventFlagId3);
});

// マリケス撃破 -- Defeat Mariquez
$Event(13002800, Restart, function() {
    if (EventFlag(13000800)) {
        EndIf(!PlayerIsInOwnWorld());
        GotoIf(L1, !EventFlag(118));
        EndEvent();
    }
L0:
    WaitFor(CharacterHPValue(13000800) <= 0);
    ForceCharacterDeath(13000801, false);
    ForceCharacterDeath(13000800, false);
    WaitFixedTimeSeconds(4);
    PlaySE(13008000, SoundType.SFX, 888880000);
    WaitFor(
        (PlayerIsInOwnWorld() && CharacterDead(13000800) && !CharacterHasSpEffect(10000, 9646))
            || EventFlag(13000800));
    EnableCharacterDefaultBackread(13000800);
    HandleBossDefeatAndDisplayBanner(13000800, TextBannerType.LegendFelled);
    SetNetworkconnectedEventFlagID(13000800, ON);
    SetEventFlagID(9116, ON);
    if (PlayerIsInOwnWorld()) {
        SetEventFlagID(61116, ON);
    }
    EndIf(!PlayerIsInOwnWorld());
    EndIf(PlayerIsInOwnWorld());
});

// マリケス用篝火処理 -- Bonfire processing for Marikes
$Event(13002805, Restart, function() {
    if (!EventFlag(13000800)) {
        DisableCharacter(13000950);
        DisableAsset(13001950);
        WaitFixedTimeSeconds(1);
        WaitFor(EventFlag(13000800));
        WaitFixedTimeSeconds(4);
        WaitFixedTimeSeconds(7.8);
        SpawnOneshotSFX(TargetEntityType.Asset, 13001950, 200, 1060);
        WaitFixedTimeSeconds(0.5);
        EnableCharacter(13000950);
        EnableAsset(13001950);
    }
L0:
    RegisterBonfire(13000000, 13001950, 5, 180, 0, 5);
});

// マリケス出現 -- Marikes appears
$Event(13002810, Restart, function() {
    if (EventFlag(13000800)) {
        DisableCharacter(13000800);
        DisableCharacter(13000801);
        DisableCharacterCollision(13000800);
        DisableCharacterCollision(13000801);
        ForceCharacterDeath(13000800, false);
        ForceCharacterDeath(13000801, false);
        EndEvent();
    }
L0:
    DisableCharacterAI(13000801);
    DisableCharacterAI(13000800);
    DisableCharacterHPBarDisplay(13000800);
    DisableCharacter(13000800);
    DisableCharacterGravity(13000800);
    DisableCharacterCollision(13000800);
    if (!EventFlag(13000801)) {
        ForceAnimationPlayback(13000801, 30018, true, false, false);
        WaitFor(EventFlag(13002805) && InArea(10000, 13002800));
        WaitFixedTimeSeconds(3);
        ForceAnimationPlayback(13000801, 20038, true, false, false);
        SetNetworkconnectedEventFlagID(13000801, ON);
    } else {
L1:
        WaitFor(EventFlag(13002805) && InArea(10000, 13002800));
        SetEventFlagID(13002803, ON);
    }
L2:
    EnableCharacter(13000800);
    CreateReferredDamagePair(13000801, 13000800);
    EnableCharacterAI(13000801);
    SetNetworkUpdateRate(13000801, true, CharacterUpdateFrequency.AlwaysUpdate);
    SetNetworkUpdateRate(13000800, true, CharacterUpdateFrequency.AlwaysUpdate);
    DisplayBossHealthBar(Enabled, 13000801, 0, 902110000);
});

// マリケス激昂 -- marikes rage
$Event(13002811, Restart, function() {
    EndIf(EventFlag(13000800));
    WaitFor(HPRatio(13000801) <= 0.55);
    EndIf(CharacterHPValue(10000) <= 0 || InArea(10000, 13002815));
    DisableCharacterFadeOnEnable(13000800);
    if (PlayerIsInOwnWorld()) {
        PlayCutsceneToPlayerAndWarp(13000040, CutscenePlayMode.Skippable, 13002820, 13000000, 10000, 0, false);
    } else {
        PlayCutsceneToPlayer(13000040, CutscenePlayMode.Skippable, 10000);
    }
    WaitFixedTimeRealFrames(1);
    SetEventFlagID(13002802, ON);
    DisableCharacter(13000801);
    SetNetworkUpdateRate(13000801, false, CharacterUpdateFrequency.NoUpdate);
    DisableCharacterAI(13000801);
    ForceAnimationPlayback(13000800, 20015, false, false, false);
    WarpCharacterAndCopyFloor(13000800, TargetEntityType.Area, 13002825, -1, 13000800);
    EnableCharacterGravity(13000800);
    EnableCharacterCollision(13000800);
    EnableCharacterAI(13000800);
    SetNetworkUpdateRate(13000800, true, CharacterUpdateFrequency.AlwaysUpdate);
    DisplayBossHealthBar(Enabled, 13000800, 0, 902110001);
});

// マリケス柱内復帰ワープ処理 -- Marikes pillar return warp processing
$Event(13002819, Restart, function() {
    WaitFor(CharacterHasSpEffect(13000800, 15272));
    WarpCharacterAndCopyFloor(13000800, TargetEntityType.Area, 13002825, -1, 13000800);
    WaitFixedTimeSeconds(1);
    RestartEvent();
});

// マリケス壁キック用イベントターゲット設定 -- Event target setting for Marikes wall kick
$Event(13002820, Restart, function() {
    hpFlag = HPRatio(13000800) != 0 && EventFlag(13002821);
    if (EventFlag(13002822)) {
        SetEventPoint(13000800, 13002810, 200);
    }
    if (EventFlag(13002823)) {
        SetEventPoint(13000800, 13002811, 200);
    }
    if (EventFlag(13002824)) {
        SetEventPoint(13000800, 13002812, 200);
    }
    SetEventFlagID(13002821, OFF);
    RestartEvent();
});

// マリケス柱内復帰処理 -- Marikes pillar return process
$Event(13002827, Restart, function() {
    WaitFor(
        !CharacterHasSpEffect(13000800, 15270)
            && !EventFlag(13002826)
            && (InArea(13000800, 13002840) || InArea(13000800, 13002841) || InArea(13000800, 13002842)));
    SetSpEffect(13000800, 15270);
    SetEventFlagID(13002826, ON);
    RestartEvent();
});

// マリケス柱内復帰処理_完了 -- Marikes pillar return process_completed
$Event(13002828, Restart, function() {
    WaitFor(
        EventFlag(13002826)
            && !InArea(13000800, 13002840)
            && !InArea(13000800, 13002841)
            && !InArea(13000800, 13002842));
    SetEventFlagID(13002826, OFF);
    RestartEvent();
});

// マリケスボスイベント起動 -- Marikes boss event started
$Event(13002829, Restart, function() {
    $InitializeCommonEvent(0, 9005800, 13000800, 13001800, 13002800, 13002805, 13005800, 10000, 0, 0);
    $InitializeCommonEvent(0, 9005801, 13000800, 13001800, 13002800, 13002805, 13002806, 10000);
    $InitializeCommonEvent(0, 9005811, 13000800, 13001800, 4, 0);
    $InitializeCommonEvent(0, 9005822, 13000800, 211000, 13002805, 13002806, 0, 13002802, 1, 1);
});

// 古龍撃破 -- Defeat the ancient dragon
$Event(13002830, Restart, function() {
    EndIf(EventFlag(13000830));
    WaitFor(CharacterHPValue(13000830) <= 0);
    ForceCharacterDeath(13000830, false);
    WaitFixedTimeSeconds(4);
    PlaySE(13008000, SoundType.SFX, 888880000);
    WaitFor(CharacterDead(13000830));
    HandleBossDefeatAndDisplayBanner(13000830, TextBannerType.LegendFelled);
    ChangeWeather(Weather.Default, -1, false);
    SetEventFlagID(13000830, ON);
    SetEventFlagID(9115, ON);
    if (PlayerIsInOwnWorld()) {
        SetEventFlagID(61115, ON);
    }
    if (PlayerIsInOwnWorld()) {
        SetEventFlagID(71301, ON);
    }
});

// 古龍ボス部屋へワープする -- Warp to the Elder Dragon boss room
$Event(13002834, Restart, function() {
    EndIf(EventFlag(13000830));
    if (!PlayerIsInOwnWorld()) {
        if (EventFlag(13002834)) {
            WarpCharacterAndCopyFloorWithFadeout(20000, TargetEntityType.Area, 13002836, -1, 20000, false, true);
            ChangeCamera(4525, 4520);
            EndEvent();
        }
    }
L0:
    EndIf(
        CharacterType(10000, TargetType.BlackPhantom)
            || CharacterType(10000, TargetType.Invader)
            || CharacterType(10000, TargetType.Invader2)
            || CharacterType(10000, TargetType.Invader3)
            || CharacterType(10000, TargetType.BluePhantom));
    GotoIf(L0, ThisEventSlot());
    WaitFor(PlayerIsInOwnWorld() && ActionButtonInArea(9740, 13001505));
    IssueShortWarpRequest(10000, TargetEntityType.Asset, 13001505, 100);
    ForceAnimationPlayback(10000, 67010, false, false, false);
    WaitFixedTimeSeconds(3);
    if (PlayerIsInOwnWorld()) {
        SendInvadingPhantomsHome(0);
    }
    if (PlayerIsInOwnWorld()) {
        PlayCutsceneToPlayerAndWarpWithWeatherAndTime(13000010, CutscenePlayMode.Skippable, 13002834, 13000000, 10000, 0, false, true, Weather.FlatClouds, -1, false, 0, 0, 0);
    } else {
        PlayCutsceneToPlayerAndWarpWithWeatherAndTime(13000010, CutscenePlayMode.Unskippable, 13002836, 13000000, 10000, 0, false, true, Weather.FlatClouds, -1, false, 0, 0, 0);
    }
    WaitFixedTimeRealFrames(1);
    SetNetworkconnectedThisEventSlot(ON);
    ChangeCamera(4525, 4520);
});

// 古龍出現 -- Ancient dragon appears
$Event(13002835, Restart, function() {
    if (EventFlag(13000830)) {
        DisableCharacter(13005830);
        DisableCharacterCollision(13005830);
        ForceCharacterDeath(13005830, false);
        SetEventFlagID(71301, ON);
        EndEvent();
    }
L3:
    DisableCharacterAI(13000830);
    CreateNPCPart(13000830, 0, NPCPartType.Part1, 9999, 1, 1, false, false);
    CreateNPCPart(13000830, 1, NPCPartType.Part2, 9999, 1, 1, false, false);
    SetNPCPartSEAndSFX(13000830, 0, 173, 173, 139, 139, 0);
    SetNPCPartSEAndSFX(13000830, 1, 173, 173, 139, 139, 0);
    DisableLockOnPoint(13000830, 222);
    DisableLockOnPoint(13000830, 223);
    DisableLockOnPoint(13000830, 224);
    DisableLockOnPoint(13000830, 225);
    SetCharacterEventTarget(13000830, 13000840);
    EnableCharacterDefaultBackread(13000830);
    ForceAnimationPlayback(13000830, 30000, true, false, false);
    WaitFor(
        InArea(10000, 13002831)
            || HasDamageType(13000830, 0, DamageType.Unspecified)
            || CharacterHasStateInfo(13000830, 436)
            || CharacterHasStateInfo(13000830, 2)
            || CharacterHasStateInfo(13000830, 5)
            || CharacterHasStateInfo(13000830, 6)
            || CharacterHasStateInfo(13000830, 260));
    ForceAnimationPlayback(13000830, 20000, false, false, false);
    EnableCharacterAI(13000830);
    SetNetworkUpdateRate(13000830, true, CharacterUpdateFrequency.AlwaysUpdate);
    DisplayBossHealthBar(Enabled, 13000830, 0, 904520000);
    ActivateMultiplayerdependantBuffs(13005830);
    EndIf(!PlayerIsInOwnWorld());
    SetNetworkconnectedEventFlagID(13002835, ON);
    SetNetworkUpdateAuthority(13005830, AuthorityLevel.Forced);
    IssueBossRoomEntryNotification();
});

// 古龍激昂 -- Old dragon rage
$Event(13002840, Restart, function() {
    EndIf(EventFlag(13000830));
    WaitFor(CharacterHasSpEffect(13000830, 5029));
    ChangeWeather(Weather.WindyRain, -1, false);
    SetEventFlagID(13002832, ON);
});

// 古龍カメラ変更イベント -- Old dragon camera change event
$Event(13002841, Restart, function() {
    EndIf(EventFlag(13000830));
    DisableNetworkSync();
    WaitFor(CharacterHasSpEffect(13000830, 5025));
    ChangeCamera(4525, 4521);
    WaitFixedTimeSeconds(1);
    WaitFor(!CharacterHasSpEffect(13000830, 5025));
    ChangeCamera(4525, 4520);
    WaitFixedTimeSeconds(1);
    RestartEvent();
});

// 古龍用ゲストがボス部屋入場 -- Ancient dragon guest enters boss room
$Event(13002846, Restart, function(eventFlagId, eventFlagId2, eventFlagId3) {
    DisableNetworkSync();
    EndIf(EventFlag(eventFlagId));
    WaitFor(
        !EventFlag(eventFlagId)
            && EventFlag(eventFlagId2)
            && CharacterType(10000, TargetType.WhitePhantom));
    SetEventFlagID(eventFlagId3, ON);
    RestartEvent();
});

// 古龍ボスイベント起動 -- Ancient dragon boss event started
$Event(13002849, Restart, function() {
    $InitializeEvent(0, 13002846, 13000830, 13002835, 13002836);
    $InitializeCommonEvent(0, 9005822, 13000830, 452000, 13002835, 13002836, 0, 13002832, 0, 1);
});

// 神肌撃破 -- Defeat God's skin
$Event(13002850, Restart, function() {
    EndIf(EventFlag(13000850));
    WaitFor(CharacterHPValue(13000850) <= 0);
    ForceCharacterDeath(13000851, false);
    ForceCharacterDeath(13000852, false);
    SetEventFlagID(13002854, ON);
    WaitFixedTimeSeconds(4);
    PlaySE(13000850, SoundType.SFX, 888880000);
    WaitFor(CharacterDead(13000850));
    HandleBossDefeatAndDisplayBanner(13000850, TextBannerType.GreatEnemyFelled);
    SetEventFlagID(13000850, ON);
    SetEventFlagID(9114, ON);
    if (PlayerIsInOwnWorld()) {
        SetEventFlagID(61114, ON);
    }
});

// 【専用】協力NPC_ボス部屋入場 -- [Exclusive] Cooperating NPC_Boss room entry
$Event(13002859, Default, function() {
    EndIf(!PlayerIsInOwnWorld());
    WaitFor(EventFlag(13002160) && EventFlag(13002855));
    if (!InArea(10000, 13002852)) {
        RequestCharacterAICommand(13000720, 10, 0);
        RequestCharacterAIReplan(13000720);
        SetEventPoint(13000720, 13002850, 0);
        WaitFor(InArea(13000720, 13002859));
        RotateCharacter(13000720, 13002850, 60060, true);
        time |= ElapsedSeconds(3);
        WaitFor(time || InArea(13000720, 13002850));
        RestartIf(time.Passed);
        RequestCharacterAICommand(13000720, -1, 0);
        RequestCharacterAIReplan(13000720);
        SetNetworkUpdateRate(13000720, true, CharacterUpdateFrequency.AlwaysUpdate);
        EndEvent();
    }
L0:
    RequestCharacterAICommand(13000720, 10, 0);
    RequestCharacterAIReplan(13000720);
    SetEventPoint(13000720, 13002852, 0);
    WaitFor(InArea(13000720, 13002859));
    RotateCharacter(13000720, 13002852, 60060, true);
    time |= ElapsedSeconds(3);
    WaitFor(time || InArea(13000720, 13002852));
    RestartIf(time.Passed);
    RequestCharacterAICommand(13000720, -1, 0);
    RequestCharacterAIReplan(13000720);
    SetNetworkUpdateRate(13000720, true, CharacterUpdateFrequency.AlwaysUpdate);
});

// 神肌出現 -- Divine skin appears
$Event(13002860, Restart, function() {
    if (EventFlag(13000850)) {
        DisableCharacter(13000850);
        DisableCharacter(13000851);
        DisableCharacter(13000852);
        DisableCharacterCollision(13000850);
        DisableCharacterCollision(13000851);
        DisableCharacterCollision(13000852);
        ForceCharacterDeath(13000850, false);
        ForceCharacterDeath(13000851, false);
        ForceCharacterDeath(13000852, false);
        EndEvent();
    }
L6:
    DisableCharacterAI(13000851);
    DisableCharacterAI(13000852);
    DisableCharacter(13000850);
    DisableCharacterGravity(13000850);
    DisableCharacterCollision(13000850);
    if (!EventFlag(13000851)) {
        DisableCharacter(13000851);
        DisableCharacter(13000852);
        ForceAnimationPlayback(13000851, 30001, true, false, false);
        ForceAnimationPlayback(13000852, 30001, true, false, false);
        WaitFor(
            (PlayerIsInOwnWorld() && InArea(10000, 13002851))
                || HasDamageType(13000851, 10000, DamageType.Unspecified)
                || HasDamageType(13000852, 10000, DamageType.Unspecified));
        SetNetworkconnectedEventFlagID(13000851, ON);
        EnableCharacter(13000851);
        EnableCharacter(13000852);
        ForceAnimationPlayback(13000851, 20001, false, false, false);
        ForceAnimationPlayback(13000852, 20001, false, false, false);
    } else {
L7:
        WaitFor(
            EventFlag(13002855)
                || InArea(10000, 13002850)
                || InArea(10000, 13002852)
                || InArea(10000, 13002853));
    }
L8:
    EnableCharacter(13000850);
    DisableCharacterAI(13000850);
    EnableCharacterAI(13000851);
    EnableCharacterAI(13000852);
    SetNetworkUpdateRate(13000850, true, CharacterUpdateFrequency.AlwaysUpdate);
    SetNetworkUpdateRate(13000851, true, CharacterUpdateFrequency.AlwaysUpdate);
    SetNetworkUpdateRate(13000852, true, CharacterUpdateFrequency.AlwaysUpdate);
    CreateReferredDamagePair(13005851, 13000850);
    DisplayBossHealthBar(Enabled, 13000850, 0, 903575000);
});

// 神肌激昂 -- divine rage
$Event(13002861, Restart, function() {
    EndIf(EventFlag(13000850));
    WaitFor(HPRatio(13000850) <= 0.5 || EventFlag(13002873) || EventFlag(13002874));
    SetEventFlagID(13002852, ON);
});

// 神肌復活カウントダウン_XX -- God skin revival countdown_XX
$Event(13002890, Restart, function(eventFlagId, chrEntityId, chrEntityId2, spEffectId) {
    EndIf(!PlayerIsInOwnWorld());
    EndIf(EventFlag(13000850));
    EndIf(EventFlag(13002854));
    WaitFor(!EventFlag(eventFlagId) && CharacterDead(chrEntityId));
    WaitFixedTimeSeconds(20);
    if (CharacterHPValue(chrEntityId2) <= 0) {
        RestartEvent();
    }
L0:
    SetSpEffect(chrEntityId2, spEffectId);
    SetNetworkconnectedEventFlagID(eventFlagId, ON);
    RestartEvent();
});

// 神肌復活_XX -- Divine skin revival_XX
$Event(13002891, Restart, function(eventFlagId, generatorEntityId, chrEntityId, spEffectId, chrEntityId2, eventFlagId2) {
    EndIf(!PlayerIsInOwnWorld());
    EndIf(EventFlag(13000850));
    EndIf(EventFlag(13002854));
    WaitFor(
        (CharacterHasSpEffect(chrEntityId, spEffectId) || CharacterDead(chrEntityId))
            && EventFlag(eventFlagId));
    EndIf(EventFlag(13000850));
    EndIf(EventFlag(13002854));
    InvokeEnemyGenerator(generatorEntityId);
    SetNetworkconnectedEventFlagID(eventFlagId, OFF);
    SetNetworkconnectedEventFlagID(eventFlagId2, ON);
    SetNetworkUpdateRate(chrEntityId2, true, CharacterUpdateFrequency.AlwaysUpdate);
    RestartEvent();
});

// 神肌復活_両方死亡 -- God skin resurrection_both dead
$Event(13002892, Restart, function() {
    EndIf(!PlayerIsInOwnWorld());
    EndIf(EventFlag(13000850));
    EndIf(EventFlag(13002854));
    WaitFor(
        CharacterDead(13000851)
            && CharacterDead(13000852)
            && !EventFlag(13002944)
            && !EventFlag(13002945));
    EndIf(EventFlag(13000850));
    WaitFixedTimeSeconds(10);
    EndIf(EventFlag(13000850));
    EndIf(EventFlag(13002854));
    RandomlySetEventFlagInRange(13002875, 13002876, ON);
    GotoIf(L0, EventFlag(13002875));
    GotoIf(L1, EventFlag(13002876));
L0:
    InvokeEnemyGenerator(13003851);
    SetEventFlagID(13002873, ON);
    SetEventFlagID(13002875, OFF);
    RestartEvent();
L1:
    InvokeEnemyGenerator(13003852);
    SetEventFlagID(13002874, ON);
    SetEventFlagID(13002876, OFF);
    RestartEvent();
});

// 神肌ボスイベント起動 -- Divine skin boss event started
$Event(13002865, Restart, function() {
    $InitializeCommonEvent(0, 9005800, 13000850, 13001850, 13002850, 13002855, 13005850, 10000, 13000851, 13002851);
    $InitializeCommonEvent(0, 9005800, 13000850, 13001852, 13002852, 13002855, 13005850, 10000, 13000851, 13002851);
    $InitializeCommonEvent(0, 9005800, 13000850, 13001853, 13002853, 13002855, 13005850, 10000, 13000851, 13002851);
    $InitializeCommonEvent(0, 9005801, 13000850, 13001850, 13002850, 13002855, 13002856, 10000);
    $InitializeCommonEvent(0, 9005801, 13000850, 13001852, 13002852, 13002855, 13002856, 10000);
    $InitializeCommonEvent(0, 9005801, 13000850, 13001853, 13002853, 13002855, 13002856, 10000);
    $InitializeCommonEvent(0, 9005811, 13000850, 13001850, 5, 13000851);
    $InitializeCommonEvent(0, 9005811, 13000850, 13001852, 5, 13000851);
    $InitializeCommonEvent(0, 9005811, 13000850, 13001853, 5, 13000851);
    $InitializeCommonEvent(0, 9005811, 13000850, 13001854, 5, 13000851);
    $InitializeCommonEvent(0, 9005811, 13000850, 13001855, 5, 13000851);
    $InitializeCommonEvent(0, 9005822, 13000850, 356000, 13002855, 13002856, 0, 13002852, 0, 0);
});

// 落雷演出_XX -- Lightning strike_XX
$Event(13002600, Restart, function(chrEntityId, areaEntityId, entityId, timeSeconds) {
    EndIf(EventFlag(13000490));
    CreateBulletOwner(chrEntityId);
    WaitFor(InArea(10000, areaEntityId));
    WaitFixedTimeSeconds(0.1);
    WaitFixedTimeSeconds(timeSeconds);
    SpawnOneshotSFX(TargetEntityType.Area, entityId, -1, 813600);
    WaitFixedTimeSeconds(5);
    RestartEvent();
});

// 守護末落雷 -- Thunderbolt at the end of the guardian
$Event(13002610, Restart, function() {
    ForceAnimationPlayback(13000495, 0, false, false, false);
    EndIf(CharacterAIState(13000495, AIStateType.Combat));
    EndIf(InArea(10000, 13002495) || EventFlag(13000495));
    WaitFor(
        InArea(10000, 13002619)
            && ((CharacterType(10000, TargetType.BlackPhantom) && CharacterHasSpEffect(10000, 3710))
                || CharacterType(10000, TargetType.Alive)
                || CharacterType(10000, TargetType.BluePhantom)
                || CharacterType(10000, TargetType.WhitePhantom)));
    if (!ThisEventSlot()) {
        ForceAnimationPlayback(13000495, 3029, false, false, false);
    } else {
        ForceAnimationPlayback(13000495, 20002, false, false, false);
    }
    SetThisEventSlot(ON);
    WaitFixedTimeSeconds(2);
    EndIf(InArea(10000, 13002495) || EventFlag(13000495));
    if (EventFlag(50)) {
        ShootBullet(13000610, 13002610, -1, 803000000, 0, 0, 0);
    }
    if (EventFlag(51)) {
        ShootBullet(13000610, 13002610, -1, 803000010, 0, 0, 0);
    }
    if (EventFlag(52)) {
        ShootBullet(13000610, 13002610, -1, 803000020, 0, 0, 0);
    }
    if (EventFlag(53)) {
        ShootBullet(13000610, 13002610, -1, 803000030, 0, 0, 0);
    }
    if (EventFlag(54)) {
        ShootBullet(13000610, 13002610, -1, 803000040, 0, 0, 0);
    }
    if (EventFlag(55)) {
        ShootBullet(13000610, 13002610, -1, 803000050, 0, 0, 0);
    }
    if (EventFlag(56)) {
        ShootBullet(13000610, 13002610, -1, 803000060, 0, 0, 0);
    }
    if (EventFlag(57)) {
        ShootBullet(13000610, 13002610, -1, 803000070, 0, 0, 0);
    }
    WaitFixedTimeSeconds(1.5);
    EndIf(InArea(10000, 13002495) || EventFlag(13000495));
    if (EventFlag(50)) {
        ShootBullet(13000620, 13002620, -1, 803000000, 0, 0, 0);
    }
    if (EventFlag(51)) {
        ShootBullet(13000620, 13002620, -1, 803000010, 0, 0, 0);
    }
    if (EventFlag(52)) {
        ShootBullet(13000620, 13002620, -1, 803000020, 0, 0, 0);
    }
    if (EventFlag(53)) {
        ShootBullet(13000620, 13002620, -1, 803000030, 0, 0, 0);
    }
    if (EventFlag(54)) {
        ShootBullet(13000620, 13002620, -1, 803000040, 0, 0, 0);
    }
    if (EventFlag(55)) {
        ShootBullet(13000620, 13002620, -1, 803000050, 0, 0, 0);
    }
    if (EventFlag(56)) {
        ShootBullet(13000620, 13002620, -1, 803000060, 0, 0, 0);
    }
    if (EventFlag(57)) {
        ShootBullet(13000620, 13002620, -1, 803000070, 0, 0, 0);
    }
    if (EventFlag(50)) {
        ShootBullet(13000621, 13002621, -1, 803000000, 0, 0, 0);
    }
    if (EventFlag(51)) {
        ShootBullet(13000621, 13002621, -1, 803000010, 0, 0, 0);
    }
    if (EventFlag(52)) {
        ShootBullet(13000621, 13002621, -1, 803000020, 0, 0, 0);
    }
    if (EventFlag(53)) {
        ShootBullet(13000621, 13002621, -1, 803000030, 0, 0, 0);
    }
    if (EventFlag(54)) {
        ShootBullet(13000621, 13002621, -1, 803000040, 0, 0, 0);
    }
    if (EventFlag(55)) {
        ShootBullet(13000621, 13002621, -1, 803000050, 0, 0, 0);
    }
    if (EventFlag(56)) {
        ShootBullet(13000621, 13002621, -1, 803000060, 0, 0, 0);
    }
    if (EventFlag(57)) {
        ShootBullet(13000621, 13002621, -1, 803000070, 0, 0, 0);
    }
    WaitFixedTimeSeconds(1.5);
    EndIf(InArea(10000, 13002495) || EventFlag(13000495));
    if (EventFlag(50)) {
        ShootBullet(13000630, 13002630, -1, 803000000, 0, 0, 0);
    }
    if (EventFlag(51)) {
        ShootBullet(13000630, 13002630, -1, 803000010, 0, 0, 0);
    }
    if (EventFlag(52)) {
        ShootBullet(13000630, 13002630, -1, 803000020, 0, 0, 0);
    }
    if (EventFlag(53)) {
        ShootBullet(13000630, 13002630, -1, 803000030, 0, 0, 0);
    }
    if (EventFlag(54)) {
        ShootBullet(13000630, 13002630, -1, 803000040, 0, 0, 0);
    }
    if (EventFlag(55)) {
        ShootBullet(13000630, 13002630, -1, 803000050, 0, 0, 0);
    }
    if (EventFlag(56)) {
        ShootBullet(13000630, 13002630, -1, 803000060, 0, 0, 0);
    }
    if (EventFlag(57)) {
        ShootBullet(13000630, 13002630, -1, 803000070, 0, 0, 0);
    }
    if (EventFlag(50)) {
        ShootBullet(13000631, 13002631, -1, 803000000, 0, 0, 0);
    }
    if (EventFlag(51)) {
        ShootBullet(13000631, 13002631, -1, 803000010, 0, 0, 0);
    }
    if (EventFlag(52)) {
        ShootBullet(13000631, 13002631, -1, 803000020, 0, 0, 0);
    }
    if (EventFlag(53)) {
        ShootBullet(13000631, 13002631, -1, 803000030, 0, 0, 0);
    }
    if (EventFlag(54)) {
        ShootBullet(13000631, 13002631, -1, 803000040, 0, 0, 0);
    }
    if (EventFlag(55)) {
        ShootBullet(13000631, 13002631, -1, 803000050, 0, 0, 0);
    }
    if (EventFlag(56)) {
        ShootBullet(13000631, 13002631, -1, 803000060, 0, 0, 0);
    }
    if (EventFlag(57)) {
        ShootBullet(13000631, 13002631, -1, 803000070, 0, 0, 0);
    }
    WaitFixedTimeSeconds(0.9);
    EndIf(InArea(10000, 13002495) || EventFlag(13000495));
    ForceAnimationPlayback(13000495, 30000, false, false, false);
    if (!(InArea(10000, 13002495) || EventFlag(13000495))) {
        WaitFixedTimeSeconds(1);
        if (!(InArea(10000, 13002495) || EventFlag(13000495))) {
            WaitFixedTimeSeconds(1);
            if (!(InArea(10000, 13002495) || EventFlag(13000495))) {
                WaitFixedTimeSeconds(1);
                if (!(InArea(10000, 13002495) || EventFlag(13000495))) {
                    WaitFixedTimeSeconds(1);
                    if (!(InArea(10000, 13002495) || EventFlag(13000495))) {
                        WaitFixedTimeSeconds(1);
                        areaFlag = InArea(10000, 13002495) || EventFlag(13000495);
                        WaitFixedTimeSeconds(1);
                    }
                }
            }
        }
    }
L0:
    RestartEvent();
});

// NPC202_マリケス_会話処理限界延長 -- NPC202_Marikes_Conversation processing limit extension
$Event(13003700, Restart, function() {
    EndIf(!PlayerIsInOwnWorld());
    WaitFor(EventFlag(13002805));
    SetCharacterTalkRange(13000801, 100);
    SetCharacterTalkRange(13000800, 100);
    EndEvent();
});

// 壺マイヤー_NPC初期化イベント_最後の戦い -- Tsubo Meyer_NPC initialization event_Last battle
$Event(13003710, Restart, function(chrEntityId) {
    WaitFixedTimeFrames(1);
    DisableNetworkSync();
    if (PlayerIsInOwnWorld()) {
        if (EventFlag(3660)) {
            SetEventFlagID(1043399303, OFF);
        }
    }
L19:
    if (!EventFlag(3671)) {
        DisableCharacter(chrEntityId);
        SetCharacterBackreadState(chrEntityId, true);
        DisableCharacter(13000701);
        EnableCharacter(13000702);
        if (EventFlag(13000702)) {
            DisableCharacter(13000702);
        }
        WaitFor(EventFlag(3671));
        RestartEvent();
    }
L6:
    SetEventFlagID(13002710, ON);
    GotoIf(L4, EventFlag(13009257));
    GotoIf(L1, EventFlag(3660));
    GotoIf(L2, EventFlag(3661));
    GotoIf(L4, EventFlag(3663));
L1:
    EnableCharacter(chrEntityId);
    SetCharacterBackreadState(chrEntityId, false);
    ForceAnimationPlayback(chrEntityId, 930010, false, false, false);
    if (EventFlag(13009258)) {
        ForceAnimationPlayback(chrEntityId, 930014, false, false, false);
    }
    DisableCharacter(13000701);
    ForceAnimationPlayback(13000701, 10001, false, false, false);
    DisableCharacter(13000702);
    Goto(L20);
L2:
    SetCharacterBackreadState(chrEntityId, false);
    EnableCharacter(chrEntityId);
    SetCharacterTeamType(chrEntityId, TeamType.HostileNPC);
    DisableCharacter(13000701);
    DisableCharacter(13000702);
    Goto(L20);
L4:
    ForceCharacterTreasure(chrEntityId);
    DisableCharacter(chrEntityId);
    SetCharacterBackreadState(chrEntityId, true);
    DisableCharacter(13000701);
    DisableCharacter(13000702);
    Goto(L20);
L20:
    WaitFor(!EventFlag(3671));
    RestartEvent();
});

// 壺マイヤー_最後の戦い -- Tsubomayer_The Last Battle
$Event(13003711, Restart, function(chrEntityId) {
    EndIf(!PlayerIsInOwnWorld());
    WaitFor(EventFlag(3671) && EventFlag(13009256));
    SetCharacterTalkRange(chrEntityId, 200);
    if (EventFlag(13009258)) {
        flagHp &= EventFlag(13009258) && !EventFlag(13009257);
        GotoIf(L2, flagHp);
        flag &= EventFlag(13009258) && EventFlag(13009257);
        GotoIf(L3, flag);
    }
L1:
    SetCharacterTeamType(chrEntityId, TeamType.HostileNPC);
    EnableCharacterAI(chrEntityId);
    EnableCharacterImmortality(chrEntityId);
    BatchSetNetworkconnectedEventFlags(3660, 3663, OFF);
    SetNetworkconnectedEventFlagID(3662, ON);
    SetEventFlagID(400175, ON);
    flagHp &= CharacterHPValue(chrEntityId) == 1;
    WaitFor(flagHp);
    SetNetworkconnectedEventFlagID(13002712, ON);
    ForceAnimationPlayback(chrEntityId, 20035, false, false, false);
L2:
    DisableCharacterAI(chrEntityId);
    BatchSetNetworkconnectedEventFlags(3660, 3663, OFF);
    SetNetworkconnectedEventFlagID(3660, ON);
    SetCharacterTeamType(chrEntityId, TeamType.Disabled);
    flag &= EventFlag(13009257);
    WaitFor(flag);
    SetCharacterTeamType(chrEntityId, TeamType.FriendlyNPC);
    DisableCharacterImmortality(chrEntityId);
    WaitFor(
        EventFlag(13009260)
            || HasDamageType(chrEntityId, 10000, DamageType.Unspecified)
            || CharacterDead(chrEntityId));
    if (!CharacterDead(chrEntityId)) {
        ForceCharacterDeath(chrEntityId, true);
    }
    AwardItemLot(101740);
L3:
    if (!EventFlag(400174)) {
        SetEventFlagID(13009254, ON);
    }
    BatchSetNetworkconnectedEventFlags(3660, 3663, OFF);
    SetNetworkconnectedEventFlagID(3663, ON);
    EndEvent();
});

// NPC326_火山館最強の騎士_闇霊侵入許可フラグ立て -- NPC326_Volcano Pavilion's Strongest Knight_Dark Spirit Intrusion Permission Flag Set
$Event(13003720, Restart, function() {
    WaitFixedTimeFrames(1);
    SetEventFlagID(13009300, OFF);
    EndIf(!EventFlag(16009460) && !EventFlag(3883));
    SetEventFlagID(13009300, ON);
    EndEvent();
});

// NPC326_火山館最強の騎士_白霊共闘許可フラグ立て -- NPC326_Volcano Pavilion's Strongest Knight_White Spirit Collaboration Permission Flag Raised
$Event(13003721, Default, function() {
    EndIf(!PlayerIsInOwnWorld());
    WaitFixedTimeFrames(1);
    EndIf(EventFlag(13002720) || EventFlag(13002721));
    EndIf(EventFlag(13000850));
    EndIf(!EventFlag(3880));
    area = EntityInRadiusOfEntity(10000, 13002721, 10, 1);
    WaitFor(area || EntityInRadiusOfEntity(10000, 13002726, 10, 1));
    GotoIf(L1, area.Passed);
    Goto(L2);
L1:
    SetEventFlagID(13002720, ON);
    SetEventFlagID(13002721, OFF);
    EndEvent();
L2:
    SetEventFlagID(13002720, OFF);
    SetEventFlagID(13002721, ON);
    EndEvent();
});


