Exemplo n.º 1
0
        private void ToPresentBullet(IProjectile projectile)
        {
            var customBullet = Game.CreateObject("XmasPresent00",
                                                 worldPosition: projectile.Position,
                                                 angle: (float)Math.Atan2(projectile.Direction.X, projectile.Direction.Y),
                                                 linearVelocity: projectile.Velocity / 50 + new Vector2(0, 3),
                                                 angularVelocity: 50f * (int)(projectile.Direction.X % 1),
                                                 faceDirection: (int)(projectile.Direction.X % 1)
                                                 );

            customBullet.TrackAsMissile(true);
            m_customBullets.Add(customBullet.UniqueID, customBullet);
            projectile.FlagForRemoval();
        }
Exemplo n.º 2
0
        protected static IObject CreateCustomProjectile(IProjectile projectile, string objectID, Vector2 velocity)
        {
            var customBullet = Game.CreateObject(objectID);
            var length       = Math.Max(customBullet.GetAABB().Width, customBullet.GetAABB().Height);

            customBullet.SetWorldPosition(projectile.Position + projectile.Direction * (length + 1));
            customBullet.SetLinearVelocity(velocity);
            customBullet.SetFaceDirection(Math.Sign(projectile.Direction.X));
            customBullet.TrackAsMissile(true);

            projectile.FlagForRemoval();

            return(customBullet);
        }
Exemplo n.º 3
0
        public override void OnProjectileCreated(IProjectile projectile)
        {
            // Remove projectile completely since gravity gun only use objects laying around the map as ammunation
            projectile.FlagForRemoval();

            // Cannot use ia 1 because we only want this particular gun to have indefinite ammo
            if (BotManager.GetBot(Owner).CurrentAmmo == 0)
            {
                if (Type == WeaponItemType.Rifle)
                {
                    Owner.SetCurrentPrimaryWeaponAmmo(Owner.CurrentPrimaryWeapon.MaxTotalAmmo - 1);
                }
                if (Type == WeaponItemType.Handgun)
                {
                    Owner.SetCurrentSecondaryWeaponAmmo(Owner.CurrentSecondaryWeapon.MaxTotalAmmo - 1);
                }
            }

            Release();
        }
Exemplo n.º 4
0
        public override void OnProjectileCreated(IProjectile projectile)
        {
            base.OnProjectileCreated(projectile);

            if (Projectile.IsSlowProjectile(projectile))
            {
                return;
            }

            var range = 300;

            if (projectile.ProjectileItem == ProjectileItem.SNIPER ||
                projectile.ProjectileItem == ProjectileItem.MAGNUM)
            {
                range *= 2;
            }

            var start       = projectile.Position;
            var end         = start + projectile.Direction * range;
            var maxHitCount = (int)(ChargeModifier / 1000 + 1);
            var results     = Game.RayCast(start, end, new RayCastInput()
            {
                ProjectileHit  = RayCastFilterMode.True,
                IncludeOverlap = true,
                ClosestHitOnly = maxHitCount == 1,
            }).Where(r => r.HitObject != null);

            if (results.Count() == 0)
            {
                Game.PlayEffect(EffectName.Electric, end);
            }

            var hitCount = 0;

            foreach (var result in results)
            {
                var hitObject      = result.HitObject;
                var projectileItem = projectile.ProjectileItem;
                var direction      = projectile.Direction;
                var powerup        = ScriptHelper.GetPowerup(projectile);

                Game.PlayEffect(EffectName.Electric, result.Position);
                Game.PlaySound("ElectricSparks", result.Position);
                ScriptHelper.Timeout(() =>
                {
                    var p = Game.SpawnProjectile(projectileItem, result.Position, direction, powerup);
                    p.CritChanceDealtModifier *= 3;
                    if (!hitObject.GetCollisionFilter().AbsorbProjectile)
                    {
                        ScriptHelper.Timeout(() => p.FlagForRemoval(), 0);
                    }
                }, 0);
                //if (Game.IsEditorTest)
                //{
                //    ScriptHelper.RunIn(() =>
                //    {
                //        if (hitObject != null)
                //            Game.DrawArea(hitObject.GetAABB());
                //        Game.DrawLine(start, end, Color.Cyan);
                //    }, 500);
                //}
                if (hitObject.GetCollisionFilter().AbsorbProjectile)
                {
                    hitCount++;
                }
                if (hitCount >= maxHitCount)
                {
                    break;
                }
            }

            projectile.FlagForRemoval();
        }