/**
 * \~russian @defgroup ServerReservedMain   
 *
 *     @b main.fos.    ,    .
 *
 * \~english @defgroup ServerReservedMain Reserved script functions
 *
 * Used only in the script @b main.fos. Required to be defined for server to start.
 *
 * \~ @ingroup Server
 */
/*@{*/

/**
 * \~russian @name 
 * \~english @name Server
 * \~ @weight 200
 */
//@{

/** \~russian    .
 *
 * @return     .
 *         @c true   ; @c false    .
 */
bool start();

/** \~russian    . */
void finish();

/** \~russian ,     .
 *
 *      .
 *
 * @return   ,      .
 *            ,      .
 */
uint loop();

/** \~russian ,    .
 *
 *     .
 *
 * @param [out] multiplier     (1..99).
 * @param [out] year          (1700..30000).
 * @param [out] month         (1..12).
 * @param [out] day           (1..31).
 * @param [out] hour           (0..23).
 * @param [out] minute        (0..59)
 */
void get_start_time(uint16& multiplier,
    uint16& year, uint16& month, uint16& day, uint16& hour, uint16& minute);

//@}

/**
 * \~russian @name  
 * \~english @name Worldmap
 * \~ @weight 190
 */
//@{

/** \~russian    ,            .
 *
 *  ,      (   @a type):
 * - @c GLOBAL_PROCESS_MOVE      ,  5 .
 * - @c GLOBAL_PROCESS_ENTER       .
 * - @c GLOBAL_PROCESS_START_FAST          .
 * - @c GLOBAL_PROCESS_START    20          .
 * - @c GLOBAL_PROCESS_SET_MOVE     .
 * - @c GLOBAL_PROCESS_STOPPED      .
 * - @c GLOBAL_PROCESS_NPC_IDLE    NPC  
 *      (     #__CritterIdleTick).
 *
 *           
 *  <code>Say*</code>  Critter,  :
 * - @c SAY_ENCOUNTER_ANY        ,
 *              .
 * - @c SAY_ENCOUNTER_RT         .
 * - @c SAY_ENCOUNTER_TB         .
 *
 * @param [in]      type                  .
 * @param [in]      cr                   ,    .
 * @param [in]      group                 ,  .
 * @param [in]      car                    ,  .
 * @param [in, out] x, y                  .
 * @param [in, out] toX, toY             ,   .
 * @param [out]     speed                      .
 * @param [out]     encounterDescriptor        
 *                                        ,       #global_invite,
 *                                                  .
 *                                        @a encounterDescriptor  0,   #global_invite  .
 * @param [out]     waitForAnswer              
 *                                        @c true,      #global_invite  
 *                                         .  @c false,   #global_invite
 *                                        .      .  .
 *
 * @remarks    @a x, @a y, @a toX, @a toY,   :
 *            , .    
 *             .
 *
 * @remarks     @a group   .
 *
 * @see     global_invite
 * @see     Critter::Say
 * @see     Critter::SayMsg
 * @see     CRITTER_EVENT_GLOBAL_PROCESS
 */
void global_process(int type, Critter& cr, Critter@[]& group, Item@ car,
                    uint& x, uint& y,
                    uint& toX, uint& toY,
                    uint& speed, uint& encounterDescriptor, bool& waitForAnswer);

/** \~russian ,      .
 *
 * @param [in]  group                 ,   .
 * @param [in]  car                    ,  .
 * @param [in]  encounterDescriptor     #global_process .
 * @param [in]  combatMode            (  )  
 *                                   (. @link CombatModes Combat modes@endlink).
 * @param [out] mapId                   .
 *                                           ,
 *                                        .
 * @param [out] hexX, hexY               .
 * @param [out] dir                      .
 *
 * @see   global_process
 * @see   CRITTER_EVENT_GLOBAL_INVITE
 */
void global_invite(Critter@[]& group, Item@ car, uint encounterDescriptor, int combatMode,
                   uint& mapId, uint16& hexX, uint16& hexY, uint8& dir);

//@}

/**
 * \~russian @name 
 * \~english @name Map event handlers
 * \~ @weight 190
 */
//@{

/** \~russian      .
 *
 * @param  map  ,    .
 * @param  cr   ,  .
 *
 * @see    MAP_EVENT_CRITTER_IN
 */
void map_critter_in(Map& map, Critter& cr);

/** \~russian      .
 *
 * @param  map  ,    .
 * @param  cr   ,  .
 *
 * @see    MAP_EVENT_CRITTER_OUT
 */
void map_critter_out(Map& map, Critter& cr);

//@}

/**
 * \~russian @name 
 * \~english @name Critter event handlers
 * \~ @weight 180
 */
//@{

/** \~russian   /   / NPC.
 *
 * @param   cr            .
 * @param   registration     @c false;   ( )  @c true.
 *
 * @remarks  ,       .
 */
void critter_init(Critter& cr, bool registration);

/** \~russian    .
 *
 *      #__CritterIdleTick.
 *
 * @param  cr  ,    .
 *
 * @see    CRITTER_EVENT_IDLE
 */
void critter_idle(Critter& cr);

/** \~russian      .
 *
 * @param  cr  ,    .
 *
 * @see    CRITTER_EVENT_FINISH
 */
void critter_finish(Critter& cr);

/** \~russian     .
 *
 * @param  cr         .
 * @param  killer    -.
 *
 * @see    CRITTER_EVENT_DEAD
 *         MAP_EVENT_CRITTER_DEAD
 */
void critter_dead(Critter& cr, Critter@ killer);

/** \~russian    .
 *
 * @param  cr  ,    .
 *
 * @see    CRITTER_EVENT_RESPAWN
 */
void critter_respawn(Critter& cr);

/** \~russian   ,         .
 *
 * @param  cr           .
 * @param  target       .
 * @param  weapon        ,      .
 * @param  weaponMode    .
 *    -  (. @link HitLocations Hit Locations@endlink),
 *    -   (0  primary, 1  secondary, 2  third).
 * @param  ammo         .
 *
 * @see    Critter::SendCombatResult
 * @see    CRITTER_EVENT_ATTACK
 * @see    CRITTER_EVENT_SMTH_ATTACK
 */
void critter_attack(Critter& cr, Critter& target, ProtoItem& weapon, uint8 weaponMode, ProtoItem@ ammo);

/** \~russian   ,         .
 *
 * @param  cr         .
 * @param  attacker   .
 *
 * @see    CRITTER_EVENT_ATTACKED
 * @see    CRITTER_EVENT_SMTH_ATTACKED
 */
void critter_attacked(Critter& cr, Critter& attacker);

/** \~russian    .
 *
 * @param  cr      .
 * @param  thief  .
 * @param  item    .
 * @param  count    .
 *
 * @return    @a success  
 *         #CRITTER_EVENT_STEALING  #CRITTER_EVENT_SMTH_STEALING,
 *         ,   ,     .
 *
 * @see    CRITTER_EVENT_STEALING
 * @see    CRITTER_EVENT_SMTH_STEALING
 */
bool critter_stealing(Critter& cr, Critter& thief, Item& item, uint count);

/** \~russian    .
 *
 * @param  cr          ,   .
 * @param  item         .
 * @param  targetCr      ,    .
 * @param  targetItem    ,    .
 * @param  targetScen    ,    .
 * @param  param       (?).
 *
 * @return @c true,     ;
 *         @c false,      .
 *
 * @see    CRITTER_EVENT_USE_ITEM
 */
bool critter_use_item(Critter& cr, Item& item, Critter@ targetCr, Item@ targetItem, Scenery@ targetScen, uint param);

/** \~russian    .
 *
 * @param  cr          ,  .
 * @param  skill        
 *                     (. @link Skills @endlink  @link SpecialSkillValues Special Skill Values@endlink).
 * @param  targetCr      ,    .
 * @param  targetItem    ,    .
 * @param  targetScen    ,    .
 *
 * @return @c true,     ;
 *         @c false,      .
 *
 * @see    CRITTER_EVENT_USE_SKILL
 */
bool critter_use_skill(Critter& cr, int skill, Critter@ targetCr, Item@ targetItem, Scenery@ targetScen);

/** \~russian  ,         (     ).
 *
 * @param  cr        ,  .
 * @param  item      .
 * @param  fromSlot   (. @link Slots@endlink).
 */
void critter_change_item(Critter& cr, Item& item, int fromSlot);

/** \~russian       .
 *
 * @param  cr      ,   .
 * @param  weapon  .
 * @param  ammo      ,  .   @c null,
 *                   ,    .
 */
void critter_reload_weapon(Critter& cr, Item& weapon, Item@ ammo);

/** \~russian        (,      )  .
 *
 * @param  cr        ,   .
 * @param  item      ,  .
 * @param  fromSlot  ,    .
 */
void critter_change_item(Critter& cr, Item& item, uint8 fromSlot);

//@}

/**
 * \~russian @name 
 *
 *     .      NPC,
 *       .
 *
 * \~english @name Global plan event handlers
 *
 * \~ @weight 170
 */
//@{

/** \~russian     (      NPC).
 *
 * @param  npc         NPC,    .
 * @param  plane        .
 * @param  childIndex      .
 * @param  reason         
 *                     (. @link PlanesReasons Plane begin reasons@endlink).
 * @param  someCr      (?)
 * @param  someItem    (?)
 *
 * @return   @c false,    ;  @c true,  .
 */
bool npc_plane_begin(Critter& npc, NpcPlane& plane, uint childIndex, int reason, Critter@ someCr, Item@ someItem);

/** \~russian     (     ).
 *
 * @param  npc         NPC,    .
 * @param  plane        .
 * @param  childIndex      .
 * @param  reason         
 *                     (. @link PlanesReasons Plane end reasons@endlink).
 * @param  someCr      (?)
 * @param  someItem    (?)
 *
 * @return   @c false,       ;
 *          @c true,  .
 */
bool npc_plane_end(Critter& npc, NpcPlane& plane, uint childIndex, int reason, Critter@ someCr, Item@ someItem);

/** \~russian      .
 *
 * @param            npc NPC,    -.
 * @param            plane ,    -.
 * @param            childIndex     .
 * @param            reason ,       (. @link PlanesReasons Plane run reasons@endlink).
 * @param  [in, out] result0, result1, result2 ,    
 *                    @a reason.
 *
 * @return ,      .
 */
bool npc_plane_run(Critter& npc, NpcPlane& plane, uint childIndex, int reason,
                   uint& result0, uint& result1, uint& result2);

//@}

/** \~russian       .
 *
 * @param  crFrom  ,  .
 * @param  crTo    ,   .
 * @param  valUp      (@c true)   (@c false).
 */
void karma_voting(Critter& crFrom, Critter& crTo, bool valUp);

/** \~russian ,        .
 *
 *       ,
 *   @c LOOK_CHECK_SCRIPT   #__LookChecks.
 *
 * @param   cr        ,      .
 * @param   opponent  ,   .
 *
 * @return  @c true,  ,     ;
 *          @c false    .
 *
 * @remarks  @c CRITTER_EVENT_SHOW_CRITTER_X  @c CRITTER_EVENT_HIDE_CRITTER_X
 *             .
 */
bool check_look(Critter& cr, Critter& opponent);

/** \~russian ,      .
 *
 *        ,
 *     #__CustomItemCost  @c true.
 *
 * @param    item  ,    .
 * @param    cr    ,   .
 * @param    npc   NPC,   .
 * @param    sell  ,   (@c true)     (@c false).
 *
 * @remarks         .
 * @remarks  ,       ,    .
 *
 * @return     .
 *
 * @see      ClientReserved#item_cost
 */
uint item_cost(Item& item, Critter& cr, Critter& npc, bool sell);

/** \~russian      .
 *
 * @param  items        .
 * @param  itemsCount     (    ).
 * @param  resources   -.
 * @param  crafter     ,  .
 *
 * @remarks  @a resources     - 
 *          (<code>Item::Accessory == ACCESSORY_NONE</code>)   
 *             ,     .
 *
 */
void items_crafted(Item@[]& items, uint[]& itemsCount, Item@[]& resources, Critter& crafter);

/** \~russian         NPC.
 *
 * @param  saleItems         .
 * @param  saleItemsCount      ,  @a saleItems.
 * @param  buyItems          .
 * @param  buyItemsCount       ,  @a buyItems.
 * @param  player          ,   .
 * @param  npc             NPC,   .
 *
 * @return   @c false,     .
 *
 ** \~english Call on barter transaction.
 *
 * @return Return false to cancel transaction.
 */
bool items_barter(Item@[]& saleItems, uint[]& saleItemsCount, Item@[]& buyItems, uint[]& buyItemsCount, Critter& player, Critter& npc);

/**        .
 *
 * @param  player      .
 * @param  skillIndex   ,     (. @link Skills @endlink).
 * @param  skillUp       .
 * @param  perkIndex      (. @link Perks @endlink).
 */
void player_levelup(Critter& player, uint skillIndex, uint skillUp, uint perkIndex);

/*@}*/

