summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/AttackApplyStun.cs
blob: c9c1d808b9fa701ef6c41849f6bd6c774396fed2 (plain)
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
using System;
using XUtliPoolLib;

namespace XMainClient
{
	internal class AttackApplyStun : AttackApplyState
	{
		public override int GetStateMask()
		{
			return XFastEnumIntEqualityComparer<DamageFlag>.ToInt(DamageFlag.DMGFLAG_STUN);
		}

		public override bool IsApplyState(XEntity entity)
		{
			XAttributes attributes = entity.Attributes;
			double attr = attributes.GetAttr(XAttributeDefine.XAttr_Stun_Total);
			CombatParamTable.RowData combatParam = XSingleton<XCombat>.singleton.GetCombatParam(attributes.Level);
			double num = attr / (attr + (double)combatParam.StunBase);
			bool flag = num > XSingleton<XGlobalConfig>.singleton.StunLimit;
			if (flag)
			{
				num = XSingleton<XGlobalConfig>.singleton.StunLimit;
			}
			float num2 = XSingleton<XCommon>.singleton.RandomFloat(0f, 1f);
			return (double)num2 < num;
		}

		public override bool IsDefenseState(XEntity entity)
		{
			XAttributes attributes = entity.Attributes;
			double attr = attributes.GetAttr(XAttributeDefine.XAttr_StunResist_Total);
			CombatParamTable.RowData combatParam = XSingleton<XCombat>.singleton.GetCombatParam(attributes.Level);
			double num = attr / (attr + (double)combatParam.StunResistBase);
			bool flag = num > XSingleton<XGlobalConfig>.singleton.StunResistLimit;
			if (flag)
			{
				num = XSingleton<XGlobalConfig>.singleton.StunResistLimit;
			}
			float num2 = XSingleton<XCommon>.singleton.RandomFloat(0f, 1f);
			return (double)num2 < num;
		}

		public override void ApplyState(XEntity caster, ProjectDamageResult result)
		{
			result.SetResult(ProjectResultType.PJRES_STUN);
		}
	}
}