#GENERAL
*name       = "hairhair_lvl_03";
*faction    = "hair";
*enemy_faction = "good";

*rad        = 1.3;
*mass       = 6.0;
*elasticity = 0.2;
*drag       = 0.5;
*friction   = 6.5;
*hardness   = 0.3;

*model      = "npc_hairhair_01";
//*model_col  = colorRGB(1.0, 0.3, 0.3);
*model_scale = 2.0;
*bleed_rate = 3.0;
*leak_decal_vec = {"decals/big_blood_01.tga"};
*dam_part_vec = {"blood_01"};

#ATTRIBUTE "ccrange";
#BASE      2.0;
#ATTRIBUTE "ccspeed";
#BASE      mult(2, avar("ccspeed_level"));
#ATTRIBUTE "ccdamage";
#BASE      mult(3, avar("ccdamage_level"));
#ATTRIBUTE "projspeed";
#BASE      20;
#ATTRIBUTE "projdamage";
#BASE      mult(7, avar("projdamage_level"));
#ATTRIBUTE "projwait";
#BASE      2.0;
#ATTRIBUTE "projrange";
#BASE      19;
#ATTRIBUTE "attract";
#BASE      20.0;
#ATTRIBUTE "leak";
#BASE      0.0;
#ATTRIBUTE "speed";
#BASE      mult(19, avar("speed_level"));
#ATTRIBUTE "health";
#BASE      mult(250, avar("health_level"));
#ATTRIBUTE "res";
#BASE      1.0;
#ATTRIBUTE "rot_speed";
#BASE      100.0;
#ATTRIBUTE "exp";
#BASE      mult(3, avar("exp_level"));
#ATTRIBUTE "level";
#BASE      3;

#INTERACTION
#ACTION

#EVENT
##BEGIN
##END

#ON_DAMAGE
  // Bleed a little.
  sound_play( add("monsters/spit_0", num_to_str(rand(1, 4.99)), ".wav"), this_x(), this_y(), 1 );

#ON_DEATH

  avar("total_spawn", sub(avar("total_spawn"), 1));
  sound_play( add("monsters/squash_0", num_to_str(rand(1, 3.99)), ".wav"), this_x(), this_y(), 1 );

#CONTROL "script";
##BEGIN

#SEQUENCE "init";
# wait( .1, 1 );
  move(1000, 1000, 0);
# this_control_push("script", "monsters/ink");
  wait(.15, 1); message_box("hello");
  move_to( 1000, 1000, 0 );
# this_control_push("script", "monsters/money");
  wait(.15, 1);
  move_to( 1000, 1000, 0 );
# seq_jump(if(this_get_attribute("waiting"), "waiting", "attack"));

#SEQUENCE "attack";
# particle_make( "wood_dust_03", this_x(), this_y(), 1, rand(-2,2), rand(-2,2), rand(1,4), rand(-1,1) );
# this_control_jump( 
  "range faction",
  "*faction       = \"good\";
   *min_dist      = 0.0;
   *max_dist   = this_get_attribute(\"projrange\");
   *aggressive    = 0;
   *avoid_faction = \"hair\";
   *avoid_dist = rand(0,10);
   *predict_dist = 24;
   *predict_weight = .5;

// The action is going to be kinda hairy, because we've got to insert numerical
// values into a string.
*action =
  \"
    var script = \\\" \\\";
    script =
      add(
        \\\"  *faction       = \\\\\\\"good\\\\\\\";
            *move_x        = \\\", num_to_str( this_x(),  1 ),\\\"; 
			*move_y        = \\\", num_to_str( this_y(),  1 ),\\\"; 
		    *orig_x        = 0;
            *orig_y        = -1.0;
            *orig_z        = 1.3;
            *speed         = this_get_attribute(\\\\\\\"projspeed\\\\\\\");
            *shots         = 1;
            *rate          = 1;
            *error         = 5;
            *damage        = mult(this_get_attribute(\\\\\\\"projdamage\\\\\\\"), avar(\\\\\\\"projdamage_level\\\\\\\"));
            *particle      = \\\\\\\"wood_dust_02\\\\\\\";
            *vec_sounds    = { \\\\\\\"monsters/tree_shot_01.wav\\\\\\\", \\\\\\\"monsters/tree_shot_02.wav\\\\\\\" };
            *line_of_sight = 3.0;
		\\\"
        );

    this_control_push(
      \\\"shoot\\\",
      script,
      1
      );

	*wait = rand(sub(this_get_attribute(\\\"projwait\\\"), .5) , add(this_get_attribute(\\\"projwait\\\"), .5));
\";", 1.0);
# seq_jump("wait");

#SEQUENCE "waiting";
# this_control_jump( 
  "wait for faction",
  "*faction    = \"good\";
   *range = 24.0;
   *control = \"range faction\";
   *init = \"
	 *faction       = \\\"good\\\";
     *min_dist      = 0.0;
     *max_dist   = this_get_attribute(\\\"projrange\\\");
     *aggressive    = 0;
     *avoid_faction = \\\"hair\\\";
     *avoid_dist = rand(0,10);
     *predict_dist = 24;
     *predict_weight = .5;
	 *aggressive = 1;
	 *action     = \\\"
	 var script = \\\\\\\" \\\\\\\";
     script =
      add(
        \\\\\\\"  *faction       = \\\\\\\\\\\\\\\"good\\\\\\\\\\\\\\\";
            *move_x        = \\\\\\\", num_to_str( this_x(),  1 ),\\\\\\\"; 
			*move_y        = \\\\\\\", num_to_str( this_y(),  1 ),\\\\\\\"; 
		    *orig_x        = 0;
            *orig_y        = -1.0;
            *orig_z        = 1.3;
            *speed         = this_get_attribute(\\\\\\\\\\\\\\\"projspeed\\\\\\\\\\\\\\\");
            *shots         = 1;
            *rate          = 1;
            *error         = 5;
            *damage        = mult(this_get_attribute(\\\\\\\\\\\\\\\"projdamage\\\\\\\\\\\\\\\"), avar(\\\\\\\\\\\\\\\"projdamage_level\\\\\\\\\\\\\\\"));
            *particle      = \\\\\\\\\\\\\\\"wood_dust_02\\\\\\\\\\\\\\\";
            *vec_sounds    = { \\\\\\\\\\\\\\\"monsters/tree_shot_01.wav\\\\\\\\\\\\\\\", \\\\\\\\\\\\\\\"monsters/tree_shot_02.wav\\\\\\\\\\\\\\\" };
            *line_of_sight = 3.0;
		\\\\\\\"
        );

    this_control_push(
      \\\\\\\"shoot\\\\\\\",
      script,
      1
      );

	*wait = rand(sub(this_get_attribute(\\\\\\\"projwait\\\\\\\"), .5) , add(this_get_attribute(\\\\\\\"projwait\\\\\\\"), .5));
	 \\\";
  \";
  *file = 0.0;
  ",
  1.0
  );
# seq_jump("wait");

#SEQUENCE "wait";
# wait( 10000 );

##END