Advertisement
Guest User

Untitled

a guest
Jul 6th, 2021
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package src.data.scripts.weapons;
  2.  
  3. import com.fs.starfarer.api.Global;
  4. import com.fs.starfarer.api.combat.CollisionClass;
  5. import com.fs.starfarer.api.combat.CombatEngineAPI;
  6. import com.fs.starfarer.api.combat.CombatEntityAPI;
  7. import com.fs.starfarer.api.combat.CombatUIAPI;
  8. import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
  9. import com.fs.starfarer.api.combat.FighterWingAPI;
  10. import com.fs.starfarer.api.combat.MutableShipStatsAPI;
  11. import com.fs.starfarer.api.combat.ShipAPI;
  12. import com.fs.starfarer.api.combat.ShipVariantAPI;
  13. import com.fs.starfarer.api.combat.WeaponAPI;
  14. import com.fs.starfarer.api.loading.WeaponSlotAPI;
  15. import com.fs.starfarer.api.util.IntervalUtil;
  16. import java.awt.Color;
  17. import java.util.List;
  18.  
  19. public class omm_weapondrone implements EveryFrameWeaponEffectPlugin {
  20.  
  21. private boolean runOnce = false;
  22. private boolean isWeaponSwapped1 = false;
  23. private ShipAPI SHIP;
  24. private ShipAPI FIGHTER;
  25. public IntervalUtil timer = new IntervalUtil(3F, 20F);
  26.  
  27. @Override
  28. public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
  29. this.SHIP = weapon.getShip();
  30. if (engine.isPaused()) {
  31. return;
  32. }
  33. List<WeaponAPI> list = this.SHIP.getAllWeapons();
  34. if (this.SHIP.getOriginalOwner() == 0 || this.SHIP.getOriginalOwner() == 1) {
  35. for (WeaponAPI weaponAPI : list) {
  36. if (weaponAPI.getId().equals("omm_weaponpoddeco")) {
  37. weaponAPI.getSprite().setColor(new Color(255, 255, 255, 0));
  38. }
  39.  
  40. if (weaponAPI.getSlot().getId().equals("droneslot")) {
  41. weaponAPI.disable(true);
  42. weaponAPI.getSprite().setColor(new Color(255, 255, 255, 0));
  43. }
  44. if (weaponAPI.getBarrelSpriteAPI() != null) {
  45. weaponAPI.getBarrelSpriteAPI().setColor(new Color(255, 255, 255, 0));
  46. }
  47. }
  48.  
  49. }
  50.  
  51. this.timer.randomize();
  52.  
  53. this.timer.advance(amount);
  54. if (!this.timer.intervalElapsed()) {
  55. return;
  56. }
  57. if (isWeaponSwapped1) {
  58. return;
  59. }
  60. if (!isWeaponSwapped1) {
  61.  
  62. if (this.SHIP != null) {
  63. List<FighterWingAPI> list1 = this.SHIP.getAllWings();
  64. for (FighterWingAPI fighterWingAPI : list1) {
  65. if (!fighterWingAPI.getWingId().equals("omm_weaponpod_wing")) {
  66. continue;
  67. }
  68.  
  69. {
  70. this.FIGHTER = fighterWingAPI.getLeader();
  71. MutableShipStatsAPI mutableShipStatsAPI = this.FIGHTER.getMutableStats();
  72. ShipVariantAPI shipVariantAPI = mutableShipStatsAPI.getVariant().clone();
  73. mutableShipStatsAPI.getVariant().setOriginalVariant(null);
  74. this.FIGHTER.getFleetMember().setVariant(shipVariantAPI, false, true);
  75. mutableShipStatsAPI.getVariant().clearSlot("droneslot");
  76. if (this.SHIP.getVariant().getWeaponSpec("droneslot") != null) {
  77. mutableShipStatsAPI.getVariant().addWeapon("droneslot", this.SHIP.getVariant().getWeaponId("droneslot"));
  78. mutableShipStatsAPI.getVariant().getWeaponSpec("droneslot").addTag("FIRE_WHEN_INEFFICIENT");
  79. fighterWingAPI.orderReturn(this.FIGHTER);
  80. {
  81.  
  82. this.isWeaponSwapped1 = true;
  83.  
  84. }
  85. }
  86.  
  87. }
  88. }
  89.  
  90. }
  91. }
  92. }
  93. }
  94.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement