MP to Directly Follow Its Speed to Certain Points

maxman

Well-known member
I have an MP that has its max value of 114 for a specific character, and 3 images for MP parts that are for filling to its max. I'd like to fill the diamonds from 0 to 3 as max MP every time the bar increases via King of Fighters 98, but in the way the bar increases like A-ISM that's within 3 levels from the Street Fighter Alpha series, especially part 3. It's a combination of both for a 3-level bar increment. Plus, I use iconmplow, iconmphalf, and iconmphigh, for increasing to certain parts depending on the max number of MP the player uses.

First, I was using the image 1 (with one diamond) for iconmplow, image 2 (2 diamonds) for iconmphalf, and image 3 (3 full diamonds) for iconmphigh. The good thing was that it displayed image 3 when I started in the beginning. But it turned out when I used all the MP from its max, it reached to image 1 (but not the one without all diamonds) which I didn't realize that its max is the reach of 1/3 of its MP. So, it displayed image 1 when MP is 0. Not only that, but also when you reached 1/3 as its max, image 2 started to display (iconmphalf). When you reach to 2/3 of its max, iconmphigh image displayed. This is the MP setup I tried using.

Code:
icon            data/chars/haggar/icon.gif  1
icondie            data/chars/haggar/icond.gif 1

iconmplow        data/chars/haggar/33.png 1
iconmphalf        data/chars/haggar/66.gif 1
iconmphigh        data/chars/haggar/full_bar.gif 1

In the end, I started not to trust these kinds of setups, so I started to arrange the icon MP setup into this for a better one.

Code:
icon            data/chars/haggar/icon.gif  1
icondie            data/chars/haggar/icond.gif 1

iconmplow        data/chars/haggar/icon.gif 1 # From level 0 to 1
iconmphalf        data/chars/haggar/33.png 1 # From level 1 to 2
iconmphigh        data/chars/haggar/66.gif 1 # From level 2 and on

I already created a separate diamond from one of the 3 images and placed it in the sprites folder for reaching its true max number of MP that the player uses. I made one update.c for this MP. What I want is for the last image to display as it reaches to its max, so that it will look like it's filled with all 3 diamonds.

C:
void main(){
    playerMP();
}

void playerMP()
{
    if(openborvariant("in_level")==1){
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(2, "entity");

    void Diamond = getglobalvar("Diamond");
    float time = openborvariant("elapsed_time"); // Current time
    float delay = 30;

    if(!Diamond){
        Diamond = loadsprite("data/sprites/diamond.gif");
        setglobalvar("Diamond", Diamond);
    }

    if(P1){
        int MP = getentityproperty(P1, "mp");
        int maxMP = getentityproperty(P1, "maxmp");
        void ani = getentityproperty(P1, "animationid");
        int frame = getentityproperty(P1, "animpos");

        if(getentityvar(P1, "playerOne") == NULL()){setentityvar(P1, "playerOne", MP);}
        drawstring(20, 190, 1, "Time:_"+time);


        if(MP < getentityvar(P1, "playerOne")){ //If HP box smaller than damage box
        if(getentityvar(P1, 1) == NULL()){
            setentityvar(P1, 1, 0); //Set entity var 1 to zero if null this is a timer
        }
        setentityvar(P1, 1, getentityvar(P1, 1)+1); //Add 1 to timer; this will run every game tick
        if(getentityvar(P1, 1) > 2){ //If timer over 7
            setentityvar(P1, "playerOne", getentityvar(P1, "playerOne")-1); //Reduce displayed damage by 1
            setentityvar(P1, 1, 0); //Reset timer to zero; this will cause a loop until damage is the same as hp
        }
        }

        drawbox(26, 170, getentityvar(P1, "playerOne")-27, 10, 3999, rgbcolor(100,100,255), 0);
      
       if(time >= 0 && time < 100){
        if(MP == maxMP){
            setglobalvar("Diamond", NULL());
        }
        }

        if(time >= 100){
        if(MP == maxMP){
            drawsprite(Diamond, 97, 24, 5000);
        }
        }

        if(ani == openborconstant("ANI_PAIN99")){
        if(time >= 0 && time < 300){
           if(MP == 76 && MP == maxMP){
            setglobalvar("Diamond", NULL());
           }
        }

        if(time >= 300){
           if(MP == maxMP){
            drawsprite(Diamond, 97, 24, 5000);
           }
        }
        }
      

        /*if(MP == maxMP){ // If MP reaches its max
        drawsprite(Diamond, 97, 24, 5000);
        }*/
        if(MP < maxMP){ // If MP is less than its max MP
        setglobalvar("Diamond", NULL());
        }
    }

    if(P2){
        int MP2 = getentityproperty(P2, "mp");
        int maxMP2 = getentityproperty(P2, "maxmp");
        if(MP2 == maxMP2){ // If MP reaches its max
        drawsprite(Diamond, 212, 24, 5000);
        }
        if(MP2 < maxMP2){ // If MP is less than its max MP
        setglobalvar("Diamond", NULL());
        }
    }

    if(P3){
        int MP3 = getentityproperty(P3, "mp");
        int maxMP3 = getentityproperty(P3, "maxmp");
        if(MP3 == maxMP3){ // If MP reaches its max
        drawsprite(Diamond, 328, 24, 5000);
        }
        if(MP3 < maxMP3){ // If MP is less than its max MP
        setglobalvar("Diamond", NULL());
        }
    }

    }

}

void oncreate()
{
    void Diamond;

    if(!Diamond){
    Diamond = loadsprite("data/sprites/diamond.gif");
    setglobalvar("Diamond", Diamond);
    }
  

}

void ondestroy(){

    void Diamond = getglobalvar("Diamond");
 
    if(Diamond){
    free(Diamond);
    setglobalvar("Diamond", NULL());
    }
  

}

The reason I put the time variant over its MP in the beginning of the game, is that the last diamond image should appear every time the end of the MP bar reaches to its max.

I'm using only a default MP bar for this. If it doesn't work, should I use a scripted MP bar for this? I started to play @Kratus's SOR2X for searching for the way of how the MP is used with stars and when it's all consumed, it disappears until you keep attacking to fill.

Here's a character header just in case.

Code:
name            Haggar
type            player
health            100
mp              114
running         15 2.4 1.8 1 0
nolife        1
speed            7
jumpspeed    10
jumpheight      3
mprate        1.5
grabdistance    24
grabfinish    1
grabback    0
grabwalk        6
antigravity     10
bounce        1
noquake         1
gfxshadow       1
jugglepoints    10
diesound        data/chars/haggar/hagg05.wav
flash         flash
bflash         guard
dust        dust2
toflip        1
atchain         1 2 3
makeinv         3 0
falldie     2
riseinv     1 1
antigravity     20

candamage enemy obstacle npc

icon            data/chars/haggar/icon.gif  1
icondie            data/chars/haggar/icond.gif 1

iconmplow        data/chars/haggar/icon.gif 1
iconmphalf        data/chars/haggar/33.png 1
iconmphigh        data/chars/haggar/66.gif 1

typemp 1 is already set in levels.txt BTW.
 
Last edited:
Here's the first one with this icon MP setting is used here.

Code:
iconmplow        data/chars/haggar/icon.gif 1
iconmphalf        data/chars/haggar/33.png 1
iconmphigh        data/chars/haggar/66.gif 1


Here's the second one.

Code:
iconmplow        data/chars/haggar/33.png 1
iconmphalf        data/chars/haggar/66.gif 1
iconmphigh        data/chars/haggar/full_bar.gif 1


What I want is to have a full MP like the second one, but with no MP like the first one. Here's how I would it to work. When it reaches to 1/3 of its MP, one point appears. When it reaches 2/3, it's 2 points, until it reaches full and that's when there's 3.

EDIT:
Here's the third video with my input of update.c. But my problem with this is that every time I gain an MP without attacking anyone or anything, the diamond only appears when it's already full and the default MP gains. How can I time an MP sprite to appear and reach its max like iconmplow, iconmphalf, and iconmphigh?


C:
#######  TRAINING ROOM - RECHARGE
anim pain99
@script
void self = getlocalvar("self"); //get the self var
void power = getentityproperty(self,"mp"); // get target's current mp
changeentityproperty(self, "mp", power+114);
@end_script
    loop        0
    offset        94 171
    bbox        80 94 29 75
    delay        6
sound       data/chars/0misc/rechar/recha02.wav
    frame        data/chars/haggar/a101.gif
    frame        data/chars/haggar/ta01.gif
    delay        50
    frame        data/chars/haggar/ta03.gif

EDIT 2:
The only difference in this video is the timing of this last diamond that appears as a full MP in the very beginning of the level. It appears when the default MP bar reaches to its max. I'm still having trouble with the precise timing of the MP sprite for it to appear as an MP gain with no attacks at all. (This MP sprite only appears instantly every time it gains to its max.)


Changed the time value to fit its timing for an MP sprite to appear in the beginning of the level.
C:
       if(time >= 0 && time < 115){
        if(MP == maxMP){
            setglobalvar("Diamond", NULL());
        }
       }

        if(time >= 115){
          if(MP == maxMP){
            drawsprite(Diamond, 97, 24, 5000);
          }
        }

        if(ani == openborconstant("ANI_PAIN99")){
          if(time >= 0 && time < 300){
           if(MP == 76 && MP == maxMP){
            setglobalvar("Diamond", NULL());
           }
          }

          if(time >= 300){
           if(MP == maxMP){
            drawsprite(Diamond, 97, 24, 5000);
           }
          }
        }
 
Last edited:
I got my own problem solved after I figured out how to get MP to work in some specific way(s). I started to use ondrawscript for this to work instead of update.c, even though I'm saving necessary parts in oncreate and ondestroy in update.c. Plus, I got the global join event working for players to join by forcing the players' MP to start from 0. Therefore, having another player to join after one player starts the game is no problem now. However, I do have a problem with a player starting the game and his/her MP automatically fills to full instead of starting with 0.

@DCurrent Do you have any clue why level.c is not working when any player starts the game without leaving its MP value to 0? It's supposed to work when any level with this global level event starts it. I tried to force the players' MP's to initially start with 0 every time they start the game. But it's like it's got no effect to it.

level.c:
(Found this to be wrong.)
C:
void main(){
    playerOne();
    playerTwo();
    playerThree();
}

void playerOne(){
    int P1 = getplayerproperty(0, "entity");
    changeentityproperty(P1, "mp", 0);
}

void playerTwo(){
    int P2 = getplayerproperty(1, "entity");
    changeentityproperty(P2, "mp", 0);
}

void playerThree(){
    int P3 = getplayerproperty(2, "entity");
    changeentityproperty(P3, "mp", 0);
}

I also tried this before creating separate functions for level.c. (This one actually works fine.)

C:
void main(){
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(2, "entity");
    changeentityproperty(P1, "mp", 0);
    changeentityproperty(P2, "mp", 0);
    changeentityproperty(P3, "mp", 0);
}

level.c

  • Any level begins.

Because level.c doesn't help with forcing players' MPs to start from 0 for starting the game, I end up using these in a level like this here. And this works fine. I think I will have to use these since level.c is ineffective with changing player MPs to 0.

(Maybe I won't need this after finding out that level.c has to be used in levelscript in a level txt.)
C:
spawn empty
@script
void main(){
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(2, "entity");

    changeentityproperty(P1, "mp", 0);
    changeentityproperty(P2, "mp", 0);
    changeentityproperty(P3, "mp", 0);

}
@end_script
coords  300 100
at      0

Sorry for mentioning you on this, DC. I didn't have a clue to find how level.c could work until I figured out that I had to add levelscript and name level.c like this right here.

Code:
levelscripts data/levels/level.c

EDIT:
I just got it all working. My apologies.

The only thing left is refilling MP every time players start or join the game.
 
Last edited:
Back
Top Bottom