Hello everyone,
I'm working on a custom magic system for RPGmaker XP. The idea isn't completely unique but I'm building it from the ground up. What I'm looking for is input and advice on making it run smoothly.
The idea is this:
Player Bob has no magic spells. When Player Bob equips a Flame Orb, he learns the Fireball spell. When he unequips the Flame Orb he also loses his newly learned spell. Upon equipping a Frost Orb, he learns the appropriate ice-based spell and then loses it once he removes the orb. Party members can be customized by attaching different orbs according to the user's desire.
Another feature is that the orbs grow with the player. Once Player Bob reaches level 10, he not only gains the Fireball spell but also gains a Fireblast spell. Once unequipped, he loses both. If the Frost orb is equipped, he gets two spells at level 10 just like the Flame Orb. Each Orb grows differently, and new spells are gained for each level "milestone".
On to the code!
-------------
Since I have no experience with RGSS, I'm scripting this using a Common Event. My idea is to use a parallel process that checks if the player has any orbs equipped.
It would look like this:
The event checks if the Flame Orb is equipped, and grants the appropriate spells. The "else" case at the bottom removes the spells if the Flame Orb is not equipped.
Since I couldn't find a "If player's level = ?" conditional branch, I had to store the player's level into a variable and then check the variable for the proper spells to be learned. When I add more spells to the Orbs, it will check for levels 10, 20, 30 and so on. It's easily adjustable if needed.
If more orbs need to be added, it's a simple copy+paste as long as you change the Orb type and the spells learned/unlearned.
However, there are some flaws with my code that I need help with!
--------------
Upon entering the menu to equip/unequip spells, I noticed that the character will only learn/unlearn after you exit and re-enter the menu. It would be nice if it was instant, but the Common Event only checks the orbs if you're outside of the menu. Probably not a big deal, but it would be nice to find a way to make it instantly change.
If, for example, I was going to use 5 elements I would have to make the event check for 5 different orbs. If I had 4 party members, it would have to check for 5 orbs for 4 party members. This means it's checking for 20 orbs at all times. The only way I could think to make this work was with a parallel process, which could eat up CPU resources. If you're running a big map with a lot of moving parts, the Orb common event could cause problems (but I haven't tested it yet). Maybe there is a way to simplify the code?
I have a theory: A special shop/NPC could be used to control the use of the Orbs. If a player wanted to change their Orb, they would have to go to the special NPC to make the adjustment. This would make the Common Event be called on demand, without the need for it to run 24/7 as a parallel process. However, I can't work my head around that yet.