help with boss enemy

jonsilva

New member
hello

ive made boss character
i whanted to make him play an animation when his life reaches 80%
then 50% then 20%...

i already have a script that makes this work
void damage(int hp,char ani)
{
void self=getlocalvar("self");
if (getentityproperty(self,"health")<=(getentityproperty(self,"maxhealth")*hp/100))
{
changeentityproperty(self,"animation",openborconstant(ani));
}

enemy.txt
anim idle
loop 1
delay 10
@cmd damage 80 "ANI_FOLLOW1"
offset 106 89
bbox 0 9 190 75
frame data/chars/MISC/car/sta1.GIF


but this will make the character play follow1 every time it returns to idle and hes health is below 80%

is there a way to make the character only play follow1 one time ?
I think this type of boss was already made in other borgames ???
 
I think you need to specify range of HP instead of speific value like this. It's very tough to get HP exactly 80% of maximum HP.
For instance: 50% <= HP <= 80%, play FOLLOW1

It is much easier to get to this condition.

Also, why do you need to perform specific animation just once?

Hmmm... if you need to perform that animation just once, you could chip HP a bit so it's out of range like this:

say, the HP range is 75% to 85% to perform FOLLOW1. At the end of FOLLOW1 animation, change boss' HP to 74% so when boss returns to IDLE, boss won't play FOLLOW1 again.
 
i cant get it to work
everything ive tried makes the character not play follow1
or cant compile script

also the player attack has a damage of 12 and other attacks have diferent values

Is there aything that can be added in the script
void damage(int hp,char ani)
{
void self=getlocalvar("self");
if (getentityproperty(self,"health")<=(getentityproperty(self,"maxhealth")*hp/100))
{
changeentityproperty(self,"animation",openborconstant(ani));
}
}
so that character only plays @cmd damage 80 one time

like the killgun script in contra
void killgun(int Num, int Flag)
{ // Kill bound gun based on number
    void self = getlocalvar("self");
    void Gun = getentityvar(self, Num);

    if(Gun!=NULL()){
      bindentity(Gun, NULL());
      if(Flag==1){
        damageentity(Gun, self, 1000, 0, openborconstant("ATK_NORMAL"));
      } else {
        killentity(Gun);
      }
    }
}

a flag @cmd damage that could be used at end of follow1

 
I am sure I have already explained how to script hp percentages !

this is off the top of my head but you can give it a try:

void damage(int low, int lower, int lowest)
{
    void self=getlocalvar("self");
    int MHealth = getentityproperty(self,"maxhealth"); //get max hp
    int PHealth = getentityproperty(self,"health")/0.01/MHealth; //work out hp percentage
if(PHealth<=20){updateframe(self, lowest);
}
else if(PHealth<=50){updateframe(self, lower);
}
else if(PHealth<=80){updateframe(self, low);
}
}

and here is a example on how to use it all the alternate poses are in one animation and the script controls where the animation jumps depending on hp %.  the animation has a @cmd updateframe that will cause a loop the next frame will jump to whatever number you specify.

anim idle
loop    0
delay  1
offset  121 201
bbox    102 100 39 97
@cmd damage 2 5 8
frame data/chars/boss/empty.gif
delay  10
frame data/chars/boss/101.gif
frame data/chars/boss/102.gif
@cmd updateframe getlocalvar("self") 2
frame data/chars/boss/103.gif

frame data/chars/boss/201.gif
frame data/chars/boss/202.gif
@cmd updateframe getlocalvar("self") 4
frame data/chars/boss/203.gif

frame data/chars/boss/301.gif
frame data/chars/boss/302.gif
@cmd updateframe getlocalvar("self") 8
frame data/chars/boss/303.gif

please let me know if that works for you !
 
thanks malik4ever

ive just tried but the game crashs a few seconds after the level starts
i have to exit it with crtl alt del
iam using openbor stats v0.53

the idea you put on the script looks good but iam not trying to make
the character play diferent idle animations... i really needed him to play
follow1 /follow2/follow3

ive tried to change the
changeentityproperty(self,"animation",openborconstant(ani));
in the original damage script to
performattack(self, openborconstant(Ani)); //Change the animation

because when he goes to anim follow1 he keeps walking and chasing the player...
but the game also crashed with crtl alt del

the way i whanted to make the boss work was to make him spawn
shadows of himself with @cmd tosser
for example in anim
follow1
hp80%  -2 shadows
follow2
hp50%  -4 shadows
follow3
hp20%  -6 shadows

ive came into a part of the game where the player fights 2/3 bosses
at the same time
but this boss is just one guy so i whanted to make him spawn enemies
(shadows /alpha) of himself so that he doesnt feel easier to defeat
than the previous levels



 
well if this is a one off code there is no need to input any variables you could use like this:
void kakebushinnojutsu()
{
    void self=getlocalvar("self");
    int MHealth = getentityproperty(self,"maxhealth"); //get max hp
    int PHealth = getentityproperty(self,"health")/0.01/MHealth; //work out hp percentage
if(PHealth<=20){performattack(self, openborconstant(ANI_FOLLOW3));
}
else if(PHealth<=50){performattack(self, openborconstant(ANI_FOLLOW2));
}
else if(PHealth<=80){performattack(self, openborconstant(ANI_FOLLOW1));
}
}

then use as : @cmd kakebushinnojutsu

give that a try ! kakebushinnojutsu may be too long you could keep damage as the name  ;D
 
thanks malik4ever

but i still cant get it to work
its showing the cant compile script error in log

i cant even change the (changeentityproperty) to (performattack)
in the original damage script it show the cant compile script error
 
forgot the "" added them in and i tested this script so i know it works now

void damage()
{
    void self=getlocalvar("self");
    int MHealth = getentityproperty(self,"maxhealth"); //get max hp
    int PHealth = getentityproperty(self,"health")/0.01/MHealth; //work out hp percentage
if(PHealth<=20){performattack(self, openborconstant("ANI_FOLLOW3"));
}
else if(PHealth<=50){performattack(self,openborconstant("ANI_FOLLOW2"));
}
else if(PHealth<=80){performattack(self, openborconstant("ANI_FOLLOW1"));
}
}



to use : @cmd damage

in case your still having problems here is a demo with the trick working to make billy jump higher depending on how low his life becomes

http://www.mediafire.com/?nbn5cddaexofj2a
 
I think you should type it like this:

int PHealth = 100*getentityproperty(self,"health")/MHealth; //work out hp percentage

so it's easier to understand.

Examing the rest of function.... it looks fine. Though if this script is run, the boss would constantly play FOLLOW1 until his HP falls below 50%.... then play FOLLOW2 and so on.

Let's use local variable to prevent boss from replaying animation like that. For instance (editing malik's script above):

void damage()
{
    void self = getlocalvar("self");
    int Flag = getlocalvar("Flag" + self);
    int MHealth = getentityproperty(self,"maxhealth"); //get max hp
    int PHealth = 100*getentityproperty(self,"health")/MHealth; //work out hp percentage

if(Flag == NULL()){
  Flag=0;
}

if(PHealth<=20 && Flag < 3){performattack(self, openborconstant("ANI_FOLLOW3"));
}
else if(PHealth<=50 && Flag < 2){performattack(self,openborconstant("ANI_FOLLOW2"));
}
else if(PHealth<=80 && Flag < 1){performattack(self, openborconstant("ANI_FOLLOW1"));
}

}

In FOLLOW1, add:

@script
    void self = getlocalvar("self");

    if(frame==0){ // set local variable at 1st frame
      setlocalvar("Flag" + self,1)
    }
@end_script

In FOLLOW2, add:

@script
    void self = getlocalvar("self");

    if(frame==0){ // set local variable at 1st frame
      setlocalvar("Flag" + self,2)
    }
@end_script

In FOLLOW3, add:

@script
    void self = getlocalvar("self");

    if(frame==0){ // set local variable at 1st frame
      setlocalvar("Flag" + self,3)
    }
@end_script

Each FOLLOW has script which prevents it from being performed again.

HTH
 
thanks for script malik4ever
(i didnt had the oportunity to thank you yesterday)

the script is playing fine now...
i was trying to add an MP 100 to the boss and then
add an energycost 90 to follow1 60 follow2 30 follow3 to prevent him from keep playing the animation...

i see bloodbane already made it work
i will try it now
thanks
 
 
No problem and I think the mp option would work best for you !

@bloodbane
I tried to avoid using any variables (vars) for generic scripts as I thought it would affect other entities using the same script.  So are local variables exclusive to each entity using them? And do localvars only store numbers or can they hold words, sound effects or pictures?

Sorry for being off Topic
 
I think i got it working...???
the ";" was missing at the end of "setlocalvar("Flag" + self,3)"
this is hard to see without c compiler
i also changed the "if(frame==0)" to "if(frame==20)" and added
20 frames to the animation because he wasnt playing the animation
 
but he seems to be playing follow1 twice then stops
but works for me anyway... thanks bloodbane


this is how its looks
anim follow10
loop 0
delay 8
offset 100 189
bbox 0 0 0 0
@script
    void self = getlocalvar("self");

    if(frame==19){ // set local variable at 1st frame
      setlocalvar("Flag" + self,2);
    }
@end_script
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif
frame data/chars/3kagajin/jump02.gif

 
malik4ever said:
I tried to avoid using any variables (vars) for generic scripts as I thought it would affect other entities using the same script.  So are local variables exclusive to each entity using them? And do localvars only store numbers or can they hold words, sound effects or pictures?

The data types in OpenBOR script are integer, float, string, and pointer.  Not number, word, sound effect, or picture.  That aside, a local variable can hold any data type.

Local variables are not exclusive to entities; they are exclusive to scripts.  But when you load the same script for two models, the engine treats it as two separate scripts.  So they're essentially exclusive to the model using them, and shared among all entities with that model.

There are, however, the setentityvar() and getentityvar() functions; any variables used with those are obviously entity-exclusive.
 
BTW
Why do you need so many frames? 
You can just use delay 152 you know.

its to make a loop in the animation while its spawning shadows
anim follow9
loop 0
delay 14
offset 100 189
bbox 0 0 0 0
@script
    void self = getlocalvar("self");

    if(frame==1){ // set local variable at 1st frame
      setlocalvar("Flag" + self,1);
    }
@end_script
frame data/chars/3kagajin/b01.gif
frame data/chars/3kagajin/b02.gif
delay 8
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
@cmd    spawn01 "kagajin2" -30 60 1
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
@cmd    spawn01 "kagajin2" 30 60 1
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
frame data/chars/3kagajin/b04.gif
frame data/chars/3kagajin/b03.gif
delay 14
frame data/chars/3kagajin/b02.gif
frame data/chars/3kagajin/b01.gif
 
thanks for the info Plombo !

i know this is a old post but i revisited it to use the script and im having a problem i only have one follow animation and each time its run i want to add +1 to the flag localvar with this code: setlocalvar("Flag" + self,+1);

I can't see why this wont work can anyone help ?
 
Back
Top Bottom