procedure start;
procedure combat_p_proc;
procedure critter_p_proc;
procedure damage_p_proc;
procedure destroy_p_proc;
procedure look_at_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure timed_event_p_proc;
procedure flee_dude;
variable hostile;
variable initialized;
variable round_counter;
variable PsstTime;
procedure start
begin
if (not(initialized)) then begin
critter_add_trait(self_obj, 1, 6, 2);
critter_add_trait(self_obj, 1, 5, 6);
add_timer_event(self_obj, game_ticks(random(15, 60)), 1);
add_timer_event(self_obj, game_ticks(random(3, 5)), 1);
initialized := 1;
end
else begin
if (script_action == 13) then begin
call combat_p_proc;
end
else begin
if (script_action == 12) then begin
call critter_p_proc;
end
else begin
if (script_action == 18) then begin
call destroy_p_proc;
end
else begin
if (script_action == 21) then begin
call look_at_p_proc;
end
else begin
if (script_action == 4) then begin
call pickup_p_proc;
end
else begin
if (script_action == 11) then begin
call talk_p_proc;
end
end
end
end
end
end
end
end
procedure combat_p_proc
begin
if (fixed_param == 4) then begin
round_counter := round_counter + 1;
if (round_counter > 3) then begin
if ((global_var(246) == 0) and ((cur_map_index == 26) or (cur_map_index == 25))) then begin
set_global_var(246, 1);
set_global_var(155, global_var(155) - 5);
end
end
end
end
procedure critter_p_proc
begin
variable LVar0 := 0;
if (hostile) then begin
hostile := 0;
attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
end
else begin
if (local_var(0)) then begin
if (tile_distance_objs(self_obj, dude_obj) < 8) then begin
call flee_dude;
end
end
end
LVar0 := global_var(343);
if ((((game_time / 10) - LVar0) >= 10) and (tile_distance_objs(self_obj, dude_obj) <= 4) and (global_var(246) == 0) and ((cur_map_index == 26) or (cur_map_index == 25))) then begin
float_msg(self_obj, message_str(115, random(110, 114)), 0);
LVar0 := game_time / 10;
set_global_var(343, LVar0);
end
end
procedure damage_p_proc
begin
if (source_obj == dude_obj) then begin
set_local_var(0, 1);
end
end
procedure destroy_p_proc
begin
if ((source_obj == dude_obj) and ((cur_map_index == 26) or (cur_map_index == 25))) then begin
set_global_var(246, 1);
end
if (source_obj == dude_obj) then begin
if (((global_var(160) + global_var(159)) >= 25) and ((global_var(159) > (2 * global_var(160))) or (global_var(156) == 1))) then begin
set_global_var(156, 1);
set_global_var(157, 0);
end
if (((global_var(160) + global_var(159)) >= 25) and ((global_var(160) > (3 * global_var(159))) or (global_var(157) == 1))) then begin
set_global_var(157, 1);
set_global_var(156, 0);
end
set_global_var(159, global_var(159) + 1);
if ((global_var(159) % 2) == 0) then begin
set_global_var(155, global_var(155) - 1);
end
end
end
procedure look_at_p_proc
begin
script_overrides;
display_msg(message_str(9, 100));
end
procedure pickup_p_proc
begin
hostile := 1;
end
procedure talk_p_proc
begin
if (local_var(0) or global_var(246)) then begin
float_msg(self_obj, message_str(669, random(100, 105)), 0);
end
else begin
float_msg(self_obj, message_str(9, random(101, 106)), 0);
end
end
procedure timed_event_p_proc
begin
if (obj_on_screen(self_obj)) then begin
animate_move_obj_to_tile(self_obj, tile_num_in_direction(tile_num(self_obj), random(0, 5), random(1, 5)), 0);
end
add_timer_event(self_obj, game_ticks(random(6, 10)), 1);
end
procedure flee_dude
begin
variable LVar0 := 0;
variable LVar1 := 0;
variable LVar2 := 0;
while(LVar1 < 5) do begin
if (tile_distance(tile_num(dude_obj), tile_num_in_direction(tile_num(self_obj), LVar1, 3)) > LVar2) then begin
LVar0 := tile_num_in_direction(tile_num(self_obj), LVar1, 3);
LVar2 := tile_distance(tile_num(dude_obj), LVar0);
end
LVar1 := LVar1 + 1;
end
animate_move_obj_to_tile(self_obj, LVar0, 1);
end