Help with script involving MP

mersox

Active member
Alright I have wasted hours trying to make this work, so I think it's time to ask for help.

I have two special attacks (free specials 2 and 3) that consume mp. Until now, each one is assigned to a different gamepad button, but to make things simpler for the player as well as more streamlined, I want to have only one button for special attacks, and depending on the amount of MP the player would perform either freespecial2 or 3.

freespecial2 requires 20 MP (half bar), and freespecial3 requires 40 MP (a full bar)

So I am adding this to freespecial2:
anim freespecial2

@script
    void self = getlocalvar("self");
    int mp = getentityproperty(self, "mp");

if (frame == 0 && mp == 40 ){
performattack(self, openborconstant("ANI_FREESPECIAL3"));
}
@end_script

@cmd randSound7 "tommylong01.wav" "tommylong02.wav" "tommylong03.wav" "tommylong10.wav" "tommylong11.wav" "tommylong12.wav" "tommylong13.wav"
energycost 20
mponly 1
loop 0
delay 6
offset 68 125
frame data/chars/green_ranger/a3-000flash.gif


Thoughts? 
 
Use in freespecial 3
Code:
	@script
    void self = getlocalvar("self");
    int mp = getentityproperty(self, "mp");

   if (frame >= 0 && mp <= 20 ){
   performattack(self, openborconstant("ANI_FREESPECIAL2"));
   }
	@end_script
 
Thanks. It didn't work but at least it got my brain working.

I solved the issue, I had to create a new free special that branches into the other two depending of the amount of mp, and also consumes mp (because for some reason mpcost doesn't work when combined with this scrip. Long story)

Here's the code:

anim freespecial4 ***button touch

@script
    void self = getlocalvar("self");
    int mp = getentityproperty(self, "mp");


if (frame == 0 && mp == 40 ){

performattack(self, openborconstant("ANI_FREESPECIAL3"));
changeentityproperty(self, "mp", (mp-40));

} else if (frame == 0 && mp >= 20 ){

performattack(self, openborconstant("ANI_FREESPECIAL2"));
changeentityproperty(self, "mp", (mp-20));
}
@end_script

loop 0
offset 15 72
bbox 9 6 21 64
delay 1
frame data/chars/green_ranger/stand003.gif
 
  I'm going to assume that your maximum MP is 40 cause depending on how you spend your MP, you may or may not reach 40 MP

  You can use keyscript for this job alternatively. That is if you don't need to show 'not enough MP' animation
 
Back
Top Bottom