New progress - power system!
(in other words - the ability to set up power items and such.)
The basic idea behind it is as follows:
- The game script will set up how power items scale and such, while the player script will be given a "power level" value to determine how it will act.
- By default, the power system is disabled, and the player script will be instructed to act at full-power.
- MnD tracks a "power amount" for the player, which is increased as they pick up power items and decreased when they get hit. This amount has a minimum of zero and a script-defined maximum.
- The script also defines a set of "power level" thresholds - when the power amount reaches a threshold, the player reaches the corresponding power level.
- A player's "power level" can be in the range of 0 through 8, with 0 being the lowest level and 8 being full power.
To give an example of how this works in practice, here is the script to set up a powerup system similar to PCB:
// Set PCB-style power system
SetPowerDisplay(power_display_fraction);
SetPowerThreshold(1, 8);
SetPowerThreshold(2, 16);
SetPowerThreshold(3, 32);
SetPowerThreshold(4, 48);
SetPowerThreshold(5, 64);
SetPowerThreshold(6, 80);
SetPowerThreshold(7, 96);
SetPowerThreshold(8, 128);
SetPowerMax(128);
SetPowerMaxDisplay("MAX POWER!");
Here's a rundown of how it works:
The
SetPowerDisplay function determines how power will be displayed in the HUD. I'll go over the defined values below; in this case, it's setting it to display it as "<amount> / <max>".
The
SetPowerThreshold defines the threshold amounts for each power level. In this case, we define all 8 levels to correspond to the power amounts in PCB where you power up.
The
SetPowerMax sets the maximum power amount - in this case it is the same as the final threshold.
The
SetPowerMaxDisplay tells the game engine to replace the power display with the given text when at the maximum power amount. If this is not given, the power display will remain as-is at max power.
As another example to show how this can work, here's a script to do a power system similar to MoF/SA (disclaimer: I haven't played as much of the newer Touhou games, so this might not be as accurate as the PCB-style script):
global power_value_2;
// ...
{
// ...
{
// Set MOF/SA-style power system
SetPowerDisplay(power_display_decimal_fraction);
SetPowerThreshold(2, 20);
SetPowerThreshold(4, 40);
SetPowerThreshold(6, 60);
SetPowerThreshold(8, 80);
power_value_2 = 20;
SetPowerMax(100);
SetPowerLostOnMiss(20);
}
}
For the general idea of this one, we are equating 20 units of power items with 1.00 value on the MoF display. The powerup system works entirely with integers (to make life simpler), so we count the lowest denominator (0.05) as one unit of power.
In this case,
SetPowerDisplay indicates a "#.## / #.##" display style. What this does is match the MoF-style display, where the whole-number is the number of power thresholds you have passed, and the fractional part is the % you are to the next threshold. (To be specific - in MoF, every 20 power items was equivalent to 1.00 - one 'threshold').
We only define thresholds for half of the power levels. Since MoF only has four "power-up" points (when the player obtains each option), these are mapped to these thresholds. The player will jump from power level zero straight to 2, then to 4, etc.
Here, we also define the maximum power amount to be above the last threshold. Like MoF, this gives a "buffer zone" where you can lose some power and still be at the highest power level.
SetPowerLostOnMiss, as the name implies, sets the amount of power lost when the player loses a life. The default is 16, but for this we want 20 (the amount of one threshold - equivalent to 1.00).
Finally, the business with
power_value_2. This is a globally defined value that determines how much power a large power items gives the player (for reference, the small item's amount is
power_value). By default, this is 8; here, we want it to be 20, which is enough to push the meter up 1.00 (one whole threshold). The
global statement at the beginning tells the game to treat the name as a global variable, rather than a local one, so we are sure to set the correct value. I might end up making functions to set these values later on ...
In your player script, use the function
GetPowerLevel() to get the current player power level, based on the above data. Again, the value returned by this function is in the range of zero through eight, inclusive.
Finally, to spawn a power item, simply create a new object of type
PowerItem (small power item) or
PowerItem2 (large power item).
In short, this setup allows us to define the power system with the game, and still allow any player script to work with it by giving the player script a set of discrete power levels to work with. I used both above power system scripts with the same player script, and it allowed the player script to utilize the two different power systems without any problems.
There are six power display types defined currently (all are prefixed with
power_display_):
- none - doesn't display at all (the default). This will not prevent a power system from working if you define the other values, it just won't show any value.
- meter - shows a graphical meter that fill up horizontally.
- number - just shows the raw power amount.
- fraction - shows a fraction in the form of "<current amount> / <max amount>"
- decimal - shows an MoF style #.## display. The whole number digit is the number of thresholds met/passed, while the fractional portion is the % to the next threshold.
- decimal_fraction - same as decimal, except it adds a "/ #.##" to show the maximum value of this display as well.
Happy holidays!
BV