Skip to content

Commit

Permalink
Merge pull request #593 from jrodrigv/master
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
jrodrigv authored Nov 17, 2018
2 parents bb9b094 + 825b047 commit 4270ff8
Show file tree
Hide file tree
Showing 47 changed files with 1,559 additions and 1,046 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
BDArmory Ignore
#######################################
BDArmory/BDArmory.csproj.user
_LocalDev

BahaTurret/.vs
BahaTurret/obj
Expand Down
2 changes: 0 additions & 2 deletions BDArmory.Core/BDAPersistantSettingsField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class BDAPersistantSettingsField : Attribute
public BDAPersistantSettingsField()
{
}

public static void Save()
{
ConfigNode fileNode = ConfigNode.Load(BDArmorySettings.settingsConfigURL);
Expand All @@ -34,7 +33,6 @@ public static void Save()
field.Dispose();
fileNode.Save(BDArmorySettings.settingsConfigURL);
}

public static void Load()
{
ConfigNode fileNode = ConfigNode.Load(BDArmorySettings.settingsConfigURL);
Expand Down
1 change: 1 addition & 0 deletions BDArmory.Core/BDArmorySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class BDArmorySettings

[BDAPersistantSettingsField] public static float RECOIL_FACTOR = 0.75f;
[BDAPersistantSettingsField] public static float DMG_MULTIPLIER = 100f;
[BDAPersistantSettingsField] public static float BALLISTIC_DMG_FACTOR = 1f;
[BDAPersistantSettingsField] public static float HITPOINT_MULTIPLIER = 2.0f;
[BDAPersistantSettingsField] public static float EXP_DMG_MOD_BALLISTIC;
[BDAPersistantSettingsField] public static float EXP_DMG_MOD_MISSILE;
Expand Down
91 changes: 66 additions & 25 deletions BDArmory.Core/Extension/PartExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void AddBallisticDamage(this Part p,

float damage_ = ((0.5f * (mass * Mathf.Pow(impactVelocity, 2)))
* (BDArmorySettings.DMG_MULTIPLIER / 100) * bulletDmgMult
* 1e-4f);
* 1e-4f * BDArmorySettings.BALLISTIC_DMG_FACTOR);

//////////////////////////////////////////////////////////
// Armor Reduction factors
Expand Down Expand Up @@ -274,31 +274,49 @@ public static bool IsMissile(this Part part)
part.Modules.Contains("BDModularGuidance");
}

public static float GetArea(this Part part)
public static float GetArea(this Part part, bool isprefab = false, Part prefab = null)
{
var boundsSize = PartGeometryUtil.MergeBounds(part.GetRendererBounds(), part.transform).size;
float sfcAreaCalc = 2f * (boundsSize.x * boundsSize.y) + 2f * (boundsSize.y * boundsSize.z) + 2f * (boundsSize.x * boundsSize.z);
//Debug.Log("[BDArmory]: Surface Area1: " + part.surfaceAreas.magnitude);
//Debug.Log("[BDArmory]: Surface Area2: " + sfcAreaCalc);

var size = part.GetSize();
float sfcAreaCalc = 2f * (size.x * size.y) + 2f * (size.y * size.z) + 2f * (size.x * size.z);

return sfcAreaCalc;
}

public static float GetAverageBoundSize(this Part part)
{
var boundsSize = PartGeometryUtil.MergeBounds(part.GetRendererBounds(), part.transform).size;
return (boundsSize.x + boundsSize.y + boundsSize.z) / 3f;
var size = part.GetSize();



return (size.x + size.y + size.z) / 3f;
}

public static float GetVolume(this Part part)
{
var boundsSize = PartGeometryUtil.MergeBounds(part.GetRendererBounds(), part.transform).size;
return boundsSize.x * boundsSize.y * boundsSize.z;
var size = part.GetSize();
var volume = size.x * size.y * size.z;
return volume;
}

public static float GetDensity (this Part part)
public static Vector3 GetSize(this Part part)
{
return (part.mass * 1000) / part.GetVolume();

var size = part.GetComponentInChildren<MeshFilter>().mesh.bounds.size;

if (part.name.Contains("B9.Aero.Wing.Procedural"))
{
size = size * 0.1f;
}

float scaleMultiplier = 1f;
if (part.Modules.Contains("TweakScale"))
{
var tweakScaleModule = part.Modules["TweakScale"];
scaleMultiplier = tweakScaleModule.Fields["currentScale"].GetValue<float>(tweakScaleModule) /
tweakScaleModule.Fields["defaultScale"].GetValue<float>(tweakScaleModule);
}

return size * scaleMultiplier;
}

public static bool IsAero(this Part part)
Expand Down Expand Up @@ -349,7 +367,8 @@ public static bool HasFuel(this Part part)
}

public static float DamageReduction(float armor, float damage,bool isMissile,float caliber = 0, float penetrationfactor = 0)
{
{
float _damageReduction;

if (isMissile)
{
Expand All @@ -368,22 +387,39 @@ public static float DamageReduction(float armor, float damage,bool isMissile,flo

}

if(!isMissile && !(penetrationfactor >= 1f))
if (!isMissile && !(penetrationfactor >= 1f))
{
if (BDAMath.Between(armor, 100f, 200f))
{
damage *= 0.300f;
}
else if (BDAMath.Between(armor, 200f, 400f))
{
damage *= 0.250f;
}
else if (BDAMath.Between(armor, 400f, 500f))
//if (BDAMath.Between(armor, 100f, 200f))
//{
// damage *= 0.300f;
//}
//else if (BDAMath.Between(armor, 200f, 400f))
//{
// damage *= 0.250f;
//}
//else if (BDAMath.Between(armor, 400f, 500f))
//{
// damage *= 0.200f;
//}


//y=(98.34817*x)/(97.85935+x)

_damageReduction = (113 * armor) / (154 + armor);


if (BDArmorySettings.DRAW_DEBUG_LABELS)
{
damage *= 0.200f;
Debug.Log("[BDArmory]: Damage Before Reduction : " + Math.Round(damage, 2) / 100);
Debug.Log("[BDArmory]: Damage Reduction : " + Math.Round(_damageReduction, 2)/100);
Debug.Log("[BDArmory]: Damage After Armor : " + Math.Round(damage *= (_damageReduction / 100f)));
}

damage *= (_damageReduction / 100f);
}



return damage;
}

Expand All @@ -401,5 +437,10 @@ public static void CheckDamageFX(Part part)
}

}

public static Vector3 GetBoundsSize(Part part)
{
return PartGeometryUtil.MergeBounds(part.GetRendererBounds(), part.transform).size;
}
}
}
2 changes: 1 addition & 1 deletion BDArmory.Core/Extension/VesselExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static bool InOrbit(this Vessel v)

public static bool InVacuum(this Vessel v)
{
return v.atmDensity <= 0.001;
return v.atmDensity <= 0.001f;
}

public static Vector3d Velocity(this Vessel v)
Expand Down
Loading

0 comments on commit 4270ff8

Please sign in to comment.