Advertisement
Crushed

Untitled

Nov 5th, 2017
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 22.86 KB | None | 0 0
  1.  
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5. using Oxide.Core.Libraries;
  6. using Oxide.Core.Libraries.Covalence;
  7. using Oxide.Game.Rust.Cui;
  8. using Oxide.Core;
  9. using Oxide.Core.Plugins;
  10. using Oxide.Core.Configuration;
  11. using System.Collections.Generic;
  12. using System.Reflection;
  13. using System;
  14. using ProtoBuf;
  15. using System.Data;
  16. using UnityEngine;
  17. using System.Linq;
  18. using System.Reflection;
  19. using System.Text;
  20. using Newtonsoft.Json;
  21. using static UnityEngine.Camera;
  22. using Newtonsoft.Json.Linq;
  23. using System.Data;
  24. using Network;
  25. using Rust;
  26. using Facepunch;
  27. using Facepunch.Extend;
  28.  
  29. namespace Oxide.Plugins
  30. {
  31.     [Info("Blinkarrow", "Crushedice", 0.1)]
  32.     [Description("Makes epic stuff happen")]
  33.    
  34.   class Blinkarrow : RustPlugin
  35.     {
  36.         [PluginReference] Plugin EntityOwner;
  37.         [PluginReference] Plugin RunningMan;
  38.         [PluginReference] Plugin ZoneManager;
  39.         [PluginReference("SteamReport")]
  40.         private Plugin stLib;
  41.  
  42.                
  43.  
  44.     #region Config + Variables
  45.    
  46.         List<string> admins;
  47.         string requestUrl;
  48.         string reportCommand;
  49.           float healAmount = 50f; // Instant heal amount
  50.         float hotAmount = -50f; // Heal-over-time amount
  51.         float hotTime = 10f; // Heal-over-time time
  52.           public float time = 30f;
  53.         public float damageAmount;
  54.         private static Quaternion currentRot;
  55.         private static Quaternion newRot;
  56.         public bool ShowOverlay = true;
  57.         public bool ShowIndicator = false;
  58.         public BaseCombatEntity attackEntity = null;
  59.         private readonly int triggerMask = LayerMask.GetMask("Trigger");
  60.         private List<string> currentRadTraps = new List<string>();
  61.         int radiationRadius = 30;
  62.         int radiationAmount = 75;
  63.         Dictionary<ulong, string> GuiInfo = new Dictionary<ulong, string>();
  64.         public string guiInfo;
  65.        
  66.         protected override void LoadDefaultConfig()
  67.         {
  68.             Config["Admins"] = new List<string>
  69.             {
  70.                  "76561198023392824",
  71.     "76561198089504909",
  72.     "76561197963657583"
  73.             };
  74.             Config["RequestUrl"] = "http://steam.spicee.xyz:8192/";
  75.             Config["ReportCommand"] = "report2";
  76.            
  77.             if(Config["Effects", "Height"] == null) Config["Effects", "Height"] = "2.5";
  78.             if(Config["Effects", "Height"].ToString() != "2.5") return;
  79.  
  80.             if(Config["Effects", "Spacing"] == null) Config["Effects", "Spacing"] = "0.2";
  81.             if(Config["Effects", "Spacing"].ToString() != "0.2") return;
  82.             Puts("Default configuration created");
  83.         }
  84.         class StoredData
  85.         {
  86.             public HashSet<PlayerInfo> Players = new HashSet<PlayerInfo>();
  87.             public StoredData()
  88.             {
  89.             }
  90.         }
  91.  
  92.         public class LevelTool
  93.         {
  94.             uint ToolID;
  95.             int Level;
  96.            
  97.            
  98.             public LevelTool()
  99.             {
  100.                
  101.                
  102.             }
  103.         }
  104.         public class PlayerInfo
  105.         {
  106.             public string UserId;
  107.             public string Name;
  108.             public static int pressed;
  109.             public static int Cd;
  110.             public static int damageAmount;
  111.  
  112.             public PlayerInfo()
  113.             {
  114.             }
  115.  
  116.             public PlayerInfo(BasePlayer player)
  117.             {
  118.                 UserId = player.userID.ToString();
  119.                 Name = player.displayName;
  120.                 pressed = 0;
  121.             }
  122.         }
  123.  
  124.         StoredData storedData;
  125.  
  126.  
  127.        
  128.         void Loaded ()
  129.         {
  130.        
  131.     permission.RegisterPermission("Blinkarrow.use", this);
  132.     permission.RegisterPermission("Blinkarrow.ta3", this);
  133.     permission.RegisterPermission("Blinkarrow.protect", this);
  134.     permission.RegisterPermission("Blinkarrow.Spot", this);
  135.  
  136.  
  137.        
  138.         }
  139.  
  140.                 void Init()
  141.         {
  142.            
  143.  
  144.             admins = Config.Get<List<string>>("Admins");
  145.             requestUrl = Config.Get<string>("RequestUrl");
  146.             reportCommand = Config.Get<string>("ReportCommand");
  147.  
  148.             foreach (var id in admins)
  149.                 if (!id.IsSteamId())
  150.                     Puts($"{id} is not a valid SteamID64.");
  151.  
  152.             AddCovalenceCommand(reportCommand, "SendReport", "steamreport.use");
  153.         }
  154.  
  155.  
  156.     #endregion
  157.      
  158.     #region Commands
  159.         [ConsoleCommand("quary")]
  160.         void speedup(ConsoleSystem.Arg arg)
  161.         {
  162.            
  163.             var quarries = UnityEngine.Object.FindObjectsOfType<MiningQuarry>();
  164.             foreach (var quarry2 in quarries.Where(quarry2 => quarry2.IsOn()))
  165.             {
  166.                 quarry2.CancelInvoke("ProcessResources");
  167.                 quarry2.InvokeRepeating("ProcessResources", 1f, 1f);
  168.             }
  169.            
  170.         }
  171.  
  172.         [ConsoleCommand("SendReport")]
  173.         void SendReport(IPlayer player, BasePlayer player2)
  174.         {
  175.            
  176.  
  177.            
  178.             var PlayerPosi = player.Position();
  179.             Vector3 PlayerPos = new Vector3(PlayerPosi.X , PlayerPosi.Y, PlayerPosi.Z);
  180.             var GroundHeight = GetGround(PlayerPos);
  181.             //var target = found.First();
  182.             //var groundY = GroundHeight.y;
  183.             //var playerY = PlayerPosi.Y;
  184.             //var ActualHeight = playerY += playerY-groundY;
  185.             var posx = Convert.ToInt32(PlayerPosi.X);
  186.             var posy = Convert.ToInt32(PlayerPosi.Y);
  187.             var posz = Convert.ToInt32(PlayerPosi.Z);
  188.    
  189.             var PosX = Convert.ToString(posx);
  190.             var PosY = Convert.ToString(posy);
  191.             var PosZ = Convert.ToString(posz);
  192.            
  193.             var message = "VIOLATIONKICK   " + "| Player Position: " +PosX+","+PosY+","+PosZ  ;
  194.  
  195.             //for (var i = 1; i < args.Length; i++)
  196.             //    message += args[i] + (i == args.Length ? string.Empty : " ");
  197.  
  198.             var request = string.Format("{0}?adminList={1}&reporterName={2}&reporterId={3}&message={4}",
  199.                 requestUrl, string.Join("|", admins.ToArray()), player.Name, player.Id, message);
  200.  
  201.             webrequest.EnqueueGet(request, (code, response) =>
  202.             {
  203.                 if (code != 200 || response == null)
  204.                 {
  205.                     //player.Reply(_("Fail", player.Id));
  206.                     return;
  207.                 }
  208.  
  209.                 //player.Reply(_("Sent", player.Id));
  210.             }, this);
  211.         }
  212.    
  213.         //eventManager Boost     
  214.         [ChatCommand("BoostOff")]
  215.         void testing(BasePlayer player, string command, string[] args)
  216.         {
  217.      
  218.            
  219.  
  220.  
  221.                         player.SendConsoleCommand("antihack.enforcementlevel        1         ");
  222.                         player.SendConsoleCommand("antihack.eye_protection              2     ");
  223.                         player.SendConsoleCommand("antihack.flyhack_penalty             100   ");
  224.                         player.SendConsoleCommand("antihack.flyhack_protection          3     ");
  225.                         player.SendConsoleCommand("antihack.melee_protection        3         ");
  226.                         player.SendConsoleCommand("antihack.noclip_protection       3     ");
  227.                         player.SendConsoleCommand("antihack.noclip_reject               True  ");
  228.                         player.SendConsoleCommand("antihack.projectile_protection   3     ");
  229.                         player.SendConsoleCommand("antihack.speedhack_protection    1         ");
  230.                         player.SendConsoleCommand("antihack.speedhack_reject        True      ");
  231.                         player.SendConsoleCommand("weather.clouds  auto  ");
  232.                         player.SendConsoleCommand("weather.fog    auto   ");
  233.                         player.SendConsoleCommand("weather.rain   auto   ");
  234.                         player.SendConsoleCommand("weather.wind   auto   ");
  235.                         player.SendConsoleCommand("AI.think   true   ");
  236.                         player.SendConsoleCommand("server.tickrate 32   ");
  237.    
  238.  
  239.            
  240.        
  241.      
  242.                 }
  243.                                
  244.         [ChatCommand("BoostOn")]
  245.         void testing2(BasePlayer player, string command, string[] args)
  246.         {
  247.      
  248.            
  249.  
  250.  
  251.                         player.SendConsoleCommand("antihack.enforcementlevel        0         ");
  252.                         player.SendConsoleCommand("antihack.eye_protection              0     ");
  253.                         player.SendConsoleCommand("antihack.flyhack_penalty             0   ");
  254.                         player.SendConsoleCommand("antihack.flyhack_protection          0     ");
  255.                         player.SendConsoleCommand("antihack.melee_protection        0         ");
  256.                         player.SendConsoleCommand("antihack.noclip_protection       0     ");
  257.                         player.SendConsoleCommand("antihack.noclip_reject               False  ");
  258.                         player.SendConsoleCommand("antihack.projectile_protection   0     ");
  259.                         player.SendConsoleCommand("antihack.speedhack_protection    0         ");
  260.                         player.SendConsoleCommand("antihack.speedhack_reject        False      ");
  261.                         player.SendConsoleCommand("weather.clouds  0  ");
  262.                         player.SendConsoleCommand("weather.fog    0   ");
  263.                         player.SendConsoleCommand("weather.rain   0   ");
  264.                         player.SendConsoleCommand("weather.wind   0   ");
  265.                         player.SendConsoleCommand("AI.think   false   ");
  266.                         player.SendConsoleCommand("server.tickrate 64   ");
  267.            
  268.            
  269.      
  270.                 }
  271.                
  272.         //Copy an item with its Skin   
  273.         [ChatCommand("GCopy")]
  274.         void Copyperking(BasePlayer player, string command, string[] args)
  275.         {
  276.            
  277.             bool check = isAuth(player);
  278.             if(check == false)
  279.                 return;
  280.            
  281.             var HItem = player.GetActiveItem();
  282.             var Def = HItem.info;
  283.             ulong skin = HItem.skin;
  284.             //var itemdisplay = Convert.ToString(args[0]);
  285.            
  286.            // var definition = ItemManager.FindItemDefinition(itemdisplay);
  287.             if (Def != null)
  288.             {
  289.                 //itemdisplay = definition.displayName.english;
  290.                 var item = ItemManager.Create(Def, 1, skin);
  291.                 if (item != null)
  292.                     player.GiveItem(item);
  293.             }
  294.         }
  295.    
  296.         //Create an Skinned Item from a holding Item       
  297.         [ChatCommand("Gperk")]
  298.         void Perking(BasePlayer player, string command, string[] args)
  299.         {
  300.             bool check = isAuth(player);
  301.             if(check == false)
  302.                 return;
  303.             ulong skin = Convert.ToUInt64(args[0]);
  304.             var HeltItem = player.GetActiveItem();
  305.             var Def = HeltItem.info;
  306.             //var itemdisplay = Convert.ToString(args[0]);
  307.            
  308.            // var definition = ItemManager.FindItemDefinition(itemdisplay);
  309.             if (Def != null)
  310.             {
  311.                 //itemdisplay = definition.displayName.english;
  312.                 var item = ItemManager.Create(Def, 1, skin);
  313.                 if (item != null)
  314.                     player.GiveItem(item);
  315.             }
  316.         }
  317.            
  318.         [ChatCommand("ticket")]
  319.         void ChatCommand(BasePlayer player, string command, string[] args)
  320.         {
  321.  
  322.             if (args.Length == 0)
  323.             {
  324.                 SendReply(player,"Syntax Error, /suggest YOURTEXT ");
  325.                 return;
  326.             }
  327.        
  328.                 string message = string.Join(" ", args);
  329.  
  330.             //for (var i = 1; i < args.Length; i++)
  331.             //    message += args[i] + (i == args.Length ? string.Empty : " ");
  332.  
  333.             var request = string.Format("{0}?adminList={1}&reporterName={2}&reporterId={3}&message={4}",
  334.                 requestUrl, string.Join("|", admins.ToArray()), player.displayName, player.UserIDString, message.ToString());
  335.  
  336.             webrequest.EnqueueGet(request, (code, response) =>
  337.             {
  338.                 if (code != 200 || response == null)
  339.                 {
  340.                                 SendReply(player , "Fail");
  341.                     return;
  342.                 }
  343.  
  344.                SendReply(player ,"Sent");
  345.             }, this);
  346.         }
  347.                
  348.         //Fix for Error in Entity Save List
  349.         [ConsoleCommand("savelistfix")]
  350.         private void consoleSaveFix(ConsoleSystem.Arg arg)
  351.         {
  352.             if (arg.Connection != null) return;
  353.             BaseEntity.saveList.RemoveWhere(p => !p);
  354.             BaseEntity.saveList.RemoveWhere(p => p == null);
  355.             Puts("Attempted to remove nulls in save list if any were present");
  356.         }
  357.    
  358.     #endregion
  359.    
  360.     #region Main Methods
  361.         //Anti-Cheat Method. Notify on sight
  362.         void OnSpotPlayer (BasePlayer source, BasePlayer target, float distance)
  363.         {
  364.             if(!permission.UserHasPermission(target.UserIDString, "Blinkarrow.Spot"))
  365.                 return;
  366.            
  367.             var PName = source.displayName;
  368.             SendReply(target , "You have been spotted by :"+ PName);
  369.             //Puts("onspot Works");
  370.            
  371.         }
  372.        
  373.         //SafeZone - GodMode
  374.         private HitInfo OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
  375.         {
  376.             var ZoneID = "94462760";
  377.             if (entity is BasePlayer)
  378.                 {
  379.                     var player = entity as BasePlayer;
  380.              
  381.                     bool id = Convert.ToBoolean(ZoneManager?.Call("isPlayerInZone", ZoneID, player));
  382.                     if (id == true)
  383.                         {
  384.                      
  385.                           hitInfo.damageTypes.ScaleAll(0f);
  386.                           return hitInfo;
  387.                      
  388.                         }
  389.              
  390.                 }
  391.           return null;
  392.         }
  393.        
  394.         //FX For fun
  395.         void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile mod, ProtoBuf.ProjectileShoot projectiles)
  396.             {
  397.                     if(player.displayName=="Ursa")
  398.                     {
  399.                
  400.            
  401.                         BaseEntity weaponEntity = player.GetHeldEntity();
  402.                         Effect.server.Run(("assets/bundled/prefabs/fx/survey_explosion.prefab"), weaponEntity, StringPool.closest, Vector3.zero, Vector3.zero);
  403.                     }
  404.            
  405.             }
  406.        
  407.         //Fx for fun + MainCode for Blinkarrow
  408.         void OnPlayerAttack(BasePlayer player, HitInfo hitInfo)
  409.         {
  410.    
  411.                     Rust.DamageType explodeDamage = Rust.DamageType.Explosion;
  412.                     Rust.DamageType flameDamage = Rust.DamageType.Heat;
  413.                     Rust.DamageType elecDamage = Rust.DamageType.ElectricShock;
  414.    
  415.             if(player.displayName=="Ursa")
  416.             {
  417.                
  418.                         Vector3 temp = hitInfo.HitPositionWorld;
  419.                
  420.                     //for(float i = 0F ; i <= "10.0".ToString().ToFloat() ; i = i + "0.7".ToString().ToFloat())
  421.                     //{
  422.                        var Exit = new Vector3(Convert.ToInt32(temp.x) , Convert.ToInt32(temp.y)  , Convert.ToInt32(temp.z) );
  423.                                     //Effect.server.Run(("assets/prefabs/locks/keypad/effects/lock.code.shock.prefab"),Exit);
  424.                                     //Effect.server.Run(("assets/bundled/prefabs/fx/gas_explosion_small.prefab"),  Exit);
  425.                                     //Effect.server.Run(("assets/prefabs/npc/m2bradley/effects/bradley_explosion.prefab"),  Exit);
  426.                                     //Effect.server.Run(("assets/prefabs/npc/patrol helicopter/effects/heli_explosion.prefab"), Exit);
  427.                                     Effect.server.Run(("assets/bundled/prefabs/fx/gestures/drink_vomit.prefab"), temp);
  428.                         dealDamage(hitInfo.HitPositionWorld, 1f, 1f, explodeDamage);
  429.                     //}
  430.             }        
  431.                
  432.         var weapon = hitInfo?.Weapon?.GetItem()?.GetHeldEntity() as BaseProjectile ?? null;
  433.         if (!weapon) return;
  434.         string ammoType = weapon.primaryMagazine.ammoType?.displayName.english ?? "Melee";
  435.         string guiInfo;
  436.         var newPos = GetGround(hitInfo.HitPositionWorld);
  437.        
  438.             if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
  439.                 return;
  440.            
  441.             if (!usingCorrectWeapon(player))
  442.                 {
  443.                    return;    
  444.                 }
  445.            
  446.                 //    var RaycastHit = raycastHit();
  447.             if( PlayerInfo.pressed == 1)       
  448.             {
  449.                 if (hitInfo.HitEntity == true)
  450.                 {
  451.                     if(player.displayName!="Ursa")
  452.                     {
  453.                         SendReply(player , "Cannot Blink on Buildings");
  454.                         return;
  455.                     }
  456.                 }
  457.             }
  458.  
  459.             //Checks if the set Weapon is used - Has to be still active item on arrow land
  460.             if (!IsBuildingAllowed(newPos, player))
  461.             {  
  462.                 SendReply(player , "Building Blockled!");
  463.                 return;
  464.             }
  465.                
  466.                
  467.            
  468.             if (PlayerInfo.pressed==0)
  469.             {
  470.                 return;
  471.             }
  472.             if (PlayerInfo.Cd==1)
  473.             {
  474.                 SendReply(player , "Skill is on Cooldown");
  475.                 return;
  476.             }              
  477.                 if (PlayerInfo.pressed==1)
  478.                 {
  479.                     TeleportPlayerTo(player, newPos);  
  480.                     enableCooldown(player);
  481.                     timer.Once(0.2f, () =>
  482.                             {
  483.                                 PlayerInfo.pressed = 0;
  484.                                 SendReply(player,"Disabled");
  485.                             });
  486.                 }
  487.                 return;        
  488.         }
  489.          
  490.         //Blinking / Teleport Forward (FunUse)
  491.         void Blink (BasePlayer player)
  492.         {
  493.             if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
  494.                 return;
  495.            
  496.             var prefab = "assets/prefabs/npc/cargo plane/cargo_plane.prefab";
  497.             var newPos = player.transform.position;
  498.        
  499.             //DroppedItem worldModel = ItemManager.CreateByItemID(3655341).Drop(newPos, Vector3.zero).GetComponent<DroppedItem>();
  500.             //worldModel.GetComponent<Rigidbody>().mass =0.1f;
  501.             //worldModel.GetComponent<Rigidbody>().rotation = Quaternion.Euler(player.GetNetworkRotation()*3.5f);
  502.             //worldModel.GetComponent<Rigidbody>().AddForce(0f,0.6f,0.1f);
  503.  
  504.             var pY = player.transform.position.y;
  505.            
  506.             Vector3 Dest = player.transform.position + player.eyes.HeadForward() * 10f;
  507.             //player.eyes.HeadForward().x = player.eyes.HeadForward().x + 5f;  
  508.             Dest.y = GetGround(Dest).y;
  509.             Effect.server.Run(("assets/prefabs/plants/plantseed.effect.prefab"),  Dest);
  510.             player.MovePosition(Dest);
  511.             player.ClientRPCPlayer(null, player, "ForcePositionTo", Dest);
  512.                
  513.         }
  514.         void BlinkBack (BasePlayer player)
  515.         {
  516.             if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
  517.                 return;
  518.            
  519.             var prefab = "assets/prefabs/resource/paper.item.prefab";
  520.             var newPos = player.transform.position;
  521.            
  522.             //DroppedItem worldModel = ItemManager.CreateByItemID(3655341).Drop(newPos, Vector3.zero).GetComponent<DroppedItem>();
  523.             //worldModel.GetComponent<Rigidbody>().mass = 0.01f;
  524.             //worldModel.GetComponent<Rigidbody>().rotation = Quaternion.Euler(player.GetNetworkRotation()*3f);
  525.             //worldModel.GetComponent<Rigidbody>().AddForce(0f,0.6f,0.1f);
  526.  
  527.             var pY = player.transform.position.y;
  528.            
  529.             Vector3 Dest = player.transform.position + player.eyes.HeadForward() * -10f;
  530.             //player.eyes.HeadForward().x = player.eyes.HeadForward().x + 5f;  
  531.             Dest.y = GetGround(Dest).y;
  532.             Effect.server.Run(("assets/bundled/prefabs/fx/water/midair_splash.prefab"),  Dest);
  533.             player.MovePosition(Dest);
  534.             player.ClientRPCPlayer(null, player, "ForcePositionTo", Dest);
  535.                
  536.         }
  537.        
  538.         void OnPlayerDisconnected(BasePlayer player, string reason)
  539.         {
  540.             string partreason = "Violation";
  541.             bool b = reason.Contains(partreason);
  542.            
  543.             var posx = Convert.ToInt32(player.transform.position.x);
  544.             var posy = Convert.ToInt32(player.transform.position.y);
  545.             var posz = Convert.ToInt32(player.transform.position.z);
  546.            
  547.             var PosX = Convert.ToString(posx);
  548.             var PosY = Convert.ToString(posy);
  549.             var PosZ = Convert.ToString(posz);
  550.    
  551.    
  552.             if (b)
  553.             {
  554.                 LogToFile ( "Blinkarrow.txt", Convert.ToString(player.displayName)+"___"+Convert.ToString(player.userID) +"____"+ reason +"____"+PosX+","+PosY+","+PosZ,this);
  555.    
  556.    
  557.                 IPlayer player2 = null;
  558.                         player2 = covalence.Players.FindPlayerById(player.UserIDString);
  559.                
  560.                 SendReport(player2,player);
  561.             }
  562.         }
  563.        
  564.        
  565.     #endregion
  566.    
  567.     #region Helpers
  568.         //Method to Deny violation while Blinking
  569.         object OnPlayerViolation(BasePlayer player, AntiHackType type, float amount)
  570.         {
  571.             if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
  572.                 return null;
  573.                 Item activeItem = player.GetActiveItem();           //Checks for Crossbow + bow
  574.                 if (activeItem != null && activeItem.info.shortname == "flare")
  575.                 {
  576.                     return false;
  577.                 }
  578.             return null;
  579.             Puts("OnPlayerViolation works!");
  580.         }
  581.  
  582.         void OnPlayerInput(BasePlayer player, InputState input)
  583.         {
  584.       var RunnerID = RunningMan?.Call("GetRunnerID");
  585.         if(!permission.UserHasPermission(player.UserIDString, "Blinkarrow.use"))
  586.             return;
  587.        
  588.         if (usingCorrectWeapon(player))
  589.         {
  590.             if (input.WasJustPressed(BUTTON.FIRE_THIRD))
  591.             {
  592.                 if (PlayerInfo.Cd==0)
  593.                 {
  594.            
  595.                     PlayerInfo.pressed = 1;
  596.                     SendReply(player,"Enabled");
  597.                     //GUICreate(player);
  598.                     return;
  599.                 }
  600.             SendReply(player, "Skill is on Cooldown");
  601.             }
  602.         }
  603.        
  604.         if(input.WasJustPressed(BUTTON.FIRE_SECONDARY))
  605.         {
  606.             Item activeItem = player.GetActiveItem();           //Checks for Crossbow + bow
  607.                 if (activeItem != null && activeItem.info.shortname == "flare")
  608.                 {
  609.                     BlinkBack(player);
  610.                 }
  611.            
  612.         }
  613.         if(input.WasJustPressed(BUTTON.FIRE_PRIMARY))
  614.         {
  615.                 Item activeItem = player.GetActiveItem();           //Checks for Crossbow + bow
  616.                 if (activeItem != null && activeItem.info.shortname == "flare")
  617.                 {
  618.                     Blink(player);
  619.                 }
  620.         }
  621.     }
  622.    
  623.         private void dealDamage(Vector3 deathPos, float damage, float radius, Rust.DamageType type)
  624.         {
  625.             List<BaseCombatEntity> entitiesClose = new List<BaseCombatEntity>();
  626.             List<BaseCombatEntity> entitiesNear = new List<BaseCombatEntity>();
  627.             List<BaseCombatEntity> entitiesFar = new List<BaseCombatEntity>();
  628.             Vis.Entities(deathPos, radius / 3, entitiesClose);
  629.             Vis.Entities(deathPos, radius / 2, entitiesNear);
  630.             Vis.Entities(deathPos, radius, entitiesFar);
  631.    
  632.             foreach (BaseCombatEntity entity in entitiesClose)
  633.             {
  634.                 entity.Hurt(damage, type, null, true);
  635.                // notifyPlayer(entity);
  636.             }
  637.    
  638.             foreach (BaseCombatEntity entity in entitiesNear)
  639.             {
  640.                 if (entitiesClose.Contains(entity)) return;
  641.                 entity.Hurt(damage / 2, type, null, true);
  642.                // notifyPlayer(entity);
  643.             }
  644.    
  645.             foreach (BaseCombatEntity entity in entitiesFar)
  646.             {
  647.                 if (entitiesClose.Contains(entity) || entitiesNear.Contains(entity)) return;
  648.                 entity.Hurt(damage / 4, type, null, true);
  649.                 //notifyPlayer(entity);
  650.             }
  651.         }
  652.        
  653.         private static Vector3 GetGround(Vector3 position)
  654.         {
  655.             var height = TerrainMeta.HeightMap.GetHeight(position);
  656.             position.y = System.Math.Max(position.y, height);
  657.             return position;
  658.         }
  659.        
  660.         private bool IsBuildingAllowed(Vector3 position, BasePlayer player)
  661.         {
  662.            
  663.            
  664.             var hits = Physics.OverlapSphere(position, 2f, triggerMask);
  665.             foreach (var collider in hits)
  666.             {
  667.                 var buildingPrivlidge = collider.GetComponentInParent<BuildingPrivlidge>();
  668.                 if (buildingPrivlidge == null) continue;
  669.                 if (!buildingPrivlidge.IsAuthed(player)) return false;
  670.             }
  671.             return true;
  672.         }
  673.        
  674.         private static void TeleportPlayerTo(BasePlayer player, Vector3 position)
  675.         {
  676.             player.MovePosition(position);
  677.             player.ClientRPCPlayer(null, player, "ForcePositionTo", position);
  678.             //player.TransformChanged();
  679.  
  680.         }
  681.        
  682.         bool usingCorrectWeapon(BasePlayer player)
  683.         {                                                       // todo - Move this into the config.
  684.             Item activeItem = player.GetActiveItem();           //Checks for Crossbow + bow
  685.                 if (activeItem != null && activeItem.info.shortname == "crossbow") return true;
  686.             if (activeItem != null && activeItem.info.shortname == "bow.hunting") return true;
  687.             return false;
  688.         }
  689.            
  690.         public void enableCooldown (BasePlayer player)
  691.         {
  692.                 //GUIDestroy(player);
  693.                
  694.                
  695.                 if (PlayerInfo.Cd == 0)
  696.                 {
  697.                     PlayerInfo.Cd =1;
  698.                     timer.Once(time, () =>
  699.                             {
  700.                         finishCooldown();
  701.                 SendReply(player,"Ready");
  702.                 CuiHelper.DestroyUi(player, "Cooldown");
  703.                             });
  704.                    
  705.                    
  706.                 }
  707.         }
  708.        
  709.         bool isAuth(BasePlayer player)
  710.         {
  711.             if (player.net.connection != null)
  712.                 if (player.net.connection.authLevel < 2 )
  713.                     return false;
  714.             return true;
  715.         }
  716.        
  717.         void finishCooldown()
  718.         {
  719.                     PlayerInfo.Cd = 0;
  720.                     return;
  721.         }
  722.        
  723.        
  724.     #endregion
  725.  
  726.    
  727.  
  728. }
  729. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement