action opponent_ninja_C()
{
// my.material = mtl_toon; //füge im den Toon Shader zu
VECTOR temp; //3 lokale vectoren
VECTOR my_speed;
VECTOR new_point;
var turn[3]; //5 lokale variablen
var turn_help;
var move_lenght = 0;
////
c_setminmax(me); //setzt die kollision
set(me, POLYGON | CAST); //setzt in auf Poligon genau erkennung - und das Cast flag
my.alpha = 100; //setzt die Tranzperent auf 0
my.emask |= ENABLE_IMPACT; //Empfindlich für berührung
my.event = loose_health;
my.health = 100; //meine helath points auf 100
while(player == NULL) wait(1); //warte bis der spieler erstellt wurde
wait(1);
while(my.health > 50) //solange der Spieler lebt
//here begins enemys 1 action
{
if((move_lenght <= 0)&&(vec_dist(my.x, player.x) < 300)) //wenn die Distanz zum Spieler kleiner als 300 quants ist und er sich ich twohin bewegen soll
{
var stand_per; //lokale Variable
ent_animate(my, "stand", stand_per, ANM_CYCLE); //spiele stand anomation
stand_per += 7 * time_step;
vec_set(temp, player.x); //berechne den Winkél zum spieler
vec_sub(temp, my.x);
vec_to_angle(turn, temp);
if(turn[0] < 0) turn[0] += 360; //die nächsten zeilen sind für das drehen des Spieler (es ist so lang da es immer den kürzesten weg dreht)
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
if(turn[0] > turn[1] && turn[0] < turn[1] + 180)
{
while(turn[0] > turn[1])
{
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
if(turn[0] < turn[1] - 180 && turn[0] < 180 && turn[1] > 180)
{
while(turn[0] > turn[1] || turn_help == 0)
{
if(my.pan > 360) my.pan -= 360;
if(my.pan < 179 && my.pan > 0) turn_help = 1;
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
if(turn[0] > turn[1] + 180 && turn[0] > 180 && turn[1] < 180)
{
while(turn[1] > turn[0] || turn_help == 0)
{
if(my.pan < 0) my.pan += 360;
if(my.pan > 181 && my.pan < 360) turn_help = 1;
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] > 360) turn[1] -= 360;
wait(1);
}
}
if(turn[0] < turn[1] && turn[0] > turn[1] - 180)
{
while(turn[0] < turn[1])
{
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0; //hilfvariable zurücksetzen
my.tilt = 0; //setze die drehungen der anderen winkel wieder auf 0
my.roll = 0;
ent_create("blaster_ball.mdl", vec_for_vertex(temp, me, 957), enemy_blaster_shoot); //erstelle eine Kugel
new_point.x = my.x + random(500)-250; //setze irgendwo in Abstand von 250 quants einen Punkt
new_point.y = my.y + random(500)-250;
new_point.z = my.z;
if(c_content(new_point, 0) != 3) //wenn der neue Punkt in nicht drin ist
{
move_lenght = vec_dist(new_point, my.x); //setze die distanz auf den Abstand zwischen dem Punkt und meiner Positoin
}
else //wiederhole es wenn nciht
{
new_point.x = my.x + random(500)-250;
new_point.y = my.y + random(500)-250;
new_point.z = my.z;
if(c_content(new_point, 0) != 3)
{
move_lenght = vec_dist(new_point, my.x);
}
}
ent_animate(my, "stand", stand_per, ANM_CYCLE); //animiere in Stand animation
stand_per += 7 * time_step;
vec_set(temp, new_point); //finde winkel zum neuen punkt
vec_sub(temp, my.x);
vec_to_angle(turn, temp);
if(turn[0] < 0) turn[0] += 360; //die drehung(beschreibung oben)
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
if(turn[0] > turn[1] && turn[0] < turn[1] + 180)
{
while(turn[0] > turn[1])
{
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
if(turn[0] < turn[1] - 180 && turn[0] < 180 && turn[1] > 180)
{
while(turn[0] > turn[1] || turn_help == 0)
{
if(my.pan > 360) my.pan -= 360;
if(my.pan < 179 && my.pan > 0) turn_help = 1;
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
if(turn[0] > turn[1] + 180 && turn[0] > 180 && turn[1] < 180)
{
while(turn[1] > turn[0] || turn_help == 0)
{
if(my.pan < 0) my.pan += 360;
if(my.pan > 181 && my.pan < 360) turn_help = 1;
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] > 360) turn[1] -= 360;
wait(1);
}
}
if(turn[0] < turn[1] && turn[0] > turn[1] - 180)
{
while(turn[0] < turn[1])
{
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
my.tilt = 0;
my.roll = 0;
wait(-0.1);
}
if(move_lenght > 0) //wenn er sich bewegen soll
{
var walk_per;
my_speed.x = 6 * time_step;
c_move(me, my_speed, nullvector, GLIDE | IGNORE_PASSABLE); //bewegt ihn
move_lenght -= my_speed.x;
ent_animate(my, "walk", walk_per, ANM_CYCLE); //und animiert ihn in seiner Walk animation
walk_per += 12 * time_step;
}
else
{
var stand_per; //sonst stand animation
ent_animate(my, "stand", stand_per, ANM_CYCLE);
stand_per += 7 * time_step;
}
result = c_trace(my.x, vector(my.x, my.y, my.z - 500), IGNORE_ME | IGNORE_YOU | IGNORE_SPRITES | IGNORE_MODELS | USE_BOX); //graviation
vec_set(temp, nullvector);
temp.z = result*(-1);
c_move(me, temp, nullvector, GLIDE);
wait(1);
}
opponent_ninja_C_wounded();
}
/////
function opponent_ninja_C_wounded()
{
VECTOR temp; //3 lokale vectoren
VECTOR my_speed;
VECTOR new_point;
VECTOR sword_start, sword_end;
var turn[3]; //5 lokale variablen
var attack_per;
var turn_help;
var move_lenght = 0;
////
set(me, TRANSLUCENT);
my.alpha = 100;
ent_create("cell_bumm01.pcx", vec_for_vertex(temp, my, 2358), explode);
wait(-0.1);
ent_create("cell_bumm01.pcx", vec_for_vertex(temp, my, 334), explode);
wait(-0.05);
ent_create("cell_bumm01.pcx", vec_for_vertex(temp, my, 2721), explode);
ent_morph(me, "ninja.mdl");
reset(my, TRANSLUCENT);
wait(-1);
my.scale_x = 1.5;
my.scale_y = 1.5;
my.scale_z = 1.5;
c_setminmax(me);
while(my.health > 0)
//here begins enemys 2 action
{
if((move_lenght <= 0)&&(vec_dist(my.x, player.x) < 300))
{
var stand_per;
ent_animate(my, "stand", stand_per, ANM_CYCLE);
stand_per += 7 * time_step;
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(turn, temp);
if(turn[0] < 0) turn[0] += 360;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
if(turn[0] > turn[1] && turn[0] < turn[1] + 180)
{
while(turn[0] > turn[1])
{
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
if(turn[0] < turn[1] - 180 && turn[0] < 180 && turn[1] > 180)
{
while(turn[0] > turn[1] || turn_help == 0)
{
if(my.pan > 360) my.pan -= 360;
if(my.pan < 179 && my.pan > 0) turn_help = 1;
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
if(turn[0] > turn[1] + 180 && turn[0] > 180 && turn[1] < 180)
{
while(turn[1] > turn[0] || turn_help == 0)
{
if(my.pan < 0) my.pan += 360;
if(my.pan > 181 && my.pan < 360) turn_help = 1;
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] > 360) turn[1] -= 360;
wait(1);
}
}
if(turn[0] < turn[1] && turn[0] > turn[1] - 180)
{
while(turn[0] < turn[1])
{
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
my.tilt = 0;
my.roll = 0;
var walk_per = 0;
while(vec_dist(my.x, player.x) > 50)
{
c_move(me, vector(5 * time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE);
ent_animate(my, "walk", walk_per, ANM_CYCLE);
walk_per += 12 * time_step;
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
wait(1);
}
vec_zero(temp);
attack_per = 0;
while(attack_per < 98)
{
vec_for_vertex(sword_start, my, 509);
vec_for_vertex(sword_end, my, 510);
ent_animate(me, "attack_sword_up", attack_per, ANM_CYCLE);
attack_per += 5 * time_step;
if((c_trace(sword_start, sword_end, IGNORE_ME | IGNORE_PASSABLE) > 0)&&(attack_per > 60))
{
if(you == player)
{
printf("Wuhu, i hit you! xD ^^ ROFL", NULL);
}
}
wait(1);
}
new_point.x = my.x + random(500)-250;
new_point.y = my.y + random(500)-250;
new_point.z = my.z;
if(c_content(new_point, 0) != 3)
{
move_lenght = vec_dist(new_point, my.x);
}
ent_animate(my, "stand", stand_per, ANM_CYCLE);
stand_per += 7 * time_step;
vec_set(temp, new_point);
vec_sub(temp, my.x);
vec_to_angle(turn, temp);
if(turn[0] < 0) turn[0] += 360;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
if(turn[0] > turn[1] && turn[0] < turn[1] + 180)
{
while(turn[0] > turn[1])
{
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
if(turn[0] < turn[1] - 180 && turn[0] < 180 && turn[1] > 180)
{
while(turn[0] > turn[1] || turn_help == 0)
{
if(my.pan > 360) my.pan -= 360;
if(my.pan < 179 && my.pan > 0) turn_help = 1;
my.pan += 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
if(turn[0] > turn[1] + 180 && turn[0] > 180 && turn[1] < 180)
{
while(turn[1] > turn[0] || turn_help == 0)
{
if(my.pan < 0) my.pan += 360;
if(my.pan > 181 && my.pan < 360) turn_help = 1;
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] > 360) turn[1] -= 360;
wait(1);
}
}
if(turn[0] < turn[1] && turn[0] > turn[1] - 180)
{
while(turn[0] < turn[1])
{
my.pan -= 8 * time_step;
turn[1] = my.pan;
if(turn[1] < 0) turn[1] += 360;
wait(1);
}
}
turn_help = 0;
my.tilt = 0;
my.roll = 0;
wait(-0.1);
}
if(move_lenght > 0)
{
var walk_per;
my_speed.x = 6 * time_step;
c_move(me, my_speed, nullvector, GLIDE | IGNORE_PASSABLE);
move_lenght -= my_speed.x;
ent_animate(my, "walk", walk_per, ANM_CYCLE);
walk_per += 8 * time_step;
}
else
{
var stand_per;
ent_animate(my, "stand", stand_per, ANM_CYCLE);
stand_per += 7 * time_step;
}
result = c_trace(my.x, vector(my.x, my.y, my.z - 500), IGNORE_ME | IGNORE_YOU | IGNORE_SPRITES | IGNORE_MODELS | USE_BOX);
vec_set(temp, nullvector);
temp.z = result*(-1);
c_move(me, vector(0,0,temp.z), nullvector, GLIDE);
wait(1);
}
opponent_ninja_C_dying();
}
/////
function opponent_ninja_C_dying()
{
var dead_per = 0;
////
while(dead_per < 98)
{
ent_animate(me, "death", dead_per, ANM_ADD);
dead_per += 5 * time_step;
wait(1);
}
set(me, PASSABLE | TRANSLUCENT);
wait(-1);
while(my.alpha > 10)
{
my.alpha -= 10 * time_step;
wait(1);
}
ptr_remove(me);
}