Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.26 KB | None | 0 0
  1. // Reference: UnityEngine.UI
  2.  
  3. using System;
  4. using System.Reflection;
  5. using Assets.Scripts.Core;
  6. using UnityEngine;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using uLink;
  10.  
  11. namespace Oxide.Plugins
  12. {
  13.     [Info("Trap", "WolfPack", 0.1)]
  14.     [Description("Raycasts for TrapFoundations and spawns TrapItems on Hit")]
  15.  
  16.     class Trap : HurtworldPlugin
  17.     {
  18.         private void Loaded()
  19.         {
  20.             Puts("Plugin loaded");
  21.         }
  22.         void OnPlayerInput(PlayerSession session, InputControls input)
  23.         {
  24.             if (input.Forward
  25.             || input.Backward
  26.             || input.StrafeLeft
  27.             || input.StrafeRight
  28.             || input.Sprint
  29.             || input.Crouch)
  30.             {
  31.                 // Puts("Player imput works");
  32.                 StartTrap(session);
  33.             }
  34.         }
  35.  
  36.  
  37.         void StartTrap(PlayerSession session)
  38.         {
  39.             // Puts("Calling Void works");
  40.             // var all = Resources.FindObjectsOfTypeAll<TrapFoundation>();
  41.             string steamId = session.SteamId.ToString();
  42.             Vector3 randposition = session.WorldPlayerEntity.transform.position;
  43.  
  44.             if (!string.IsNullOrEmpty(steamId))
  45.             {
  46.               // Puts("Finding steamid works");
  47.  
  48.                 RaycastHit hitInfo;
  49.                 var rayLength = 1;
  50.  
  51.  
  52.                 if (Physics.Raycast(randposition, Vector3.down, out hitInfo, rayLength))
  53.                 {
  54.  
  55.  
  56. // SPEARTRAP
  57.                     //Check Raycast
  58.                     if (hitInfo.collider.gameObject.name.Contains("ConcreteSpear1TrapFoundation"))
  59.                     {
  60.                       // timer.Once(0f, () =>
  61.                         Puts("Spiketrap");
  62.                         hurt.SendChatMessage(session, "SPIKETRAP!!");
  63.  
  64.                         //Spawn Items Below SpikesIronDynamicServer
  65.                         var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
  66.                             "spear1DynamicServer", session.WorldPlayerEntity.transform.position,
  67.                             Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
  68.                             GameManager.GetSceneTime());
  69.  
  70.                         //     audio.PlayOneShot(landcrabArmedSound, 0.7F),
  71.                         timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
  72. }
  73.  
  74. // FIRETRAP
  75.                     //Check Raycast
  76.                     if (hitInfo.collider.gameObject.name.Contains("ConcreteFireTrapFoundation"))
  77.                     {
  78.                         //console and notifier
  79.                         Puts("Firetrap");
  80.                         hurt.SendChatMessage(session, "FIRETRAP!!");
  81.  
  82.                         //Spawn Items Below
  83.                         var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
  84.                             "FireDynamicServer", session.WorldPlayerEntity.transform.position,
  85.                             Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
  86.                             GameManager.GetSceneTime());
  87.                             //destroy items
  88.                             timer.Once(15f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
  89.  
  90.                     }
  91.  
  92. //ACID
  93.                     //Check Raycast
  94.                     if (hitInfo.collider.gameObject.name.Contains("ConcretePoisonTrapFoundation"))
  95.                     {
  96.                         //console and notifier
  97.                         Puts("Poisontrap");
  98.                         hurt.SendChatMessage(session, "BAD ACID!!");
  99.  
  100.                         //Spawn Items Below
  101.                         var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
  102.                             "TrapPoison", session.WorldPlayerEntity.transform.position,
  103.                             Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
  104.                             GameManager.GetSceneTime());
  105.  
  106.                         //destroy items
  107.                         timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
  108.  
  109.                     }
  110.  
  111. //SPEAR 2
  112.  
  113.                     //Check Raycast
  114.                     if (hitInfo.collider.gameObject.name.Contains("ConcreteSpear2TrapFoundation"))
  115.                     {
  116.                         //console and notifier
  117.                         Puts("SpikeTrap2");
  118.                         hurt.SendChatMessage(session, "SpikeTrap 2");
  119.  
  120.                         //Spawn Items Below
  121.                         var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
  122.                             "spear2DynamicServer", session.WorldPlayerEntity.transform.position,
  123.                             Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
  124.                             GameManager.GetSceneTime());
  125.  
  126.                         //destroy items
  127.                         timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
  128.  
  129.                     }
  130.  
  131. //SPEAR 3
  132.  
  133.  
  134.                     //Check Raycast
  135.                     if (hitInfo.collider.gameObject.name.Contains("ConcreteSpear3TrapFoundation"))
  136.                     {
  137.                         //console and notifier
  138.                         Puts("SpikeTrap3");
  139.                         hurt.SendChatMessage(session, "SpikeTrap 3");
  140.  
  141.                         //Spawn Items Below (alternative SpikesIronDynamicServer)
  142.                         var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
  143.                             "spear3DynamicServer", session.WorldPlayerEntity.transform.position,
  144.                             Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
  145.                             GameManager.GetSceneTime());
  146.  
  147.                         //destroy items
  148.                         timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
  149.  
  150. }
  151. //DEBUG
  152.                  if (hitInfo.collider.gameObject.name.Contains("batman"))
  153.  
  154.  
  155.                     {
  156.                         Puts("Whatever!");
  157.  
  158.                         hurt.SendChatMessage(session, "name:");
  159.                         hurt.SendChatMessage(session, hitInfo.collider.gameObject.name);
  160.                      // hurt.SendChatMessage(session, "tag:");
  161.                      // hurt.SendChatMessage(session, hitInfo.collider.gameObject.tag);
  162.                     }
  163.  
  164.                 }
  165.             }
  166.         }
  167.     }
  168. }
  169.  
  170.  
  171.  
  172. /*
  173.  
  174. Goodies from CowTrix:
  175.  
  176. StructureManager.GetAttachment(HitInfo raycastHit)
  177. //
  178.  
  179. var enumerator = OwnershipStakeServer.GetEnumerator();
  180. while(enumerator.MoveNext())
  181. {
  182. var currentStake = enumerator.Current;
  183. // Do whatever
  184. }
  185.  
  186.  
  187. // play sound
  188. if (EmissionSounds != null && EmissionSounds.Length != 0)
  189. {
  190.     AudioSource audio = meteor.GetComponent<AudioSource>();
  191.     if (audio != null)
  192.     {
  193.         int index = UnityEngine.Random.Range(0, EmissionSounds.Length);
  194.         AudioClip clip = EmissionSounds[index];
  195.         audio.PlayOneShot(clip, scale);
  196.     }
  197. }
  198. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement