#GENERAL
*name    = "player";
*faction = "player";

*rad        = 0.9;
*mass       = 20.0;
*elasticity = 0.3;
*drag       = 2.0;
*friction   = 8.0;
*hardness   = 0.3;
*roll       = 1;
*col_dam_ignore = 30.0;

*model = "pc_eye_01";
*model_scale = 1.0;
*grasper_model = "brush_01";
*bleed_rate = 3.0;
*leak_decal_vec = {"decals/big_blood_01.tga"};
*dam_part_vec = {"blood_01"};

//add_move_sounds( "default", "gulp_01.wav" );
add_impact_sounds( "default", "monsters/squash_01.wav", "monsters/squash_02.wav", "monsters/squash_03.wav" );
*stride = 4.75;


#ATTRIBUTE "blitz";
#BASE      0.0;
#STEP      0.0;
#HELP      "How quickly you can charge up your blitz attack.";

#ATTRIBUTE "ccdamage";
#BASE      2.0;
#STEP      0.0;
#HELP      "The power of your close combat attack.";

#ATTRIBUTE "pull";
#BASE      1500.0;
#STEP      750.0;
#HELP      "How much force you exert on objects when pulling them.";

#ATTRIBUTE "punch";
#BASE      0.0;
#STEP      0.0;
#HELP      "Your punching skill.";

#ATTRIBUTE "speed";
#BASE      90.0;
#STEP      25.0;
#HELP      "How quickly you can roll.";

#ATTRIBUTE "ccrange";
#BASE      1.5;
#ATTRIBUTE "ccspeed";
#BASE      500.0;
#ATTRIBUTE "health";
#BASE      25.0;
#ATTRIBUTE "regen";
#BASE      25.0;
#ATTRIBUTE "paint max";
#BASE      300.0;
#ATTRIBUTE "paint refill level";
#BASE      .2;
#ATTRIBUTE "paint refill rate";
#BASE      150;
#ATTRIBUTE "paint rate";
#BASE      0.025;
#ATTRIBUTE "item range";
#BASE      10.0;
#ATTRIBUTE "attract";
#BASE      20.0;
#ATTRIBUTE "leak";
#BASE      0.0;
#ATTRIBUTE "res";
#BASE      1.0;
#ATTRIBUTE "rot_speed";
#BASE      100.0;
#ATTRIBUTE "exp";
#BASE      0.0;
#ATTRIBUTE "skill";
#BASE      0.0;
#ATTRIBUTE "level";
#BASE      1.0;
#ATTRIBUTE "laser";
#BASE      0.0;
#ATTRIBUTE "explosion";
#BASE      0.0;
#ATTRIBUTE "vortex";
#BASE      0.0;
#ATTRIBUTE "money";
#BASE      0.0;
#ATTRIBUTE "repaints";
#BASE      0.0;
#ATTRIBUTE "opening";
#BASE      0.0;

#ON_SPELL_CIRCLE
  // Get the player's laser skill attribute.
  var laser = char_get_attribute( "player", "laser" );
  // Determine whether or not we can use a laser.
  var can_use = greater( laser, 0 );
  // We'll need a function variable for later.
  var func = nop;

  // Calculate how to shoot the laser at the center of the circle.
  var tx = char_get_x("player");
  var ty = char_get_y("player");
  var tz = get_land_height( tx, ty );
  var dx = sub( *x, tx );
  var dy = sub( *y, ty );
  var dist = sqrt( add( mult(dy,dy), mult(dx,dx) ) );
  var dz = sub( get_land_height( *x, *y ), tz );
  var speed = mult(div( *rad, 5 ), 50);
  dx = mult( speed, div( dx, dist ) );
  dy = mult( speed, div( dy, dist ) );

  // Figure out which particle we should use for the projectile.
  var part_num = div( *rad, 2.0 );
  part_num = if( less(    part_num, 1 ), 1, part_num );
  part_num = if( greater( part_num, 6 ), 6, part_num );
  var part_name = add( "shot_0", num_to_str( part_num ) );

  // Run the actual projectile making function, if we have the skillz.
  func = if( can_use, projectile_make, nop );
  func( tx, ty, add(1,tz), dx, dy, div(dz,div(dist,speed)), 0, 0, 0, mult( 20, *rad ), part_name );
  // Play a laser shooting sound.
  func = if( can_use, sound_play, nop );
  func( add("player/shot_0", num_to_str(rand(1, 3.99)), ".wav"), char_get_x("player"), char_get_y("player"), 1 );

  // If the player has a higher level laser skill, add more lasers.
  var shoot_x = add( *x, rand( mult(-.5,*rad), mult(.5,*rad) ) );
  var shoot_y = add( *y, rand( mult(-.5,*rad), mult(.5,*rad) ) );
  dx = sub( shoot_x, tx );
  dy = sub( shoot_y, ty );
  dz = sub( get_land_height( shoot_x, shoot_y ), tz );
  dist = sqrt( add( mult(dy,dy), mult(dx,dx) ) );
  dx = mult( speed, div( dx, dist ) );
  dy = mult( speed, div( dy, dist ) );
  func = if( greater( laser, 1 ), projectile_make, nop );
  func( tx, ty, add(1,tz), dx, dy, div(dz,div(dist,speed)), 0, 0, 0, mult( 20, *rad ), part_name );

  shoot_x = add( *x, rand( mult(-.5,*rad), mult(.5,*rad) ) );
  shoot_y = add( *y, rand( mult(-.5,*rad), mult(.5,*rad) ) );
  dx = sub( shoot_x, tx );
  dy = sub( shoot_y, ty );
  dz = sub( get_land_height( shoot_x, shoot_y ), tz );
  dist = sqrt( add( mult(dy,dy), mult(dx,dx) ) );
  dx = mult( speed, div( dx, dist ) );
  dy = mult( speed, div( dy, dist ) );
  func = if( greater( laser, 1 ), projectile_make, nop );
  func( tx, ty, add(1,tz), dx, dy, div(dz,div(dist,speed)), 0, 0, 0, mult( 20, *rad ), part_name );

#ON_SPELL_FAIL
  // Play an error sound.
  sound_play( "fail.wav" );

#ON_SPELL_LINE
  // Make a push circle.
  var vx = mult( 35, sub( *x2, *x1 ) );
  var vy = mult( 35, sub( *y2, *y1 ) );
  var length = sqrt( add( mult(vx,vx), mult(vy,vy) ) );
  var vz = mult( 0.1, length );
  vz = if( greater( vz, 35 ), 35, vz );
  push_circle_make( *x1, *y1, 2.75, vx, vy, vz );

#ON_SPELL_SCRIBBLE
  // Get the player's explosion skill attribute.
  var explosion = char_get_attribute( "player", "explosion" );
  // Determine whether or not we can use an explosion.
  var can_use = greater( explosion, 0 );
  // We'll need a function variable for later.
  var func = nop;

  // We don't want little scribbles to get too dense.
  var rad_div_five = div( *rad, 5 );
  *density = if( less( *rad, 5 ),
                 mult( *density, rad_div_five, rad_div_five ),
				 *density );

  // Figure out which particle we should use.
  var part_num = div( *density, 10 );
  part_num = if( less(    part_num, 1 ), 1, part_num );
  part_num = if( greater( part_num, 6 ), 6, part_num );
  var part_name = add( "fire_0", num_to_str( part_num ) );

  // If our explosion skill is high enough, double damage and make us immune.
  var high_skill = greater( explosion, 1 );
  var damage = mult(*density, sqrt(sqrt(*density)), 2.5);
  damage = if( high_skill, mult(2,damage), damage );
  var ignore_fac = "";
  ignore_fac = if( high_skill, "player", "" );

  // Make the explosion, if we have the ability.
  func = if( can_use, explosion_make, nop );
  func( *x, *y, *rad, 0.4, damage, 0, 0, ignore_fac, part_name );
  // Play an exploding sound.
  func = if( can_use, sound_play, nop );
  func( add("player/explode_0", num_to_str(rand(1, 3.99)), ".wav"), char_get_x("player"), char_get_y("player"), 1 );
  // Make a dent in the ground.
  func = if( can_use, land_changer_make, nop );
  var lower = div( damage, -50 );
  lower = if( less( lower, -3 ), -3, lower );
  func( *x, *y, 0, *rad, 0, 1, lower, lower, 0, 1.0, 0.4 );

#ON_SPELL_SPIRAL
  // Get the player's vortex skill attribute.
  var vortex = char_get_attribute( "player", "vortex" );
  // Determine whether or not we can use an vortex.
  var can_use = greater( vortex, 0 );
  // We'll need a function variable for later.
  var func = nop;

  // Figure out how strong to make the vortex.
  var force = mult( 500, *turns, if( *inward, -1.25, 0.125 ) );
  var trans_force = mult(force, 0.075);
  trans_force = if( *left_handed, trans_force, mult(-1,trans_force) );
  var vert_force = mult( *turns, if( *inward, 5, -15 ), gvar("env_gravity") );
  var max_vert_force = mult( -40, gvar("env_gravity") );
  vert_force = if( greater( vert_force, max_vert_force ), max_vert_force, vert_force );

  // If we have the skill, make the vortex.
  func = if( can_use, vortex_make, nop );
  func( *x_in, *y_in, mult(1.25,*rad), force, trans_force, vert_force, 0.0, mult(0.25,*turns) );
  func = if( can_use, sound_play, nop );
  func( if(*inward, "wind_in.wav", "wind_out.wav"), *x_in, *y_in, 1, 24);

#ON_SPELL_STAR
  var func = nop;
  func = if(avar("teleport"), script_load, nop);
  func("player/teleport");
  func = if(and(avar("star_learning"), eq(char_get_attribute( "player", "opening" ), 2)), load_event, nop);
  func("city/tut_star");
  //message_box(add("Repaints:", num_to_str(char_get_attribute("player","repaints"))));
  //teleport_player("forest_02", 127, 3 );

#ON_DAMAGE
  // If we're dead, bring us back to life.
  var func = nop;
  func = if( leq(*health, 0.0), script_load, nop );
  func( "player/repaint" );
  script_load("player/dying");
  sound_play( add("player/ow_0", num_to_str(rand(1, 5.99)), ".wav"));

#CONTROL "human";
##BEGIN

##END
