#include <define.h>

#define NAME                    SCRIPT_TEST

#include <command.h>
//#include <ModReact.h>



procedure start;
#include <push.h>
procedure timed_event_p_proc;

variable gun_ptr;

procedure map_enter_p_proc;
procedure Node001;
procedure description_p_proc;

procedure start
begin

end

procedure timed_event_p_proc
begin
  variable LVar0 := 0;
  variable LVar1 := 0;
  variable LVar2 := 0;
  if (fixed_param == 3) then begin
    metarule(13, 0);
  end
  else begin
    if (fixed_param == 4) then begin
      float_msg(self_obj, message_str(SCRIPT_OBJ_DUDE, 500), FLOAT_MSG_WARNING);
      add_timer_event(dude_obj, game_ticks(15), 3);
    end
    else begin
      if (fixed_param == 5) then begin
        game_ui_disable;
        animate_move_obj_to_tile(map_var(0), 16890, ANIMATE_WALK);
        add_timer_event(dude_obj, 5, 6);
      end
      else begin
        if (fixed_param == 6) then begin
          LVar0 := 0;
          if (has_trait(2, dude_obj, 8)) then begin
            LVar0 := 1;
          end
          else begin
            if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_GOOD_MONSTER) > (2 * global_var(GVAR_BAD_MONSTER))) or (global_var(GVAR_BERSERKER_REPUTATION) == 1))) then begin
              LVar0 := 1;
            end
            else begin
              if (global_var(GVAR_PLAYER_REPUTATION) < -1) then begin
                LVar0 := 1;
              end
              else begin
                if (global_var(GVAR_CHILDKILLER_REPUTATION) > 2) then begin
                  LVar0 := 1;
                end
              end
            end
          end
          if (LVar0 == 1) then begin
            gun_ptr := create_object_sid(8, 0, 0, -1);
            add_obj_to_inven(dude_obj, gun_ptr);
            wield_obj_critter(dude_obj, gun_ptr);
            add_timer_event(dude_obj, 25, 7);
          end
          else begin
            add_timer_event(dude_obj, 25, 8);
          end
        end
        else begin
          if (fixed_param == 7) then begin
            reg_anim_func(2, map_var(0));
            reg_anim_func(1, 1);
            reg_anim_animate(dude_obj, 43, -1);
            LVar1 := sfx_build_weapon_name(1, gun_ptr, LVar2, map_var(0));
            reg_anim_play_sfx(dude_obj, LVar1, -1);
            reg_anim_animate(dude_obj, 45, -1);
            LVar1 := sfx_build_char_name(map_var(0), 20, 3);
            reg_anim_play_sfx(map_var(0), LVar1, 0);
            reg_anim_animate(map_var(0), 20, 0);
            reg_anim_animate(dude_obj, 44, 0);
            reg_anim_func(3, 0);
            add_timer_event(dude_obj, game_ticks(11), 8);
          end
          else begin
            if (fixed_param == 8) then begin
              game_ui_enable;
              endgame_movie;
              metarule(13, 0);
            end
          end
        end
      end
    end
  end
end

procedure map_enter_p_proc begin

/*
 mark_vault_13_on_map
 mark_vault_15_on_map
 mark_shady_sands_on_map
 mark_junktown_on_map
 mark_raiders_on_map
 mark_necropolis_on_map
 mark_hub_on_map
 mark_brotherhood_on_map
 mark_military_base_on_map
 mark_glow_on_map
 mark_boneyard_on_map
 mark_cathedral_on_map
*/

end

procedure Node001 begin 
  variable word; // SVAR для верного слова 
  variable remn;       // SVAR для остатка 
  variable GVAR_DayCounter; 
  GVAR_DayCounter := GVAR_VAULT_WATER;

remn := global_var(GVAR_DayCounter) % 10; 
if (remn > 4) then begin 
   word := 3; 
end else begin 
   if (remn > 1) then begin 
        word := 2; 
   end else begin 
       if (remn == 1 and global_var(GVAR_DayCounter) != 11) then begin 
           word := 1; 
       end else begin 
           word := 3; 
       end 
   end 
end 

display_msg(mstr(100+word) + (global_var(GVAR_VAULT_WATER) - GAME_TIME_IN_DAYS) + mstr(110+word));
end

procedure description_p_proc begin 
 script_overrides; 
 call Node001; 
end