Skip to content

Commit

Permalink
clean up bullets somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisforbes committed Jul 9, 2010
1 parent 5e1c63e commit 20785a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
26 changes: 23 additions & 3 deletions OpenRA.Mods.RA/Effects/Bullet.cs
Expand Up @@ -66,13 +66,33 @@ public Bullet(BulletInfo info, ProjectileArgs args)

if (Info.Image != null)
{
anim = new Animation(Info.Image, () => Traits.Util.GetFacing(Args.dest - Args.src, 0));
anim = new Animation(Info.Image, GetEffectiveFacing);
anim.PlayRepeating("idle");
}
}

int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; }

float GetAltitude()
{
var at = (float)t / TotalTime();
return (Args.dest - Args.src).Length * Info.Angle * 4 * at * (1 - at);
}

int GetEffectiveFacing()
{
var at = (float)t / TotalTime();
var attitude = Info.Angle * (1 - 2 * at);

var rawFacing = Traits.Util.GetFacing(Args.dest - Args.src, 0);
var u = (rawFacing % 128) / 128f;
var scale = 512 * u * (1 - u);

return (int)(rawFacing < 128
? rawFacing - scale * attitude
: rawFacing + scale * attitude);
}

public void Tick( World world )
{
t += 40;
Expand All @@ -88,7 +108,7 @@ public void Tick( World world )
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);

var highPos = (Info.High || Info.Angle > 0)
? (pos - new float2(0, (Args.dest - Args.src).Length * Info.Angle * 4 * at * (1 - at)))
? (pos - new float2(0, GetAltitude()))
: pos;

world.AddFrameEndTask(w => w.Add(
Expand Down Expand Up @@ -126,7 +146,7 @@ public IEnumerable<Renderable> Render()
if (Info.Shadow)
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow");

var highPos = pos - new float2(0, (Args.dest - Args.src).Length * Info.Angle * 4 * at * (1 - at));
var highPos = pos - new float2(0, GetAltitude());

yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette);
}
Expand Down
1 change: 1 addition & 0 deletions mods/ra/weapons.yaml
Expand Up @@ -633,6 +633,7 @@ SCUD:
Trail: smokey
Inaccuracy: 5
Image: V2
Angle: .1
Warhead:
Spread: 8
Verses: 90%,75%,60%,25%,100%
Expand Down

0 comments on commit 20785a6

Please sign in to comment.