making pain anim in abstacles ?

jonsilva

New member
hello

iam trying to add a pain anim to abstacles
iam using this script:
Code:
void damage(int hp,char ani)
{
		void self=getlocalvar("self");
		if (getentityproperty(self,"health")<=(getentityproperty(self,"maxhealth")*hp/100))
		{
			changeentityproperty(self,"animation",openborconstant(ani));
		}
}

void beidle()
{// Go to IDLE animation!
    void self = getlocalvar("self");

    setidle(self, openborconstant("ANI_IDLE"));
}


this is the obstacle .txt
Code:
name			woodtrain3
type			obstacle
health			100
shadow			0
animationscript		data/scripts/obstacle.c
falldie			1
nodieblink		3
noatflash 		1
flash     		flash5
gfxshadow		1






anim	death
	loop	0
	delay	16
	offset	40 130
	jumpframe 0 2 -1
	sound   data/sounds/wood.wav
	frame	data/chars/misc/bonus/woodtrain/tfall1.gif
	frame	data/chars/misc/bonus/woodtrain/tfall2.gif
	offset	70 130
	frame	data/chars/misc/bonus/woodtrain/tfall3.gif
	frame	data/chars/misc/bonus/woodtrain/tfall4.gif
	delay	200
	frame	data/chars/misc/bonus/woodtrain/tfall4.gif
		
anim	fall
	loop	0
	delay	30
	offset	40 130
	frame	data/chars/misc/bonus/woodtrain/tfall1.gif
	frame	data/chars/misc/bonus/woodtrain/tfall2.gif
		
anim	follow1
	loop	0
	delay	9
	offset	40 130
	bbox	0 0 70 135
	frame	data/chars/misc/bonus/woodtrain/tpain1.gif
	frame	data/chars/misc/bonus/woodtrain/tpain2.gif
	frame	data/chars/misc/bonus/woodtrain/tstand.gif
	frame	data/chars/misc/bonus/woodtrain/tpain1.gif
	frame	data/chars/misc/bonus/woodtrain/tpain2.gif
	frame	data/chars/misc/bonus/woodtrain/tstand.gif
	frame	data/chars/misc/bonus/woodtrain/tpain1.gif
	@cmd	beidle
	frame	data/chars/misc/bonus/woodtrain/tpain1.gif
		

		
anim	idle
	loop	1
	delay	10
	@cmd	damage 95 "ANI_FOLLOW1"
	offset	40 130
	bbox	0 0 70 135
	frame	data/chars/misc/bonus/woodtrain/tstand.gif
		
#|edited by openBor Stats v 0.53


this was the best script i could find for a pain animation
but way the script plays with
@cmd damage 95 "ANI_FOLLOW1"
means whenever the healthbar reaches 95% it play anim follow1
anim follow 1 returns to idle.... and since the health its not 100% in idle it goes to follow1 again...


ive tried to change this part of the script
(self,"maxhealth")*hp/100))
but it dindnt changed anything
is there a way to change the script so that it changes to follow1 when it
takes 5 or 10 damadge ?  not when its bellow 95% health...


 
The best way would be using takedamagescript which is run when entity takes damage. That script also can acquire latest received damage.

The idea is this script checks last damage then if it's accepted on your condition (5 or 10), a variable (entity variable is preferred) is filled with say 1.

This variable is later checked in IDLE animation. If it's 1, change to FOLLOW1 animation. The variable is cleared either in FOLLOW1 or at same time with animation change to avoid repetition.
 
Too bad obstacles cant have pain anim hardcoded, or just some other named animation that plays when you hit obstacle without knocking it down.
Theres still some small feature holes here and there which have to be taken care of by using scripts.
Obstacles arent just barrels and using NPC to solve this also isnt too smart cause then it reduces your NPC usage freedom later especially with "candamage" or "hostile" when enemies just keep hitting your NPC obstacles.
I wanted to have enemies characters as obstacles so they would play pain animations and after knockdown they would play death but it would be just link animation to spawn their clone to fight normally as regular enemy .
Cant something be done for obstacles to give them such basic animation ?
 
Obstacles arent just barrels and using NPC to solve this also isnt too smart cause then it reduces your NPC usage freedom later especially with "candamage" or "hostile" when enemies just keep hitting your NPC obstacles.

ive already have this problem in the game theres a level were the player and an NPC fight a boss togheter...
and the npc is always getting hit by player
attackchain also doesnt seemed to work on the npc...

Is there an example of a takedamagescript ?
i cant find it in any game

also
how can i see the openbor .c code ?
i know this word "maxhealth" (self,"maxhealth") its the name its being used to define 100% health

but i dont know the name of the other words
that are used in other openbor functions
 
bWWd said:
I dont think there was ability to use and change "type" for changeentityproperty, how ? Or i have old script reference

@script
if(frame==1)
{
  changeentityproperty(getlocalvar("self"), "type", openborconstant("TYPE_OBSTACLE"));
}
@end_script


To avoid the first frame problem, you need to do that in seond frame (frame==1).
This will make the enemy a moving obstacle.
 
@script
if(frame==1)
{
  changeentityproperty(getlocalvar("self"), "type", openborconstant("TYPE_OBSTACLE"));
}
@end_script

thanks
Loooool... i think this just worked !!!
i had already made a woodtrain1 type npc
ive use the script obove in the spawn anim
and now its playing pain animation

i also have an npc player in the level and he is not being attack by the player

atchain combo also seems to work on woodtrain1
previous the player set with the candamage npc
was able to hit the npc but it dindt played the atchain combo


 
Yes I had the same problem as you the code your using to get the life percentage is wrong.

Void both maxhealth and health as maxhp and hp then:

void percent = hp*0.01/maxhp;

I'm not at my pc right now but I'm quite sure that's the right code took me a long time to figure out !
 
thanks for the code malik4ever

the script code i was using was taken from rocket viper 2 tdamage/object.c
i prefer not to change it right now iam using it for a couple of cars and its working...
i will use the changeentityproperty for the other obstacles and try not
mess to much with scripts otherwise i wil loose a lot of time trying to lear how it works and then the game will take even more time to be finish... (its all a time problem for me)


 
Back
Top Bottom