Solved Energycost per frame?

Question that is answered or resolved.

tightninja

Member
Is it possible to reduce MP per frame in a freespecial?

I have a multi hit freespecial that gives too much MP per hit even after draining all MP. Is there a way to reduce it per frame or at the end of an animation?
 
Solution
Is it possible

Another kitten dies...

If it were me, I would go the opposite direction. Turn off the native MP gain on hit and script my own as part of the didhitscript event. It would be a lot less janky than taking away MP at the same time the engine adds it.

But if you must...

Put this into your model's animation script file.

C-like:
/*
* Caskey, Damon V.
* 2026-07-24
*
* Simple MP adjust. Accepts entity and
* integer value. Adds the integer value
* to the entity's current MP.
*/
void dc_mp_adjust(void acting_entity, int mp_adjust) {
 
    /* Guards. */
    if(typeof(acting_entity) != openborcosntant("VT_PTR")
        || typeof(mp_adjust) != openborcosntant("VT_INTEGER")){
            shutdown(1, "\n dc_mp_adjust...
Is it possible

Another kitten dies...

If it were me, I would go the opposite direction. Turn off the native MP gain on hit and script my own as part of the didhitscript event. It would be a lot less janky than taking away MP at the same time the engine adds it.

But if you must...

Put this into your model's animation script file.

C-like:
/*
* Caskey, Damon V.
* 2026-07-24
*
* Simple MP adjust. Accepts entity and
* integer value. Adds the integer value
* to the entity's current MP.
*/
void dc_mp_adjust(void acting_entity, int mp_adjust) {
 
    /* Guards. */
    if(typeof(acting_entity) != openborcosntant("VT_PTR")
        || typeof(mp_adjust) != openborcosntant("VT_INTEGER")){
            shutdown(1, "\n dc_mp_adjust: Missing or invalid invalid arguments.");
    }

    /* Get curret MP. */
    int curret_mp = getentityproperty(acting_entity, "mp");

    /* Calculate new MP. */
    int new_mp = curret_mp + mp_adjust;

    /* Set new MP. */
    changeentityproperty(acting_entity, "mp", new_mp);
}

In the model, call the function on any frames you want to adjust MP. Pass it a negative value to subtract, positive to add.

Rich (BB code):
# Subtract 2 MP on this frame.

@cmd dc_mp_adjust getlocalvar("self") -2
frame data/chars/dude/punch_0.png

HTH,
DC
 
Solution
Another kitten dies...


The kitten's sacrifice will not be in vain. Script works perfectly thanks!


Turn off the native MP gain on hit and script my own as part of the didhitscript event.
Do you mean something like:

if openborconstant("ANI_FREESPECIAL15") changeentitiypropperty(mprate==0) or something like that?

I am just curious and always want to learn more, this journey has been fun for me. I now spend more time creating games than playing them!
 
if openborconstant("ANI_FREESPECIAL15") changeentitiypropperty(mprate==0) or something like that?

I believe he meant to fill MP manually per hit. Something like this:
C:
    void self = getlocalvar("self");
    void vAniID = getentityproperty(self,"animationID");
    int MP = getentityproperty(self,"mp");

    if(vAniID == openborconstant("ANI_FREESPECIAL15")){
      changeentityproperty(self, "mp", MP + 1);
    }

Each successful hit with FREESPECIAL15 recovers 1 MP.

this journey has been fun for me. I now spend more time creating games than playing them!

Glad to hear that :D . That's what game devs should feel.
 
Back
Top Bottom