Example #1
0
		public void mod_AdjustDamageDealt(GameObject enemy, DamageInfo damage, bool testing) {
			if (IEModOptions.DisableFriendlyFire && gameObject && enemy?.GetComponent<Faction>()?.IsFriendly(gameObject) == true && base.IsPartyMember) {
				damage.IsCriticalHit = damage.Interrupts = damage.IsGraze =damage.IsKillingBlow = false;
				damage.IsMiss = true;
				return;
			}
			orig_AdjustDamageDealt(enemy, damage, testing);
		}
Example #2
0
		public static bool FriendlyRightNowAndAlsoWhenConfused(GameObject target, GameObject caster) {
			var targetFaction = target?.GetComponent<Faction>();
			var casterFaction = caster?.GetComponent<Faction>();
			var targetAiController = GameUtilities.FindActiveAIController(target);
			if (IEModOptions.TargetTurnedEnemies && targetAiController != null && casterFaction != null) {
				var targetOriginallyFriendly = targetAiController.GetOriginalTeam()?.GetRelationship(casterFaction.CurrentTeam)
					== Faction.Relationship.Friendly;
				if (!targetOriginallyFriendly) {
					return false;
				}
			}
			return targetFaction?.IsFriendly(caster) == true || casterFaction?.IsFriendly(target) == true;
		}
Example #3
0
		public bool mod_CanActivate(GameObject victim) {
			if (!this.m_trap_initialized)
			{
				Debug.LogError("Cannot activate uninitialized trap!");
				return false;
			}
			if (IEModOptions.DisableFriendlyFire) {
				Faction victimFaction = victim?.GetComponent<Faction>();
				if (victimFaction?.isPartyMember == true && this.IsPlayerOwnedTrap)
				{
					return false;
				}
			}
			return orig_CanActivate(victim);
		}
Example #4
0
		public static bool HostileEvenIfConfused(GameObject target, GameObject caster) {
			var targetFaction = target?.GetComponent<Faction>();
			var casterFaction = caster?.GetComponent<Faction>();
			var targetAiController = GameUtilities.FindActiveAIController(target);
			if (targetFaction?.IsHostile(caster) == true || casterFaction?.IsHostile(target) == true) {
				//they're actually hostile
				return true;
			}
			if (targetAiController == null) {
				//not AI controller. Can never be confused.
				return false;
			}
			if (!IEModOptions.TargetTurnedEnemies) {
				//no more checks if the option is disabled.
				return false;
			}
		
			var targetOriginal = targetAiController.GetOriginalTeam()?.GetRelationship(casterFaction?.CurrentTeam)
				== Faction.Relationship.Hostile;

			return targetOriginal;
		}