Improvements to Mobile to support smooth movement (like real-ra does it)
- McvDeploy got simpler.
- BUGFIX: Bullet no longer crashes when it damages a tree
This commit is contained in:
@@ -4,19 +4,19 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.GameRules;
|
||||
using IjwFramework.Types;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
interface IEffect
|
||||
{
|
||||
void Tick();
|
||||
IEnumerable<Pair<Sprite, float2>> Render();
|
||||
Player Owner { get; }
|
||||
}
|
||||
{
|
||||
interface IEffect
|
||||
{
|
||||
void Tick();
|
||||
IEnumerable<Pair<Sprite, float2>> Render();
|
||||
Player Owner { get; }
|
||||
}
|
||||
|
||||
class Bullet : IEffect
|
||||
{
|
||||
{
|
||||
public Player Owner { get; private set; }
|
||||
readonly Actor FiredBy;
|
||||
readonly WeaponInfo Weapon;
|
||||
@@ -49,22 +49,22 @@ namespace OpenRa.Game
|
||||
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
{
|
||||
if (t == 0)
|
||||
Game.PlaySound(Weapon.Report + ".aud", false);
|
||||
|
||||
t += 40;
|
||||
|
||||
if (t > TotalTime()) /* remove finished bullets */
|
||||
{
|
||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
Game.world.AddFrameEndTask(w => w.Add(new Explosion(Dest)));
|
||||
|
||||
var maxSpread = GetMaximumSpread();
|
||||
var hitActors = Game.FindUnitsInCircle(Dest, GetMaximumSpread());
|
||||
|
||||
foreach (var victim in hitActors)
|
||||
victim.InflictDamage(FiredBy, this, (int)GetDamageToInflict(victim));
|
||||
t += 40;
|
||||
|
||||
if (t > TotalTime()) /* remove finished bullets */
|
||||
{
|
||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
Game.world.AddFrameEndTask(w => w.Add(new Explosion(Dest)));
|
||||
|
||||
var maxSpread = GetMaximumSpread();
|
||||
var hitActors = Game.FindUnitsInCircle(Dest, GetMaximumSpread());
|
||||
|
||||
foreach (var victim in hitActors)
|
||||
victim.InflictDamage(FiredBy, this, (int)GetDamageToInflict(victim));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,21 +75,24 @@ namespace OpenRa.Game
|
||||
Src.ToFloat2(),
|
||||
Dest.ToFloat2(),
|
||||
(float)t / TotalTime()) - 0.5f * anim.Image.size);
|
||||
}
|
||||
|
||||
float GetMaximumSpread()
|
||||
}
|
||||
|
||||
float GetMaximumSpread()
|
||||
{
|
||||
return (int)(Warhead.Spread * Math.Log(Weapon.Damage, 2));
|
||||
}
|
||||
|
||||
float GetDamageToInflict(Actor target)
|
||||
{
|
||||
return (int)(Warhead.Spread * Math.Log(Weapon.Damage, 2));
|
||||
}
|
||||
|
||||
float GetDamageToInflict(Actor target)
|
||||
{
|
||||
/* todo: some things can't be damaged AT ALL by certain weapons! */
|
||||
var distance = (target.CenterLocation - Dest).Length;
|
||||
var rawDamage = Weapon.Damage * (float)Math.Exp(-distance / Warhead.Spread);
|
||||
var multiplier = Warhead.EffectivenessAgainst(target.unitInfo.Armor);
|
||||
|
||||
return rawDamage * multiplier;
|
||||
if( target.unitInfo == null ) // tree or other doodad
|
||||
return 0;
|
||||
|
||||
/* todo: some things can't be damaged AT ALL by certain weapons! */
|
||||
var distance = (target.CenterLocation - Dest).Length;
|
||||
var rawDamage = Weapon.Damage * (float)Math.Exp(-distance / Warhead.Spread);
|
||||
var multiplier = Warhead.EffectivenessAgainst(target.unitInfo.Armor);
|
||||
|
||||
return rawDamage * multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user