I've been looking through SRPG_Core but I'm unsure what I should change. I'd appreciate some help!
This is hard. srpg_core does not store the last action of a unit (well it does, but wipes it once the exp screen is loaded) so its hard to check if the last action done by anyone is an item or not. Usually we would use $gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].currentAction() to check what action the active event is performing
Another issue is we can't tap into a pre-existing function to store the last action. srpg_core uses the this._actions = []; instead of the this.clearActions() function which means we can't even store the action by editing the clearActions function
So the only way to fix this is to store the action when it is made:
var _srpgMakeNewActions = Game_Battler.prototype.srpgMakeNewActions;
Game_Battler.prototype.srpgMakeNewActions = function () {
_srpgMakeNewActions.call(this);
if (this._actions.length > 0) {
console.log(this._actions);
this._previousAction = this._actions[0];
}
};
Now we have the action stored, we can edit BattleManager.makeRewards to check if the used action is an item or not, and if so alter BattleManager._rewards.exp = 0;
To check if an action is an item, I would use: $gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1]._previousAction._item._dataClass == "item"
Please, tell me, is it possible for one enemy to use several different target formulas with a certain chance?
Yeah... kind of. For example if you use the notetag: <aiTarget: Math.randomInt(20) + b.mhp>, the game will add "0-19" to the potential target's max hp and target the unit with the highest combined value. The issue is that targetScore is calculated for the size of $gameTemp.RangeMoveTable which means that this targetScore value is calculated many times for the same "target" (just at different positions) which means the randomness becomes less random.
You could change it to <aiTarget: Math.randomInt(20) > 10 ? b.mhp : 200 - b.mhp> which means about half of the time the target score will be higher if the target has maxHP and half the time the target score will be lower if the target has maxHP but again, because the targetScore function is calculated for every possible square in $gameTemp.RangeMoveTable, it means the targetScore is calculated several times, nullifying the "random" check.
The best way to circumvent this is to set a variable to a random value at the start of every turn (via an srpgEvent such as <type:afterAction> and then use the value of the variable as the "random variable". Doing this means that the random variable does not change when targetScore function is run and thus the result is always the same.
If the above doesn't make sense, here is an example:
Enemy A has two targets, X and Y
If we use <aiTarget: Math.randomInt(3)> then X and Y will have a targetScore between 0 and 2. An example calculation would be:
X: targetScore 0
X: targetScore 0
X: targetScore 1
X: targetScore 1
X: targetScore 0
X: targetScore 2
Y: targetScore 0
Y: targetScore 1
This results in X been selected as it has a targetScore of 2 (the highest). This is purely random and the targetScore changes for each iteration of $gameTemp.RangeMoveTable tile
If we use <aiTarget: $gameVariables.value(3) > 2 ? b.hp : 1> and have an <type:afterAction> event that runs a scriptCall: $gameVariables.setValue(3, Math.randomInt(5)), then there us a 40% chance the enemy A will target the unit with the highest HP, otherwise it will randomly select X or Y (as both will have target score of 1). In this scenario the calculation could be:
X: targetScore 43
X: targetScore 43
X: targetScore 43
X: targetScore 43
X: targetScore 43
X: targetScore 43
Y: targetScore 23
Y: targetScore 23
In this scenario, $gameVariables.value(3) > 2 is true, so the targetScore is set to X or Y's current HP. the targetScore is always calculated the same as $gameVariables.value(3) does not change when targetScore() is run.