- Joined
- Oct 3, 2012
- Messages
- 130
- Reaction score
- 28
- First Language
- english
- Primarily Uses
- RMMZ
Hi there! I'm currently attempting to develop a plugin that would allow me to use images during battles, instead of relying on face sets that are tied to the actor's ID. I'm struggling with the coding aspect of it and was hoping someone could lend a hand in making sense of it or even assist me in creating it. Any help would be greatly appreciated!
// Define a function to load and display a picture based on actor class ID.
function showPictureByClassId(classId, x, y, pictureName) {
var actor = $gameParty.members().find(function(actor) {
return actor.currentClass().id === classId;
});
if (actor) {
var pictureId = $gameScreen.showPicture(-1, pictureName, 0, x, y, 100, 100, 255, 0);
actor.setPictureId(pictureId); // Store the picture ID on the actor for reference.
}
}
// Define a function to remove a picture associated with an actor.
function removePictureByActor(actor) {
if (actor && actor.pictureId !== undefined) {
$gameScreen.erasePicture(actor.pictureId);
actor.pictureId = undefined;
}
}
// Extend the Game_Actor class to store the picture ID associated with each actor.
Game_Actor.prototype.initialize = function(actorId) {
// ... Existing code ...
this.pictureId = undefined; // Initialize the picture ID property.
};
// Extend the BattleManager class to handle picture display and removal during battle.
var _BattleManager_startBattle = BattleManager.startBattle;
BattleManager.startBattle = function() {
_BattleManager_startBattle.call(this);
// Iterate through the party members and display pictures based on class IDs.
$gameParty.members().forEach(function(actor) {
showPictureByClassId(actor.currentClass().id, 100, 100, "PictureName"); // Change "PictureName" to your picture filename.
});
};
var _BattleManager_endBattle = BattleManager.endBattle;
BattleManager.endBattle = function(result) {
_BattleManager_endBattle.call(this, result);
// Iterate through the party members and remove pictures associated with them.
$gameParty.members().forEach(function(actor) {
removePictureByActor(actor);
});
};
// Define a function to load and display a picture based on actor class ID.
function showPictureByClassId(classId, x, y, pictureName) {
var actor = $gameParty.members().find(function(actor) {
return actor.currentClass().id === classId;
});
if (actor) {
var pictureId = $gameScreen.showPicture(-1, pictureName, 0, x, y, 100, 100, 255, 0);
actor.setPictureId(pictureId); // Store the picture ID on the actor for reference.
}
}
// Define a function to remove a picture associated with an actor.
function removePictureByActor(actor) {
if (actor && actor.pictureId !== undefined) {
$gameScreen.erasePicture(actor.pictureId);
actor.pictureId = undefined;
}
}
// Extend the Game_Actor class to store the picture ID associated with each actor.
Game_Actor.prototype.initialize = function(actorId) {
// ... Existing code ...
this.pictureId = undefined; // Initialize the picture ID property.
};
// Extend the BattleManager class to handle picture display and removal during battle.
var _BattleManager_startBattle = BattleManager.startBattle;
BattleManager.startBattle = function() {
_BattleManager_startBattle.call(this);
// Iterate through the party members and display pictures based on class IDs.
$gameParty.members().forEach(function(actor) {
showPictureByClassId(actor.currentClass().id, 100, 100, "PictureName"); // Change "PictureName" to your picture filename.
});
};
var _BattleManager_endBattle = BattleManager.endBattle;
BattleManager.endBattle = function(result) {
_BattleManager_endBattle.call(this, result);
// Iterate through the party members and remove pictures associated with them.
$gameParty.members().forEach(function(actor) {
removePictureByActor(actor);
});
};