http://xkcd.com/292/

I'll look at your code..but wheres the problem to post it in 2 little code-tags? That would make it much easyier for people to look at it...please do that

Code:
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();

}


It's not really the best code...I just created 2 local variables and check them by 2 if functions. I'm sure there are a lot of better ways to do it, but I don't have the time for it. (I also replaced sleep(1), which is obsolete syntax by wait(-1))

Last edited by Scorpion; 08/09/08 13:48. Reason: added new code