public override void Update() { base.Update(); if (IsAttacking) { int attackTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_attackStart; if (attackTime > ATTACK_LENGTH) { IsAttacking = false; MyCharacter botEntity = m_bot.AgentEntity; if (botEntity != null) { botEntity.EnableAnimationCommands(); } } else if (attackTime > 500 && m_bot.AgentEntity.UseNewAnimationSystem) { m_bot.AgentEntity.AnimationController.TriggerAction(m_stringIdAttackAction); if (Sync.IsServer) { MyMultiplayer.RaiseStaticEvent(x => PlayAttackAnimation, m_bot.AgentEntity.EntityId); } } if (attackTime > 500 && !m_attackPerformed) { MyCharacter botEntity = m_bot.AgentEntity; if (botEntity != null) { Vector3D attackPosition = botEntity.WorldMatrix.Translation + botEntity.PositionComp.WorldMatrix.Forward * 2.5 + botEntity.PositionComp.WorldMatrix.Up * 1.0; m_attackBoundingSphere = new BoundingSphereD(attackPosition, 1.1); m_attackPerformed = true; List <MyEntity> hitEntities = MyEntities.GetTopMostEntitiesInSphere(ref m_attackBoundingSphere); foreach (var hitEntity in hitEntities) { //AttackEntity(hitEntity); if (hitEntity is MyCharacter && hitEntity != botEntity) { var character = hitEntity as MyCharacter; if (character.IsSitting) { continue; } var characterVolume = character.PositionComp.WorldVolume; double touchDistSq = m_attackBoundingSphere.Radius + characterVolume.Radius; touchDistSq = touchDistSq * touchDistSq; if (Vector3D.DistanceSquared(m_attackBoundingSphere.Center, characterVolume.Center) > touchDistSq) { continue; } if (character.IsDead) { var inventory = character.GetInventory(); if (inventory == null) { continue; } if (m_bot.AgentEntity == null) { continue; } var cyberhoundInventory = m_bot.AgentEntity.GetInventory(); if (cyberhoundInventory == null) { continue; } MyInventory.TransferAll(inventory, cyberhoundInventory); } else { character.DoDamage(ATTACK_DAMAGE_TO_CHARACTER, MyDamageType.Bolt, updateSync: true, attackerId: botEntity.EntityId); } } else if (hitEntity is MyCubeGrid && hitEntity.Physics != null) { var grid = hitEntity as MyCubeGrid; m_tmpBlocks.Clear(); grid.GetBlocksInsideSphere(ref m_attackBoundingSphere, m_tmpBlocks); foreach (var block in m_tmpBlocks) { block.DoDamage(ATTACK_DAMAGE_TO_GRID, MyDamageType.Bolt); } m_tmpBlocks.Clear(); } } hitEntities.Clear(); } } if (attackTime > 500) { //MyRenderProxy.DebugDrawSphere(m_attackBoundingSphere.Center, (float)m_attackBoundingSphere.Radius, Color.Red, 1.0f, false); } } }