SP meter script (Tech Demo)

@Bruce here you go as promised updated the first post with a tech demo showing the sp meter in effect.

I have to apologise the scripts I posted seemed sound in theory but I had to change them a lot to get them working I moved everything to the ondrawscript including the key inputs. If you have any questions don't hesitate to ask.
 
@Bruce here you go as promised updated the first post with a tech demo showing the sp meter in effect.

I have to apologise the scripts I posted seemed sound in theory but I had to change them a lot to get them working I moved everything to the ondrawscript including the key inputs. If you have any questions don't hesitate to ask.
Thank you, I found a problem. After entering the game again after returning to the main menu, the SP timer will not be counted for the first time, and it will be counted after a while.
 
Noticed that too did not think of it as a big issue since it only happens when you first enter a stage.
 
I explained this in another thread. If you are comparing something against elapsed time, you have to remember elapsed time resets any time there's a screen transition (ex. starting a new stage).

If you don't ensure your accumulated value also resets, it will start out far ahead and your timing won't work correctly until elapsed time catches up.

DC
 
Last edited:
@Bruce here you go as promised updated the first post with a tech demo showing the sp meter in effect.

I have to apologise the scripts I posted seemed sound in theory but I had to change them a lot to get them working I moved everything to the ondrawscript including the key inputs. If you have any questions don't hesitate to ask.
I added your script to my existing game, and it did display SP on the screen, thank you very much.

when I tried @cmd frame2ani "freespecial4" 2 "attack2" to my char.c
it gave me the error message: "Script compile error: can't find function 'frame2ani'"
on your ondrawscript, it says
void sp_atk( char ani, int sp_cost, char input1, char input2, char input3, char input4 )

I've also tried @cmd sp_atk "freespecial4" 2 "attack2"
it also gave me the error message: "Script compile error: can't find function 'sp_atk'"

How do you use the function?

Thank you very much for your help.
 
Last edited:
I added your script to my existing game, and it did display SP on the screen, thank you very much.

when I tried @cmd frame2ani "freespecial4" 2 "attack2" to my char.c
it gave me the error message: "Script compile error: can't find function 'frame2ani'"
on your ondrawscript, it says
void sp_atk( char ani, int sp_cost, char input1, char input2, char input3, char input4 )

I've also tried @cmd sp_atk "freespecial4" 2 "attack2"
it also gave me the error message: "Script compile error: can't find function 'sp_atk'"

How do you use the function?

Thank you very much for your help.
Regarding using sp, I re-edited a simple script, the player script "animationscript data/scripts/scripts.c"
Place the following script code in scripts.c
Code:
void costsp(int DamageSP, void Ani)
{
    void self = getlocalvar("self");
    void sp = getentityvar(self,"sp");
    int sp=sp - DamageSP;

      if(sp>=0){
      setentityvar( self, "sp", sp);
      }else{
      changeentityproperty(self, "animation", openborconstant(Ani));
    }
}
Finally add @cmd costsp 5 "ANI_FOLLOW1" to the animation,Note: FOLLOW1 is the animation after insufficient sp
Code:
anim freespecial2
    loop    0
    delay   10
        offset  72 131
        bbox    63 102 16 29
     fastattack 1
        @cmd    costsp 5 "ANI_FOLLOW1"
     followanim 1
     followcond 2
    hitfx    data/sounds/hit03.wav
    frame    data/chars/pla01/0sp1.gif
    delay   10
    frame    data/chars/pla01/0sp2.gif
        bbox    63 102 9 29
     move       6
     delay      2
        attack    70 110 16 20 6 0 0 0 0
    frame    data/chars/pla01/0a103.gif
 
I added your script to my existing game, and it did display SP on the screen, thank you very much.

when I tried @cmd frame2ani "freespecial4" 2 "attack2" to my char.c
it gave me the error message: "Script compile error: can't find function 'frame2ani'"
on your ondrawscript, it says
void sp_atk( char ani, int sp_cost, char input1, char input2, char input3, char input4 )

I've also tried @cmd sp_atk "freespecial4" 2 "attack2"
it also gave me the error message: "Script compile error: can't find function 'sp_atk'"

How do you use the function?

Thank you very much for your help.

The moves need to be set in the ondrawscript but i guess it could be more user friendly to add a @cmd call instead. I will add a little update need to fix the timer issue anyway.

@pud Nice edit.
 
updated the first post with a fix to the delay on the sp meter starting when re-entering a stage.

@Bruce open ondraw.c and edit this part for moves. you can set what animations can be cancelled and what button inputs are required. but its just single direction pressing so "d" "f" "a" is not like ryus fireball motion its diagonal forward and down with attack.

C-like:
//KEYSCRIPTS
    void ani = getentityproperty(self,"animationid");
        if (ani == openborconstant("ANI_IDLE") || ani == openborconstant("ANI_WALK") || ani == openborconstant("ANI_ATTACK1") )
            {// these are the animations that can be canceled
                sp_atk("freespecial",10,"f","a"); //if you press forward and attack when you have 10SP or more perform freespecial
            }
 
updated the first post with a fix to the delay on the sp meter starting when re-entering a stage.

@Bruce open ondraw.c and edit this part for moves. you can set what animations can be cancelled and what button inputs are required. but its just single direction pressing so "d" "f" "a" is not like ryus fireball motion its diagonal forward and down with attack.

C-like:
//KEYSCRIPTS
    void ani = getentityproperty(self,"animationid");
        if (ani == openborconstant("ANI_IDLE") || ani == openborconstant("ANI_WALK") || ani == openborconstant("ANI_ATTACK1") )
            {// these are the animations that can be canceled
                sp_atk("freespecial",10,"f","a"); //if you press forward and attack when you have 10SP or more perform freespecial
            }
Thank you, returning to the main menu to enter the game again will not delay the recovery, but entering the next level will still be delayed.
 
@pudu I have updated to v3 in the first post. Now there is a fix for a small issue where you have to have a greater value then the cost to perform the move. Fixed the timer when moving stages this demo has 1 enemy and 2 stages so it should be easy for you to test it.
 
Regarding using sp, I re-edited a simple script, the player script "animationscript data/scripts/scripts.c"
Place the following script code in scripts.c
Code:
void costsp(int DamageSP, void Ani)
{
    void self = getlocalvar("self");
    void sp = getentityvar(self,"sp");
    int sp=sp - DamageSP;

      if(sp>=0){
      setentityvar( self, "sp", sp);
      }else{
      changeentityproperty(self, "animation", openborconstant(Ani));
    }
}
Finally add @cmd costsp 5 "ANI_FOLLOW1" to the animation,Note: FOLLOW1 is the animation after insufficient sp
Code:
anim freespecial2
    loop    0
    delay   10
        offset  72 131
        bbox    63 102 16 29
     fastattack 1
        @cmd    costsp 5 "ANI_FOLLOW1"
     followanim 1
     followcond 2
    hitfx    data/sounds/hit03.wav
    frame    data/chars/pla01/0sp1.gif
    delay   10
    frame    data/chars/pla01/0sp2.gif
        bbox    63 102 9 29
     move       6
     delay      2
        attack    70 110 16 20 6 0 0 0 0
    frame    data/chars/pla01/0a103.gif
Thank you very much for the CostSp script. I am actually using your script!
 
Thanks a lot, the script worked perfectly. @msmalik681

@pudu I have updated to v3 in the first post. Now there is a fix for a small issue where you have to have a greater value then the cost to perform the move. Fixed the timer when moving stages this demo has 1 enemy and 2 stages so it should be easy for you to test it.
It is working perfect! THANK YOU!
We can not thank you enough for helping us out.
I've modified your script a bit to add the hit combo into it.
Basically, the SP won't generate until the hit combo starts and the SP keeps on generating until the hit combo ends.
This is perfect of what I really wanted!
Now I am learning how to call out a summon using this SP, but I have no idea how to start it yet.
Thank you and thank you!
 
Code:
//PLAYER SP RECOVERY by {//msmalik681 & edited by Bruce (script for SP meter and moves control)     
    if(openborvariant("in_level")){
    void self = getlocalvar("self");
    int sp = getentityvar(self,"sp");
    int max_sp = 99; //set the max to what you like
    int time = openborvariant("elapsed_time");
    int i, x;

    if(!sp){ setentityvar(self,"sp",0); }
    if(!getentityvar(self,"timer")){ // this controls how quick the sp recovers
        setentityvar(self,"timer",time+400); //change value to control how fast or slow sp recovers
    }
    
    void player;
    for(i = 0; i < 4; i++){   
        player = getplayerproperty(i, "ent");
        if(player != NULL()){
            int player_index = getentityproperty(player, "playerindex");
            if (getglobalvar("rush_p" + player_index) > 1){
                if (openborvariant("elapsed_time") - getglobalvar("rush_time_counter_p" + player_index) <= 0){
                    if(time > getentityvar(player,"timer") && sp < max_sp){ //sp recovery control
                        setentityvar(player,"sp",getentityvar(player,"sp")+1); //recover 1 sp
                        setentityvar(player,"timer",NULL());    //reset timer
                    }       
                }else if(openborvariant("elapsed_time") - getglobalvar("rush_time_counter_p" + player_index) > 0){
                    setglobalvar("rush_p" + i, 0);
                }
            }
        
        //SP DISPLAY ON SCREEN
             if( player_index == 0){ x=115;}    //player 1
        else if( player_index == 1){ x=375;}    //player 2
        else if( player_index == 2){ x=635;}    //player 3
        else if( player_index == 3){ x=895;}    //player 4
        
             if(sp) { drawstring(x, 50, 3, "SP: " + getentityvar(player,"sp")); }
               else { drawstring(x, 50, 3, "SP: " + getentityvar(player,"sp")); }             
                                 // Y, front type (0 = font1, 1 = font2, etc..)
        }
     }
  }
 
You sound like Eddie Brock "We are Venom!" lol

So to summon something your could have a SP move that has a spawnframe see the manual for more details.
Thanks. I followed the manual, but my summon always comes down from the top. Is there a way to have the summon appeared at the specific offset (location)?
It looks odd to summon a helper coming down from the top of the screen.
My goal is to summon a helper to come out and help with 1 skill then disappears after that.
Thank you so much

Edited: nevermind,
spawnframe 1 X 0 X 1 will do it...
 
Last edited:
You sound like Eddie Brock "We are Venom!" lol

So to summon something your could have a SP move that has a spawnframe see the manual for more details.
How do I use the anim Pain, anim Attack, etc. in Anim freespecial__?
I've tried to find it in the manual, but I could not find it. I'm sure it's in the manual, it's just that it doesn't have examples for me to understand it.
I've tried @cmd anim Pain
but it did not work. Thank you very much.
 
@Bruce If your trying to change the entity's animation property to another animation what property do you think your need to modify? You can find a whole list in the manual under the heading Entityproperty.
 
@Bruce If your trying to change the entity's animation property to another animation what property do you think your need to modify? You can find a whole list in the manual under the heading Entityproperty.
What I like to do is:
For example, I have

Character_1.c:

anim freespecial22
....
...


Character_2.c:

anim freespecial22
....
...

While playing as Character_1,
I want to be able to use the freespecial22 from Character_2.c in the game.
Basically, the Character_2 appears, executes his freespecial22 then disappears after that.

I know that I can create a skill, load it, then use spawnframe to execute this skill in another character. Howwver, I just wanted to be able to use the skills with the character.c files from different characters. I hope this makes to you.
I'm sorry I just don't know the technical terms to describe to you easily lol.


Thank you
 
Last edited:
Back
Top Bottom