File size: 3,858 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//-----------------------------
// ANIMAL BLEEDING
//-----------------------------
/*
Animal bleeding is handled by this component.
*/

class ComponentAnimalBleeding : Component
{
	// Member variables
	protected ref Timer m_BleedTimer;
	protected const float BASE_BLEED_RATE = 250;
	protected const float PASS_OUT_AMOUT = 500;

	// Constructor
	void ComponentAnimalBleeding()
	{
		
	}
	
	void InflictWoundDamage( TotalDamageResult damage_result, string zone_name, string ammo )
	{
		if ( ammo == "MeleeWolf")
		{
			m_ThisEntityAI.SetHealth( "", "", 0 );
		}	
		
		if ( !zone_name )
			return;
		
		float health_damage_inflicted = damage_result.GetDamage( zone_name, "Health");
		//float blood_damage_inflicted = damage_result.GetDamage( zone_name, "Blood");	
		float wound_healt_damage = health_damage_inflicted;
		//float wound_blood_damage = health_damage_inflicted;
		
		m_ThisEntityAI.DecreaseHealth( "", "Health", wound_healt_damage );
		//m_ThisEntityAI.DecreaseHealth( "", "Blood", wound_blood_damage );
		
		if ( zone_name != "" )
		{
			m_ThisEntityAI.DecreaseHealth( zone_name, "Health", wound_healt_damage );
			//m_ThisEntityAI.DecreaseHealth( zone_name, "Blood", wound_blood_damage );
		}	
		
		//Print("Zone hit: " + zone_name );
		
		//Print("damage_result Health: " + damage_result.GetDamage( zone_name, "Health" ) );
		//Print("damage_result Blood: " + damage_result.GetDamage( zone_name, "Blood" ) );
	}
	
	void CreateWound( TotalDamageResult damage_result, string zone_name, string ammo )
	{
		//Print( "GetHealth Health before creating wound@: " + zone_name + " " + m_ThisEntityAI.GetHealth( zone_name, "Health" ));
		InflictWoundDamage( damage_result, zone_name, ammo );
		//Print( "GetHealth Health after creating wood@: " + zone_name + " " + m_ThisEntityAI.GetHealth( zone_name, "Health" ));
		
		float can_bleed = false; //= GetGame().ConfigGetFloat( "CfgVehicles " + m_ThisEntityAI.GetType() + " DamageSystem " + "DamageZones " + zone_name + " canBleed" );
		//Print("can_bleed: " + can_bleed );
		float bleed_treshold = 0; //= GetGame().ConfigGetFloat( "CfgAmmo " + ammo + " DamageApplied " + "bleedThreshold" );
		//Print("bleed_treshold: " + bleed_treshold );
		float chance = -1; //Math.RandomFloat01();
		//Print("chance: " + chance );
		
		//Print( "GetHealth Health @: " + m_ThisEntityAI.GetHealth( zone_name, "Health" ));
		//Print( "GetHealth Blood @: " + m_ThisEntityAI.GetHealth( zone_name, "Blood" ));
		//Print( "GetHealth Shock @: " + m_ThisEntityAI.GetHealth( zone_name, "Shock" ));
		
		if ( can_bleed && chance <= bleed_treshold )
		{
			m_BleedTimer = new Timer();
			float wound_intensity = GetWoundIntensity( bleed_treshold );
			//Print("wound_intensity: " + wound_intensity);
			m_BleedTimer.Run( 1, this, "Bleed", new Param1<float>( wound_intensity ), true ); 
		}
		/*
		else
		{
			Print("Not bleeding");
		}
		*/
	}

	void Bleed( float wound_intensity )
	{
		if ( m_ThisEntityAI.IsAlive() )
		{
			float bleeding_intensity = BASE_BLEED_RATE * wound_intensity;
			//Print("bleeding_intensity: " + bleeding_intensity);
			float global_blood_lvl = m_ThisEntityAI.GetHealth( "", "Blood" );

			m_ThisEntityAI.DecreaseHealth( "", "Blood", bleeding_intensity );

			if ( global_blood_lvl < PASS_OUT_AMOUT )
			{
				m_ThisEntityAI.SetHealth( "", "", 0 );
				//Print("global_blood_lvl < PASS_OUT_AMOUT => Zabijam zviera.");	
			}
			
			//Print( "GetHealth Global Health: " + m_ThisEntityAI.GetHealth( "", "Health" ));
			//Print( "GetHealth Global Blood: " + m_ThisEntityAI.GetHealth( "", "Blood" ));
			//Print( "GetHealth Global Shock: " + m_ThisEntityAI.GetHealth( "", "Shock" ));
			
		}
		else
		{
			m_BleedTimer.Stop();	
			//Print("Vypinam timer.");		
		}
	}

	float GetWoundIntensity( float bleed_treshold )
	{
		//higher the bleeding treshold => more intense bleeding
		return bleed_treshold * 2;
	}
}