Closes #4463. Added Shrapnel, as well as variable velocity and arc for bullets
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -22,8 +22,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class BulletInfo : IProjectileInfo
|
||||
{
|
||||
[Desc("Projectile speed in WRange / tick")]
|
||||
public readonly WRange Speed = new WRange(17);
|
||||
[Desc("Projectile speed in WRange / tick, two values indicate variable velocity")]
|
||||
public readonly WRange[] Speed = { new WRange(17) };
|
||||
public readonly string Trail = null;
|
||||
[Desc("Maximum offset at the maximum range")]
|
||||
public readonly WRange Inaccuracy = WRange.Zero;
|
||||
@@ -31,7 +31,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
[Desc("Check for whether an actor with Wall: trait blocks fire")]
|
||||
public readonly bool High = false;
|
||||
public readonly bool Shadow = false;
|
||||
public readonly WAngle Angle = WAngle.Zero;
|
||||
[Desc("Arc in WAngles, two values indicate variable arc.")]
|
||||
public readonly WAngle[] Angle = { WAngle.Zero };
|
||||
public readonly int TrailInterval = 2;
|
||||
public readonly int TrailDelay = 1;
|
||||
public readonly int ContrailLength = 0;
|
||||
@@ -46,6 +47,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
readonly BulletInfo info;
|
||||
readonly ProjectileArgs args;
|
||||
[Sync] readonly WAngle angle;
|
||||
[Sync] readonly WRange speed;
|
||||
|
||||
ContrailRenderable trail;
|
||||
Animation anim;
|
||||
@@ -63,6 +66,17 @@ namespace OpenRA.Mods.RA.Effects
|
||||
this.args = args;
|
||||
this.pos = args.Source;
|
||||
|
||||
if (info.Angle.Length > 1 && info.Speed.Length > 1)
|
||||
{
|
||||
angle = new WAngle(args.SourceActor.World.SharedRandom.Next(info.Angle[0].Angle, info.Angle[1].Angle));
|
||||
speed = new WRange(args.SourceActor.World.SharedRandom.Next(info.Speed[0].Range, info.Speed[1].Range));
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = info.Angle[0];
|
||||
speed = info.Speed[0];
|
||||
}
|
||||
|
||||
target = args.PassiveTarget;
|
||||
if (info.Inaccuracy.Range > 0)
|
||||
{
|
||||
@@ -71,7 +85,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
}
|
||||
|
||||
facing = Traits.Util.GetFacing(target - pos, 0);
|
||||
length = Math.Max((target - pos).Length / info.Speed.Range, 1);
|
||||
length = Math.Max((target - pos).Length / speed.Range, 1);
|
||||
|
||||
if (info.Image != null)
|
||||
{
|
||||
@@ -91,7 +105,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
int GetEffectiveFacing()
|
||||
{
|
||||
var at = (float)ticks / (length - 1);
|
||||
var attitude = info.Angle.Tan() * (1 - 2 * at) / (4 * 1024);
|
||||
var attitude = angle.Tan() * (1 - 2 * at) / (4 * 1024);
|
||||
|
||||
var u = (facing % 128) / 128f;
|
||||
var scale = 512 * u * (1 - u);
|
||||
@@ -106,11 +120,11 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (anim != null)
|
||||
anim.Tick();
|
||||
|
||||
pos = WPos.LerpQuadratic(args.Source, target, info.Angle, ticks, length);
|
||||
pos = WPos.LerpQuadratic(args.Source, target, angle, ticks, length);
|
||||
|
||||
if (info.Trail != null && --smokeTicks < 0)
|
||||
{
|
||||
var delayedPos = WPos.LerpQuadratic(args.Source, target, info.Angle, ticks - info.TrailDelay, length);
|
||||
var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length);
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail)));
|
||||
smokeTicks = info.TrailInterval;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user