// goblinpunch.txt v1.0
// Author : Terror's Martyr
// (And a hearty thanks to Khoth and Imban for helping me debug this!)
// Email : terrorsmartyr@wi.rr.com
//
// This script causes the creature to be immobile, but
// the creature will seek out and hit a few enemies per
// turn with a "punch" that does random damage of
// a random type, with a random boom type and a
// random zap type.  Can cause "interesting" combat
// if used.
//
// Cell 0 - How Many Punches Plus 1, TIMES TWO
// (Meaning, if you set cell 0 to be 1, then
// there will be four punches.  Setting it to
// 2 results in 6, etc.)
// Cell 1 - Minimum Damage
// Cell 2 - Maximum Damage

begincreaturescript;

variables;

short poink,px,py,mx,my,ok,gc;

body;

beginstate INIT_STATE;
break;

beginstate DEAD_STATE;
break;

beginstate START_STATE; 


gc = get_memory_cell(0) + 1;

ok = 0;

if(enemies_nearby(10) == 0)
end();

while(ok < gc){

	poink = get_ran(1,0,120);
	if (char_ok(poink)) {
		px = char_loc_x(poink);
		py = char_loc_y(poink);

			if(can_see_loc(px,py) == 1 && get_attitude(poink) != get_attitude(ME)){
				text_bubble_on_char(ME,"Goblin Punch!");
				force_instant_terrain_redraw();
				pause(5);
				
				text_bubble_on_char(ME,"");
				mx = my_loc_x();
				my = my_loc_y();
				put_straight_zap(mx,my,px,py,get_ran(1,0,6));
				put_boom_on_char(poink,get_ran(1,0,7),0);
				set_character_pose(ME,1);
				force_instant_terrain_redraw();
				run_animation_sound(152);
				damage_char(poink,get_ran(1,get_memory_cell(1),get_memory_cell(2)),get_ran(1,0,6));
				pause(5);
set_character_pose(ME,2);
				force_instant_terrain_redraw();
				pause(3);
				ok = ok + 1;
				}
			}
		}
break;