Ejemplo n.º 1
0
	public string[] customVar = { "", "" };					// when param0/1 = 5 or 8

	public ValueModifier Copy()
	{
		ValueModifier v = new ValueModifier();
		v.resultToValue = this.resultToValue;
		v.param = new int[] { this.param[0], this.param[1] };
		v.attribId = new GUID[] { this.attribId[0].Copy(), this.attribId[1].Copy() };
		v.numVal = new NumericValue[] { this.numVal[0].Copy(), this.numVal[1].Copy() };
		v.doWhatToParams = this.doWhatToParams;
		v.customVar = this.customVar;
		return v;
	}
Ejemplo n.º 2
0
	private float ApplyValueMod(ValueModifier mod, float value, Actor a1, Actor a2, UniqueMonoBehaviour ub1, UniqueMonoBehaviour ub2, GameObject self, GameObject targeted, GameObject selfTargetedBy, GameObject equipTarget, GameObject helper)
	{
		if (mod.param[0] == 0 && mod.param[1] == 0) return value; // nothing to do

		float v = 0f;
		float v1 = 0f;
		float v2 = 0f;

		if (mod.param[0] > 0)
		{	// get value from param 1; 0: Not Used, 1:Numeric, 2:Value, 3:level(1), 4:attribute(1), 5:CustomVar(1), 6:level(2), 7:attribute(2), 8:CustomVar(2)

			if (mod.param[0] == 1) v1 = mod.numVal[0].Value(self, targeted, selfTargetedBy, equipTarget, helper);
			else if (mod.param[0] == 2) v1 = value;
			else if (mod.param[0] == 3) v1 = a1.ActorClass.Level;
			else if (mod.param[0] == 4)
			{
				RPGAttribute att = a1.ActorClass.GetAttribute(mod.attribId[0]);
				if (att != null) v1 = att.Value;
				else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Subject.");
			}
			else if (mod.param[0] == 5)
			{
				if (ub1 != null)
				{
					if (false == float.TryParse(ub1.GetCustomVariable(mod.customVar[0]), out v1))
					{
						Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Subject or has invalid value.");
					}
				}
				else Debug.LogError("Attribute Action Error: Subject does not support custom variables.");
			}
			else
			{
				if (mod.param[0] == 6 || mod.param[0] == 7)
				{
					if (a2 != null)
					{
						if (mod.param[0] == 6) v1 = a2.ActorClass.Level;
						else if (mod.param[0] == 7)
						{
							RPGAttribute att = a2.ActorClass.GetAttribute(mod.attribId[0]);
							if (att != null) v1 = att.Value;
							else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Aggressor.");
						}
					}
					else Debug.LogError("Attribute Action Error: Aggressor is not an Actor.");
				}
				else if (mod.param[0] == 8)
				{
					if (ub2 != null)
					{
						if (false == float.TryParse(ub2.GetCustomVariable(mod.customVar[0]), out v1))
						{
							Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Aggressor or has invalid value.");
						}
					}
					else Debug.LogError("Attribute Action Error: Aggressor does not support custom variables.");
				}				
			}			
		}

		if (mod.param[1] > 0)
		{	// get value from param 2; 0: Not Used, 1:Numeric, 2:Value, 3:level(1), 4:attribute(1), 5:CustomVar(1), 6:level(2), 7:attribute(2), 8:CustomVar(2)

			if (mod.param[1] == 1) v2 = mod.numVal[1].Value(self, targeted, selfTargetedBy, equipTarget, helper);
			else if (mod.param[1] == 2) v2 = value;
			else if (mod.param[1] == 3) v2 = a1.ActorClass.Level;
			else if (mod.param[1] == 4)
			{
				RPGAttribute att = a1.ActorClass.GetAttribute(mod.attribId[1]);
				if (att != null) v2 = att.Value;
				else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Subject.");
			}
			else if (mod.param[1] == 5)
			{
				if (ub1 != null)
				{
					if (false == float.TryParse(ub1.GetCustomVariable(mod.customVar[0]), out v1))
					{
						Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Subject or has invalid value.");
					}
				}
				else Debug.LogError("Attribute Action Error: Subject does not support custom variables.");
			}
			else
			{
				if (mod.param[1] == 6 || mod.param[1] == 7)
				{
					if (a2 != null)
					{
						if (mod.param[1] == 6) v2 = a2.ActorClass.Level;
						else if (mod.param[1] == 7)
						{
							RPGAttribute att = a2.ActorClass.GetAttribute(mod.attribId[1]);
							if (att != null) v2 = att.Value;
							else Debug.LogError("Attribute Action Error: Modifier Attribute not found on Aggressor.");
						}
					} else Debug.LogError("Attribute Action Error: Aggressor is not an Actor.");
				}
				else if (mod.param[1] == 8)
				{
					if (ub2 != null)
					{
						if (false == float.TryParse(ub2.GetCustomVariable(mod.customVar[1]), out v2))
						{
							Debug.LogError("Attribute Action Error: Modifier Custom Variable not found on Aggressor or has invalid value.");
						}
					}
					else Debug.LogError("Attribute Action Error: Aggressor does not support custom variables.");
				}
			}
		}

		if (mod.param[0] == 0) v = v2;
		if (mod.param[1] == 0) v = v1;

		if (mod.param[0] > 0 && mod.param[1] > 0)
		{	// apply math to param1 and 2 if applicable; 0:add, 1:sub, 2:div, 3:multiply
			if (mod.doWhatToParams == 0) v = v1 + v2;
			else if (mod.doWhatToParams == 1) v = v1 - v2;
			else if (mod.doWhatToParams == 2) v = v1 / v2;
			else if (mod.doWhatToParams == 3) v = v1 * v2;
			else if (mod.doWhatToParams == 4) v = v1 % v2;
		}

		// apply to value, // 0:add, 1:sub, 2:div, 3:multiply
		if (mod.resultToValue == 0) value = value + v;
		else if (mod.resultToValue == 1) value = value - v;
		else if (mod.resultToValue == 2) value = value / v;
		else if (mod.resultToValue == 3) value = value * v;
		else if (mod.resultToValue == 4) value = value % v;

		return value;
	}