在新窗口中打开脚本页

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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//=============================================================================
// VIPArcher_Character_Animations.js
//=============================================================================
/*:
* @plugindesc Extended character animation setting, including 8-direction walking animation/ (4/8-direction) running animation / standby animation/ character animations with more than 4 frames
* @author VIPArcher
*
* @param Dir8_Flag
* @desc Symbol used to activate this plugin on the image file
* @default %
*
* @param Frames_Flag
* @desc Symbol used before numbers to show the frame number of the image file
* @default #
*
* @param Stand_Wait
* @desc How many frame numbers with no action in the map needed to activate the standby animation
* @default 60
*
* @help Put the first symbol (default symbol: % or what you set) in the front of the image's filename if the image needs to follow this plugin's setting.
* Image file naming standard (with the default symbol):
* %FILENAME.png -> FILENAME should be replaced with your own character's name
* eg: %VIPArcher.png ->replace 'VIPArcher' with your character's name
* By default, the image file will be arranged into 2 rows and 4 columns equaling 8 images.
* ----------------------------------------------------------------
* Normal | Normal | Normal |
* 4-dir | 4-dir | 4-dir |
* walking | running | standby | EMPTY
* image | image | image |
* ----------------------------------------------------------------
* Extra | Extra | Extra |
* 8-dir | 8-dir | 8-dir |
* walking | running | standby | EMPTY
* image | image | image |
* ----------------------------------------------------------------
* ADDITIONAL:
* If your character animation image is more than 3 frames in every direction, put the second symbol (default symol: #) with two numbers to customize it.
* Image file naming standard (with all default symbols):
* %FILENAME#NO1,NO2.png ->replace NO1 with the frame number that your image has in every direction
* ->replace NO2 with the frame that the character shows when fixed
* eg: %VIPArcher#6,3.png ->it means every image of 8 images in this file has 6 frames in every direction, and the default frame to show the fixed character is the 3rd one
*/
(function() {
var parameters = PluginManager.parameters('VIPArcher_Character_Animations');
var dir8_flag = String(parameters['Dir8_Flag'] || '%' );
var stand_wait = String(parameters['Stand_Wait'] || '60');
var frame_flag = String(parameters['Frames_Flag'] || '#' );
ImageManager.isDir8Character = function(filename) {
var reg = new RegExp("^\[\\!\\$\\" + dir8_flag + ']+');
var sign = filename.match(reg);
return sign && sign[0].contains(dir8_flag);
};
var _Game_CharacterBaseinitMembers = Game_CharacterBase.prototype.initMembers;
Game_CharacterBase.prototype.initMembers = function() {
_Game_CharacterBaseinitMembers.call(this);
this._standWait = 0;
this._isStand = false;
this._isDir8Character = false;
};
var _Game_CharacterBasesetImage = Game_CharacterBase.prototype.setImage;
Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
_Game_CharacterBasesetImage.call(this, characterName, characterIndex);
this.getCharacterMaxFrame(characterName);
if (ImageManager.isDir8Character(characterName)) {
this._characterIndex = 0;
this._isDir8Character = true;
}
};
var _Game_CharacterBaseupdate = Game_CharacterBase.prototype.update;
Game_CharacterBase.prototype.update = function() {
_Game_CharacterBaseupdate.call(this);
if (this.isMoving()) {
this._standWait = 0;
this._isStand = false;
if (this._isDir8Character) { this._stepAnime = false };
} else {
this._standWait += 1;
if (this._standWait > parseInt(stand_wait)) {
this._isStand = true;
if (this._isDir8Character) { this._stepAnime = true };
}
}
};
var _Game_CharacterBasemoveDiagonally = Game_CharacterBase.prototype.moveDiagonally;
Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
_Game_CharacterBasemoveDiagonally.call(this, horz, vert);
if (horz > 5) {
vert > 5 ? this.setDirection(9) : this.setDirection(7);
} else {
vert > 5 ? this.setDirection(3) : this.setDirection(1);
}
};
Game_CharacterBase.prototype.getCharacterMaxFrame = function(characterName) {
var framedate = characterName.match(new RegExp(frame_flag + "(\\d+),(\\d+)"));
if (framedate) {
this._maxFrame = parseInt(framedate[1]);
this._formerPattern = parseInt(framedate[2]);
} else{
this._maxFrame = 3;
this._formerPattern = 1;
}
};
Game_CharacterBase.prototype.pattern = function() {
return this._pattern < this.maxFrame() ? this._pattern : 1;
};
Game_CharacterBase.prototype.maxFrame = function() {
return this._maxFrame;
};
Game_CharacterBase.prototype.maxPattern = function() {
if (this._maxFrame === 3) {
return 4;
} else {
return this._maxFrame;
}
};
Game_CharacterBase.prototype.isOriginalPattern = function() {
return this.pattern() === this._formerPattern;
};
Game_CharacterBase.prototype.resetPattern = function() {
this.setPattern(this._formerPattern);
};
Game_CharacterBase.prototype.isFast = function() {
return this._standWait < 2 && (this.isDashing() || this._moveSpeed > 4);
};
Game_CharacterBase.prototype.isStand = function() {
return this._isStand;
};
Game_CharacterBase.prototype.setCharacterIndex = function(index) {
this._characterIndex = index;
};
Game_Player.prototype.moveByInput = function() {
if (!this.isMoving() && this.canMove()) {
var direction = Input.dir8;
if (direction > 0) {
$gameTemp.clearDestination();
} else if ($gameTemp.isDestinationValid()){
var x = $gameTemp.destinationX();
var y = $gameTemp.destinationY();
direction = this.findDirectionTo(x, y);
}
if (direction > 0) {
if (direction % 2 == 0){
this.moveStraight(direction);
return;
}
if (direction < 5){
this.moveDiagonally(direction + 3 , 2);
} else {
this.moveDiagonally(direction - 3 , 8);
}
}
}
};
var _Game_PlayermoveDiagonally = Game_Player.prototype.moveDiagonally;
Game_Player.prototype.moveDiagonally = function(horz, vert) {
if (!this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
this.setMovementSuccess(false);
return;
}
if (this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
this.moveStraight(horz);
return;
}
if (this.canPass(this._x, this._y, vert) && !this.canPass(this._x, this._y, horz)){
this.moveStraight(vert);
return;
}
if (!this.canPassDiagonally(this._x, this._y, horz, vert)) {
if (Math.random() > 0.5){
this.setDirection(vert); this.moveStraight(vert);
} else {
this.setDirection(horz); this.moveStraight(horz);
}
return;
}
_Game_PlayermoveDiagonally.call(this, horz, vert);
};
Sprite_Character.prototype.characterPatternY = function() {
if (this._character.direction() % 2 == 0){
if (this._character._isDir8Character){
this._character.setCharacterIndex(this._character.isFast() ? 1 : this._character.isStand() ? 2 : 0);
}
return (this._character.direction() - 2) / 2;
} else {
if (this._character._isDir8Character){
this._character.setCharacterIndex(this._character.isFast() ? 5 : this._character.isStand() ? 6 : 4);
}
return parseInt((this._character.direction() + 1) / 3);
}
};
Sprite_Character.prototype.patternWidth = function() {
if (this._tileId > 0) {
return $gameMap.tileWidth();
} else if (this._isBigCharacter) {
return this.bitmap.width / this._character.maxFrame();
} else {
return this.bitmap.width / (this._character.maxFrame() * 4);
}
};
Sprite_Character.prototype.characterBlockX = function() {
if (this._isBigCharacter) {
return 0;
} else {
var index = this._character.characterIndex();
return (index % 4) * this._character.maxFrame();
}
};
})();

文章目录