MP recover

Gurtag

Active member
hey guys, i am trying to configure a way to recover MP by hiting enemies, typemp doesnt seem to work and i tryed spawning mp touch item on enemy´s pain anims, it worked but it also makes the enemy´s health bar to stuter wile been hit, wich is quite anoying.
is there a script for this? or a way to force standar ATTACK anims to have energycost?
 
or a way to force standar ATTACK anims to have energycost?

That's not the solution cause setting energycost could prevent you from performing the attack. Not to mention, energycost doesn't care if attack connects or not.

You can use didhitscript for this purpose.
 
Gurtag, I am using a script that Kratus made.
This is my customized version, but he can paste here his original code (I can't remember where it is).

To optimize the resources, I always use a forwarder file:
didhitscript  data/scripts/didhit/mp.c

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

void main()
{
    actual_main();
}

mp_actual.c

Code:
void actual_main(){
lockMp();
}

void lockMp()
{//Lock mprate with defined conditions. Used for Counter, Super and Rage animations that never fill mp - THANKS KRATUS
	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");
		void tName  = getentityproperty(target,"model");
		
		if(disable == 6){
			if(blocked == 0){
				if(mp < maxMp){
					if(type != openborconstant("TYPE_OBSTACLE")){
						if(tName !="Box" || tName !="Glass" || tName !="Roll"){
						changeentityproperty(self, "mp", mp-mpRate);
						}
						//settextobj(1, 240,  154, 2, 999999999, "disable", 100+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);
						}
					}
				}
			}
		}
	}
}
 
Bloodbane said:
or a way to force standar ATTACK anims to have energycost?

That's not the solution cause setting energycost could prevent you from performing the attack. Not to mention, energycost doesn't care if attack connects or not.

hey bloodbane negative values gives you mp instead of taking it out, i know it is rudimentary but was just an idea ;p

O_Ilusionista said:
Gurtag, I am using a script that Kratus made.
This is my customized version, but he can paste here his original code (I can't remember where it is).

To optimize the resources, I always use a forwarder file:
didhitscript  data/scripts/didhit/mp.c

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

void main()
{
    actual_main();
}

mp_actual.c

Code:
void actual_main(){
lockMp();
}

void lockMp()
{//Lock mprate with defined conditions. Used for Counter, Super and Rage animations that never fill mp - THANKS KRATUS
	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");
		void tName  = getentityproperty(target,"model");
		
		if(disable == 6){
			if(blocked == 0){
				if(mp < maxMp){
					if(type != openborconstant("TYPE_OBSTACLE")){
						if(tName !="Box" || tName !="Glass" || tName !="Roll"){
						changeentityproperty(self, "mp", mp-mpRate);
						}
						//settextobj(1, 240,  154, 2, 999999999, "disable", 100+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);
						}
					}
				}
			}
		}
	}
}

thanks a lot ilu, will take a look and see if i can get it runing.




 
Back
Top Bottom