name		CBunker
type		enemy
health		100
#facing		1
nomove		1 1
death		1
animationscript data/scripts/enemy.c

load		Cobra_Officer
load		Crimson_Guard
load		Dog
load		Viper2


anim idle
@script
    void self = getlocalvar("self");
    int Health = getentityproperty(self, "health");
    int Enemy = openborvariant("count_enemies");

    if( Enemy == 1){
      if( Health > 0){
        int r = rand()%40;

        if( r > 20){
          performattack(self, openborconstant("ANI_FOLLOW1"));
        } else if( r < -20) {
          performattack(self, openborconstant("ANI_FOLLOW2"));
        } else if( r > 0 && r <= 20 ){
          performattack(self, openborconstant("ANI_FOLLOW3"));
        } else {
          performattack(self, openborconstant("ANI_FOLLOW4"));
        }
        changeentityproperty(self, "health", Health-10);
      } else {
        killentity(self); //Suicide!
      }
    }
@end_script
        loop	1
	delay	20
	offset	1 1
        frame	data/chars/misc/empty.gif
        frame	data/chars/misc/empty.gif

anim follow1
	delay	10
	offset	1 1
        frame	data/chars/misc/empty.gif
        delay	200
        @cmd	spawn01 "Cobra_Officer" 0 0 2
        @cmd	spawn01 "Crimson_Guard" 28 0 2
        frame	data/chars/misc/empty.gif
	delay	10
	@cmd	beidle
        frame	data/chars/misc/empty.gif

anim follow2
	delay	10
	offset	1 1
        frame	data/chars/misc/empty.gif
        delay	200
        @cmd	spawn01 "Cobra_Officer" 0 0 2
        @cmd	spawn01 "Dog" 28 0 2
        frame	data/chars/misc/empty.gif
	delay	10
	@cmd	beidle
        frame	data/chars/misc/empty.gif

anim follow3
	delay	10
	offset	1 1
        frame	data/chars/misc/empty.gif
        delay	200
        @cmd	spawn01 "Viper2" 0 0 2
        @cmd	spawn01 "Crimson_Guard" 28 0 2
        frame	data/chars/misc/empty.gif
	delay	10
	@cmd	beidle
        frame	data/chars/misc/empty.gif

anim follow4
	delay	10
	offset	1 1
        frame	data/chars/misc/empty.gif
        delay	200
        @cmd	spawn01 "Viper2" 0 0 2
        @cmd	spawn01 "Dog" 28 0 2
        frame	data/chars/misc/empty.gif
	delay	10
	@cmd	beidle
        frame	data/chars/misc/empty.gif


anim death
        offset	1 1
        delay	60
        frame	data/chars/misc/empty.gif
