Solved Boss with two behaviours

Question that is answered or resolved.

dantedevil

Well-known member
I currently have a boss that I use in 2 different stages. The idea is that the first time it appears, it escapes before you can finish it. The second time he fights normally, until his health bar runs out.

I use "Desperation" script by Bloodbane:
Code:
@script   
    if(frame==0){
      void vSelf = getlocalvar("self");
      int MHealth = getentityproperty(vSelf,"maxhealth");
      int Health = getentityproperty(vSelf,"health");

      if(Health <= MHealth/3){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script

The problem with using this method is that I am forced to create 2 versions of the same character. One version with the Script in "anim idle", and the other version without the Script.

So, is there any way to do this, without the need to create 2 versions of the same character?
 
Last edited:
Solution
Damon meant something like this:
Code:
@script	
    if(frame==0){
      void vSelf = getlocalvar("self");
      int Flee = getglobalvar("L0");      
      int MHealth = getentityproperty(vSelf,"maxhealth");
      int Health = getentityproperty(vSelf,"health");

      if(Health <= MHealth/3 && Flee != "X"){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script

In this updated script, entity will only play FOLLOW1 when global variable named L0 isn't filled with "X".
To fill that variable, simple add this line in level text:
Code:
spawn	...
@script
void main()
{
    setglobalvar("L0", "X");
}
@end_script
...

You can declare that in any entity spawn but make sure it's declared...
dantedevil said:

You need t place a variable or tweak some other flag when the entity is spawned in. Then you add a check for that condition in your existing script and act accordingly. That will allow you to use the same model for both.

DC
 
Damon Caskey said:
dantedevil said:

You need t place a variable or tweak some other flag when the entity is spawned in. Then you add a check for that condition in your existing script and act accordingly. That will allow you to use the same model for both.

DC

Hello my friend!

I appreciate your help, but that exceeds my knowledge.
I think in use some script in the level spawn, but I do not have a very clear idea of ​​how to do it exactly.
 
Damon meant something like this:
Code:
@script	
    if(frame==0){
      void vSelf = getlocalvar("self");
      int Flee = getglobalvar("L0");      
      int MHealth = getentityproperty(vSelf,"maxhealth");
      int Health = getentityproperty(vSelf,"health");

      if(Health <= MHealth/3 && Flee != "X"){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script

In this updated script, entity will only play FOLLOW1 when global variable named L0 isn't filled with "X".
To fill that variable, simple add this line in level text:
Code:
spawn	...
@script
void main()
{
    setglobalvar("L0", "X");
}
@end_script
...

You can declare that in any entity spawn but make sure it's declared before the boss is spawned

To clear that variable, you need to add this line in your endlevel.c

Code:
    setglobalvar("L0", NULL());

HTH
 
Solution
Well my friend, I try but not work.

Here my enemy amim idle with the script:
Code:
anim idle
@script	
    if(frame==0){
      void vSelf = getlocalvar("self");
      int Flee = getglobalvar("L0");     
      int MHealth = getentityproperty(vSelf,"maxhealth");
      int Health = getentityproperty(vSelf,"health");

      if(Health <= MHealth/3 && Flee != "X"){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW19"));
      }
    }
@end_script
	loop	1
	offset	82 177
	bbox	63 78 36 103
	delay	10
        @cmd    clearL
	frame	data/chars/gang1/bee/idle0.png
	frame	data/chars/gang1/bee/idle1.png
        frame	data/chars/gang1/bee/idle2.png
        frame	data/chars/gang1/bee/idle3.png
        frame	data/chars/gang1/bee/idle4.png
        frame	data/chars/gang1/bee/idle5.png
        frame	data/chars/gang1/bee/idle6.png


Here the level spawn:
Code:
spawn  bee
@script
void main()
{
    setglobalvar("L0", "X");
}
@end_script
coords  362 242 0
at      0

And here my endlevel.c:
Code:
#include "data/scripts/story/story_clear.c"

void main()
{
   clearStory();
   setdrawmethod(NULL(),0,256,256,0,0,0,0,0,0,0,0,0,NULL());
    setindexedvar("Lesn", NULL());
    setindexedvar("Wait", NULL());
    setindexedvar("Ulang", NULL());
    setglobalvar("L0", NULL());
}

I test in a free training stage, but not work.
 
Hmmm.... does the script work without setting the global variable?

I usually declare desperation script in IDLE and WALK to ensure enemy will perform the script when his/her HP falls below limit.
 
Bloodbane said:
Hmmm.... does the script work without setting the global variable?

I usually declare desperation script in IDLE and WALK to ensure enemy will perform the script when his/her HP falls below limit.

Without setting the global variable, the script works ok.

I declare in IDLE and WALK animations, but not work.
 
But that's the idea, setting the global variable will prevent the enemy from doing the desperation move or FOLLOW19

In level where the enemy shouldn't perform FOLLOW19, set the global variable. In other levels, don't set the variable :)
 
Bloodbane said:
But that's the idea, setting the global variable will prevent the enemy from doing the desperation move or FOLLOW19

In level where the enemy shouldn't perform FOLLOW19, set the global variable. In other levels, don't set the variable :)

Ups! Sorry... ;D mybad...
I had understood it the other way around.
Now if it is clear to me.

Thanks my friend!
 
Back
Top Bottom