-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculatepreciseangle.cs
95 lines (77 loc) · 3.2 KB
/
calculatepreciseangle.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rocket.Core;
using Rocket.API.Collections;
using Rocket.Unturned.Events;
using Rocket.Unturned.Player;
using Rocket.Unturned.Chat;
using Rocket.Core.Plugins;
using Rocket.Core.Logging;
using SDG.Unturned;
using UnityEngine;
using Rocket.API;
using System.Reflection;
using SDG.Framework.Utilities;
namespace Random.miscstuff
{
public class calculatepreciseangle : IRocketCommand
{
public AllowedCaller AllowedCaller => AllowedCaller.Player;
public string Name => "calculatepreciseangle";
public string Help => "Calculate precise firing angle (MUST BE IN VEHICLE BINO SEAT WITH MARKER PLACED)";
public string Syntax => "/calculatepreciseangle";
public List<string> Aliases => new List<string> { "cpa" };
public List<string> Permissions => new List<string> { "calculatepreciseangle" };
//With inspiration from gaming: Tanks
public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
//dont need this
////check if player already calculating
//if (miscstuff.Instance.calcangle.ContainsKey(player.Player))
//{
// UnturnedChat.Say(player, "Already calculating!", Color.red);
// return;
//}
//just stop coroutine if found in miscstuf.cs
//check if player has marker placed
if (!player.Player.quests.isMarkerPlaced)
{
UnturnedChat.Say(player, "No Marker Placed!", Color.red);
return;
}
//Vector3 playerLocation = player.Player.look.aim.position;
//check
Vector3 markerLocation = new Vector3(player.Player.quests.markerPosition.x, player.Position.y, player.Player.quests.markerPosition.z);
//check if player is in vehicle
if (player.CurrentVehicle == null)
{
UnturnedChat.Say(player, "You are not in vehicle!", Color.red);
return;
}
var steamplayer = player.SteamPlayer();
Passenger pass = null;
foreach (Passenger passenger in player.CurrentVehicle.turrets)
{
if (passenger.player == steamplayer)
{
pass = passenger;
break;
}
}
//get the current "gun" of the player calling
ushort currentturretgun = pass.turret.itemID;
//if player isnt hoplding valid id
if (!miscstuff.Config.artycalculatorids.Contains(currentturretgun))
{
UnturnedChat.Say(player, "Current turret gun: " + currentturretgun);
UnturnedChat.Say(player, "You are not in a seat that can do that!", Color.red);
}
miscstuff.Instance.startrangefinding(caller);
//UnturnedChat.Say(player, "playerloc is " + playerLocation.ToString());
//UnturnedChat.Say(player, "turretloc is " + pass.turretAim.position.ToString());
}
}
}