SHARE
TWEET

Untitled

a guest Jun 15th, 2017 209 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** @file */
  2.  
  3.  
  4. const int INDEX_NOT_FOUND = -1;
  5. //-----------------------------------------------------------------------------
  6. typedef Serializer ParamsReadContext;
  7. typedef Serializer ParamsWriteContext;
  8.  
  9.  
  10. //-----------------------------------------------------------------------------
  11. class Action
  12. {
  13.     proto bool GetText(Man player, out string text);
  14.     proto bool GetTextRich(Man player, out string text);
  15.     proto native int AddRef();
  16.     proto native int Release();
  17. };
  18.  
  19. class TotalDamageResult
  20. {
  21.     proto native float GetDamage(string zoneName, string healthType);
  22.     proto native float GetHighestDamage(string healthType);
  23. };
  24.  
  25. /*class TRefArray<class T> extends array<T>
  26. {
  27.     void ~TRefArray()
  28.     {
  29.         for (int i = 0; i < Count(); i++)
  30.         {
  31.             T item = Get(i);
  32.             item.Release();
  33.         }
  34.     }
  35. };
  36.  
  37. typedef TRefArray<Action> TActionRefArray;*/
  38.  
  39. class TActionRefArray extends array<Action>
  40. {
  41.     void AddRef()
  42.     {
  43.         for (int i = 0; i < Count(); i++)
  44.         {
  45.             Action item = Get(i);
  46.             item.AddRef();
  47.         }
  48.     }
  49.  
  50.     void Release()
  51.     {
  52.         for (int i = 0; i < Count(); i++)
  53.         {
  54.             Action item = Get(i);
  55.             item.Release();
  56.         }
  57.  
  58.         Clear();
  59.     }
  60.  
  61.     void ~TActionRefArray()
  62.     {
  63.         Release();
  64.     }
  65. };
  66.  
  67. //-----------------------------------------------------------------------------
  68. class ActionMenuContext
  69. {
  70.     proto void AddAction(string text, int action_id, Param params, float priority, bool showWindow, bool hideOnUse, array<int> memoryPoints = NULL);
  71.     private void ~ActionMenuContext()
  72.     {
  73.     }
  74. };
  75.  
  76. class ActionParams
  77. {
  78.  
  79. };
  80.  
  81. const string NullStringArray[1] = { "" };
  82.  
  83. //-----------------------------------------------------------------------------
  84. //! Selection class
  85. class Selection
  86. {
  87.     proto native string GetName();
  88.     proto native int GetVertexCount();
  89.     proto native int GetLODVertexIndex(int sel_vertex_index);
  90.  
  91.     vector GetVertexPosition(LOD lod, int index)
  92.     {
  93.         int lodIndex = GetLODVertexIndex(index);
  94.         return lod.GetVertexPosition(lodIndex);
  95.     }
  96. };
  97.  
  98. //-----------------------------------------------------------------------------
  99. //! LOD class
  100. class LOD
  101. {
  102.     proto native int GetSelectionCount();
  103.     proto native bool GetSelections(notnull out array<Selection> selections);
  104.  
  105.     proto native vector GetVertexPosition(int vertex_index);
  106.    
  107.     proto native string GetName(Object myObject);
  108.    
  109.     Selection GetSelectionByName( string name )
  110.     {
  111.         array<Selection> selections = new array<Selection>;
  112.         GetSelections( selections );
  113.        
  114.         for ( int i = 0; i < selections.Count(); ++i )
  115.         {
  116.             string selection_name = selections.Get( i ).GetName();
  117.             if ( selection_name.ToLower() == name.ToLower() ) return selections.Get( i );
  118.         }
  119.        
  120.         return NULL;
  121.     }
  122. }
  123.  
  124. //-----------------------------------------------------------------------------
  125. //! Object class
  126. class Object extends IEntity
  127. {
  128.     proto private void ~Object();
  129.     proto private void Object();
  130.    
  131.     //! Retrieve all LODS  
  132.     proto native bool GetLODS(notnull out array<LOD> lods);
  133.    
  134.     //! Retrieve LOD name
  135.     proto native string GetLODName(LOD lod);
  136.    
  137.     //! Retrieve LOD by given name
  138.     LOD GetLODByName( string name )
  139.     {
  140.         array<LOD> lods = new array<LOD>;
  141.         GetLODS( lods );
  142.        
  143.         for ( int i = 0; i < lods.Count(); ++i )
  144.         {
  145.             string lod_name = GetLODName( lods.Get( i ) );
  146.             if ( lod_name.ToLower() == name.ToLower() ) return lods.Get( i );  
  147.         }
  148.        
  149.         return NULL;
  150.     }
  151.    
  152.     //! Retrieve position
  153.     proto native vector GetPosition();
  154.    
  155.     //! Set position
  156.     proto native void SetPosition(vector vPos);
  157.    
  158.     /**
  159.     \brief Place object on surface
  160.     */
  161.     proto native void PlaceOnSurface();
  162.  
  163.     /**
  164.     \brief Retrieve orientation (yaw, pitch, roll) in <b>degrees</b>
  165.     \return vector of yaw, pitch and roll angles (x = yaw, y = pitch, z = roll)
  166.     */
  167.     proto native vector GetOrientation();
  168.  
  169.     /**
  170.     \brief Set orientation (yaw, pitch, roll) in <b>degrees</b>
  171.     @param vOrientation, vector of yaw, pitch and roll angles (x = yaw, y = pitch, z = roll)
  172.     */
  173.     proto native void SetOrientation(vector vOrientation);
  174.    
  175.     //! Retrieve direction vector
  176.     proto native vector GetDirection();
  177.    
  178.     /**
  179.     \brief Set direction of object
  180.     @param vDirection, direction vector
  181.     \note object up vector is always y-axis
  182.     */
  183.     proto native void SetDirection(vector vPos);
  184.    
  185.     //! Calculate local position of other entity to this entity
  186.     proto native vector GetLocalPos(vector vPos);
  187.     //! Calculate global position to this entity from local position
  188.     proto native vector GetGlobalPos(vector vPos);
  189.    
  190.     //! Retrieve object's speed in global space
  191.     proto native vector GetSpeed();
  192.    
  193.     //! Retrieve object's speed in local space
  194.     proto native vector GetModelSpeed();
  195.    
  196.     //! Returns true if object's geometry can affect pathgraph generation
  197.     proto native bool CanAffectPathgraph();
  198.    
  199.     //! Sets if object's geometry affects pathgraph generation. If first parameter is true, it ignores second parameter and sets affecting pathgraph by parameter set in object's config
  200.     proto native void SetAffectPathgraph(bool fromConfig, bool affect);
  201.    
  202.  
  203.     /**
  204.     \brief Get Clipping info
  205.     @param minMax array[2] of vectors, into minMax[0] is returned min, into minMax[1] is returned max
  206.     \return radius of bounding box
  207.     @code
  208.     vector minMax[2];
  209.     float radius = GetGame().GetPlayer().ClippingInfo(minMax);
  210.     Print(minMax);
  211.     Print(radius);
  212.     @endcode
  213.     */
  214.     proto float ClippingInfo(out vector minMax[2]);
  215.    
  216.     /**
  217.     \brief Gets collision bounding box
  218.     @param minMax array[2] of vectors, into minMax[0] is returned min, into minMax[1] is returned max
  219.     \return true if collision box exists, false otherwise
  220.     @code
  221.     vector minMax[2];
  222.     if(GetGame().GetPlayer().GetCollisionBox(minMax))
  223.         Print("has box");
  224.     @endcode
  225.     */
  226.     proto native bool GetCollisionBox(out vector minMax[2]);
  227.    
  228.     //! Set object damage (high level, network aware), call only from server
  229.     proto native void SetDamage(float damage);
  230.    
  231.     //! Get total damage (clipped to range 0..1)
  232.     proto native float GetDamage();
  233.    
  234.     //! Get damage level (range 0..4, 0 = pristine, 1 = worn, 2 = damaged, 3 = badly damaged, 4 = ruined)
  235.     proto native int GetDamageLevel();
  236.    
  237.     //! Add damage to total damage (clipped to range 0..1) auto_delete = true If damage is 1 or more, object will be deleted automaticly
  238.     float AddDamage(float damage, bool auto_delete = false)
  239.     {
  240.         float obj_dmg = GetDamage();
  241.         obj_dmg = obj_dmg + damage;
  242.            
  243.         SetDamage(obj_dmg);
  244.        
  245.         if ( auto_delete && obj_dmg >= 1 )
  246.         {
  247.             GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame(), "ObjectDelete", new Param1<Object>(this));
  248.         }
  249.        
  250.         return obj_dmg;
  251.     }
  252.    
  253.     proto native void GetSelectionList(out TStringArray selectionList);
  254.    
  255.     //! Returns true if the given selection was found in the p3d file. False if otherwise.
  256.     bool HasSelection( string selection )
  257.     {
  258.         autoptr TStringArray selections = new TStringArray;
  259.         GetSelectionList( selections );
  260.        
  261.         for ( local int i = 0; i < selections.Count(); ++i )
  262.         {
  263.             if ( selections.Get( i ) == selection )
  264.             {
  265.                 return true;
  266.             }
  267.         }
  268.        
  269.         return false;
  270.     }
  271.    
  272.     //! Searches object's config for the given animation name. Returns true if it was found, or false if not.
  273.     bool HasAnimation( string anim_name )
  274.     {
  275.         string cfg_path_vehicles = "CfgVehicles " + GetType() + " ";
  276.         if ( GetGame().ConfigIsExisting (cfg_path_vehicles)  &&  GetGame().ConfigIsExisting (cfg_path_vehicles + "AnimationSources " + anim_name) )
  277.         {
  278.             return true;
  279.         }
  280.        
  281.         string cfg_path_weapons = "CfgWeapons " + GetType() + " ";
  282.         if ( GetGame().ConfigIsExisting (cfg_path_weapons)  &&  GetGame().ConfigIsExisting (cfg_path_weapons + "AnimationSources " + anim_name) )
  283.         {
  284.             return true;
  285.         }
  286.        
  287.         string cfg_path_magazines = "CfgMagazines " + GetType() + " ";
  288.         if ( GetGame().ConfigIsExisting (cfg_path_magazines)  &&  GetGame().ConfigIsExisting (cfg_path_magazines + "AnimationSources " + anim_name) )
  289.         {
  290.             return true;
  291.         }
  292.        
  293.         return false;
  294.     }
  295.    
  296.     //! If Returns true if this item has EnergyManager in its config. Otherwise returns false.
  297.     bool HasEnergyManager()
  298.     {
  299.         return false;
  300.     }
  301.    
  302.     proto native int GetMemoryPointIndex(string memoryPointName);
  303.  
  304.     /**
  305.   \brief [Client] This function is called by engine to get list of scripted actions
  306.     @param ctx action menu context
  307.     @param player which is asking for actions
  308.     \n usage :
  309.     @code
  310.     void OnGetActions(ActionMenuContext ctx, Man player)
  311.     {
  312.         super.OnGetActions(ctx, player);
  313.         if (IsActionCopyAvalible())
  314.         {
  315.             autoptr Param4<string, int, EntityAI, EntityAI> p = new Param4<string, int, EntityAI, EntityAI>("ahoj", 5, this, player);
  316.             ctx.AddAction("Copy", ACTION_ID_COPY, p, 1000, true, true);
  317.         }
  318.     }
  319.     @endcode
  320.     */
  321.     void OnGetActions(ActionMenuContext ctx, Man player)
  322.     {
  323.     }
  324.  
  325.     /**
  326.   \brief [Server] Function called by engine to execute scripted action
  327.     @param action_id ID of action given in OnGetActions
  328.     @param player which is executing action
  329.     @param params custom action params given in OnGetActions
  330.     \n usage :
  331.     @code
  332.     bool OnAction(int action_id, Man player, ParamsReadContext ctx)
  333.     {
  334.         switch (action_id)
  335.         {
  336.             case ACTION_ID_COPY:
  337.                 if (IsActionCopyAvalible())
  338.                 {
  339.                     autoptr Param4<string, int, EntityAI, EntityAI> copy_action_params = new Param4<string, int, EntityAI, EntityAI>("", 0, NULL, NULL);
  340.                     if (ctx.Read(copy_action_params))
  341.                     {
  342.                         PrintString("Copy test: " + copy_action_params.param1 + "  " + copy_action_params.param2.ToString());
  343.                         Print(copy_action_params.param3);
  344.                         Print(copy_action_params.param4);
  345.                         GetGame().CreateObject("Trap_Bear", player.GetPosition(), false);
  346.                         return true;
  347.                     }
  348.                 }
  349.                 return false;
  350.         }
  351.  
  352.         return super.OnAction(action_id, player, ctx);
  353.     }
  354.     @endcode
  355.     */
  356.     bool OnAction(int action_id, Man player, ParamsReadContext ctx)
  357.     {
  358.     }
  359.  
  360.     //! Get config class of object
  361.     string GetType()
  362.     {
  363.         string ret;
  364.         GetGame().ObjectGetType(this, ret);
  365.    
  366.         return ret;
  367.     }
  368.    
  369.     //! Get display name of entity
  370.     string GetName()
  371.     {
  372.         string tmp;
  373.         GetGame().ObjectGetDisplayName(this, tmp);
  374.         return tmp;
  375.     }
  376.  
  377.  
  378.     int Release()
  379.     {
  380.         return GetGame().ObjectRelease(this);
  381.     }
  382.    
  383.     proto native int AddRef();
  384.    
  385.     //! Check config class name of the object
  386.     bool IsKindOf(string type)
  387.     {
  388.         return GetGame().ObjectIsKindOf(this, type);
  389.     }
  390.        
  391.     // Check alive state
  392.     bool IsAlive()
  393.     {
  394.         if ( GetDamage() >= 1 )
  395.         {
  396.             return false; // Is dead
  397.         }
  398.         return true; // Is alive
  399.     }
  400.  
  401.        
  402.     //! Returns if this entity is Man
  403.     bool IsMan()
  404.     {
  405.         return false;
  406.     }
  407.    
  408.     //! Returns if this entity is EntityAI
  409.     bool IsEntityAI()
  410.     {
  411.         return false;
  412.     }
  413.    
  414.     //! Returns if this entity is Static Transmitter
  415.     bool IsStaticTransmitter()
  416.     {
  417.         return false;
  418.     }
  419.    
  420.     //! Returns if this entity is ItemBase
  421.     bool IsItemBase()
  422.     {
  423.         return false;
  424.     }
  425.    
  426.     bool IsContainer()
  427.     {
  428.         return false;
  429.     }
  430.    
  431.     //! Returns if this entity is Magazine
  432.     bool IsMagazine()
  433.     {
  434.         return false;
  435.     }
  436.    
  437.     //! Returns if this entity is InventoryItem
  438.     bool IsInventoryItem()
  439.     {
  440.         return false;
  441.     }
  442.  
  443.     //! Returns if this entity is Clothing
  444.     bool IsClothing()
  445.     {
  446.         return false;
  447.     }
  448.  
  449.     //! Returns if this entity is fireplacebase
  450.     bool IsFireplace()
  451.     {  
  452.         return false;
  453.     }
  454.    
  455.     //! Returns if this entity is tree
  456.     bool IsTree()
  457.     {  
  458.         return false;
  459.     }
  460.    
  461.     //! Returns if this entity is rock
  462.     bool IsRock()
  463.     {  
  464.         return false;
  465.     }
  466.    
  467.     //! Returns whether object is PlanBase
  468.     bool IsWoodBase()
  469.     {
  470.         return false;
  471.     }
  472.  
  473.     //! Returns if this entity is bush
  474.     bool IsBush()
  475.     {
  476.         return false;
  477.     }
  478.    
  479.     //! Returns if this entity is Pelt_Base
  480.     bool IsPeltBase()
  481.     {
  482.         return false;
  483.     }
  484.  
  485.     //! Returns if this entity is Weapon
  486.     bool IsWeapon()
  487.     {
  488.         return false;
  489.     }
  490.     //! Remote procedure call shortcut, see CGame.RPC / CGame.RPCSingleParam
  491.     void RPC(int rpc_type, array<Param> params, Man recipient = NULL)
  492.     {
  493.         GetGame().RPC(this, rpc_type, params, recipient);
  494.     }
  495.    
  496.     //! Remote procedure call shortcut, see CGame.RPCSingleParam / CGame.RPC
  497.     void RPCSingleParam(int rpc_type, Param param, Man recipient = NULL)
  498.     {
  499.         GetGame().RPCSingleParam(this, rpc_type, param, recipient);
  500.     }
  501.    
  502.     /**
  503.   \brief Called after remote procedure call is recieved for this object
  504.         @param rpc_type user defined identification of RPC
  505.         @param ctx read context for params
  506.     */
  507.     void OnRPC(int rpc_type, ParamsReadContext ctx);
  508.  
  509.     vector GetSelectionPosition(string name)
  510.     {
  511.         return GetGame().ObjectGetSelectionPosition(this, name);
  512.     }
  513.    
  514.     vector ModelToWorld(vector modelPos)
  515.     {
  516.         return GetGame().ObjectModelToWorld(this, modelPos);
  517.     }
  518.    
  519.     vector WorldToModel(vector worldPos)
  520.     {
  521.         return GetGame().ObjectWorldToModel(this, worldPos);
  522.     }
  523.  
  524.     // config class API
  525.    
  526.     proto string ConfigGetString(string entryName);
  527.     proto int ConfigGetInt(string entryName);
  528.     bool ConfigGetBool(string entryName)
  529.     {
  530.         if ( ConfigGetInt(entryName) == 1 )
  531.         {
  532.             return true;
  533.         }
  534.        
  535.         return false;
  536.     }
  537.  
  538.     proto float ConfigGetFloat(string entryName);
  539.     proto vector ConfigGetVector(string entryName);
  540.     //proto ParamEntry ConfigGetEntry(string entryName);
  541.  
  542.     /**
  543.   \brief Get array of strings from config entry.
  544.     @param entryName
  545.     @param value output
  546.     */
  547.     proto native void       ConfigGetTextArray(string entryName, out TStringArray values);
  548.  
  549.     /**
  550.   \brief Get array of floats from config entry.
  551.     @param entryName
  552.     @param value output
  553.     */
  554.     proto native void       ConfigGetFloatArray(string entryName, out TFloatArray values);
  555.    
  556.     /**
  557.   \brief Get array of integers from config entry.
  558.     @param entryName
  559.     @param value output
  560.     */
  561.     proto native void       ConfigGetIntArray(string entryName, out TIntArray values);
  562.  
  563.     /**
  564.   \brief Checks if given entry exists.
  565.     @param entryName
  566.     */
  567.     proto native bool       ConfigIsExisting(string entryName);
  568.    
  569.     /**
  570.   \brief Checks if object is destroyed.
  571.     */
  572.     proto native bool   IsDamageDestroyed();
  573.    
  574.     /**
  575.   \brief Returns current state of health.
  576.     @param zoneName if empty string, returns state of global health
  577.     @param healthType if empty string, returns state of main health
  578.     */
  579.     proto native float  GetHealth(string zoneName, string healthType);
  580.    
  581.     /**
  582.   \brief Returns maximum value of health.
  583.     @param zoneName if empty string, returns state of global health
  584.     @param healthType if empty string, returns state of main health
  585.     */
  586.     proto native float  GetMaxHealth(string zoneName, string healthType);
  587.  
  588.     /**
  589.   \brief Sets current state of health.
  590.     @param zoneName if empty string, sets state of global health
  591.     @param healthType if empty string, sets state of main health
  592.     */
  593.     proto native void   SetHealth(string zoneName, string healthType, float value);
  594.    
  595.     /**
  596.   \brief Adds health.
  597.     @param zoneName if empty string, sets state of global health
  598.     @param healthType if empty string, sets state of main health
  599.     */
  600.     proto native void   AddHealth(string zoneName, string healthType, float value);
  601.  
  602.     /**
  603.   \brief Decreases health.
  604.     @param zoneName if empty string, sets state of global health
  605.     @param healthType if empty string, sets state of main health
  606.     */
  607.     proto native void   DecreaseHealth(string zoneName, string healthType, float value);
  608.  
  609.     /**
  610.   \brief Applies damage on object.
  611.     @param damageType DT_CLOSE_COMBAT/DT_FIRE_ARM/DT_EXPLOSION/DT_CUSTOM
  612.     @param source source of damage
  613.     @param compomentName which component was hit
  614.     @param ammoName ammoType, which defines how much damage should be applied
  615.     @param directHitModelPos local position of hit
  616.     @param damageCoef multiplier of applied damage
  617.     */
  618.     proto native void   ProcessDirectDamage(int damageType, EntityAI source, string componentName, string ammoName, vector modelPos, float damageCoef = 1.0);
  619.    
  620.    
  621.     proto native string GetDamageZoneNameByComponentIndex(int componentIndex);
  622.    
  623.    
  624.     //! Compares config class name to given string
  625.     bool KindOf( string tag )
  626.     {
  627.         bool found = false;
  628.         string item_name = this.GetType(); 
  629.         autoptr TStringArray item_tag_array = new TStringArray;
  630.         ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);  
  631.        
  632.         int array_size = item_tag_array.Count();
  633.         for (int i = 0; i < array_size; i++)
  634.         {
  635.             if ( item_tag_array.Get(i) == tag )
  636.             {
  637.                 found = true;
  638.                 break;
  639.             }
  640.         }
  641.         return found;
  642.     }
  643. };
  644.  
  645. class Plant extends Object
  646. {
  647. };
  648.  
  649. /*
  650. class ParamEntry
  651. {
  652.     proto string GetString(string entryName);
  653.     proto int GetInt(string entryName);
  654.     proto float GetFloat(string entryName);
  655.     proto autoptr ParamEntry GetEntry(string entryName);
  656.     proto int GetNumChildren();
  657.     proto autoptr ParamEntry GetNumChildren(int n);
  658. };
  659. */
  660. //-----------------------------------------------------------------------------
  661. class ObjectTyped extends Object
  662. {
  663. };
  664.  
  665. //-----------------------------------------------------------------------------
  666. class Entity extends ObjectTyped
  667. {
  668. };
  669.  
  670. //-----------------------------------------------------------------------------
  671. class Camera extends Entity
  672. {
  673.     proto native void SetPos(vector pos); // set destination
  674.     proto native void SetDir(vector dir); // set direction
  675.     proto native void SetFOV(float fov);
  676.     proto native void SetFOVRange(float minFov, float maxFov);
  677.     proto native void SetFocus(float distance, float blur);
  678.     proto native void SetTarget(vector target);
  679.     proto native void PreparePos(vector pos);
  680.     proto native void PrepareFOV(float fov);
  681.     proto native void PrepareFOVRange(float minFov, float maxFov);
  682.     proto native void PrepareFocus(float distance, float blur);
  683.     proto native void PrepareTarget(vector target);
  684.     proto native void Command(string mode);
  685.     proto native void Commit(float time); // commit all deferred settings
  686.     proto native void CommitPrepared(float time); // commit all prepared settings
  687.     proto native void PreloadPrepared(float time); // commit all deferred settings
  688.     proto native void SetBank(float bank); // set camera bank
  689.     proto native void SetManual(bool manual);
  690.     proto native bool GetManual();
  691.     proto native void SetComfy(bool comfy);
  692.     proto native bool GetComfy();
  693.     proto native void SetIsMouseMoveDisabled(bool isMouseMoveDisabled);
  694.     proto native bool GetIsMouseMoveDisabled();
  695.     proto native bool GetCommitted();
  696.     proto native bool GetPreloaded();
  697.    
  698.     /**
  699.     \brief Sets target EntityAI around which camera will orbit. Camera will also
  700.         change from free mode to orbit mode. To change camera mode back to free
  701.         mode set orbitTarget to NULL.
  702.         \param orbitTarget \p EntityAI target object around which will camera orbit.
  703.     */
  704.     proto native void SetOrbitTarget(EntityAI orbitTarget);
  705.    
  706.     /**
  707.     \brief Set direction of object
  708.     @param vDirection, direction vector
  709.     \note { object up vector is always y-axis }
  710.     \note { also commit(0) }
  711.     */
  712.     /*void SetDirection(vector vDirection)
  713.     {
  714.         SetDir(vDirection);
  715.         SetTarget(GetPosition() + vDirection);
  716.         Commit(0);
  717.     }*/
  718. };
  719.  
  720. //-----------------------------------------------------------------------------
  721. class ProxyInventory extends ObjectTyped
  722. {
  723. };
  724.  
  725. //-----------------------------------------------------------------------------
  726. class ProxyCrew extends Entity
  727. {
  728. };
  729.  
  730. //-----------------------------------------------------------------------------
  731. class ProxySubpart extends Entity
  732. {
  733. };
  734.  
  735. class EventParams
  736. {
  737. };
  738.  
  739. class EventParams1 extends EventParams
  740. {
  741.     Object obj;
  742.     void EventParams1(Object o)
  743.     {
  744.         obj = o;
  745.     }
  746. };
  747.  
  748. class EntityAI;
  749.  
  750. class EntityEventHandler
  751. {
  752.     void OnEvent(EntityAI entity, int entity_event_type /* EE* */, Param params)
  753.     {
  754.     }
  755. };
  756.  
  757. class EntityAnimEndEventHandler extends EntityEventHandler
  758. {
  759.     private string m_anim_name;
  760.     private autoptr CallQueueContext m_call;
  761.  
  762.     void EntityAnimEndEventHandler(string anim_name, Class target, string fn, Param params = NULL)
  763.     {
  764.         m_anim_name = anim_name;
  765.         m_call = new CallQueueContext(target, fn, params);
  766.     }
  767.  
  768.     void OnEvent(EntityAI entity, int entity_event_type /* EE* */, Param params)
  769.     {
  770.         if (entity_event_type != EEAnimDone) return;
  771.         if (!m_call) return;
  772.  
  773.         Param1<string> param = params;
  774.         if (m_anim_name == "" || param.param1 == m_anim_name)
  775.         {
  776.             m_call.Call();
  777.         }
  778.     }
  779. };
  780.  
  781. //-----------------------------------------------------------------------------
  782. //! Reloads weapon with magazine
  783. proto native bool TryReloadWeapon(EntityAI person, EntityAI weapon, EntityAI magazine);
  784.  
  785. proto native bool TrySetEntityToQuickBar(Man person, EntityAI item, int index);
  786. //! Better to use Man::CanDropEntity and Man::DropEntity instead
  787. proto native bool TryDropEntity(Man person, EntityAI item);
  788. //! Better to use EntityAI::CanTakeEntityAsOwned and EntityAI::TakeEntityAsOwned instead
  789. proto native bool TryTakeEntityAsOwned(EntityAI person, EntityAI item);
  790. //! Better to use EntityAI::CanAddEntityInCargo and EntityAI::TakeEntityAsOwned instead
  791. proto native bool TryTakeEntityToCargo(EntityAI person, EntityAI item);
  792. //! Better to use EntityAI::CanAddEntityInCargoEx and EntityAI::TakeEntityAsOwnedAtPos instead
  793. proto native bool TryTakeEntityToCargoEx(EntityAI person, EntityAI item, int row, int col);
  794. //! Better to use EntityAI::CanAddEntityInCargoEx instead
  795. proto native bool TryTakeEntityToProxyCargoEx(EntityAI owner, EntityAI item, int pxy, int row, int col);
  796. //! Better to use EntityAI::CanTakeEntityAsAttachment  and EntityAI::TakeEntityAsAttachment instead
  797. proto native bool TryTakeEntityAsAttachment(EntityAI person, EntityAI item, int slot);
  798. //! Better to use EntityAI::CanAddEntityInHands and EntityAI::TakeEntityToHands instead
  799. proto native bool TryTakeEntityToHands(Man person, EntityAI item);
  800. //! Better to use EntityAI::MoveItemFromHandsToInventory  instead
  801. proto native bool TryMoveItemFromHandsToInventory(Man person, EntityAI item);
  802. //! Better to use EntityAI::RemoveItemFromHands  instead
  803. proto native bool TryRemoveItemFromHands(Man person, EntityAI item);
  804. //! Better to use EntityAI::SwapEntities  instead
  805. proto native bool TrySwapEntities(Man person, EntityAI item1, EntityAI item2);
  806. //! Check if entities can be swapped
  807. proto native bool CanSwapEntities(EntityAI item1, EntityAI item2);
  808.  
  809.  
  810. //-----------------------------------------------------------------------------
  811. class EntityAI extends Entity
  812. {
  813.    
  814.     private ComponentsBank m_ComponentsBank;
  815.    
  816.     //! CreateComponent
  817.     Component CreateComponent(int comp_type, string extended_class_name="")
  818.     {
  819.         return GetComponent(comp_type, extended_class_name);   
  820.     }
  821.    
  822.     //! GetComponent
  823.     Component GetComponent(int comp_type, string extended_class_name="")
  824.     {
  825.         if ( m_ComponentsBank == NULL )
  826.         {
  827.             m_ComponentsBank = new ComponentsBank(this);
  828.         }
  829.        
  830.         return m_ComponentsBank.GetComponent(comp_type, extended_class_name);
  831.     }
  832.    
  833.     //! DeleteComponent
  834.     bool DeleteComponent(int comp_type)
  835.     {
  836.         return m_ComponentsBank.DeleteComponent(comp_type);
  837.     }
  838.    
  839.     //! IsComponentExist
  840.     bool HasComponent(int comp_type)
  841.     {
  842.         if ( m_ComponentsBank )
  843.         {
  844.             return m_ComponentsBank.IsComponentAlreadyExist(comp_type);
  845.         }
  846.        
  847.         return false;
  848.     }
  849.    
  850.     //! Log
  851.     void Log(string msg, string fnc_name = "n/a")
  852.     {
  853.         Debug.Log(msg, "Object", "n/a", fnc_name, this.GetType());
  854.     }
  855.    
  856.     //! LogWarning
  857.     void LogWarning(string msg, string fnc_name = "n/a")
  858.     {
  859.         Debug.LogWarning(msg, "Object", "n/a", fnc_name, this.GetType());
  860.     }
  861.    
  862.     //! LogError
  863.     void LogError(string msg, string fnc_name = "n/a")
  864.     {
  865.         Debug.LogError(msg, "Object", "n/a", fnc_name, this.GetType());
  866.     }  
  867.    
  868.     private EntityEventHandler m_event_handler;
  869.  
  870.     void EntityAI()
  871.     {
  872.         // Set up the Energy Manager
  873.         string type = GetType();
  874.         string param_access_energy_sys = "CfgVehicles " + type + " EnergyManager ";
  875.         bool is_electic_device  = GetGame().ConfigIsExisting(param_access_energy_sys);
  876.        
  877.         if (is_electic_device)
  878.         {
  879.             switch(type)
  880.             {
  881.                 case "EN5C_PowerGenerator":
  882.                     CreateComponent(COMP_TYPE_ENERGY_MANAGER, "ComponentEnergyPowerGenerator");
  883.                 break;
  884.                
  885.                 case "EN5C_Spotlight":
  886.                     CreateComponent(COMP_TYPE_ENERGY_MANAGER, "ComponentEnergySpotlight");
  887.                 break;
  888.                  
  889.                 default:
  890.                     CreateComponent(COMP_TYPE_ENERGY_MANAGER);
  891.                 break;
  892.             }
  893.         }
  894.     }
  895.  
  896.     void ~EntityAI()
  897.     {
  898.         delete m_ComponentsBank;
  899.     }
  900.    
  901.     //! is this container empty or not, checks both cargo and attachments
  902.     bool IsEmpty()
  903.     {
  904.         return (!HasAnyCargo() && AttachmentsCount() == 0);
  905.     }
  906.  
  907.     //! is this container empty or not, checks only cargo
  908.     bool HasAnyCargo()
  909.     {
  910.         Cargo cargo = this.GetCargo();
  911.        
  912.         if(!cargo) return false;//this is not a cargo container
  913.        
  914.         if( cargo.GetItemCount() > 0 )
  915.         {
  916.             return true;
  917.         }
  918.         else
  919.         {
  920.             return false;
  921.         }
  922.     }
  923.    
  924.     EntityEventHandler GetEventHandler()
  925.     {
  926.         return m_event_handler;
  927.     }
  928.  
  929.     void SetEventHandler(EntityEventHandler event_handler)
  930.     {
  931.         m_event_handler = event_handler;
  932.     }
  933.    
  934.     int GetAgents()
  935.     {
  936.         return 0;
  937.     }      
  938.     void RemoveAgent(int agent_id);
  939.     void RemoveAllAgents();
  940.     void InsertAgent(int agent, int count);
  941.    
  942.     bool IsEntityAI()
  943.     {
  944.         return true;
  945.     }
  946.    
  947.     /**
  948. \brief Delete this object in next frame
  949.     \return \p void
  950.     @code
  951.         ItemBase item = GetGame().GetPlayer().CreateInInventory("GrenadeRGD5");
  952.        
  953.         item.Delete();
  954.     @endcode
  955. */
  956.     void Delete()
  957.     {
  958.         GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame(), "ObjectDelete", new Param1<Object>(this));
  959.     }  
  960.  
  961.     //! Entity-variables can be used/shared with SQF scripts through EntityAI::GetVariable/SetVariable methods (the same as getVariable/setVariable on SQF side)
  962.     proto bool GetVariable(string varName, out void var);
  963.     //! Entity-variables can be used/shared with SQF scripts through EntityAI::GetVariable/SetVariable methods (the same as getVariable/setVariable on SQF side)
  964.     proto void SetVariable(string varName, void var);
  965.    
  966.     //! Legacy event system can be used from enforce script through EntityAI::OnEvent method. (parameters are passed through Params class. Variables in params class must match with event handler parameters.). It's best way how to call SQF code from enforce-scripted entities
  967.     proto native void OnEvent(int eventType, Param params);
  968.    
  969.     //! Returns player which owns this entity (top in ownership hierarchy)
  970.     proto native Man GetOwnerPlayer();
  971.  
  972.     //! Returns direct owner of this entity (for example: if this entity is in Backpack, returns Backpack)
  973.     proto native EntityAI GetOwner();
  974.    
  975.     string GetVariableString(string varName)
  976.     {
  977.         string ret = "";
  978.         GetVariable(varName, ret);
  979.         return ret;
  980.     }
  981.     int GetVariableInt(string varName)
  982.     {
  983.         int ret = 0;
  984.         GetVariable(varName, ret);
  985.         return ret;
  986.     }
  987.     float GetVariableFloat(string varName)
  988.     {
  989.         float ret = 0;
  990.         GetVariable(varName, ret);
  991.         return ret;
  992.     }
  993.     Object GetVariableObject(string varName)
  994.     {
  995.         Object ret = NULL;
  996.         GetVariable(varName, ret);
  997.         return ret;
  998.     }
  999.  
  1000.     //!Called upon object creation
  1001.     void EEInit()
  1002.     {
  1003.     }
  1004.  
  1005.     void EEAnimHook(int userType, string param)
  1006.     {
  1007.     }
  1008.  
  1009.     void EEAnimDone(string moveName)
  1010.     {
  1011.         if (m_event_handler)
  1012.         {
  1013.             Param param = new Param1<string>(moveName);
  1014.             m_event_handler.OnEvent(this, EEAnimDone, param);
  1015.             delete param;
  1016.         }
  1017.     }
  1018.  
  1019.     /**
  1020.     @code
  1021.     // example of detecting getting item/dropping item from/to inventory
  1022.     void EEItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
  1023.     {
  1024.         Man owner_player_old = NULL;
  1025.         Man owner_player_new = NULL;
  1026.  
  1027.         if (old_owner)
  1028.         {
  1029.             if (old_owner.IsPlayer())
  1030.             {
  1031.                 owner_player_old = old_owner;
  1032.             }
  1033.             else
  1034.             {
  1035.                 owner_player_old = old_owner.GetOwnerPlayer();
  1036.             }
  1037.         }
  1038.  
  1039.         if (new_owner)
  1040.         {
  1041.             if (new_owner.IsPlayer())
  1042.             {
  1043.                 owner_player_new = new_owner;
  1044.             }
  1045.             else
  1046.             {
  1047.                 owner_player_new = new_owner.GetOwnerPlayer();
  1048.             }
  1049.         }
  1050.  
  1051.         if ( !owner_player_new && owner_player_old )
  1052.         {
  1053.             Print("Item dropped from inventory");
  1054.         }
  1055.  
  1056.         if ( owner_player_new && !owner_player_old )
  1057.         {
  1058.             Print("Item taken to inventory");
  1059.         }
  1060.     }
  1061.     @endcode
  1062. */ 
  1063.     void EEItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
  1064.     {
  1065.     }
  1066.  
  1067.     void EEAnimStateChanged(string moveName)
  1068.     {
  1069.     }
  1070.    
  1071.     void EEFired(string weaponType, string muzzleType, string mode, string type, string magazineType, Object missile)
  1072.     {
  1073.     }
  1074.  
  1075.     void EELocal(bool isLocal)
  1076.     {
  1077.     }
  1078.  
  1079.     void EEEngine(bool onOff)
  1080.     {
  1081.     }
  1082.    
  1083.     void EEFuel(bool hasFuel)
  1084.     {
  1085.     }
  1086.  
  1087.     void EEDammaged(string hitpointName, float hit)
  1088.     {
  1089.     }
  1090.  
  1091.     void EEKilled(Object killer)
  1092.     {
  1093.     }
  1094.    
  1095.     void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, string component, string ammo, vector modelPos)
  1096.     {
  1097.     }
  1098.    
  1099.     // !Called on PARENT when a child is attached to it.
  1100.     void EEItemAttached(EntityAI item, string slot_name)
  1101.     {
  1102.         if ( m_ComponentsBank != NULL )
  1103.         {
  1104.             for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
  1105.             {
  1106.                 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
  1107.                 {
  1108.                     m_ComponentsBank.GetComponent(comp_key).Event_OnItemAttached(item, slot_name);
  1109.                 }
  1110.             }
  1111.         }
  1112.        
  1113.         // Energy Manager
  1114.         if ( GetGame().IsServer() )
  1115.         {
  1116.             if ( this.HasEnergyManager()  &&  item.HasEnergyManager() )
  1117.             {
  1118.                 GetCompEM().OnAttachmentAdded(item);
  1119.             }
  1120.         }
  1121.        
  1122.         //item.OnWasAttached(this, slot_name); // Commented out since it's not being used in 0.62. Fix for: DAYZ-25234
  1123.     }
  1124.    
  1125.     // !Called on PARENT when a child is detached from it.
  1126.     void EEItemDetached(EntityAI item, string slot_name)
  1127.     {
  1128.         if ( m_ComponentsBank != NULL )
  1129.         {
  1130.             for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
  1131.             {
  1132.                 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
  1133.                 {
  1134.                     m_ComponentsBank.GetComponent(comp_key).Event_OnItemDetached(item, slot_name);
  1135.                 }
  1136.             }
  1137.         }
  1138.        
  1139.         // Energy Manager
  1140.         if ( GetGame().IsServer() )
  1141.         {
  1142.             if ( this.HasEnergyManager()  &&  item.HasEnergyManager() )
  1143.             {
  1144.                 GetCompEM().OnAttachmentRemoved(item);
  1145.             }
  1146.         }
  1147.        
  1148.         //item.OnWasDetached(this, slot_name); // Commented out since it's not being used in 0.62. Fix for: DAYZ-25234
  1149.     }
  1150.  
  1151.     void EECargoIn(EntityAI item)
  1152.     {
  1153.     }
  1154.  
  1155.     void EECargoOut(EntityAI item)
  1156.     {
  1157.     }
  1158.  
  1159.     void EECargoMove(EntityAI item)
  1160.     {
  1161.     }
  1162.    
  1163.     void EEOnWaterEnter()
  1164.     {
  1165.     }
  1166.    
  1167.     void EEOnWaterExit()
  1168.     {
  1169.     }
  1170.  
  1171.     void EEUsed(Man owner)
  1172.     {
  1173.     }
  1174.  
  1175.     //! Called on client (in multiplayer) when sqf synchronize variable is synchronized
  1176.     void EEVariableSynchronized(string variable_name)
  1177.     {
  1178.     }
  1179.  
  1180.     void EEOnAfterLoad()
  1181.     {
  1182.         // ENERGY MANAGER
  1183.         // Restore connections between devices which were connected before server restart
  1184.         if ( HasEnergyManager()  &&  GetCompEM().GetRestorePlugState() )
  1185.         {
  1186.             int low = GetCompEM().GetEnergySourceIDLow();
  1187.             int high = GetCompEM().GetEnergySourceIDHigh();
  1188.            
  1189.             // get pointer to EntityAI based on this ID
  1190.             EntityAI potential_energy_source = GetGame().GetEntityByPersitentID(low, high); // This function is available only in this event!
  1191.            
  1192.             // IMPORTANT!
  1193.             // Object IDs acquired here become INVALID when electric devices are transfered to another server while in plugged state (like Flashlight plugged into its attachment 9V battery)
  1194.             // These items must be excluded from this system of restoring plug state so they don't accidentally connect to incorrect objects through invalid IDs.
  1195.             // Therefore their plug state should be restored withing the EEItemAttached() event instead of here.
  1196.            
  1197.             bool IsAttachment = false;
  1198.            
  1199.             if (potential_energy_source)
  1200.                 IsAttachment = this.HasAttachment(potential_energy_source);
  1201.            
  1202.             if ( !IsAttachment  &&  potential_energy_source )
  1203.                 IsAttachment = potential_energy_source.HasAttachment(this);
  1204.            
  1205.             if ( potential_energy_source  &&  potential_energy_source.HasEnergyManager()  &&  !IsAttachment )
  1206.             {
  1207.                 GetCompEM().PlugThisInto(potential_energy_source); // restore connection
  1208.             }
  1209.         }
  1210.        
  1211.     }
  1212.    
  1213.     /**
  1214.     \brief This event is called when player is marked captive.
  1215.         \param captive \p bool true when player is marked captive, false when it is unmarked captive.
  1216.     */
  1217.     void EEOnSetCaptive(bool captive)
  1218.     {
  1219.     }
  1220.  
  1221.     // inventory conditions
  1222.     bool ConditionAttachEntityAI(EntityAI child)
  1223.     {
  1224.     }
  1225.  
  1226.     bool ConditionAttach(EntityAI parent)
  1227.     {
  1228.     }
  1229.  
  1230.     bool ConditionDetachEntityAI(EntityAI child)
  1231.     {
  1232.     }
  1233.  
  1234.     bool ConditionDetach(EntityAI parent)
  1235.     {
  1236.     }
  1237.  
  1238.     bool ConditionCargoInEntityAI(EntityAI child)
  1239.     {
  1240.     }
  1241.  
  1242.     bool ConditionCargoIn(EntityAI parent)
  1243.     {
  1244.     }
  1245.  
  1246.     bool ConditionCargoOutEntityAI(EntityAI child)
  1247.     {
  1248.     }
  1249.  
  1250.     bool ConditionCargoOut(EntityAI parent)
  1251.     {
  1252.     }
  1253.    
  1254.     bool ConditionIntoInventoryEntityAI(EntityAI entity_ai)
  1255.     {
  1256.     }
  1257.  
  1258.     bool ConditionIntoInventory(EntityAI player)
  1259.     {
  1260.     }
  1261.  
  1262.     bool ConditionIntoHandsEntityAI(EntityAI entity_ai)
  1263.     {
  1264.     }
  1265.  
  1266.     bool ConditionIntoHands(EntityAI player)
  1267.     {
  1268.     }
  1269.  
  1270.     bool ConditionOutOfHandsEntityAI(EntityAI entity_ai)
  1271.     {
  1272.     }
  1273.  
  1274.     bool ConditionOutOfHands(EntityAI player)  
  1275.     {
  1276.     }
  1277.  
  1278.  
  1279.     // !Called on CHILD when it's attached to parent.
  1280.     void OnWasAttached( EntityAI parent, string slot_name )
  1281.     {
  1282.        
  1283.     }
  1284.    
  1285.     // !Called on CHILD when it's detached from parent.
  1286.     void OnWasDetached( EntityAI parent, string slot_name )
  1287.     {
  1288.        
  1289.     }
  1290.    
  1291.     /**
  1292.     \brief Returns attachment slot where this item belongs
  1293.     */
  1294.     proto native int GetSlotId();
  1295.     /**
  1296.     \brief Returns number of slots for attachments
  1297.     */
  1298.     proto native int GetSlotsCount();
  1299.     /**
  1300.     \brief Returns number of slots for attachments corrected for weapons
  1301.     */
  1302.     int GetSlotsCountCorrect()
  1303.     {
  1304.         return GetSlotsCount();
  1305.     };
  1306.     /**
  1307.     \brief Returns count of attachments attached to this item
  1308.     */
  1309.     proto native int AttachmentsCount();
  1310.     /**
  1311.     \brief Returns attached entity by attachment index
  1312.     \note index is not slot! for getting attachment by slot use FindAttachment
  1313.     */
  1314.     proto native EntityAI GetAttachmentFromIndex(int index);
  1315.     /**
  1316.     \brief Returns True if entity is attached to this
  1317.     */
  1318.     proto native bool HasAttachment(EntityAI e);
  1319.     /**
  1320.     \brief Returns True if entity is attached to this in slot
  1321.     */
  1322.     proto native bool HasAttachmentEx(EntityAI e, int slot);
  1323.     /**
  1324.     \brief Returns attached entity in slot (you can use GetGame().GetInventorySlot(name) to get slot id)
  1325.     */
  1326.     proto native EntityAI FindAttachment(int slot);
  1327.     /**
  1328.     \brief Returns placeholder entity for slot (naked arms, legs etc)
  1329.     */
  1330.     proto native EntityAI FindPlaceholderForSlot(int slot);
  1331.  
  1332.     //! Returns attachment by slot name.
  1333.     EntityAI FindAttachmentBySlotName(string slot_name)
  1334.     {
  1335.         if ( GetGame() )
  1336.         {
  1337.             int slot_id = GetGame().GetInventorySlot(slot_name);
  1338.             return this.FindAttachment(slot_id);
  1339.         }
  1340.     }
  1341.    
  1342.     proto native bool CanRemoveAttachment(EntityAI attachment);
  1343.     proto native bool CanRemoveAttachmentEx(EntityAI attachment, int slot);
  1344.  
  1345.     /**
  1346.     \brief Returns if entity can be removed from its current location
  1347.     */
  1348.     proto native bool CanRemoveEntity();
  1349.    
  1350.     /**
  1351.     \brief Remove attachment
  1352.     */
  1353.     proto native bool RemoveAttachment(EntityAI attachment);
  1354.     /**
  1355.     \brief Remove attachment from slot
  1356.     */
  1357.     proto native bool RemoveAttachmentEx(EntityAI attachment, int slot);
  1358.  
  1359.     /**
  1360.     \brief Create Entity of specified type inside this entity
  1361.     \warning Low-level API, not synchronized over network!
  1362.     */
  1363.     proto native EntityAI CreateOwnedEntity(string typeName);
  1364.     /**
  1365.     \brief Create Entity of specified type as attachment of entity
  1366.     */
  1367.     proto native EntityAI CreateAttachment(string typeName);
  1368.     /**
  1369.     \brief Returns if item can be added anywhere into this entity (as attachment or into cargo, recursively)
  1370.     */
  1371.     bool CanTakeEntityAsOwned(EntityAI item)
  1372.     {
  1373.         if (CanAddAttachment(item))
  1374.         {
  1375.             return true;
  1376.         }
  1377.    
  1378.         if (CanAddEntityInCargo(item))
  1379.         {
  1380.             return true;
  1381.         }
  1382.    
  1383.         // try add into one of attachments
  1384.         int attachments = AttachmentsCount();
  1385.         for (int i = 0; i < attachments; i++)
  1386.         {
  1387.             EntityAI attachment = GetAttachmentFromIndex(i);
  1388.             if (!attachment) continue;
  1389.    
  1390.             if (attachment.CanAddEntityInCargo(item))
  1391.             {
  1392.                 return true;
  1393.             }
  1394.         }
  1395.    
  1396.         return false;
  1397.     }
  1398.     /**
  1399.     \brief Put item anywhere into this entity (as attachment or into cargo, recursively)
  1400.     */
  1401.     bool TakeEntityAsOwned(EntityAI item)
  1402.     {
  1403.         return TryTakeEntityAsOwned(this, item);
  1404.     }
  1405.     /**
  1406.     \brief Put item into into cargo
  1407.     */
  1408.     bool TakeEntityToCargo(EntityAI item)
  1409.     {
  1410.         return TryTakeEntityToCargo(this, item);
  1411.     }
  1412.     /**
  1413.     \brief Put item into into cargo on specific cargo location
  1414.     */
  1415.     bool TakeEntityToCargoAtPos(EntityAI item, Cargo cargo, int row, int col)
  1416.     {
  1417.         if (HasProxyCargo() && cargo != GetCargo())
  1418.         {
  1419.             int i,c;
  1420.             c = GetProxyCargoCount();
  1421.             for (i = 0; i < c; i++)
  1422.             {
  1423.                 if (cargo == GetProxyCargo(i))
  1424.                 {
  1425.                     return TryTakeEntityToProxyCargoEx(this, item, i, row, col);
  1426.                 }
  1427.             }
  1428.         }
  1429.         return TryTakeEntityToCargoEx(this, item, row, col);
  1430.     }
  1431.     /**
  1432.     \brief Returns if item can be added as attachment on specific slot
  1433.     */
  1434.     bool CanTakeEntityAsAttachmentToSlot(EntityAI item, int slot)
  1435.     {
  1436.         return CanAddAttachmentEx(item, slot);
  1437.     }
  1438.     /**
  1439.     \brief Put item into as attachment on specific slot
  1440.     */
  1441.     bool TakeEntityAsAttachmentToSlot(EntityAI item, int slot)
  1442.     {
  1443.         return TryTakeEntityAsAttachment(this, item, slot);
  1444.     }
  1445.     /**
  1446.     \brief Returns if item can be added as attachment
  1447.     */
  1448.     bool CanTakeEntityAsAttachment(EntityAI item)
  1449.     {
  1450.         return CanAddAttachmentEx(item, item.GetSlotId());
  1451.     }
  1452.     /**
  1453.     \brief Put item into as attachment
  1454.     */
  1455.     bool TakeEntityAsAttachment(EntityAI item)
  1456.     {
  1457.         return TryTakeEntityAsAttachment(this, item, item.GetSlotId());
  1458.     }
  1459.     /**
  1460.     \brief Get attached entity by type
  1461.     */
  1462.     EntityAI GetAttachmentByType(typename type)
  1463.     {
  1464.         for ( int i = 0; i < AttachmentsCount(); i++ )
  1465.         {
  1466.             EntityAI attachment = GetAttachmentFromIndex ( i );
  1467.             if ( attachment && attachment.IsInherited ( type ) )
  1468.             {
  1469.                 return attachment;
  1470.             }
  1471.         }
  1472.        
  1473.         return NULL;
  1474.     }
  1475.     /**
  1476.     \brief Get attached entity by config type name
  1477.     */
  1478.     EntityAI GetAttachmentByConfigTypeName(string type)
  1479.     {
  1480.         for ( int i = 0; i < AttachmentsCount(); i++ )
  1481.         {
  1482.             EntityAI attachment = GetAttachmentFromIndex ( i );
  1483.             if ( attachment.IsKindOf ( type ) )
  1484.             {
  1485.                 return attachment;
  1486.             }
  1487.         }
  1488.        
  1489.         return NULL;
  1490.     }
  1491.     /**
  1492.     \brief Returns if item can be dropped out from this entity
  1493.     */
  1494.     bool CanDropEntity(EntityAI item)
  1495.     {
  1496.         // this function will be implemented in future
  1497.         return true;
  1498.     }
  1499.     /**
  1500.     \brief Drop item out of this entity
  1501.     */
  1502.     bool DropEntity(EntityAI item)
  1503.     {
  1504.         return TryDropEntity(this, item);
  1505.     }
  1506.  
  1507.     /**
  1508.     \brief LOW LEVEL: Check if attachment can be added to any slot
  1509.     */ 
  1510.     proto native bool CanAddAttachment(notnull EntityAI e);
  1511.     /**
  1512.     \brief LOW LEVEL: Check if attachment can be added to slot
  1513.     */
  1514.     proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot);
  1515.  
  1516.     /**
  1517.     \brief LOW LEVEL: Get Cargo class for this entity
  1518.     \warning Low-level API, use only if you know what you are doing
  1519.     */
  1520.     proto native Cargo GetCargo();
  1521.     proto native bool HasProxyCargo();
  1522.     proto native int GetProxyCargoCount();
  1523.     proto native Cargo GetProxyCargo(int cargoIndex);
  1524.  
  1525.     proto native bool HasOwnedEntity(EntityAI item);
  1526.     proto native bool CanAddOwnedEntity(EntityAI item);
  1527.     proto native bool AddOwnedEntity(EntityAI item);
  1528.     proto native bool CanRemoveOwnedEntity(EntityAI item);
  1529.     proto native bool RemoveOwnedEntity(EntityAI item);
  1530.  
  1531.     proto native bool HasEntityInCargo(EntityAI e);
  1532.     proto native bool HasEntityInCargoEx(EntityAI e, int row, int col);
  1533.     proto native bool CanAddEntityInCargo(EntityAI e);
  1534.     proto native bool CanAddEntityInCargoEx(EntityAI e, int row, int col);
  1535.     proto native bool AddEntityInCargo(EntityAI owner, EntityAI cargo);
  1536.     proto native bool AddEntityInCargoEx(EntityAI owner, EntityAI e, int row, int col);
  1537.     proto native bool CanRemoveEntityInCargo(EntityAI e);
  1538.     proto native bool RemoveEntityInCargo(EntityAI owner, EntityAI e);
  1539.  
  1540.     proto native bool CanLockInventoryWithKey(EntityAI key);
  1541.     proto native bool CanUnlockInventoryWithKey(EntityAI key);
  1542.     proto native void LockInventoryWithKey(EntityAI key);
  1543.     proto native void UnlockInventoryWithKey(EntityAI key);
  1544.     proto native bool HasKeys();
  1545.  
  1546.     proto native void LockInventory(int lockType);
  1547.     proto native void UnlockInventory(int lockType);
  1548.     proto native bool IsInventoryUnlocked();
  1549.     proto native bool IsInventoryLocked();
  1550.  
  1551.     proto native void SwitchLight(bool isOn);
  1552.    
  1553.     //! Change texture in hiddenSelections
  1554.     proto native void SetObjectTexture(int index, string texture_name);
  1555.     //! Change material in hiddenSelections
  1556.     proto native void SetObjectMaterial(int index, string mat_name);
  1557.  
  1558.     //! Return animation phase of animation on object.
  1559.     proto native float GetAnimationPhase(string animation);
  1560.     //! Process animation on object. Animation is defined in config file. Wanted animation phase is set to phase.
  1561.     void SetAnimationPhase(string animation, float phase)
  1562.     {
  1563.         GetGame().ObjectSetAnimationPhase(this, animation, phase);
  1564.     }
  1565.    
  1566.     proto native bool   IsPilotLight();
  1567.     proto native void SetPilotLight(bool isOn);
  1568.    
  1569.     proto native bool IsWaterContact();
  1570.    
  1571.     //! Returns the vehicle in which the given unit is mounted. If there is none, the unit is returned.
  1572.     proto native EntityAI GetVehicle();
  1573.    
  1574.     /**
  1575.     \brief Checks whether the unit is a captive. If the unit is a vehicle, its commander is checked instead.
  1576.     @code
  1577.         GetGame().GetPlayer().IsCaptive();
  1578.     @endcode
  1579.     */
  1580.     proto native bool IsCaptive();
  1581.  
  1582.     proto native void SetAllowDamage(bool val);
  1583.  
  1584.     //! Get list of available actions
  1585.     proto native void GetActions(Man player, EntityAI with = NULL);
  1586.    
  1587.     //! Returns True if object has any actions
  1588.     proto native bool HasActions(Man player, EntityAI with = NULL);
  1589.  
  1590.     /**
  1591.     \brief Engine calls this function to collect data from entity to store to game database (on server side).
  1592.     @code
  1593.     void OnStoreSave(ParamsWriteContext ctx)
  1594.     {
  1595.         // dont forget to propagate this call trough class hierarchy!
  1596.         super.OnStoreSave(ctx);
  1597.  
  1598.         // write any data (using params) you want to store
  1599.         autoptr Param4<bool, int, float, string> p1 = new Param4<bool, int, float, string>(true, 56, 6.28, "Pepe");
  1600.         autoptr Param4<float, string, float, string> p2 = new Param4<float, string, float, string>(9.56, "ahoj", 6.28, "svet");
  1601.         ctx.Write(p1);
  1602.         ctx.Write(p2);
  1603.     }
  1604.     @endcode
  1605.     */
  1606.     void OnStoreSave(ParamsWriteContext ctx)
  1607.     {
  1608.         // Saving of energy related states
  1609.         if ( HasEnergyManager() )
  1610.         {
  1611.             /*===========================
  1612.                 Save int, float, bool
  1613.             ===========================*/
  1614.            
  1615.             // Save energy amount
  1616.             autoptr Param1<float> par_f_energy = new Param1<float>( GetCompEM().GetEnergy() );
  1617.             ctx.Write( par_f_energy );
  1618.            
  1619.             // Save passive/active state
  1620.             autoptr Param1<bool> par_b_is_passive = new Param1<bool>( GetCompEM().IsPassive() );
  1621.             ctx.Write( par_b_is_passive );
  1622.            
  1623.             // Save ON/OFF state
  1624.             autoptr Param1<bool> par_b_is_on = new Param1<bool>( GetCompEM().IsSwitchedOn() );
  1625.             ctx.Write( par_b_is_on );
  1626.            
  1627.             // Save plugged/unplugged state
  1628.             autoptr Param1<bool> par_b_is_plugged = new Param1<bool>( GetCompEM().IsPlugged() );
  1629.             ctx.Write( par_b_is_plugged );
  1630.            
  1631.            
  1632.             /*===========================
  1633.                     Save object IDs
  1634.             ===========================*/
  1635.            
  1636.             // ENERGY SOURCE
  1637.             // Save energy source IDs
  1638.             EntityAI energy_source = GetCompEM().GetEnergySource();
  1639.             int ID_low = 0;
  1640.             int ID_high = 0;
  1641.            
  1642.             if (energy_source)
  1643.             {
  1644.                 energy_source.GetPersistentID(ID_low, ID_high);
  1645.             }
  1646.            
  1647.             // Save energy source ID low
  1648.             autoptr Param1<int> p_i_energy_source_ID_low = new Param1<int>( ID_low );
  1649.             ctx.Write( p_i_energy_source_ID_low );
  1650.            
  1651.             // Save energy source ID high
  1652.             autoptr Param1<int> p_i_energy_source_ID_high = new Param1<int>( ID_high );
  1653.             ctx.Write( p_i_energy_source_ID_high );
  1654.         }
  1655.     }
  1656.    
  1657.     /**
  1658.     \brief Called when data is loaded from game database (on server side).
  1659.     @code
  1660.     void OnStoreLoad(ParamsReadContext ctx)
  1661.     {
  1662.         // dont forget to propagate this call trough class hierarchy!
  1663.         super.OnStoreLoad(ctx);
  1664.  
  1665.         // read data loaded from game database (format and order of reading must be the same as writing!)
  1666.         autoptr Param4<bool, int, float, string> p1 = new Param4<bool, int, float, string>(false, 0, 0, "");
  1667.         autoptr Param4<float, string, float, string> p2 = new Param4<float, string, float, string>(0, "", 0, "");
  1668.         if (ctx.Read(p1))
  1669.         {
  1670.           Print(p1.param1);
  1671.           Print(p1.param2);
  1672.           Print(p1.param3);
  1673.           Print(p1.param4);
  1674.         }
  1675.         else
  1676.         {
  1677.             Print("no data");
  1678.         }
  1679.  
  1680.         if (ctx.Read(p2))
  1681.         {
  1682.           Print(p2.param1);
  1683.           Print(p2.param2);
  1684.           Print(p2.param3);
  1685.           Print(p2.param4);
  1686.         }
  1687.         else
  1688.         {
  1689.             Print("no data");
  1690.         }
  1691.     }
  1692.     @endcode
  1693.     */
  1694.     void OnStoreLoad (ParamsReadContext ctx)
  1695.     {
  1696.         // Restoring of energy related states
  1697.         if ( HasEnergyManager() )
  1698.         {
  1699.             /*=====================================
  1700.                 Load int, float, bool variables
  1701.             =====================================*/
  1702.            
  1703.             // Load energy amount
  1704.             autoptr Param1<float> par_f_energy = new Param1<float>( 0 );
  1705.             ctx.Read( par_f_energy );
  1706.             GetCompEM().SetEnergy(par_f_energy.param1);
  1707.            
  1708.             // Load passive/active state
  1709.             autoptr Param1<bool> par_b_is_passive = new Param1<bool>( 0 );
  1710.             ctx.Read( par_b_is_passive );
  1711.             GetCompEM().SetPassiveState(par_b_is_passive.param1);
  1712.            
  1713.             // Load ON/OFF state
  1714.             autoptr Param1<bool> par_b_is_on = new Param1<bool>( false );
  1715.             ctx.Read( par_b_is_on );
  1716.            
  1717.             // Load plugged/unplugged state
  1718.             autoptr Param1<bool> par_b_is_plugged = new Param1<bool>( false );
  1719.             ctx.Read( par_b_is_plugged );
  1720.            
  1721.            
  1722.             /*=============================
  1723.                     Load object IDs
  1724.             =============================*/
  1725.            
  1726.             // ENERGY SOURCE
  1727.             // Load energy source ID low
  1728.             autoptr Param1<int> p_i_energy_source_ID_low = new Param1<int>( 0 ); // Even 0 can be valid ID!
  1729.             ctx.Read( p_i_energy_source_ID_low );
  1730.            
  1731.             // Load energy source ID high
  1732.             autoptr Param1<int> p_i_energy_source_ID_high = new Param1<int>( 0 ); // Even 0 can be valid ID!
  1733.             ctx.Read( p_i_energy_source_ID_high );
  1734.            
  1735.             if ( par_b_is_plugged.param1 )
  1736.             {
  1737.                 // Because function GetEntityByPersitentID() cannot be called here, ID values must be stored and used later.
  1738.                 GetCompEM().StoreEnergySourceIDs( p_i_energy_source_ID_low.param1, p_i_energy_source_ID_high.param1 );
  1739.                 GetCompEM().RestorePlugState(true);
  1740.             }
  1741.            
  1742.             if (par_b_is_on.param1)
  1743.             {
  1744.                 GetCompEM().SwitchOn();
  1745.             }
  1746.         }
  1747.     }
  1748.  
  1749.     //! Sets object synchronization dirty flag, which signalize that object wants to be synchronized (take effect only in MP on server side)
  1750.     proto native void SetSynchDirty();
  1751.  
  1752.     /**
  1753.     \brief After synchronization dirty flag is set (SetSynchDirty function), engine calls this function to collect data to synchronize from entity (on server side).
  1754.     @code
  1755.     void OnSynchronize(ParamsWriteContext ctx)
  1756.     {
  1757.         // dont forget to propagate this call trough class hierarchy!
  1758.         super.OnSynchronize(ctx);
  1759.  
  1760.         // write any data (using params) you want to pass to clients instances
  1761.         autoptr Param2<int, float> p = new Param2<int, float>(m_counter, m_blood_preasure);
  1762.         ctx.Write(p);
  1763.     }
  1764.     @endcode
  1765.     */
  1766.     void OnSynchronize(ParamsWriteContext ctx)
  1767.     {
  1768.     }
  1769.    
  1770.     /**
  1771.     \brief Called on clients after receiving synchronization data from server.
  1772.     @code
  1773.     void OnSynchronized(ParamsReadContext ctx)
  1774.     {
  1775.         // dont forget to propagate this call trough class hierarchy!
  1776.         super.OnSynchronized(ctx);
  1777.  
  1778.         // read data (format and order of reading on client must be the same as writing on server side)
  1779.         Param2<int, float> p = new Param2<int, float>(0, 0);
  1780.         if (ctx.Read(p))
  1781.         {
  1782.             m_counter = p.param1;
  1783.             m_blood_preasure = p.param2;
  1784.         }
  1785.     }
  1786.     @endcode
  1787.     */
  1788.     void OnSynchronized (ParamsReadContext ctx)
  1789.     {
  1790.     }
  1791.    
  1792.     void EOnFrame(IEntity other, float timeSlice)
  1793.     {
  1794.         if ( m_ComponentsBank != NULL )
  1795.         {
  1796.             for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
  1797.             {
  1798.                 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
  1799.                 {
  1800.                     m_ComponentsBank.GetComponent(comp_key).Event_OnFrame(other, timeSlice);
  1801.                 }
  1802.             }
  1803.         }
  1804.     }
  1805.    
  1806.     // -------------------------------------------------------------------------
  1807.     Shape DebugBBoxDraw()
  1808.     {
  1809.         return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDraw();
  1810.     }
  1811.    
  1812.     // -------------------------------------------------------------------------
  1813.     void DebugBBoxSetColor(int color)
  1814.     {
  1815.         GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxSetColor(color);
  1816.     }
  1817.    
  1818.     // -------------------------------------------------------------------------
  1819.     void DebugBBoxDelete()
  1820.     {
  1821.         GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDelete();
  1822.     }
  1823.    
  1824.     // -------------------------------------------------------------------------
  1825.     Shape DebugDirectionDraw(float distance = 1)
  1826.     {
  1827.         return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDraw(distance);
  1828.     }
  1829.    
  1830.     // -------------------------------------------------------------------------
  1831.     void DebugDirectionSetColor(int color)
  1832.     {
  1833.         GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionSetColor(color);
  1834.     }
  1835.    
  1836.     // -------------------------------------------------------------------------
  1837.     void DebugDirectionDelete()
  1838.     {
  1839.         GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDelete();
  1840.     }
  1841.    
  1842.     //! Hides selection of the given name. Must be configed in config.hpp and models.cfg
  1843.     void HideSelection( string selection_name )
  1844.     {
  1845.         SetAnimationPhase ( selection_name, 1 ); // 1 = hide, 0 = unhide!
  1846.     }
  1847.    
  1848.     //! Shows selection of the given name. Must be configed in config.hpp and models.cfg
  1849.     void ShowSelection( string selection_name )
  1850.     {
  1851.         SetAnimationPhase ( selection_name, 0 ); // 1 = hide, 0 = unhide!
  1852.     }
  1853.  
  1854.     //! Returns low and high bits of persistence id of this entity.
  1855.     //! This id stays the same event after server restart.
  1856.     proto void GetPersistentID( out int low, out int high );
  1857.    
  1858.     //! Get remaining economy lifetime (seconds)
  1859.     proto native float GetLifetime();
  1860.     //! Reset economy lifetime to default (seconds)
  1861.     proto native void IncreaseLifetime();
  1862.    
  1863.     /*===================================================================================================
  1864.                                                 ENERGY MANAGER
  1865.     Documentation: Confluence >> Camping & Squatting >> Electricity >> Energy Manager functionalities
  1866.     ===================================================================================================*/
  1867.    
  1868.     //! Use this to access Energy Manager component on your device. Returns NULL if the given object lacks such component.
  1869.     ComponentEnergyManager GetCompEM()
  1870.     {
  1871.         if ( HasComponent(COMP_TYPE_ENERGY_MANAGER) )
  1872.         {
  1873.             return GetComponent(COMP_TYPE_ENERGY_MANAGER);
  1874.         }
  1875.        
  1876.         return NULL;
  1877.     }
  1878.    
  1879.     //! If this item has class EnergyManager in its config then it returns true. Otherwise returns false.
  1880.     bool HasEnergyManager()
  1881.     {
  1882.         return HasComponent(COMP_TYPE_ENERGY_MANAGER);
  1883.     }
  1884.    
  1885.     // ------ Public Events for Energy manager component------
  1886.    
  1887.     //! Energy manager event: Called only once when this device starts doing its work
  1888.     void OnWorkStart() {}
  1889.    
  1890.     //! Energy manager event: Called every device update if its supposed to do some work. The update can be every second or at random, depending on its manipulation.
  1891.     void OnWork( float consumed_energy ) {}
  1892.    
  1893.     //! Energy manager event: Called when the device stops working (was switched OFF or ran out of energy)
  1894.     void OnWorkStop() {}
  1895.    
  1896.     //! Energy manager event: Called when the device is switched on
  1897.     void OnSwitchOn() {}
  1898.    
  1899.     //! Energy manager event: Called when the device is switched OFF
  1900.     void OnSwitchOff() {}
  1901.    
  1902.     //! Energy manager event: Called when this device is plugged into some energy source
  1903.     void OnIsPlugged(EntityAI source_device) {}
  1904.    
  1905.     //! Energy manager event: Called when this device is UNPLUGGED from the energy source
  1906.     void OnIsUnplugged( EntityAI last_energy_source ) {}
  1907.    
  1908.     //! Energy manager event: When something is plugged into this device
  1909.     void OnOwnSocketTaken( EntityAI device ) {}
  1910.    
  1911.     //! Energy manager event: When something is UNPLUGGED from this device
  1912.     void OnOwnSocketReleased( EntityAI device ) {}
  1913.    
  1914.     //! Energy manager event: Object's initialization. Energy Manager is fully initialized by this point.
  1915.     void OnInitEnergy() {}
  1916.    
  1917.     // ------ End of Energy Manager Component ------
  1918. };
  1919.  
  1920. //-----------------------------------------------------------------------------
  1921. class ScriptedEntity extends EntityAI
  1922. {
  1923.     /**
  1924.     \brief Sets collision box for object
  1925.     @param mins min values of box
  1926.     @param maxs max values of box
  1927.     \note This function is obsolete, use rather SetCollisionBox()
  1928.     */
  1929.     proto native void SetClippingInfo(vector mins, vector maxs, float radius);
  1930.    
  1931.     /**
  1932.     \brief Sets collision box for object
  1933.     @param mins min values of box
  1934.     @param maxs max values of box
  1935.     \n usage :
  1936.     @code
  1937.     vector mins = "-1 -1 -1";
  1938.     vector maxs = "1 1 1";
  1939.     SetCollisionBox(mins, maxs);
  1940.     @endcode
  1941.     */
  1942.     proto native void SetCollisionBox(vector mins, vector maxs);
  1943. };
  1944.  
  1945. //-----------------------------------------------------------------------------
  1946. class Transport extends EntityAI
  1947. {
  1948.     proto native bool EngineInOperation();
  1949.     proto native float GetRPM();
  1950.     proto native float GetSpeedometerValue();
  1951.     proto native float GetFuelFraction();
  1952.     proto native float VisibleLights();
  1953.     proto native float VisibleMovement();
  1954.     proto native float VisibleMovementNoSize();
  1955.     proto native float Audible();
  1956.  
  1957. /*  bool TestEngineInOperation()
  1958.     {
  1959.         Print("Transport::EngineInOperation");
  1960.         float isRunning = EngineInOperation();
  1961.         return isRunning;
  1962.     }
  1963.     float TestGetRPM()
  1964.     {
  1965.         Print("Transport::GetRPM");
  1966.         float rpm = GetRPM();
  1967.         return rpm;
  1968.     }
  1969.     float TestGetSpeedometerValue()
  1970.     {
  1971.         Print("Transport::GetSpeedometerValue");
  1972.         float speedKmh = GetSpeedometerValue();
  1973.         return speedKmh;
  1974.     }
  1975.     float TestGetFuelFraction()
  1976.     {
  1977.         Print("Transport::GetFuelFraction");
  1978.         float fuel = GetFuelFraction();
  1979.         return fuel;
  1980.     }
  1981.     float TestVisibleLights()
  1982.     {
  1983.         Print("Transport::VisibleLights");
  1984.         return VisibleLights();
  1985.     }
  1986.     float TestVisibleMovement()
  1987.     {
  1988.         Print("Transport::VisibleMovement");
  1989.         return VisibleMovement();
  1990.     }
  1991.     float TestVisibleMovementNoSize()
  1992.     {
  1993.         Print("Transport::VisibleMovementNoSize");
  1994.         return VisibleMovementNoSize();
  1995.     }
  1996.     float TestAudible()
  1997.     {
  1998.         Print("Transport::Audible");
  1999.         return Audible();
  2000.     }*/
  2001. };
  2002.  
  2003. //-----------------------------------------------------------------------------
  2004. class TankOrCar extends Transport
  2005. {
  2006.     proto native int GetEngagedGear();
  2007.     proto native float GetMinRPM();
  2008.     proto native float GetMaxRPM();
  2009.     proto native float GetBrakeFluidFraction();
  2010.     proto native float GetOilFraction();
  2011.     proto native float GetCoolantFraction();
  2012.     proto native float GetElectricPowerFraction();
  2013.  
  2014. /*  int TestGetEngagedGear()
  2015.     {
  2016.         Print("GetEngagedGear");
  2017.         int gear = GetEngagedGear();
  2018.         return gear;
  2019.     }
  2020.     float TestGetMinRPM()
  2021.     {
  2022.         Print("TankOrCar::GetMinRPM");
  2023.         float minRpm = GetMinRPM();
  2024.         return minRpm;
  2025.     }
  2026.     float TestGetMaxRPM()
  2027.     {
  2028.         Print("TankOrCar::GetMaxRPM");
  2029.         float maxRpm = GetMaxRPM();
  2030.         return maxRpm;
  2031.     }
  2032.     float TestGetBrakeFluidFraction()
  2033.     {
  2034.         Print("Transport::GetBrakeFluidFraction");
  2035.         float fluid = GetBrakeFluidFraction();
  2036.         return fluid;
  2037.     }
  2038.     float TestGetOilFraction()
  2039.     {
  2040.         Print("Transport::GetOilFraction");
  2041.         float oil = GetOilFraction();
  2042.         return oil;
  2043.     }
  2044.     float TestGetCoolantFraction()
  2045.     {
  2046.         Print("Transport::GetCoolantFraction");
  2047.         float coolant = GetCoolantFraction();
  2048.         return coolant;
  2049.     }
  2050.     float TestGetElectricPowerFraction()
  2051.     {
  2052.         Print("Transport::GetElectricPowerFraction");
  2053.         float electricPower = GetElectricPowerFraction();
  2054.         return ElectricPower;
  2055.     }*/
  2056. };
  2057.  
  2058. //-----------------------------------------------------------------------------
  2059. class Car extends TankOrCar
  2060. {
  2061.     int testVar;
  2062.    
  2063.     proto native void TestMethod(int a);
  2064. /*
  2065.     void EOnFrame(IEntity other, float timeSlice)
  2066.     {
  2067.         TestMethod(1);
  2068.        
  2069.         vector pos = GetOrigin();
  2070.         Shape.Create(ShapeType.LINE, 0xffffffff, SS_ONCE, pos, pos + Vector(0,5,0));
  2071.         //Print(GetOrigin());
  2072.         //Print("frame");
  2073.         if(KeyState(KC_J))
  2074.         {
  2075.             Print("frame");
  2076.             SetOrigin(Vector(0, 1, 0) * timeSlice + GetOrigin());      
  2077.         }
  2078.     }
  2079.    
  2080.     void EOnSimulate(IEntity other, float timeSlice)
  2081.     {
  2082.         //Print("simulate");
  2083.     }
  2084.  
  2085.     void EOnInit(IEntity world, int extra)
  2086.     {
  2087.         Print("on init");
  2088.     }
  2089. */     
  2090.     void Car()
  2091.     {
  2092.         SetFlags(EntityFlags.SOLID, false);
  2093. //      SetEventMask(EntityEvent.FRAME|EntityEvent.SIMULATE);
  2094.     }
  2095. };
  2096.  
  2097. //-----------------------------------------------------------------------------
  2098. class Thing extends EntityAI
  2099. {
  2100. };
  2101.  
  2102. //-----------------------------------------------------------------------------
  2103. class Man extends EntityAI
  2104. {
  2105.     proto native void                       DisableSimulation(bool disable);
  2106.  
  2107.     proto native bool                       PlayActionGlobal(string action);
  2108.     proto native bool                       PlayActionNowGlobal(string action);
  2109.     proto native bool                       PlayMoveGlobal(string move);
  2110.     proto native bool                       PlayMoveNowGlobal(string move);
  2111.     proto native void                       SwitchMoveGlobal(string move);
  2112.     proto native void                       SwitchActionGlobal(string action);
  2113.  
  2114.     //! Returns vehicle which this Man object is driving. If this Man object isn't as driver of any vehicle it will return NULL.
  2115.     proto native EntityAI                   GetDrivingVehicle();
  2116.  
  2117.     proto native bool                       CanOpenInventory();
  2118.    
  2119.     proto native int                        GetQuickBarSize();
  2120.     proto native bool                       CanAddEntityToQuickBarEx(EntityAI item, int index);
  2121.     proto native EntityAI               GetEntityInQuickBar(int index);
  2122.     proto native EntityAI               GetEntityInHands();
  2123.     proto native bool                       HasEntityInHands(EntityAI e);
  2124.     proto native bool                       CanAddEntityInHands(EntityAI e);
  2125.     proto native bool                   CanRemoveEntityInHands();
  2126.  
  2127.     proto native void                   SetAnimVariableInt(string name, int value);
  2128.     proto native void                   SetAnimVariableFloat(string name, float value);
  2129.     proto native void                   SetAnimVariableBool(string name, bool value);
  2130.     proto native void                   SetAnimVariableString(string name, string value);
  2131.    
  2132.     proto native void                   SetShakeBodyFactor(float value);
  2133.     proto native void                   SetShakeHandsFactor(float value);
  2134.  
  2135.     proto native vector                 GetCameraDirection();
  2136.     proto native vector                 GetCameraPosition();
  2137.    
  2138.     proto native void                       AddNoise(string noiseTypeName);
  2139.     proto native float                  GetPresenceInAI();
  2140.     proto native string                 GetCurrentWeaponMode();
  2141.     proto native float                  GetCurrentZeroing();
  2142.  
  2143.     //! Returns Life State of player, possible values are LifeStateAlive, LifeStateDead, LifeStateAsleep, LifeStateUnconscious
  2144.     proto native int                        GetLifeState();
  2145.  
  2146.     //! Set speech restriction
  2147.     proto native void                       SetSpeechRestricted(bool state);
  2148.    
  2149.     //! Check if player has resctricted speech
  2150.     proto native bool                       IsSpeechRestricted();
  2151.    
  2152.     //! Texture that is used on the Man's face and hands
  2153.     proto native void                       SetFaceTexture(string texture_name);
  2154.     //! Material that is used on the Man's face and hands
  2155.     proto native void                       SetFaceMaterial(string material_name);
  2156.  
  2157.     bool IsMan()
  2158.     {
  2159.         return true;
  2160.     }
  2161.  
  2162.     void EEItemIntoHands(EntityAI item)
  2163.     {
  2164.     }
  2165.  
  2166.     void EEItemOutOfHands(EntityAI item)
  2167.     {
  2168.     }
  2169.  
  2170.     // multiplayer safe inventory operations
  2171.     bool SetEntityShortcut(EntityAI item, int index)
  2172.     {
  2173.         return TrySetEntityToQuickBar(this, item, index);
  2174.     }
  2175.    
  2176.     // -------------------------------------------------------------------------
  2177.     bool CanDropEntity(EntityAI item)
  2178.     {
  2179.         // this function can be implemented in future
  2180.         return true;
  2181.     }
  2182.    
  2183.     // -------------------------------------------------------------------------
  2184.     bool DropEntity(EntityAI item)
  2185.     {
  2186.         return TryDropEntity(this, item);
  2187.     }
  2188.    
  2189.     // -------------------------------------------------------------------------
  2190.     bool TakeEntityToHands(EntityAI item)
  2191.     {
  2192.         EntityAI in_hands = GetEntityInHands();
  2193.         if (in_hands)
  2194.         {
  2195.             MoveItemFromHandsToInventory(in_hands);
  2196.         }
  2197.    
  2198.         return TryTakeEntityToHands(this, item);
  2199.     }
  2200.    
  2201.     // -------------------------------------------------------------------------
  2202.     bool MoveItemFromHandsToInventory(EntityAI item)
  2203.     {
  2204.         return TryMoveItemFromHandsToInventory(this, item);
  2205.     }
  2206.    
  2207.     // -------------------------------------------------------------------------
  2208.     bool RemoveItemFromHands(EntityAI item)
  2209.     {
  2210.         return TryRemoveItemFromHands(this, item);
  2211.     }
  2212.    
  2213.     // -------------------------------------------------------------------------
  2214.     bool SwapEntities(EntityAI item1, EntityAI item2)
  2215.     {
  2216.         return TrySwapEntities(this, item1, item2);
  2217.     }
  2218.  
  2219. //----------------------------------------------------------------
  2220. // Stats
  2221.  
  2222.     //! Registers new stat type for this player.
  2223.     /*!
  2224.         \param[in] name The name of the stat type.
  2225.     */
  2226.     proto native bool StatRegister( string name );
  2227.     //! Gets counter value of the specified stat type.
  2228.     /*!
  2229.         \param[in] name The name of the stat type.
  2230.     */
  2231.     proto native float StatGet( string name );
  2232.     //! Gets counter value as string of the specified stat type.
  2233.     /*!
  2234.         \param[in]  name  The name of the stat type.
  2235.         \param[out] value A formatted string containing stat value.
  2236.     */
  2237.     proto void StatGetCounter( string name, out string value );
  2238.     //! Gets counter value as formatted time string of the specified stat type.
  2239.     /*!
  2240.         \param[in]  name  The name of the stat type.
  2241.         \param[out] value A formatted string containing stat value.
  2242.     */
  2243.     proto void StatGetAsTime( string name, out string value );
  2244.     //! Updates stat counter with given value.
  2245.     /*!
  2246.         \param[in] name  The name of the stat type.
  2247.         \param[in] value The specified value.
  2248.     */
  2249.     proto native void StatUpdate( string name, float value );
  2250.     //! Updates stat counter by time.
  2251.     /*!
  2252.         Use this to measure play time.
  2253.  
  2254.         \param[in] name The name of the stat type.
  2255.     */
  2256.     proto native void StatUpdateByTime( string name );
  2257.     //! Updates stat counter by player's actual position.
  2258.     /*!
  2259.         Use this to measure player's travelling distance.
  2260.  
  2261.         \param[in] name The name of the stat type.
  2262.     */
  2263.     proto native void StatUpdateByPosition( string name );
  2264.     //! Updates stat counter by given position.
  2265.     /*!
  2266.         \param[in] name The name of the stat type.
  2267.         \param[in] pos  The specified position.
  2268.     */
  2269.     proto native void StatUpdateByGivenPos( string name, vector pos );
  2270.     //! Invokes read stats from server to client.
  2271.     proto native void StatInvokeUpdate();
  2272.  
  2273. //----------------------------------------------------------------
  2274.    
  2275.     void TestSQF(int number, string text, vector vec)
  2276.     {
  2277.         Print(number);
  2278.         Print(text);
  2279.         Print(vec);
  2280.     }
  2281.  
  2282.     void PerformAction(Action action)
  2283.     {
  2284.         GetGame().PerformAction(this, action);
  2285.     }
  2286.  
  2287.     void Man()
  2288.     {
  2289.         SetFlags(EntityFlags.TOUCHTRIGGERS, false);
  2290.     }
  2291. };
  2292.  
  2293.  
  2294. //-----------------------------------------------------------------------------
  2295. class InventoryItem extends EntityAI
  2296. {  
  2297.     //! Some inventoryItem devices can be switched on/off (radios, transmitters)
  2298.     proto native void SwitchOn(bool onOff);
  2299.     //! Some inventoryItem devices can be switched on/off (radios, transmitters)
  2300.     proto native bool   IsOn();
  2301.    
  2302.     void EEUsed(Man owner)
  2303.     {
  2304.         if (GetGame().GetMission())
  2305.         {
  2306.             GetGame().GetMission().OnItemUsed(this, owner);
  2307.         }
  2308.     }
  2309.    
  2310.     void OnRightClick()
  2311.     {
  2312.    
  2313.     }
  2314.  
  2315.     event bool OnUseFromInventory(Man owner)
  2316.     {
  2317.         return false;
  2318.     }
  2319.  
  2320.     //! Get tooltip text
  2321.     string GetTooltip()
  2322.     {
  2323.         return ConfigGetString("descriptionShort");
  2324.     }
  2325.  
  2326.     bool IsInventoryItem()
  2327.     {
  2328.         return true;
  2329.     }
  2330. };
  2331.  
  2332. //-----------------------------------------------------------------------------
  2333. class Cargo
  2334. {
  2335.     proto native int GetWidth();
  2336.     proto native int GetHeight();
  2337.     proto native int GetItemCount();
  2338.     proto native EntityAI GetItem(int index);
  2339.     proto void GetItemSize(int index, out int w, out int h);
  2340.     proto void GetItemPos(int index, out int x, out int y);
  2341.  
  2342.     proto native EntityAI FindEntityInCargoOn(int row, int col);
  2343.     proto native int FindEntityInCargo(EntityAI e);
  2344.  
  2345.     proto native bool CanMoveEntityInCargoEx(EntityAI e, int row, int col); /// can move from current location in cargo to new one
  2346.     proto native bool CanSwapEntityInCargo(EntityAI oldItem, EntityAI newItem);
  2347.  
  2348.     proto native EntityAI GetParent();
  2349. };
  2350.  
  2351. //-----------------------------------------------------------------------------
  2352. class Building extends EntityAI
  2353. {
  2354. };
  2355.  
  2356. //-----------------------------------------------------------------------------
  2357. class SoundOnVehicle extends Entity
  2358. {
  2359. };
  2360.  
  2361. // custom widgets
  2362. //-----------------------------------------------------------------------------
  2363. class ItemPreviewWidget extends UIWidget
  2364. {
  2365.     proto native void SetItem(EntityAI object);
  2366.     proto native EntityAI GetItem();
  2367.    
  2368.     proto native bool GetCloseup();
  2369.     proto native void SetCloseup(bool enabled);
  2370.  
  2371.     proto native void       SetModelOrientation(vector vOrientation);
  2372.     proto native vector GetModelOrientation();
  2373.     proto native void       SetModelPosition(vector vPos);
  2374.     proto native vector GetModelPosition();
  2375. };
  2376.  
  2377. //-----------------------------------------------------------------------------
  2378. class PlayerPreviewWidget extends UIWidget
  2379. {
  2380.     proto native void       SetItemInHands(InventoryItem object);
  2381.     proto native InventoryItem      GetItemInHands();
  2382.     proto native void       SetPlayer(Man player);
  2383.     proto native Man        GetPlayer();
  2384.     proto native void       SwitchMove(string move);
  2385.  
  2386.     proto native void       SetModelOrientation(vector vOrientation);
  2387.     proto native vector GetModelOrientation();
  2388.     proto native void       SetModelPosition(vector vPos);
  2389.     proto native vector GetModelPosition();
  2390. };
  2391.  
  2392.  
  2393. //-----------------------------------------------------------------------------
  2394. class EntityScriptedActivity
  2395. {
  2396.     void EntityScriptedActivity()
  2397.     {
  2398.     }
  2399.  
  2400.     void ~EntityScriptedActivity()
  2401.     {
  2402.     }
  2403.  
  2404.     bool OnSimulate(float timeslice)
  2405.     {
  2406.         return false;
  2407.     }
  2408.  
  2409.     proto native int AddRef();
  2410.     proto native int Release();
  2411. };
  2412.  
  2413. //-----------------------------------------------------------------------------
  2414. //! Player description
  2415. class PlayerIdentity
  2416. {
  2417.     //! ping range estimation
  2418.     proto native int GetPingMin();
  2419.     //! ping range estimation
  2420.     proto native int GetPingMax();
  2421.     //! ping range estimation
  2422.     proto native int GetPingAvg();
  2423.  
  2424.     //! bandwidth estimation (in kbps)
  2425.     proto native int GetBandwidthMin();
  2426.     //! bandwidth estimation (in kbps)
  2427.     proto native int GetBandwidthMax();
  2428.     //! bandwidth estimation (in kbps)
  2429.     proto native int GetBandwidthAvg();
  2430.  
  2431.     //! current desync level (max. error of unsent messages)
  2432.     proto native int GetDesynch();
  2433.    
  2434.     //! nick (short) name of player
  2435.     proto native owned string GetName();
  2436.     //! full name of player
  2437.     proto native owned string GetFullName();
  2438.     //! unique id of player (derived from CD key, may include verified userId after a double colon)
  2439.     proto native owned string GetId();
  2440.  
  2441.     private void ~PlayerIdentity()
  2442.     {
  2443.     }
  2444. };
  2445.  
  2446. //-----------------------------------------------------------------------------
  2447. const int PROGRESS_START = 0;
  2448. const int PROGRESS_FINISH = 1;
  2449. const int PROGRESS_PROGRESS = 2;
  2450. const int PROGRESS_UPDATE = 3;
  2451.  
  2452. //-----------------------------------------------------------------------------
  2453. typedef int HiveEventPriority;
  2454. typedef int ChatChannel;
  2455.  
  2456. //-----------------------------------------------------------------------------
  2457. //! state, progress, title
  2458. typedef Param3<int, float, string> ProgressEventParams;
  2459. typedef Param1<string> ScriptLogEventParams;
  2460. typedef Param1<EntityAI> EntityNetworkUpdateEventParams;
  2461. //! channel, from, text, color config class
  2462. typedef Param4<int, string, string, string> ChatMessageEventParams;
  2463. typedef Param1<int> ChatChannelEventParams;
  2464. typedef Param1<int> SQFConsoleEventParams;
  2465. //! type (TitEffectName), show, duration, title  
  2466. typedef Param4<int, int, float, string> TileEffectEventParams;
  2467. //! player, item1, item2, actions
  2468. typedef Param4<Man, EntityAI, EntityAI, array<Action>> InventoryActionsEventParams;
  2469. //! PlayerIdentity, PlayerPos, Top, Bottom, Shoe, Skin
  2470. typedef Param6<PlayerIdentity, vector, int, int, int, int> ClientNewEventParams;
  2471. //! PlayerIdentity
  2472. typedef Param1<PlayerIdentity> ClientRespawnEventParams;
  2473. //! PlayerIdentity, Man
  2474. typedef Param2<PlayerIdentity, Man> ClientReadyEventParams;
  2475. //! PlayerIdentity, Man
  2476. typedef Param3<PlayerIdentity, Man, int> ClientDisconnectedEventParams;
  2477. //! PlayerIdentity, QueueTime, NewChar
  2478. typedef Param3<PlayerIdentity, int, bool> ClientQueuedEventParams;
  2479. //! Width, Height, Windowed
  2480. typedef Param3<int, int, bool> WindowsResizeEventParams;
  2481. //! Enabled
  2482. typedef Param1<bool> VONStateEventParams;
  2483. //! Camera
  2484. typedef Param1<Camera> SetFreeCameraEventParams;
  2485.  
  2486.  
  2487. //-----------------------------------------------------------------------------
  2488. #ifdef DOXYGEN
  2489. // just because of doc
  2490.  
  2491. enum ChatChannel
  2492. {
  2493.     CCNone,
  2494.     CCGlobal,
  2495.     CCVehicle,
  2496.     CCItemTransmitter,
  2497.     CCPublicAddressSystem,
  2498.     CCItemMegaphone,
  2499.     CCDirect,
  2500.     CCCustom1,
  2501.     CCCustom2,
  2502.     CCCustom3,
  2503.     CCCustom4,
  2504.     CCCustom5,
  2505.     CCCustom6,
  2506.     CCCustom7,
  2507.     CCCustom8,
  2508.     CCCustom9,
  2509.     CCCustom10,
  2510.     CCCustomLast = CCCustom10,
  2511.     CCStatus,
  2512.     CCSystem,
  2513.     CCN
  2514. };
  2515.  
  2516. enum EventType
  2517. {
  2518.     //! no params
  2519.     StartupEventTypeID,
  2520.     //! no params
  2521.     WorldCleaupEventTypeID,
  2522.     //! no params
  2523.     MPSessionStartEventTypeID,
  2524.     //! no params
  2525.     MPSessionEndEventTypeID,
  2526.     //! no params
  2527.     MPSessionFailEventTypeID,
  2528.     //! params: \ref ProgressEventParams
  2529.     ProgressEventTypeID,
  2530.     //! no params
  2531.     NetworkManagerClientEventTypeID,
  2532.     //! no params
  2533.     NetworkManagerServerEventTypeID,
  2534.     //! no params
  2535.     DialogQueuedEventTypeID,
  2536.     //! params: \ref EntityNetworkUpdateEventParams
  2537.     EntityNetworkUpdateEventTypeID,
  2538.     //! params: \ref ChatMessageEventParams
  2539.     ChatMessageEventTypeID,
  2540.     //! params: \ref ChatChannelEventParams
  2541.     ChatChannelEventTypeID,
  2542.     //! params: \ref SQFConsoleEventParams
  2543.     SQFConsoleEventTypeID,
  2544.     //! params: \ref TileEffectEventParams
  2545.     TileEffectEventTypeID,
  2546.     //! no params
  2547.     ActionMenuChangedEventTypeID,
  2548.     //! params: \ref InventoryActionsEventParams
  2549.     InventoryActionsEventTypeID,
  2550.     //! params: \ref ClientNewEventParams
  2551.     ClientNewEventTypeID,
  2552.     //! params: \ref ClientRespawnEventParams
  2553.     ClientRespawnEventTypeID,
  2554.     //! params: \ref ClientReadyEventParams
  2555.     ClientReadyEventTypeID,
  2556.     //! params: \ref ClientDisconnectedEventParams
  2557.     ClientDisconnectedEventTypeID,
  2558.     //! params: \ref ClientQueuedEventParams
  2559.     ClientQueuedEventTypeID,
  2560.     //! params: \ref ScriptLogEventParams
  2561.     ScriptLogEventTypeID,
  2562.     //! params: \ref VONStateEventParams
  2563.     VONStateEventTypeID,
  2564.     //! params: \ref SetFreeCameraEventParams
  2565.     SetFreeCameraEventTypeID
  2566.    
  2567.     //possible in engine events not accessable from script
  2568.     //ReloadShadersEvent
  2569.     //LoadWorldProgressEvent
  2570.    
  2571.     //SignStatusEvent
  2572.     //SetPausedEvent
  2573.     //TerminationEvent
  2574.     //UserSettingsChangedEvent
  2575.     //StorageChangedEvent
  2576.     //BeforeResetEvent
  2577.     //AfterRenderEvent
  2578.     //AfterResetEvent
  2579.     //CrashLogEvent
  2580.     //ConsoleEvent
  2581. };
  2582.  
  2583. enum TitEffectName
  2584. {
  2585.     TitPlain,
  2586.     TitPlainDown,
  2587.     TitBlack,
  2588.     TitBlackFaded,
  2589.     TitBlackOut,
  2590.     TitBlackIn,
  2591.     TitWhiteOut,
  2592.     TitWhiteIn,
  2593.     TitPlainNoFade
  2594. };
  2595. #endif
  2596. /**
  2597.  *  Game Class provide most "world" or global engine API functions.
  2598.  */
  2599. class CGame
  2600. {
  2601.     // -enUserActions
  2602.     bool m_ParamUserActions;
  2603.     // -enDebugActions
  2604.     bool m_DebugActions;
  2605.     // -enNewPlayer
  2606.     bool m_ParamNewPlayer;
  2607.     // -enNewInventory
  2608.     bool m_ParamNewInventory;
  2609.     // -enPlayerDiag
  2610.     bool m_ParamPlayerDiag;
  2611.     // -enNoLogs
  2612.     bool m_ParamNoLogs
  2613.     // -enMainMenu2
  2614.     bool m_MainMenu2;
  2615.    
  2616.     ScriptModule GameScript;
  2617.  
  2618.     private autoptr array<Param> m_ParamCache;
  2619.    
  2620.     void CGame()
  2621.     {
  2622.         m_ParamCache = new array<Param>;
  2623.         m_ParamCache.Insert(NULL);
  2624.     }
  2625.    
  2626.     proto native WorkspaceWidget GetWorkspace();
  2627.    
  2628.     //!
  2629.     /**
  2630.   \brief Called when some system event occur.
  2631.   @param eventTypeId event type.
  2632.     @param params Param object, cast to specific param class to get parameters for particular event.
  2633.     */
  2634.     void OnEvent(EventType eventTypeId, Param params)
  2635.     {
  2636.     }
  2637.  
  2638.     /**
  2639.     \brief Called after creating of CGame instance
  2640.     */
  2641.     void OnAfterCreate()
  2642.     {
  2643.     }
  2644.    
  2645.     /**
  2646.   \brief Called on World update
  2647.   @param doSim False when simulation is paused, True otherwise
  2648.     @param timeslice time elapsed from last call
  2649.     */
  2650.     void OnUpdate(bool doSim, float timeslice)
  2651.     {
  2652.     }
  2653.  
  2654.     /**
  2655.   \brief Called when key is pressed
  2656.   @param key direct input key code (DIK)
  2657.     */
  2658.     void OnKeyPress(int key)
  2659.     {
  2660.     }
  2661.  
  2662.     /**
  2663.   \brief Called when key is released
  2664.   @param key direct input key code (DIK)
  2665.     */
  2666.     void OnKeyRelease(int key)
  2667.     {
  2668.     }
  2669.  
  2670.     /**
  2671.   \brief Called when mouse button is pressed
  2672.   @param button - number of button \ref Mouse
  2673.     */
  2674.     void OnMouseButtonPress(int button)
  2675.     {
  2676.     }
  2677.    
  2678.     /**
  2679.   \brief Called when mouse button is released
  2680.   @param button - number of button \ref Mouse
  2681.     */
  2682.     void OnMouseButtonRelease(int button)
  2683.     {
  2684.     }
  2685.    
  2686.     /**
  2687.   \brief create custom main menu part (submenu)
  2688.     */
  2689.     UIScriptedMenu          CreateScriptedMenu( int id ) { }
  2690.  
  2691.     /**
  2692.   \brief create custom window part
  2693.     */
  2694.     UIScriptedWindow            CreateScriptedWindow( int id ) { } 
  2695.    
  2696.     /**
  2697.   \brief Called after remote procedure call is recieved for this object
  2698.         @param target object on which remote procedure is called, when NULL, RPC is evaluated by CGame as global
  2699.         @param rpc_type user defined identification of RPC
  2700.         @param ctx read context for params
  2701.     */
  2702.     void    OnRPC(Object target, int rpc_type, ParamsReadContext ctx)
  2703.     {
  2704.     }
  2705.    
  2706.     /**
  2707.   \brief Sets exit code and quits in the right moment
  2708.     */
  2709.     proto native void       RequestExit( int code );
  2710.  
  2711.     /**
  2712.   \brief Sets exit code and restart in the right moment
  2713.     */
  2714.     proto native void       RequestRestart(int code);
  2715.  
  2716.     /**
  2717.   \brief Connects to last success network session
  2718.     \return true on success, false if there is no previous session
  2719.     */
  2720.     proto native int        ConnectLastSession( UIScriptedMenu parent , int selectedCharacter = -1 );
  2721.     /**
  2722.   \brief Disconnects from current multiplayer session
  2723.     */
  2724.     proto native void       DisconnectSession();
  2725.  
  2726.     // profile functions
  2727.     /**
  2728.   \brief Gets array of strings from profile variable
  2729.     @param name of the variable
  2730.     @param values output values
  2731.     \n usage:
  2732.     @code
  2733.     autoptr TStringArray lastInventoryArray = new TStringArray;
  2734.     GetGame().GetProfileStringList("lastInventory", lastInventoryArray);
  2735.     @endcode
  2736.     */
  2737.     proto native void       GetProfileStringList(string name, out TStringArray values);
  2738.  
  2739.     /**
  2740.   \brief Gets string from profile variable
  2741.     @param name of the variable
  2742.     @param value output value
  2743.     \return true when successful
  2744.     */
  2745.     proto bool                  GetProfileString(string name, out string value);
  2746.  
  2747.     /**
  2748.   \brief Sets array of strings to profile variable
  2749.     @param name of the variable
  2750.     @param values to set
  2751.     */
  2752.     proto native void       SetProfileStringList(string name, TStringArray values);
  2753.  
  2754.     /**
  2755.   \brief Sets string to profile variable
  2756.     @param name of the variable
  2757.     @param value to set
  2758.     */
  2759.     proto native void       SetProfileString(string name, string value);
  2760.  
  2761.     /**
  2762.   \brief Saves profile on disk.
  2763.     */
  2764.     proto native void       SaveProfile();
  2765.  
  2766.     /**
  2767.   \brief Gets current player name
  2768.     @param name output value
  2769.     */
  2770.     proto void                  GetPlayerName(out string name);
  2771.  
  2772.     /**
  2773.   \brief Sets current player name
  2774.     @param name
  2775.     */
  2776.     proto native void       SetPlayerName(string name);
  2777.    
  2778.     /**
  2779.     \brief Assign player entity to client (in multiplayer)
  2780.     \note Works only on server
  2781.     @param name
  2782.     */ 
  2783.     proto native Entity CreateEntity(PlayerIdentity identity, string name, vector pos, float radius, string spec);
  2784.    
  2785.     /**
  2786.     \brief Set camera for player
  2787.     \note Works only on server
  2788.     @param Player object
  2789.     */ 
  2790.     proto native void       SelectPlayer(PlayerIdentity identity, Object player);
  2791.    
  2792.     /**
  2793.     \brief Sets client as disconnected after log-out timeout
  2794.     \note Works only on server
  2795.     @param name
  2796.     */ 
  2797.     proto native void       SetPlayerDisconnected(PlayerIdentity identity);
  2798.    
  2799.     /**
  2800.     \brief Sets client to leave waiting screen after log-in time
  2801.     \note Works only on client
  2802.     */
  2803.     proto native void       SetPlayerWaited();
  2804.    
  2805.     /**
  2806.     \brief Returns current daytime on server
  2807.     */
  2808.     proto native float      GetDayTime();
  2809.    
  2810.     // config functions
  2811.     /**
  2812.     \brief Get string value from config on path.
  2813.         @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2814.         @param value output
  2815.         \return true on success
  2816.     */
  2817.     proto bool                  ConfigGetText(string path, out string value);
  2818.    
  2819.     /**
  2820.     \brief Get string value from config on path.
  2821.         @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2822.         \return value output string
  2823.     */
  2824.     string ConfigGetTextOut(string path)
  2825.     {
  2826.         string ret_s;
  2827.         ConfigGetText(path, ret_s);
  2828.         return ret_s;
  2829.     }
  2830.    
  2831.     /**
  2832.   \brief Get float value from config on path.
  2833.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2834.     \return value
  2835.     */
  2836.     proto native float  ConfigGetFloat(string path);
  2837.    
  2838.  
  2839.     /**
  2840.   \brief Get vector value from config on path.
  2841.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2842.     \return value
  2843.     */
  2844.     proto native vector ConfigGetVector(string path);
  2845.  
  2846.     /**
  2847.   \brief Get int value from config on path.
  2848.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2849.     \return value
  2850.     */
  2851.     proto native int        ConfigGetInt(string path);
  2852.  
  2853.     /**
  2854.   \brief Returns type of config value
  2855.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2856.     \return one of constants CT_INT, CT_FLOAT, CT_STRING, CT_ARRAY, CT_CLASS, CT_OTHER
  2857.     */
  2858.     proto native int        ConfigGetType(string path);
  2859.  
  2860.     /**
  2861.   \brief Get array of strings from config on path.
  2862.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2863.     @param value output
  2864.     \n usage :
  2865.     @code
  2866.     autoptr TStringArray characterAnimations = new TStringArray;
  2867.     GetGate().ConfigGetTextArray("CfgMovesMaleSdr2 States menu_idleUnarmed0 variantsPlayer", characterAnimations);
  2868.     @endcode
  2869.     */
  2870.     proto native void       ConfigGetTextArray(string path, out TStringArray values);
  2871.  
  2872.     /**
  2873.   \brief Get array of floats from config on path.
  2874.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2875.     @param value output
  2876.     */
  2877.     proto native void       ConfigGetFloatArray(string path, out TFloatArray values);
  2878.    
  2879.     /**
  2880.   \brief Get array of integers from config on path.
  2881.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2882.     @param value output
  2883.     */
  2884.     proto native void       ConfigGetIntArray(string path, out TIntArray values);
  2885.  
  2886.     /**
  2887.   \brief Get name of subclass in config class on path.
  2888.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2889.     @param index of subclass in class
  2890.     @param name output
  2891.     \return true on success, false if path or child is not found
  2892.     */
  2893.     proto bool                  ConfigGetChildName(string path, int index, out string name);
  2894.  
  2895.     /**
  2896.   \brief Get name of base class of config class on path.
  2897.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2898.     @param name output
  2899.     \return true on success, false if path or base is not exists
  2900.     */
  2901.     proto bool                  ConfigGetBaseName(string path, out string base_name);
  2902.  
  2903.     /**
  2904.   \brief Get count of subclasses in config class on path.
  2905.     @param path of value, classes are delimited by empty space. You can specify config file by using "configFile" or "missionConfigFile" as a first class name.
  2906.     @param index of parameter in class
  2907.     @param name output
  2908.     \return true on success, false if path or child is not found
  2909.     */
  2910.     proto native int        ConfigGetChildrenCount(string path);
  2911.     proto native bool       ConfigIsExisting(string path);
  2912.  
  2913.     proto native void       ConfigGetFullPath(string path, out TStringArray full_path);
  2914.     proto native void       ConfigGetObjectFullPath(Object obj, out TStringArray full_path);
  2915.  
  2916. /**
  2917. \brief Converts array of strings into single string.
  2918.     \param Array of strings like {"All", "AllVehicles", "Land"}
  2919.     \return Converts given array into something lile "All AllVehicles Land".
  2920.     @code
  2921.         ???
  2922.     @endcode
  2923. */
  2924.     string                  ConfigPathToString(TStringArray array_path)
  2925.     {
  2926.         string return_path = "";
  2927.         int count = array_path.Count();
  2928.        
  2929.         for (int i = 0; i < count; i++)
  2930.         {
  2931.             return_path += array_path.Get(i);
  2932.            
  2933.             if ( i < count - 1 )
  2934.             {
  2935.                 return_path += " ";
  2936.             }
  2937.         }
  2938.        
  2939.         return return_path;
  2940.     }
  2941.  
  2942.     /**
  2943.   \brief Get command line parameter value.
  2944.     @param name of parameter
  2945.     @param value output
  2946.     \return true when parameter exists, false otherwise
  2947.     \n usage :
  2948.     @code
  2949.     // you run e.g.: DayZInt.exe -scriptDebug=true
  2950.     string value;
  2951.     if (GetGame().CommandlineGetParam("scriptDebug", value) && value == "true")
  2952.     {
  2953.         Print("Script debugging on!");
  2954.     }
  2955.     @endcode
  2956.     */
  2957.     proto bool                  CommandlineGetParam(string name, out string value);
  2958.    
  2959.     proto native void CopyToClipboard(string text);
  2960.     proto void              CopyFromClipboard(out string text);
  2961.  
  2962.     proto native void   BeginOptionsVideo();
  2963.     proto native void   EndOptionsVideo();
  2964.    
  2965.     // entity functions
  2966.     /**
  2967.     \brief Preload objects with certain type in certain distance from camera.
  2968.     @param type of objects which should be preloaded
  2969.     @param distance from camera in which objects should be preloaded
  2970.     \return true on success
  2971.     */
  2972.     proto native bool       PreloadObject( string type, float distance );
  2973.  
  2974.     /**
  2975.     \brief Creates object of certain type
  2976.     @param type of objects to create
  2977.     @param pos position where to create object
  2978.     @param create_local if True, object is not spawned on clients only on server
  2979.     @param init_ai if creating object is LightAI class, by this param is initialised AI or not
  2980.     \return new Object
  2981.     */
  2982.     proto native Object CreateObject( string type, vector pos, bool create_local = false, bool init_ai = false );
  2983.     proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped);
  2984.     proto native void   ObjectDelete( Object obj );
  2985.     proto native int    ObjectRelease( Object obj );
  2986.     proto void          ObjectGetType( Object obj, out string type );
  2987.     proto void          ObjectGetDisplayName( Object obj, out string name );
  2988.     proto native void   ObjectSetAnimationPhase(Entity obj, string animation, float phase);
  2989.     proto native float  ObjectGetAnimationPhase(Entity obj, string animation);
  2990.     proto native vector ObjectGetSelectionPosition(Object obj, string name);
  2991.     proto native vector ObjectModelToWorld(Object obj, vector modelPos);
  2992.     proto native vector ObjectWorldToModel(Object obj, vector worldPos);
  2993.     //! returns true if player can access item's cargo/attachments (check only distance)
  2994.     proto native bool       IsObjectAccesible(EntityAI item, Man player);
  2995.     //! returns true if player can access item's cargo/attachments (check only inventory conditions)
  2996.     proto native bool       IsInventoryTreeLocked(EntityAI item, EntityAI player); 
  2997.  
  2998.     // input
  2999.     proto native Input  GetInput();
  3000.    
  3001.     // inventory stuff, MP safe
  3002.     /*proto native void     InventorySetItemShortcut(Man owner, InventoryItem item, int index);
  3003.     proto native void       InventoryDropItem(Man owner, InventoryItem item);
  3004.     proto native void       InventoryMoveItem(EntityAI target, int index, InventoryItem item);
  3005.     proto native int        InventoryCanMoveItem(EntityAI target, int index, InventoryItem item);
  3006.     proto native void       InventoryTakeItemToHands(Man man, InventoryItem item);
  3007.     proto native int        InventorySwapItems(Man owner, InventoryItem item1, InventoryItem item2);
  3008.     proto native int        InventoryCanSwapItems(InventoryItem item1, InventoryItem item2);*/
  3009.  
  3010.     // support
  3011.     //! Executes SQF expression, if there is an error, is printed into the script console
  3012.     proto native void       ExecuteSQF(string expression);
  3013.     //! Executes Enforce Script expression, if there is an error, is printed into the script console
  3014.     proto native bool   ExecuteEnforceScript(string expression, string mainFnName);
  3015.  
  3016.     proto native bool   ScriptTest();
  3017.     //! Get list of all debug modes
  3018.     proto native void       GetDiagModeNames(out TStringArray diag_names);
  3019.     //! Set specific debug mode
  3020.     proto native void       SetDiagModeEnable(int diag_mode, bool enabled);
  3021.     //! Gets state of specific debug mode
  3022.     proto native bool       GetDiagModeEnable(int diag_mode);
  3023.  
  3024.     //! Get list of all debug draw modes
  3025.     proto native void       GetDiagDrawModeNames(out TStringArray diag_names);
  3026.     //! Set debug draw mode
  3027.     proto native void       SetDiagDrawMode(int diag_draw_mode);
  3028.     //! Gets current debug draw mode
  3029.     proto native int        GetDiagDrawMode();
  3030.    
  3031.     /**
  3032.     \brief Returns average FPS of last 16 frames
  3033.     @return fps in milliseconds
  3034.     */
  3035.     proto native float      GetFps();
  3036.    
  3037.     /**
  3038.     \brief Returns current time from start of the game
  3039.     @return time in milliseconds
  3040.     */
  3041.     proto native float      GetTickTime();
  3042.  
  3043.     //! return inventory slot id for given inventory slot name
  3044.     proto native int        GetInventorySlot(string slot_name);
  3045.     proto void                  GetInventoryItemSize(InventoryItem item, out int width, out int height);
  3046.     /**
  3047.   \brief Returns list of all objects in radius "radius" around position "pos"
  3048.     @param pos
  3049.     @param radius
  3050.     @param inPlayerSight if inPlayerSight is not NULL, function raycast every object if is visible by player "inPlayerSight" (heavy performance load!)
  3051.     @param objects output array
  3052.     */
  3053.     proto native void       GetObjectsAtPosition(vector pos, float radius, Man inPlayerSight, out array<Object> objects, out array<Cargo> proxyCargos);
  3054.     proto native World  GetWorld();
  3055.     proto void                  GetWorldName( out string world_name );
  3056.     proto native vector SnapToGround( vector pos );
  3057.     proto void                  FormatString( string format, string params[], out string output);
  3058.     proto void                  HtmlToPlain( string text );
  3059.     proto void                  GetVersion( out string version );
  3060.     proto native UIManager  GetUIManager();
  3061.     proto native Man        GetPlayer();
  3062.     proto native void       GetPlayers( out array<Man> players );
  3063.    
  3064.     // actions & activities
  3065.     EntityScriptedActivity CreateActivity(Object target, Man man, int activity_type)
  3066.     {
  3067.         Print(activity_type);
  3068.         return NULL;
  3069.     }
  3070.  
  3071.     proto native void       PerformAction(Man player, Action action);
  3072.     proto native void       GetActionMenuActions(out TActionRefArray actions);
  3073.     //! Updates action menu items, call UpdateCursorTarget prior this to update aiming target
  3074.     proto native void       UpdateActionMenuActions();
  3075.    
  3076.     //! Updates target of player aiming
  3077.     proto native void       UpdateCursorTarget();
  3078.     //! Returns world position where player aims, call UpdateCursorTarget to refresh this data
  3079.     proto native vector     GetCursorPos();
  3080.     //! Returns object on which player aims, call UpdateCursorTarget to refresh this data
  3081.     proto native Object     GetCursorObject();
  3082.     //! Returns name of component/selection on which player aims, call UpdateCursorTarget to refresh this data. The object must have View Geometry or Fire Geometry. View Geometry has priority.
  3083.     proto void              GetCursorObjectComponentName( out string component_name );
  3084.     //! Returns the direction where the mouse points, from the camera view
  3085.     proto native vector     GetPointerDirection();
  3086.     //! Transforms position in world to position in screen in pixels as x, y component of vector, z parameter represents distance between camera and world_pos
  3087.     proto native vector     GetScreenPos(vector world_pos);
  3088.     //! Transforms position in world to position in screen in percentage (0.0 - 1.0) as x, y component of vector, z parameter represents distance between camera and world_pos
  3089.     proto native vector     GetScreenPosRelative(vector world_pos);
  3090.    
  3091.     //! Returns world position where player aims (works only on server)
  3092.     proto native vector     GetPlayerCursorPos(Man man);
  3093.     //! Returns object on which player aims,(works only on server)
  3094.     proto native Object     GetPlayerCursorObject(Man man);
  3095.     //! Returns name of component/selection on which player aims (works only on server)
  3096.     proto void              GetPlayerCursorObjectComponentName( Man man, out string component_name );
  3097.     //! Returns true if player is aiming on component with given name(works only on server)
  3098.     proto native bool       GetPlayerCursorObjectComponentNameQuery( Man man, string component_name );
  3099.  
  3100.     //! Returns position of crosshair in pixels
  3101.     proto void              GetCrosshairScreenPos( out float x, out float y );
  3102.    
  3103.     //! Return singleton of MenuData class - at main menu contains characters played with current profile.
  3104.     proto native MenuData   GetMenuData();
  3105.     /**
  3106.   \brief Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on server, RPC is executed on all clients
  3107.     @param target object on which remote procedure is called, when NULL, RPC is evaluated by CGame as global
  3108.     @param rpc_type user defined identification of RPC
  3109.     @param params custom params array
  3110.     @param recipient specified client to send RPC to. If NULL, RPC will be send to all clients (specifying recipient increase security and decrease network traffic)
  3111.     @code
  3112.     const int RPC_LOW_BLOOD_PRESSURE_EFFECT = 0;
  3113.     ...
  3114.     // on server side, after blood pressure of player is low...
  3115.     autoptr Param1<float> p = new Param1<float>(m_blood_pressure);
  3116.     autoptr array<param> params = new array<param>;
  3117.     params.Insert(p);
  3118.     GetGame().RPC(player, RPC_LOW_BLOOD_PRESSURE_EFFECT, params);
  3119.     // or shortcut
  3120.     GetGame().RPCSingleParam(player, RPC_LOW_BLOOD_PRESSURE_EFFECT, p);
  3121.     ...
  3122.     // on client
  3123.     class PlayerBase
  3124.     {
  3125.         // override OnRPC function
  3126.         void OnRPC(int rpc_type, ParamsReadContext ctx)
  3127.         {
  3128.             // dont forget to propagate this call trough class hierarchy!
  3129.             super.OnRPC(rpc_type, ctx);
  3130.  
  3131.             switch(rpc_type)
  3132.             {
  3133.                 case RPC_LOW_BLOOD_PRESSURE_EFFECT:
  3134.                     autoptr Param1<float> p = Param1<float>(0);
  3135.                     if (ctx.Read(p))
  3136.                     {
  3137.                         float blood_pressure = p.param1;
  3138.                         float effect_intensity = 1.0 - blood_pressure;
  3139.                         ShowFancyScreenEffect(effect_intensity);
  3140.                     }
  3141.                 break;
  3142.             }
  3143.         }
  3144.     }
  3145.     @endcode
  3146.     */
  3147.     proto native void       RPC(Object target, int rpc_type, notnull array<Param> params, Man recipient = NULL);
  3148.     //! see CGame.RPC
  3149.     void                    RPCSingleParam(Object target, int rpc_type, Param param, Man recipient = NULL)
  3150.     {
  3151.         m_ParamCache.Set(0, param);
  3152.         RPC(target, rpc_type, m_ParamCache, recipient);
  3153.     }
  3154.  
  3155.     //! Use for profiling code from start to stop, they must match have same name, look wiki pages for more info: https://confluence.bistudio.com/display/EN/Profiler
  3156.     proto native void       ProfilerStart(string name);
  3157.     //! Use for profiling code from start to stop, they must match have same name, look wiki pages for more info: https://confluence.bistudio.com/display/EN/Profiler
  3158.     proto native void       ProfilerStop(string name);
  3159.  
  3160.     /**
  3161.     \brief Returns list of names of recipes for certain player and items combination.
  3162.     @param player
  3163.     @param item1
  3164.     @param item2
  3165.     @param recipe_names output, results are inserted here
  3166.     */
  3167.     proto native void       RecipesGet(Man player, EntityAI item1, EntityAI item2, out TStringArray recipe_names);
  3168.     /**
  3169.     \brief Returns true, if items has any recipes for certain player
  3170.     @param player
  3171.     @param item1
  3172.     @param item2
  3173.     */
  3174.     proto native bool       RecipesHas(Man player, EntityAI item1, EntityAI item2);
  3175.     /**
  3176.     \brief Process recipe.
  3177.     @param recipe_name name of recipe (you can get recipe names using RecipesGet function)
  3178.     @param player
  3179.     @param item1
  3180.     @param item2
  3181.     */
  3182.     proto native void       RecipeProcess(string recipe_name, Man player, EntityAI item1, EntityAI item2);
  3183.     /**
  3184.     \brief Generate description for recipe for certain player and items combination.
  3185.     @param recipe_name name of recipe (you can get recipe names using RecipesGet function)
  3186.     @param player
  3187.     @param item1
  3188.     @param item2
  3189.     @param text final description is outputted here
  3190.     */
  3191.     proto void              RecipeGetDescription(string recipe_name, Man player, EntityAI item1, EntityAI item2, out string text);
  3192. /**
  3193.  \brief Prints text into game chat.
  3194.     \param text to print
  3195.     \param colorClass ??
  3196.     \n usage :
  3197.     @code
  3198.         GetGame().Chat("Item splitted", "colorAction");
  3199.     @endcode
  3200. */
  3201.     proto native void       Chat(string text, string colorClass);
  3202.     proto native void       ChatMP(Man recipient, string text, string colorClass);
  3203.     proto native void       ChatPlayer(ChatChannel channel, string text);
  3204.     //! Returns current chat channel.
  3205.     proto native ChatChannel ChatGetChannel();
  3206.  
  3207.     // sound
  3208.     /**
  3209.  \brief Unit or object will say given sound in 3D Space. This allows broadcasting of positional music or sound from a source, without having to script a fade sound or music command. Sound is defined in CfgSound of the Description.ext.
  3210.  \param unit: Object - position of sound is taken from position of this object
  3211.  \param sound: String - classname. Defined in Description.ext
  3212.  \param distance: float - how far is dound hearable
  3213.  */
  3214.     proto native void       Say3D(Object source, string sound_name, float distance);
  3215.  
  3216.     // mission
  3217.     proto native Mission    GetMission();
  3218.     proto native void       SetMission(Mission mission);
  3219.    
  3220.     //! Starts mission (equivalent for SQF playMission). You MUST use double slash \\
  3221.     proto native void       PlayMission(string path);
  3222.    
  3223.     //! Create only enforce script mission, used for mission script reloading
  3224.     proto protected native void     CreateMission(string path);
  3225.     proto native void       RestartMission();
  3226.     proto native void       AbortMission();
  3227.     proto native void       RespawnPlayer();
  3228.     proto native bool       CanRespawnPlayer();
  3229.     proto native int        RetryMission();
  3230.  
  3231.     proto native bool       IsMultiplayer();
  3232.     proto native bool       IsClient();
  3233.     proto native bool       IsServer();
  3234.    
  3235.     // Interny build
  3236.    
  3237.     //proto native bool     IsDebug();
  3238.    
  3239.     bool IsDebug()
  3240.     {
  3241.         return true;
  3242.     }
  3243.    
  3244.     bool IsParamUserActions()
  3245.     {
  3246.         return m_ParamUserActions;
  3247.     }
  3248.    
  3249.     bool IsNewPlayer()
  3250.     {
  3251.         return m_ParamNewPlayer;
  3252.     }
  3253.  
  3254.     bool IsNewInventory()
  3255.     {
  3256.         return m_ParamNewInventory;
  3257.     }
  3258.    
  3259.     bool IsNoLogs()
  3260.     {
  3261.         return m_ParamNoLogs;
  3262.     }
  3263.    
  3264.     bool IsDebugActions()
  3265.     {
  3266.         return m_DebugActions;
  3267.     }
  3268.    
  3269.     bool IsNewUI()
  3270.     {
  3271.         return true;
  3272.     }
  3273.    
  3274.     bool IsPlayerDiag()
  3275.     {
  3276.         return m_ParamPlayerDiag;
  3277.     }
  3278.  
  3279.     bool IsMainMenu2()
  3280.     {
  3281.         return m_MainMenu2;
  3282.     }
  3283.  
  3284.     proto native void       GetPlayerIndentities( out array<PlayerIdentity> identities );
  3285.    
  3286.     proto native float      SurfaceY(float x, float z);
  3287.     proto native float      SurfaceRoadY(float x, float z);
  3288.     proto void              SurfaceGetType(float x, float z, out string type);
  3289.     proto native vector     SurfaceGetNormal(float x, float z);
  3290.     proto native float      SurfaceGetSeaLevel();
  3291.     proto native bool       SurfaceIsSea(float x, float z);
  3292.     proto native bool       SurfaceIsPond(float x, float z);
  3293.    
  3294.     proto native void       UpdatePathgraphRegion(vector regionMin, vector regionMax);
  3295.    
  3296.     void                    UpdatePathgraphRegionByObject(Object object)
  3297.     {
  3298.         vector pos = object.GetPosition();
  3299.         vector min_max[2];
  3300.         float radius = object.ClippingInfo ( min_max );
  3301.         vector min = Vector ( pos[0] - radius, pos[1], pos[2] - radius );
  3302.         vector max = Vector ( pos[0] + radius, pos[1], pos[2] + radius );
  3303.         UpdatePathgraphRegion( min, max );
  3304.     }
  3305.    
  3306.     /**
  3307.     \brief Finds all objects that are in choosen oriented bounding box (OBB)
  3308.         \param center \p vector, center of OBB
  3309.         \param orientation \p vector, direction (front vector), used for calculation of OBB rotation
  3310.         \param edgeLength \p vector, sizes of whole box
  3311.         \param excludeObjects \p array<Object>, objects that should be excluded from collision check
  3312.         \param collidedObjects \p array<Object>, out parameter, objects that collided with OBB
  3313.         \returns \p bool, \p true if at least one object collided with OBB, \p false otherwise
  3314.         \note Object that doesn't have collision geometry will be ignored
  3315.        
  3316.         @code
  3317.             vector pos = GetPosition();
  3318.             vector orientation = GetOrientation();
  3319.             vector size = "10 4 8";
  3320.             autoptr array<Object> excluded_objects = new array<Object>;
  3321.             excluded_objects.Insert(this);
  3322.             autoptr array<Object> nearby_objects = new array<Object>;
  3323.            
  3324.             if(GetGame().IsBoxColliding( pos, orientation, size, excluded_objects, nearby_objects))
  3325.             {
  3326.                 for (local int i = 0, c = nearby_objects.Count(); i < c; ++i)
  3327.                 {
  3328.                     PrintString("object " + i.ToString());
  3329.                 }
  3330.             }
  3331.         @endcode
  3332.     */
  3333.     proto native bool       IsBoxColliding(vector center, vector orientation, vector edgeLength, array<Object> excludeObjects, array<Object> collidedObjects = NULL);
  3334.    
  3335.     /**
  3336.     \brief Raycasts world by given parameters
  3337.     \param begPos \p vector
  3338.     \param endPos \p vector
  3339.     \param contactPos \p vector out, world position of first contact
  3340.     \param contactDir \p vector out, direction of first contact (available only when object is hitted)
  3341.     \param contactComponent \p int out, object component index (available only when object is hitted)
  3342.     \param results \p set<Object> out, set of objects hitted by raycast. Can be NULL if not needed
  3343.     \param with \p Object
  3344.     \param ignore \p Object
  3345.     \param sorted \p bool
  3346.     \param ground_only \bool raycasts only ground (ignores all objects)
  3347.     \param iType \p int, type of intersection, possible values \ref ObjIntersect
  3348.     \param radius \p float
  3349.  
  3350.     \returns \p bool return true if raycast hits ground or object
  3351.     @code
  3352.     // raycast test
  3353.     if (player)
  3354.     {
  3355.         vector from = player.GetPosition();
  3356.         vector to = from + (player.GetDirection() * 100);
  3357.         vector contactPos;
  3358.         vector contactDir;
  3359.         int contactComponent;
  3360.  
  3361.         if ( GetGame().Raycast(from, to, contactPos, contactDir, contactComponent) )
  3362.         {
  3363.             Print(contactPos);
  3364.             Print(contactDir);
  3365.             Print(contactComponent);
  3366.         }
  3367.     }
  3368.     @endcode
  3369.     */
  3370.     proto bool              Raycast(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, out set<Object> results = NULL, Object with = NULL, Object ignore = NULL,  bool sorted = false,  bool ground_only = false,  int iType = ObjIntersectView, float radius = 0.0);
  3371.  
  3372. //-----------------------------------------------------------------------------
  3373. // weather
  3374. //-----------------------------------------------------------------------------
  3375.  
  3376.     //! Returns actual sky overcast in range <0, 1> where 0 means no cloud in the sky at all.
  3377.     proto native float  GetOvercast();
  3378.     //! Returns overcast value towards the weather is heading.
  3379.     proto native float  GetOvercastForecast();
  3380.     /*!
  3381.         \brief Sets the overcast forecast.
  3382.         \param  overcast     Desired overcast value that should be met in given time.
  3383.         \param  time         A time of the next change (how long it takes in seconds to interpolate to given value).
  3384.         \param  minDuration  A minimal time in seconds the change will last.
  3385.     */
  3386.     proto native void       SetOvercast( float overcast, float time = 0, float minDuration = 0 );
  3387.     //! Returns actual fog density in range <0, 1> where 0 means no fog.
  3388.     proto native float  GetFog();
  3389.     //! Returns fog density towards the weather is heading.
  3390.     proto native float  GetFogForecast();
  3391.     /*!
  3392.         \brief Sets the fog density forecast.
  3393.         \param  fog          Desired fog density that should be met in given time.
  3394.         \param  time         A time of the next change (how long it takes in seconds to get to given value).
  3395.         \param  minDuration  A minimal time in seconds the change will last.
  3396.     */
  3397.   proto native void     SetFog( float fog, float time = 0, float minDuration = 0 );
  3398.     //! Returns actual rain density in range <0, 1> where 0 means no rain.
  3399.   proto native float    GetRain();
  3400.     /*!
  3401.         \brief Returns rain density towards the weather is heading.
  3402.         \note Keep in mind that if the overcast value is small, rain values are not updated.
  3403.               So rain forecast and its next time change can be misleading.
  3404.     */
  3405.     proto native float  GetRainForecast();
  3406.     //! Returns remaining time in seconds until next rain forecast will be computed.
  3407.     proto native float  GetRainNextChange();
  3408.     /*!
  3409.         \brief Sets the rain forecast.
  3410.         \param  rain         Desired rain density that should be met in given time.
  3411.         \param  time         A time of the next change (how long it takes in seconds to get to given value).
  3412.         \param  minDuration  A minimal time in seconds the change will last.
  3413.     */
  3414.     proto native void       SetRain( float density, float time = 0, float minDuration = 0 );
  3415.     //! Sets the time in seconds from now when next rain forecast should be computed.
  3416.     proto native void       SetRainNextChange( float time );
  3417.     /*!
  3418.         \brief Sets the properties of thunderstorms.
  3419.         \param  density  A value in <0, 1> range where 0 means no thunderstorms at all
  3420.                          and 1 means thunderstorm every time it gets cloudy.
  3421.         \param  timeOut  A minimal time in seconds before next thunder can be created.
  3422.     */
  3423.     proto native void       SetStorm( float density, float timeOut );
  3424.     /*!
  3425.         \brief Returns actual wind force in range <0, 1> where 0 means no wind and 1 means strong wind.
  3426.         \note Wind is changing very often in the game, so the returned value may not stand for too long if not forced.
  3427.     */
  3428.     proto native float  GetWindForce();
  3429.     //! Returns wind vector (direction and speed as length of the vector).
  3430.     proto native vector GetWind();
  3431.     /*!
  3432.         \brief Sets the actual wind force in range <0, 1> where 0 means no wind and 1 means strong wind (current maximum wind speed is 35 m/s).
  3433.         \note Wind is changing very often in the game, so the set value may not stand for too long if not forced.
  3434.     */
  3435.     proto native void       SetWindForce( float wind );
  3436.     /*!
  3437.         \brief Sets the wind vector (direction and speed as length of the vector).
  3438.         \param  direction  Wind vector (direction and speed as length of the vector).
  3439.         \param  force      If true forces the wind to keep the given props (turns off updating).
  3440.         \note Wind is changing very often in the game, so the set value may not stand for too long if not forced.
  3441.     */
  3442.     proto native void       SetWind( vector direction, bool force = false );
  3443.     //! Returns actual time from start of a server (how many seconds elapsed from server start).
  3444.     proto native float  GetWeatherTime();
  3445.     //! Returns remaining time in seconds until next weather forecast will be computed.
  3446.     proto native float  GetNextWeatherChange();
  3447.     //! Sets the time in seconds from now when next weather forecast should be computed.
  3448.     proto native void       SetNextWeatherChange( float time );
  3449.     // reset
  3450.     proto native void   ResetWeather();
  3451.     //! Returns actual air temperature in degrees Celsius.
  3452.     proto native float  GetAirTemperature();
  3453.     //! Sets custom camera camera EV.
  3454.     proto native void   SetEVUser(float value);
  3455. //-----------------------------------------------------------------------------
  3456.  
  3457. //-----------------------------------------------------------------------------
  3458. // persitence
  3459. //-----------------------------------------------------------------------------
  3460.  
  3461.     //! Returns EntityAI by its persistent ID parts
  3462.     //! or null if entity with given persistent ID does not exists.
  3463.     /*!
  3464.         This function returns valid data only inside AfterLoad event.
  3465.         Do not use this in anywhere else.
  3466.  
  3467.         Its main purpose is only for keep track on object connections
  3468.         after server restarts, all data related to this function are deleted
  3469.         when server initializtion is done.
  3470.     */
  3471.     proto native EntityAI GetEntityByPersitentID( int low, int high );
  3472.  
  3473. //-----------------------------------------------------------------------------
  3474.  
  3475. #ifdef DOXYGEN
  3476.     // just because of doc
  3477.     enum HiveEventPriority
  3478.     {
  3479.         EVENT_PRIORITY_ERROR,
  3480.         EVENT_PRIORITY_WARNING,
  3481.         EVENT_PRIORITY_INFO
  3482.     };
  3483. #endif
  3484.  
  3485.     //! Add hive event with given data
  3486.     proto native bool AddEvent( HiveEventPriority priority, string msg_text, int timeout = -1 );
  3487.     //! Check if any hive event is pending
  3488.     proto native bool   CheckHiveEvents();
  3489.     //! Return text and seconds of the pending event
  3490.     proto void              GetLastHiveEvent(out string msg_text, out int value, out int priority);
  3491.  
  3492. /**
  3493. \brief Returns is class name inherited from parent class name
  3494.     \param cfg_class_name \p Config Class name ("Animal_CervusElaphus")
  3495.     \param cfg_parent_name \p Parent Config Class name ("DZ_LightAI")
  3496.     \returns \p bool is class name inherited from parent class name
  3497.     @code
  3498.         bool is_kind = GetGame().IsKindOf( "Animal_CervusElaphus", "DZ_LightAI");
  3499.         PrintString(ToString(is_kind));
  3500.        
  3501.         >> 1
  3502.     @endcode
  3503. */
  3504.     bool IsKindOf(string cfg_class_name, string cfg_parent_name)
  3505.     {
  3506.         TStringArray full_path = new TStringArray;
  3507.        
  3508.         ConfigGetFullPath("CfgVehicles " + cfg_class_name, full_path);
  3509.    
  3510.         if (full_path.Count() == 0)
  3511.         {
  3512.             ConfigGetFullPath("CfgAmmo " + cfg_class_name, full_path);
  3513.         }
  3514.        
  3515.         if (full_path.Count() == 0)
  3516.         {
  3517.             ConfigGetFullPath("CfgMagazines " + cfg_class_name, full_path);
  3518.         }
  3519.        
  3520.         if (full_path.Count() == 0)
  3521.         {
  3522.             ConfigGetFullPath("cfgWeapons " + cfg_class_name, full_path);
  3523.         }
  3524.    
  3525.         if (full_path.Count() == 0)
  3526.         {
  3527.             ConfigGetFullPath("CfgNonAIVehicles " + cfg_class_name, full_path);
  3528.         }
  3529.        
  3530.         cfg_parent_name.ToLower();
  3531.         for (int i = 0; i < full_path.Count(); i++)
  3532.         {
  3533.             string tmp = full_path.Get(i);
  3534.             tmp.ToLower();
  3535.             if (tmp == cfg_parent_name)
  3536.             {
  3537.                 delete full_path;
  3538.                 return true;
  3539.             }
  3540.         }
  3541.    
  3542.         delete full_path;
  3543.         return false;
  3544.     }
  3545.  
  3546. /**
  3547. \brief Returns is object inherited from parent class name
  3548.     \param object \p Object
  3549.     \param cfg_parent_name \p Parent Config Class name ("DZ_LightAI")
  3550.     \returns \p bool is object inherited from parent class name
  3551.     @code
  3552.         bool is_kind = GetGame().IsKindOf( my_animal, "DZ_LightAI");
  3553.         PrintString(ToString(is_kind));
  3554.        
  3555.         >> 1
  3556.     @endcode
  3557. */
  3558.     bool ObjectIsKindOf(Object object, string cfg_parent_name)
  3559.     {
  3560.         TStringArray full_path = new TStringArray;
  3561.         ConfigGetObjectFullPath(object, full_path);
  3562.    
  3563.         cfg_parent_name.ToLower();
  3564.    
  3565.         for (int i = 0; i < full_path.Count(); i++)
  3566.         {
  3567.             string tmp = full_path.Get(i);
  3568.             tmp.ToLower();
  3569.             if (tmp == cfg_parent_name)
  3570.             {
  3571.                 delete full_path;
  3572.                 return true;
  3573.             }
  3574.         }
  3575.    
  3576.         delete full_path;
  3577.         return false;
  3578.     }
  3579.    
  3580.     /**
  3581.     Searches given config path (config_path) for the given member (searched_member) and returns its index.
  3582.     \nReturns -1 if not found.
  3583.     \n usage:
  3584.     * @code
  3585.     * int skinning_class_index = g_Game.ConfigFindClassIndex(cfgPath_animal, "Skinning");
  3586.     * @endcode
  3587.     */
  3588.     int ConfigFindClassIndex(string config_path, string searched_member)
  3589.     {
  3590.         int class_count = ConfigGetChildrenCount(config_path);
  3591.         for (int index = 0; index < class_count; index++)
  3592.         {
  3593.             string found_class = "";
  3594.             ConfigGetChildName(config_path, index, found_class);
  3595.             if (found_class == searched_member)
  3596.             {
  3597.                 return index;
  3598.             }
  3599.         }
  3600.         return -1;
  3601.     }
  3602.  
  3603.     //!returns mission time in milliseconds
  3604.     proto int GetTime();
  3605.  
  3606.     /**
  3607.   Returns CallQueue for certain category
  3608.   @param call_category call category, valid values are:
  3609.     \n CALL_CATEGORY_SYSTEM - calls & timers in this queue are processed every time without any restrictions
  3610.     \n CALL_CATEGORY_GUI - calls & timers in this queue are processed when GUI is enabled (even during pase game)
  3611.     \n CALL_CATEGORY_GAMEPLAY - calls & timers in this queue are processed only during mission, when game is not paused
  3612.     \n usage:
  3613.     * @code
  3614.     * GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(this, "Refresh"); // calls "Refresh" function on "this" with no arguments
  3615.     * GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(this, "Show", new Param1<bool>(true)); // calls "Show" function on "this" with one bool argument
  3616.     * GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(this, "SetPos", new Param2<float, float>(0.2, 0.5)); // calls "SetPos" function on "this" with two float arguments
  3617.     * @endcode
  3618.     */
  3619.     CallQueue GetCallQueue(int call_category) {}
  3620.  
  3621.     /**
  3622.   Returns TimerQueue for certain category
  3623.   @param call_category call category, valid values are:
  3624.     \n CALL_CATEGORY_SYSTEM - calls & timers in this queue are processed every time without any restrictions
  3625.     \n CALL_CATEGORY_GUI - calls & timers in this queue are processed when GUI is enabled (even during pase game)
  3626.     \n CALL_CATEGORY_GAMEPLAY - calls & timers in this queue are processed only during mission, when game is not paused
  3627.     */
  3628.     TimerQueue GetTimerQueue(int call_category) {}
  3629.  
  3630.     /**
  3631.   Returns DragQueue. Callbacks are called on mouse move until mouse button is released, then the queue is cleaned.
  3632.     */
  3633.     DragQueue GetDragQueue() {}
  3634.    
  3635.    
  3636.     bool IsInventoryOpen()
  3637.     {
  3638.     }
  3639. };
  3640.  
  3641. // some defs for CGame::ShowDialog()
  3642. /*
  3643. const int DBB_NONE = 0;
  3644. const int DBB_OK = 1;
  3645. const int DBB_YES = 2;
  3646. const int DBB_NO = 3;
  3647. const int DBB_CANCEL = 4;
  3648.  
  3649. const int DBT_OK = 0;       //just OK button
  3650. const int DBT_YESNO = 1;    //Yes and No buttons
  3651. const int DBT_YESNOCANCEL = 2; //Yes, No, Cancel buttons
  3652.  
  3653. const int DMT_NONE = 0;
  3654. const int DMT_INFO = 1;
  3655. const int DMT_WARNING = 2;
  3656. const int DMT_QUESTION = 3;
  3657. const int DMT_EXCLAMATION = 4;
  3658. */
  3659.  
  3660. proto native CGame GetGame();
  3661.  
  3662. class Hud
  3663. {
  3664.     autoptr Timer m_Timer;
  3665.     void Init( Widget hud_panel_widget ) {}
  3666.     void DisplayNotifier( int key, int tendency ) {}
  3667.     void DisplayBadge( int key, bool show ) {}
  3668.     void SetStamina( int value, int range ) {}
  3669.     void DisplayStance( int stance ) {}
  3670.     void DisplayPresence() {}
  3671. };
  3672.  
  3673. //-----------------------------------------------------------------------------
  3674. //! Mission class
  3675. class Mission
  3676. {
  3677.     ScriptModule MissionScript;
  3678.  
  3679.     void OnInit()   {}
  3680.     void OnMissionStart() {}
  3681.     void OnMissionFinish()  {}
  3682.     void OnUpdate(float timeslice) {}
  3683.     void OnKeyPress(int key) {}
  3684.     void OnKeyRelease(int key) {}
  3685.     void OnMouseButtonPress(int button){}
  3686.     void OnMouseButtonRelease(int button){}
  3687.     void OnEvent(EventType eventTypeId, Param params) {}
  3688.     void OnItemUsed(InventoryItem item, Man owner) {}  
  3689.    
  3690.     Hud GetHud()
  3691.     {
  3692.         return NULL;
  3693.     }
  3694.    
  3695.     EntityScriptedActivity  CreateActivity(Object target, Man man, int activity_type)
  3696.     {
  3697.         return NULL;
  3698.     }
  3699.  
  3700.     UIScriptedMenu  CreateScriptedMenu( int id )
  3701.     {
  3702.         return NULL;
  3703.     }
  3704.    
  3705.     UIScriptedWindow    CreateScriptedWindow( int id )
  3706.     {
  3707.         return NULL;
  3708.     }
  3709.    
  3710.     bool IsPaused()
  3711.     {
  3712.         return false;
  3713.     }
  3714.    
  3715.     bool IsGame()
  3716.     {
  3717.         return false;
  3718.     }
  3719.    
  3720.     bool IsServer()
  3721.     {
  3722.         return false;
  3723.     }
  3724.  
  3725.     void Pause() {}
  3726.     void Continue() {}
  3727.    
  3728.     void RefreshCrosshairVisibility() {}
  3729.    
  3730.     bool IsMissionGameplay()
  3731.     {
  3732.         return false;
  3733.     }
  3734. };
  3735.  
  3736. // -------------------------------------------------------------------------
  3737. /*
  3738. const int CamEffectTop = 0;
  3739. const int CamEffectLeft = 1;
  3740. const int CamEffectRight = 2;
  3741. const int CamEffectFront = 3;
  3742. const int CamEffectBack = 4;
  3743. const int CamEffectLeftFront = 5;
  3744. const int CamEffectRightFront = 6;
  3745. const int CamEffectLeftBack = 7;
  3746. const int CamEffectRightBack = 8;
  3747. const int CamEffectLeftTop = 9;
  3748. const int CamEffectRightTop = 10;
  3749. const int CamEffectFrontTop = 11;
  3750. const int CamEffectBackTop = 12;
  3751. const int CamEffectBottom = 13;
  3752. */
  3753. // --------------------------------------------------------------------------
  3754.  
  3755. class MenuData
  3756. {
  3757.     proto native int    GetCharactersCount();
  3758.     proto native int    GetLastPlayedCharacter();
  3759.     proto native Man    CreateCharacterPerson(int index);
  3760.  
  3761.     //proto native void GetCharacterStringList(int characterID, string name, out TStringArray values);
  3762.     //proto bool            GetCharacterString(int characterID,string name, out string value);
  3763. }
  3764.  
  3765. class World
  3766. {
  3767.     //proto private void ~World();
  3768.     //proto private void World();
  3769.  
  3770.     proto native void   GetPlayerList(out array<Man> players);
  3771.    
  3772.     /**
  3773.     \brief Get actual ingame world time
  3774.         \param year
  3775.         \param month in range <1, 12>
  3776.         \param day in range <1, 31>
  3777.         \param hour in range <0, 23>
  3778.         \param minute in range <0, 59>
  3779.         @code
  3780.             int year, month, day, hour, minute;
  3781.             GetGame().GetWorld().GetDate(year, month, day, hour, minute);
  3782.         @endcode
  3783.     */
  3784.     proto void          GetDate(out int year, out int month, out int day, out int hour, out int minute);
  3785.    
  3786.     /**
  3787.     \brief Sets actual ingame world time
  3788.         \param year
  3789.         \param month in range <1, 12>
  3790.         \param day in range <1, 31>
  3791.         \param hour in range <0, 23>
  3792.         \param minute in range <0, 59>
  3793.         @code
  3794.             int year = 2016;
  3795.             int month = 5;
  3796.             int day = 4;
  3797.             int hour = 14;
  3798.             int minute = 57;
  3799.             GetGame().GetWorld().SetDate(year, month, day, hour, minute);
  3800.         @endcode
  3801.     */
  3802.     proto native void   SetDate(int year, int month, int day, int hour, int minute);
  3803.     proto native float  GetLatitude();
  3804.     proto native float  GetLongitude();
  3805.     proto native float  GetMoonIntensity();
  3806.     proto native float  GetSunOrMoon();
  3807.    
  3808.     proto native float  GetEyeAccom();
  3809.     proto native void   SetEyeAccom(float eyeAccom);
  3810.     proto native void   SetCameraEffect( Object obj, string name, int pos, bool infinite );
  3811.     proto native Camera CreateFreeCamera();
  3812.     proto native void   DeleteFreeCamera();
  3813.     proto native void   StartFpsBenchmark(int sectorsCount, float preloadDistance, float fpsLimitRed, float fpsLimitGreen, float fpsLimitBlue, float minX, float minY, float maxX, float maxY);
  3814.     proto native void   StartFpsBenchmarkWithMask(float preloadDistance, float fpsLimitRed, float fpsLimitGreen, float fpsLimitBlue);
  3815.     proto native void   StartFpsBenchmarkViews(string xmlFileName, float preloadDistance);
  3816.    
  3817.     /*!
  3818.     @code
  3819.     Material matColors = GetGame().GetWorld().GetMaterial("postprocess/colors");
  3820.     SetMaterialParam(matColors, "Saturation", 0.8);
  3821.     float color[4];
  3822.     color[0] = 0.5;
  3823.     color[1] = 0.8;
  3824.     color[2] = 0.7;
  3825.     color[3] = 0.6;
  3826.     SetMaterialParam(matColors, "OverlayColor", color);
  3827.     @endcode
  3828.     */
  3829.     proto native Material GetMaterial(string materialName);
  3830.  
  3831.     /*!
  3832.     set new PP effect and its material
  3833.     \param camera                   number of camera
  3834.     \param effectIndex      index of effect
  3835.     \param effectName           name of effect
  3836.     \param matName              name of material
  3837.     */
  3838.     proto native void       SetCameraPostProcessEffect(int cam, int ppEffect, string effectName, string materialName);
  3839.    
  3840.     void SetAperture(float invDiameter)
  3841.     {
  3842.         if (invDiameter <= 0)
  3843.         {
  3844.             SetEyeAccom(-1);
  3845.         }
  3846.         else
  3847.         {
  3848.             float apertureArea = 1.0 / invDiameter;
  3849.             SetEyeAccom(apertureArea * apertureArea);
  3850.         }
  3851.     }
  3852. };
  3853.  
  3854. // -------------------------------------------------------------------------
  3855. /*
  3856. // Option Access Type
  3857. const int AT_UNKNOWN = 0;
  3858. const int AT_OBJECTS_DETAIL = 1;
  3859. const int AT_TEXTURE_DETAIL = 2;
  3860. const int AT_VRAM_VALUE = 3;
  3861. const int AT_HDR_DETAIL = 4;
  3862. const int AT_FSAA_DETAIL = 5;
  3863. const int AT_VSYNC_VALUE = 6;
  3864. const int AT_ANISO_DETAIL = 7;
  3865. const int AT_OPTIONS_FXAA_VALUE = 8;
  3866. const int AT_OPTIONS_PIP_VALUE = 9;
  3867. const int AT_OPTIONS_SW_VALUE = 10;
  3868. const int AT_POSTPROCESS_EFFECTS = 11;
  3869. const int AT_QUALITY_PREFERENCE = 12;
  3870. const int AT_ATOC_DETAIL = 13;
  3871. const int AT_AMBIENT_OCCLUSION = 14;
  3872. const int AT_BLOOM = 15;
  3873. const int AT_ROTATION_BLUR = 16;
  3874. const int AT_SHADING_DETAIL = 17;
  3875. const int AT_SHADOW_DETAIL = 18;
  3876. const int AT_OPTIONS_TERRAIN = 19;
  3877. const int AT_OPTIONS_RESOLUTION = 20;
  3878. const int AT_OPTIONS_SLIDER_FILLRATE = 21;
  3879. const int AT_OPTIONS_REFRESH = 22;
  3880. const int AT_OPTIONS_GAMMA_SLIDER = 23;
  3881. const int AT_OPTIONS_BRIGHT_SLIDER = 24;
  3882. const int AT_OPTIONS_VISIBILITY_SLIDER = 25;
  3883. const int AT_OPTIONS_OBJECT_VISIBILITY_SLIDER = 26;
  3884. const int AT_OPTIONS_TRAFFIC_VISIBILITY_SLIDER = 27;
  3885. const int AT_OPTIONS_SHADOW_VISIBILITY_SLIDER = 28;
  3886. const int AT_OPTIONS_DRAWDISTANCE_SLIDER = 29;
  3887. const int AT_OPTIONS_BLOOD = 30;
  3888. const int AT_OPTIONS_IMPERIALUNITS = 31;
  3889. const int AT_OPTIONS_VEHICLEFREELOOK = 32;
  3890. const int AT_OPTIONS_WBUFFER = 33;
  3891. const int AT_ASPECT_RATIO = 34;
  3892. const int AT_OPTIONS_IGUISIZE = 35;
  3893. const int AT_CONFIG_YREVERSED = 36;
  3894. const int AT_OPTIONS_PERSPECTIVE = 37;
  3895. const int AT_OPTIONS_FIELD_OF_VIEW = 38;
  3896. const int AT_OPTIONS_MUSIC_SLIDER = 39;
  3897. const int AT_OPTIONS_EFFECTS_SLIDER = 40;
  3898. const int AT_OPTIONS_VON_SLIDER = 41;
  3899. const int AT_OPTIONS_MASTER_VOLUME = 42;
  3900. const int AT_OPTIONS_VOICES_SLIDER = 43;
  3901. const int AT_OPTIONS_MIC_SENS_SLIDER = 44;
  3902. const int AT_OPTIONS_SAMPLES_SLIDER = 45;
  3903. const int AT_OPTIONS_HWACC = 46;
  3904. const int AT_OPTIONS_EAX = 47;
  3905. const int AT_OPTIONS_SINGLE_VOICE = 48;
  3906. const int AT_OPTIONS_LANGUAGE = 49;
  3907. const int AT_OPTIONS_SUBTITLES = 50;
  3908. const int AT_OPTIONS_RADIO = 51;
  3909. const int AT_CONFIG_XAXIS = 52;
  3910. const int AT_CONFIG_YAXIS = 53;
  3911. const int AT_CONFIG_FLOATING_ZONE = 54;
  3912. const int AT_CONFIG_MOUSE_FILTERING = 55;
  3913. const int AT_CONFIG_HEAD_BOB = 56;
  3914.  
  3915. // Option Access Control Type
  3916. const int OA_CT_NUMERIC = 0;
  3917. const int OA_CT_SWITCH = 1;
  3918. const int OA_CT_LIST = 2;
  3919.  
  3920. // Option Field of view constants
  3921. const float OPTIONS_FIELD_OF_VIEW_MIN = 0.75242724772f;
  3922. const float OPTIONS_FIELD_OF_VIEW_MAX = 1.30322025726f;
  3923. */
  3924.  
  3925. class OptionsAccess
  3926. {
  3927.     //proto private void ~OptionsAccess();
  3928.     //proto private void OptionsAccess();
  3929.  
  3930.     proto native  int       GetAccessType();
  3931.     proto native  int       GetControlType();
  3932.     proto native  void  Apply();
  3933.     proto native  void  Test();
  3934.     proto native  void  Revert();
  3935.     proto native  int       IsChanged();
  3936.     proto native  int       NeedRestart();
  3937.     proto native  int       SetChangeImmediately();
  3938. };
  3939.  
  3940. // -------------------------------------------------------------------------
  3941. class NumericOptionsAccess extends OptionsAccess
  3942. {
  3943.     proto native  float ReadValue();
  3944.     proto native  void  WriteValue(float value);
  3945.     proto native    float   GetMin();
  3946.     proto native    float   GetMax();
  3947. };
  3948.  
  3949. // -------------------------------------------------------------------------
  3950. class ListOptionsAccess extends OptionsAccess
  3951. {
  3952.     proto native int        GetIndex();
  3953.     proto native void       SetIndex(int index);
  3954.     proto native int        GetItemsCount();
  3955.     proto   void                    GetItemText(int index, out string value);
  3956. };
  3957.  
  3958. // -------------------------------------------------------------------------
  3959. class SwitchOptionsAccess extends OptionsAccess
  3960. {
  3961.     proto native void       Switch();
  3962.     proto   void                    GetItemText(out string value);
  3963. };
  3964.  
  3965. // -------------------------------------------------------------------------
  3966. class GameOptions
  3967. {
  3968.     proto native void   Apply();
  3969.     proto native void   Revert();
  3970.     proto native void   Test();
  3971.     proto native OptionsAccess GetOption(int index);
  3972.     proto native int GetOptionsCount();
  3973.     proto native int NeedRestart();
  3974. };
  3975.  
  3976. typedef Ref<Object> ORefT;
  3977. typedef Link<Object> OLinkT;
  3978.  
  3979. // #include "Scripts/Classes/Component/_include.c"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top