Skip to content

Commit

Permalink
SS-1 turret
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacchan-VRC committed Oct 28, 2021
1 parent cefff31 commit 1446cca
Show file tree
Hide file tree
Showing 25 changed files with 5,264 additions and 787 deletions.
1,071 changes: 1,021 additions & 50 deletions Prefabs/SS-1Main.prefab

Large diffs are not rendered by default.

Binary file modified SS-1/Models/SS-1.fbx
Binary file not shown.
25 changes: 14 additions & 11 deletions Scripts/DFUNC/DFUNC_AAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public class DFUNC_AAM : UdonSharpBehaviour
[SerializeField] private float AAMLaunchDelay = 0.5f;
[Tooltip("How long it takes to fully reload from empty in seconds. Can be inaccurate because it can only reload by integers per resupply")]
[SerializeField] private float FullReloadTimeSec = 10;
[Tooltip("Set a boolean value in the animator when switching to this weapon?")]
[Tooltip("Allow user to fire the weapon while the vehicle is on the ground taxiing?")]
[SerializeField] private bool AllowFiringWhenGrounded = false;
[Tooltip("Send the boolean(AnimBoolName) true to the animator when selected?")]
[SerializeField] private bool DoAnimBool = false;
[Tooltip("Animator bool that is true when this function is selected")]
[SerializeField] private string AnimBoolName = "AAMSelected";
Expand Down Expand Up @@ -85,7 +87,8 @@ public void SFEXT_L_EntityStart()
{
distance_from_head = (float)HUDControl.GetProgramVariable("distance_from_head");
}
if (distance_from_head == 0) { distance_from_head = 1.333f; }
else
{ distance_from_head = 1.333f; }

FindSelf();

Expand Down Expand Up @@ -129,7 +132,7 @@ public void SFEXT_P_PassengerEnter()
public void SFEXT_G_Explode()
{
NumAAM = FullAAMs;
AAMAnimator.SetFloat(AnimFloatName, 1);
if (AAMAnimator) { AAMAnimator.SetFloat(AnimFloatName, 1); }
if (func_active)
{
DFUNC_Deselected();
Expand All @@ -142,13 +145,13 @@ public void SFEXT_G_ReSupply()
if (NumAAM != FullAAMs)
{ SAVControl.SetProgramVariable("ReSupplied", (int)SAVControl.GetProgramVariable("ReSupplied") + 1); }
NumAAM = (int)Mathf.Min(NumAAM + Mathf.Max(Mathf.Floor(reloadspeed), 1), FullAAMs);
AAMAnimator.SetFloat(AnimFloatName, (float)NumAAM * FullAAMsDivider);
if (AAMAnimator) { AAMAnimator.SetFloat(AnimFloatName, (float)NumAAM * FullAAMsDivider); }
if (HUDText_AAM_ammo) { HUDText_AAM_ammo.text = NumAAM.ToString("F0"); }
}
public void SFEXT_G_RespawnButton()
{
NumAAM = FullAAMs;
AAMAnimator.SetFloat(AnimFloatName, 1);
if (AAMAnimator) { AAMAnimator.SetFloat(AnimFloatName, 1); }
if (DoAnimBool && AnimOn)
{ SetBoolOff(); }
}
Expand Down Expand Up @@ -225,7 +228,7 @@ void Update()
{
if (!TriggerLastFrame)
{
if (AAMLocked && !(bool)SAVControl.GetProgramVariable("Taxiing") && Time.time - AAMLastFiredTime > AAMLaunchDelay)
if (AAMLocked && Time.time - AAMLastFiredTime > AAMLaunchDelay)
{
AAMLastFiredTime = Time.time;
AAMFire++;//launch AAM using set
Expand Down Expand Up @@ -357,7 +360,7 @@ private void FixedUpdate()//old AAMTargeting function
else
{ AAMTargetObscuredDelay = 0; }

if (!(bool)SAVControl.GetProgramVariable("Taxiing")
if ((!(bool)SAVControl.GetProgramVariable("Taxiing") || AllowFiringWhenGrounded)
&& (AAMTargetObscuredDelay < .25f)
&& AAMCurrentTargetDistance < AAMMaxTargetDistance
&& AAMTargets[AAMTarget].activeInHierarchy
Expand Down Expand Up @@ -441,15 +444,15 @@ public void LaunchAAM()
InEditor = (bool)SAVControl.GetProgramVariable("InEditor");
if (!InEditor) { IsOwner = localPlayer.IsOwner(gameObject); } else { IsOwner = true; }
if (NumAAM > 0) { NumAAM--; }//so it doesn't go below 0 when desync occurs
AAMAnimator.SetTrigger(AnimFiredTriggerName);
if (AAMAnimator) { AAMAnimator.SetTrigger(AnimFiredTriggerName); }
if (AAM)
{
GameObject NewAAM = Object.Instantiate(AAM);
NewAAM.transform.SetPositionAndRotation(AAMLaunchPoint.position, AAMLaunchPoint.transform.rotation);
NewAAM.SetActive(true);
NewAAM.GetComponent<Rigidbody>().velocity = (Vector3)SAVControl.GetProgramVariable("CurrentVel");
}
AAMAnimator.SetFloat(AnimFloatName, (float)NumAAM * FullAAMsDivider);
if (AAMAnimator) { AAMAnimator.SetFloat(AnimFloatName, (float)NumAAM * FullAAMsDivider); }
if (HUDText_AAM_ammo) { HUDText_AAM_ammo.text = NumAAM.ToString("F0"); }
}
private void FindSelf()
Expand Down Expand Up @@ -481,13 +484,13 @@ public void SetBoolOn()
{
boolToggleTime = Time.time;
AnimOn = true;
AAMAnimator.SetBool(AnimBoolName, AnimOn);
if (AAMAnimator) { AAMAnimator.SetBool(AnimBoolName, AnimOn); }
}
public void SetBoolOff()
{
boolToggleTime = Time.time;
AnimOn = false;
AAMAnimator.SetBool(AnimBoolName, AnimOn);
if (AAMAnimator) { AAMAnimator.SetBool(AnimBoolName, AnimOn); }
}
public void KeyboardInput()
{
Expand Down
4 changes: 3 additions & 1 deletion Scripts/DFUNC/DFUNC_AGM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public class DFUNC_AGM : UdonSharpBehaviour
[SerializeField] private AudioSource AGMLock;
[Tooltip("Sound that plays when the AGM unlocks")]
[SerializeField] private AudioSource AGMUnlock;
[SerializeField] private bool AllowFiringWhenGrounded;
[Tooltip("Allow user to fire the weapon while the vehicle is on the ground taxiing?")]
[SerializeField] private bool AllowFiringWhenGrounded = false;
[Tooltip("Send the boolean(AnimBoolName) true to the animator when selected?")]
[SerializeField] private bool DoAnimBool = false;
[Tooltip("Animator bool that is true when this function is selected")]
[SerializeField] private string AnimBoolName = "AGMSelected";
Expand Down
22 changes: 10 additions & 12 deletions Scripts/DFUNC/DFUNC_Bomb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class DFUNC_Bomb : UdonSharpBehaviour
[SerializeField] private float BombDelay = 0f;
[Tooltip("Points at which bombs appear, each succesive bomb appears at the next transform")]
[SerializeField] private Transform[] BombLaunchPoints;
[Tooltip("Allow user to fire the weapon while the vehicle is on the ground taxiing?")]
[SerializeField] private bool AllowFiringWhenGrounded = false;
[SerializeField] private bool DoAnimBool = false;
[Tooltip("Animator bool that is true when this function is selected")]
[SerializeField] private string AnimBoolName = "BombSelected";
Expand Down Expand Up @@ -179,7 +181,7 @@ private void Update()
{
if (!TriggerLastFrame)
{
if (NumBomb > 0 && !(bool)SAVControl.GetProgramVariable("Taxiing") && ((Time.time - LastBombDropTime) > BombDelay))
if (NumBomb > 0 && (AllowFiringWhenGrounded || !(bool)SAVControl.GetProgramVariable("Taxiing")) && ((Time.time - LastBombDropTime) > BombDelay))
{
LastBombDropTime = Time.time;
BombFire++;
Expand All @@ -188,18 +190,14 @@ private void Update()
{ EntityControl.SendEventToExtensions("SFEXT_O_BombLaunch"); }
}
}
else//launch every BombHoldDelay
if (NumBomb > 0 && ((Time.time - LastBombDropTime) > BombHoldDelay) && !(bool)SAVControl.GetProgramVariable("Taxiing"))
{
{
LastBombDropTime = Time.time;
BombFire++;
RequestSerialization();
if ((bool)SAVControl.GetProgramVariable("IsOwner"))
{ EntityControl.SendEventToExtensions("SFEXT_O_BombLaunch"); }
}
else if (NumBomb > 0 && ((Time.time - LastBombDropTime) > BombHoldDelay) && (AllowFiringWhenGrounded || !(bool)SAVControl.GetProgramVariable("Taxiing")))
{///launch every BombHoldDelay
LastBombDropTime = Time.time;
BombFire++;
RequestSerialization();
if ((bool)SAVControl.GetProgramVariable("IsOwner"))
{ EntityControl.SendEventToExtensions("SFEXT_O_BombLaunch"); }
}

TriggerLastFrame = true;
}
else { TriggerLastFrame = false; }
Expand Down
2 changes: 1 addition & 1 deletion Scripts/DFUNC/DFUNC_Reverse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class DFUNC_Reverse : UdonSharpBehaviour
{
[SerializeField] private UdonSharpBehaviour SAVControl;
[SerializeField] private float ReversingThrottleMultiplier = -1.25f;
[SerializeField] private float ReversingThrottleMultiplier = -.5f;
[SerializeField] private GameObject Dial_funcon;
private float StartThrottleStrength;
private float StartABStrength;
Expand Down
3 changes: 1 addition & 2 deletions Scripts/SaccAAGun/SAAG_SyncScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ private void Update()
else
{
float TimeSinceUpdate = ((float)(Networking.GetServerTimeInMilliseconds() - L_UpdateTime) * .001f);
Vector2 PredictedRotation = Vector2.zero;
PredictedRotation = O_GunRotation + (GunRotationSpeed * (Ping + TimeSinceUpdate));
Vector2 PredictedRotation = O_GunRotation + (GunRotationSpeed * (Ping + TimeSinceUpdate));
PredictedRotation.x = Mathf.Clamp(PredictedRotation.x, -UpAngleMax, DownAngleMax);

Vector3 PredictedRotation_3 = new Vector3(PredictedRotation.x, PredictedRotation.y, 0);
Expand Down
10 changes: 5 additions & 5 deletions Scripts/SaccAAGun/SaccAAGunController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public class SaccAAGunController : UdonSharpBehaviour
[System.NonSerializedAttribute] public float FullHealth;
[System.NonSerializedAttribute] public bool Manning = false;//like Piloting in the plane
[System.NonSerializedAttribute] public VRCPlayerApi localPlayer;
[System.NonSerializedAttribute] public float RotationSpeedX = 0f;
[System.NonSerializedAttribute] public float RotationSpeedY = 0f;
private float RotationSpeedX = 0f;
private float RotationSpeedY = 0f;
private Vector3 StartRot;
[System.NonSerializedAttribute] public bool InEditor = true;
[System.NonSerializedAttribute] public bool IsOwner = false;
Expand All @@ -99,7 +99,6 @@ public class SaccAAGunController : UdonSharpBehaviour
Quaternion AAGunRotLastFrame;
Quaternion JoystickZeroPoint;
[System.NonSerializedAttribute] public bool RGripLastFrame = false;
Vector2 VRPitchYawInput;
private float FullAAMsDivider;
private float FullHealthDivider;
private bool LTriggerLastFrame;
Expand All @@ -108,8 +107,8 @@ public class SaccAAGunController : UdonSharpBehaviour
[System.NonSerializedAttribute] public float AAMReloadTimer;
[System.NonSerializedAttribute] public float HealthUpTimer;
[System.NonSerializedAttribute] public float HPRepairTimer;
[System.NonSerializedAttribute] public float InputXKeyb;
[System.NonSerializedAttribute] public float InputYKeyb;
[System.NonSerializedAttribute] private float InputXKeyb;
[System.NonSerializedAttribute] private float InputYKeyb;
[System.NonSerializedAttribute] public float LastHealthUpdate = 0;
[System.NonSerializedAttribute] public Transform CenterOfMass;
private bool Occupied;
Expand Down Expand Up @@ -196,6 +195,7 @@ void LateUpdate()
Vector3 JoystickPos;

//virtual joystick
Vector2 VRPitchYawInput = Vector2.zero;
if (InVR)
{
if (RGrip > 0.75)
Expand Down
28 changes: 13 additions & 15 deletions Scripts/SaccAirVehicle/DFUNCP/DFUNCP_Minigun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class DFUNCP_Minigun : UdonSharpBehaviour
[Tooltip("Transform of which its X scale scales with ammo")]
[SerializeField] private Transform AmmoBar;
[SerializeField] private KeyCode MinigunFireKey = KeyCode.Space;
private bool AmmoBarNULL = true;
[UdonSynced(UdonSyncMode.None)] private Vector2 GunRotation;
private bool InVR;
private VRCPlayerApi localPlayer;
Expand All @@ -42,8 +41,7 @@ public void SFEXTP_L_EntityStart()
{
FullGunAmmoInSeconds = GunAmmoInSeconds;
reloadspeed = FullGunAmmoInSeconds / FullReloadTimeSec;
AmmoBarNULL = AmmoBar == null;
if (!AmmoBarNULL) { AmmoBarScaleStart = AmmoBar.localScale; }
if (AmmoBar) { AmmoBarScaleStart = AmmoBar.localScale; }
FullGunAmmoInSeconds = GunAmmoInSeconds;
FullGunAmmoDivider = 1f / (FullGunAmmoInSeconds > 0 ? FullGunAmmoInSeconds : 10000000);
GUNFIRING_STRING = Animator.StringToHash(AnimatorFiringStringName);
Expand All @@ -54,14 +52,8 @@ public void SFEXTP_L_EntityStart()
InVR = localPlayer.IsUserInVR();
}
}
public void Activate()
{
gameObject.SetActive(true);
}
public void Deactivate()
{
gameObject.SetActive(false);
}
public void Activate() { gameObject.SetActive(true); }
public void Deactivate() { gameObject.SetActive(false); }
public void DFUNC_Selected()
{
Selected = true;
Expand Down Expand Up @@ -112,7 +104,15 @@ public void SFEXTP_G_RespawnButton()
}
public void SFEXTP_G_ReSupply()
{
if (Selected)
if (gameObject.activeInHierarchy)
{
if (func_active)
{
if (GunAmmoInSeconds != FullGunAmmoInSeconds) { SAVControl.SetProgramVariable("ReSupplied", (int)SAVControl.GetProgramVariable("ReSupplied") + 1); }
GunAmmoInSeconds = Mathf.Min(GunAmmoInSeconds + reloadspeed, FullGunAmmoInSeconds);
}
}
else
{
if (GunAmmoInSeconds != FullGunAmmoInSeconds) { SAVControl.SetProgramVariable("ReSupplied", (int)SAVControl.GetProgramVariable("ReSupplied") + 1); }
GunAmmoInSeconds = Mathf.Min(GunAmmoInSeconds + reloadspeed, FullGunAmmoInSeconds);
Expand Down Expand Up @@ -185,9 +185,7 @@ private void LateUpdate()
Quaternion newrot = (Quaternion.Euler(new Vector3(GunRotation.x, GunRotation.y, 0)));
Minigun.rotation = Quaternion.Slerp(Minigun.rotation, newrot, 4 * DeltaTime);
}


if (!AmmoBarNULL) AmmoBar.localScale = new Vector3((GunAmmoInSeconds * FullGunAmmoDivider) * AmmoBarScaleStart.x, AmmoBarScaleStart.y, AmmoBarScaleStart.z);
if (AmmoBar) { AmmoBar.localScale = new Vector3((GunAmmoInSeconds * FullGunAmmoDivider) * AmmoBarScaleStart.x, AmmoBarScaleStart.y, AmmoBarScaleStart.z); }
}
private void OnDisable()
{
Expand Down
Loading

0 comments on commit 1446cca

Please sign in to comment.