beginterrainscript;
variables;
short t, target, x, y, n;
body;
beginstate INIT_STATE;
set_script_mode(3);
if(get_memory_cell(2) == 0)
set_memory_cell(2,1);
break;
beginstate START_STATE;
if((my_current_message() == 111) || (get_flag(get_memory_cell(0),get_memory_cell(1)) == 1)){
set_flag(get_memory_cell(0),get_memory_cell(1),1);
set_state(3);
}
break;
beginstate SEARCH_STATE;
break;
beginstate STEP_INTO_SPOT_STATE;
set_ter_script_mode(37,3);
i_am_active = 1;
set_state(3);
break;
beginstate 3;
if(get_flag(get_memory_cell(0),get_memory_cell(1)) == 0)
set_state(START_STATE);
if((get_ran(1,1,4) == 1) && (n != get_current_tick())){
target = random_party_member();
x = (char_loc_x(target) + get_ran(1,1,10)) - 5;
y = (char_loc_y(target) + get_ran(1,1,10)) - 5;
if(party_can_see_loc(x,y)){
put_boom_on_space(x,y,1,0);
run_animation_sound(152);
}
if((get_terrain(x,y) > 37) && (get_terrain(x,y) < 46) && (get_terrain(x,y) != 1))
set_terrain(x,y,156);
if(char_on_loc(x,y) != -1){
target=char_on_loc(x,y);
if((get_attitude(target) > 4) && (get_memory_cell(3) != 138))
damage_char(target,get_memory_cell(3),get_memory_cell(2));
else if(get_memory_cell(4) != 138)
damage_char(target,get_memory_cell(4),get_memory_cell(2));
}
}
else if(n == get_current_tick())
end();
n = get_current_tick();
break