-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
RS_PutInSubPartyMembers.js
141 lines (124 loc) · 4.53 KB
/
RS_PutInSubPartyMembers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//================================================================
// RS_PutInSubPartyMembers.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2019 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @plugindesc This plugin allows you to add a extra party member when all of party members are dead <RS_PutInSubPartyMembers>
* @author biud436
*
* @param Extra Members Ids
* @type actor[]
* @desc Specify the extra party members.
* @default ["5","6","7","8"]
*
* @help
* Note that this plugin is possible to use in RPG Maker MV v1.5.1+ or more.
* ================================================================
* Version Log
* ================================================================
* 2019.01.26 (v1.0.0) - First Release.
*/
/*:ko
* @plugindesc 모든 파티원이 전투 불능일 때 추가 파티원이 즉시 투입됩니다. <RS_PutInSubPartyMembers>
* @author biud436
*
* @param Extra Members Ids
* @type actor[]
* @desc 추가 파티원을 설정하십시오.
* @default ["5","6","7","8"]
*
* @help
*
* ================================================================
* Version Log
* ================================================================
* 2019.01.26 (v1.0.0) - 공개
*/
var Imported = Imported || {};
Imported.RS_PutInSubPartyMembers = true;
var RS = RS || {};
RS.PutInSubPartyMembers = RS.PutInSubPartyMembers || {};
(function($) {
var parameters = $plugins.filter(function (i) {
return i.description.contains('<RS_PutInSubPartyMembers>');
});
parameters = (parameters.length > 0) && parameters[0].parameters;
$.jsonParse = function (str) {
var retData = JSON.parse(str, function (k, v) {
try { return $.jsonParse(v); } catch (e) { return v; }
});
return retData;
};
var extraMembers = $.jsonParse(parameters["Extra Members Ids"]);
//================================================================
// Game_Party
//================================================================
Game_Party.prototype.getMemberIds = function() {
var ids = $gameParty.members().map(function(i) {
return i.actorId();
});
return ids;
};
Game_Party.prototype.extraMembers = function() {
var members = this.getMemberIds().concat(extraMembers).map(function(id) {
return $gameActors.actor(id);
});
return members.filter(function(member) {
return member.isAlive();
});
};
Game_Party.prototype.isExtraMembersAllDead = function() {
return this.extraMembers().length === 0;
};
//================================================================
// BattleManager
//================================================================
var alias_BattleManager_initMembers = BattleManager.initMembers;
BattleManager.initMembers = function() {
alias_BattleManager_initMembers.call(this);
this.initExtraMembers();
};
BattleManager.initExtraMembers = function() {
// 추가 멤버 셋업
extraMembers.forEach(function(i) {
var actorId = i;
$gameActors.actor(actorId).setup(actorId);
});
this._isExtraMembers = false;
};
/**
* ! 턴 진행 중에 여분의 파티원을 투입합니다.
*/
var alias_BattleManager_updateTurn = BattleManager.updateTurn;
BattleManager.updateTurn = function() {
alias_BattleManager_updateTurn.call(this);
if($gameParty.isAllDead() && !this._isExtraMembers) {
$gameParty.getMemberIds().forEach(function(e, i, a) {
$gameParty.removeActor(e);
$gameParty.addActor(extraMembers[i]);
});
this._isExtraMembers = true;
}
};
/**
* ! 여분의 파티원까지 모두 Dead 상태일 때 전투가 종료 됩니다.
*/
BattleManager.checkBattleEnd = function() {
if (this._phase) {
if (this.checkAbort()) {
return true;
} else if ($gameParty.isAllDead() && $gameParty.isExtraMembersAllDead()) {
this.processDefeat();
return true;
} else if ($gameTroop.isAllDead()) {
this.processVictory();
return true;
}
}
return false;
};
})(RS.PutInSubPartyMembers);