protected override void UnloadData() { if (ShieldApiLoaded) { SApi.Unload(); } if (WeaponCoreLoaded) { WeaponCore.Unload(); } if (MESApi.MESApiReady) { MESApi.UnregisterListener(); } if (WaterMod.Registered) { WaterMod.Unregister(); WaterMod.OnRegisteredEvent -= WaterLogged; WaterMod.WaterCreatedEvent -= WaterHelper.WaterAdded; WaterMod.WaterRemovedEvent -= WaterHelper.WaterRemoved; } DebugTerminalControls.RegisterControls(false); Instance = null; SyncManager.Close(); DamageHelper.UnregisterEntityWatchers(); BehaviorManager.Behaviors.Clear(); EntityWatcher.UnregisterWatcher(); }
public override void Execute() { ItemUsage(); if (Settings.UseQ && Q.IsReady()) { Q.Cast(); } if (Settings.UseW && W.IsReady()) { var target = TargetSelector.GetTarget(W.Range - 50, DamageType.Physical); if (target != null && target.IsValidTarget()) { if ((Settings.UseW && !Player.Instance.HasBuff("TwitchFullAutomatic")) || (Settings.UseWUlt && Player.Instance.HasBuff("TwitchFullAutomatic"))) { var predW = W.GetPrediction(target); W.Cast(predW.CastPosition); } } } if (Settings.UseE && E.IsReady()) { var target = TargetSelector.GetTarget(E.Range, DamageType.Physical); if (target != null && target.IsValidTarget() && target.Health < DamageHelper.GetEDamage(target)) { E.Cast(); } } if (Settings.UseR && R.IsReady() && Player.Instance.CountEnemiesInRange(850) >= Settings.NumberR) { R.Cast(); } }
public override void BeforeStart() { if (MyAPIGateway.Session.SessionSettings.EnableSelectivePhysicsUpdates && MyAPIGateway.Utilities.IsDedicated) { Logger.WriteLog("WARNING: Selective Physics Updates World Option Detected with RivalAI."); if (MyAPIGateway.Session.SessionSettings.SyncDistance < 10000) { Logger.WriteLog("Mod Disabled."); Logger.WriteLog("Sync Distance Must Be Set to 10000m or Higher for RivalAI to Function with Selective Physics Updates enabled."); Logger.WriteLog("Please Adjust World Settings and Restart Server."); RivalAiEnabled = false; return; } Logger.WriteLog("Encounters Using RivalAI May Not Work Correctly Outside of 10000m Sync Distance with Selective Physics Updates enabled."); Logger.WriteLog("Consider Increasing Sync Distnace if you Encounter Issues Outside Your Current Sync Distance Range."); } if (!MyAPIGateway.Multiplayer.IsServer) { return; } DebugTerminalControls.RegisterControls(); //TODO: Register Shield and WeaponCore APIs try { Logger.WriteLog("Defense Shields API Loading"); if (ShieldMod && !ShieldApiLoaded) { SApi.Load(); } } catch (Exception exc) { Logger.WriteLog("Defense Shields API Failed To Load"); Logger.WriteLog(exc.ToString()); } try { if (WeaponCoreMod && !Instance.WeaponCore.IsReady) { Logger.WriteLog("WeaponCore API Loading"); WeaponCore.Load(WcApiCallback, true); } else { Logger.WriteLog("WeaponCore API Failed To Load For Unknown Reason"); } } catch (Exception exc) { Logger.WriteLog("WeaponCore API Failed To Load"); Logger.WriteLog(exc.ToString()); } Logger.LoadDebugFromSandbox(); Utilities.GetDefinitionsAndIDs(); TagHelper.Setup(); DamageHelper.RegisterEntityWatchers(); }
// On particle collision void OnParticleCollision(GameObject other) { int safeLength = ParticlePhysicsExtensions.GetSafeCollisionEventSize(ps); if (collisionEvents.Length < safeLength) { collisionEvents = new ParticleCollisionEvent[safeLength]; } int numCollisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(ps, other, collisionEvents); // Play collision sound and apply force to the rigidbody was hit int i = 0; while (i < numCollisionEvents) { //F3DAudioController.instance.ShotGunHit(collisionEvents[i].intersection); Rigidbody rb = other.GetComponent <Rigidbody>(); if (rb) { Vector3 pos = collisionEvents[i].intersection; Vector3 force = collisionEvents[i].velocity.normalized * 50f; rb.AddForceAtPosition(force, pos); DamageHelper.MakeDamage(other, DamageType.Kinetik, DamageValues.ShotGun); other.SendMessage("Shatter", pos, SendMessageOptions.DontRequireReceiver); } i++; } }
public override void Update(long gameTime, NamelessGame namelessGame) { while (namelessGame.Commander.DequeueCommand(out AttackCommand ac)) { var random = new InternalRandom(); var source = ac.getSource(); var stats = source.GetComponentOfType <Stats>(); //TODO: attack damage based on stats, equipment etc. int damage = stats.Attack.Value; DamageHelper.ApplyDamage(ac.getTarget(), ac.getSource(), damage); Description targetDescription = ac.getTarget().GetComponentOfType <Description>(); Description sourceDescription = ac.getSource().GetComponentOfType <Description>(); if (targetDescription != null && sourceDescription != null) { var logCommand = new HudLogMessageCommand(); namelessGame.Commander.EnqueueCommand(logCommand); logCommand.LogMessage += (sourceDescription.Name + " deals " + (damage) + " damage to " + targetDescription.Name); //namelessGame.WriteLineToConsole; } } }
private void CalculateDamages(Mech attacker, AbstractActor target) { Mod.MeleeLog.Info?.Write($"Calculating DFA damage for attacker: {CombatantUtils.Label(attacker)} " + $"vs. target: {CombatantUtils.Label(target)}"); float targetTonnage = 0; if (target is Vehicle vehicle) { targetTonnage = vehicle.tonnage; } else if (target is Mech mech) { targetTonnage = mech.tonnage; } else if (target is Turret turret) { targetTonnage = turret.MeleeTonnage(); } Mod.MeleeLog.Info?.Write($" - Tonnage => Attacker: {attacker.tonnage} Target: {targetTonnage}"); // split attacker damage into clusters float attackerDamage = attacker.DFAAttackerDamage(targetTonnage); attackerDamage = attacker.ApplyDFADamageReduction(attackerDamage); DamageHelper.ClusterDamage(attackerDamage, Mod.Config.Melee.DFA.DamageClusterDivisor, out this.AttackerDamageClusters); // split target damage into clusters float targetDamage = attacker.DFATargetDamage(); targetDamage = target.ApplyDFADamageReduction(targetDamage); DamageHelper.ClusterDamage(targetDamage, Mod.Config.Melee.DFA.DamageClusterDivisor, out this.TargetDamageClusters); }
private void CalculateDamages(Mech attacker, AbstractActor target, int hexesMoved) { Mod.MeleeLog.Info?.Write($"Calculating CHARGE damage for attacker: {CombatantUtils.Label(attacker)} " + $"vs. target: {CombatantUtils.Label(target)} at hexesMoved: {hexesMoved}"); float targetTonnage = 0; if (target is Vehicle vehicle) { targetTonnage = vehicle.tonnage; } else if (target is Mech mech) { targetTonnage = mech.tonnage; } else if (target is Turret turret) { targetTonnage = turret.MeleeTonnage(); } Mod.MeleeLog.Info?.Write($" - Tonnage => Attacker: {attacker.tonnage} Target: {targetTonnage}"); // Calculate attacker damage float attackerDamage = attacker.ChargeAttackerDamage(targetTonnage); attackerDamage = attacker.ApplyChargeDamageReduction(attackerDamage); DamageHelper.ClusterDamage(attackerDamage, Mod.Config.Melee.Charge.DamageClusterDivisor, out this.AttackerDamageClusters); // Resolve target damage - include movement! float targetDamage = attacker.ChargeTargetDamage(hexesMoved); targetDamage = target.ApplyChargeDamageReduction(targetDamage); DamageHelper.ClusterDamage(targetDamage, Mod.Config.Melee.Charge.DamageClusterDivisor, out this.TargetDamageClusters); }
public void Setup() { helper = new AttackHelper(); damageHelper = new DamageHelper(); collectionSelector = GetNewInstanceOf <ICollectionSelector>(); featsSelector = GetNewInstanceOf <IFeatsSelector>(); creatureDataSelector = GetNewInstanceOf <ICreatureDataSelector>(); }
public SpecialAbilitiesGenerator(ICollectionSelector collectionsSelector, ITreasurePercentileSelector percentileSelector, ISpecialAbilityDataSelector specialAbilityDataSelector) { this.collectionsSelector = collectionsSelector; this.percentileSelector = percentileSelector; this.specialAbilityDataSelector = specialAbilityDataSelector; damageHelper = new DamageHelper(); }
public virtual void TakeDamage(DamageType damageType, float damage) { LifeLevel -= DamageHelper.CalculateDamage(damageType, damage, CurObjMaterial); if (LifeLevel <= 0f && !_isDemolition) { _isDemolition = true; Demolition(); } }
private void KsE() { if (Config.Modes.KillSteal.KsE) { if (EntityManager.Heroes.Enemies.Any(c => Player.Instance.Position.IsInRange(c.Position, SpellManager.E.Range) && c.IsValidTarget() && c.Health < DamageHelper.GetEDamage(c))) { E.Cast(); } } }
private void EFullStacks() { if (Config.Modes.KillSteal.EFullStacks) { if (EntityManager.Heroes.Enemies.Any(c => Player.Instance.Position.IsInRange(c.Position, SpellManager.E.Range) && c.IsValidTarget() && DamageHelper.getEStacks(c) >= Config.Modes.KillSteal.ENumberstacks)) { E.Cast(); } } }
private void EBaronDragon() { if (Config.Modes.Clear.EBaronDragon) { if (EntityManager.MinionsAndMonsters.Monsters.Any(c => Player.Instance.Position.IsInRange(c.Position, SpellManager.E.Range) && (c.BaseSkinName.Contains("Dragon") || c.BaseSkinName.Contains("Baron") || c.BaseSkinName.Contains("Herald")) && c.Health < DamageHelper.GetEDamage(c))) { E.Cast(); } } }
public override void Execute() { var minion = EntityManager.MinionsAndMonsters.GetLaneMinions(EntityManager.UnitTeam.Enemy, Player.Instance.ServerPosition, E.Range, false); if (Settings.WLaneClear && W.IsReady() && Player.Instance.ManaPercent > Settings.LaneClearMana) { foreach (var hitableminion in minion) { var collision = new List <Obj_AI_Minion>(); var startPos = Player.Instance.Position.To2D(); var endPos = hitableminion.Position.To2D(); collision.Clear(); foreach ( var colliMinion in EntityManager.MinionsAndMonsters.EnemyMinions.Where( colliMinion => colliMinion.IsInRange(hitableminion, W.Range) && colliMinion.IsValidTarget(W.Range)) ) { if (Prediction.Position.Collision.CircularMissileCollision(colliMinion, startPos, endPos, SpellManager.W.Speed, SpellManager.W.Width, SpellManager.W.CastDelay)) { collision.Add(colliMinion); } if (collision.Count >= Settings.WNumber) { W.Cast(hitableminion); } } } } if (Settings.ELaneClear && E.IsReady() && Player.Instance.ManaPercent > Settings.LaneClearMana) { var kill = 0; foreach (var killableminion in minion) { if (kill >= Settings.ENumber) { E.Cast(); break; } if (killableminion.Health < DamageHelper.GetEDamage(killableminion)) { kill++; } } } }
public void _export_to_target_damage(EntityExportToTargetData data, EntityBlackBoard blackboard) { if (data == null || blackboard == null) { return; } BaseEntity entity = blackboard.entity; target_list = blackboard.GetValue <List <BaseEntity> >(EntityBlackBoardConst.TARGET_LIST); int length = target_list.Count; for (int i = 0; i < length; i++) { DamageHelper.ExportDamageToTarget(entity, target_list[i], 10); ActionLog.Log("对目标:[{0}]造成[{1}]点伤害", target_list[i].ToDes(), data.damage); } target_list.Clear(); }
private void Explosion() { Instantiate(ExlosionPrefab, transform.position, new Quaternion(0f, 0f, 0f, 0f)); Vector3 explosionPos = transform.position; Collider[] colliders = Physics.OverlapSphere(explosionPos, ExplosionRadius); foreach (Collider hit in colliders) { Rigidbody rb = hit.GetComponent <Rigidbody>(); if (rb == null) { continue; } float distance = Vector3.Distance(hit.transform.position, transform.position); if (distance < ExplosionRadius) { float curDamage = DamageValues.Explosion - ((DamageValues.Explosion / ExplosionRadius) * distance); // Try to make Damage: DamageHelper.MakeDamage(hit.gameObject, DamageType.Explosion, curDamage); if (hit.GetComponent <ShatterTool>() is ShatterTool) { Mesh mesh = hit.gameObject.GetComponent <MeshFilter>().mesh; Vector3[] vertices = mesh.vertices; for (var i = 0; i < vertices.Length; i++) { var spawnPoint = transform.TransformPoint(vertices[i]); var q = Random.Range(0, vertices.Length); spawnPoint = transform.TransformPoint(vertices[q]); hit.gameObject.SendMessage("Shatter", spawnPoint, SendMessageOptions.DontRequireReceiver); } } } rb.AddExplosionForce(ExplosionPower, explosionPos, ExplosionRadius, 1.0f); } Invoke("DestroyThis", 0.1f); }
public override void BeforeStart() { if (!MyAPIGateway.Multiplayer.IsServer) { return; } //TODO: Register Shield and WeaponCore APIs try { Logger.WriteLog("Defense Shields API Loading"); if (ShieldMod && !ShieldApiLoaded) { SApi.Load(); } } catch (Exception exc) { Logger.WriteLog("Defense Shields API Failed To Load"); Logger.WriteLog(exc.ToString()); } try { if (WeaponCoreMod && !Instance.WeaponCore.IsReady) { Logger.WriteLog("WeaponCore API Loading"); WeaponCore.Load(WcApiCallback, true); } else { Logger.WriteLog("WeaponCore API Failed To Load For Unknown Reason"); } } catch (Exception exc) { Logger.WriteLog("WeaponCore API Failed To Load"); Logger.WriteLog(exc.ToString()); } Logger.LoadDebugFromSandbox(); Utilities.GetDefinitionsAndIDs(); TagHelper.Setup(); DamageHelper.RegisterEntityWatchers(); }
public static AttackSelection From(string rawData) { var helper = new AttackHelper(); var data = helper.ParseEntry(rawData); var selection = new AttackSelection(); selection.IsMelee = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsMeleeIndex]); selection.IsNatural = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsNaturalIndex]); selection.IsPrimary = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsPrimaryIndex]); selection.IsSpecial = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsSpecialIndex]); selection.Name = data[DataIndexConstants.AttackData.NameIndex]; selection.DamageEffect = data[DataIndexConstants.AttackData.DamageEffectIndex]; selection.DamageBonusMultiplier = Convert.ToDouble(data[DataIndexConstants.AttackData.DamageBonusMultiplierIndex]); selection.FrequencyQuantity = Convert.ToInt32(data[DataIndexConstants.AttackData.FrequencyQuantityIndex]); selection.FrequencyTimePeriod = data[DataIndexConstants.AttackData.FrequencyTimePeriodIndex]; selection.Save = data[DataIndexConstants.AttackData.SaveIndex]; selection.SaveAbility = data[DataIndexConstants.AttackData.SaveAbilityIndex]; selection.AttackType = data[DataIndexConstants.AttackData.AttackTypeIndex]; selection.SaveDcBonus = Convert.ToInt32(data[DataIndexConstants.AttackData.SaveDcBonusIndex]); var damageHelper = new DamageHelper(); var damageEntries = damageHelper.ParseEntries(data[DataIndexConstants.AttackData.DamageDataIndex]); foreach (var damageData in damageEntries) { var damage = new Damage { Roll = damageData[DataIndexConstants.AttackData.DamageData.RollIndex], Type = damageData[DataIndexConstants.AttackData.DamageData.TypeIndex], Condition = damageData[DataIndexConstants.AttackData.DamageData.ConditionIndex], }; selection.Damages.Add(damage); } return(selection); }
protected override void UnloadData() { if (ShieldApiLoaded) { SApi.Unload(); } if (WeaponCoreLoaded) { WeaponCore.Unload(); } if (MESApi.MESApiReady) { MESApi.UnregisterListener(); } Instance = null; SyncManager.Close(); DamageHelper.UnregisterEntityWatchers(); BehaviorManager.Behaviors.Clear(); EntityWatcher.UnregisterWatcher(); }
public void Attack(Unit target, float dmgBaseValue, int dmgType, int dmgFlag = 0) { if (target.dead) { return; } // -- 0 var dmg = DamageHelper.CreatDamage(dmgBaseValue, dmgType, dmgFlag); dmg.unitId = target.uid; // -- 0 this.OnAttackModifier(dmg, target); // -- 1 target.TakeDamage(dmg, this); // -- 2 this.OnAttackFeedback(dmg, target); // -- 3 if (target.dead) { this.OnKill(dmg, target); } // -- 4 this.battle.recorder.PushDamage(dmg); }
private void EBigMinion() { if (Config.Modes.Clear.EBigMinion) { if (EntityManager.MinionsAndMonsters.EnemyMinions.Any(c => Player.Instance.Position.IsInRange(c.Position, SpellManager.E.Range) && (c.BaseSkinName.Contains("Siege") || c.BaseSkinName.Contains("Super")) && c.IsValid && c.Health < DamageHelper.GetEDamage(c))) { E.Cast(); } } }
public void Setup() { selection = new AttackSelection(); attackHelper = new AttackHelper(); damageHelper = new DamageHelper(); }
public void Setup() { helper = new AttackHelper(); damageHelper = new DamageHelper(); }
public void Setup() { mockInnerSelector = new Mock <ICollectionSelector>(); weaponDataSelector = new WeaponDataSelector(mockInnerSelector.Object); damageHelper = new DamageHelper(); }
public void ProcessAction(TriggerProfile trigger, ActionProfile actions, long attackerEntityId = 0, long detectedEntity = 0, Command command = null) { Logger.MsgDebug(trigger.ProfileSubtypeId + " Attempting To Execute Action Profile " + actions.ProfileSubtypeId, DebugTypeEnum.Action); if (actions.Chance < 100) { var roll = Utilities.Rnd.Next(0, 101); if (roll > actions.Chance) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Did Not Pass Chance Check", DebugTypeEnum.Action); return; } } Logger.MsgDebug(actions.ProfileSubtypeId + ": Performing Eligible Actions", DebugTypeEnum.Action); //ChatBroadcast if (actions.UseChatBroadcast == true) { foreach (var chatData in actions.ChatData) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Chat Broadcast", DebugTypeEnum.Action); _broadcast.BroadcastRequest(chatData); } } //BarrellRoll if (actions.BarrelRoll == true) { _behavior.AutoPilot.ActivateBarrelRoll(); } //Ramming if (actions.Ramming == true) { _behavior.AutoPilot.ActivateRamming(); } //Strafe - Implement Post Release if (actions.Strafe == true) { //_autopilot.ChangeAutoPilotMode(AutoPilotMode.Strafe); } //ChangeAutopilotSpeed if (actions.ChangeAutopilotSpeed == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Changing AutoPilot Speed To: " + actions.NewAutopilotSpeed.ToString(), DebugTypeEnum.Action); _autopilot.Data.IdealMaxSpeed = actions.NewAutopilotSpeed; var blockList = TargetHelper.GetAllBlocks(RemoteControl.SlimBlock.CubeGrid); foreach (var block in blockList.Where(x => x.FatBlock != null)) { var tBlock = block.FatBlock as IMyRemoteControl; if (tBlock != null) { tBlock.SpeedLimit = actions.NewAutopilotSpeed; } } } //SpawnReinforcements if (actions.SpawnEncounter == true) { foreach (var spawner in actions.Spawner) { if (spawner.UseSpawn) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Spawn", DebugTypeEnum.Spawn); if (spawner.IsReadyToSpawn()) { //Logger.AddMsg("Do Spawn", true); spawner.AssignInitialMatrix(RemoteControl.WorldMatrix); spawner.CurrentFactionTag = spawner.ForceSameFactionOwnership && !string.IsNullOrWhiteSpace(_owner.Faction?.Tag) ? _owner.Faction.Tag : ""; SpawnHelper.SpawnRequest(spawner); } } } } else { } //SelfDestruct if (actions.SelfDestruct == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting SelfDestruct", DebugTypeEnum.Action); var blockList = TargetHelper.GetAllBlocks(RemoteControl.SlimBlock.CubeGrid); int totalWarheads = 0; foreach (var block in blockList.Where(x => x.FatBlock != null)) { var tBlock = block.FatBlock as IMyWarhead; if (tBlock != null) { if (!actions.StaggerWarheadDetonation) { tBlock.IsArmed = true; tBlock.DetonationTime = 0; tBlock.Detonate(); totalWarheads++; } else { totalWarheads++; tBlock.IsArmed = true; tBlock.DetonationTime = (totalWarheads * actions.SelfDestructTimeBetweenBlasts) + actions.SelfDestructTimerPadding; tBlock.StartCountdown(); } } } //Logger.AddMsg("TotalBlocks: " + blockList.Count.ToString(), true); //Logger.AddMsg("TotalWarheads: " + totalWarheads.ToString(), true); //TODO: Shield EMP } //Retreat if (actions.Retreat) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Retreat", DebugTypeEnum.Action); _despawn.Retreat(); } //ForceDespawn if (actions.ForceDespawn) { _despawn.DespawnGrid(); } //TerminateBehavior if (actions.TerminateBehavior) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Termination Of Behavior", DebugTypeEnum.Action); _autopilot.ActivateAutoPilot(Vector3D.Zero, NewAutoPilotMode.None); _behavior.BehaviorTerminated = true; } //BroadcastGenericCommand if (actions.BroadcastGenericCommand == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Broadcast of Generic Command", DebugTypeEnum.Action); double sendRadius = 0; if (actions.SendCommandWithoutAntenna) { sendRadius = actions.SendCommandWithoutAntennaRadius; } else { var antenna = _behavior.Grid.GetAntennaWithHighestRange(); if (antenna != null) { sendRadius = antenna.Radius; } } if (sendRadius != 0) { var newCommand = new Command(); newCommand.CommandCode = actions.BroadcastSendCode; newCommand.RemoteControl = RemoteControl; newCommand.Radius = sendRadius; CommandHelper.CommandTrigger?.Invoke(newCommand); } } //BroadcastDamagerTarget if (actions.BroadcastDamagerTarget == true && detectedEntity != 0) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Broadcast of Damager", DebugTypeEnum.Action); double sendRadius = 0; if (actions.SendCommandWithoutAntenna) { sendRadius = actions.SendCommandWithoutAntennaRadius; } else { var antenna = _behavior.Grid.GetAntennaWithHighestRange(); if (antenna != null) { sendRadius = antenna.Radius; } } if (sendRadius != 0) { var newCommand = new Command(); newCommand.CommandCode = actions.BroadcastSendCode; newCommand.RemoteControl = RemoteControl; newCommand.Radius = sendRadius; newCommand.TargetEntityId = detectedEntity; CommandHelper.CommandTrigger?.Invoke(newCommand); } } //SwitchToReceivedTarget if (actions.SwitchToReceivedTarget == true && (command != null || detectedEntity != 0)) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Switch to Received Target Data", DebugTypeEnum.Action); long switchToId = 0; if (command != null && command.TargetEntityId != 0) { switchToId = command.TargetEntityId; } else if (detectedEntity != 0) { switchToId = detectedEntity; } IMyEntity tempEntity = null; if (MyAPIGateway.Entities.TryGetEntityById(switchToId, out tempEntity)) { _autopilot.Targeting.ForceTargetEntityId = switchToId; _autopilot.Targeting.ForceTargetEntity = tempEntity; _autopilot.Targeting.ForceRefresh = true; } } //SwitchToDamagerTarget if (actions.SwitchToDamagerTarget == true && detectedEntity != 0) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Switch to Damager Target Data", DebugTypeEnum.Action); _autopilot.Targeting.ForceTargetEntityId = detectedEntity; _autopilot.Targeting.ForceRefresh = true; } //SwitchToBehavior if (actions.SwitchToBehavior == true) { _behavior.ChangeBehavior(actions.NewBehavior, actions.PreserveSettingsOnBehaviorSwitch, actions.PreserveTriggersOnBehaviorSwitch, actions.PreserveTargetDataOnBehaviorSwitch); } //ChangePlayerCredits if (actions.ChangePlayerCredits && command != null && command.Type == CommandType.PlayerChat) { if (command.PlayerIdentity != 0) { var playerList = new List <IMyPlayer>(); MyAPIGateway.Players.GetPlayers(playerList, p => p.IdentityId == command.PlayerIdentity); foreach (var player in playerList) { long credits = 0; player.TryGetBalanceInfo(out credits); if (actions.ChangePlayerCreditsAmount > 0) { player.RequestChangeBalance(actions.ChangePlayerCreditsAmount); PaymentSuccessTriggered = true; } else { if (actions.ChangePlayerCreditsAmount > credits) { PaymentFailureTriggered = true; } else { player.RequestChangeBalance(actions.ChangePlayerCreditsAmount); PaymentSuccessTriggered = true; } } } } } //ChangeNpcFactionCredits if (actions.ChangeNpcFactionCredits) { IMyFaction faction = null; if (string.IsNullOrWhiteSpace(actions.ChangeNpcFactionCreditsTag)) { faction = _behavior.Owner.Faction; } else { faction = MyAPIGateway.Session.Factions.TryGetFactionByTag(actions.ChangeNpcFactionCreditsTag); } if (faction != null) { long credits = 0; faction.TryGetBalanceInfo(out credits); if (actions.ChangePlayerCreditsAmount > 0) { faction.RequestChangeBalance(actions.ChangePlayerCreditsAmount); PaymentSuccessTriggered = true; } else { if (actions.ChangePlayerCreditsAmount > credits) { PaymentFailureTriggered = true; } else { faction.RequestChangeBalance(actions.ChangePlayerCreditsAmount); PaymentSuccessTriggered = true; } } } } //RefreshTarget if (actions.RefreshTarget == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Target Refresh", DebugTypeEnum.Action); _autopilot.Targeting.ForceRefresh = true; } //ChangeTargetProfile if (actions.ChangeTargetProfile == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Target Profile Change", DebugTypeEnum.Action); _autopilot.Targeting.UseNewTargetProfile = true; _autopilot.Targeting.NewTargetProfileName = actions.NewTargetProfileId; } //ChangeReputationWithPlayers if (actions.ChangeReputationWithPlayers == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Reputation Change With Players In Radius", DebugTypeEnum.Action); OwnershipHelper.ChangeReputationWithPlayersInRadius(RemoteControl, actions.ReputationChangeRadius, actions.ReputationChangeAmount, actions.ReputationChangeFactions, actions.ReputationChangesForAllRadiusPlayerFactionMembers); } //ChangeAttackerReputation if (actions.ChangeAttackerReputation == true && detectedEntity != 0) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Reputation Change for Attacker", DebugTypeEnum.Action); OwnershipHelper.ChangeDamageOwnerReputation(actions.ChangeAttackerReputationFaction, detectedEntity, actions.ChangeAttackerReputationAmount, actions.ReputationChangesForAllAttackPlayerFactionMembers); } //TriggerTimerBlock if (actions.TriggerTimerBlocks == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Trigger of Timer Blocks", DebugTypeEnum.Action); var blockList = BlockHelper.GetBlocksWithNames(RemoteControl.SlimBlock.CubeGrid, actions.TimerBlockNames); foreach (var block in blockList) { var tBlock = block as IMyTimerBlock; if (tBlock != null) { tBlock.Trigger(); } } } //ChangeBlockNames if (actions.ChangeBlockNames) { _behavior.Grid.RenameBlocks(actions.ChangeBlockNamesFrom, actions.ChangeBlockNamesTo, actions.ProfileSubtypeId); } //ChangeAntennaRanges if (actions.ChangeAntennaRanges) { _behavior.Grid.SetGridAntennaRanges(actions.AntennaNamesForRangeChange, actions.AntennaRangeChangeType, actions.AntennaRangeChangeAmount); } //ChangeAntennaOwnership if (actions.ChangeAntennaOwnership == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Antenna Ownership Change", DebugTypeEnum.Action); OwnershipHelper.ChangeAntennaBlockOwnership(AntennaList, actions.AntennaFactionOwner); } //CreateKnownPlayerArea if (actions.CreateKnownPlayerArea == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Creation of Known Player Area in MES", DebugTypeEnum.Action); MESApi.AddKnownPlayerLocation(RemoteControl.GetPosition(), _owner.Faction?.Tag, actions.KnownPlayerAreaRadius, actions.KnownPlayerAreaTimer, actions.KnownPlayerAreaMaxSpawns, actions.KnownPlayerAreaMinThreatForAvoidingAbandonment); } //RemoveKnownPlayerLocation if (actions.RemoveKnownPlayerArea == true) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Removal of Known Player Area in MES", DebugTypeEnum.Action); MESApi.RemoveKnownPlayerLocation(RemoteControl.GetPosition(), _owner.Faction?.Tag, actions.RemoveAllKnownPlayerAreas); } //DamageAttacker if (actions.DamageToolAttacker == true && detectedEntity != 0) { Logger.MsgDebug(actions.ProfileSubtypeId + ": Attempting Damage to Tool User", DebugTypeEnum.Action); DamageHelper.ApplyDamageToTarget(attackerEntityId, actions.DamageToolAttackerAmount, actions.DamageToolAttackerParticle, actions.DamageToolAttackerSound); } //PlayParticleEffectAtRemote if (actions.PlayParticleEffectAtRemote == true) { EffectManager.SendParticleEffectRequest(actions.ParticleEffectId, RemoteControl.WorldMatrix, actions.ParticleEffectOffset, actions.ParticleEffectScale, actions.ParticleEffectMaxTime, actions.ParticleEffectColor); } //ResetCooldownTimeOfTriggers if (actions.ResetCooldownTimeOfTriggers) { foreach (var resetTrigger in Triggers) { if (actions.ResetTriggerCooldownNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; } } foreach (var resetTrigger in DamageTriggers) { if (actions.ResetTriggerCooldownNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; } } foreach (var resetTrigger in CommandTriggers) { if (actions.ResetTriggerCooldownNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; } } } //EnableTriggers if (actions.EnableTriggers) { Logger.MsgDebug(actions.ProfileSubtypeId + " Attempting To Enable Triggers.", DebugTypeEnum.Action); foreach (var resetTrigger in Triggers) { if (actions.EnableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = true; } } foreach (var resetTrigger in DamageTriggers) { if (actions.EnableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = true; } } foreach (var resetTrigger in CommandTriggers) { if (actions.EnableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = true; } } } //DisableTriggers if (actions.DisableTriggers) { Logger.MsgDebug(actions.ProfileSubtypeId + " Attempting To Disable Triggers.", DebugTypeEnum.Action); foreach (var resetTrigger in Triggers) { if (actions.DisableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = false; } } foreach (var resetTrigger in DamageTriggers) { if (actions.DisableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = false; } } foreach (var resetTrigger in CommandTriggers) { if (actions.DisableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = false; } } } //ManuallyActivateTrigger if (actions.ManuallyActivateTrigger) { Logger.MsgDebug(actions.ProfileSubtypeId + " Attempting To Manually Activate Triggers.", DebugTypeEnum.Action); foreach (var manualTrigger in Triggers) { if (actions.ManuallyActivatedTriggerNames.Contains(manualTrigger.ProfileSubtypeId)) { ProcessManualTrigger(manualTrigger, actions.ForceManualTriggerActivation); } } } //ChangeInertiaDampeners if (actions.ChangeInertiaDampeners) { RemoteControl.DampenersOverride = actions.InertiaDampenersEnable; } //ChangeRotationDirection if (actions.ChangeRotationDirection) { _behavior.Settings.SetRotation(actions.RotationDirection); } //GenerateExplosion if (actions.GenerateExplosion) { var coords = Vector3D.Transform(actions.ExplosionOffsetFromRemote, RemoteControl.WorldMatrix); DamageHelper.CreateExplosion(coords, actions.ExplosionRange, actions.ExplosionDamage, RemoteControl, actions.ExplosionIgnoresVoxels); } //GridEditable if (actions.GridEditable != CheckEnum.Ignore) { _behavior.Grid.SetGridEditable(RemoteControl.SlimBlock.CubeGrid, actions.GridEditable == CheckEnum.Yes); if (actions.SubGridsEditable != CheckEnum.Ignore) { foreach (var cubeGrid in MyAPIGateway.GridGroups.GetGroup(RemoteControl.SlimBlock.CubeGrid, GridLinkTypeEnum.Physical)) { _behavior.Grid.SetGridEditable(cubeGrid, actions.SubGridsEditable == CheckEnum.Yes); } } } //GridDestructible if (actions.GridDestructible != CheckEnum.Ignore) { _behavior.Grid.SetGridDestructible(RemoteControl.SlimBlock.CubeGrid, actions.GridDestructible == CheckEnum.Yes); if (actions.SubGridsDestructible != CheckEnum.Ignore) { foreach (var cubeGrid in MyAPIGateway.GridGroups.GetGroup(RemoteControl.SlimBlock.CubeGrid, GridLinkTypeEnum.Physical)) { _behavior.Grid.SetGridDestructible(cubeGrid, actions.SubGridsDestructible == CheckEnum.Yes); } } } //RecolorGrid if (actions.RecolorGrid) { _behavior.Grid.RecolorBlocks(RemoteControl.SlimBlock.CubeGrid, actions.OldBlockColors, actions.NewBlockColors, actions.NewBlockSkins); if (actions.RecolorSubGrids) { foreach (var cubeGrid in MyAPIGateway.GridGroups.GetGroup(RemoteControl.SlimBlock.CubeGrid, GridLinkTypeEnum.Physical)) { _behavior.Grid.RecolorBlocks(cubeGrid, actions.OldBlockColors, actions.NewBlockColors, actions.NewBlockSkins); } } } //Enable Blocks if (actions.EnableBlocks) { _behavior.Grid.EnableBlocks(actions.EnableBlockNames, actions.EnableBlockStates); } //BuildProjectedBlocks if (actions.BuildProjectedBlocks) { _behavior.Grid.BuildProjectedBlocks(actions.MaxProjectedBlocksToBuild); } //ChangeBlockOwnership if (actions.ChangeBlockOwnership) { BlockHelper.ChangeBlockOwnership(RemoteControl.SlimBlock.CubeGrid, actions.OwnershipBlockNames, actions.OwnershipBlockFactions); } //RazeBlocks if (actions.RazeBlocksWithNames) { _behavior.Grid.RazeBlocksWithNames(actions.RazeBlocksNames); } //ChangeAutoPilotProfile if (actions.ChangeAutopilotProfile) { _behavior.AutoPilot.SetAutoPilotDataMode(actions.AutopilotProfile); } //CreateRandomLightning if (actions.CreateRandomLightning) { if (_behavior.AutoPilot.InGravity() && _behavior.AutoPilot.CurrentPlanet.HasAtmosphere) { var up = Vector3D.Normalize(RemoteControl.GetPosition() - _behavior.AutoPilot.CurrentPlanet.PositionComp.WorldAABB.Center); var randomPerpendicular = MyUtils.GetRandomPerpendicularVector(ref up); var strikeCoords = _behavior.AutoPilot.CurrentPlanet.GetClosestSurfacePointGlobal(randomPerpendicular * MathTools.RandomBetween(actions.LightningMinDistance, actions.LightningMaxDistance) + RemoteControl.GetPosition()); DamageHelper.CreateLightning(strikeCoords, actions.LightningDamage, actions.LightningExplosionRadius, actions.LightningColor); } } //CreateLightningAtAttacker if (actions.CreateLightningAtAttacker && detectedEntity != 0) { if (_behavior.AutoPilot.InGravity() && _behavior.AutoPilot.CurrentPlanet.HasAtmosphere) { IMyEntity entity = null; if (MyAPIGateway.Entities.TryGetEntityById(detectedEntity, out entity)) { DamageHelper.CreateLightning(entity.PositionComp.WorldAABB.Center, actions.LightningDamage, actions.LightningExplosionRadius, actions.LightningColor); } } } //CreateLightningAtTarget if (actions.CreateLightningAtTarget && _behavior.AutoPilot.Targeting.HasTarget()) { if (_behavior.AutoPilot.InGravity() && _behavior.AutoPilot.CurrentPlanet.HasAtmosphere) { DamageHelper.CreateLightning(_behavior.AutoPilot.Targeting.TargetLastKnownCoords, actions.LightningDamage, actions.LightningExplosionRadius, actions.LightningColor); } } //InheritLastAttackerFromCommand if (actions.InheritLastAttackerFromCommand) { _behavior.Settings.LastDamagerEntity = command != null ? command.TargetEntityId : 0; } //SetBooleansTrue foreach (var variable in actions.SetBooleansTrue) { _settings.SetCustomBool(variable, true); } //SetBooleansFalse foreach (var variable in actions.SetBooleansFalse) { _settings.SetCustomBool(variable, false); } //IncreaseCounters foreach (var variable in actions.IncreaseCounters) { _settings.SetCustomCounter(variable, 1); } //DecreaseCounters foreach (var variable in actions.DecreaseCounters) { _settings.SetCustomCounter(variable, -1); } //ResetCounters foreach (var variable in actions.ResetCounters) { _settings.SetCustomCounter(variable, 0, true); } //SetCounters if (actions.SetCounters.Count == actions.SetCountersValues.Count) { for (int i = 0; i < actions.SetCounters.Count; i++) { _settings.SetCustomCounter(actions.SetCounters[i], actions.SetCountersValues[i], false, true); } } //SetSandboxBooleansTrue foreach (var variable in actions.SetSandboxBooleansTrue) { SetSandboxBool(variable, true); } //SetSandboxBooleansFalse foreach (var variable in actions.SetSandboxBooleansFalse) { SetSandboxBool(variable, false); } //IncreaseSandboxCounters foreach (var variable in actions.IncreaseSandboxCounters) { SetSandboxCounter(variable, 1); } //DecreaseSandboxCounters foreach (var variable in actions.DecreaseSandboxCounters) { SetSandboxCounter(variable, -1); } //ResetSandboxCounters foreach (var variable in actions.ResetSandboxCounters) { SetSandboxCounter(variable, 0); } //SetSandboxCounters if (actions.SetSandboxCounters.Count != 0 && actions.SetSandboxCounters.Count == actions.SetSandboxCountersValues.Count) { for (int i = 0; i < actions.SetCounters.Count; i++) { SetSandboxCounter(actions.SetSandboxCounters[i], actions.SetSandboxCountersValues[i], true); } } //BehaviorSpecificEventA if (actions.BehaviorSpecificEventA) { _behavior.BehaviorActionA = true; } //BehaviorSpecificEventB if (actions.BehaviorSpecificEventB) { _behavior.BehaviorActionB = true; } //BehaviorSpecificEventC if (actions.BehaviorSpecificEventC) { _behavior.BehaviorActionC = true; } //BehaviorSpecificEventD if (actions.BehaviorSpecificEventD) { _behavior.BehaviorActionD = true; } //BehaviorSpecificEventE if (actions.BehaviorSpecificEventE) { _behavior.BehaviorActionE = true; } //BehaviorSpecificEventF if (actions.BehaviorSpecificEventF) { _behavior.BehaviorActionF = true; } //BehaviorSpecificEventG if (actions.BehaviorSpecificEventG) { _behavior.BehaviorActionG = true; } //BehaviorSpecificEventH if (actions.BehaviorSpecificEventH) { _behavior.BehaviorActionH = true; } }
private void EDying() { if (Config.Modes.KillSteal.EDying) { foreach (var enemy in EntityManager.Heroes.Enemies.Where(c => Player.Instance.Position.IsInRange(c.Position, SpellManager.E.Range) && c.IsValidTarget() && DamageHelper.getEStacks(c) >= 1)) { if (Player.Instance.HealthPercent < 10) { E.Cast(); } } } }
private void EOutOfRange() { if (Config.Modes.KillSteal.EOutOfRange) { foreach (var enemy in EntityManager.Heroes.Enemies.Where(c => Player.Instance.Position.IsInRange(c.Position, SpellManager.E.Range) && c.IsValidTarget() && DamageHelper.getEStacks(c) >= Config.Modes.KillSteal.EOutOfRangeStacks)) { if (Player.Instance.Distance(enemy.Position) > SpellManager.E.Range - 150) { E.Cast(); } } } }
public void Setup() { helper = new DamageHelper(); }
public void Setup() { damageHelper = new DamageHelper(); weaponDataSelector = GetNewInstanceOf <IWeaponDataSelector>(); }
public void ProcessTrigger(TriggerProfile trigger, long attackerEntityId = 0, bool skipOnComplete = false) { if (this.RemoteControl?.SlimBlock?.CubeGrid == null) { return; } if (trigger.Triggered == false || trigger.Actions == null) { return; } long detectedEntity = attackerEntityId; if (trigger.DetectedEntityId != 0 && detectedEntity == 0) { detectedEntity = trigger.DetectedEntityId; } trigger.DetectedEntityId = 0; trigger.Triggered = false; trigger.CooldownTime = trigger.Rnd.Next((int)trigger.MinCooldownMs, (int)trigger.MaxCooldownMs); trigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; trigger.TriggerCount++; Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Performing Eligible Actions", DebugTypeEnum.Action); //ChatBroadcast if (trigger.Actions.UseChatBroadcast == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Chat Broadcast", DebugTypeEnum.Action); _broadcast.BroadcastRequest(trigger.Actions.ChatData); } //BarrellRoll - Implement Post Release if (trigger.Actions.BarrelRoll == true) { //_autopilot.ChangeAutoPilotMode(AutoPilotMode.BarrelRoll); } //Strafe - Implement Post Release if (trigger.Actions.Strafe == true) { //_autopilot.ChangeAutoPilotMode(AutoPilotMode.Strafe); } //ChangeAutopilotSpeed if (trigger.Actions.ChangeAutopilotSpeed == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Changing AutoPilot Speed To: " + trigger.Actions.NewAutopilotSpeed.ToString(), DebugTypeEnum.Action); _autopilot.IdealMaxSpeed = trigger.Actions.NewAutopilotSpeed; var blockList = TargetHelper.GetAllBlocks(RemoteControl.SlimBlock.CubeGrid); foreach (var block in blockList.Where(x => x.FatBlock != null)) { var tBlock = block.FatBlock as IMyRemoteControl; if (tBlock != null) { tBlock.SpeedLimit = trigger.Actions.NewAutopilotSpeed; } } } //SpawnReinforcements if (trigger.Actions.SpawnEncounter == true && trigger.Actions.Spawner.UseSpawn) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Spawn", DebugTypeEnum.Spawn); if (trigger.Actions.Spawner.IsReadyToSpawn()) { //Logger.AddMsg("Do Spawn", true); trigger.Actions.Spawner.CurrentPositionMatrix = this.RemoteControl.WorldMatrix; trigger.Actions.Spawner.CurrentFactionTag = (trigger.Actions.Spawner.ForceSameFactionOwnership && !string.IsNullOrWhiteSpace(_owner.Faction?.Tag)) ? _owner.Faction.Tag : ""; SpawnHelper.SpawnRequest(trigger.Actions.Spawner); } } else { } //SelfDestruct if (trigger.Actions.SelfDestruct == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting SelfDestruct", DebugTypeEnum.Action); var blockList = TargetHelper.GetAllBlocks(RemoteControl.SlimBlock.CubeGrid); int totalWarheads = 0; foreach (var block in blockList.Where(x => x.FatBlock != null)) { var tBlock = block.FatBlock as IMyWarhead; if (tBlock != null) { if (!trigger.Actions.StaggerWarheadDetonation) { tBlock.IsArmed = true; tBlock.DetonationTime = 0; tBlock.Detonate(); totalWarheads++; } else { tBlock.DetonationTime = totalWarheads + 1; tBlock.StartCountdown(); totalWarheads++; } } } //Logger.AddMsg("TotalBlocks: " + blockList.Count.ToString(), true); //Logger.AddMsg("TotalWarheads: " + totalWarheads.ToString(), true); //TODO: Shield EMP } //Retreat if (trigger.Actions.Retreat) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Retreat", DebugTypeEnum.Action); _despawn.Retreat(); } //ForceDespawn if (trigger.Actions.ForceDespawn) { _despawn.DespawnGrid(); } //TerminateBehavior if (trigger.Actions.TerminateBehavior) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Termination Of Behavior", DebugTypeEnum.Action); _autopilot.ActivateAutoPilot(AutoPilotType.None, NewAutoPilotMode.None, Vector3D.Zero); _behavior.BehaviorTerminated = true; } //BroadcastGenericCommand if (trigger.Actions.BroadcastGenericCommand == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Broadcast of Generic Command", DebugTypeEnum.Action); var antenna = BlockHelper.GetAntennaWithHighestRange(this.AntennaList); if (antenna != null) { CommandHelper.CommandTrigger?.Invoke(trigger.Actions.BroadcastSendCode, this.RemoteControl, (double)antenna.Radius, 0); } } //BroadcastCurrentTarget if (trigger.Actions.BroadcastCurrentTarget == true && detectedEntity != 0) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Broadcast of Current Target", DebugTypeEnum.Action); var antenna = BlockHelper.GetAntennaWithHighestRange(this.AntennaList); if (antenna != null) { CommandHelper.CommandTrigger?.Invoke(trigger.Actions.BroadcastSendCode, this.RemoteControl, (double)antenna.Radius, detectedEntity); } } //SwitchToReceivedTarget if (trigger.Actions.SwitchToReceivedTarget == true && detectedEntity != 0) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Switch to Received Target Data", DebugTypeEnum.Action); _autopilot.Targeting.ForceTargetEntity = detectedEntity; _autopilot.Targeting.ForceRefresh = true; } //SwitchToBehavior if (trigger.Actions.SwitchToBehavior == true) { _behavior.ChangeBehavior(trigger.Actions.NewBehavior, trigger.Actions.PreserveSettingsOnBehaviorSwitch, trigger.Actions.PreserveTriggersOnBehaviorSwitch, trigger.Actions.PreserveTargetDataOnBehaviorSwitch); } //RefreshTarget if (trigger.Actions.RefreshTarget == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Target Refresh", DebugTypeEnum.Action); _autopilot.Targeting.ForceRefresh = true; } //ChangeTargetProfile if (trigger.Actions.ChangeTargetProfile == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Target Change", DebugTypeEnum.Action); _autopilot.Targeting.UseNewTargetProfile = true; _autopilot.Targeting.NewTargetProfileName = trigger.Actions.NewTargetProfileId; } //ChangeReputationWithPlayers if (trigger.Actions.ChangeReputationWithPlayers == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Reputation Change With Players In Radius", DebugTypeEnum.Action); OwnershipHelper.ChangeReputationWithPlayersInRadius(this.RemoteControl, trigger.Actions.ReputationChangeRadius, trigger.Actions.ReputationChangeAmount, trigger.Actions.ReputationChangeFactions, trigger.Actions.ReputationChangesForAllRadiusPlayerFactionMembers); } //ChangeAttackerReputation if (trigger.Actions.ChangeAttackerReputation == true && detectedEntity != 0) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Reputation Change for Attacker", DebugTypeEnum.Action); OwnershipHelper.ChangeDamageOwnerReputation(trigger.Actions.ChangeAttackerReputationFaction, detectedEntity, trigger.Actions.ChangeAttackerReputationAmount, trigger.Actions.ReputationChangesForAllAttackPlayerFactionMembers); } //TriggerTimerBlock if (trigger.Actions.TriggerTimerBlocks == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Trigger of Timer Blocks", DebugTypeEnum.Action); var blockList = BlockHelper.GetBlocksWithNames(RemoteControl.SlimBlock.CubeGrid, trigger.Actions.TimerBlockNames); foreach (var block in blockList) { var tBlock = block as IMyTimerBlock; if (tBlock != null) { tBlock.Trigger(); } } } //ChangeBlockNames if (trigger.Actions.ChangeBlockNames) { BlockHelper.RenameBlocks(RemoteControl.CubeGrid, trigger.Actions.ChangeBlockNamesFrom, trigger.Actions.ChangeBlockNamesTo, trigger.Actions.ProfileSubtypeId); } //ChangeAntennaRanges if (trigger.Actions.ChangeAntennaRanges) { BlockHelper.SetGridAntennaRanges(AntennaList, trigger.Actions.AntennaNamesForRangeChange, trigger.Actions.AntennaRangeChangeType, trigger.Actions.AntennaRangeChangeAmount); } //ChangeAntennaOwnership if (trigger.Actions.ChangeAntennaOwnership == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Antenna Ownership Change", DebugTypeEnum.Action); OwnershipHelper.ChangeAntennaBlockOwnership(AntennaList, trigger.Actions.AntennaFactionOwner); } //CreateKnownPlayerArea if (trigger.Actions.CreateKnownPlayerArea == true) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Creation of Known Player Area in MES", DebugTypeEnum.Action); MESApi.AddKnownPlayerLocation(this.RemoteControl.GetPosition(), _owner.Faction?.Tag, trigger.Actions.KnownPlayerAreaRadius, trigger.Actions.KnownPlayerAreaTimer, trigger.Actions.KnownPlayerAreaMaxSpawns); } //DamageAttacker if (trigger.Actions.DamageToolAttacker == true && detectedEntity != 0) { Logger.MsgDebug(trigger.Actions.ProfileSubtypeId + ": Attempting Damage to Tool User", DebugTypeEnum.Action); DamageHelper.ApplyDamageToTarget(attackerEntityId, trigger.Actions.DamageToolAttackerAmount, trigger.Actions.DamageToolAttackerParticle, trigger.Actions.DamageToolAttackerSound); } //PlayParticleEffectAtRemote if (trigger.Actions.PlayParticleEffectAtRemote == true) { EffectManager.SendParticleEffectRequest(trigger.Actions.ParticleEffectId, this.RemoteControl.WorldMatrix, trigger.Actions.ParticleEffectOffset, trigger.Actions.ParticleEffectScale, trigger.Actions.ParticleEffectMaxTime, trigger.Actions.ParticleEffectColor); } //ResetCooldownTimeOfTriggers if (trigger.Actions.ResetCooldownTimeOfTriggers) { foreach (var resetTrigger in Triggers) { if (trigger.Actions.ResetTriggerCooldownNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; } } foreach (var resetTrigger in DamageTriggers) { if (trigger.Actions.ResetTriggerCooldownNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; } } foreach (var resetTrigger in CommandTriggers) { if (trigger.Actions.ResetTriggerCooldownNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.LastTriggerTime = MyAPIGateway.Session.GameDateTime; } } } if (trigger.Actions.EnableTriggers) { foreach (var resetTrigger in Triggers) { if (trigger.Actions.EnableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = true; } } foreach (var resetTrigger in DamageTriggers) { if (trigger.Actions.EnableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = true; } } foreach (var resetTrigger in CommandTriggers) { if (trigger.Actions.EnableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = true; } } } if (trigger.Actions.DisableTriggers) { foreach (var resetTrigger in Triggers) { if (trigger.Actions.DisableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = false; } } foreach (var resetTrigger in DamageTriggers) { if (trigger.Actions.DisableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = false; } } foreach (var resetTrigger in CommandTriggers) { if (trigger.Actions.DisableTriggerNames.Contains(resetTrigger.ProfileSubtypeId)) { resetTrigger.UseTrigger = false; } } } //ChangeInertiaDampeners if (trigger.Actions.ChangeInertiaDampeners) { RemoteControl.DampenersOverride = trigger.Actions.InertiaDampenersEnable; } //ChangeRotationDirection if (trigger.Actions.ChangeRotationDirection) { _behavior.Settings.SetRotation(trigger.Actions.RotationDirection); } //GenerateExplosion if (trigger.Actions.GenerateExplosion) { var coords = Vector3D.Transform(trigger.Actions.ExplosionOffsetFromRemote, RemoteControl.WorldMatrix); MyVisualScriptLogicProvider.CreateExplosion(coords, trigger.Actions.ExplosionRange, trigger.Actions.ExplosionDamage); } //SetBooleansTrue foreach (var variable in trigger.Actions.SetBooleansTrue) { _settings.SetCustomBool(variable, true); } //SetBooleansFalse foreach (var variable in trigger.Actions.SetBooleansFalse) { _settings.SetCustomBool(variable, false); } //IncreaseCounters foreach (var variable in trigger.Actions.IncreaseCounters) { _settings.SetCustomCounter(variable, 1); } //DecreaseCounters foreach (var variable in trigger.Actions.DecreaseCounters) { _settings.SetCustomCounter(variable, -1); } //ResetCounters foreach (var variable in trigger.Actions.ResetCounters) { _settings.SetCustomCounter(variable, 0, true); } //SetSandboxBooleansTrue foreach (var variable in trigger.Actions.SetSandboxBooleansTrue) { SetSandboxBool(variable, true); } //SetSandboxBooleansFalse foreach (var variable in trigger.Actions.SetSandboxBooleansFalse) { SetSandboxBool(variable, false); } //IncreaseSandboxCounters foreach (var variable in trigger.Actions.IncreaseSandboxCounters) { SetSandboxCounter(variable, 1); } //DecreaseSandboxCounters foreach (var variable in trigger.Actions.DecreaseSandboxCounters) { SetSandboxCounter(variable, -1); } //ResetSandboxCounters foreach (var variable in trigger.Actions.ResetSandboxCounters) { SetSandboxCounter(variable, 0); } //BehaviorSpecificEventA if (trigger.Actions.BehaviorSpecificEventA) { BehaviorEventA?.Invoke(); } //BehaviorSpecificEventB if (trigger.Actions.BehaviorSpecificEventB) { BehaviorEventB?.Invoke(); } //BehaviorSpecificEventC if (trigger.Actions.BehaviorSpecificEventC) { BehaviorEventC?.Invoke(); } //BehaviorSpecificEventD if (trigger.Actions.BehaviorSpecificEventD) { BehaviorEventD?.Invoke(); } //BehaviorSpecificEventE if (trigger.Actions.BehaviorSpecificEventE) { BehaviorEventE?.Invoke(); } //BehaviorSpecificEventF if (trigger.Actions.BehaviorSpecificEventF) { BehaviorEventF?.Invoke(); } //BehaviorSpecificEventG if (trigger.Actions.BehaviorSpecificEventG) { BehaviorEventG?.Invoke(); } //BehaviorSpecificEventH if (trigger.Actions.BehaviorSpecificEventH) { BehaviorEventH?.Invoke(); } }