Charge like Megaman

O Ilusionista

Captain 100K
(or moves like Jagger, lol)

I need some help for a complex thing here. I need to make a charge power like in Mega Man games, but there are some points involved on it and its a bit complex to me to handle alone. I understand all the logic on it, but I still lack the knowledge to make it BOR (while I can do in mugen).

How the move works?

1- You hold ATTACK button to chage power. The charge counter (not visible, just a variable) can store up to 3 values (lets say 0-99, 100-199 and 200-299). it increases its values in 1 per tick. Lets call this "levels"

2- The player should blink quickly from the normal palette to a hidden palete to simulate the effect (or a drawmethod is enough). Each "level" uses different colors (palette or drawmethods)

3- While holding, everytime you blink, a sound effect is played (and not a big sound file because I don't see something "StopSND" like we have in mugen). Or there is a way to stop a specific sound once we get hit?

4- once player release the button and is in idle animation, walk animation or jump animation, it will spawn a projectile.

5- The projectile entity will change based on which "level" you are. So, for level1, its one projectile, level2 uses another one and level 3 will use yet another one. Each one will have different sprites, velocities, etc...IOW different entities. (or not, if there is a smarter way to do it)

6- If you release the button, but you aren't on the possible animaions (check item 4), nothing happens and the counter resets itself. If you are hit while holding the button, the counter resets.

7- I need to spawn an effect, which will be bind to the player, which acts as a level indicator. It needs to change its animation based on the "level", so it will have 3 different levels.


Can someone give me a hand with that?
 
I'm a little run over, but yeah this can all be done, including the sound issue. Sounds are played by index. If you trigger a sound with script, you can store the index you used to play it and later use that same index to stop the sound (in this case you'd do it in the "takedamage" event). I'm literally going out the door right now, but will try to add some details later.

Good luck!

DC
 
Well, it's a bit complex but easy.
I hope that you've skill with script ^__^
You've to decide if to use charge attack or not.
However you have to use a script event (not ondraw).

You've to catch the keys with player keys to verify hold atk button.

So:
int pindex = getentityproperty(self,"playerindex");
if ( playerkeys(pindex,0,"attack") {

// initialize charge time (FUNCTION)

} else // reset time if the time (ALL TIMES) is initialized!! (RESET FUNCTION)


to initialize time use a localvar:
if ( getlocalvar("charge_time") == NULL() ) {
int time = openborvariant("elapsed_time");

setlocalvar("charge_time",time);
}

then verify your time range ex.:
time = getlocalvar("charge_time");

if ( (time/3) ) // blink violet
else if ( (time/3)*2 ) // blink green

than you've to spawn a charge flash animation
so in if ( playerkeys(pindex,0,"attack") ...

if ( !getentityproperty(getlocalvar("charge_flash"),"exists") ) {
void charge_flash;

...
charge_flash = spawn();
setlocalvar("charge_flash",charge_flash);
}

to blink I advice you to use changedrawmethod();
ex.:
            changedrawmethod(NULL(), "enabled", 1);
            changedrawmethod(NULL(), "reset", 1);

            changedrawmethod(NULL(), "tintmode", 1);
            changedrawmethod(NULL(), "tintcolor", color);


and to make a blink effect:
in if ( playerkeys(pindex,0,"attack") ...

if ( getlocalvar("blink_time") == NULL() ) {
int time = openborvariant("elapsed_time");
int eta = openborvariant("game_speed")*0.5; // blink duration. in this case 1/2 sec.

setlocalvar("blink_time",time+eta);
} else {
int time = openborvariant("elapsed_time");
int eta = openborvariant("game_speed")*0.5;

if ( getlocalvar("blink_time") <= time+(eta/2) ) // ----> change color func
else if ( getlocalvar("blink_time") <= time+eta ) // ----> reset color func
else if ( getlocalvar("blink_time") < time ) setlocalvar("blink_time",NULL());
}
 
I once made something like this some time ago but I forget where I put it  :'(
Anyways, I used seperate entity to do most of the work.
Though I used alternate palette trick for blink effect (drawmethod was incapable of changing color balance that time) but now that drawmethod is updated, using drawmethod is best for blinking effect.
 
See, I'm trying do something different.

I want to make it so that once anim chargeattack is accessible (ie, letting go of Attack1 will launch chargeattack), an entity is spawned with @cmd spawn(). The entity would be the "charging" animation, and then I'd use @cmd killentity() in the chargeattack animation.

Sounds easy enough, but I have no idea how to make script recognize when ANI_CHARGEATTACK is ready for use. :(

 
NickyP said:
Sounds easy enough, but I have no idea how to make script recognize when ANI_CHARGEATTACK is ready for use. :(

There isn't a 'ready' status at all. There are instead two time variables. The first is just the setting for how long you have to hold down Attack. The second stores the elapsed time value whenever Attack is pushed. When you releases Attack, the stored time is compared to current elapsed time. If the difference between them >= time required setting then the engine knows to trigger ANI_CHARGEATTACK (assuming other checks like being on the ground and such also pass).

Elapsed time has been available forever: openbrovariant("elapsed_time"). The charge attack time variables are probably available too, but if not won't be that hard to give you access.

DC
 
Back
Top Bottom