Advertisement
DeAmouSE

Untitled

May 12th, 2021
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.20 KB | None | 0 0
  1. class ActionBlowCB : ActionSingleUseBaseCB
  2. {
  3.     override void CreateActionComponent()
  4.     {
  5.         m_ActionData.m_ActionComponent = new CAContinuousQuantityEdible(UAQuantityConsumed.EAT_SMALL,UATimeSpent.DEFAULT);
  6.     }
  7. };
  8.  
  9. class ActionBlow: ActionSingleUseBase
  10. {
  11.     const int CONSUMED_TEMPERATURE = 20;
  12.     protected EffectSound blowSound;
  13.    
  14.     void ActionBlow()
  15.     {
  16.         m_CallbackClass = ActionBlowCB;
  17.         m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_LICKBATTERY;
  18.         //m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_LICKBATTERY;
  19.  
  20.         //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_DRINK;
  21.         //m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_DRINK;
  22.        
  23.         //m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;            
  24.        
  25.         //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_EAT;
  26.         //m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_EAT;
  27.     }
  28.    
  29.     override void CreateConditionComponents()  
  30.     {
  31.         m_ConditionItem = new CCINonRuined;
  32.         m_ConditionTarget = new CCTSelf;
  33.     }
  34.    
  35.     override bool HasProneException()
  36.     {
  37.         return true;
  38.     }
  39.  
  40.     override bool HasTarget()
  41.     {
  42.         return false;
  43.     }
  44.  
  45.     override string GetText()
  46.     {
  47.         return "Остудить";
  48.     }
  49.  
  50.     override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  51.     {
  52.         if (player.CheckMaskHeadGear())
  53.         {
  54.              return false;
  55.          }
  56.         //преобразуем в еду
  57.         Edible_Base food;
  58.         if(Class.CastTo(food, item))
  59.         {
  60.             //получаем температуру
  61.             int food_temperature = food.GetTemperature();
  62.             if(food_temperature > GameConstants.FOOD_TEMP_NORMAL)
  63.             {
  64.                 return true;
  65.             }
  66.         }
  67.         Bottle_Base bottle;
  68.         if(Class.CastTo(bottle, item))
  69.         {
  70.             int bottle_temperature = bottle.GetTemperature();
  71.             if(bottle.GetTemperature() > GameConstants.FOOD_TEMP_NORMAL)
  72.             {
  73.                 return true;
  74.             }
  75.         }
  76.        
  77.         return false;
  78.     }
  79.  
  80.     /*
  81.     override void OnExecuteServer(ActionData action_data)
  82.     {
  83.         PlayerBase player = action_data.m_Player;
  84.        
  85.         if ( player && action_data.m_MainItem )
  86.         {
  87.             player.Consume(action_data.m_MainItem, GetConsumedQuantity(), EConsumeType.ITEM_SINGLE_TIME);
  88.         }
  89.     }
  90.     */
  91.  
  92.     override void OnStartClient(ActionData action_data)
  93.     {
  94.         TStringArray male_BlowSound = {"male_blow1_sound","male_blow2_sound","male_blow3_sound","male_blow4_sound"};
  95.         TStringArray female_BlowSound = {"female_blow1_sound","female_blow2_sound","female_blow3_sound","female_blow4_sound"};
  96.         PlayerBase player = PlayerBase.Cast(action_data.m_Player);
  97.         EntityAI item = EntityAI.Cast(action_data.m_MainItem);
  98.         if(player && item)
  99.         {
  100.             if(player.GetType().Contains("SurvivorM"))
  101.                 action_data.m_MainItem.PlaySoundSet(blowSound, male_BlowSound.GetRandomElement(), 0, 0 );
  102.             else
  103.                 action_data.m_MainItem.PlaySoundSet(blowSound, female_BlowSound.GetRandomElement(), 0, 0 );
  104.         }
  105.         //bool soundstate = action_data.m_Player.PlaySoundSetLoop(blowSound, "male_blow_sound", 0, 0 );
  106.         //Print(":::Server :: ActionBlow Sound : " + soundstate);
  107.     }
  108.  
  109.     override void OnEndClient(ActionData action_data) //method called on finish main animation loop (before out animation part )
  110.     {
  111.         //if (blowSound) action_data.m_MainItem.StopSoundSet(blowSound);
  112.     }
  113.    
  114.     override void OnStartServer(ActionData action_data)
  115.     {
  116.     }
  117.    
  118.     override void OnEndServer(ActionData action_data)
  119.     {
  120.         int temp = action_data.m_MainItem.GetTemperature();
  121.         action_data.m_MainItem.SetTemperature(temp - GameConstants.FOOD_TEMP_BLOW);
  122.         if(temp == GameConstants.FOOD_TEMP_NORMAL)
  123.         {
  124.             SendMessageToClient(action_data.m_Player, "Подходящая температура чтобы съесть...");
  125.         }
  126.         action_data.m_MainItem.SetSynchDirty();
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement