So I made a skill that allows the player to call a random encounter and it works great on the world map where there are random encounters. The problem I'm having is on inside maps like dungeons and caves where I don't have random encounters, I made some random encounters with a 0 weight, because I don't the encounters to actually happen as I have on map enemies there. However, because they are 0 weight the battle processing calling a random encounter wont work there. Is there an alternative way of calling the random encounters, that will allow this to work in those areas?
Trying to adjust an enemy call skill
RPG Maker MZ SupportIf the map has no random encounters you need to define a pool of troops then have a script randomly pick a number from that pool and create a battle.
This worked for me although I only tried two different troops
This worked for me although I only tried two different troops
The problem is I need it to call from random encounter list for the map. There is no way i could create the lists for all the maps i would need to generate a random number for. On the same skill.
Then you would fill the troopPool array with variables that reference the encounter list for the current map.
Or do a branching condition:
If the map HAS a encounter list, do your default skill function
Else, use my function (when the map doesn't have random encounters)
Or do a branching condition:
If the map HAS a encounter list, do your default skill function
Else, use my function (when the map doesn't have random encounters)
what if you added the random encounter troops to your no-encounter maps with normal weight, but then whenever the player transfers to this map, you set the encounter rate to 0%?
Ah ok. Im still not good at arrays. Ill have to look that up.
@TESTOSTERONE I just tried that and it didnt engage the encounter.
EDIT:
I was able to make it work with a switch and a small plugin:
@TESTOSTERONE @AquaEcho
Thanks for the inspirations! There was one factor I forgot, the conditions of the random battles. This way it will still do the conditions check (like region restricion) mostly when on the world map.
@TESTOSTERONE I just tried that and it didnt engage the encounter.
EDIT:
I was able to make it work with a switch and a small plugin:
Game_Player.prototype.makeEncounterTroopId = function() {
const encounterList = [];
let weightSum = 0;
for (const encounter of $gameMap.encounterList()) {
if (this.meetsEncounterConditions(encounter)) {
encounterList.push(encounter);
weightSum += encounter.weight;
}
}
if (weightSum > 0) {
let value = Math.randomInt(weightSum);
for (const encounter of encounterList) {
value -= encounter.weight;
if (value < 0) {
return encounter.troopId;
}
}
}
if (weightSum == 0 && $gameSwitches.value(15) == true) { //Added this If statement.
let value = Math.randomInt(weightSum);
for (const encounter of encounterList) {
value -= encounter.weight;
if (value == 0) {
return encounter.troopId;
}
}
}
return 0;
};
@TESTOSTERONE @AquaEcho
Thanks for the inspirations! There was one factor I forgot, the conditions of the random battles. This way it will still do the conditions check (like region restricion) mostly when on the world map.
Original thread: https://forums.rpgmakerweb.com/threads/trying-to-adjust-an-enemy-call-skill.158344/