Re: Generalized random battle implementation?
Reply #4 –
Triggers or zones. That's what I figured. Which requires the actual code that tests for a battle to be put into each map's script. Obviously analogue.js makes that task easier, but it's still code duplication, which I wanted to avoid. What I want to do is to be able to initialize my RandomBattles singleton once, and have the logic follow the player around regardless of what map they go to. Literally the only code that I want to have to put into a map script is when the map is loaded, to set the enemies that can appear and various area-specific parameters like encounter rate, etc. The RandomBattles singleton should ideally handle all the testing for a battle and triggering the battle engine itself without any additional code in the map script. Obviously things like zones can be used to customize encounter rate, etc. for different parts of a map, but I don't want to have to make triggers on every single map to test for a battle.
In pseudocode, what I want is this:
As part of one-time initialization:
CreatePerson("Player", "hero.rss", false); // persistent entity representing player's sprite
RandomBattles.initialize();
RandomBattles.attach("Player");
And then on map load:
RandomBattles.setEnemies( /*...*/ );
RandomBattles.setEncounterRate(whatever);
Long story short, I want the RandomBattles object to handle all the battle testing, etc., after just a single call to .attach() and no other code required in a map script other than the initialization listed above. Is this possible?