/*▄▄▄ ███▄ ▄███▓ ▄████ ▄▄▄██▀▀▀▓█████▄▄▄█████▓ ▓█████▄ ▓██▒▀█▀ ██▒ ██▒ ▀█▒ ▒██ ▓█ ▀▓ ██▒ ▓▒ ▒██▒ ▄██▓██ ▓██░▒██░▄▄▄░ ░██ ▒███ ▒ ▓██░ ▒░ ▒██░█▀ ▒██ ▒██ ░▓█ ██▓▓██▄██▓ ▒▓█ ▄░ ▓██▓ ░ ░▓█ ▀█▓▒██▒ ░██▒░▒▓███▀▒ ▓███▒ ░▒████▒ ▒██▒ ░ ░▒▓███▀▒░ ▒░ ░ ░ ░▒ ▒ ▒▓▒▒░ ░░ ▒░ ░ ▒ ░░ ▒░▒ ░ ░ ░ ░ ░ ░ ▒ ░▒░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░*/ using System; namespace Oxide.Plugins { [Info("SupplySignalMiniCopter", "bmgjet", "1.0.0")] [Description("Gives a skinned supply signal and, when thrown, spawns a mini copter instead of a normal supply drop if the signal uses the special skin.")] public class SupplySignalMiniCopter : RustPlugin { // Skin ID to check private const ulong SpecialSkinId = 2144524645UL; //Prefabs private const string SupplySignalItemShortname = "supply.signal"; private const string MiniCopterPrefab = "assets/content/vehicles/minicopter/minicopter.entity.prefab"; public void GivePlayerSS(BasePlayer player) { if (player == null) return; Item item = ItemManager.CreateByName(SupplySignalItemShortname, 1); if (item == null) { return; } try { item.skin = SpecialSkinId; item.GetHeldEntity().skinID = SpecialSkinId; item.MarkDirty(); player.GiveItem(item); } catch (Exception ex) { player.ChatMessage("[SupplySignalMiniCopter] Failed to give item: " + ex.Message); } } public void SpawnMiniCopter(BasePlayer player, BaseEntity entity) { var pos = entity.transform.position; entity.Kill(); var mini = GameManager.server.CreateEntity(MiniCopterPrefab, pos); if (mini != null) { mini.Spawn(); mini.OwnerID = player.userID; Puts($"Spawned mini copter for {player.displayName} at {pos} using special supply signal."); timer.Once(2f, () => { if (mini != null) { IFuelSystem fuelSystem = (mini as PlayerHelicopter).GetFuelSystem(); if (fuelSystem is EntityFuelSystem entityFuelSystem) { StorageContainer fuelContainer = entityFuelSystem.GetFuelContainer(); if (fuelContainer != null) { (mini as PlayerHelicopter).fuelPerSec = 0f; fuelContainer.inventory.AddItem(fuelContainer.allowedItem, 1); fuelContainer.SetFlagLocal(BaseEntity.Flags.Locked, true); } } } }); } } private void Init() { cmd.AddChatCommand("gss", this, nameof(CmdGiveSupplySignal)); // alias } private void CmdGiveSupplySignal(BasePlayer player, string command, string[] args) { if (player == null || !player.IsAdmin) return; GivePlayerSS(player); } private void OnExplosiveDropped(BasePlayer player, BaseEntity entity) => OnExplosiveThrown(player, entity); private void OnExplosiveThrown(BasePlayer player, BaseEntity entity) { if (entity == null) return; if (entity.ShortPrefabName != "grenade.supplysignal.deployed") return; if (entity.skinID != SpecialSkinId) return; // normal signal, let default behaviour run timer.Once(1.5f, () => { if (entity != null) { SpawnMiniCopter(player, entity); } }); } object OnHammerHit(BasePlayer ownerPlayer, HitInfo info) { if (ownerPlayer == null || !(info?.HitEntity is Minicopter)) { return null; } //Check has reload down and permission if (info.HitEntity.OwnerID == ownerPlayer.userID && !ownerPlayer.IsBuildingBlocked()) { Minicopter minicopter = info?.HitEntity as Minicopter; if (minicopter != null && ownerPlayer.serverInput.IsDown(BUTTON.RELOAD)) { if (minicopter.health == minicopter.MaxHealth()) { minicopter.Kill(); GivePlayerSS(ownerPlayer); ownerPlayer.ChatMessage("Minicopter Picked Up"); return true; } else { ownerPlayer.ChatMessage("Minicopter Must Have Full Health To Pick Up"); return true; } } } return null; } } }