Example #1
0
        public override void OnUpdate()
        {
            if (Owner.Get() == null || lifetime <= 0)
            {
                Decorative.Remove(this);
                return;
            }

            if (rof-- > 0 && --lifetime > 0)
            {
                return;
            }
            rof = 5;

            int damage = lifetime > 0 ? 10 : 100;

            TechnoExt target = Decorative as TechnoExt;

            Pointer <WeaponTypeClass>  pWeapon  = Weapon;
            Pointer <WarheadTypeClass> pWarhead = Warhead;

            Func <int, Pointer <BulletClass> > CreateBullet = (int damage) => {
                Pointer <BulletClass> pBullet = pWeapon.Ref.Projectile.Ref.
                                                CreateBullet(target.OwnerObject.Convert <AbstractClass>(), Owner.Get().OwnerObject,
                                                             damage, pWarhead, pWeapon.Ref.Speed, pWeapon.Ref.Bright);
                return(pBullet);
            };

            CoordStruct curLocation = target.OwnerObject.Ref.Base.Base.GetCoords();

            if (Cluster)
            {
                CellStruct cur = MapClass.Coord2Cell(curLocation);

                CellSpreadEnumerator enumerator = new CellSpreadEnumerator(2);
                foreach (CellStruct offset in enumerator)
                {
                    Pointer <BulletClass> pBullet = CreateBullet(damage);
                    CoordStruct where = MapClass.Cell2Coord(cur + offset, 2000);
                    if (MapClass.Instance.TryGetCellAt(where, out Pointer <CellClass> pCell))
                    {
                        BulletVelocity velocity = new BulletVelocity(0, 0, 0);
                        pBullet.Ref.MoveTo(where, velocity);
                        pBullet.Ref.SetTarget(pCell.Convert <AbstractClass>());
                    }
                }
            }
            else
            {
                Pointer <BulletClass> pBullet = CreateBullet(damage);

                const int radius = 600;
                CoordStruct where = curLocation + new CoordStruct(random.Next(-radius, radius), random.Next(-radius, radius), 2000);
                BulletVelocity velocity = new BulletVelocity(0, 0, 0);
                pBullet.Ref.MoveTo(where, velocity);
            }
        }
Example #2
0
        public override void OnFire(Pointer <AbstractClass> pTarget, int weaponIndex)
        {
            TechnoTypeExt extType = Owner.Type;
            Pointer <SuperWeaponTypeClass> pSWType = extType.FireSuperWeapon;

            if (pSWType.IsNull == false)
            {
                Pointer <TechnoClass> pTechno = Owner.OwnerObject;
                Pointer <HouseClass>  pOwner  = pTechno.Ref.Owner;
                Pointer <SuperClass>  pSuper  = pOwner.Ref.FindSuperWeapon(pSWType);

                CellStruct targetCell = MapClass.Coord2Cell(pTarget.Ref.GetCoords());
                //Logger.Log("FireSuperWeapon({2}):0x({3:X}) -> ({0}, {1})", targetCell.X, targetCell.Y, pSWType.Ref.Base.GetID(), (int)pSuper);
                pSuper.Ref.IsCharged = 1;
                pSuper.Ref.Launch(targetCell, true);
                pSuper.Ref.IsCharged = 0;
            }
        }