function attack_script (caster, defender)
{
int noAttack = 0;
int playerDied = 0;
temp_caster = caster;
temp_defender = defender;
freeze_someone(temp_caster);
vec_set(target_location.x, temp_defender.x);
if (temp_caster.x > temp_defender.x) {target_location.x += 50;} else {target_location.x -= 50;}
move_to_location(temp_caster, target_location, yes);
get_casters_frames();
animate_caster_cycle(temp_caster_frames[run_start], temp_caster_frames[run_end], 1.5);
while (in_progress == yes) {wait(1);}
end_animate_caster_cycle = yes;
animate_caster(temp_caster_frames[attack_start], temp_caster_frames[attack_end], 1.8, yes);
while (in_progress == yes) {wait(1);}
/////////////////Randomize attack, if miss then goto skip the rest of the code so no damage is done.
randomize();
temp = random(100);
if (int(temp) < 10)
{
vec_set(temp,temp_defender.x);
vec_to_screen(temp, field_camera);
miss_text.pos_x = temp.x - 23;
miss_text.pos_y = temp.y - 70;
miss_text.visible = on;
wait(-1);
miss_text.visible = off;
noAttack = 1;
}
if(noAttack==0){
get_casters_stats();
get_defenders_stats();
damage = ((temp_caster_stats[atk])*2) - temp_defender_stats[def];
damage = max(damage, 0);
temp_defender_stats[current_hp] -= damage;
temp_defender_stats[current_hp] = max(temp_defender_stats[current_hp], 0);
affect_defenders_stats();
if (temp_defender_stats[current_hp] <= 0) {temp_defender_die();}
vec_set(temp,temp_defender.x);
vec_to_screen(temp, field_camera);
damage_pan.pos_x = temp.x - 23;
damage_pan.pos_y = temp.y - 70;
damage_pan.visible = on;
wait(-1);
damage_pan.visible = off;
if(temp_defender_stats[current_hp] <= 0) && (temp_caster) == (temp_defender) {freeze_someone(temp_defender); playerDied=1;}
}
if(playerDied==0){
temp_caster.pan -= 180;
get_starting_location(temp_caster);
move_to_location(temp_caster, starting_location, yes);
animate_caster_cycle(temp_caster_frames[run_start], temp_caster_frames[run_end], 1.5);
while (in_progress == yes) {wait(1);}
end_animate_caster_cycle = yes;
temp_caster.pan += 180;
unfreeze_someone(temp_caster);
}
wait(1);
death_check();
wait(1);
turn_check();
}