Skip to content

Commit

Permalink
All Debris changed to ProjetcileHusk for perf.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnqbob committed Oct 18, 2023
1 parent 9075612 commit 83debc2
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 67 deletions.
31 changes: 20 additions & 11 deletions OpenRA.Mods.Sp/Projectiles/ProjetcileHusk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ public class ProjetcileHuskInfo : IProjectileInfo
[Desc("Projectile movement vector per tick (forward, right, up), use negative values for opposite directions.")]
public readonly WVec Velocity = WVec.Zero;

[Desc("The X of the speed becomes dead actor speed by using range modifier, coop with " + nameof(SpawnHuskEffectOnDeath) + ".")]
public readonly bool UseRangeModifierAsVelocityX = true;

[Desc("Movement random factor on Velocity.")]
public readonly WVec? VelocityRandomFactor = null;

[Desc("Value added to Velocity every tick when spin is activated.")]
public readonly WVec AccelerationWhenSpin = new(0, 0, -10);

[Desc("Value added to Velocity every tickwhen spin is NOT activated.")]
public readonly WVec Acceleration = new(0, 0, -10);

[Desc("The X of the speed becomes dead actor speed by using range modifier, coop with " + nameof(SpawnHuskEffectOnDeath) + ".")]
public readonly bool UseRangeModifierAsVelocityX = true;

[Desc("Chance of Spin. Activate Spin.")]
public readonly int SpinChance = 100;

Expand All @@ -68,7 +71,7 @@ public class ProjetcileHuskInfo : IProjectileInfo
[Desc("begin spin speed.")]
public readonly int Spin = 0;

[Desc("Revert the Y of the speed, spin and horizongtal acceleration at 50% randomness.")]
[Desc("Revert the Y of the speed, and X, Y of acceleration at 50% randomness.")]
public readonly bool HorizontalRevert = false;

[Desc("Trail animation.")]
Expand Down Expand Up @@ -124,10 +127,11 @@ public ProjetcileHusk(ProjetcileHuskInfo info, ProjectileArgs args)
var world = args.SourceActor.World;

var vx = info.UseRangeModifierAsVelocityX && args.RangeModifiers.Length > 0 ? args.RangeModifiers[0] : info.Velocity.X;
var vec = info.VelocityRandomFactor != null ? new WVec(vx + world.SharedRandom.Next(info.VelocityRandomFactor.Value.X), info.Velocity.Y + world.SharedRandom.Next(info.VelocityRandomFactor.Value.Y), info.Velocity.Z + world.SharedRandom.Next(info.VelocityRandomFactor.Value.Z)) : new WVec(vx, info.Velocity.Y, info.Velocity.Z);

if (info.HorizontalRevert && world.SharedRandom.Next(2) == 0)
{
velocity = new WVec(-info.Velocity.Y, -vx, info.Velocity.Z);
velocity = new WVec(-vec.Y, -vec.X, vec.Z);
if (info.MaximumSpinSpeed > 0 && world.SharedRandom.Next(1, 101) <= info.SpinChance)
{
acceleration = new WVec(-info.AccelerationWhenSpin.Y, info.AccelerationWhenSpin.X, info.AccelerationWhenSpin.Z);
Expand All @@ -140,7 +144,7 @@ public ProjetcileHusk(ProjetcileHuskInfo info, ProjectileArgs args)
}
else
{
velocity = new WVec(info.Velocity.Y, -vx, info.Velocity.Z);
velocity = new WVec(vec.Y, -vec.X, vec.Z);
if (info.MaximumSpinSpeed > 0 && world.SharedRandom.Next(1, 101) <= info.SpinChance)
{
acceleration = new WVec(info.AccelerationWhenSpin.Y, -info.AccelerationWhenSpin.X, info.AccelerationWhenSpin.Z);
Expand Down Expand Up @@ -174,13 +178,18 @@ public void Tick(World world)
{
lastPos = pos;
pos += velocity;
var spinAngle = new WAngle(spin);
facing += spinAngle;
acceleration = acceleration.Rotate(WRot.FromYaw(spinAngle));
velocity += acceleration;

spin = Math.Abs(spin) < Math.Abs(maxSpin) ? spin + spinAcc : maxSpin;
if (maxSpin != 0)
{
var spinAngle = new WAngle(spin);
facing += spinAngle;
acceleration = acceleration.Rotate(WRot.FromYaw(spinAngle));
spin = Math.Abs(spin) < Math.Abs(maxSpin) ? spin + spinAcc : maxSpin;
}

velocity += acceleration;

// Explodes
if (pos.Z <= args.PassiveTarget.Z)
{
pos += new WVec(0, 0, args.PassiveTarget.Z - pos.Z);
Expand Down
7 changes: 4 additions & 3 deletions OpenRA.Mods.Sp/Traits/SpawnSparks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ void ITick.Tick(Actor self)
var offset = 1024 / amount;
for (var i = 0; i < amount; i++)
{
var rotation = WRot.FromYaw(new WAngle(i * offset));
var facing = new WAngle(i * offset);
var rotation = WRot.FromYaw(facing);
var targetpos = epicenter + new WVec(weapon.Range.Length, 0, 0).Rotate(rotation);
var radiusTarget = Target.FromPos(new WPos(targetpos.X, targetpos.Y, Info.ForceToGround ? map.CenterOfCell(map.CellContaining(targetpos)).Z : targetpos.Z));

var projectileArgs = new ProjectileArgs
{
Weapon = weapon,
Facing = default,
CurrentMuzzleFacing = () => default,
Facing = facing,
CurrentMuzzleFacing = () => facing,

DamageModifiers = Array.Empty<int>(),

Expand Down
16 changes: 8 additions & 8 deletions mods/sp/rules/vehicles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ APC:
Weapon: ApcVulcanLine
PauseOnCondition: empdisable || !Attacking || attack-air
LocalOffset: 350,0,700
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 350,0,700
CasingTargetOffset: -1024,0, 0
RequiresCondition: !apammo
Expand All @@ -283,7 +283,7 @@ APC:
Weapon: ApcVulcanLineAP
PauseOnCondition: empdisable || !Attacking || attack-air
LocalOffset: 350,0,700
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 350,0,700
CasingTargetOffset: -1024,0, 0
RequiresCondition: apammo
Expand All @@ -292,7 +292,7 @@ APC:
Weapon: ApcVulcanLineAA
PauseOnCondition: empdisable || !Attacking || attack-ground
LocalOffset: 290,0,1020
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 290,0,1020
CasingTargetOffset: -1024,0, 0
RequiresCondition: !apammo
Expand All @@ -301,7 +301,7 @@ APC:
Weapon: ApcVulcanLineAPAA
PauseOnCondition: empdisable || !Attacking || attack-ground
LocalOffset: 290,0,1020
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 290,0,1020
CasingTargetOffset: -1024,0, 0
RequiresCondition: apammo
Expand Down Expand Up @@ -701,7 +701,7 @@ HMEC:
Weapon: MKIIVulcanLine
LocalOffset: 1638,0,800, 1638,0,800
Name: tertiary
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 1638,0,800, 1638,0,800
CasingTargetOffset: 620, 512, 0, 620, -512, 0
PauseOnCondition: empdisable
Expand All @@ -710,7 +710,7 @@ HMEC:
Weapon: MKIIVulcanLineAP
LocalOffset: 1638,0,800, 1638,0,800
Name: tertiary
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 1638,0,800, 1638,0,800
CasingTargetOffset: 620, 512, 0, 620, -512, 0
PauseOnCondition: empdisable
Expand Down Expand Up @@ -1967,7 +1967,7 @@ MUTQUAD:
Armament@Fakebullet:
Weapon: QuadFireLine
LocalOffset: 800,90,370, 800,-90,370
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 100,20,400, 100,-20,400
CasingTargetOffset: -256, 512, 0, -256, -512, 0
PauseOnCondition: empdisable || attack-air
Expand All @@ -1977,7 +1977,7 @@ MUTQUAD:
Weapon: QuadFireLineAA
Name: secondary
LocalOffset: 500,90,1000, 500,-90,1000
CasingWeapon: CasingDebris
CasingWeapon: CasingDebrisLong
CasingSpawnLocalOffset: 100,20,600, 100,-20,600
CasingTargetOffset: -256, 512, 0, -256, -512, 0
PauseOnCondition: empdisable || attack-ground
Expand Down
100 changes: 56 additions & 44 deletions mods/sp/weapons/explosionweapons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,23 @@ AmmoCrateExplo:
SparkDebris:
Range: 1c00
ReloadDelay: 100
Projectile: Bullet
Speed: 50, 125
Inaccuracy: 256
InaccuracyType: PerCellIncrement
LaunchAngle: 200, 250
Projectile: ProjetcileHusk
Image: sparkprojectile
Velocity: 30, 0, 200
VelocityRandomFactor: 50, 50, 200
Acceleration: 0, 0, -30
HorizontalRevert: true
UseRangeModifierAsVelocityX: false

LightningSparkDebris:
Range: 1c00
Projectile: Bullet
Speed: 55, 90
Inaccuracy: 4c0
InaccuracyType: PerCellIncrement
LaunchAngle: 150, 250
Projectile: ProjetcileHusk
Image: sparkprojectile
Velocity: 30, 0, 300
VelocityRandomFactor: 50, 50, 400
Acceleration: 0, 0, -30
HorizontalRevert: true
UseRangeModifierAsVelocityX: false
Warhead@2Eff: CreateEffect
Explosions: marnflash7
ExplosionPalette: MarnAlphaAlpha
Expand All @@ -386,14 +388,14 @@ CasingDebris:
ReloadDelay: 60
Range: 0c1
ValidTargets: Infantry, Vehicle, Building, Wall, Ground, Water, Air
Projectile: Bullet
Speed: 150
Inaccuracy: 0c256
InaccuracyType: Absolute
LaunchAngle: 164
Projectile: ProjetcileHusk
Velocity: 50, 0, 100
VelocityRandomFactor: 0, 15, 30
Acceleration: 0, 0, -30
HorizontalRevert: true
Image: casing
Sequences: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Shadow: true
UseRangeModifierAsVelocityX: false
Warhead@: CreateEffect
Explosions: casingscorch, casingscorch2, casingscorch3, casingscorch4, casingscorch5, casingscorch6, casingscorch7
ExplosionPalette: effect
Expand All @@ -409,40 +411,47 @@ CasingDebris:
AirThreshold: 8c0
ImpactActors: false

CasingDebrisLong:
Inherits: CasingDebris
Projectile: ProjetcileHusk
Velocity: 100, 0, 100
VelocityRandomFactor: 0, 25, 30

ShellCasingDebris:
Inherits: CasingDebris
MinRange: 0c512
Range: 1c764
Projectile: Bullet
Speed: 100
Inaccuracy: 128
LaunchAngle: 164
Projectile: ProjetcileHusk
Velocity: 90, 0, 100
VelocityRandomFactor: 0, 30, 30
Image: shellcasing
Shadow: true
Warhead@: CreateEffect
Explosions: shellcasingscorch, shellcasingscorch2, shellcasingscorch3, shellcasingscorch4, shellcasingscorch5, shellcasingscorch6, shellcasingscorch7

WoodDebris:
Inherits: CasingDebris
ReloadDelay: 60
Range: 1c0
Projectile: Bullet
Speed: 50, 125
Inaccuracy: 256
LaunchAngle: 91, 255
Image: wooddebris
Projectile: ProjetcileHusk
Velocity: 25, 0, 80
VelocityRandomFactor: 0, 25, 150
Acceleration: 0, 0, -15
HorizontalRevert: true
Shadow: true
UseRangeModifierAsVelocityX: false
Image: wooddebris
Sequences: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Warhead@: CreateEffect
Explosions: woodbits, woodbits2, woodbits3, woodbits4, woodbits5, woodbits6, woodbits7

WoodDebrisBig:
Inherits: WoodDebris
ReloadDelay: 60
Range: 2c0
Projectile: Bullet
Speed: 25, 60
Inaccuracy: 256
LaunchAngle: 180, 255
Projectile: ProjetcileHusk
Velocity: 15, 0, 20
VelocityRandomFactor: 0, 15, 90
Image: wooddebrisbig
Sequences: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Shadow: true
Warhead@: CreateEffect
Explosions: woodbitsbig, woodbitsbig2, woodbitsbig3, woodbitsbig4, woodbitsbig5, woodbitsbig6, woodbitsbig7
Expand All @@ -453,11 +462,12 @@ SmallDebris:
ReloadDelay: 60
Range: 4c0
Report:
Projectile: Bullet
Speed: 50, 125
Inaccuracy: 4c0
InaccuracyType: PerCellIncrement
LaunchAngle: 91, 255
Projectile: ProjetcileHusk
Velocity: 30, 0, 300
VelocityRandomFactor: 50, 50, 400
Acceleration: 0, 0, -15
HorizontalRevert: true
UseRangeModifierAsVelocityX: false
Image: dbrissm
Sequences: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Shadow: true
Expand All @@ -470,9 +480,12 @@ LargeDebris:
ReloadDelay: 60
Range: 4c0
Report:
Projectile: BulletAS
Speed: 50, 125
LaunchAngle: 91, 255
Projectile: ProjetcileHusk
Velocity: 20, 0, 300
VelocityRandomFactor: 40, 40, 300
Acceleration: 0, 0, -15
HorizontalRevert: true
UseRangeModifierAsVelocityX: false
Image: dbrislg
Sequences: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
Shadow: true
Expand All @@ -484,7 +497,7 @@ LargeDebris:

SmallDebrisScrin:
Inherits: SmallDebris
Projectile: BulletAS
Projectile: ProjetcileHusk
Palette: jascblue
Warhead@2: SpawnSmokeParticle
Sequences: scrinfire3, scrinfire4
Expand All @@ -493,7 +506,7 @@ SmallDebrisScrin:

LargeDebrisScrin:
Inherits: LargeDebris
Projectile: BulletAS
Projectile: ProjetcileHusk
Palette: jascblue
Warhead@2: SpawnSmokeParticle
Sequences: scrinfire2, scrinfire3
Expand All @@ -504,7 +517,7 @@ LargeDebrisScrin:

TSmallDebris:
Inherits: SmallDebris
Projectile: BulletAS
Projectile: ProjetcileHusk
Palette: greentibpal
-Warhead@2:
Warhead@2Eff: CreateEffect
Expand All @@ -516,7 +529,7 @@ TSmallDebris:

TLargeDebris:
Inherits: LargeDebris
Projectile: BulletAS
Projectile: ProjetcileHusk
Palette: greentibpal
-Warhead@2:
Warhead@2Eff: CreateEffect
Expand All @@ -533,7 +546,6 @@ QuickSmoke:
Warhead@smoke: CreateEffect
Delay: 0


QuickTibSmoke:
Inherits: ^DelayedSmokeEffect
Range: 2c0
Expand Down
2 changes: 1 addition & 1 deletion mods/sp/weapons/mutweapons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ MutSWLightningCharge:
Warhead@5op: FireRadius
Weapon: LightningSparkDebris
ImpactActors: false
Amount: 1
Amount: 2
ValidTargets: Infantry, Vehicle, Building, Wall, Ground, Water, Air
AirThreshold: 8c0
-Warhead@6Eff:

0 comments on commit 83debc2

Please sign in to comment.