Hello again
@RCXGaming
As discussed, I'll show how to, with a few tweaks to the code, add popups to show states addition and removal. This is just to display the state names as a string with a + or - sign in front to show if the state is added or removed. You're free to edit it as you like afterward; I'm just showing the basic process.
1)
add some methods to Game_ActionResult
Simply add these methods somewhere in the plugin.
Code:
//== Game_ActionResult ================================
Game_ActionResult.prototype.isStateChanged = function() {
return (
this.addedStates.length > 0 ||
this.removedStates.length > 0
);
};
Game_ActionResult.prototype.damageAffected = function() {
return (
this.hpDamage ||
this.mpDamage ||
this.tpDamage
);
};
2)
Edit Game_Battler.prototype.startDamagePopup
Find the method in the plugin and add last part:
Code:
if (Imported.YEP_BattleEngineCore) {
Game_Battler.prototype.startDamagePopup = function() {
var result = this.result();
if (result.missed || result.evaded) {
var copyResult = JsonEx.makeDeepCopy(result);
copyResult.hpAffected = false;
copyResult.mpDamage = 0;
this._damagePopup.push(copyResult);
}
if (result._StateResistRequest && !result.hpAffected) {
var copyResult = JsonEx.makeDeepCopy(result);
this._damagePopup.push(copyResult);
}
if (result.tpDamage !== 0) {
var copyResult = JsonEx.makeDeepCopy(result);
copyResult.hpAffected = false;
copyResult.mpDamage = 0;
this._damagePopup.push(copyResult);
}
if (result.mpDamage !== 0) {
var copyResult = JsonEx.makeDeepCopy(result);
copyResult.hpAffected = false;
copyResult.tpDamage = 0;
this._damagePopup.push(copyResult);
}
if (result.hpAffected) {
var copyResult = JsonEx.makeDeepCopy(result);
copyResult.mpDamage = 0;
this._damagePopup.push(copyResult);
}
/// ADD THIS PART ///////
if (result.isStateChanged() && !result.damageAffected()) {
var copyResult = JsonEx.makeDeepCopy(result);
this._damagePopup.push(copyResult);
}
////////////////////////
};
};
*this is to create a popup even if the action doesn't have a damage type.
3)
Edit Sprite_Damage.prototype.setup
Find the method and to the following change:
Code:
if (Imported.YEP_BattleEngineCore) {
Sprite_Damage.prototype.setup = function(target) {
this._result = target.shiftDamagePopup();
let result = this._result;
let dam = result.tpDamage || 0;
let damm = result.mpDamage || 0;
let critical = result.critical;
let overkill = this.CheckOverkill(target, result)
let alive = target.isAlive() && target.hp > 0;
if (result.missed || result.evaded) {
if (TSR.Popups.sheet_enable || TSR.Popups.string_enable) {
this.createEffects('miss');
} else {
this.createMiss();
}
} else {
///////// THIS IS THE PART TO CHANGE /////////////
if (this.isStateElementVisible(critical, overkill) && alive) {
if (result._StateResistRequest && TSR.Popups.state_show) {
this.createEffects('state');
}
if (result.isStateChanged()) {
const changedStates = [];
for (const as of result.addedStates) {
changedStates.push([as, true]);
}
for (const rs of result.removedStates) {
changedStates.push([rs, false]);
}
this.createEffects('state', changedStates.sort((a, b) => a[0] - b[0]));
}
}
///////////////////////////////////////
if (result.hpAffected) {
this...... ////
*The state add/remove popups use the same condition than the state resist (action is not a critical hit, not an overkill and target is still alive). But they are created independently from the resist popup and will appear even if the state resist popup is disabled with the plugin parameter.
Basically, the added and removed states are pushed in the changedStates array as smal arrays with first entry being the state Id, and second entry is true if state was added and false if the state was removed.
Then the changedStates array is send to the createEffect method as a second arguments.
4)
Edit Sprite_Damage.prototype.createEffects
Code:
Sprite_Damage.prototype.createEffects = function(info, chgStates) {
let w = this.digitWidth(),
h = this.digitHeight(),
col = TSR.Popups.effectInfo[info].col,
row = TSR.Popups.effectInfo[info].row,
wid = TSR.Popups.effectInfo[info].wid,
string = TSR.Popups.effectInfo[info].string,
enableString = TSR.Popups.effectInfo[info].enb;
if (chgStates) {
for (let s = 0; s < chgStates.length; s++) {
const prefix = chgStates[s][1] ? '+' : '-';
string = prefix + $dataStates[chgStates[s][0]].name;
info = chgStates[s][1] ? 'addedState' : 'removedState'
for (var i = 0; i < string.length; i++) {
let sprite = this.createStringChildSprite(string[i], 0, info);
let w = sprite.bitmap.measureTextWidth(string[i])
sprite.x = (i - (string.length - 1) / 2) * w;
sprite.anchor.y -= 0.5 * s;
sprite.dy = -i;
}
}
} else {
if (!enableString) {
if (TSR.Popups.sheet_enable) {
let sprite = this.createChildSprite(info);
sprite.setFrame(col * w, row * h, wid * w, h);
sprite.dy = 0;
}
} else if (string) {
for (var i = 0; i < string.length; i++) {
let sprite = this.createStringChildSprite(string[i], 0, info);
let w = sprite.bitmap.measureTextWidth(string[i])
sprite.x = (i - (string.length - 1) / 2) * w;
sprite.dy = -i;
}
}
}
};
Don't forget to add the second argument chgStates. Make the conditional branch that check if chgStates exist and in the Else part, you paste the 'default' code.
When chgStates is defined (true) the code above will create an popup for each of the added and removed states, with a + or - in front accordingly. Note that the sprite.anchor.y is increased for each states so the states popups won't overlap and will stack down.
Also the info value is changed to 'added/removedState' so the popup type can be recognized in further methods.
5) Edit Sprite_Damage.prototype.createStringChildSprite
Code:
Sprite_Damage.prototype.createStringChildSprite = function(string, row, info) {
let color;
if (TSR.Popups.digitInfo[info]) {
color = (row === 0 || row === 2 || row === 5)?
TSR.Popups.digitInfo[info].damage.color || '':
TSR.Popups.digitInfo[info].recovery.color || '';
} else if (TSR.Popups.effectInfo[info]) {
color = TSR.Popups.effectInfo[info].color || '';
} else {
color = '';
}
let fontSize = TSR.Popups.string_fontSize;
let pad = fontSize * 0.36;
let height = fontSize + pad;
let sprite = new Sprite(new Bitmap(190, height));
sprite.bitmap.fontSize = fontSize;
sprite.bitmap.fontFace = TSR.Popups.string_fontFace || 'GameFont';
sprite.bitmap.textColor = this.getPopupDefaultColor(row, info)
sprite.bitmap.outlineColor = '#000000';
sprite.bitmap.outlineWidth = 5;
sprite.anchor.x = 0;
sprite.anchor.y = this.getAnchor(info);
sprite.y = -1 * TSR.Popups.popup_drop;
sprite.ry = sprite.y;
sprite.bitmap.drawText(color + string, 10, 0, 200, height);
this.addChild(sprite);
return sprite;
};
Here, only the top conditionnal is to be changed because 'added/removedState' isn't declared in the digitInfo and effectInfo objects.
6)
Edit Sprite_Damage.prototype.getPopupDefaultColor and
Sprite_Damage.prototype.getAnchor
Code:
Sprite_Damage.prototype.getPopupDefaultColor = function(row, info) {
if (info === 'mp') {
return (row === 0 || row === 2 || row === 5)? '#E9967a' : '#ba55d3';
} else if (info === 'tp') {
return (row === 0 || row === 2 || row === 5)? '#f0e68c' : '#87cefa';
} else if (info === 'critical') {
return '#ff4500';
} else if (info === 'overkill') {
return '#ffa500';
} else if (info === 'immune') {
return '#ba55d3';
} else if (info === 'resist') {
return '#3cb371';
} else if (info === 'weak') {
return '#f0e68c';
} else if (info === 'addedState') {
return '#ccffcc';
} else if (info === 'removedState') {
return '#ffcccc';
} else {
return (row % 2 === 0)? '#ffffff' : '#7fff00';
}
};
Sprite_Damage.prototype.getAnchor = function(info) {
let anc = TSR.Popups.popup_anchor;
let anchor = 1;
let result = this._result;
if (info === 'mp') {
if (result.ReceivedHpDamage && !Imported.YEP_BattleEngineCore) anchor += anc;
} else if (info === 'tp') {
if (result.ReceivedHpDamage && !Imported.YEP_BattleEngineCore) anchor += anc;
if (result.ReceivedMpDamage && !Imported.YEP_BattleEngineCore) anchor += anc;
} else if (info === 'critical' ||
info === 'resist' ||
info === 'weak' ||
info === 'immune' ) {
anchor -= anc;
} else if (info === 'overkill') {
anchor -= anc;
if (this._result.critical) anchor -= anc;
} else if (info.toLowerCase().includes('state')) {
anchor -= anc;
if (this._result._haveElementEffect) anchor -= anc;
}
return anchor;
};
Change the color of the added/removed state popups by adding a condition for both (optional).
For the anchor method, for now it use the same anchor point than the state resist popup, which mean that if you use it the popups might overlap if both condition occurs. But that can be a later fix if needed.
That's pretty much it. Hope you'll find that useful. This, of course if just the general process, once you got it to work, you can edit it to your liking.
Good luck.
Regards,
TSR