Hallo ihr lieben, ich hoffe das ihr mir weiter helfen könnt.
Ich versuche schon seit Tagen das mit der c_scan anweisung hinzubekommen aber ich schaffe es irgendwie nicht.
Hier ist mein Problem!
Ich starte das level und der Gegner scant den player wobei er dann ein sound ertönen lässt das klappt auch alles ganz gut nur wenn ich dann auf den Gegner schieße kommt immer die Fehlermeldung E1515 Invalid agruments in remove_bullets!
Hier ist der Code wäre schön wenn ihr mir sagen könntet was ich falsch mache!
//STRINGS///////////////////////////////////
STRING* bullet_mdl ="bullet.mdl";
//SOUNDS////////////////////////////////////
SOUND* explosin_wav ="explosin.wav";
SOUND* step_wav = "step.wav";
SOUND* death_wav = "death.wav";
//defines///////////////////////////////////
#define health skill1
//vars - global/////////////////////////////
var health;
//FUNCTIONS/////////////////////////////////
function move_bullets();
function remove_bullets();
function attach_weapon();
action players_code();
function got_shot();
action my_enemy();
//player//////////////////////
action players_code()
{ player = my;
var sounded_once;
var anim_percentage;
set(my, INVISIBLE);
var death_handle;
ent_create ("M.mdl", nullvector, attach_weapon);
while (1)
{
c_move (player,vector(10 * (key_w - key_s) * time_step, 6 * (key_a - key_d) * time_step, 0), nullvector,
IGNORE_PASSABLE | GLIDE);
vec_set (camera.x, player.x);
camera.z += 30;
camera.pan -= 5 * mouse_force.x * time_step;
camera.tilt += 3 * mouse_force.y * time_step;
player.pan = camera.pan;
wait (1);
}
}
function attach_weapon()
{
VECTOR bullet_pos[3];
set(my, PASSABLE);
while (1)
{
vec_set (my.x, vector (20, -10, 15));
vec_rotate (my.x, you.pan);
vec_add (my.x, you.x);
my.pan = you.pan;
my.tilt = camera.tilt;
if (mouse_left && (total_frames % 10 == 1)) // fire 6 bullets per second at a frame rate of 60
{
vec_for_vertex(bullet_pos, my, 6);
ent_create("bullet.mdl", bullet_pos, move_bullets);
snd_play (explosin_wav, 100, 0);
}
wait (1);
}
}
function move_bullets()
{
var death_handle;
VECTOR bullet_speed[3];
my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_BLOCK ;
my.event = remove_bullets;
my.pan = camera.pan;
my.tilt = camera.tilt;
my.skill30 = 1; // player's bullets will have their skill100 set to 999,999
bullet_speed.x = 50 * time_step;
bullet_speed.y = 0;
bullet_speed.z = 0;
while (my)
{
c_move (my, bullet_speed, nullvector, IGNORE_PASSABLE | IGNORE_YOU );
wait(1);
}
}
function got_shot()
{
if (you.skill30 != 1)
{
return;
}
my.health -=10;
if(my.health==0)
{
my.skill99=1;
return;
}
}
action my_enemy()
{
var anim_percentage = 0;
var walk_percentage;
var death_handle;
set(my, POLYGON);
my.health=100;
my.skill99 = 0;
my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY );
my.event = got_shot; // and runs this function when it is hit
while(!player){wait(1);}
while (my.skill99 == 0)
{
if ((c_scan(my.x,my.pan, vector(120, 60, 1000), IGNORE_ME ) > 0) && (you == player))
{
if (!snd_playing(death_handle)) // the alarm sound isn't playing already?
{
death_handle = snd_play(death_wav, 70, 0); // then let's play it!
ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // play the "walk" animation in a loop
anim_percentage += 3 * time_step; // 2 controls the walk animation speed
}
}
else
{
c_move (my, vector(5 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
my.pan += 3 * time_step; // make the enemy rotate in a circle
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation in a loop
anim_percentage += 3 * time_step; // 2 controls the walk animation speed
}
wait (1);
}
my.event = NULL;
anim_percentage = 0;
while (anim_percentage < 100) // the loop runs until the "death" animation percentage reaches 100%
{
ent_animate(my, "death", anim_percentage, NULL); // play the "die" animation only once
anim_percentage += 3 * time_step; // "3" controls the animation speed
wait (1);
}
set (my, PASSABLE);// allow the player to pass through the corpse now
}
function remove_bullets()
{
wait(1);
ent_remove(my);
}