DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ OnAction()

override bool ReplaceEdibleWithNewLambda::OnAction ( int action_id,
Man player,
ParamsReadContext ctx )
protected

См. определение в файле Edible_Base.c строка 2099

2099 : ItemBase
2100{
2101 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
2102
2103 const string SOUND_BAKING_START = "Baking_SoundSet";
2104 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
2105 const string SOUND_BOILING_START = "Boiling_SoundSet";
2106 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
2107 const string SOUND_DRYING_START = "Drying_SoundSet";
2108 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
2109 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
2110
2111 protected bool m_MakeCookingSounds;
2112 protected SoundOnVehicle m_SoundCooking;
2114 protected string m_SoundPlaying;
2115 ref FoodStage m_FoodStage;
2116 protected float m_DecayTimer;
2117 protected float m_DecayDelta = 0.0;
2120
2122
2123 void Edible_Base()
2124 {
2125 if (HasFoodStage())
2126 {
2127 m_FoodStage = new FoodStage(this);
2128
2129 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
2130 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
2131
2132 m_SoundPlaying = "";
2134 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
2135 RegisterNetSyncVariableBool("m_MakeCookingSounds");
2136 }
2137 }
2138
2139 override void EEInit()
2140 {
2141 super.EEInit();
2142
2143 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
2144 }
2145
2146 override void EEDelete(EntityAI parent)
2147 {
2148 super.EEDelete(parent);
2149
2150 RemoveAudio();
2151
2153 m_HotVaporParticle.Stop();
2154 }
2155
2156 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
2157 {
2158 super.EEItemLocationChanged(oldLoc, newLoc);
2159
2161 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
2162 {
2163 switch (oldLoc.GetParent().GetType())
2164 {
2165 case "FryingPan":
2166 case "Pot":
2167 case "Cauldron":
2168 case "SharpWoodenStick":
2169 MakeSoundsOnClient(false);
2170 break;
2171 }
2172
2174 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
2175 {
2176 MakeSoundsOnClient(false);
2177 }
2178 }
2179
2180 if (oldLoc.IsValid())
2182
2183 if (CanHaveTemperature())
2185 }
2186
2187 void UpdateVisualsEx(bool forced = false)
2188 {
2189 if (GetFoodStage())
2190 GetFoodStage().UpdateVisualsEx(forced);
2191 }
2192
2193 bool Consume(float amount, PlayerBase consumer)
2194 {
2195 AddQuantity(-amount, false, false);
2196 OnConsume(amount, consumer);
2197
2198 return true;
2199 }
2200
2201 void OnConsume(float amount, PlayerBase consumer)
2202 {
2204 {
2205 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
2206 }
2207 }
2208
2210 int FilterAgents(int agentsIn)
2211 {
2212 int foodStageType;
2213
2214 FoodStage foodStage = GetFoodStage();
2215 if (foodStage)
2216 foodStageType = foodStage.GetFoodStageType();
2217
2219 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
2220 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
2221 agentsIn &= ~eAgents.FOOD_POISON;
2222
2223 return agentsIn;
2224 }
2225
2226 //food staging
2227 override bool CanBeCooked()
2228 {
2229 return false;
2230 }
2231
2232 override bool CanBeCookedOnStick()
2233 {
2234 return false;
2235 }
2236
2237 override float GetTemperatureFreezeTime()
2238 {
2239 if (GetFoodStage())
2240 {
2241 switch (m_FoodStage.GetFoodStageType())
2242 {
2243 case FoodStageType.DRIED:
2244 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
2245
2246 case FoodStageType.BURNED:
2247 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
2248
2249 default:
2250 return super.GetTemperatureFreezeTime();
2251 }
2252 }
2253
2254 return super.GetTemperatureFreezeTime();
2255 }
2256
2257 override float GetTemperatureThawTime()
2258 {
2259 if (GetFoodStage())
2260 {
2261 switch (m_FoodStage.GetFoodStageType())
2262 {
2263 case FoodStageType.DRIED:
2264 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
2265
2266 case FoodStageType.BURNED:
2267 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
2268
2269 default:
2270 return super.GetTemperatureThawTime();
2271 }
2272 }
2273
2274 return super.GetTemperatureThawTime();
2275 }
2276
2277 override bool CanItemOverheat()
2278 {
2279 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
2280 }
2281
2282 //================================================================
2283 // SYNCHRONIZATION
2284 //================================================================
2285 void Synchronize()
2286 {
2287 SetSynchDirty();
2288 }
2289
2290 override void OnVariablesSynchronized()
2291 {
2292 super.OnVariablesSynchronized();
2293
2294 //UpdateVisualsEx(); //performed on client only
2295
2296 //update audio
2298 {
2299 RefreshAudio();
2300 }
2301 else
2302 {
2303 RemoveAudio();
2304 }
2305
2306 if (CanHaveTemperature())
2308 }
2309
2310 //================================================================
2311 // AUDIO EFFECTS (WHEN ON DCS)
2312 //================================================================
2313 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
2314 {
2315 m_MakeCookingSounds = soundstate;
2316 m_CookedByMethod = cookingMethod;
2317
2318 Synchronize();
2319 }
2320
2321 protected void RefreshAudio()
2322 {
2323 string soundName = "";
2324
2325 FoodStageType currentFoodStage = GetFoodStageType();
2327
2328 if (currentFoodStage == FoodStageType.BURNED)
2329 {
2330 soundName = SOUND_BURNING_DONE;
2331 }
2332 else
2333 {
2334 switch (m_CookedByMethod)
2335 {
2336 case CookingMethodType.BAKING:
2337 {
2338 if (nextFoodStage == FoodStageType.BAKED)
2339 soundName = SOUND_BAKING_START;
2340 else if (currentFoodStage == FoodStageType.BAKED)
2341 soundName = SOUND_BAKING_DONE;
2342 else
2343 soundName = "";
2344 break;
2345 }
2346
2347 case CookingMethodType.BOILING:
2348 {
2349 if (nextFoodStage == FoodStageType.BOILED)
2350 soundName = SOUND_BOILING_START;
2351 else if (currentFoodStage == FoodStageType.BOILED)
2352 soundName = SOUND_BOILING_DONE;
2353 else
2354 soundName = "";
2355 break;
2356 }
2357
2358 case CookingMethodType.DRYING:
2359 {
2360 if (nextFoodStage == FoodStageType.DRIED)
2361 soundName = SOUND_DRYING_START;
2362 else if (currentFoodStage == FoodStageType.DRIED)
2363 soundName = SOUND_DRYING_DONE;
2364 else
2365 soundName = "";
2366 break;
2367 }
2368
2369 default:
2370 soundName = "";
2371 break;
2372 }
2373
2374 if (nextFoodStage == FoodStageType.BURNED)
2375 {
2376 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
2377 {
2378 soundName = SOUND_BURNING_DONE;
2379 }
2380 else // pre-emptive burning sounds replace regular ones
2381 {
2382 array<float> nextStageProperties = new array<float>();
2383 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
2384 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
2385 float progress01 = GetCookingTime() / nextStageTime;
2386 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
2387 {
2388 soundName = SOUND_BURNING_DONE;
2389 }
2390 }
2391 }
2392 }
2393
2394 SoundCookingStart(soundName);
2395 }
2396
2397 protected void RemoveAudio()
2398 {
2399 m_MakeCookingSounds = false;
2401 }
2402
2403 //================================================================
2404 // SERIALIZATION
2405 //================================================================
2406 override void OnStoreSave(ParamsWriteContext ctx)
2407 {
2408 super.OnStoreSave(ctx);
2409
2410 if (GetFoodStage())
2411 {
2412 GetFoodStage().OnStoreSave(ctx);
2413 }
2414
2415 // food decay
2416 ctx.Write(m_DecayTimer);
2418 }
2419
2420 override bool OnStoreLoad(ParamsReadContext ctx, int version)
2421 {
2422 if (!super.OnStoreLoad(ctx, version))
2423 return false;
2424
2425 if (GetFoodStage())
2426 {
2427 if (!GetFoodStage().OnStoreLoad(ctx, version))
2428 return false;
2429 }
2430
2431 if (version >= 115)
2432 {
2433 if (!ctx.Read(m_DecayTimer))
2434 {
2435 m_DecayTimer = 0.0;
2436 return false;
2437 }
2438 if (!ctx.Read(m_LastDecayStage))
2439 {
2441 return false;
2442 }
2443 }
2444
2445 UpdateVisualsEx(true); //forced init visuals
2446 Synchronize();
2447
2448 return true;
2449 }
2450
2451 override void AfterStoreLoad()
2452 {
2453 super.AfterStoreLoad();
2454
2455 Synchronize();
2456 }
2457
2458 //get food stage
2459 override FoodStage GetFoodStage()
2460 {
2461 return m_FoodStage;
2462 }
2463
2464 //food types
2465 override bool IsMeat()
2466 {
2467 return false;
2468 }
2469
2470 override bool IsCorpse()
2471 {
2472 return false;
2473 }
2474
2475 override bool IsFruit()
2476 {
2477 return false;
2478 }
2479
2480 override bool IsMushroom()
2481 {
2482 return false;
2483 }
2484
2485 //================================================================
2486 // NUTRITIONAL VALUES
2487 //================================================================
2488 //food properties
2489 static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
2490 {
2491 Edible_Base food_item = Edible_Base.Cast(item);
2492 if (food_item && food_item.GetFoodStage())
2493 {
2494 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
2495 }
2496 else if (classname != "" && food_stage)
2497 {
2498 return FoodStage.GetFullnessIndex(null, food_stage, classname);
2499 }
2500 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2501 return g_Game.ConfigGetFloat( class_path + " fullnessIndex" );
2502
2503 }
2504
2505 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
2506 {
2507 Edible_Base food_item = Edible_Base.Cast(item);
2508 if (food_item && food_item.GetFoodStage())
2509 {
2510 return FoodStage.GetEnergy(food_item.GetFoodStage());
2511 }
2512 else if (classname != "" && food_stage)
2513 {
2514 return FoodStage.GetEnergy(null, food_stage, classname);
2515 }
2516 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2517 return g_Game.ConfigGetFloat( class_path + " energy" );
2518 }
2519
2520 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
2521 {
2522 Edible_Base food_item = Edible_Base.Cast(item);
2523 if (food_item && food_item.GetFoodStage())
2524 {
2525 return FoodStage.GetWater(food_item.GetFoodStage());
2526 }
2527 else if (classname != "" && food_stage)
2528 {
2529 return FoodStage.GetWater(null, food_stage, classname);
2530 }
2531 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2532 return g_Game.ConfigGetFloat( class_path + " water" );
2533 }
2534
2535 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
2536 {
2537 Edible_Base food_item = Edible_Base.Cast(item);
2538 if (food_item && food_item.GetFoodStage())
2539 {
2540 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
2541 }
2542 else if (classname != "" && food_stage)
2543 {
2544 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
2545 }
2546 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2547 return g_Game.ConfigGetFloat( class_path + " nutritionalIndex" );
2548
2549 }
2550
2551 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
2552 {
2553 Edible_Base food_item = Edible_Base.Cast(item);
2554 if (food_item && food_item.GetFoodStage())
2555 {
2556 return FoodStage.GetToxicity(food_item.GetFoodStage());
2557 }
2558 else if (classname != "" && food_stage)
2559 {
2560 return FoodStage.GetToxicity(null, food_stage, classname);
2561 }
2562 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2563 return g_Game.ConfigGetFloat( class_path + " toxicity" );
2564 }
2565
2566 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
2567 {
2568 Edible_Base food_item = Edible_Base.Cast(item);
2569 if (food_item && food_item.GetFoodStage())
2570 {
2571 return FoodStage.GetAgents(food_item.GetFoodStage());
2572 }
2573 else if (classname != "" && food_stage)
2574 {
2575 return FoodStage.GetAgents(null, food_stage, classname);
2576 }
2577 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2578 return g_Game.ConfigGetInt( class_path + " agents" );
2579 }
2580
2581 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
2582 {
2583 Edible_Base food_item = Edible_Base.Cast(item);
2584 if (food_item && food_item.GetFoodStage())
2585 {
2586 return FoodStage.GetDigestibility(food_item.GetFoodStage());
2587 }
2588 else if (classname != "" && food_stage)
2589 {
2590 return FoodStage.GetDigestibility(null, food_stage, classname);
2591 }
2592 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2593 return g_Game.ConfigGetInt( class_path + " digestibility" );
2594 }
2595
2596 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
2597 {
2598 Edible_Base foodItem = Edible_Base.Cast(item);
2599 if (foodItem && foodItem.GetFoodStage())
2600 {
2601 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
2602 }
2603 else if (className != "" && foodStage)
2604 {
2605 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
2606 }
2607 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
2608 return g_Game.ConfigGetInt(classPath + " agentsPerDigest");
2609 }
2610
2611 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
2612 {
2613 NutritionalProfile profile = new NutritionalProfile();
2614 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
2615 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
2616 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
2617 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
2618 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
2619 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
2620 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
2621 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
2622
2623 return profile;
2624 }
2625
2626 //================================================================
2627 // FOOD STAGING
2628 //================================================================
2630 {
2631 return GetFoodStage().GetFoodStageType();
2632 }
2633
2634 //food stage states
2635 bool IsFoodRaw()
2636 {
2637 if ( GetFoodStage() )
2638 {
2639 return GetFoodStage().IsFoodRaw();
2640 }
2641
2642 return false;
2643 }
2644
2645 bool IsFoodBaked()
2646 {
2647 if ( GetFoodStage() )
2648 {
2649 return GetFoodStage().IsFoodBaked();
2650 }
2651
2652 return false;
2653 }
2654
2655 bool IsFoodBoiled()
2656 {
2657 if ( GetFoodStage() )
2658 {
2659 return GetFoodStage().IsFoodBoiled();
2660 }
2661
2662 return false;
2663 }
2664
2665 bool IsFoodDried()
2666 {
2667 if ( GetFoodStage() )
2668 {
2669 return GetFoodStage().IsFoodDried();
2670 }
2671
2672 return false;
2673 }
2674
2675 bool IsFoodBurned()
2676 {
2677 if ( GetFoodStage() )
2678 {
2679 return GetFoodStage().IsFoodBurned();
2680 }
2681
2682 return false;
2683 }
2684
2685 bool IsFoodRotten()
2686 {
2687 if ( GetFoodStage() )
2688 {
2689 return GetFoodStage().IsFoodRotten();
2690 }
2691
2692 return false;
2693 }
2694
2695 //food stage change
2696 void ChangeFoodStage( FoodStageType new_food_stage_type )
2697 {
2698 GetFoodStage().ChangeFoodStage( new_food_stage_type );
2699 }
2700
2702 {
2703 return GetFoodStage().GetNextFoodStageType( cooking_method );
2704 }
2705
2706 string GetFoodStageName( FoodStageType food_stage_type )
2707 {
2708 return GetFoodStage().GetFoodStageName( food_stage_type );
2709 }
2710
2711 bool CanChangeToNewStage( CookingMethodType cooking_method )
2712 {
2713 return GetFoodStage().CanChangeToNewStage( cooking_method );
2714 }
2715
2716 //Use this to receive food stage from another Edible_Base
2717 void TransferFoodStage( notnull Edible_Base source )
2718 {
2719 if ( !source.GetFoodStage())
2720 return;
2721 m_LastDecayStage = source.GetLastDecayStage();
2722 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
2723 m_DecayTimer = source.GetDecayTimer();
2724 m_DecayDelta = source.GetDecayDelta();
2725 }
2726
2728 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
2729 {
2730 HandleFoodStageChangeAgents(stageOld,stageNew);
2731 UpdateVisualsEx(); //performed on server only
2732 }
2733
2736 {
2737 switch (stageNew)
2738 {
2739 case FoodStageType.BAKED:
2740 case FoodStageType.BOILED:
2741 case FoodStageType.DRIED:
2742 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2743 break;
2744
2745 case FoodStageType.BURNED:
2746 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2747 break;
2748 }
2749 }
2750
2751 //================================================================
2752 // COOKING
2753 //================================================================
2754 //cooking time
2755 float GetCookingTime()
2756 {
2757 return GetFoodStage().GetCookingTime();
2758 }
2759
2760 void SetCookingTime( float time )
2761 {
2762 GetFoodStage().SetCookingTime( time );
2763
2764 //synchronize when calling on server
2765 Synchronize();
2766 }
2767
2768 void ResetCookingTime()
2769 {
2770 if (GetFoodStage())
2771 {
2772 GetFoodStage().SetCookingTime(0);
2773 Synchronize();
2774 }
2775 }
2776
2777 //replace edible with new item (opening cans)
2778 void ReplaceEdibleWithNew( string typeName )
2779 {
2780 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
2781 if (player)
2782 {
2783 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
2784 player.ServerReplaceItemInHandsWithNew(lambda);
2785 }
2786 else
2787 Error("ReplaceEdibleWithNew - cannot use edible without player");
2788 }
2789
2791 {
2793 }
2794
2795 override void SetActions()
2796 {
2797 super.SetActions();
2798
2801 }
2802
2803 protected void SoundCookingStart(string sound_name)
2804 {
2805 #ifndef SERVER
2806 #ifndef NO_GUI
2807 if (m_SoundPlaying != sound_name)
2808 {
2810
2811 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
2812 m_SoundPlaying = sound_name;
2813 }
2814 #endif
2815 #endif
2816 }
2817
2818 protected void SoundCookingStop()
2819 {
2820 #ifndef SERVER
2821 #ifndef NO_GUI
2823 {
2824 m_SoundEffectCooking.Stop();
2825 m_SoundEffectCooking = null;
2826 m_SoundPlaying = "";
2827 }
2828 #endif
2829 #endif
2830 }
2831
2832 override bool CanDecay()
2833 {
2834 return false;
2835 }
2836
2837 override bool CanProcessDecay()
2838 {
2839 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
2840 }
2841
2842 override void ProcessDecay( float delta, bool hasRootAsPlayer )
2843 {
2844 m_DecayDelta = 0.0;
2845
2846 delta *= DayZGame.Cast(g_Game).GetFoodDecayModifier();
2847 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
2848 if ( hasRootAsPlayer )
2850
2851 /*Print( "-------------------------" );
2852 Print( this );
2853 Print( m_DecayTimer );
2854 Print( m_DecayDelta );
2855 Print( m_LastDecayStage );*/
2856
2857 if ( IsFruit() || IsMushroom() )
2858 {
2859 // fruit, vegetables and mushrooms
2861 {
2862 switch ( GetFoodStageType() )
2863 {
2864 case FoodStageType.RAW:
2867 break;
2868
2869 case FoodStageType.BOILED:
2872 break;
2873
2874 case FoodStageType.BAKED:
2877 break;
2878
2879 case FoodStageType.DRIED:
2880 case FoodStageType.BURNED:
2881 case FoodStageType.ROTTEN:
2882 default:
2883 m_DecayTimer = -1;
2885 return;
2886 }
2887
2888 //m_DecayTimer = m_DecayTimer / 1000.0;
2889 }
2890
2891 m_DecayTimer -= ( delta * m_DecayDelta );
2892
2893 if ( m_DecayTimer <= 0 )
2894 {
2895 if ( m_LastDecayStage != FoodStageType.NONE )
2896 {
2897 // switch to decayed stage
2898 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2899 {
2901 }
2902 if ( m_LastDecayStage == FoodStageType.RAW )
2903 {
2904 int rng = Math.RandomIntInclusive( 0, 100 );
2906 {
2908 }
2909 else
2910 {
2911 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
2912 {
2914 }
2915 else
2916 {
2918 }
2919 }
2920 }
2921 }
2922 }
2923
2924 }
2925 else if ( IsMeat() )
2926 {
2927 // meat
2929 {
2930 switch ( GetFoodStageType() )
2931 {
2932 case FoodStageType.RAW:
2935 break;
2936
2937 case FoodStageType.BOILED:
2940 break;
2941
2942 case FoodStageType.BAKED:
2945 break;
2946
2947 case FoodStageType.DRIED:
2950 break;
2951
2952 case FoodStageType.BURNED:
2953 case FoodStageType.ROTTEN:
2954 default:
2955 m_DecayTimer = -1;
2957 return;
2958 }
2959 }
2960
2961 m_DecayTimer -= ( delta * m_DecayDelta );
2962
2963 if ( m_DecayTimer <= 0 )
2964 {
2965 if ( m_LastDecayStage != FoodStageType.NONE )
2966 {
2967 // switch to decayed stage
2968 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2969 {
2971 }
2972 }
2973 }
2974 }
2975 else if ( IsCorpse() )
2976 {
2977 // corpse
2979 {
2980 switch ( GetFoodStageType() )
2981 {
2982 case FoodStageType.RAW:
2985 break;
2986
2987 case FoodStageType.BURNED:
2988 case FoodStageType.ROTTEN:
2989 default:
2990 m_DecayTimer = -1;
2992 return;
2993 }
2994 }
2995
2996 m_DecayTimer -= ( delta * m_DecayDelta );
2997
2998 if ( m_DecayTimer <= 0 )
2999 {
3000 if ( m_LastDecayStage != FoodStageType.NONE )
3001 {
3002 // switch to decayed stage
3003 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
3004 {
3006 }
3007 }
3008 }
3009 }
3010 else
3011 {
3012 // opened cans
3013 m_DecayTimer -= ( delta * m_DecayDelta );
3014
3015 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
3016 {
3019 //m_DecayTimer = m_DecayTimer / 1000.0;
3020 }
3021 else
3022 {
3023 if ( m_DecayTimer <= 0 )
3024 {
3025 InsertAgent(eAgents.FOOD_POISON, 1);
3026 m_DecayTimer = -1;
3027 }
3028 }
3029 }
3030 }
3031
3032 protected void UpdateVaporParticle()
3033 {
3034 if (g_Game.IsHeadlessOrDedicatedServer())
3035 return;
3036
3037 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
3038 {
3039 InventoryLocation invLoc = new InventoryLocation();
3040 GetInventory().GetCurrentInventoryLocation(invLoc);
3041 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
3042 {
3043 ParticleManager ptcMgr = ParticleManager.GetInstance();
3044 if (ptcMgr)
3045 {
3046 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
3047 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
3048 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
3049 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
3050 }
3051 }
3052 }
3053 else if (m_HotVaporParticle)
3054 {
3055 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
3056 {
3057 m_HotVaporParticle.Stop();
3058 m_HotVaporParticle = null;
3059 return;
3060 }
3061
3062 InventoryLocation inventoryLoc = new InventoryLocation();
3063 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
3064 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
3065 {
3066 m_HotVaporParticle.Stop();
3067 m_HotVaporParticle = null;
3068 }
3069 }
3070 }
3071
3072 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
3073 {
3074 if (GetFoodStage())
3075 {
3076 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_NUTRITIONS_DATA, "Food Nutritions Data", FadeColors.WHITE));
3077 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
3078 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
3079 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
3080 }
3081
3082 super.GetDebugActions(outputList);
3083 }
3084
3085 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
3086 {
3087 super.OnAction(action_id, player, ctx);
3088
3089 if ( g_Game.IsServer() )
3090 {
3091 if ( action_id == EActions.FOOD_STAGE_PREV )
3092 {
3093 int food_stage_prev = GetFoodStageType() - 1;
3094 if (food_stage_prev <= 0)
3095 {
3096 food_stage_prev = FoodStageType.COUNT - 1;
3097 }
3098 ChangeFoodStage(food_stage_prev);
3099 return true;
3100 }
3101 else if ( action_id == EActions.FOOD_STAGE_NEXT )
3102 {
3103 int food_stage_next = GetFoodStageType() + 1;
3104 if (food_stage_next >= FoodStageType.COUNT )
3105 {
3106 food_stage_next = FoodStageType.RAW;
3107 }
3108 ChangeFoodStage(food_stage_next);
3109 return true;
3110 }
3111
3112 }
3113
3114 #ifdef DIAG_DEVELOPER
3115 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
3116 {
3117 PrintNutritionsData();
3118 return true;
3119 }
3120 #endif
3121
3122 return false;
3123 }
3124
3125 override string GetDebugText()
3126 {
3127 string debug_output;
3128
3129 debug_output = super.GetDebugText();
3130
3131 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
3132 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
3133
3134 return debug_output;
3135 }
3136
3137 //================================================================
3138 // GENERAL GETTERS
3139 //================================================================
3140
3141 override float GetBaitEffectivity()
3142 {
3143 float ret = super.GetBaitEffectivity();
3144
3145 if (IsFoodRotten())
3146 {
3147 ret *= 0.5;
3148 }
3149
3150 return ret;
3151 }
3152
3153 float GetDecayTimer()
3154 {
3155 return m_DecayTimer;
3156 }
3157
3158 float GetDecayDelta()
3159 {
3160 return m_DecayDelta;
3161 }
3162
3164 {
3165 return m_LastDecayStage;
3166 }
3167
3168 #ifdef DIAG_DEVELOPER
3169 private void PrintNutritionsData()
3170 {
3171 string nutritionsData = "";
3172
3173 FoodStage stage = GetFoodStage();
3174 FoodStageType stageType = stage.GetFoodStageType();
3175
3176 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
3177 if (profile)
3178 {
3179 nutritionsData = string.Format("Item: %1\n\n", this);
3180 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
3181 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
3182 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
3183 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
3184 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
3185 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
3186 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
3187
3188 if (profile.IsLiquid())
3189 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
3190
3191 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
3192 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
3193 }
3194
3195 nutritionsData += "-----\n";
3196
3197 Debug.Log(nutritionsData);
3198 }
3199 #endif
3200
3202 //DEPRECATED
3204 void UpdateVisuals()
3205 {
3207 }
3208}
3209
3211{
3212 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
3213};
Param4< int, int, string, int > TSelectableActionInfoWithColor
class LogManager EntityAI
eBleedingSourceType GetType()
AttachActionData ActionData ActionAttach()
Определения ActionAttach.c:9
void ActionDetach()
Определения ActionDetach.c:10
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:4074
AbstractWave m_SoundPlaying
Определения DynamicMusicPlayer.c:118
EActions
Определения EActions.c:2
eAgents
Определения EAgents.c:3
EConsumptionPenaltyContext
Определения EConsumptionPenaltyContext.c:2
void ReplaceEdibleWithNew(string typeName)
Определения Edible_Base.c:1792
ref FoodStage m_FoodStage
Определения Edible_Base.c:1129
bool IsFoodRotten()
Определения Edible_Base.c:1699
static float GetFoodWater(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1534
override bool CanBeCooked()
Определения Edible_Base.c:1241
bool IsFoodBaked()
Определения Edible_Base.c:1659
override string GetDebugText()
Определения Edible_Base.c:2139
override void AfterStoreLoad()
Определения Edible_Base.c:1465
void Edible_Base()
Определения Edible_Base.c:1137
void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
called on server
Определения Edible_Base.c:1742
float m_DecayDelta
Определения Edible_Base.c:1131
void Synchronize()
Определения Edible_Base.c:1299
override void OnVariablesSynchronized()
Определения Edible_Base.c:1304
const string SOUND_BURNING_DONE
Определения Edible_Base.c:1123
bool CanChangeToNewStage(CookingMethodType cooking_method)
Определения Edible_Base.c:1725
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения Edible_Base.c:2099
void RemoveAudio()
Определения Edible_Base.c:1411
override bool CanItemOverheat()
Определения Edible_Base.c:1291
float GetDecayDelta()
Определения Edible_Base.c:2172
override float GetBaitEffectivity()
Определения Edible_Base.c:2155
override FoodStage GetFoodStage()
Определения Edible_Base.c:1473
override void SetActions()
Определения Edible_Base.c:1809
bool m_MakeCookingSounds
Определения Edible_Base.c:1125
override float GetTemperatureFreezeTime()
Определения Edible_Base.c:1251
void SoundCookingStop()
Определения Edible_Base.c:1832
const string DIRECT_COOKING_SLOT_NAME
Определения Edible_Base.c:1115
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
Определения Edible_Base.c:1715
void ChangeFoodStage(FoodStageType new_food_stage_type)
Определения Edible_Base.c:1710
void OnConsume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1215
static float GetFoodNutritionalIndex(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1549
SoundOnVehicle m_SoundCooking
Определения Edible_Base.c:1126
static float GetFoodToxicity(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1565
override bool CanDecay()
Определения Edible_Base.c:1846
void UpdateVisualsEx(bool forced=false)
Определения Edible_Base.c:1201
const string SOUND_BAKING_DONE
Определения Edible_Base.c:1118
static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1625
int FilterAgents(int agentsIn)
Filter agents from the item (override on higher implementations)
Определения Edible_Base.c:1224
override void EEDelete(EntityAI parent)
Определения Edible_Base.c:1160
FoodStageType m_LastDecayStage
Определения Edible_Base.c:1132
float GetCookingTime()
Определения Edible_Base.c:1769
override bool CanBeCookedOnStick()
Определения Edible_Base.c:1246
override bool IsCorpse()
Определения Edible_Base.c:1484
void UpdateVisuals()
Определения Edible_Base.c:2218
float GetDecayTimer()
Определения Edible_Base.c:2167
FoodStageType GetLastDecayStage()
Определения Edible_Base.c:2177
string GetFoodStageName(FoodStageType food_stage_type)
Определения Edible_Base.c:1720
override float GetTemperatureThawTime()
Определения Edible_Base.c:1271
void UpdateVaporParticle()
Определения Edible_Base.c:2046
static float GetFoodDigestibility(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1595
void TransferFoodStage(notnull Edible_Base source)
Определения Edible_Base.c:1731
override void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения Edible_Base.c:1856
const string SOUND_DRYING_START
Определения Edible_Base.c:1121
void SetCookingTime(float time)
Определения Edible_Base.c:1774
void SoundCookingStart(string sound_name)
Определения Edible_Base.c:1817
override bool IsMeat()
Определения Edible_Base.c:1479
const string SOUND_BAKING_START
Определения Edible_Base.c:1117
static float GetFoodTotalVolume(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1503
const string SOUND_DRYING_DONE
Определения Edible_Base.c:1122
void HandleFoodStageChangeAgents(FoodStageType stageOld, FoodStageType stageNew)
removes select agents on foodstage transitions
Определения Edible_Base.c:1749
void ResetCookingTime()
Определения Edible_Base.c:1782
override bool IsFruit()
Определения Edible_Base.c:1489
Edible_Base ItemBase ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Определения Edible_Base.c:1114
bool Consume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1207
EffectSound m_SoundEffectCooking
DEPRECATED.
Определения Edible_Base.c:1127
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения Edible_Base.c:1434
FoodStageType GetFoodStageType()
Определения Edible_Base.c:1643
override bool CanProcessDecay()
Определения Edible_Base.c:1851
ParticleSource m_HotVaporParticle
Определения Edible_Base.c:1133
void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod=CookingMethodType.NONE)
Определения Edible_Base.c:1327
static int GetFoodAgents(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1580
override bool IsMushroom()
Определения Edible_Base.c:1494
static float GetFoodEnergy(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1519
static float GetAgentsPerDigest(ItemBase item, string className="", int foodStage=0)
Определения Edible_Base.c:1610
void RefreshAudio()
Определения Edible_Base.c:1335
const string SOUND_BOILING_DONE
Определения Edible_Base.c:1120
int GetConsumptionPenaltyContext()
Определения Edible_Base.c:1804
const string SOUND_BOILING_START
Определения Edible_Base.c:1119
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения Edible_Base.c:2086
CookingMethodType m_CookedByMethod
Определения Edible_Base.c:1135
bool IsFoodDried()
Определения Edible_Base.c:1679
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения Edible_Base.c:1170
override void OnStoreSave(ParamsWriteContext ctx)
Определения Edible_Base.c:1420
bool IsFoodRaw()
Определения Edible_Base.c:1649
bool IsFoodBurned()
Определения Edible_Base.c:1689
override void EEInit()
Определения Edible_Base.c:1153
bool IsFoodBoiled()
Определения Edible_Base.c:1669
float m_DecayTimer
Определения Edible_Base.c:1130
override bool CanHaveTemperature()
Определения FireplaceBase.c:575
FoodStageType
Определения FoodStage.c:2
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:3979
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:3984
bool HasFoodStage()
Определения ItemBase.c:2589
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:3389
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
ParticleAutoDestroyFlags
Flags to pass to ParticleSource.SetParticleAutoDestroyFlags.
Определения ParticleSource.c:3
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения 3_Game/DayZ/tools/Debug.c:183
Определения 3_Game/DayZ/tools/Debug.c:2
override FoodStage GetFoodStage()
Определения Edible_Base.c:361
Определения Edible_Base.c:2
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:30
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
override void EEInit()
Определения BarbedWire.c:41
Определения EnMath.c:7
float m_Digestibility
Определения NutritionalProfile.c:11
bool IsLiquid()
Определения NutritionalProfile.c:47
float m_WaterContent
Определения NutritionalProfile.c:4
string m_LiquidClassname
Определения NutritionalProfile.c:10
float m_FullnessIndex
Определения NutritionalProfile.c:6
float m_Toxicity
Определения NutritionalProfile.c:7
float m_Energy
Определения NutritionalProfile.c:3
int m_Agents
Определения NutritionalProfile.c:9
float m_AgentsPerDigest
Определения NutritionalProfile.c:12
float m_NutritionalIndex
Определения NutritionalProfile.c:5
static const int ITEM_HOT_VAPOR
Определения ParticleList.c:78
Определения ParticleList.c:12
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:128
Определения PlayerBaseClient.c:2
static const float CONSUMPTION_DAMAGE_PER_BITE
Определения PlayerConstants.c:146
static const float CONSUMPTION_DAMAGE_TEMP_THRESHOLD
Определения PlayerConstants.c:147
Определения PlayerConstants.c:2
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Определения EffectManager.c:178
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
const float DECAY_FOOD_BAKED_FRVG
Определения 3_Game/DayZ/constants.c:1101
const float DECAY_FOOD_CAN_OPEN
Определения 3_Game/DayZ/constants.c:1103
const float DECAY_FOOD_RAW_FRVG
Определения 3_Game/DayZ/constants.c:1097
const int DECAY_TIMER_RANDOM_PERCENTAGE
Определения 3_Game/DayZ/constants.c:1105
const int DECAY_FOOD_FRVG_DRIED_CHANCE
Определения 3_Game/DayZ/constants.c:1104
const float DECAY_FOOD_RAW_MEAT
Определения 3_Game/DayZ/constants.c:1095
const float DECAY_FOOD_BAKED_MEAT
Определения 3_Game/DayZ/constants.c:1100
const float DECAY_FOOD_BOILED_MEAT
Определения 3_Game/DayZ/constants.c:1098
const float DECAY_FOOD_BOILED_FRVG
Определения 3_Game/DayZ/constants.c:1099
const float DECAY_FOOD_DRIED_MEAT
Определения 3_Game/DayZ/constants.c:1102
const float DECAY_FOOD_RAW_CORPSE
Определения 3_Game/DayZ/constants.c:1096
const float DECAY_RATE_ON_PLAYER
Определения 3_Game/DayZ/constants.c:1106
static const float TEMPERATURE_THAW_TIME_COEF_BURNED
Определения 3_Game/DayZ/constants.c:998
static const float TEMPERATURE_FREEZE_TIME_COEF_BURNED
Определения 3_Game/DayZ/constants.c:997
static const float TEMPERATURE_THAW_TIME_COEF_DRIED
Определения 3_Game/DayZ/constants.c:999
static const float TEMPERATURE_FREEZE_TIME_COEF_DRIED
Определения 3_Game/DayZ/constants.c:996
const int STATE_HOT_LVL_TWO
Определения 3_Game/DayZ/constants.c:947
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
EmitorParam
Определения EnVisual.c:114
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:486
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.