public Missile(MissileInfo info, ProjectileArgs args) { Info = info; Args = args; SubPxPosition = Args.src.ToPSubPos(); Altitude = Args.srcAltitude; Facing = Args.facing; if (info.Inaccuracy > 0) { offset = (PVecInt)(info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); } if (Info.Image != null) { anim = new Animation(Info.Image, () => Facing); anim.PlayRepeating("idle"); } if (Info.ContrailLength > 0) { Trail = new ContrailHistory(Info.ContrailLength, Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, Info.ContrailDelay); } }
public ParaBomb(ParaBombInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; var convertedVelocity = new WVec(info.Velocity.Y, -info.Velocity.X, info.Velocity.Z); velocity = convertedVelocity.Rotate(WRot.FromYaw(args.Facing)); acceleration = new WVec(info.Acceleration.Y, -info.Acceleration.X, info.Acceleration.Z); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(args.SourceActor.World, info.Image, () => args.Facing); if (!string.IsNullOrEmpty(info.OpenSequence)) { anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom))); } else { anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom)); } parachute = new Animation(args.SourceActor.World, info.Image, () => args.Facing); parachute.PlayThen(info.ParachuteOpeningSequence, () => parachute.PlayRepeating(info.ParachuteSequence)); } }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; hFacing = args.Facing.Facing; gravity = new WVec(0, 0, -info.Gravity); targetPosition = args.PassiveTarget; var limit = info.RangeLimit != WDist.Zero ? info.RangeLimit : args.Weapon.Range; rangeLimit = new WDist(Util.ApplyPercentageModifiers(limit.Length, args.RangeModifiers)); minLaunchSpeed = info.MinimumLaunchSpeed.Length > -1 ? info.MinimumLaunchSpeed.Length : info.Speed.Length; maxLaunchSpeed = info.MaximumLaunchSpeed.Length > -1 ? info.MaximumLaunchSpeed.Length : info.Speed.Length; maxSpeed = info.Speed.Length; minLaunchAngle = info.MinimumLaunchAngle; maxLaunchAngle = info.MaximumLaunchAngle; var world = args.SourceActor.World; if (world.SharedRandom.Next(100) <= info.LockOnProbability) { lockOn = true; } var inaccuracy = lockOn && info.LockOnInaccuracy.Length > -1 ? info.LockOnInaccuracy.Length : info.Inaccuracy.Length; if (inaccuracy > 0) { var maxInaccuracyOffset = Util.GetProjectileInaccuracy(info.Inaccuracy.Length, info.InaccuracyType, args); offset = WVec.FromPDF(world.SharedRandom, 2) * maxInaccuracyOffset / 1024; } DetermineLaunchSpeedAndAngle(world, out speed, out vFacing); velocity = new WVec(0, -speed, 0) .Rotate(new WRot(WAngle.FromFacing(vFacing), WAngle.Zero, WAngle.Zero)) .Rotate(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(hFacing))); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, () => renderFacing); anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } shadowColor = new float3(info.ShadowColor.R, info.ShadowColor.G, info.ShadowColor.B) / 255f; shadowAlpha = info.ShadowColor.A; }
public Bullet(BulletInfo info, ProjectileArgs args) { Info = info; Args = args; if (info.Inaccuracy > 0) { var factor = ((Args.dest - Args.src).ToCVec().Length) / args.weapon.Range; Args.dest += (PVecInt)(info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); Log.Write("debug", "Bullet with Inaccuracy; factor: #{0}; Projectile dest: {1}", factor, Args.dest); } if (Info.Image != null) { anim = new Animation(Info.Image, GetEffectiveFacing); anim.PlayRepeating("idle"); } if (Info.ContrailLength > 0) { Trail = new ContrailHistory(Info.ContrailLength, Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, Info.ContrailDelay); } }
public WarheadTrailProjectileEffect(WarheadTrailProjectileInfo info, ProjectileArgs args, int lifespan, int estimatedlifespan) { this.info = info; this.args = args; this.lifespan = lifespan; this.estimatedlifespan = estimatedlifespan; projectilepos = args.Source; source = args.Source; world = args.SourceActor.World; targetpos = args.PassiveTarget; facing = args.Facing; if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, new Func <WAngle>(GetEffectiveFacing)); anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } smokeTicks = info.TrailDelay; }
public SpriteRailgun(ProjectileArgs args, SpriteRailgunInfo info, Color beamColor) { this.args = args; this.info = info; target = args.PassiveTarget; BeamColor = beamColor; if (!string.IsNullOrEmpty(info.HitAnim)) { hitanim = new Animation(args.SourceActor.World, info.HitAnim); } CalculateVectors(); var pos = args.Source; var angle = WAngle.Zero; for (var i = cycleCount * info.QuantizationCount - 1; i >= 0; i--) { // Make it narrower near the end. var rad = i < info.QuantizationCount ? info.HelixRadius / 4 : i < 2 * info.QuantizationCount ? info.HelixRadius / 2 : info.HelixRadius; // Note: WAngle.Sin(x) = 1024 * Math.Sin(2pi/1024 * x) var offset = rad.Length * angle.Cos() * leftVector / (1024 * 1024) + rad.Length * angle.Sin() * upVector / (1024 * 1024); var animpos = pos + offset; args.SourceActor.World.AddFrameEndTask(w => w.Add(new SpriteEffect(animpos, angle, w, info.HelixAnim, info.HelixAnimSequence, info.HelixAnimPalette))); pos += forwardStep; angle += angleStep; } }
public LaserZapCA(LaserZapCAInfo info, ProjectileArgs args, Color color) { this.args = args; this.info = info; this.color = color; secondaryColor = info.SecondaryBeamUsePlayerColor ? args.SourceActor.Owner.Color : info.SecondaryBeamColor; target = args.PassiveTarget; // Game.Debug(target.ToString()); source = args.Source; if (info.Inaccuracy.Length > 0) { var inaccuracy = OpenRA.Mods.Common.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers); var maxOffset = inaccuracy * (target - source).Length / args.Weapon.Range.Length; target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024; } if (!string.IsNullOrEmpty(info.HitAnim)) { hitanim = new Animation(args.SourceActor.World, info.HitAnim); showHitAnim = true; } hasLaunchEffect = !string.IsNullOrEmpty(info.LaunchEffectImage) && !string.IsNullOrEmpty(info.LaunchEffectSequence); }
public IProjectile Create(ProjectileArgs args) { var bc = BeamPlayerColor ? Color.FromArgb(BeamColor.A, args.SourceActor.Owner.Color) : BeamColor; var hc = HelixPlayerColor ? Color.FromArgb(HelixColor.A, args.SourceActor.Owner.Color) : HelixColor; return(new Railgun(args, this, bc, hc)); }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; facing = args.Facing; targetPosition = args.PassiveTarget; if (info.Inaccuracy.Range > 0) { offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * info.Inaccuracy.Range / 1024; } if (info.Image != null) { anim = new Animation(args.SourceActor.World, info.Image, () => facing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0); } }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; facing = args.Facing; targetPosition = args.PassiveTarget; var world = args.SourceActor.World; if (world.SharedRandom.Next(100) <= info.LockOnProbability) { lockOn = true; } if (info.Inaccuracy.Range > 0) { var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Range, args.InaccuracyModifiers); offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024; } if (info.Image != null) { anim = new Animation(world, info.Image, () => facing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; trail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0); } }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; facing = args.Facing; targetPosition = args.PassiveTarget; // Convert ProjectileArg definitions to world coordinates // TODO: Change the yaml definitions so we don't need this var inaccuracy = (int)(info.Inaccuracy * 1024 / Game.CellSize); speed = info.Speed * 1024 / (5 * Game.CellSize); if (info.Inaccuracy > 0) { offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * inaccuracy / 1024; } if (info.Image != null) { anim = new Animation(info.Image, () => facing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0); } }
public GravityBomb(GravityBombInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; var convertedVelocity = new WVec(info.Velocity.Y, -info.Velocity.X, info.Velocity.Z); velocity = convertedVelocity.Rotate(WRot.FromYaw(args.Facing)); var convertedAcceleration = new WVec(info.Acceleration.Y, -info.Acceleration.X, info.Acceleration.Z); acceleration = convertedAcceleration.Rotate(WRot.FromYaw(args.Facing)); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(args.SourceActor.World, info.Image, () => args.Facing); if (!string.IsNullOrEmpty(info.OpenSequence)) { anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom))); } else { anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom)); } } shadowColor = new float3(info.ShadowColor.R, info.ShadowColor.G, info.ShadowColor.B) / 255f; shadowAlpha = info.ShadowColor.A / 255f; }
public Laser(ProjectileArgs args, LaserInfo info) { this.info = info; this.random = args.SourceActor.World.SharedRandom; this.colors = new Color[info.Radius]; for (var i = 0; i < info.Radius; i++) { var color = info.Color == Color.Transparent ? args.SourceActor.Owner.Color : info.Color; var bw = (float)((info.InnerLightness - info.OuterLightness) * i / (info.Radius - 1) + info.OuterLightness) / 0xff; var dstR = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.R / 0xff) : 2 * bw * ((float)color.R / 0xff); var dstG = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.G / 0xff) : 2 * bw * ((float)color.G / 0xff); var dstB = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.B / 0xff) : 2 * bw * ((float)color.B / 0xff); this.colors[i] = Color.FromArgb((int)(dstR * 0xff), (int)(dstG * 0xff), (int)(dstB * 0xff)); } var direction = args.PassiveTarget - args.Source; if (this.info.SegmentLength == WDist.Zero) { this.offsets = new[] { args.Source, args.PassiveTarget } } ; else { var numSegments = (direction.Length - 1) / info.SegmentLength.Length + 1; this.offsets = new WPos[numSegments + 1]; this.offsets[0] = args.Source; this.offsets[^ 1] = args.PassiveTarget;
public Bullet(BulletInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; source = args.Source; var world = args.SourceActor.World; if (info.LaunchAngle.Length > 1) { angle = new WAngle(world.SharedRandom.Next(info.LaunchAngle[0].Angle, info.LaunchAngle[1].Angle)); } else { angle = info.LaunchAngle[0]; } if (info.Speed.Length > 1) { speed = new WDist(world.SharedRandom.Next(info.Speed[0].Length, info.Speed[1].Length)); } else { speed = info.Speed[0]; } target = args.PassiveTarget; if (info.Inaccuracy.Length > 0) { var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers); var range = Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers); var maxOffset = inaccuracy * (target - pos).Length / range; target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024; } facing = (target - pos).Yaw.Facing; length = Math.Max((target - pos).Length / speed.Length, 1); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, new Func <int>(GetEffectiveFacing)); anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } smokeTicks = info.TrailDelay; remainingBounces = info.BounceCount; }
public IProjectile Create(ProjectileArgs args) { var palette = IsPlayerPalette ? MissilePalette + args.SourceActor.Owner.InternalName : MissilePalette; return(new NukeLaunch(args.SourceActor.Owner, MissileImage, WeaponInfo, palette, MissileUp, MissileDown, args.Source, args.PassiveTarget, DetonationAltitude, RemoveMissileOnDetonation, FlightVelocity, 0, FlightDelay, SkipAscent, TrailImage, TrailSequences, TrailPalette, TrailUsePlayerPalette, TrailDelay, TrailInterval)); }
public TeslaZap(TeslaZapInfo info, ProjectileArgs args) { this.args = args; this.info = info; ticksUntilRemove = info.Duration; damageDuration = info.DamageDuration > info.Duration ? info.Duration : info.DamageDuration; target = args.PassiveTarget; }
/// <summary> /// Applies modifications to a new projectile and removes disallowed ones /// </summary> /// <param name="args">The GetDataHandlerArgs object containing the player that sent the /// packet and the data of the packet</param> /// <returns>Whether or not the packet was handled (and should therefore not be processed /// by anything else)</returns> private bool HandleProjectile(GetDataHandlerArgs args) { var ident = args.Data.ReadInt16(); var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var knockback = args.Data.ReadSingle(); var dmg = args.Data.ReadInt16(); var owner = args.Data.ReadByte(); var type = args.Data.ReadInt16(); var aiFlags = (BitsByte)args.Data.ReadByte(); float ai0 = 0; float ai1 = 0; if (aiFlags[0]) { ai0 = args.Data.ReadSingle(); } if (aiFlags[1]) { ai1 = args.Data.ReadSingle(); } owner = (byte)args.Player.Index; float[] ai = new float[Projectile.maxAI]; bool handled = false; if (args.Player.TPlayer.hostile) { if (Controller.Projectiles.Count(p => p.netID == type && p.banned) > 0) { args.Player.RemoveProjectileAndTellIsIneffective(ident); } else { if (args.Player.IsDead) { handled = true; args.Player.RemoveProjectile(ident); } else { var projArgs = new ProjectileArgs( ident: ident, owner: owner, type: type, damage: dmg, velocity: vel, position: pos, ai0: ai0, ai1: ai1 ); handled = args.Player.ModifyProjectile(projArgs); } } } return(handled); }
public ElectricBolt(ElectricBoltInfo info, ProjectileArgs args) { this.args = args; this.info = info; var playerColors = args.SourceActor.Owner.Color; var colors = info.Colors; for (var i = 0; i < info.PlayerColorZaps; i++) { colors.Append(playerColors); } target = args.PassiveTarget; source = args.Source; random = args.SourceActor.World.LocalRandom; hasLaunchEffect = !string.IsNullOrEmpty(info.LaunchEffectImage) && !string.IsNullOrEmpty(info.LaunchEffectSequence); var direction = args.PassiveTarget - args.Source; if (info.Distortion != 0) { leftVector = new WVec(direction.Y, -direction.X, 0); if (leftVector.Length != 0) { leftVector = 1024 * leftVector / leftVector.Length; } upVector = leftVector.Length != 0 ? new WVec( -direction.X * direction.Z, -direction.Z * direction.Y, direction.X * direction.X + direction.Y * direction.Y) : new WVec(direction.Z, direction.Z, 0); if (upVector.Length != 0) { upVector = 1024 * upVector / upVector.Length; } } zaps = new HashSet <Pair <Color, WPos[]> >(); foreach (var c in colors) { var numSegments = (direction.Length - 1) / info.SegmentLength.Length + 1; var offsets = new WPos[numSegments + 1]; offsets[0] = args.Source; offsets[offsets.Length - 1] = args.PassiveTarget; var angle = new WAngle((-info.Angle.Angle / 2) + random.Next(info.Angle.Angle)); for (var i = 1; i < numSegments; i++) { offsets[i] = WPos.LerpQuadratic(source, target, angle, i, numSegments); } zaps.Add(Pair.New(c, offsets)); } }
void SeedResources(Actor self) { var pieces = self.World.SharedRandom.Next(info.Pieces[0], info.Pieces[1]) * ticks / growTicks; if (pieces < info.Pieces[0]) { pieces = info.Pieces[0]; } var cells = self.World.Map.FindTilesInAnnulus(self.Location, 1, info.Range); for (var i = 0; i < pieces; i++) { var cell = cells.SkipWhile(p => resLayer.GetResourceType(p) == resType && resLayer.IsFull(p)).Cast <CPos?>().RandomOrDefault(self.World.SharedRandom); if (cell == null) { cell = cells.Random(self.World.SharedRandom); } var args = new ProjectileArgs { Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()], Facing = WAngle.Zero, CurrentMuzzleFacing = () => WAngle.Zero, DamageModifiers = self.TraitsImplementing <IFirepowerModifier>() .Select(a => a.GetFirepowerModifier()).ToArray(), InaccuracyModifiers = self.TraitsImplementing <IInaccuracyModifier>() .Select(a => a.GetInaccuracyModifier()).ToArray(), RangeModifiers = self.TraitsImplementing <IRangeModifier>() .Select(a => a.GetRangeModifier()).ToArray(), Source = self.CenterPosition, CurrentSource = () => self.CenterPosition, SourceActor = self, PassiveTarget = self.World.Map.CenterOfCell(cell.Value) }; self.World.AddFrameEndTask(_ => { if (args.Weapon.Projectile != null) { var projectile = args.Weapon.Projectile.Create(args); if (projectile != null) { self.World.Add(projectile); } if (args.Weapon.Report != null && args.Weapon.Report.Any()) { Game.Sound.Play(SoundType.World, args.Weapon.Report, self.World, self.CenterPosition); } } }); } }
public override void DoImpact(Target target, Actor firedBy, IEnumerable <int> damageModifiers) { var map = firedBy.World.Map; var targetCell = map.CellContaining(target.CenterPosition); if (!IsValidImpact(target.CenterPosition, firedBy)) { return; } var targetCells = map.FindTilesInCircle(targetCell, Range); foreach (var cell in targetCells) { var tc = Target.FromCell(firedBy.World, cell); if (!weapon.IsValidAgainst(tc, firedBy.World, firedBy)) { continue; } var args = new ProjectileArgs { Weapon = weapon, Facing = (map.CenterOfCell(cell) - target.CenterPosition).Yaw.Facing, DamageModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IFirepowerModifier>() .Select(a => a.GetFirepowerModifier()).ToArray() : new int[0], InaccuracyModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IInaccuracyModifier>() .Select(a => a.GetInaccuracyModifier()).ToArray() : new int[0], RangeModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IRangeModifier>() .Select(a => a.GetRangeModifier()).ToArray() : new int[0], Source = target.CenterPosition, SourceActor = firedBy, PassiveTarget = map.CenterOfCell(cell), GuidedTarget = tc }; if (args.Weapon.Projectile != null) { var projectile = args.Weapon.Projectile.Create(args); if (projectile != null) { firedBy.World.AddFrameEndTask(w => w.Add(projectile)); } if (args.Weapon.Report != null && args.Weapon.Report.Any()) { Game.Sound.Play(args.Weapon.Report.Random(firedBy.World.SharedRandom), target.CenterPosition); } } } }
public Bullet(BulletInfo info, ProjectileArgs args) { this.info = info; this.args = args; this.pos = args.Source; var world = args.SourceActor.World; if (info.Angle.Length > 1) { angle = new WAngle(world.SharedRandom.Next(info.Angle[0].Angle, info.Angle[1].Angle)); } else { angle = info.Angle[0]; } if (info.Speed.Length > 1) { speed = new WRange(world.SharedRandom.Next(info.Speed[0].Range, info.Speed[1].Range)); } else { speed = info.Speed[0]; } target = args.PassiveTarget; if (info.Inaccuracy.Range > 0) { var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Range, args.InaccuracyModifiers); var maxOffset = inaccuracy * (target - pos).Length / args.Weapon.Range.Range; target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024; } facing = OpenRA.Traits.Util.GetFacing(target - pos, 0); length = Math.Max((target - pos).Length / speed.Range, 1); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, GetEffectiveFacing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } smokeTicks = info.TrailDelay; }
public override void DoImpact(Target target, Actor firedBy, IEnumerable <int> damageModifiers) { if (!target.IsValidFor(firedBy)) { return; } var world = firedBy.World; var map = world.Map; if (!IsValidImpact(target.CenterPosition, firedBy)) { return; } var targetpos = UseZOffsetAsAbsoluteHeight ? new WPos(target.CenterPosition.X + Offset.X, target.CenterPosition.Y + Offset.Y, map.CenterOfCell(map.CellContaining(target.CenterPosition)).Z + Offset.Z) : target.CenterPosition + Offset; var fragmentTarget = Target.FromPos(targetpos); var args = new ProjectileArgs { Weapon = weapon, Facing = (fragmentTarget.CenterPosition - target.CenterPosition).Yaw.Facing, DamageModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IFirepowerModifier>() .Select(a => a.GetFirepowerModifier()).ToArray() : new int[0], InaccuracyModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IInaccuracyModifier>() .Select(a => a.GetInaccuracyModifier()).ToArray() : new int[0], RangeModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IRangeModifier>() .Select(a => a.GetRangeModifier()).ToArray() : new int[0], Source = target.CenterPosition, CurrentSource = () => target.CenterPosition, SourceActor = firedBy, GuidedTarget = fragmentTarget, PassiveTarget = fragmentTarget.CenterPosition }; if (args.Weapon.Projectile != null) { var projectile = args.Weapon.Projectile.Create(args); if (projectile != null) { firedBy.World.AddFrameEndTask(w => w.Add(projectile)); } if (args.Weapon.Report != null && args.Weapon.Report.Any()) { Game.Sound.Play(SoundType.World, args.Weapon.Report.Random(firedBy.World.SharedRandom), target.CenterPosition); } } }
public override void DoImpact(Target target, Actor firedBy, IEnumerable <int> damageModifiers) { Actor selftarget = firedBy; if (!IsValidImpact(target.CenterPosition, firedBy)) { return; } Target shrapnelTarget = Target.Invalid; shrapnelTarget = Target.FromActor(selftarget); if (shrapnelTarget.Type != TargetType.Invalid) { var args = new ProjectileArgs { Weapon = weapon, Facing = (shrapnelTarget.CenterPosition - target.CenterPosition).Yaw.Facing, DamageModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IFirepowerModifier>() .Select(a => a.GetFirepowerModifier()).ToArray() : new int[0], InaccuracyModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IInaccuracyModifier>() .Select(a => a.GetInaccuracyModifier()).ToArray() : new int[0], RangeModifiers = !firedBy.IsDead ? firedBy.TraitsImplementing <IRangeModifier>() .Select(a => a.GetRangeModifier()).ToArray() : new int[0], Source = target.CenterPosition, SourceActor = firedBy, GuidedTarget = shrapnelTarget, PassiveTarget = shrapnelTarget.CenterPosition }; if (args.Weapon.Projectile != null) { var projectile = args.Weapon.Projectile.Create(args); if (projectile != null) { firedBy.World.AddFrameEndTask(w => w.Add(projectile)); } if (args.Weapon.Report != null && args.Weapon.Report.Any()) { Game.Sound.Play(SoundType.World, args.Weapon.Report.Random(firedBy.World.SharedRandom), target.CenterPosition); } } } }
public void Killed(Actor self, AttackInfo attack) { if (IsTraitDisabled) { return; } foreach (var wep in Info.WeaponInfos) { var pieces = self.World.SharedRandom.Next(Info.Pieces[0], Info.Pieces[1]); var range = self.World.SharedRandom.Next(Info.Range[0].Length, Info.Range[1].Length); for (var i = 0; pieces > i; i++) { var rotation = WRot.FromFacing(self.World.SharedRandom.Next(1024)); var args = new ProjectileArgs { Weapon = wep, Facing = self.World.SharedRandom.Next(-1, 255), CurrentMuzzleFacing = () => 0, DamageModifiers = self.TraitsImplementing <IFirepowerModifier>() .Select(a => a.GetFirepowerModifier()).ToArray(), InaccuracyModifiers = self.TraitsImplementing <IInaccuracyModifier>() .Select(a => a.GetInaccuracyModifier()).ToArray(), RangeModifiers = self.TraitsImplementing <IRangeModifier>() .Select(a => a.GetRangeModifier()).ToArray(), Source = self.CenterPosition, CurrentSource = () => self.CenterPosition, SourceActor = self, PassiveTarget = self.CenterPosition + new WVec(range, 0, 0).Rotate(rotation) }; self.World.AddFrameEndTask(x => { if (args.Weapon.Projectile != null) { var projectile = args.Weapon.Projectile.Create(args); if (projectile != null) { self.World.Add(projectile); } if (args.Weapon.Report != null && args.Weapon.Report.Any()) { Game.Sound.Play(SoundType.World, args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } } }); } } }
public RadBeam(ProjectileArgs args, RadBeamInfo info, Color color) { this.args = args; this.info = info; target = args.PassiveTarget; if (!string.IsNullOrEmpty(info.HitAnim)) { hitanim = new Animation(args.SourceActor.World, info.HitAnim); } }
public LaserZap(ProjectileArgs args, LaserZapInfo info, Color color) { this.args = args; this.info = info; this.color = color; if (info.Explosion != null) { this.explosion = new Animation(info.Explosion); } }
public LaserZap(ProjectileArgs args, LaserZapInfo info, Color color) { this.args = args; this.info = info; this.color = color; this.target = args.PassiveTarget; if (info.HitAnim != null) { this.hitanim = new Animation(info.HitAnim); } }
public LaserZap(ProjectileArgs args, LaserZapInfo info, Color color) { this.args = args; this.info = info; this.color = color; this.target = args.PassiveTarget; if (!string.IsNullOrEmpty(info.HitAnim)) { this.hitanim = new Animation(args.SourceActor.World, info.HitAnim); } }
public TeslaZap(TeslaZapInfo info, ProjectileArgs args) { Args = args; var bright = SequenceProvider.GetSequence(info.Image, "bright"); var dim = SequenceProvider.GetSequence(info.Image, "dim"); for (var n = 0; n < info.DimZaps; n++) { renderables.AddRange(DrawZapWandering(args.src, args.dest, dim)); } for (var n = 0; n < info.BrightZaps; n++) { renderables.AddRange(DrawZapWandering(args.src, args.dest, bright)); } }
public GravityBomb(GravityBombInfo info, ProjectileArgs args) { Args = args; altitude = args.srcAltitude; anim = new Animation(info.Image); if (anim.HasSequence("open")) { anim.PlayThen("open", () => anim.PlayRepeating("idle")); } else { anim.PlayRepeating("idle"); } }