- Initiating dialogues
- Altering the properties of battle actors
- Setting custom victory or defeat criteria
- Scripting of action animations and sounds
- Implementing enemy AI
There may be more things we need battle scripts to do now or in the future that I haven't thought of yet. I'm going to lay down my thoughts on how to design all this. Please provide feedback, especially if you think any of my design proposals are flawed or have a better idea in mind.
Specific Battle Scripts
Some of these features will be on a per-battle basis. For example, a boss battle may have custom dialogue and victory conditions. We do not want to nor need to do any sort of code sharing for this case, so we'll write a Lua script specifically for this one battle. I'll call these Specific Battle scripts, or SB scripts (can't think of a better name at the moment).
BattleMode will have a pointer to the Lua file representing the SB script. Most battles will just have this member set to NULL and ignore it. To set a SB script for a battle, the code creating the battle will need to call a specific method to instruct the BattleMode instance to open the SB file. SB scripts will be stored in a new directory: dat/battles/. File naming will try to be descriptive of which battle the script represents. For example, the first battle in the game (which may start off with some dialogue to introduce the player to the battle concepts) would be called "first_battle.lua". The first boss battle against the Goliath Scorpion would be "boss_goliath_scorpion.lua". I imagine we'll have a lot of "boss*" scripts to write.
The format of the SB script is pretty simple and familiar. It needs a Load(), Update(), and Draw() function defined. Other than that, there are no limits to the format of the file. These functions would be called during the battle's initialization, update, and draw functions, though I'm not certain exactly where in those functions those calls should/will be made yet. So for example, we may have a battle where if an enemy falls below 500HP, we want to start a screen shake effect and initiate a dialogue. In this script, the Load() function would construct the dialogue and prepare it. The Update() function would continually check the enemy's health to see if the 500HP condition has been met, and the draw function would do the screen shake effect for as long as is needed.
Common Battle Scripts
The other type of battle script is a common battle script, or CB scripts. These scripts contain individual functions that we want to make use of throughout different battles. Enemy AI and action animation are included in this category. Action animation is currently achieved through the BattleExecute() function for each skill and item in the script file. This, however, is not a long-term solution since the function may only be called once, and we can't implement custom animations to be done with only a single function call.
Enemy AI are functions that analyze the current state of the battle when an enemy is ready to select an action (when its finished with its idle state) and selects an appropriate action to take. Currently there is no AI, as enemies choose a random action and a random target each time. AI is something we'll need to approach in the future, but will be off the table for now. I also expect us to need to implement some AI algorithms that are specific to certain enemies (namely bosses), though I'm not sure if it would be better that all enemy AI be stored in the same location in a CB script, or if those special AI cases would better belong in SB scripts. Its not worth mulling over now though since we're still a long ways out from needing to make decisions about this.
Since I don't see the the uses of CB scripts being needed at this point, I'm not going to discuss them further here. But I did want to mention that I think in the future we'll need to make use of a second type of battle script and that the SB scripts that I believe we need to implement now do not need to consider this type of functionality.
The reason I'm bringing this topic up now is that I've been working on battle dialogues, and I think SB scripts are the best way to achieve that. We had battle dialogues working in the past, but I think you could only declare that the dialogue be at the beginning or end of the battle and it wasn't very flexible. This solution I'm proposing is a long-term one that I don't believe will need any changes. I'm going to be moving ahead with this plan so I can get dialogues implemented in the next week or two. But like I said I'm open to hearing suggested alternatives.