예제 #1
0
        private void ApplyProcHealthChange(IHealthComponent healthComp, Buff buff)
        {
            if (healthComp == null)
            {
                return;
            }
            SmartEntity source = null;
            int         health = healthComp.Health;
            int         num    = health;

            buff.ApplyStacks(ref num, healthComp.MaxHealth);
            int num2 = num - health;

            if (num2 > 0)
            {
                HealthFragment fragment = new HealthFragment(source, HealthType.Healing, num2);
                this.ApplyHealthFragment(healthComp, fragment, false);
                return;
            }
            if (num2 < 0)
            {
                HealthFragment fragment2 = new HealthFragment(source, HealthType.Damaging, -num2);
                this.ApplyHealthFragment(healthComp, fragment2, false);
            }
        }
예제 #2
0
        public Bullet SpawnProjectileForDeath(Vector3 spawnWorldLocation, SmartEntity attacker, ProjectileTypeVO deathProjectileType, uint deathProjectileDelay, int deathProjectileDistance, int deathProjectileDamage, out bool useRotation, ref int rotateDegrees)
        {
            useRotation = false;
            TransformComponent transformComp = attacker.TransformComp;
            int num  = transformComp.CenterGridX();
            int num2 = transformComp.CenterGridZ();

            if (spawnWorldLocation.y < 0f)
            {
                spawnWorldLocation = new Vector3(Units.BoardToWorldX(num), 0f, Units.BoardToWorldZ(num2));
            }
            Vector3 vector = spawnWorldLocation;

            if (deathProjectileDistance > 0)
            {
                this.ChooseTargetLocationForDeathProjectile(attacker, deathProjectileDistance, ref num, ref num2, out rotateDegrees);
                useRotation = true;
                Vector3 point = Vector3.right * (float)deathProjectileDistance;
                vector += Quaternion.Euler(0f, (float)rotateDegrees, 0f) * point;
            }
            HealthFragment healthFrag = new HealthFragment(attacker, HealthType.Damaging, deathProjectileDamage);
            TeamType       teamType   = attacker.TeamComp.TeamType;
            Bullet         bullet     = new Bullet();

            bullet.InitWithTargetPositionAndTravelTime(deathProjectileDelay, spawnWorldLocation, num, num2, teamType, attacker, healthFrag, deathProjectileType, null, FactionType.Invalid);
            bullet.SetTargetWorldLocation(vector);
            bullet.FlashTarget = (deathProjectileType.ApplyBuffs == null || deathProjectileType.ApplyBuffs.Length == 0);
            this.SpawnProjectileInternal(bullet, true, false);
            return(bullet);
        }
예제 #3
0
        public int ApplyHealthFragment(IHealthComponent healthComponent, HealthFragment fragment, List <int> damageMultipliers, int damagePercentage, bool fromSplash, bool fromBeam, SmartEntity source)
        {
            if (healthComponent == null || healthComponent.IsDead() || damagePercentage == 0)
            {
                return(0);
            }
            int health = healthComponent.Health;
            int num    = fragment.Quantity;

            if (fromSplash)
            {
                num = fragment.SplashQuantity;
            }
            int rawDamage = num;

            if (damageMultipliers != null)
            {
                int healthMultiplier = this.GetHealthMultiplier(healthComponent, damageMultipliers);
                num = num * healthMultiplier / 100;
            }
            SmartEntity    target         = (SmartEntity)((ComponentBase)healthComponent).Entity;
            BuffController buffController = Service.Get <BuffController>();

            if (fragment.Type == HealthType.Healing)
            {
                buffController.ApplyActiveBuffs(target, BuffModify.HealDefense, ref damagePercentage, 100);
            }
            else
            {
                buffController.ApplyActiveBuffs(target, BuffModify.Defense, ref damagePercentage, 100);
                if (fromSplash)
                {
                    buffController.ApplyActiveBuffs(target, BuffModify.SplashDefense, ref damagePercentage, 100);
                }
            }
            num = IntMath.GetPercent(damagePercentage, num);
            if (fragment.Type == HealthType.Healing)
            {
                healthComponent.Health += num;
                if (healthComponent.Health > healthComponent.MaxHealth)
                {
                    healthComponent.Health = healthComponent.MaxHealth;
                }
            }
            else
            {
                healthComponent.Health -= num;
                if (healthComponent.Health <= 0)
                {
                    healthComponent.Health = 0;
                }
            }
            int num2 = healthComponent.Health - health;
            EntityHealthChangedData cookie = new EntityHealthChangedData(source, target, num2, rawDamage, fromBeam);

            Service.Get <EventManager>().SendEvent(EventId.EntityHealthChanged, cookie);
            this.HandleHealthChange(healthComponent, num2);
            return(num2);
        }
예제 #4
0
        private void FireAShot(int spawnBoardX, int spawnBoardZ, Vector3 startPos, Target target, GameObject gunLocator)
        {
            FactionType faction = FactionType.Invalid;

            if (this.Entity != null)
            {
                BuildingComponent buildingComp = this.Entity.BuildingComp;
                TroopComponent    troopComp    = this.Entity.TroopComp;
                if (buildingComp != null)
                {
                    faction = buildingComp.BuildingType.Faction;
                }
                else if (troopComp != null)
                {
                    faction = troopComp.TroopType.Faction;
                }
            }
            HealthFragment payload = new HealthFragment(this.Entity, this.healthType, this.ShooterComp.ShooterVO.Damage);

            Service.Get <ProjectileController>().SpawnProjectileForTarget(0u, spawnBoardX, spawnBoardZ, startPos, target, payload, this.ownerTeam, this.Entity, this.ShooterComp.ShooterVO.ProjectileType, true, this.Entity.BuffComp.Buffs, faction, gunLocator);
            Service.Get <EventManager>().SendEvent(EventId.EntityAttackedTarget, this.Entity);
            this.shooterController.DecreaseShotsRemainingInClip(this.ShooterComp);
        }
예제 #5
0
        private void SpawnProjectile(uint id, object cookie)
        {
            SpecialAttack specialAttack = (SpecialAttack)cookie;

            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            if (specialAttack == null)
            {
                logger.Error("SpawnProjectile: specialAttack is null");
                this.SendSpecialAttackFired(null);
                return;
            }
            if (specialAttack.GetGunLocator() == null)
            {
                logger.Error("SpawnProjectile: specialAttack.GetGunLocator() is null " + specialAttack.VO.Uid);
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            if (specialAttack.GetGunLocator().transform == null)
            {
                logger.Error("SpawnProjectile: specialAttack.GetGunLocator().transform is null " + specialAttack.VO.Uid);
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            Vector3 position = specialAttack.GetGunLocator().transform.position;

            if (specialAttack.VO == null)
            {
                logger.Error("SpawnProjectile: specialAttack.VO is null");
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            float num      = specialAttack.VO.NumberOfAttackers;
            int   quantity = (int)((float)specialAttack.VO.Damage / num);

            specialAttack.ApplySpecialAttackBuffs(ref quantity);
            HealthFragment       payload = new HealthFragment(null, HealthType.Damaging, quantity);
            ProjectileController projectileController = Service.ProjectileController;

            if (specialAttack.TargetShield != null && !specialAttack.VO.ProjectileType.PassThroughShield)
            {
                Entity shieldBorderEntity = specialAttack.TargetShield.ShieldBorderEntity;
                if (shieldBorderEntity == null)
                {
                    logger.Error("SpawnProjectile: shieldTarget is null");
                    this.SendSpecialAttackFired(specialAttack.VO);
                    return;
                }
                Vector3 targetWorldPos = specialAttack.TargetWorldPos;
                Vector3 targetWorldLoc = Vector3.zero;
                if (!Service.ShieldController.GetRayShieldIntersection(position, specialAttack.TargetWorldPos, specialAttack.TargetShield, out targetWorldLoc))
                {
                    targetWorldLoc = targetWorldPos;
                }
                Target target      = Target.CreateTargetWithWorldLocation((SmartEntity)shieldBorderEntity, targetWorldLoc);
                int    spawnBoardX = Units.WorldToBoardX((float)((int)position.x));
                int    spawnBoardZ = Units.WorldToBoardZ((float)((int)position.z));
                projectileController.SpawnProjectileForTarget(specialAttack.VO.HitDelay, spawnBoardX, spawnBoardZ, position, target, payload, specialAttack.TeamType, null, specialAttack.VO.ProjectileType, false, specialAttack.SpecialAttackBuffs, specialAttack.VO.Faction, null);
                this.AddProjectileInFlight(specialAttack.VO.ProjectileType);
            }
            else
            {
                Bullet bullet = projectileController.SpawnProjectileForTargetPosition(specialAttack.VO.HitDelay, position, specialAttack.TargetBoardX, specialAttack.TargetBoardZ, payload, specialAttack.TeamType, null, specialAttack.VO.ProjectileType, specialAttack.SpecialAttackBuffs, specialAttack.VO.Faction, specialAttack.VO.HasDropoff);
                if (specialAttack.VO.HasDropoff)
                {
                    bullet.Cookie = specialAttack;
                    ProjectileView projectileView = Service.ProjectileViewManager.SpawnProjectile(bullet);
                    Transform      transform      = projectileView.GetTransform();
                    this.AttachGameObject(transform, specialAttack.StarshipDetachableGameObject, false);
                    specialAttack.UpdateDetachableShadowAnimator(SpecialAttackDetachableObjectState.Falling);
                }
                this.AddProjectileInFlight(specialAttack.VO.ProjectileType);
            }
            this.SendSpecialAttackFired(specialAttack.VO);
        }
예제 #6
0
        public Bullet SpawnProjectileForTarget(uint travelTime, int spawnBoardX, int spawnBoardZ, Vector3 spawnWorldLocation, Target target, HealthFragment payload, TeamType ownerTeam, Entity attacker, ProjectileTypeVO projectileType, bool allowSplash, List <Buff> appliedBuffs, FactionType faction, GameObject gunLocator)
        {
            Bullet newProjectileForTarget = this.GetNewProjectileForTarget(travelTime, spawnBoardX, spawnBoardZ, spawnWorldLocation, target, ownerTeam, attacker, projectileType, payload, appliedBuffs, faction, gunLocator);

            if (newProjectileForTarget != null)
            {
                this.SpawnProjectileInternal(newProjectileForTarget, allowSplash, false);
            }
            return(newProjectileForTarget);
        }
예제 #7
0
        public Bullet SpawnProjectileForTargetPosition(uint travelTime, Vector3 spawnWorldLocation, int targetBoardX, int targetBoardZ, HealthFragment payload, TeamType ownerTeam, Entity attacker, ProjectileTypeVO projectileType, List <Buff> appliedBuffs, FactionType faction, bool preventProjectileView)
        {
            Bullet bullet = new Bullet();

            bullet.InitWithTargetPositionAndTravelTime(travelTime, spawnWorldLocation, targetBoardX, targetBoardZ, ownerTeam, attacker, payload, projectileType, appliedBuffs, faction);
            this.SpawnProjectileInternal(bullet, true, preventProjectileView);
            return(bullet);
        }
예제 #8
0
        private Bullet GetNewProjectileForTarget(uint travelTime, int spawnBoardX, int spawnBoardZ, Vector3 spawnWorldLocation, Target target, TeamType teamType, Entity attacker, ProjectileTypeVO projectileType, HealthFragment healthFrag, List <Buff> appliedBuffs, FactionType faction, GameObject gunLocator)
        {
            Bullet bullet = new Bullet();

            if (!bullet.InitWithTarget(spawnBoardX, spawnBoardZ, spawnWorldLocation, target, teamType, attacker, healthFrag, projectileType, appliedBuffs, faction, gunLocator))
            {
                return(null);
            }
            if (travelTime > 0u)
            {
                bullet.SetTravelTime(travelTime);
            }
            else
            {
                this.SetProjectileTravelTime(bullet, bullet.TargetBoardX, bullet.TargetBoardZ);
            }
            return(bullet);
        }
예제 #9
0
 public Bullet SpawnProjectileForTargetPosition(uint travelTime, Vector3 spawnWorldLocation, int targetBoardX, int targetBoardZ, HealthFragment payload, TeamType ownerTeam, Entity attacker, ProjectileTypeVO projectileType, List <Buff> appliedBuffs, FactionType faction)
 {
     return(this.SpawnProjectileForTargetPosition(travelTime, spawnWorldLocation, targetBoardX, targetBoardZ, payload, ownerTeam, attacker, projectileType, appliedBuffs, faction, false));
 }
예제 #10
0
 public int ApplyHealthFragment(IHealthComponent healthComp, HealthFragment fragment, bool fromSplash)
 {
     return(this.ApplyHealthFragment(healthComp, fragment, null, 100, fromSplash, false, null));
 }