Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Reference: UnityEngine.UI
- using System;
- using System.Reflection;
- using Assets.Scripts.Core;
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using uLink;
- namespace Oxide.Plugins
- {
- [Info("Trap", "WolfPack", 0.1)]
- [Description("Raycasts for TrapFoundations and spawns TrapItems on Hit")]
- class Trap : HurtworldPlugin
- {
- private void Loaded()
- {
- Puts("Plugin loaded");
- }
- void OnPlayerInput(PlayerSession session, InputControls input)
- {
- if (input.Forward
- || input.Backward
- || input.StrafeLeft
- || input.StrafeRight
- || input.Sprint
- || input.Crouch)
- {
- // Puts("Player imput works");
- StartTrap(session);
- }
- }
- void StartTrap(PlayerSession session)
- {
- // Puts("Calling Void works");
- // var all = Resources.FindObjectsOfTypeAll<TrapFoundation>();
- string steamId = session.SteamId.ToString();
- Vector3 randposition = session.WorldPlayerEntity.transform.position;
- if (!string.IsNullOrEmpty(steamId))
- {
- // Puts("Finding steamid works");
- RaycastHit hitInfo;
- var rayLength = 1;
- if (Physics.Raycast(randposition, Vector3.down, out hitInfo, rayLength))
- {
- // SPEARTRAP
- //Check Raycast
- if (hitInfo.collider.gameObject.name.Contains("ConcreteSpear1TrapFoundation"))
- {
- // timer.Once(0f, () =>
- Puts("Spiketrap");
- hurt.SendChatMessage(session, "SPIKETRAP!!");
- //Spawn Items Below SpikesIronDynamicServer
- var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
- "spear1DynamicServer", session.WorldPlayerEntity.transform.position,
- Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
- GameManager.GetSceneTime());
- // audio.PlayOneShot(landcrabArmedSound, 0.7F),
- timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
- }
- // FIRETRAP
- //Check Raycast
- if (hitInfo.collider.gameObject.name.Contains("ConcreteFireTrapFoundation"))
- {
- //console and notifier
- Puts("Firetrap");
- hurt.SendChatMessage(session, "FIRETRAP!!");
- //Spawn Items Below
- var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
- "FireDynamicServer", session.WorldPlayerEntity.transform.position,
- Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
- GameManager.GetSceneTime());
- //destroy items
- timer.Once(15f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
- }
- //ACID
- //Check Raycast
- if (hitInfo.collider.gameObject.name.Contains("ConcretePoisonTrapFoundation"))
- {
- //console and notifier
- Puts("Poisontrap");
- hurt.SendChatMessage(session, "BAD ACID!!");
- //Spawn Items Below
- var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
- "TrapPoison", session.WorldPlayerEntity.transform.position,
- Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
- GameManager.GetSceneTime());
- //destroy items
- timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
- }
- //SPEAR 2
- //Check Raycast
- if (hitInfo.collider.gameObject.name.Contains("ConcreteSpear2TrapFoundation"))
- {
- //console and notifier
- Puts("SpikeTrap2");
- hurt.SendChatMessage(session, "SpikeTrap 2");
- //Spawn Items Below
- var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
- "spear2DynamicServer", session.WorldPlayerEntity.transform.position,
- Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
- GameManager.GetSceneTime());
- //destroy items
- timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
- }
- //SPEAR 3
- //Check Raycast
- if (hitInfo.collider.gameObject.name.Contains("ConcreteSpear3TrapFoundation"))
- {
- //console and notifier
- Puts("SpikeTrap3");
- hurt.SendChatMessage(session, "SpikeTrap 3");
- //Spawn Items Below (alternative SpikesIronDynamicServer)
- var obj= Singleton<HNetworkManager>.Instance.NetInstantiate(uLink.NetworkPlayer.server,
- "spear3DynamicServer", session.WorldPlayerEntity.transform.position,
- Quaternion.Euler(0.0f, (float) UnityEngine.Random.Range(0f, 360f), 0),
- GameManager.GetSceneTime());
- //destroy items
- timer.Once(5f, ()=>{HNetworkManager.Instance.NetDestroy(obj.uLinkNetworkView());Puts("Destroyed!");});
- }
- //DEBUG
- if (hitInfo.collider.gameObject.name.Contains("batman"))
- {
- Puts("Whatever!");
- hurt.SendChatMessage(session, "name:");
- hurt.SendChatMessage(session, hitInfo.collider.gameObject.name);
- // hurt.SendChatMessage(session, "tag:");
- // hurt.SendChatMessage(session, hitInfo.collider.gameObject.tag);
- }
- }
- }
- }
- }
- }
- /*
- Goodies from CowTrix:
- StructureManager.GetAttachment(HitInfo raycastHit)
- //
- var enumerator = OwnershipStakeServer.GetEnumerator();
- while(enumerator.MoveNext())
- {
- var currentStake = enumerator.Current;
- // Do whatever
- }
- // play sound
- if (EmissionSounds != null && EmissionSounds.Length != 0)
- {
- AudioSource audio = meteor.GetComponent<AudioSource>();
- if (audio != null)
- {
- int index = UnityEngine.Random.Range(0, EmissionSounds.Length);
- AudioClip clip = EmissionSounds[index];
- audio.PlayOneShot(clip, scale);
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement