Well...it's definately not a c_... problem. Everything seems alright exept from the function execution time with an increasing number of entities....can this be due to the amount of skills? Should I better use different skills for both the enemy action and the player action?
The enemy action looks like this:
Code:
action act_enemy_fight
{
ent_enemy = my;
wait(5);//this is needed to have a valid "you" pointer when using the enemy generator
if(my.use_entity_type_settings == on){
entity_type_settings();
}
else{
////set default values
if(my.entity_type_id == 0){my.entity_type_id = 1;}//0 is reserved for player entity
if(my.initial_health == 0){my.initial_health = 100;}
if(my.do_damage_factor == 0){my.do_damage_factor = 0.5;}
if(my.attack_range == 0){my.attack_range = 400;}
if(my.close_attack_dist == 0){my.close_attack_dist = 50;}
if(my.attack_push_force == 0){my.attack_push_force = 5;}
if(my.attack_seeze_sleep == 0){my.attack_seeze_sleep = 0.3;}
if(my.attack_seeze_random_sleep == 0){my.attack_seeze_random_sleep = 0.4;}
if(!my.entity_move_speed){my.entity_move_speed = 4;}
if(!my.norm_state_move_ai){my.norm_state_move_ai = 1;}
if(!my.entity_walk_run_animspeed){my.entity_walk_run_animspeed = 8;}
if(!my.entity_attack_hurt_animspeed){my.entity_attack_hurt_animspeed = 8;}
if(!my.entity_stand_idle_animspeed){my.entity_stand_idle_animspeed = 5;}
if(!my.entity_crouch_jump_animspeed){my.entity_crouch_jump_animspeed = 6;}
if(!my.entity_death_animspeed){my.entity_death_animspeed = 7;}
if(my.path_start_node_f == 0){my.path_start_node_f = 1;}
my.path_number_f = 001;
my.entity_reusable_weapons = on;
my.allow_weapon_pickup = on;
my.use_tilt_f = 0;
my.use_roll_f = 0;
}
////flag/skill settings to start with
my.weapon_do_damage_factor = 0;
my.health = my.initial_health;
my.is_attacking = off;
my.is_under_attack = off;
my.has_path = 0;
my.rh_weapon = off;
my.lh_weapon = off;
////show healthbar for boss enemies or normal enemies (above head)
if(my.health_bar_type > 0){
if(my.health_bar_type == health_bar_boss_type){
health_bar_boss();
}
if(my.health_bar_type == health_bar_above_head_type){
ent_create (bmp_health_bar_seg, my.pos, health_bar_above_head);
}
}
my.passable = off;
////collision hull stuff
// my.fat = on;
// my.narrow = off;
c_setminmax(me);
wait(1);
// my.polygon = on;
////enable events
my.enable_scan = on;
my.event = enemy_search_event_fight;
entity_initial_weapons();
while(my && my.health > 0)
{
handle_animation(my,1);
////if player exists
if(player != null)
{
////if player is alive
if(player.health > 0)
{
////if player is in range
if(vec_dist(my.x,player.x) < my.attack_range)
{
randomize();
var attack_mode;
attack_mode = int(random(2))+1;
////if is in attack range...and not not in event (being hit)
if(vec_dist(my.x,player.x) < my.close_attack_dist)
{
//look at player
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);
my.tilt = 0;
if(my.is_attacking == off && my.is_under_attack == off){// && player.is_attacking == off
////perform the attack
if(attack_mode == 1){
enemy_attack_a();
}
if(attack_mode == 2){
enemy_attack_b();
}
}
}
else{
avoid_obstacle(player.x);
////play run animation...
if (my.f_animblend != f_run)//if our current animation is not the one we want...
{
my.f_blendframe = f_run;
}
my.speed_x = (my.entity_move_speed * 1.6) * time_step;
}
}
else
{
////different move ai options when out of attack_range (selectable trough skill15)
if(my.norm_state_move_ai == stand_ai){
if (my.f_animblend != f_stand)//if our current animation is not the one we want...
{
my.f_blendframe = f_stand;
}
my.speed_x = 0;
}
if(my.norm_state_move_ai == free_walk_ai){
avoid_obstacle(player.x);
if (my.f_animblend != f_walk)//if our current animation is not the one we want...
{
my.f_blendframe = f_walk;
}
my.speed_x = my.entity_move_speed * time_step;
}
if(my.norm_state_move_ai == use_path_ai){
if (my.f_animblend != f_walk)//if our current animation is not the one we want...
{
my.f_blendframe = f_walk;
}
my.speed_x = my.entity_move_speed * time_step;
walk_path();
}
}
}
else{
////switch to stand animation when player is dead
if (my.f_animblend != f_stand)//if our current animation is not the one we want...
{
my.f_blendframe = f_stand;
}
}
}
////do not float in the air!
attach_to_ground();
////perform movement
move_friction = 0.1;
c_move(my,vector(my.speed_x,my.speed_y,0),vector(my.pushback_speed_x,my.pushback_speed_y,my.speed_z),ignore_passable + ignore_passents + ignore_me + glide);
////clear movement vector...ready for next frame
vec_set(my.speed_x,nullvector);
vec_set(my.pushback_speed_x,nullvector);
wait(1);
}
////reset event/triggers
my.enable_scan = off;
my.event = null;
snd_play(aah_wav,40,0);
wait(1);
////play death
my.skill50 = 0;
while(my.skill50 < 100){
ent_animate(my,"die",my.skill50,0);
my.skill50 += my.entity_death_animspeed * time_step;
wait(1);
}
////clear movement vector...ready for next frame
vec_set(my.speed_x,nullvector);
my.alpha = 100;
my.transparent = on;
while(my.alpha > 0)
{
my.alpha -= time_step;
if(my.alpha < 90){
my.passable = on;
}
wait(1);
}
boss_health_bar.visible = off;
ent_remove(me);
me = null;
dead_enemies += 1;
num_enemies -= 1;
if(dead_enemies == 5)
{
wait(-2);
// exit;
}
}