[SOLVED] MP charge with hits

O Ilusionista

Captain 100K
Hi guys.
I wanna test something on my projects - to change the way the players recover the MP, from constantly recover to hitting enemies only (or items).

But I have a question that I haven't found on the manual: its possible to set how much MP an entity recover for a hit?
mprate {int}

This sets how many MP player recovers (by time and by hitting enemy)
If typemp = 1, this is the amount MP player recover from hitting enemy.
If typemp = 2, this is the amount MP player recover on regular intervals.

Or even make the hit to not recover MP at all?
Probably I will need to use scripts for that, right?

Solved: http://www.chronocrash.com/forum/index.php?topic=5362.msg73050#msg73050
 
Native is one way or the other. You either recover MP over time, or when you hit. Not both. There's also mpstable, which is a much more sophisticated option for MP recovery. It lets you set up a specific amount of MP the meter is always trying to maintain, and also has a mode to mimic the SNK grove behavior. But to combine options with complex logic you'd still need to script it.

DC
 
Yeah I discovered it the hard way. And, for whatever reason, typemp is not a character setting but a stage setting (which doesn't makes much sense to me).
I am making some tests but it looks like I will have to go circular and fixing a lot of stuff for a simple return (like moves where my mp bar will be refilled) and maybe it doesn't worth the trouble.

edit: we should have an option to set how much MP we will receive back with each attack, as we have in mugen. This would be great.
 
O Ilusionista said:
Yeah I discovered it the hard way. And, for whatever reason, typemp is not a character setting but a stage setting (which doesn't makes much sense to me).
I am making some tests but it looks like I will have to go circular and fixing a lot of stuff for a simple return (like moves where my mp bar will be refilled) and maybe it doesn't worth the trouble.

edit: we should have an option to set how much MP we will receive back with each attack, as we have in mugen. This would be great.

O Ilusionista
It is not a simple way, but it is possible. I'm using a custom mp recovery system in SOR2X for different occasions, like recovering mp when taking any damage or never recovering mp in certain animations.
In addition, I'm using the "disable" number to detect what animations need to be locked or not. I discovered that these "disable" numbers don't affect anything in the game mechanic but creates some kind of "ID" for each attack type who uses mp, but you can remove this code if you want.

For example, to animations that have a "disable" number 6 (counter, super or rage) the mp will never be recovered. But for "disable" number 5 (special, front special or aerial special) the entity can recover normally.

Code:
void lockMp()
{//Lock mprate with defined conditions. Used for Counter, Super and Rage animations that never fill mp
	void self 	= getlocalvar("self");
	void target	= getlocalvar("damagetaker");
	void parent = getentityproperty(self,"parent");
	void vType 	= getentityproperty(self,"type");
	void sType	= getentityproperty(self,"subtype");
	
	//USED BY PLAYER/ENEMY
	if(parent == NULL()){
		void vAniID = getentityproperty(self,"animationID");
		void type 	= getentityproperty(target,"type");
		int disable	= getentityproperty(self,"energycost", "disable", openborconstant(vAniID));
		int blocked = getlocalvar("blocked");
		int maxMp 	= getentityproperty(self,"maxmp");
		int mp 		= getentityproperty(self,"mp");
		int mpRate 	= getentityproperty(self,"mprate");
		
		if(disable == 6){
			if(blocked == 0){
				if(mp < maxMp){
					if(type != openborconstant("TYPE_OBSTACLE")){
						changeentityproperty(self, "mp", mp-mpRate);
					}
				}
			}
		}
	}
	
	//USED BY NPC PARTNER
	if(parent != NULL()){
		if(vType == openborconstant("TYPE_NPC") && sType == openborconstant("SUBTYPE_FOLLOW")){
			void vAniID = getentityproperty(self,"animationID");
			void type 	= getentityproperty(target,"type");
			int disable	= getentityproperty(self,"energycost", "disable", openborconstant(vAniID));
			int blocked = getlocalvar("blocked");
			int maxMp 	= getentityproperty(self,"maxmp");
			int mp 		= getentityproperty(self,"mp");
			int mpRate 	= getentityproperty(self,"mprate");
			
			if(disable == 6){
				if(blocked == 0){
					if(mp < maxMp){
						if(type != openborconstant("TYPE_OBSTACLE")){
							changeentityproperty(self, "mp", mp-mpRate);
						}
					}
				}
			}
		}
		else
		{ 
		//USED BY PROJECTILES
			void type 	= getentityproperty(target,"type");
			int disable	= getentityvar(self,"disable");
			int blocked = getlocalvar("blocked");
			int maxMp 	= getentityproperty(parent,"maxmp");
			int mp 		= getentityproperty(parent,"mp");
			int mpRate 	= getentityproperty(parent,"mprate");
			
			if(disable == 6){
				if(blocked == 0){
					if(mp < maxMp){
						if(type != openborconstant("TYPE_OBSTACLE")){
							changeentityproperty(parent, "mp", mp-mpRate);
						}
					}
				}
			}
		}
	}
}

Code:
void addMp()
{//Add mp if take damage
	void self 	= getlocalvar("self");
	int dmg 	= getlocalvar("damage");
	int atkType	= getlocalvar("attacktype");
	int mp 		= getentityproperty(self,"mp");
	int mpRate 	= getentityproperty(self,"mpRate");
	
	if(dmg > 0){ //USED GRABS AND OTHER "NO DAMAGE" ATKS
		if(atkType != openborconstant("ATK_NORMAL10")){ //USED FOR ROUTE MENU, DOORS, TOXIC GAS AND OTHER INVALID ATKS
			changeentityproperty(self, "mp", mp+mpRate);
		}
	}
}

EDIT: I forgot to say that they are used in "didhit" and "takedamage" events respectively
 
Kratus ah thanks buddy, I will surely give a try!
I think I will only need it as a didhit, because the charcters won't recovery MP when hit.

So, for the moves where I don't want the MP refill, I would use:
Energycost 10 1 6
(for the follow animations, I would need to set the energycost to 0)
Energycost 0 1 6

And for the ones I do want, I set the disable to 5? For example
Energycost 0 1 5

 
Thanks Kratus, now its working!

I've saved your code as mp_actual.c

And I am calling it with a forwarder called mp.c
Code:
void actual_main(){
lockMp();
}

void lockMp()
{//Lock mprate with defined conditions. Used for Counter, Super and Rage animations that never fill mp
	void self 	= getlocalvar("self");
	void target	= getlocalvar("damagetaker");
	void parent = getentityproperty(self,"parent");
	void vType 	= getentityproperty(self,"type");
	void sType	= getentityproperty(self,"subtype");
	
	//USED BY PLAYER/ENEMY
	if(parent == NULL()){
		void vAniID = getentityproperty(self,"animationID");
		void type 	= getentityproperty(target,"type");
		int disable	= getentityproperty(self,"energycost", "disable", openborconstant(vAniID));
		int blocked = getlocalvar("blocked");
		int maxMp 	= getentityproperty(self,"maxmp");
		int mp 		= getentityproperty(self,"mp");
		int mpRate 	= getentityproperty(self,"mprate");
		
		if(disable == 6){
			if(blocked == 0){
				if(mp < maxMp){
					if(type != openborconstant("TYPE_OBSTACLE")){
						changeentityproperty(self, "mp", mp-mpRate);
						//settextobj(1, 240,  154, 2, 999999999, "disabled", 300+openborvariant("elapsed_time"));

					}
				}
			}
		}
	}
	
	//USED BY NPC PARTNER
	if(parent != NULL()){
		if(vType == openborconstant("TYPE_NPC") && sType == openborconstant("SUBTYPE_FOLLOW")){
			void vAniID = getentityproperty(self,"animationID");
			void type 	= getentityproperty(target,"type");
			int disable	= getentityproperty(self,"energycost", "disable", openborconstant(vAniID));
			int blocked = getlocalvar("blocked");
			int maxMp 	= getentityproperty(self,"maxmp");
			int mp 		= getentityproperty(self,"mp");
			int mpRate 	= getentityproperty(self,"mprate");
			
			if(disable == 6){
				if(blocked == 0){
					if(mp < maxMp){
						if(type != openborconstant("TYPE_OBSTACLE")){
							changeentityproperty(self, "mp", mp-mpRate);
						}
					}
				}
			}
		}
		else
		{
		//USED BY PROJECTILES
			void type 	= getentityproperty(target,"type");
			int disable	= getentityvar(self,"disable");
			int blocked = getlocalvar("blocked");
			int maxMp 	= getentityproperty(parent,"maxmp");
			int mp 		= getentityproperty(parent,"mp");
			int mpRate 	= getentityproperty(parent,"mprate");
			
			if(disable == 6){
				if(blocked == 0){
					if(mp < maxMp){
						if(type != openborconstant("TYPE_OBSTACLE")){
							changeentityproperty(parent, "mp", mp-mpRate);
						}
					}
				}
			}
		}
	}
}

Code:
#import "data/scripts/didhit/mp_actual.c"

void main()
{
    actual_main();
}

To make it work, if I use followanimations, I set the energycost as 0 but setting the disable
  Energycost  0 1 6


EDIT: sometimes, if you have multiple hits against multiple enemies, the code fails. But I can force the mp reset by code.
Thanks buddy!
 
Back
Top Bottom