Skip to content

Commit

Permalink
Merge pull request #317 from hackerspace-ntnu/feature/fix-displayed-s…
Browse files Browse the repository at this point in the history
…tats

Make displayed stats match actual stats and adjust ranges
  • Loading branch information
toberge authored Nov 27, 2023
2 parents 4a31cb7 + 81e7f04 commit 1ebac5b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 38 deletions.
5 changes: 2 additions & 3 deletions Assets/Prefabs/GunParts/BulletBarrel.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,8 @@ MonoBehaviour:
projectileRotation: {x: 0, y: 0, z: 0, w: 1}
stats: {fileID: 0}
player: {fileID: 0}
maxDistance: 40
collisionSamples: 80
bulletsPerShot: 1
maxDistance: 100
collisionSamplesPerUnit: 2
trail: {fileID: 1393106611541694855}
flash: {fileID: 261841362781268065}
animator: {fileID: 2824888147584701410}
Expand Down
7 changes: 5 additions & 2 deletions Assets/Prefabs/GunParts/CannonBarrel.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,17 @@ MonoBehaviour:
m_EditorClassIdentifier:
statModifiers:
- name: ProjectileDamage
addition: 30
addition: 40
multiplier: 0
exponential: 1
- name: Firerate
addition: 0
multiplier: 0
exponential: 0.3
- name: ProjectileSpeedFactor
addition: 0
multiplier: 0
exponential: 0.5
outputs:
- {fileID: 5765902433490691002}
attachmentPoints:
Expand All @@ -233,7 +237,6 @@ MonoBehaviour:
animator: {fileID: 6553004223414227404}
maxProjectiles: 300
maxDistance: 100
speed: 9
size: 0.2
vfx: {fileID: 562807672298037748}
shouldRicochet: 0
Expand Down
5 changes: 2 additions & 3 deletions Assets/Prefabs/GunParts/CoilBarrel.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,8 @@ MonoBehaviour:
projectileRotation: {x: 0, y: 0, z: 0, w: 1}
stats: {fileID: 0}
player: {fileID: 0}
maxDistance: 40
collisionSamples: 80
bulletsPerShot: 1
maxDistance: 100
collisionSamplesPerUnit: 2
trail: {fileID: 6753720039035056053}
flash: {fileID: 261841362781268065}
animator: {fileID: 8505203738795632164}
Expand Down
9 changes: 6 additions & 3 deletions Assets/Prefabs/GunParts/ShotgunBarrel.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ MonoBehaviour:
addition: 10
multiplier: 0
exponential: 1
- name: ProjectilesPerShot
addition: 0
multiplier: 10
exponential: 1
outputs:
- {fileID: 5765902433490691002}
attachmentPoints:
Expand All @@ -616,9 +620,8 @@ MonoBehaviour:
projectileRotation: {x: 0, y: 0, z: 0, w: 1}
stats: {fileID: 0}
player: {fileID: 0}
maxDistance: 10
collisionSamples: 30
bulletsPerShot: 10
maxDistance: 15
collisionSamplesPerUnit: 3
trail: {fileID: 1393106611541694855}
flash: {fileID: 261841362781268065}
animator: {fileID: 6403918129687704287}
Expand Down
6 changes: 2 additions & 4 deletions Assets/Prefabs/UI/PlayerStatUI.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
statContainer: {fileID: 3517448734813626926}
playerNameText: {fileID: 5648608041759069520}
chipsText: {fileID: 0}
gunPreviewPanel: {fileID: 6908086682209798948}
chip: {fileID: 0}
damageBar: {fileID: 809994374641583378}
fireRateBar: {fileID: 3314896837149191081}
projectilesPerShotBar: {fileID: 6994510046160422822}
Expand Down Expand Up @@ -828,7 +826,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8714461546252577768, guid: 17df745e02bd45b0c9436e1b60f6ffa4, type: 3}
propertyPath: defaultMaxValue
value: 16
value: 10
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
Expand Down Expand Up @@ -1045,7 +1043,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8714461546252577768, guid: 17df745e02bd45b0c9436e1b60f6ffa4, type: 3}
propertyPath: defaultMaxValue
value: 20
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public class MeshProjectileController : ProjectileController
private int maxProjectiles = 300;

[FormerlySerializedAs("hatMaxDistance")] [SerializeField]
private float maxDistance = 20f;
private float maxDistance = 20;

[FormerlySerializedAs("hatSpeed")] [SerializeField]
private float speed = 10f;
private const float baseSpeed = 20;

[FormerlySerializedAs("hatSize")] [SerializeField]
private float size = .2f;
Expand Down Expand Up @@ -77,7 +76,7 @@ protected override void OnReload(GunStats gunstats)
public override void InitializeProjectile(GunStats stats)
{
loadedProjectile = new ProjectileState(stats, projectileOutput);
loadedProjectile.maxDistance = this.maxDistance;
loadedProjectile.maxDistance = maxDistance;

animator.OnFire(stats.Ammo);
}
Expand All @@ -87,7 +86,7 @@ private void FireProjectile()
if (loadedProjectile == null) return;

loadedProjectile.active = true;
loadedProjectile.speed = speed;
loadedProjectile.speed = baseSpeed;
OnProjectileInit?.Invoke(ref loadedProjectile, stats);
for (int i = 0; i < maxProjectiles; i++)
{
Expand Down
21 changes: 10 additions & 11 deletions Assets/Scripts/Augment/BulletController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ public class BulletController : ProjectileController
private float maxDistance = 20;

[SerializeField]
private int collisionSamples = 30;
private int collisionSamplesPerUnit = 3;

private int vfxPositionsPerSample = 3;
private int collisionSamples;

private float bulletSpeed = 50f;
private const int vfxPositionsPerSample = 3;

[SerializeField]
private int bulletsPerShot = 1;
public int BulletsPerShot => bulletsPerShot;
private const float baseSpeed = 50f;

private VFXTextureFormatter trailPosTexture;

Expand All @@ -39,6 +37,8 @@ protected override void Awake()

private void Start()
{
collisionSamples = Mathf.CeilToInt(collisionSamplesPerUnit * maxDistance);
var bulletsPerShot = Mathf.CeilToInt(stats.ProjectilesPerShot);
flash.transform.position = projectileOutput.position;
trailPosTexture = new VFXTextureFormatter(vfxPositionsPerSample * collisionSamples * bulletsPerShot);
trail.SetTexture("Position", this.trailPosTexture.Texture);
Expand All @@ -61,12 +61,11 @@ public override void InitializeProjectile(GunStats stats)
{
animator.OnFire(stats.Ammo);

// TODO: Possibly standardize this better
for (int k = 0; k < bulletsPerShot; k++)
for (int k = 0; k < stats.ProjectilesPerShot; k++)
{

Quaternion randomSpread = Quaternion.Lerp(Quaternion.identity, Random.rotation, stats.ProjectileSpread);

// TODO: Possibly standardize this better
projectile.active = true;
projectile.distanceTraveled = 0f;
projectile.damage = stats.ProjectileDamage;
Expand All @@ -83,7 +82,7 @@ public override void InitializeProjectile(GunStats stats)

OnProjectileInit?.Invoke(ref projectile, stats);

projectile.speed = bulletSpeed * stats.ProjectileSpeedFactor;
projectile.speed = baseSpeed * stats.ProjectileSpeedFactor;

int sampleNum = 0;

Expand Down Expand Up @@ -129,8 +128,8 @@ public override void InitializeProjectile(GunStats stats)
}

trailPosTexture.ApplyChanges();
// Play the flash and trail
}
// Play the flash and trail
trail.SendEvent("OnPlay");
flash.SendEvent("OnPlay");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ private void Awake()
public void Attach(ProjectileController projectile)
{
projectile.OnHitboxCollision += KnockAwayTargets;
var bulletController = projectile.gameObject.GetComponent<BulletController>();
bulletAmount = bulletController == null || bulletController.BulletsPerShot == 0 ? 1f : bulletController.BulletsPerShot;
bulletAmount = projectile.stats.ProjectilesPerShot;
calculatedPushPower = (pushPower / bulletAmount) * (1f + (float)Math.Log10(bulletAmount));
}

Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Augment/BulletModifiers/RecoilModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ private void Awake()
public void Attach(ProjectileController projectile)
{
projectile.OnProjectileInit += KnockAwayOnShot;
var bulletController = projectile.gameObject.GetComponent<BulletController>();
bulletAmount = bulletController == null || bulletController.BulletsPerShot == 0 ? 1f : bulletController.BulletsPerShot;
bulletAmount = projectile.stats.ProjectilesPerShot;
calculatedPushPower = (pushPower / bulletAmount) * (1f + (float)Math.Log10(bulletAmount));
}

Expand All @@ -39,11 +38,13 @@ public void Detach(ProjectileController projectile)

private void KnockAwayOnShot(ref ProjectileState state, GunStats stats)
{
if (!gunController.player)
return;

Vector3 normal = -gunController.transform.forward;

float calculatedPushPowerForPlayer = (calculatedPushPower / stats.Firerate) * (baseFireRateAdder + (float)Math.Log(stats.Firerate));

gunController.player.GetComponent<Rigidbody>().AddForce(normal * calculatedPushPowerForPlayer, ForceMode.Impulse);

}
}
4 changes: 2 additions & 2 deletions Assets/VFX/SmokeTrail_Instant.vfx
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ MonoBehaviour:
- {fileID: 8926484042661614656}
- {fileID: 8926484042661614805}
dataType: 1
capacity: 15000
capacity: 75000
stripCapacity: 75
particlePerStripCount: 200
particlePerStripCount: 1000
needsComputeBounds: 1
boundsMode: 2
m_Space: 1
Expand Down

0 comments on commit 1ebac5b

Please sign in to comment.