[SOLVED] Boss attacking after set time/delay

DJGameFreakTheIguana

Active member
If someone can help me with this, I'm setting up a boss that I want to follow the played for a fixed amount of time/delay, and then attack, not on it's own like most enemies. The boss is a machine that comes down from a heightened offset to smash the player, who's trying to dodge. Once the machine hits the ground, it's the players chance to attack it before it goes back up and repeated the process. Anyone have a command for that?

x)
 
It's not hard to do.
Set your walk animation to loop, but instead of LOOP 1, make the first frame to NOT be included on the loop.
Look at my example:
Anim follow9
loop 1 1 3
delay 3
offset 300 100
frame data/chars/nave/heli1b.gif
sound data/sounds/heli.wav
frame data/chars/nave/heli2b.gif
frame data/chars/nave/heli1b.gif

The first frame is duplicated at the end, but won't be included on the loop.

Then I use this script to count the time and, after 2000 ticks, it will go to FOLLOW8 animation
Code:
   @script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
        int time;

        if(frame==0){
        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;
        }

         if(Summon <= openborvariant("elapsed_time") - 2000){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW8"));
    }
   @end_script

So you can use this code as the WALK animation of that enemy and put NO attack or freespecial (so it won't attack freely). Put the attack on a follow animation, like FOLLOW8 above.
It will walk until 2000 ticks are passed, after that it will attack.
 
Ok, I came up with a test entity but the engine crashed, saying it couldn't compile the script. Unless I have to set this in my scripts.txt file, I may have gotten something wrong here. Note, I changed the time to 200 and the follow anim to 1.

Code:
anim walk
	loop	1 1 3
	@script
	void self = getlocalvar("self");
	int Summon = getentityvar(self, 1);

        if(frame==0){
        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;
        }

         if(Summon <= openborvariant("elapsed_time") - 200){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
         }
	@end_script
	delay	2
	offset	81 326
	attack.block.penetrate 0
	attack.damage.force 0
	attack.damage.type 3
	attack.effect.hit.flash.disable 0
	attack.position.x 0
	attack.position.y 0
	attack.reaction.fall.force 0
	attack.reaction.pause.time 0
	attack.size.x 0
	attack.size.y 0
	attack.size.z.1 0
	Move 5
	#	@cmd changeentityproperty getlocalvar("self") "Subject_to_Gravity" 0
	frame	data/chars/Traps/Saw0.gif
	attack.block.penetrate 0
	attack.damage.force 30
	attack.damage.type 3
	attack.effect.hit.flash.disable 0
	attack.position.x 52
	attack.position.y 211
	attack.reaction.fall.force 1
	attack.reaction.pause.time 0
	attack.size.x 59
	attack.size.y 58
	attack.size.z.1 10
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw0.gif

Code:
anim follow1
	loop	0
	delay	2
	offset	81 276
		attack3  0
	Move 5
	#	@cmd changeentityproperty getlocalvar("self") "Subject_to_Gravity" 0
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw0.gif
	frame	data/chars/Traps/Saw1.gif
	frame	data/chars/Traps/Saw1.gif

I'll also paste the scriptlog.
Code:
####animationscript function main#####
# data/chars/Traps/BuzzSaw.txt
########################################
void main()
{
    int frame = getlocalvar("frame");
    int animhandle = getlocalvar("animhandle");
    if(animhandle==1118)
    {
        if(frame==0)
        {
            changeentityproperty(getlocalvar("self"), "Subject_to_Gravity", 0);
        }
        return;
    }
    if(animhandle==1119)
    {


	void self = getlocalvar("self");

	int Summon = getentityvar(self, 1);



        if(frame==0){

        setentityvar(self, 1, openborvariant("elapsed_time"));

        time = 0;

        }



         if(Summon <= openborvariant("elapsed_time") - 200){

         setentityvar(self, 1, NULL());

         performattack(self,openborconstant("ANI_FOLLOW1"));

         }

	        if(frame==0)
        {
            changeentityproperty(getlocalvar("self"), "Subject_to_Gravity", 0);
        }
        return;
    }
    if(animhandle==1120)
    {
        if(frame==0)
        {
            changeentityproperty(getlocalvar("self"), "Subject_to_Gravity", 0);
        }
        return;
    }

}

x)
 
Ah, I think its missing this line:
void self = getlocalvar("self");
int Summon = getentityvar(self, 1);
        int time;
But that code isn't using the var time, strange.

Here is my full code (I've made it move in a Sinusoid motion, so maybe I remove too much things when I post it here):
anim follow7
loop 1 1 3
delay 3
offset 300 100
fshadow 0
@script
void self = getlocalvar("self");
int Summon = getentityvar(self, 1);
        int time;
        int posx = getentityproperty(self, "x");

        float x,z;

        if(frame==0){

        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;

        }
        if (frame>0)
        {
        x = sin(time/0.45)/16;
        z = cos(time/0.45)/16;
        changeentityproperty(self, "velocity", 0.25, z, 0) ;
        time +=3;
        }

        if(Summon <= openborvariant("elapsed_time") - 2000){
        setentityvar(self, 1, NULL());
        performattack(self,openborconstant("ANI_FOLLOW8"));
        }
if(posx>=240)
{
        changeentityproperty(self, "velocity", 0, z, 0) ;
}

@end_script

frame data/chars/nave/heli1b.gif
sound data/sounds/heli.wav
frame data/chars/nave/heli2b.gif
frame data/chars/nave/heli1b.gif
 
This type of boss looks like it will be incredibly interesting and fresh to see play out. Reminds me of Dr. Dahm/Zero from SoR3, even.
 
Miru said:
This type of boss looks like it will be incredibly interesting and fresh to see play out. Reminds me of Dr. Dahm/Zero from SoR3, even.
That's actually what this is based.

O Ilusionista said:
Ah, I think its missing this line....
Sorry, by the time you replied it was about time for me to head to work and I barely had time to copy and paste your code into my flash drive. I spent time messing with this script because the boss kept moving crazy, but I looked over your code again and deleted all the extra stuff until I was left with the line I was missing. Good news is that the boss moves fine now, though it doesn't attack if I stand still, but will right when I move again, which doesn't fit the 300 ticks I gave it. The bad part is that the boss keeps moving as he does the attack, and I'd like to know how to make it stay in place until the animation is over.

Code:
anim walk
	loop	1 1 3
   @script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
        int time;

        if(frame==0){
        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;
        }

         if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
    }
   @end_script
	delay	2
	offset	205 583
	#	@cmd changeentityproperty getlocalvar("self") "Subject_to_Gravity" 0
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif

Code:
anim follow1
	loop	0
	delay	2
	offset	205 583
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	offset	205 550
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	offset	205 516
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	delay	80
	frame	data/chars/RoboCrusher/0.gif

x)
 
Good news is that the boss moves fine now, though it doesn't attack if I stand still, but will right when I move again, which doesn't fit the 300 ticks I gave it.
ah I see. So I think you have to split the code between the idle and walk animations:

Idle
Code:
@script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
        int time;

        if(frame==0){
        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;
        }

 if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
    }
@end_script

Walk
Code:
@script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
 if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
    }
   @end_script

I haven't tested it, but it should work.
 
O Ilusionista said:
Glad to know its working :) This gave me some ideas too...
Good to know you got something out of this.  ;)

Miru said:
I can't wait to see the final result...
Depends on how fast I work. The segment you fight this boss in is actually based on another final boss, so It'll be a cross between 2 final boss fights, and still isn't the end.

x)
 
Now THAT's nostalgia done right. (Which the games themselves have done half the time). And I would like to see this code again, it is an interesting concept.
 
Miru said:
Now THAT's nostalgia done right. (Which the games themselves have done half the time).
lol

And I would like to see this code again, it is an interesting concept.
Yeah, I was just coming here to do that in case anyone wants to see the final result.

Code:
anim idle
	loop	1 1 3
	@script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
        int time;

        if(frame==0){
        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;
        }

 if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
    }
@end_script
	delay	2
	offset	205 583
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif

Code:
anim walk
	loop	1 1 3
   @script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
 if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
    }
   @end_script
	delay	2
	offset	205 583
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif

Some of the coding in this Follow animation may not be needed but I don't know specifically which ones are it, I just copied what Illusion gave me with Velocity and changed the z's to 0's.

Code:
anim follow1
	loop	0
   @script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
        int time;
        int posx = getentityproperty(self, "x");

        float x,z;

        if(frame==0){

        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;

        }
        if (frame>0)
        {
        x = sin(time/0.45)/16;
        z = cos(time/0.45)/16;
        changeentityproperty(self, "velocity", 0, 0, 0) ;
        time +=3;
        }

         if(Summon <= openborvariant("elapsed_time") - 2000){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
         }
    if(posx>=240)
    {
        changeentityproperty(self, "velocity", 0, 0, 0) ;
    }

   @end_script
	delay	2
	offset	205 583
	#move 2
	frame	data/chars/RoboCrusher/0.gif
	move 0
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	offset	205 550
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	offset	205 516
	sound	data/chars/rash/steel.wav
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	delay	110
	frame	data/chars/RoboCrusher/0.gif

This is all the coding used for this boss.

x)
 
Yo guys, sorry to bump this back up but I'm having problems with Robocrusher's script. The script is still how it was when I pasted in my last post:
Code:
anim idle
	loop	1 1 3
	@script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
        int time;

        if(frame==0){
        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;
        }

 if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW1"));
    }
@end_script
	delay	2
	offset	205 583
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
Code:
anim walk
	loop	1 1 3
   @script
   void self = getlocalvar("self");
   int Summon = getentityvar(self, 1);
 if(Summon <= openborvariant("elapsed_time") - 300){
         setentityvar(self, 1, NULL());
         performattack(self,openborconstant("ANI_FOLLOW2"));
    }
   @end_script
	delay	2
	offset	205 583
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif
	frame	data/chars/RoboCrusher/0.gif

The only thing I changed is changing follow1 to 2 in follow1's animation, but I've been trying to test Robocrusher's stage and it keeps repeating it's Follow1, sometimes even after taking damage. Follow2 is just the end of Follow1's animation when it goes back up after the attack, in order to try and force it into another animation. I'm going to try changing this up again but if someone can think of anything, it would help.

EDIT:
Got the repeat to stop, but there was another issue I forgot to bring up, the entity sometimes doesn't follow the time script and keeps moving, not performing follow1 until it gets in a certain range.

x)
 
Let me confirm how Robocrusher acts:
1. It chases player
2. While chasing, it has timer to decide when to attack with FOLLOW1
3. After performing FOLLOW1, it goes back to IDLE then repeat from #1

Am I correct?

entity sometimes doesn't follow the time script and keeps moving, not performing follow1 until it gets in a certain range.

I think it's because it hasn't started timer yet
 
Bloodbane said:
Let me confirm how Robocrusher acts:
1. It chases player
2. While chasing, it has timer to decide when to attack with FOLLOW1
3. After performing FOLLOW1, it goes back to IDLE then repeat from #1

Am I correct?
You are, but I may have found a work around, not exactly what I wanted but I made an attack1 the same as follow1(without script) , gave it a short range, and added a high aggression #, giving it a better change to attack the player when it gets close, and I think it somehow helps the Crusher reset it's timer sometimes. Between that and the trap that takes up the whole floor, I think this is good enough. I wanted to come up with something before I bumped but I couldn't, my bad.

Code:
[quote]entity sometimes doesn't follow the time script and keeps moving, not performing follow1 until it gets in a certain range.[/quote]

 I think it's because it hasn't started timer yet
Yeah, I change the frame command from 0 to 1 to start the timer, but I don't think that made a difference.

x)
 
I noticed that you have redundant script in FOLLOW1

anim follow1
loop 0
  @script
  void self = getlocalvar("self");
  int Summon = getentityvar(self, 1);
        int time;
        int posx = getentityproperty(self, "x");

        float x,z;

        if(frame==0){

        setentityvar(self, 1, openborvariant("elapsed_time"));
        time = 0;

        }
        if (frame>0)
        {
        x = sin(time/0.45)/16;
        z = cos(time/0.45)/16;
        changeentityproperty(self, "velocity", 0, 0, 0) ;
        time +=3;
        }

        if(Summon <= openborvariant("elapsed_time") - 2000){
        setentityvar(self, 1, NULL());
        performattack(self,openborconstant("ANI_FOLLOW1"));
        }

    if(posx>=240)
    {
        changeentityproperty(self, "velocity", 0, 0, 0) ;
    }

  @end_script
delay 2
offset 205 583
#move 2
frame data/chars/RoboCrusher/0.gif
move 0
frame data/chars/RoboCrusher/0.gif
frame data/chars/RoboCrusher/0.gif
offset 205 550
frame data/chars/RoboCrusher/0.gif
frame data/chars/RoboCrusher/0.gif
frame data/chars/RoboCrusher/0.gif
offset 205 516
sound data/chars/rash/steel.wav
frame data/chars/RoboCrusher/0.gif
frame data/chars/RoboCrusher/0.gif
delay 110
frame data/chars/RoboCrusher/0.gif

The green texts aren't supposed to be here. I also don't think you need the rest of the script too, unless you want this crusher to move in sinusoid motion

I suggest change the script part into this:

Code:
anim follow1
@script
  if(frame==8){
    void self = getlocalvar("self");

    setentityvar(self, 1, openborvariant("elapsed_time"));
  }
@end_script
...

This script simply starts the timer at end of FOLLOW1

I suggest adding this to ensure timer starts

HTH
 
I applied your condensed script. The timer still doesn't reset sometimes and without the velocity part, it wont stop when doing Follow1. I've tried pasting it into your script but it makes the game crash every time, but I will need that back in there.

x)
 
Back
Top Bottom