begincreaturescript;
variables;
short i,target;
short i_gave_alert = 0;
body;
beginstate INIT_STATE;
if (get_memory_cell(0) == 2)
set_mobility(ME,0);
break;
beginstate DEAD_STATE;
if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
set_flag(get_memory_cell(1),get_memory_cell(2),1);
break;
beginstate START_STATE;
if (target_ok()) {
if (dist_to_char(get_target()) <= 16)
set_state(3);
else set_target(ME,-1);
}
if (select_target(ME,8,0)) {
do_attack();
set_state(3);
}
if (who_hit_me() >= 0) {
set_target(ME,who_hit_me());
do_attack();
set_state(3);
}
if (my_dist_from_start() >= 6) {
if (get_ran(1,1,100) < 40)
return_to_start(ME,1);
}
else if (get_memory_cell(0) == 0) {
fidget(ME,25);
}
if (am_i_doing_action() == FALSE)
end_combat_turn();
break;
beginstate 3;
if (i_gave_alert == 0) {
if(get_memory_cell(4) != 0){
alert_char(1000 + get_memory_cell(4));
if((get_memory_cell(5) != 0) || (get_memory_cell(6) != 0))
move_to_loc_x_y(1000 + get_memory_cell(4),get_memory_cell(5),get_memory_cell(6));
}
else if(what_group_in(ME) > 0){
alert_char(1000 + what_group_in(ME));
if((get_memory_cell(5) != 0) || (get_memory_cell(6) != 0))
move_to_loc_x_y(1000 + what_group_in(ME),get_memory_cell(5),get_memory_cell(6));
}
i_gave_alert = 1;
}
if (target_ok() == FALSE)
set_state(START_STATE);
do_attack();
break;
beginstate TALKING_STATE;
if (get_memory_cell(3) == 0) {
print_str("Talking: It doesn't respond.");
end();
}
begin_talk_mode(get_memory_cell(3));
break