-
Notifications
You must be signed in to change notification settings - Fork 0
/
R.cs
206 lines (188 loc) · 7.88 KB
/
R.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*---------------------------------------------------------------------------------------
-- SOURCE FILE: R.cs
--
-- PROGRAM: server
--
-- DATE: Feb 18, 2018
--
-- REVISIONS: Mar 27, 2018 - Refactored offsets for new packets
--
-- DESIGNERS: Alfred Swinton, Benny Wang
--
-- PROGRAMMER: Alfred Swinton, Haley Booker, Benny Wang
--
-- NOTES:
-- This is a file full of constants for use in various places in both server and client.
---------------------------------------------------------------------------------------*/
using System;
namespace R
{
// Contains all the constants associated with networking and the packet
public static class Net
{
public const ushort PORT = 42069;
public const Int32 TCP_BUFFER_SIZE = 8192;
public const ushort MAX_PLAYERS = 30;
public const ushort TIMEOUT = 30;
public const short TIMEOUT_ERRNO = -11;
// Contains constants associated with the header type of the packet
public static class Header
{
public const byte INIT_PLAYER = 0;
public const byte TICK = 85;
public const byte NEW_CLIENT = 69;
public const byte ACK = 170;
public const byte TERRAIN_DATA = 55;
public const byte SPAWN_DATA = 56;
}
// Contains constants associated with the packet offset or distance into the packet
public static class Offset
{
// Offsets for client to server packet
public const int PID = 1;
public const int X = PID + 1;
public const int Z = X + 4;
public const int R = Z + 4;
public const int WEAPON_ID = R + 4;
public const int WEAPON_TYPE = WEAPON_ID + 4;
public const int BULLET_ID = WEAPON_TYPE + 1;
public const int BULLET_TYPE = BULLET_ID + 4;
// Offsets for server to client packet
public const int DANGER_ZONE = 1;
public const int TIME = 13;
public const int HEALTH = 17;
public const int INVENTORY = 18;
public const int PLAYERS = 23;
public const int BULLETS = 443;
public const int WEAPONS = 653;
public static class Player
{
public const int ID = 0;
public const int X = 1;
public const int Z = 5;
public const int R = 9;
public const int W = 13;
}
public static class Bullet
{
public const int OWNER = 0;
public const int ID = 1;
public const int TYPE = 5;
public const int CHANGE = 6;
}
public static class Weapon
{
public const int ID = 0;
public const int CHANGE = 4;
}
}
// Contains related to size of the data being sent
public static class Size
{
// Packet sizes
public const int SERVER_TICK = 865;
public const int CLIENT_TICK = 24;
public const int PLAYER_DATA = 14;
}
}
// Contains Constants Related to the game
public static class Game
{
public const int TICK_RATE = 64;
public const double TICK_INTERVAL = (double)1000 / (double)TICK_RATE;
public const float GAME_TIMER_INIT = 900000f; // 15 mins
// Terrain Constants
public static class Terrain
{
// Define default constants
public const long DEFAULT_WIDTH = 1000;
public const long DEFAULT_LENGTH = 1000;
public const long DEFAULT_TILE_SIZE = 20;
public const long DEFAULT_COLLIDER_SIZE = 20;
// For the gun objects
public const int GUN_OBJECT_SIZE = 13;
public const int ID_BYTE_SIZE = 4;
public const int X_BYTE_SIZE = 4;
public const int Z_BYTE_SIZE = 4;
public const int INV_BYTE_SIZE = 5;
public const int BUL_BYTE_SIZE = 5;
public const int ID_OFFSET = 1;
public const int X_OFFSET = 5;
public const int Z_OFFSET = 9;
public const int INV_OFFSET = 14;
public const int BUL_OFFSET = 19;
// Changed to a percentage - ALam
public const float DEFAULT_BUSH_PERC = 0.9993f;
public const float DEFAULT_CACTUS_PERC = 0.9995f;
public const float DEFAULT_BUILDING_PERC = 0.9997f;
// Terrain name
public const string DEFAULT_NAME = "Terrain";
}
// Player Constants
public static class Players
{
public const int RADIUS = 1;
}
public static class Bullet
{
public const byte ADD = 1;
public const byte REMOVE = 0;
public const byte IGNORE = 255;
}
// Danger zone constant
public static class DangerZone
{
public const float ZONE_CENTER_POOL_WIDTH = R.Game.Terrain.DEFAULT_WIDTH - 250;
public const float ZONE_CENTER_POOL_HEIGHT = R.Game.Terrain.DEFAULT_LENGTH - 250;
public const byte ZONE_DAMAGE_PER_SEC = 5;
public const float RAD_RATE_PHASE1 = 0.5f; // ratio of radius to reduce per time unit -- phase 1
public const float RAD_RATE_PHASE2 = 0.2f; // ratio of radius to reduce per time unit -- phase 1
public const float RAD_RATE_PHASE3 = 0.3f; // ratio of radius to reduce per time unit -- phase 1
public const float TIME_UNIT_TO_SHRINK = 120000f; // milliseconds. time to shrink zone
public const float TIME_UNIT_TO_PAUSE = 60000f; // milliseconds. time amount to pause shrinking
public const float GAME_TIMER_PHASE1_START = R.Game.GAME_TIMER_INIT - R.Game.DangerZone.TIME_UNIT_TO_PAUSE;
public const float GAME_TIMER_PHASE1_END = R.Game.GAME_TIMER_INIT - R.Game.DangerZone.TIME_UNIT_TO_PAUSE - R.Game.DangerZone.TIME_UNIT_TO_SHRINK;
public const float GAME_TIMER_PHASE2_START = R.Game.GAME_TIMER_INIT - R.Game.DangerZone.TIME_UNIT_TO_PAUSE * 2 - R.Game.DangerZone.TIME_UNIT_TO_SHRINK;
public const float GAME_TIMER_PHASE2_END = R.Game.GAME_TIMER_INIT - R.Game.DangerZone.TIME_UNIT_TO_PAUSE * 2 - R.Game.DangerZone.TIME_UNIT_TO_SHRINK * 2;
public const float GAME_TIMER_PHASE3_START = R.Game.GAME_TIMER_INIT - R.Game.DangerZone.TIME_UNIT_TO_PAUSE * 3 - R.Game.DangerZone.TIME_UNIT_TO_SHRINK * 2;
public const float GAME_TIMER_PHASE3_END = R.Game.GAME_TIMER_INIT - R.Game.DangerZone.TIME_UNIT_TO_PAUSE * 3- R.Game.DangerZone.TIME_UNIT_TO_SHRINK * 3;
}
}
public static class Type
{
public const byte KNIFE = 1;
public const byte PISTOL = 2;
public const byte SHOTGUN = 3;
public const byte RIFLE = 4;
}
public static class Init
{
public const int PLAYERMULT = 8;
public const int WEAPONOFFSETID = 1;
public const int WEAPONOFFSETX = 5;
public const int WEAPONOFFSETZ = 9;
public const int COORDBYTES = 4;
public const int IDBYTES = 4;
public const int INDWPNPCKT = 13;
public const int QUOTIENTTOWNGUNS = 4;
public const int CLUSTERING = 50;
public const int TOWNHEIGHT = 500;
public const int TOWNWIDTH = 500;
public const int OCCURANCESQUARE = 12;
public const int WPN1 = 1;
public const int WPN2 = 2;
public const int WPN3 = 3;
public const int WPN4 = 4;
public const int WPN5 = 5;
public const int WPN6 = 6;
public const int WPN7 = 7;
public const int WPN8 = 8;
public const int WPN9 = 9;
public const int WPN10 = 10;
public const int WPN11 = 11;
public const int WPN12 = 12;
public const int WPN13 = 13;
public const int MAPEND = 1001;
public const double PERCENTHOTSPOT = 0.75;
}
}